public static T CreateFromPrefab <T>(ref uint startIndex, Transform contextHolder, IEntityFactory factory, ExclusiveGroup group, bool searchImplementorsInChildren = false, string groupNamePostfix = null) where T : MonoBehaviour, IEntityDescriptorHolder { Create <T>(new EGID(startIndex++, group), contextHolder, factory, out var holder); var children = contextHolder.GetComponentsInChildren <IEntityDescriptorHolder>(true); foreach (var child in children) { IImplementor[] childImplementors; if (child.GetType() != typeof(T)) { var monoBehaviour = child as MonoBehaviour; if (searchImplementorsInChildren == false) { childImplementors = monoBehaviour.GetComponents <IImplementor>(); } else { childImplementors = monoBehaviour.GetComponentsInChildren <IImplementor>(true); } startIndex = InternalBuildAll( startIndex, child, factory, group, childImplementors, groupNamePostfix); } } return(holder); }
public static T CreateFromPrefab <T>( ref uint startIndex, Transform contextHolder, IEntityFactory factory, ExclusiveGroup group) where T : MonoBehaviour, IEntityDescriptorHolder { var holder = Create <T>( new EGID(startIndex++, group), contextHolder, factory); var childs = contextHolder.GetComponentsInChildren <IEntityDescriptorHolder>(true); foreach (var child in childs) { if (child.GetType() != typeof(T)) { var monoBehaviour = child as MonoBehaviour; var childImplementors = monoBehaviour.GetComponents <IImplementor>(); startIndex = InternalBuildAll( startIndex, child, factory, group, childImplementors); } } return(holder); }
static uint InternalBuildAll(uint startIndex, IEntityDescriptorHolder descriptorHolder, IEntityFactory factory, ExclusiveGroup group, IImplementor[] implementors, string groupNamePostfix) { ExclusiveGroupStruct realGroup = group; if (string.IsNullOrEmpty(descriptorHolder.groupName) == false) { realGroup = ExclusiveGroup.Search(!string.IsNullOrEmpty(groupNamePostfix) ? $"{descriptorHolder.groupName}{groupNamePostfix}" : descriptorHolder.groupName); } EGID egid; var holderId = descriptorHolder.id; if (holderId == 0) { egid = new EGID(startIndex++, realGroup); } else { egid = new EGID(holderId, realGroup); } var init = factory.BuildEntity(egid, descriptorHolder.GetDescriptor(), implementors); init.Init(new EntityHierarchyComponent(group)); return(startIndex); }
public static uint CreateAll <T>(uint startIndex, ExclusiveGroup group, Transform contextHolder, IEntityFactory factory) where T : MonoBehaviour, IEntityDescriptorHolder { var holders = contextHolder.GetComponentsInChildren <T>(true); foreach (var holder in holders) { var implementors = holder.GetComponents <IImplementor>(); ExclusiveGroup.ExclusiveGroupStruct realGroup = group; if (string.IsNullOrEmpty(holder.groupName) == false) { realGroup = ExclusiveGroup.Search(holder.groupName); } EGID egid; var holderId = holder.id; if (holderId == 0) { egid = new EGID(startIndex++, realGroup); } else { egid = new EGID(holderId, realGroup); } var init = factory.BuildEntity(egid, holder.GetDescriptor(), implementors); init.Init(new EntityHierarchyStruct(group)); } return(startIndex); }
IEnumerator PollForInput() { while (true) { while (_buttonConsumer.TryDequeue(out var entity)) { if (entity.message == ButtonEvents.SELECT) { IGuiViewIndex guiViewIndex = entitiesDB.QueryEntity <GuiViewIndexEntityViewStruct>(entity.ID).guiViewIndex; ExclusiveGroup.ExclusiveGroupStruct group = entity.ID.groupID; if (string.IsNullOrEmpty(guiViewIndex.groupName) == false) { group = ExclusiveGroup.Search(guiViewIndex.groupName); } var entities = entitiesDB.QueryEntities <GUIEntityViewStruct>(group); foreach (var gui in entities) { gui.guiRoot.view = guiViewIndex.index; } } } yield return(null); } }
/// <summary> /// Works like CreateAll but only builds entities with holders that have the same group specified /// </summary> /// <param name="startId"></param> /// <param name="group">The group to match</param> /// <param name="contextHolder"></param> /// <param name="factory"></param> /// <typeparam name="T">EntityDescriptorHolder type</typeparam> /// <returns>Next available ID</returns> public static uint CreateAllInMatchingGroup <T>(uint startId, ExclusiveGroup exclusiveGroup, Transform contextHolder, IEntityFactory factory) where T : MonoBehaviour, IEntityDescriptorHolder { var holders = contextHolder.GetComponentsInChildren <T>(true); foreach (var holder in holders) { if (string.IsNullOrEmpty(holder.groupName) == false) { var realGroup = ExclusiveGroup.Search(holder.groupName); if (realGroup != exclusiveGroup) { continue; } } else { continue; } var implementors = holder.GetComponents <IImplementor>(); startId = InternalBuildAll(startId, holder, factory, exclusiveGroup, implementors, null); } return(startId); }
public static uint CreateAll <T>(uint startIndex, ExclusiveGroup group, Transform contextHolder, IEntityFactory factory, string groupNamePostfix = null) where T : MonoBehaviour, IEntityDescriptorHolder { var holders = contextHolder.GetComponentsInChildren <T>(true); foreach (var holder in holders) { var implementors = holder.GetComponents <IImplementor>(); startIndex = InternalBuildAll(startIndex, holder, factory, group, implementors, groupNamePostfix); } return(startIndex); }
/// <summary> /// Creates all the entities in a hierarchy. This was commonly used to create entities from gameobjects /// already present in the scene /// </summary> /// <param name="startIndex"></param> /// <param name="group"></param> /// <param name="contextHolder"></param> /// <param name="factory"></param> /// <param name="groupNamePostfix"></param> /// <typeparam name="T"></typeparam> /// <returns></returns> public static uint CreateAll <T>(uint startIndex, ExclusiveGroup group, Transform contextHolder, IEntityFactory factory, string groupNamePostfix = null) where T : MonoBehaviour, IEntityDescriptorHolder { var holders = contextHolder.GetComponentsInChildren <T>(true); foreach (var holder in holders) { var implementors = holder.GetComponents <IImplementor>(); try { startIndex = InternalBuildAll(startIndex, holder, factory, group, implementors, groupNamePostfix); } catch (Exception ex) { throw new Exception($"When building entity from game object {Path(holder.transform)}", ex); } } return(startIndex); }
public static void CreateAll <T>(ExclusiveGroup group, Transform contextHolder, IEntityFactory factory) where T : MonoBehaviour, IEntityDescriptorHolder { var holders = contextHolder.GetComponentsInChildren <T>(true); foreach (var holder in holders) { var implementors = holder.GetComponents <IImplementor>(); ExclusiveGroup.ExclusiveGroupStruct realGroup = group; if (string.IsNullOrEmpty(holder.groupName) == false) { realGroup = ExclusiveGroup.Search(holder.groupName); } factory.BuildEntity(holder.GetInstanceID(), realGroup, holder.GetDescriptor(), implementors); } }
public bool HasAny <T>(ExclusiveGroup @group) where T : IEntityStruct { return(HasAny <T>((int)group)); }
public EGID(int entityID, ExclusiveGroup groupID) : this() { _GID = MAKE_GLOBAL_ID(entityID, (int)groupID); }
public EntityHierarchyStruct(ExclusiveGroup @group) : this() { parentGroup = group; }
public Consumer <T> GenerateConsumer <T>(ExclusiveGroup group, string name, int capacity) where T : unmanaged, IEntityStruct { return(_enginesRoot.Target.GenerateConsumer <T>(group, name, capacity)); }
public void ExecuteOnEntities <T>(ExclusiveGroup groupID, EntitiesAction <T> action) where T : IEntityStruct { ExecuteOnEntities((int)groupID, action); }
public void ExecuteOnEntity <T, W>(int id, ExclusiveGroup groupid, ref W value, EntityAction <T, W> action) where T : IEntityStruct { ExecuteOnEntity(id, (int)groupid, ref value, action); }
public void ExecuteOnEntity <T>(int id, ExclusiveGroup groupid, EntityAction <T> action) where T : IEntityStruct { ExecuteOnEntity(id, (int)groupid, action); }
public void ExecuteOnEntities <T, W>(ExclusiveGroup groupID, ref W value, EntitiesAction <T, W> action) where T : IEntityStruct { ExecuteOnEntities((int)groupID, ref value, action); }
public EntityHierarchyComponent(ExclusiveGroup group) : this() { parentGroup = group; }
public T[] QueryEntities <T>(ExclusiveGroup @group, out int targetsCount) where T : IEntityStruct { return(QueryEntities <T>((int)@group, out targetsCount)); }
public bool HasAnyEntityInGroupArray <T>(ExclusiveGroup groupID) where T : struct, IEntityComponent { return(entitiesDB.QueryEntities <T>(groupID).count > 0); }
static int Main(string[] args) { try { var directories = new List <string>(); var files = new List <string>(); var programCommand = Command.None; Func <CompositionContractInfo, bool> contractPredicate = c => false; Func <CompositionInfo, PartDefinitionInfo, bool> partPredicate = (ci, p) => false; var verbose = false; var whitelist = new RejectionWhitelist(); var opts = new Options(); opts.Add <string>("dir", @"C:\MyApp\Parts", "Specify directories to search for parts.", d => directories.Add(d)); opts.Add <string>("file", "MyParts.dll", "Specify assemblies to search for parts.", f => files.Add(f)); opts.AddSwitch("verbose", "Print verbose information on each part.", () => verbose = true); var programCommandGroup = new ExclusiveGroup(); opts.Add <string>("type", "MyNamespace.MyType", "Print details of the given part type.", t => { programCommand = Command.PrintParts; partPredicate = AddToPredicate(partPredicate, (ci, p) => p == ci.GetPartDefinitionInfo(t)); }, programCommandGroup); opts.Add <string>("importers", "MyContract", "List importers of the given contract.", i => { programCommand = Command.PrintParts; partPredicate = AddToPredicate(partPredicate, (ci, p) => p.ImportsContract(i)); }, programCommandGroup); opts.Add <string>("exporters", "MyContract", "List exporters of the given contract.", e => { programCommand = Command.PrintParts; partPredicate = AddToPredicate(partPredicate, (ci, p) => p.ExportsContract(e)); }, programCommandGroup); opts.AddSwitch("rejected", "List all rejected parts.", () => { programCommand = Command.PrintParts; partPredicate = AddToPredicate(partPredicate, (ci, p) => p.IsRejected); }, programCommandGroup); opts.AddSwitch("causes", "List root causes - parts with errors not related to the rejection of other parts.", () => { programCommand = Command.PrintParts; partPredicate = AddToPredicate(partPredicate, (ci, p) => p.IsPrimaryRejection); }, programCommandGroup); opts.Add <string>("whitelist", "RejectionWhitelist.txt", "Specify parts that may be validly rejected; requres the /rejected or /causes commands.", w => whitelist = new RejectionWhitelist(w)); opts.AddSwitch("parts", "List all parts found in the source assemblies.", () => { programCommand = Command.PrintParts; partPredicate = AddToPredicate(partPredicate, (ci, p) => true); }, programCommandGroup); opts.AddSwitch("?", "Print usage.", () => programCommand = Command.PrintUsage, programCommandGroup); var contractsSubgroup = new InclusiveSubroup(programCommandGroup); opts.AddSwitch("imports", "Find imported contracts.", () => { programCommand = Command.PrintContracts; contractPredicate = AddToPredicate(contractPredicate, c => c.Importers.Any()); }, contractsSubgroup); opts.AddSwitch("exports", "Find exported contracts.", () => { programCommand = Command.PrintContracts; contractPredicate = AddToPredicate(contractPredicate, c => c.Exporters.Any()); }, contractsSubgroup); opts.Parse(args); return(Run(directories, files, programCommand, contractPredicate, partPredicate, verbose, whitelist, opts)); } catch (Exception ex) { Console.Write("Error: "); Console.WriteLine(ex.Message); return(1); } }
public GridCellBuilder WithGroup(ExclusiveGroup group) { _group = group; return(this); }
public EGIDMapper <T> QueryMappedEntities <T>(ExclusiveGroup groupID) where T : IEntityStruct { return(QueryMappedEntities <T>((int)groupID)); }
public TestEngine(ExclusiveGroup @group) { this.@group = @group; }