// Forget the actor public void Forget(Actor actor) { var info = new ActorInfo(actor); var exists = RealActors.Find(a => a.Equals(info)); if (exists != null) RealActors.Remove(exists); }
/// <summary> /// Create new memry node or update if exists /// </summary> /// <param name="actor"></param> public void Remember(Actor actor) { var entity = actor.GetEntity(); if (_memory.ContainsKey(entity)) { _memory[entity].Remember(actor); } else { var entityInfo = new EntityInfo(entity); entity.SetEntity(entityInfo); entityInfo.Remember(actor); _memory.Add(entity, entityInfo); } //TODO: сделать подобное рекурсивно для всех включенных парентов if (entity.Parent != null) { if (_memory.ContainsKey(entity.Parent)) { _memory[entity.Parent].Remember(actor); } else { var parentInfo = new EntityInfo(entity.Parent); entity.Parent.SetEntity(parentInfo); parentInfo.Remember(actor); _memory.Add(entity.Parent, parentInfo); } } }
public Actor GetItem(Actor item, bool peek = false) { var founded = _items.Find(i => i == item); if (founded != null && !peek) { _items.Remove(founded); } return founded; }
public Actor GetItem(Actor item) { var founded = Items.Find(i => i == item); if (founded != null) { Items.Remove(founded); } return founded; }
/// <summary> /// remove memory node, if exists /// </summary> /// <param name="actor"></param> public void Forget(Actor actor) { var entity = actor.GetEntity(); if (_memory.ContainsKey(entity)) { _memory[entity].Forget(actor); } else { Debug.Log("trying to forget about actor, when Entity doesn't exist"); } }
public void Remember(Actor actor) { if (actor == null){ return; } var actorInfo = new ActorInfo(actor); //if exists pure copy - replace it var exists = RealActors.Find(a => a.Equals(actorInfo)); if (exists != null) return; AddToList(actorInfo); if (Updated != null) Updated(actor); }
private void EntityInfoUpdated(Actor actor) { Debug.Log("<color=grey> Memory updated for "+ actor.Name+"</color>"); }
public ActorInfo(Actor actor):this(actor.Name, actor.Position, actor.GetType()) { }
public void AddItem(Actor newItem) { Items.Add(newItem); newItem.transform.SetParent(Cells); newItem.transform.position = Cells.position; }