Esempio n. 1
0
        public override bool ShouldExecute()
        {
            if (entity.World.Rand.NextDouble() > 0.03)
            {
                return(false);
            }
            if (cooldownUntilMs > entity.World.ElapsedMilliseconds)
            {
                return(false);
            }
            if (cooldownUntilTotalHours > entity.World.Calendar.TotalHours)
            {
                return(false);
            }
            if (whenInEmotionState != null && !entity.HasEmotionState(whenInEmotionState))
            {
                return(false);
            }
            if (whenNotInEmotionState != null && entity.HasEmotionState(whenNotInEmotionState))
            {
                return(false);
            }

            targetEntity = (EntityButterfly)entity.World.GetNearestEntity(entity.ServerPos.XYZ, seekingRange, seekingRange, (e) => {
                if (!e.Alive || e.EntityId == this.entity.EntityId)
                {
                    return(false);
                }

                if (e is EntityButterfly)
                {
                    return(true);
                }

                return(false);
            });

            if (targetEntity != null)
            {
                chaseTime = (float)entity.World.Rand.NextDouble() * 7 + 6;
                targetPos.Set(targetEntity.ServerPos.X, targetEntity.ServerPos.Y, targetEntity.ServerPos.Z);

                // Tell the other butterfly to chase us
                AiTaskManager        manager   = targetEntity.GetBehavior <EntityBehaviorTaskAI>().taskManager;
                AiTaskButterflyChase othertask = manager.GetTask <AiTaskButterflyChase>();
                othertask.targetEntity = this.entity as EntityButterfly;
                othertask.targetPos.Set(entity.ServerPos.X, entity.ServerPos.Y, entity.ServerPos.Z);
                othertask.chaseTime = (float)entity.World.Rand.NextDouble() * 7 + 6;

                manager.ExecuteTask <AiTaskButterflyChase>();
                return(true);
            }

            return(false);
        }
Esempio n. 2
0
 public AiTaskButterflyFlee(EntityAgent entity, EntityButterfly chaseTarget) : base(entity)
 {
     fleeTime       = (float)entity.World.Rand.NextDouble() * 7 + 6;
     fleeFromEntity = chaseTarget;
     targetPos.Set(fleeFromEntity.ServerPos.X, fleeFromEntity.ServerPos.Y, fleeFromEntity.ServerPos.Z);
 }
Esempio n. 3
0
 public AiTaskButterflyChase(EntityAgent entity, EntityButterfly chaseTarget) : base(entity)
 {
     chaseTime    = (float)entity.World.Rand.NextDouble() * 7 + 6;
     targetEntity = chaseTarget;
     targetPos.Set(targetEntity.ServerPos.X, targetEntity.ServerPos.Y, targetEntity.ServerPos.Z);
 }