public GridEntity( int id, string name, IEnumerable <EntityType> entityTypes, IEnumerable <IEntityComponent> entityComponents, IEnumerable <IItem> items, IEnumerable <IStat> stats ) : base(id, name, items, stats) { EntityTypes.AddRange(entityTypes); EntityComponents.AddRange(entityComponents); }
public void OnValueChange()// up down left right from 0 { //0 up if (null == EntityBase.current.selected) { return; } EntityComponents ec = EntityBase.current.selected.GetComponent <EntityComponents>(); for (int i = 0; i < 4; ++i) { ec.swipe.actions[i] = actions[options[i].value]; } }
/// <summary> /// Creates a new instance of <c>EntityObject</c>. /// </summary> /// <param name="entityId">The associated EntityId.</param> /// <param name="underlyingGameObject">The GameObject associated with the Entity.</param> /// <param name="prefabName">The prefab name associated with the Entity.</param> /// <param name="interestedComponentUpdaterProvider"> /// IInterestedComponentUpdaterProvider for callign /// OnInterestedComponentsPotentiallyChanged(). /// </param> public EntityObject(EntityId entityId, GameObject underlyingGameObject, string prefabName, IInterestedComponentUpdaterProvider interestedComponentUpdaterProvider) { this.interestedComponentUpdaterProvider = interestedComponentUpdaterProvider; if (underlyingGameObject == null) { throw new ArgumentNullException("underlyingGameObject"); } EntityId = entityId; UnderlyingGameObject = underlyingGameObject; PrefabName = prefabName; Visualizers = new EntityVisualizers(UnderlyingGameObject); Components = new EntityComponents(); Visualizers.AddInvalidator(this); Components.AddInvalidator(this); }
private void UpdateEntityInformation_EditorThread(CInspectorSceneComponentViewModel sceneComponentRoot, List <CInspectorEntityComponentViewModel> entityComponents, CInspectorEntityViewModel entity) { SceneComponents.Clear(); EntityComponents.Clear(); EntityInfo.Clear(); if (sceneComponentRoot != null) { SceneComponents.Add(sceneComponentRoot); } if (entityComponents != null) { EntityComponents = new ObservableCollection <CInspectorEntityComponentViewModel>(entityComponents); } if (entity != null) { EntityInfo.Add(entity); } }
public TResult FindComponent <TResult, TInterface>() { return((TResult)EntityComponents.FirstOrDefault(ec => ec.GetType().GetInterfaces().Contains(typeof(TInterface)))); }
public T FindComponent <T>() { return((T)EntityComponents.FirstOrDefault(ec => ec.GetType() == typeof(T))); }
public bool IsAttackable() { return(EntityComponents.Any(ec => ec.GetType().GetInterfaces().Contains(typeof(ICombatant)))); }
public void OnDeserializerArchetypeUpdate(NativeArray <Entity> entities, NativeArray <uint> archetypes, Dictionary <uint, NativeArray <uint> > archetypeToSystems) { var systemId = World.GetOrCreateSystem <SnapshotManager>().GetSystemId(this); var snapshotManager = World.GetOrCreateSystem <SnapshotManager>(); for (int ent = 0, length = entities.Length; ent < length; ent++) { var archetype = archetypes[ent]; var models = archetypeToSystems[archetype]; var hasModel = false; // Search if this entity has our system from the model list foreach (var model in models) { // Bingo! This entity got our system if (model == systemId) { hasModel = true; if (!EntityManager.HasComponent <TComponent>(entities[ent])) { for (var i = 0; i != EntityComponents.Length; i++) { EntityManager.AddComponent(entities[ent], EntityComponents[i]); } } break; } } if (hasModel) { continue; } if (!EntityManager.HasComponent <TComponent>(entities[ent])) { continue; } if (!EntityComponents.Contains(ComponentType.ReadWrite <TComponent>())) { throw new InvalidOperationException(); } // If the entity had the snapshot (so the model) before, but now it don't have it anymore, remove the snapshot and components var componentsToRemove = new NativeList <ComponentType>(EntityComponents.Length, Allocator.Temp); componentsToRemove.AddRange(EntityComponents); foreach (var model in models) { var system = snapshotManager.GetSystem(model); // First, check if another system got the same components as us. if (system is IEntityComponents systemWithInterface) { var systemEntityComponents = systemWithInterface.EntityComponents; for (var i = 0; i < componentsToRemove.Length; i++) { if (!systemEntityComponents.Contains(componentsToRemove[i])) { continue; } // If that system got the same component as us, remove if from the remove list. componentsToRemove.RemoveAtSwapBack(i); i--; } } } foreach (var type in componentsToRemove) { EntityManager.RemoveComponent(entities[ent], type); } } }
public EntityAnimation(EntityComponents entityComponents) { rotation = entityComponents.rotation; rotationAxis = entityComponents.rotationAxis; }