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); }
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); }
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)); } }
public override bool IsFeasible(Creature agent) { return(Mating.CanMate(agent, Them.Creature)); }
public override Feasibility IsFeasible(Creature agent) { return(Mating.CanMate(agent, Them.Creature) ? Feasibility.Feasible : Feasibility.Infeasible); }