public static FlyToward ( Actor self, Aircraft plane, int desiredFacing, WDist desiredAltitude ) : void | ||
self | Actor | |
plane | Aircraft | |
desiredFacing | int | |
desiredAltitude | WDist | |
Résultat | void |
public override Activity Tick(Actor self) { if (!target.IsValidFor(self)) { Cancel(self); } if (IsCanceled) { return(NextActivity); } var d = target.CenterPosition - self.CenterPosition; // The next move would overshoot, so just set the final position var move = plane.FlyStep(plane.Facing); if (d.HorizontalLengthSquared < move.HorizontalLengthSquared) { plane.SetPosition(self, target.CenterPosition); return(NextActivity); } var desiredFacing = Util.GetFacing(d, plane.Facing); Fly.FlyToward(self, plane, desiredFacing, WRange.Zero); return(this); }
public override Activity Tick(Actor self) { // Refuse to take off if it would land immediately again. if (plane.ForceLanding) { Cancel(self); return(NextActivity); } if (IsCanceled || !target.IsValidFor(self)) { return(NextActivity); } if (target.IsInRange(self.CenterPosition, minRange)) { var directVector = target.CenterPosition - self.CenterPosition; Fly.FlyToward(self, plane, (directVector.Yaw + WAngle.FromDegrees(180)).Facing, plane.Info.CruiseAltitude); return(this); } if (target.IsInRange(self.CenterPosition, maxRange)) { Fly.FlyToward(self, plane, plane.Facing, plane.Info.CruiseAltitude); return(this); } return(ActivityUtils.SequenceActivities(new Fly(self, target, minRange, maxRange), this)); }
public override Activity Tick(Actor self) { if (!target.IsValidFor(self)) { Cancel(self); } if (IsCanceled) { return(NextActivity); } var d = target.CenterPosition - self.CenterPosition; // The next move would overshoot, so just set the final position var move = aircraft.FlyStep(aircraft.Facing); if (d.HorizontalLengthSquared < move.HorizontalLengthSquared) { aircraft.SetPosition(self, target.CenterPosition); return(NextActivity); } var landingAlt = self.World.Map.DistanceAboveTerrain(target.CenterPosition); Fly.FlyToward(self, aircraft, d.Yaw.Facing, landingAlt); return(this); }
public override Activity Tick(Actor self) { // Refuse to take off if it would land immediately again. if (aircraft.ForceLanding) { Cancel(self); return(NextActivity); } if (IsCanceled) { return(NextActivity); } if (remainingTicks > 0) { remainingTicks--; } else if (remainingTicks == 0) { return(NextActivity); } // We can't possibly turn this fast var desiredFacing = aircraft.Facing + 64; Fly.FlyToward(self, aircraft, desiredFacing, cruiseAltitude); return(this); }
public override Activity Tick(Actor self) { if (!target.IsValidFor(self)) Cancel(self); if (IsCanceled) return NextActivity; if (!soundPlayed && aircraft.Info.LandingSounds.Length > 0 && !self.IsAtGroundLevel()) { Game.Sound.Play(SoundType.World, aircraft.Info.LandingSounds.Random(self.World.SharedRandom), aircraft.CenterPosition); soundPlayed = true; } var d = target.CenterPosition - self.CenterPosition; // The next move would overshoot, so just set the final position var move = aircraft.FlyStep(aircraft.Facing); if (d.HorizontalLengthSquared < move.HorizontalLengthSquared) { aircraft.SetPosition(self, target.CenterPosition); return NextActivity; } var landingAlt = self.World.Map.DistanceAboveTerrain(target.CenterPosition); Fly.FlyToward(self, aircraft, d.Yaw.Facing, landingAlt); return this; }
public override Activity Tick(Actor self) { if (IsCanceled || !self.World.Map.Contains(self.Location)) { return(NextActivity); } Fly.FlyToward(self, plane, plane.Facing, plane.Info.CruiseAltitude); return(this); }
public override Activity Tick(Actor self) { if (IsCanceled || remainingTicks-- == 0) { return(NextActivity); } Fly.FlyToward(self, plane, plane.Facing, cruiseAltitude); return(this); }
public override Activity Tick(Actor self) { if (IsCanceled) { return(NextActivity); } // We can't possibly turn this fast var desiredFacing = plane.Facing + 64; Fly.FlyToward(self, plane, desiredFacing, cruiseAltitude); return(this); }
public override Activity Tick(Actor self) { if (IsCanceled || !target.IsValidFor(self)) { return(NextActivity); } if (target.IsInRange(self.CenterPosition, maxRange) && !target.IsInRange(self.CenterPosition, minRange)) { Fly.FlyToward(self, plane, plane.Facing, plane.Info.CruiseAltitude); return(this); } return(ActivityUtils.SequenceActivities(new Fly(self, target, minRange, maxRange), this)); }
public override Activity Tick(Actor self) { // Refuse to take off if it would land immediately again. if (aircraft.ForceLanding) { Cancel(self); return(NextActivity); } if (IsCanceling || !self.World.Map.Contains(self.Location)) { return(NextActivity); } Fly.FlyToward(self, aircraft, aircraft.Facing, aircraft.Info.CruiseAltitude); return(this); }
public override Activity Tick(Actor self) { // Refuse to take off if it would land immediately again. if (plane.ForceLanding) { Cancel(self); return(NextActivity); } if (IsCanceled || remainingTicks-- == 0) { return(NextActivity); } Fly.FlyToward(self, plane, plane.Facing, cruiseAltitude); return(this); }
public override Activity Tick(Actor self) { if (!target.IsValidFor(self)) Cancel(self); if (IsCanceled) return NextActivity; var d = target.CenterPosition - self.CenterPosition; // The next move would overshoot, so just set the final position var move = plane.FlyStep(plane.Facing); if (d.HorizontalLengthSquared < move.HorizontalLengthSquared) { plane.SetPosition(self, target.CenterPosition); return NextActivity; } Fly.FlyToward(self, plane, d.Yaw.Facing, new WDist(target.CenterPosition.Z)); return this; }
public override Activity Tick(Actor self) { // Refuse to take off if it would land immediately again. if (aircraft.ForceLanding) { Cancel(self); return(NextActivity); } if (IsCanceled || !target.IsValidFor(self)) { return(NextActivity); } if (target.IsInRange(self.CenterPosition, maxRange) && !target.IsInRange(self.CenterPosition, minRange)) { Fly.FlyToward(self, aircraft, aircraft.Facing, aircraft.Info.CruiseAltitude); return(this); } return(ActivityUtils.SequenceActivities(new Fly(self, target, minRange, maxRange), this)); }
public override Activity Tick(Actor self) { if (ChildActivity != null) { ChildActivity = ActivityUtils.RunActivityTick(self, ChildActivity); if (ChildActivity != null) { return(this); } } // Refuse to take off if it would land immediately again. if (aircraft.ForceLanding) { Cancel(self); } if (IsCanceling) { return(NextActivity); } bool targetIsHiddenActor; target = target.Recalculate(self.Owner, out targetIsHiddenActor); if (!targetIsHiddenActor && target.Type == TargetType.Actor) { lastVisibleTarget = Target.FromTargetPositions(target); } var oldUseLastVisibleTarget = useLastVisibleTarget; useLastVisibleTarget = targetIsHiddenActor || !target.IsValidFor(self); // If we are ticking again after previously sequencing a MoveWithRange then that move must have completed // Either we are in range and can see the target, or we've lost track of it and should give up if (wasMovingWithinRange && targetIsHiddenActor) { return(NextActivity); } wasMovingWithinRange = false; // Update target lines if required if (useLastVisibleTarget != oldUseLastVisibleTarget && targetLineColor.HasValue) { self.SetTargetLine(useLastVisibleTarget ? lastVisibleTarget : target, targetLineColor.Value, false); } // Target is hidden or dead, and we don't have a fallback position to move towards if (useLastVisibleTarget && !lastVisibleTarget.IsValidFor(self)) { return(NextActivity); } var pos = self.CenterPosition; var checkTarget = useLastVisibleTarget ? lastVisibleTarget : target; // We've reached the required range - if the target is visible and valid then we wait // otherwise if it is hidden or dead we give up if (checkTarget.IsInRange(pos, maxRange) && !checkTarget.IsInRange(pos, minRange)) { Fly.FlyToward(self, aircraft, aircraft.Facing, aircraft.Info.CruiseAltitude); return(useLastVisibleTarget ? NextActivity : this); } wasMovingWithinRange = true; QueueChild(self, aircraft.MoveWithinRange(target, minRange, maxRange, checkTarget.CenterPosition, targetLineColor), true); return(this); }
public override Activity Tick(Actor self) { if (ChildActivity != null) { ChildActivity = ActivityUtils.RunActivityTick(self, ChildActivity); if (ChildActivity != null) { return(this); } } if (IsCanceling || target.Type == TargetType.Invalid) { aircraft.RemoveInfluence(); return(NextActivity); } if (!landingInitiated) { var landingCell = !aircraft.Info.VTOL ? self.World.Map.CellContaining(target.CenterPosition + offset) : self.Location; if (!aircraft.CanLand(landingCell, target.Actor)) { // Maintain holding pattern. if (!aircraft.Info.CanHover) { QueueChild(self, new FlyCircle(self, 25), true); } self.NotifyBlocker(landingCell); return(this); } aircraft.AddInfluence(landingCell); aircraft.EnteringCell(self); landingInitiated = true; } var altitude = self.World.Map.DistanceAboveTerrain(self.CenterPosition); var landAltitude = self.World.Map.DistanceAboveTerrain(target.CenterPosition + offset) + aircraft.LandAltitude; if (!soundPlayed && aircraft.Info.LandingSounds.Length > 0 && altitude != landAltitude) { Game.Sound.Play(SoundType.World, aircraft.Info.LandingSounds, self.World, aircraft.CenterPosition); soundPlayed = true; } // For VTOLs we assume we've already arrived at the target location and just need to move downward if (aircraft.Info.VTOL) { if (HeliFly.AdjustAltitude(self, aircraft, landAltitude)) { return(this); } return(NextActivity); } var d = (target.CenterPosition + offset) - self.CenterPosition; // The next move would overshoot, so just set the final position var move = aircraft.FlyStep(aircraft.Facing); if (d.HorizontalLengthSquared < move.HorizontalLengthSquared) { var landingAltVec = new WVec(WDist.Zero, WDist.Zero, aircraft.LandAltitude); aircraft.SetPosition(self, target.CenterPosition + offset + landingAltVec); return(NextActivity); } var landingAlt = self.World.Map.DistanceAboveTerrain(target.CenterPosition + offset) + aircraft.LandAltitude; Fly.FlyToward(self, aircraft, d.Yaw.Facing, landingAlt); return(this); }