Esempio n. 1
0
        public IEnumerable <Act.Status> Mate(Creature me)
        {
            Timer mateTimer = new Timer(5.0f, true);

            while (!mateTimer.HasTriggered)
            {
                me.Physics.Velocity        = Vector3.Zero;
                Them.Physics.Velocity      = Vector3.Zero;
                Them.Physics.LocalPosition = me.Physics.Position * 0.1f + Them.Physics.Position * 0.9f;
                if (MathFunctions.RandEvent(0.01f))
                {
                    me.NoiseMaker.MakeNoise("Hurt", me.AI.Position, true, 0.1f);
                    me.World.ParticleManager.Trigger("puff", me.AI.Position, Color.White, 1);
                }
                mateTimer.Update(DwarfTime.LastTime);
                yield return(Act.Status.Running);
            }

            if (Mating.CanMate(me, Them.Creature))
            {
                Mating.Mate(me, Them.Creature, me.World.Time);
            }
            else
            {
                AutoRetry = false;
                yield return(Act.Status.Fail);
            }

            yield return(Act.Status.Success);
        }
Esempio n. 2
0
 public override Feasibility IsFeasible(Creature agent)
 {
     if (Them == null || Them.IsDead || agent == null || agent.IsDead || agent.AI == null)
     {
         return(Feasibility.Infeasible);
     }
     return(Mating.CanMate(agent, Them.Creature) ? Feasibility.Feasible : Feasibility.Infeasible);
 }
Esempio n. 3
0
        public void HandleReproduction()
        {
            if (!Creature.Stats.Species.CanReproduce)
            {
                return;
            }
            if (Creature.IsPregnant)
            {
                return;
            }
            if (!MathFunctions.RandEvent(0.0002f))
            {
                return;
            }
            if (CurrentTask != null)
            {
                return;
            }
            IEnumerable <CreatureAI> potentialMates =
                Faction.Minions.Where(minion => minion != this && Mating.CanMate(minion.Creature, this.Creature));
            CreatureAI closestMate = null;
            float      closestDist = float.MaxValue;

            foreach (var ai in potentialMates)
            {
                var dist = (ai.Position - Position).LengthSquared();
                if (!(dist < closestDist))
                {
                    continue;
                }
                closestDist = dist;
                closestMate = ai;
            }

            if (closestMate != null && closestDist < 30)
            {
                Tasks.Add(new MateTask(closestMate));
            }
        }
Esempio n. 4
0
 public override bool IsFeasible(Creature agent)
 {
     return(Mating.CanMate(agent, Them.Creature));
 }
Esempio n. 5
0
 public override Feasibility IsFeasible(Creature agent)
 {
     return(Mating.CanMate(agent, Them.Creature) ? Feasibility.Feasible : Feasibility.Infeasible);
 }