Skip to content

Commit

Permalink
Update
Browse files Browse the repository at this point in the history
-> EntityComposer Removed.
-> Use Method(in ent entity, Actor actor = null) in Model classes
-> Use Set method instead of Add inside of Model methods
  • Loading branch information
Pixeye committed May 31, 2019
1 parent d2f0ede commit fe5e5fd
Showing 1 changed file with 17 additions and 20 deletions.
37 changes: 17 additions & 20 deletions Runtime/LibEcs/BufferTags.cs
Original file line number Diff line number Diff line change
Expand Up @@ -35,7 +35,7 @@ public unsafe struct BufferTags
public byte length;

public int Length => length;

public void Clear()
{
for (int i = 0; i < length; i++)
Expand Down Expand Up @@ -164,13 +164,11 @@ public static void ClearTags(in this ent entity)
Entity.tags[entity.id].Clear();
}



public static void Add(in this ent entity, int tagID)
{
ref var buffer = ref Entity.tags[entity.id];
int len = buffer.length;
var tID = (ushort) tagID;
int len = buffer.length;
var tID = (ushort) tagID;

for (int index = 0; index < len; index++)
{
Expand All @@ -184,27 +182,26 @@ public static void Add(in this ent entity, int tagID)
return;
}
}



#if UNITY_EDITOR
if (len == BufferTags.Capacity)
{
throw new Exception("Tags limit reached!");
}
#endif

buffer.SetElement(buffer.length, tagID);
HandleChange(entity, tagID);
}

public static void Add(in this ent entity, params int[] tagsID)
{
ref var buffer = ref Entity.tags[entity.id];
int len = buffer.length;
int len = buffer.length;

for (int i = 0; i < tagsID.Length; i++)
{
var tID = (ushort) tagsID[i];
var tID = (ushort) tagsID[i];
var allowToAdd = true;

for (int index = 0; index < len; index++)
Expand Down Expand Up @@ -234,11 +231,11 @@ public static void Add(in this ent entity, params int[] tagsID)
}

[MethodImpl(MethodImplOptions.AggressiveInlining)]
internal static void Set(in this ent entity, int tagID)
public static void Set(in this ent entity, int tagID)
{
ref var buffer = ref Entity.tags[entity.id];
int len = buffer.length;
var tID = (ushort) tagID;
int len = buffer.length;
var tID = (ushort) tagID;
for (int index = 0; index < len; index++)
{
if (buffer.tags[index] == tID)
Expand All @@ -263,15 +260,15 @@ internal static void Set(in this ent entity, int tagID)
}

[MethodImpl(MethodImplOptions.AggressiveInlining)]
internal static void Set(in this ent entity, params int[] tagsID)
public static void Set(in this ent entity, params int[] tagsID)
{
ref var buffer = ref Entity.tags[entity.id];

int len = buffer.length;

for (int i = 0; i < tagsID.Length; i++)
{
var tID = (ushort) tagsID[i];
var tID = (ushort) tagsID[i];
var allowToAdd = true;
for (int index = 0; index < len; index++)
{
Expand Down Expand Up @@ -301,7 +298,7 @@ internal static void Set(in this ent entity, params int[] tagsID)
public static void Remove(in this ent entity, int tagID)
{
ref var buffer = ref Entity.tags[entity.id];
int len = buffer.length;
int len = buffer.length;
for (int index = 0; index < len; index++)
{
if (buffer.tags[index] == tagID)
Expand All @@ -319,7 +316,7 @@ public static void Remove(in this ent entity, int tagID)
public static void RemoveAll(in this ent entity, params int[] tagsID)
{
ref var buffer = ref Entity.tags[entity.id];
var len = buffer.length;
var len = buffer.length;

for (int i = 0; i < tagsID.Length; i++)
{
Expand All @@ -340,8 +337,8 @@ public static void RemoveAll(in this ent entity, params int[] tagsID)
public static void RemoveAll(in this ent entity, int tagID)
{
ref var buffer = ref Entity.tags[entity.id];
int len = buffer.length;
var tID = (ushort) tagID;
int len = buffer.length;
var tID = (ushort) tagID;

for (int index = 0; index < len; index++)
{
Expand Down Expand Up @@ -376,7 +373,7 @@ public static bool HasAny(in this ent entity, params int[] tagsID)
internal static void Add(GroupCore groupCore)
{
DictionaryGroup container;
var composition = groupCore.composition;
var composition = groupCore.composition;
foreach (var tagID in composition.includeTags)
{
if (inUseGroups.TryGetValue(tagID, out container))
Expand Down

0 comments on commit fe5e5fd

Please sign in to comment.