Skip to content

Commit

Permalink
Merge branch 'release/2023.11.22'
Browse files Browse the repository at this point in the history
  • Loading branch information
Leopotam committed Nov 22, 2023
2 parents 8e714f2 + ab77617 commit 9848566
Show file tree
Hide file tree
Showing 3 changed files with 26 additions and 12 deletions.
2 changes: 1 addition & 1 deletion package.json
Original file line number Diff line number Diff line change
Expand Up @@ -4,7 +4,7 @@
"displayName": "LeoECS Lite",
"description": "LeoECS Lite - легковесный ECS-фреймворк, основанный на структурах. Производительность, нулевые или минимальные аллокации, минимизация использования памяти, отсутствие зависимостей от любого игрового движка - это основные цели данного фреймворка.",
"unity": "2020.3",
"version": "2023.9.22",
"version": "2023.11.22",
"keywords": [
"leoecslite",
"leoecs",
Expand Down
22 changes: 17 additions & 5 deletions src/entities.cs
Original file line number Diff line number Diff line change
Expand Up @@ -11,14 +11,26 @@

namespace Leopotam.EcsLite {
public struct EcsPackedEntity {
internal int Id;
internal int Gen;
public int Id;
public int Gen;

public override int GetHashCode () {
unchecked {
return (23 * 31 + Id) * 31 + Gen;
}
}
}

public struct EcsPackedEntityWithWorld {
internal int Id;
internal int Gen;
internal EcsWorld World;
public int Id;
public int Gen;
public EcsWorld World;

public override int GetHashCode () {
unchecked {
return ((23 * 31 + Id) * 31 + Gen) * 31 + (World?.GetHashCode () ?? 0);
}
}
#if DEBUG
// For using in IDE debugger.
internal object[] DebugComponentsView {
Expand Down
14 changes: 8 additions & 6 deletions src/worlds.cs
Original file line number Diff line number Diff line change
Expand Up @@ -616,12 +616,14 @@ public EcsFilter End (int capacity = 512) {
Array.Sort (Include, 0, IncludeCount);
Array.Sort (Exclude, 0, ExcludeCount);
// calculate hash.
Hash = IncludeCount + ExcludeCount;
for (int i = 0, iMax = IncludeCount; i < iMax; i++) {
Hash = unchecked (Hash * 314159 + Include[i]);
}
for (int i = 0, iMax = ExcludeCount; i < iMax; i++) {
Hash = unchecked (Hash * 314159 - Exclude[i]);
unchecked {
Hash = IncludeCount + ExcludeCount;
for (int i = 0, iMax = IncludeCount; i < iMax; i++) {
Hash = Hash * 314159 + Include[i];
}
for (int i = 0, iMax = ExcludeCount; i < iMax; i++) {
Hash = Hash * 314159 - Exclude[i];
}
}
var (filter, isNew) = _world.GetFilterInternal (this, capacity);
if (!isNew) { Recycle (); }
Expand Down

0 comments on commit 9848566

Please sign in to comment.