Implement source-backed Scooter vehicle in tutorial and outside
This commit is contained in:
1 parent
8df5e81070
commit
62c07a3d59
44 files changed
+3135
-174
No files matched your search
@@ -37,7 +37,8 @@ public sealed class ActorPatrol
|
||||
public float WaitRemaining { get; private set; }
|
||||
public string? CurrentWaypoint => waypoint?.Tag;
|
||||
public string? PreviousWaypoint => previousWaypoint?.Tag;
|
||||
public bool SupportedState => actor.AIstate is 1 or 3 or 7 or 9 || actor.Kind == "3CAR" && actor.AIstate == 6;
|
||||
public bool FollowPlayer {get;set;}
|
||||
public bool SupportedState => actor.AIstate is 1 or 3 or 7 or 9 || actor.Kind == "3CAR" && actor.AIstate == 6 || FollowPlayer&&actor.Kind=="3DOG"&&actor.AIstate==4;
|
||||
|
||||
public ActorPatrol(DirectorActor actor, Func<string, DirectorActor?> findActor,
|
||||
Func<PatrolBodyState, float, PatrolBodyState> integrateBody,
|
||||
@@ -86,7 +87,7 @@ public sealed class ActorPatrol
|
||||
if (!float.IsFinite(dt) || dt < 0 || dt > 1) throw new ArgumentOutOfRangeException(nameof(dt));
|
||||
SynchronizeAuthoredState();
|
||||
if (!SupportedState) return false;
|
||||
if (!actor.Active) return true;
|
||||
if (!actor.Active||!actor.MovementEnabled) return true;
|
||||
if (!float.IsFinite(actor.Speed)) throw new InvalidOperationException("Nonfinite Goddard speed");
|
||||
|
||||
// EXE408023->40E050: the body consumes the *previous* velocity first.
|
||||
@@ -104,6 +105,7 @@ public sealed class ActorPatrol
|
||||
{
|
||||
case 1: Velocity = Vector3.Zero; break; // EXE40835D, after body integration.
|
||||
case 3: StepPatrol(); break;
|
||||
case 4: StepFollow(); break;
|
||||
case 7: StepWait(dt); break;
|
||||
// State9 jumps directly to the common finisher408911. State6 calls
|
||||
// sensing409CC0 first; source player-contact dispatch is implemented
|
||||
@@ -112,12 +114,30 @@ public sealed class ActorPatrol
|
||||
}
|
||||
// States1/6/7 return before selecting a destination angle (409186..19B).
|
||||
// Retain the old destination on a waypoint change, as the source does.
|
||||
if (actor.AIstate == 3 && DestinationDelta.X * DestinationDelta.X + DestinationDelta.Z * DestinationDelta.Z > 0)
|
||||
if (actor.AIstate is 3 or 4 && DestinationDelta.X * DestinationDelta.X + DestinationDelta.Z * DestinationDelta.Z > 0)
|
||||
desiredYaw = MathF.Atan2(-DestinationDelta.X, DestinationDelta.Z) * (180 / MathF.PI);
|
||||
Publish();
|
||||
return true;
|
||||
}
|
||||
|
||||
private void StepFollow()
|
||||
{
|
||||
var target=findActor("JIM1");if(target==null||!target.Active)return;
|
||||
DestinationDelta=target.Position-actor.Position;DestinationDistance=DestinationDelta.Length();
|
||||
var length=magnitude(DestinationDelta);
|
||||
float multiplier=DestinationDistance>=2000?3:DestinationDistance>=1000?1.7f:1;
|
||||
Velocity=Arrived||length==0?Vector3.Zero:DestinationDelta/length*(actor.Speed*multiplier);
|
||||
if(DestinationDistance<ArrivalDistance)Arrived=true;
|
||||
else if(DestinationDistance>ArrivalDistance*1.5f)Arrived=false;
|
||||
actor.Speed=DestinationDistance>440?600:450;
|
||||
if(DestinationDistance>1500)
|
||||
{
|
||||
actor.Position=target.Position+RocketOrientation.Rotate(new(0,0,-800),target.Rotation);
|
||||
Velocity=Vector3.Zero;
|
||||
}
|
||||
actor.Animation=magnitude(Velocity)>20?"RUN":"WAG";
|
||||
}
|
||||
|
||||
private void StepPatrol()
|
||||
{
|
||||
waypoint ??= findActor(actor.Patrol ?? "none");
|
||||
|
||||
Reference in new issue
Block a user