public bool HasFlag(ComponentFlag flag) { if (flag.GetHashCode() == 0) { return(false); } return((this.SystemLowFlag & flag.SystemLowFlag) == flag.SystemLowFlag && (this.SystemHighFlag & flag.SystemHighFlag) == flag.SystemHighFlag && (this.PlayerLowFlag & flag.PlayerLowFlag) == flag.PlayerLowFlag && (this.PlayerHighFlag & flag.PlayerHighFlag) == flag.PlayerHighFlag); }
public Entity(ComponentCallBack componentCallBack, GetComponentFunc getFunc) { _id = Utils.GetEntityId(); ChildList = new List <Entity>(); _allComponenArray = new NormalComponent[ComponentIds.COMPONENT_MAX_COUNT]; _changeComponentCallBack = componentCallBack; _getComponentFunc = getFunc; _currentFlag = new ComponentFlag(); }
public void DataDrivenMethod(Entity entity, NormalComponent com) { if (entity == null) { return; } int sharedId = com.SharedId; SharedComponent sharedComponent = null; if (sharedId > 0) { sharedComponent = _sharedComponentDic[sharedId]; } int count = _systemReactiveDic.Count; for (int i = 0; i < count; i++) { ReactiveSystemDto dto = _systemReactiveDic[i]; ComponentFlag executeCondition = dto.CurrentSystem.ExecuteCondition; ComponentFlag reactiveCondition = dto.CurrentSystem.ReactiveCondition; ComponentFlag reactiveIgnoreCondition = dto.CurrentSystem.ReactiveIgnoreCondition; if (!reactiveCondition.HasFlag(com.OperatorId)) { continue; } if (sharedId > 0) { foreach (Entity setEntity in sharedComponent.SharedEntityHashSet) { if (setEntity.GetComponentFlag().HasFlag(reactiveIgnoreCondition)) { continue; } if (setEntity.GetComponentFlag().HasFlag(executeCondition)) { dto.EntityHashSet.Add(setEntity); } } } else { if (entity.GetComponentFlag().HasFlag(reactiveIgnoreCondition)) { continue; } if (entity.GetComponentFlag().HasFlag(executeCondition)) { dto.EntityHashSet.Add(entity); } } } }
public Group(params Int64[] array) { _componentFlag = new ComponentFlag(); if (array != null) { for (int i = 0; i < array.Length; i++) { ComponentFlag.SetFlag(array[i]); } } _hashCode = _componentFlag.GetHashCode(); _entityHashSet = new HashSet <Entity>(); }
public Group MatchGetGroup(ComponentFlag flag) { foreach (Group item in _matchGroupHashSet) { if (item.GetHashCode() == flag.GetHashCode()) { return(item); } } Group group = new Group(flag); _matchGroupHashSet.Add(group); return(group); }
public ComponentFlag GetFlag(params Int64[] args) { ComponentFlag flag = new ComponentFlag(); if (args != null) { for (int i = 0; i < args.Length; i++) { if (!flag.HasFlag(args[i])) { flag.SetFlag(args[i]); } } } return(flag); }
public static ComponentFlag operator &(ComponentFlag cf1, ComponentFlag cf2) { object o1 = cf1; object o2 = cf2; if (o1 == null || o2 == null) { throw new Exception("Object is Null"); } ComponentFlag temp = new ComponentFlag(); temp.SystemLowFlag = cf1.SystemLowFlag & cf2.SystemLowFlag; temp.SystemHighFlag = cf1.SystemHighFlag & cf2.SystemHighFlag; temp.PlayerLowFlag = cf1.PlayerLowFlag & cf2.PlayerLowFlag; temp.PlayerHighFlag = cf1.PlayerHighFlag & cf2.PlayerHighFlag; return(temp); }
public Group MatchGetGroup(params Int64[] componentIds) { if (componentIds == null) { throw new Exception("ComponentIds is null"); } ComponentFlag flag = new ComponentFlag(); for (int i = 0; i < componentIds.Length; i++) { if (flag.HasFlag(componentIds[i])) { continue; } flag.SetFlag(componentIds[i]); } return(MatchGetGroup(flag)); }
public bool HasComponent(Int32 flag) { return(ComponentFlag.HasFlag(flag)); }
public Group(ComponentFlag flag) { _componentFlag = flag; _hashCode = _componentFlag.GetHashCode(); _entityHashSet = new HashSet <Entity>(); }