Example #1
0
 public BaseEntity(char[,] symbols, ConsoleColor color, EntityAffection affection)
 {
     this.Symbols        = symbols ?? throw new ArgumentNullException();
     this.Color          = color;
     this.CanBeDestroyed = true;
     this.AddAffections(affection);
 }
Example #2
0
        private void AddAffections(EntityAffection affection)
        {
            this.AddAction(EntityAffectionType.Destroy, (entity) =>
            {
                if (this.CanBeDestroyed)
                {
                    if ((!(this is Item) || (this as Item).Type != ItemType.Projectile))
                    {
                        this.Clear();
                    }
                    this.IsDestroyed = true;
                    return(this.OnDestroy());
                }
                return(false);
            }).AddAction(EntityAffectionType.Nothing, (entity) =>
            {
                if (!this.IsHidden && entity is Item && (entity as Item).ID == this.ID)
                {
                    return(true);
                }
                return(false);
            });

            foreach (var affectAction in affection.AffectActions)
            {
                this.AddAction(affectAction.Key, affectAction.Value);
            }

            foreach (var affectedType in affection.AffectedTypes)
            {
                this.AddAffection(affectedType.Key, affectedType.Value);
            }
        }