public static ent Create(GameObject prefab, BlueprintEntity bpAsset, bool pooled = false) { int id; byte age = 0; if (ent.entityStackLength > 0) { var pop = ent.entityStack.Dequeue(); byte ageOld = pop.age; id = pop.id; unchecked { age = (byte)(ageOld + 1); } ent.entityStackLength--; } else { id = ent.lastID++; } var entity = new ent(id, age); Initialize(id, age, pooled); transforms[id] = pooled ? HelperFramework.SpawnInternal(Pool.Entities, prefab) : HelperFramework.SpawnInternal(prefab); bpAsset.Execute(entity); return(entity); }
//===============================// // Blueprints //===============================// #if ODIN_INSPECTOR public static ent Create(BlueprintEntity bpAsset) { int id; byte age = 0; if (ent.entityStackLength > 0) { var pop = ent.entityStack.Dequeue(); byte ageOld = pop.age; id = pop.id; unchecked { age = (byte)(ageOld + 1); } ent.entityStackLength--; } else { id = ent.lastID++; } var entity = new ent(id, age); Initialize(id, age); bpAsset.Execute(entity); return(entity); }
public static ent Create(ModelComposer model) { int id; byte age = 0; if (ent.entityStackLength > 0) { var pop = ent.entityStack.Dequeue(); byte ageOld = pop.age; id = pop.id; unchecked { age = (byte)(ageOld + 1); } ent.entityStackLength--; } else { id = ent.lastID++; } var entity = new ent(id, age); Initialize(id, age); model(entity, null); Delayed.Set(entity, 0, Delayed.Action.Activate); return(entity); }
public static ent CreateFor(GameObject prefab, ModelComposer model, bool pooled = false) { int id; byte age = 0; if (ent.entityStackLength > 0) { var pop = ent.entityStack.Dequeue(); byte ageOld = pop.age; id = pop.id; unchecked { age = (byte)(ageOld + 1); } ent.entityStackLength--; } else { id = ent.lastID++; } var entity = new ent(id, age); Initialize(id, age, pooled); transforms[id] = prefab.transform; model(entity, null); Delayed.Set(entity, 0, Delayed.Action.Activate); return(entity); }
public static ent Create(string prefabID, ModelComposer model, Vector3 position, bool pooled = false) { int id; byte age = 0; if (ent.entityStackLength > 0) { var pop = ent.entityStack.Dequeue(); byte ageOld = pop.age; id = pop.id; unchecked { age = (byte)(ageOld + 1); } ent.entityStackLength--; } else { id = ent.lastID++; } var entity = new ent(id, age); Initialize(id, age, pooled); transforms[id] = pooled ? HelperFramework.SpawnInternal(Pool.Entities, prefabID, position) : HelperFramework.SpawnInternal(prefabID, position); model(entity, null); Delayed.Set(entity, 0, Delayed.Action.Activate); return(entity); }
internal void Launch(ModelComposer model) { int id; byte age = 0; if (ent.entityStackLength > 0) { var pop = ent.entityStack.Dequeue(); byte ageOld = pop.age; id = pop.id; unchecked { age = (byte)(ageOld + 1); } ent.entityStackLength--; } else { id = ent.lastID++; } #if UNITY_EDITOR _entity = id; #endif entity = new ent(id, age); Entity.Initialize(id, age, isPooled); Entity.transforms[id] = transform; Setup(); model(entity, this); Entity.Delayed.Set(entity, 0, Entity.Delayed.Action.Activate); }
internal void Launch() { int id; byte age = 0; if (ent.entityStackLength > 0) { var pop = ent.entityStack.Dequeue(); byte ageOld = pop.age; id = pop.id; unchecked { age = (byte)(ageOld + 1); } ent.entityStackLength--; } else { id = ent.lastID++; } #if UNITY_EDITOR _entity = id; #endif entity = new ent(id, age); Entity.Initialize(id, age, isPooled); Entity.transforms[id] = transform; Setup(); if (buildFrom != null) { buildFrom.ExecuteOnStart(entity, this); } else if (isActiveAndEnabled) { Entity.Delayed.Set(entity, 0, Entity.Delayed.Action.Activate); } }
public static void ValueChange <TSource, TProp>(this TSource source, Func <TSource, TProp> propertySelector, Action <TProp> callback, ent e) { var w = new Wrap <TSource, TProp>(); w.source = source; w.prop = propertySelector; w.callback = callback; #if UNITY_EDITOR if (Comparers.storage.TryGetValue(typeof(TProp).GetHashCode(), out object comparer)) { w.comparer = comparer as IEqualityComparer <TProp>; } else { Debug.LogError($"Comparer for {typeof(TProp)} not found."); } #else w.comparer = Comparers.storage[typeof(TProp).GetHashCode()] as IEqualityComparer <TProp>; #endif ref var cObserver = ref e.AddGet <ComponentObserver>();
public static void ValueChange <TSource, TProp>(this TSource source, Func <TSource, TProp> propertySelector, Action <TProp> callback, ent e) { Wrap <TSource, TProp> w = new Wrap <TSource, TProp>(); w.source = source; w.prop = propertySelector; w.callback = callback; #if UNITY_EDITOR if (Comparers.storage.TryGetValue(typeof(TProp).GetHashCode(), out object comparer)) { w.comparer = comparer as IEqualityComparer <TProp>; } else { Debug.LogError($"Comparer for {typeof(TProp)} not found."); } #else w.comparer = Comparers.storage[typeof(TProp).GetHashCode()] as IEqualityComparer <TProp>; #endif var cObserver = e.Add <ComponentObserver>(); if (cObserver.length == cObserver.wrappers.Length) { Array.Resize(ref cObserver.wrappers, cObserver.length << 1); } cObserver.wrappers[cObserver.length++] = w; }