Skip to content
This repository has been archived by the owner on Nov 1, 2024. It is now read-only.

Commit

Permalink
Update MoverController.cs
Browse files Browse the repository at this point in the history
  • Loading branch information
Vonsant authored May 3, 2024
1 parent 97b478d commit 5d22034
Showing 1 changed file with 43 additions and 0 deletions.
43 changes: 43 additions & 0 deletions Content.Server/Physics/Controllers/MoverController.cs
Original file line number Diff line number Diff line change
@@ -1,3 +1,5 @@
using System;
using System.Collections.Generic;
using System.Numerics;
using System.Runtime.CompilerServices;
using Content.Server.Shuttles.Components;
Expand Down Expand Up @@ -146,7 +148,48 @@ private void ResetSubtick(PilotComponent component)
component.LastInputTick = Timing.CurTick;
component.LastInputSubTick = 0;
}

// Corvax start
public override void UpdateBeforeSolve(bool prediction, float frameTime)

Check failure on line 153 in Content.Server/Physics/Controllers/MoverController.cs

View workflow job for this annotation

GitHub Actions / Test Packaging

Type 'MoverController' already defines a member called 'UpdateBeforeSolve' with the same parameter types

Check failure on line 153 in Content.Server/Physics/Controllers/MoverController.cs

View workflow job for this annotation

GitHub Actions / Test Packaging

Type 'MoverController' already defines a member called 'UpdateBeforeSolve' with the same parameter types

Check failure on line 153 in Content.Server/Physics/Controllers/MoverController.cs

View workflow job for this annotation

GitHub Actions / build (ubuntu-latest)

Type 'MoverController' already defines a member called 'UpdateBeforeSolve' with the same parameter types

Check failure on line 153 in Content.Server/Physics/Controllers/MoverController.cs

View workflow job for this annotation

GitHub Actions / build (ubuntu-latest)

Type 'MoverController' already defines a member called 'UpdateBeforeSolve' with the same parameter types

Check failure on line 153 in Content.Server/Physics/Controllers/MoverController.cs

View workflow job for this annotation

GitHub Actions / YAML Linter

Type 'MoverController' already defines a member called 'UpdateBeforeSolve' with the same parameter types

Check failure on line 153 in Content.Server/Physics/Controllers/MoverController.cs

View workflow job for this annotation

GitHub Actions / YAML Linter

Type 'MoverController' already defines a member called 'UpdateBeforeSolve' with the same parameter types

Check failure on line 153 in Content.Server/Physics/Controllers/MoverController.cs

View workflow job for this annotation

GitHub Actions / build (ubuntu-latest)

Type 'MoverController' already defines a member called 'UpdateBeforeSolve' with the same parameter types

Check failure on line 153 in Content.Server/Physics/Controllers/MoverController.cs

View workflow job for this annotation

GitHub Actions / build (ubuntu-latest)

Type 'MoverController' already defines a member called 'UpdateBeforeSolve' with the same parameter types
{
base.UpdateBeforeSolve(prediction, frameTime);
UpdatePilots();
HandleShuttleMovement(frameTime);
}

private void UpdatePilots()
{
var activePilotQuery = EntityQueryEnumerator<PilotComponent, InputMoverComponent>();
var shuttleQuery = GetEntityQuery<ShuttleComponent>();
var newPilots = new Dictionary<EntityUid, (ShuttleComponent Shuttle, List<(EntityUid PilotUid, PilotComponent Pilot, InputMoverComponent Mover, TransformComponent ConsoleXform)>)>();

while (activePilotQuery.MoveNext(out var uid, out var pilot, out var mover))
{
if (!IsPilotActive(pilot)) continue;

var consoleEnt = pilot.Console;
if (!TryComp<TransformComponent>(consoleEnt, out var xform)) continue;

var gridId = xform.GridUid;
if (!shuttleQuery.TryGetComponent(gridId, out var shuttleComponent) || !shuttleComponent.Enabled) continue;

if (!newPilots.TryGetValue(gridId!.Value, out var pilots))
pilots = (shuttleComponent, new List<(EntityUid, PilotComponent, InputMoverComponent, TransformComponent)>());

pilots.Item2.Add((uid, pilot, mover, xform));
newPilots[gridId.Value] = pilots;
}

_shuttlePilots = newPilots;
}

private bool IsPilotActive(PilotComponent pilot)
{
// Determine if the pilot is currently active based on input.
return pilot.HeldButtons != ShuttleButtons.None;
}
// Corvax end

protected override void HandleShuttleInput(EntityUid uid, ShuttleButtons button, ushort subTick, bool state)
{
if (!TryComp<PilotComponent>(uid, out var pilot) || pilot.Console == null)
Expand Down

0 comments on commit 5d22034

Please sign in to comment.