Skip to content

Commit

Permalink
update
Browse files Browse the repository at this point in the history
  • Loading branch information
Pixeye committed May 30, 2019
1 parent 765d4c2 commit dcf865f
Show file tree
Hide file tree
Showing 2 changed files with 13 additions and 7 deletions.
18 changes: 12 additions & 6 deletions Runtime/LibProcessors/ProcessorGroups.cs
Original file line number Diff line number Diff line change
Expand Up @@ -16,9 +16,9 @@ public sealed class ProcessorGroups

public static void Setup(object b)
{
var type = b.GetType();
var type = b.GetType();
var objectFields = type.GetFields(BindingFlags.Instance | BindingFlags.Public | BindingFlags.NonPublic | BindingFlags.Static);
int length = objectFields.Length;
int length = objectFields.Length;

var groupType = typeof(GroupCore);

Expand All @@ -30,7 +30,7 @@ public static void Setup(object b)
if (bindAttribute != null)
{
var fType = myFieldInfo.FieldType;
var hash = fType.GetHashCode();
var hash = fType.GetHashCode();

if (!DataSession.binds.TryGetValue(hash, out object o))
{
Expand All @@ -42,7 +42,7 @@ public static void Setup(object b)
}
else if (myFieldInfo.FieldType.IsSubclassOf(groupType))
{
var groupByAttribute = Attribute.GetCustomAttribute(myFieldInfo, typeof(GroupByAttribute)) as GroupByAttribute;
var groupByAttribute = Attribute.GetCustomAttribute(myFieldInfo, typeof(GroupByAttribute)) as GroupByAttribute;
var groupExcludeAttribute = Attribute.GetCustomAttribute(myFieldInfo, typeof(GroupExcludeAttribute)) as GroupExcludeAttribute;

var includeTagsFilter = groupByAttribute != null ? groupByAttribute.filter : new int[0];
Expand All @@ -60,18 +60,24 @@ public static void Setup(object b)
composition.AddTypesExclude(excludeCompFilter);

composition.hash = HashCode.OfEach(composition.includeTags).And(17).AndEach(composition.excludeTags).And(31).AndEach(excludeCompFilter);
myFieldInfo.SetValue(b, SetupGroup(myFieldInfo.FieldType, composition));
myFieldInfo.SetValue(b, SetupGroup(myFieldInfo.FieldType, composition, myFieldInfo.GetValue(b)));
}
}
}

internal static GroupCore SetupGroup(Type groupType, Composition filter)
internal static GroupCore SetupGroup(Type groupType, Composition filter, object fieldObj)
{
if (container.TryGetValue(groupType, filter, out GroupCore group))
{
return group;
}

if (fieldObj != null)
{
group = fieldObj as GroupCore;
return group.Start(filter);
}

return container.Add((Activator.CreateInstance(groupType, true) as GroupCore).Start(filter));
}

Expand Down
2 changes: 1 addition & 1 deletion Runtime/LibProcessors/ProcessorObserver.cs
Original file line number Diff line number Diff line change
Expand Up @@ -9,7 +9,7 @@ namespace Pixeye.Framework
sealed class ProcessorObserver : Processor, ITick
{

public GroupObservers groupObservers;
public GroupObservers groupObservers = new GroupObservers();

public void Tick(float delta)
{
Expand Down

0 comments on commit dcf865f

Please sign in to comment.