Esempio n. 1
0
 // 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);
 }
Esempio n. 2
0
        /// <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);
                }
            }
        }
Esempio n. 3
0
 public Actor GetItem(Actor item, bool peek = false)
 {
     var founded = _items.Find(i => i == item);
     if (founded != null && !peek)
     {
         _items.Remove(founded);
     }
     return founded;
 }
Esempio n. 4
0
 public Actor GetItem(Actor item)
 {
     var founded = Items.Find(i => i == item);
     if (founded != null)
     {
         Items.Remove(founded);
     }
     return founded;
 }
Esempio n. 5
0
 /// <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");
     }
 }
Esempio n. 6
0
        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);
        }
Esempio n. 7
0
 private void EntityInfoUpdated(Actor actor)
 {
     Debug.Log("<color=grey> Memory updated for "+ actor.Name+"</color>");
 }
Esempio n. 8
0
 public ActorInfo(Actor actor):this(actor.Name, actor.Position, actor.GetType())
 { }
Esempio n. 9
0
 public void AddItem(Actor newItem)
 {
     Items.Add(newItem);
     newItem.transform.SetParent(Cells);
     newItem.transform.position = Cells.position;
 }