/// <summary> /// Inicjalizuje nową encję. /// </summary> /// <param name="id">Identyfikator.</param> public GameEntity(string id) { Logger.Trace("Creating new game entity with id {0}", id); this._Components = new ComponentsCollection(this); this._Attributes = new AttributesCollection(this); this.Id = id; }
public AGSComponentBinding(IComponentsCollection collection, Action <TComponent> onAdded, Action <TComponent> onRemoved) { _collection = collection; this.onAdded = onAdded; this.onRemoved = onRemoved; collection.OnComponentsChanged.Subscribe(onComponentsChanged); TComponent component = collection.GetComponent <TComponent>(); if (component != null) { onAdded.Invoke(component); } else if (!collection.ComponentsInitialized) { collection.OnComponentsInitialized.Subscribe(onComponentsInitialized); } }
public AGSComponentBinding(IComponentsCollection collection, Action <TComponent> onAdded, Action <TComponent> onRemoved) { _collection = collection; _componentChangedCallback = new Action <AGSListChangedEventArgs <IComponent> >(onComponentsChanged); _componentsInitializedCallback = new Action(onComponentsInitialized); this.onAdded = onAdded; this.onRemoved = onRemoved; collection.OnComponentsChanged.Subscribe(_componentChangedCallback); _component = collection.GetComponent <TComponent>(); if (_component != null) { onAdded.Invoke(_component); } else if (!collection.ComponentsInitialized) { collection.OnComponentsInitialized.Subscribe(_componentsInitializedCallback); } }
public void SetUp() { GameEntity ent = new GameEntity("Test"); this.Collection = new ComponentsCollection(ent); this.Component1 = new Mock<Component>("Component1") { CallBase = true }; //this.Component1.Setup(c => c.Init(ent)); this.Component1.Setup(c => c.OnInit()); this.Component2 = new Mock<Component>("Component2") { CallBase = true }; //this.Component2.Setup(c => c.Init(ent)); this.Component2.Setup(c => c.OnInit()); this.Component3 = new Mock<OtherComponent>("Component3") { CallBase = true }; //this.Component3.Setup(c => c.Init(ent)); this.Component3.Setup(c => c.OnInit()); this.Collection.Add(this.Component1.Object); this.Collection.Add(this.Component2.Object); this.Collection.Add(this.Component3.Object); }