-
Notifications
You must be signed in to change notification settings - Fork 12
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
Engine - Index: simplify - changed StoreIndex to static class
- Loading branch information
Showing
6 changed files
with
48 additions
and
72 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file was deleted.
Oops, something went wrong.
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,34 @@ | ||
// Copyright (c) Ullrich Praetz - https://github.com/friflo. All rights reserved. | ||
// See LICENSE file in the project root for full license information. | ||
|
||
// ReSharper disable once CheckNamespace | ||
namespace Friflo.Engine.ECS.Index; | ||
|
||
internal static class StoreIndex | ||
{ | ||
internal static ComponentIndex GetIndex(EntityStore store, int structIndex) | ||
{ | ||
var indexMap = store.extension.indexMap; | ||
if (indexMap != null) { | ||
var index = indexMap[structIndex]; | ||
if (index != null) { | ||
return index; | ||
} | ||
return indexMap[structIndex] = CreateIndex(store, structIndex); | ||
} | ||
indexMap = store.extension.indexMap = CreateStoreIndexMap(); | ||
return indexMap[structIndex] = CreateIndex(store, structIndex); | ||
} | ||
|
||
private static ComponentIndex CreateIndex(EntityStore store, int structIndex) | ||
{ | ||
var type = EntityStoreBase.Static.EntitySchema.indexedComponentMap[structIndex]; | ||
return type.CreateComponentIndex(store); | ||
} | ||
|
||
private static ComponentIndex[] CreateStoreIndexMap() | ||
{ | ||
var schema = EntityStoreBase.Static.EntitySchema; | ||
return new ComponentIndex[schema.maxStructIndex]; // could create smaller array containing no null elements | ||
} | ||
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters