Skip to content

Commit

Permalink
Remove DesperateDevs dependencies from Entitas project
Browse files Browse the repository at this point in the history
  • Loading branch information
sschmid committed Jul 27, 2023
1 parent 1dbba27 commit 841bdf0
Show file tree
Hide file tree
Showing 7 changed files with 14 additions and 162 deletions.
1 change: 1 addition & 0 deletions src/Entitas.Unity.Editor/Entitas.Unity.Editor.csproj
Original file line number Diff line number Diff line change
Expand Up @@ -6,6 +6,7 @@
</PropertyGroup>

<ItemGroup>
<PackageReference Include="DesperateDevs.Reflection" Version="1.*" />
<PackageReference Include="DesperateDevs.Unity.Editor" Version="2.*" />
</ItemGroup>

Expand Down
19 changes: 12 additions & 7 deletions src/Entitas/Context/Context.cs
Original file line number Diff line number Diff line change
@@ -1,7 +1,6 @@
using System;
using System.Collections.Generic;
using System.Linq;
using DesperateDevs.Caching;

namespace Entitas
{
Expand Down Expand Up @@ -108,17 +107,16 @@ public Context(int totalComponents, int startCreationIndex, ContextInfo contextI
_componentPools = new Stack<IComponent>[totalComponents];
_entityIndexes = new Dictionary<string, IEntityIndex>();

var groupChangedListPool = new ObjectPool<List<GroupChanged<TEntity>>>(
() => new List<GroupChanged<TEntity>>(),
list => list.Clear()
);

var groupChangedListPool = new Stack<List<GroupChanged<TEntity>>>();
_onEntityChangedDelegate = (entity, index, component) =>
{
var groups = _groupsForIndex[index];
if (groups != null)
{
var events = groupChangedListPool.Get();
var events = groupChangedListPool.Count != 0
? groupChangedListPool.Pop()
: new List<GroupChanged<TEntity>>();
var tEntity = (TEntity)entity;
for (var i = 0; i < groups.Count; i++)
Expand All @@ -127,6 +125,7 @@ public Context(int totalComponents, int startCreationIndex, ContextInfo contextI
for (var i = 0; i < events.Count; i++)
events[i]?.Invoke(groups[i], tEntity, index, component);
events.Clear();
groupChangedListPool.Push(events);
}
};
Expand Down Expand Up @@ -238,6 +237,12 @@ public TEntity[] GetEntities()
return _entitiesCache ??= _entities.ToArray();
}

/// Returns all entities matching the specified matcher.
public TEntity[] GetEntities(IMatcher<TEntity> matcher)
{
return GetGroup(matcher).GetEntities();
}

/// Returns a group for the specified matcher.
/// Calling context.GetGroup(matcher) with the same matcher will always
/// return the same instance of the group.
Expand Down
23 changes: 0 additions & 23 deletions src/Entitas/Context/ContextExtension.cs

This file was deleted.

2 changes: 1 addition & 1 deletion src/Entitas/Context/IContext.cs
Original file line number Diff line number Diff line change
Expand Up @@ -41,7 +41,7 @@ public interface IContext<TEntity> : IContext where TEntity : Entity

bool HasEntity(TEntity entity);
TEntity[] GetEntities();

TEntity[] GetEntities(IMatcher<TEntity> matcher);
IGroup<TEntity> GetGroup(IMatcher<TEntity> matcher);
}
}
5 changes: 0 additions & 5 deletions src/Entitas/Entitas.csproj
Original file line number Diff line number Diff line change
Expand Up @@ -12,9 +12,4 @@
</EmbeddedResource>
</ItemGroup>

<ItemGroup>
<PackageReference Include="DesperateDevs.Caching" Version="1.*" />
<PackageReference Include="DesperateDevs.Reflection" Version="1.*" />
</ItemGroup>

</Project>
29 changes: 0 additions & 29 deletions src/Entitas/Extensions/PublicMemberInfoEntityExtension.cs

This file was deleted.

97 changes: 0 additions & 97 deletions tests/Entitas.Tests/PublicMemberInfoEntityExtensionTests.cs

This file was deleted.

0 comments on commit 841bdf0

Please sign in to comment.