示例#1
0
        public void OnTick()
        {
            if (ownerEntity == null || ownerEntity.unloaded)
            {
                this.ownerEntity = GetOwner();
            }
            if (names.HasUnresolved())
            {
                this.names.Resolve(player.entities);
            }

            if (ownerEntity == null || ownerEntity.unloaded)
            {
                return;
            }

            ticks++;
            if (ticks < 5)
            {
                return;
            }
            ticks = 0;

            ILiving target = GetClosestFollowTarget();

            if (target == null)
            {
                return;
            }

            busy = true;
            var map = actions.AsyncMoveToEntity(target, token, LMO);

            map.Completed += areaMap => {
                ticks = 0;
                busy  = false;
            };
            map.Cancelled += (areaMap, cuboid) => {
                ticks = -10;
                busy  = false;
            };
            map.WaypointReached += areaMap => {
                var next = GetClosestFollowTarget();
                if (next != null && next.location.Distance(player.status.entity.location) < 1 && player.physicsEngine.path?.Complete == false)
                {
                    areaMap.CalculateFromNext(player.world, next);
                }
                else // Calculate path to the newest owners location.
                {
                    areaMap.CalculateFromNext(player.world, ownerEntity);
                }
            };

            map.Start();

            if (map.Searched && map.Complete && map.Valid)
            {
                busy = false;
            }
        }
示例#2
0
    public bool isSameSpecies(ILiving other)
    {
        Living creature = (Living)other;

        bool same;

        if (creature.getType() == getType())
        {
            same = false;
        }
        else
        {
            same = true;

            for (int i = 0; i < this.Traits.Length; i++)
            {
                if (this.Traits[i] != creature.Traits[i])
                {
                    same = false;
                }
            }
        }

        return(same);
    }
示例#3
0
 public Cell(ILiving living, LivingName livingname, int coordX, int coordY)
 {
     Living     = living;
     livingName = livingname;
     CoordX     = coordX;
     CoordY     = coordY;
 }
示例#4
0
 //// clear list to release memory
 private void OnParentAliveChanged(ILiving sender)
 {
     if (!sender.IsAlive)
     {
         Clear();
     }
 }
        public override void React(ILiving target)
        {
            switch (this.SpellType)
            {
            case SpellType.Offensive: target.HitPoints -= this.Ammount;
                break;

            case SpellType.Heal: target.HitPoints += this.Ammount;
                break;

            default:
                break;
            }
        }
示例#6
0
        public void OnTick()
        {
            ticks++;
            if (ticks < 4)
            {
                return;
            }
            ticks = 0;

            if (ownerEntity == null)
            {
                this.ownerEntity = GetOwner();
            }
            if (ownerEntity == null || ownerEntity.unloaded)
            {
                return;
            }

            this.busy = true;
            var currentOptions = state != MovementState.FOUND ? LMO : HMO;

            var map = actions.AsyncMoveToEntity(ownerEntity, token, currentOptions);

            map.Completed += areaMap => {
                state     = MovementState.FOUND;
                this.busy = false;
            };
            map.Cancelled += (areaMap, cuboid) => {
                if (state == MovementState.FOUND)
                {
                    state = MovementState.LOW_NOTFOUND;
                }
                else if (state == MovementState.LOW_NOTFOUND)
                {
                    state = MovementState.HIGH_NOTFOUND;
                }
                this.ticks = -(int)state;
                this.busy  = false;
            };
            map.Start();
        }
示例#7
0
        private ILiving GetClosestFollowTarget()
        {
            ILiving moveTarget = ownerEntity;

            if (ownerEntity == null)
            {
                return(null);
            }

            ILiving enemy = player.entities.FindClosestTarget(status.entity.location.ToLocation(), Targeter.DefaultFilter);

            if (enemy != null && mode == Mode.Aggresive && enemy.location.Distance(ownerEntity.location) < 5)
            {
                moveTarget = enemy;
            }
            else if (ownerEntity.location.Distance(status.entity.location) < 1)
            {
                return(null);
            }
            return(moveTarget);
        }
 public abstract void React(ILiving target);
 public void Attack(ILiving target)
 {
     target.HitPoints -= this.Damage;
 }
示例#10
0
 void Live(ILiving life)
 {
     life.Eat();
     life.Sleep();
 }
示例#11
0
 /// <summary>
 /// Attack Method for Entity
 /// </summary>
 /// <param name="victim"> What is Being Attacked</param>
 public virtual void Attack(ILiving victim)
 {
 }
示例#12
0
 // Holder needs to clear children when parent dies, or else their
 // references will cause parents to not be GC'd
 public BehaviorHolder(ILiving parent)
 {
     parent.AliveChanged += OnParentAliveChanged;
 }
示例#13
0
 public override void React(ILiving target)
 {
     target.HitPoints -= this.Damage;
 }