The real movement refactor (#9645)
* The real movement refactor * ref events * Jetpack cleanup * a * Vehicles partially working * Balance tweaks * Restore some shitcode * AAAAAAAA * Even more prediction * ECS compstate trying to fix this * yml * vehicles kill me * Don't lock keys * a * Fix problem * Fix sounds * shuttle inputs * Shuttle controls * space brakes * Keybinds * Fix merge * Handle shutdown * Fix keys * Bump friction * fix buckle offset * Fix relay and friction * Fix jetpack turning * contexts amirite
This commit is contained in:
@@ -1,9 +1,26 @@
|
||||
using Content.Client.Buckle.Strap;
|
||||
using Content.Shared.Buckle;
|
||||
using Content.Shared.Buckle.Components;
|
||||
using Robust.Shared.GameStates;
|
||||
|
||||
namespace Content.Client.Buckle
|
||||
{
|
||||
internal sealed class BuckleSystem : SharedBuckleSystem
|
||||
{
|
||||
public override void Initialize()
|
||||
{
|
||||
base.Initialize();
|
||||
SubscribeLocalEvent<StrapComponent, ComponentHandleState>(OnStrapHandleState);
|
||||
}
|
||||
|
||||
private void OnStrapHandleState(EntityUid uid, StrapComponent component, ref ComponentHandleState args)
|
||||
{
|
||||
if (args.Current is not StrapComponentState state) return;
|
||||
component.Position = state.Position;
|
||||
component.BuckleOffsetUnclamped = state.BuckleOffsetClamped;
|
||||
component.BuckledEntities.Clear();
|
||||
component.BuckledEntities.UnionWith(state.BuckledEntities);
|
||||
component.MaxBuckleDistance = state.MaxBuckleDistance;
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
@@ -1,6 +1,5 @@
|
||||
using Content.Shared.Buckle.Components;
|
||||
using Content.Shared.DragDrop;
|
||||
using Robust.Shared.GameObjects;
|
||||
|
||||
namespace Content.Client.Buckle.Strap
|
||||
{
|
||||
|
||||
@@ -172,6 +172,15 @@ namespace Content.Client.EscapeMenu.UI.Tabs
|
||||
AddButton(ContentKeyFunctions.Loadout8);
|
||||
AddButton(ContentKeyFunctions.Loadout9);
|
||||
|
||||
AddHeader("ui-options-header-shuttle");
|
||||
AddButton(ContentKeyFunctions.ShuttleStrafeUp);
|
||||
AddButton(ContentKeyFunctions.ShuttleStrafeRight);
|
||||
AddButton(ContentKeyFunctions.ShuttleStrafeLeft);
|
||||
AddButton(ContentKeyFunctions.ShuttleStrafeDown);
|
||||
AddButton(ContentKeyFunctions.ShuttleRotateLeft);
|
||||
AddButton(ContentKeyFunctions.ShuttleRotateRight);
|
||||
AddButton(ContentKeyFunctions.ShuttleBrake);
|
||||
|
||||
AddHeader("ui-options-header-map-editor");
|
||||
AddButton(EngineKeyFunctions.EditorPlaceObject);
|
||||
AddButton(EngineKeyFunctions.EditorCancelPlace);
|
||||
|
||||
@@ -94,7 +94,7 @@ public sealed class EyeLerpingSystem : EntitySystem
|
||||
return;
|
||||
|
||||
// We can't lerp if the mob can't move!
|
||||
if (!TryComp(mob, out IMoverComponent? mover))
|
||||
if (!TryComp(mob, out InputMoverComponent? mover))
|
||||
return;
|
||||
|
||||
LerpEye(_eyeManager.CurrentEye, frameTime, mover.LastGridAngle, _playerActiveEye);
|
||||
|
||||
@@ -33,6 +33,11 @@ namespace Content.Client.Input
|
||||
common.AddFunction(ContentKeyFunctions.EditorCopyObject);
|
||||
|
||||
var human = contexts.GetContext("human");
|
||||
human.AddFunction(EngineKeyFunctions.MoveUp);
|
||||
human.AddFunction(EngineKeyFunctions.MoveDown);
|
||||
human.AddFunction(EngineKeyFunctions.MoveLeft);
|
||||
human.AddFunction(EngineKeyFunctions.MoveRight);
|
||||
human.AddFunction(EngineKeyFunctions.Walk);
|
||||
human.AddFunction(ContentKeyFunctions.SwapHands);
|
||||
human.AddFunction(ContentKeyFunctions.Drop);
|
||||
human.AddFunction(ContentKeyFunctions.UseItemInHand);
|
||||
@@ -89,7 +94,7 @@ namespace Content.Client.Input
|
||||
aghost.AddFunction(ContentKeyFunctions.Drop);
|
||||
aghost.AddFunction(ContentKeyFunctions.ThrowItemInHand);
|
||||
|
||||
var ghost = contexts.New("ghost", "common");
|
||||
var ghost = contexts.New("ghost", "human");
|
||||
ghost.AddFunction(EngineKeyFunctions.MoveUp);
|
||||
ghost.AddFunction(EngineKeyFunctions.MoveDown);
|
||||
ghost.AddFunction(EngineKeyFunctions.MoveLeft);
|
||||
|
||||
@@ -1,10 +1,7 @@
|
||||
using Content.Shared.MobState.Components;
|
||||
using Content.Shared.Movement;
|
||||
using Content.Shared.Movement.Components;
|
||||
using Content.Shared.Movement.Systems;
|
||||
using Content.Shared.Pulling.Components;
|
||||
using Robust.Client.Player;
|
||||
using Robust.Shared.Map;
|
||||
using Robust.Shared.Physics;
|
||||
using Robust.Shared.Player;
|
||||
using Robust.Shared.Timing;
|
||||
@@ -20,10 +17,32 @@ namespace Content.Client.Physics.Controllers
|
||||
{
|
||||
base.UpdateBeforeSolve(prediction, frameTime);
|
||||
|
||||
if (_playerManager.LocalPlayer?.ControlledEntity is not {Valid: true} player ||
|
||||
!TryComp(player, out IMoverComponent? mover) ||
|
||||
!TryComp(player, out PhysicsComponent? body) ||
|
||||
!TryComp(player, out TransformComponent? xform))
|
||||
if (_playerManager.LocalPlayer?.ControlledEntity is not {Valid: true} player)
|
||||
return;
|
||||
|
||||
if (TryComp<RelayInputMoverComponent>(player, out var relayMover))
|
||||
{
|
||||
if (relayMover.RelayEntity != null)
|
||||
HandleClientsideMovement(relayMover.RelayEntity.Value, frameTime);
|
||||
|
||||
return;
|
||||
}
|
||||
|
||||
HandleClientsideMovement(player, frameTime);
|
||||
}
|
||||
|
||||
private void HandleClientsideMovement(EntityUid player, float frameTime)
|
||||
{
|
||||
if (!TryComp(player, out InputMoverComponent? mover) ||
|
||||
!TryComp(player, out TransformComponent? xform)) return;
|
||||
|
||||
PhysicsComponent? body = null;
|
||||
|
||||
if (mover.ToParent && HasComp<RelayInputMoverComponent>(xform.ParentUid))
|
||||
{
|
||||
if (!TryComp(xform.ParentUid, out body)) return;
|
||||
}
|
||||
else if (!TryComp(player, out body))
|
||||
{
|
||||
return;
|
||||
}
|
||||
@@ -65,13 +84,7 @@ namespace Content.Client.Physics.Controllers
|
||||
}
|
||||
|
||||
// Server-side should just be handled on its own so we'll just do this shizznit
|
||||
if (TryComp(player, out IMobMoverComponent? mobMover))
|
||||
{
|
||||
HandleMobMovement(mover, body, mobMover, xform, frameTime);
|
||||
return;
|
||||
}
|
||||
|
||||
HandleKinematicMovement(mover, body);
|
||||
HandleMobMovement(mover, body, xform, frameTime);
|
||||
}
|
||||
|
||||
protected override Filter GetSoundPlayers(EntityUid mover)
|
||||
|
||||
@@ -18,7 +18,6 @@ public sealed class ShuttleConsoleBoundUserInterface : BoundUserInterface
|
||||
{
|
||||
base.Open();
|
||||
_window = new ShuttleConsoleWindow();
|
||||
_window.ShuttleModePressed += OnShuttleModePressed;
|
||||
_window.UndockPressed += OnUndockPressed;
|
||||
_window.StartAutodockPressed += OnAutodockPressed;
|
||||
_window.StopAutodockPressed += OnStopAutodockPressed;
|
||||
@@ -65,11 +64,6 @@ public sealed class ShuttleConsoleBoundUserInterface : BoundUserInterface
|
||||
SendMessage(new UndockRequestMessage() {DockEntity = obj});
|
||||
}
|
||||
|
||||
private void OnShuttleModePressed(ShuttleMode obj)
|
||||
{
|
||||
SendMessage(new ShuttleModeRequestMessage() {Mode = obj});
|
||||
}
|
||||
|
||||
protected override void UpdateState(BoundUserInterfaceState state)
|
||||
{
|
||||
base.UpdateState(state);
|
||||
|
||||
@@ -1,16 +1,43 @@
|
||||
using Content.Shared.Input;
|
||||
using Content.Shared.Shuttles.Components;
|
||||
using Content.Shared.Shuttles.Events;
|
||||
using Content.Shared.Shuttles.Systems;
|
||||
using Robust.Client.Input;
|
||||
using Robust.Client.Player;
|
||||
using Robust.Shared.GameStates;
|
||||
|
||||
namespace Content.Client.Shuttles.Systems
|
||||
{
|
||||
public sealed class ShuttleConsoleSystem : SharedShuttleConsoleSystem
|
||||
{
|
||||
[Dependency] private readonly IInputManager _input = default!;
|
||||
[Dependency] private readonly IPlayerManager _playerManager = default!;
|
||||
|
||||
public override void Initialize()
|
||||
{
|
||||
base.Initialize();
|
||||
SubscribeLocalEvent<PilotComponent, ComponentHandleState>(OnHandleState);
|
||||
var shuttle = _input.Contexts.New("shuttle", "common");
|
||||
shuttle.AddFunction(ContentKeyFunctions.ShuttleStrafeUp);
|
||||
shuttle.AddFunction(ContentKeyFunctions.ShuttleStrafeDown);
|
||||
shuttle.AddFunction(ContentKeyFunctions.ShuttleStrafeLeft);
|
||||
shuttle.AddFunction(ContentKeyFunctions.ShuttleStrafeRight);
|
||||
shuttle.AddFunction(ContentKeyFunctions.ShuttleRotateLeft);
|
||||
shuttle.AddFunction(ContentKeyFunctions.ShuttleRotateRight);
|
||||
shuttle.AddFunction(ContentKeyFunctions.ShuttleBrake);
|
||||
}
|
||||
|
||||
public override void Shutdown()
|
||||
{
|
||||
base.Shutdown();
|
||||
_input.Contexts.Remove("shuttle");
|
||||
}
|
||||
|
||||
protected override void HandlePilotShutdown(EntityUid uid, PilotComponent component, ComponentShutdown args)
|
||||
{
|
||||
base.HandlePilotShutdown(uid, component, args);
|
||||
if (_playerManager.LocalPlayer?.ControlledEntity != uid) return;
|
||||
|
||||
_input.Contexts.SetActiveContext("human");
|
||||
}
|
||||
|
||||
private void OnHandleState(EntityUid uid, PilotComponent component, ref ComponentHandleState args)
|
||||
@@ -21,6 +48,7 @@ namespace Content.Client.Shuttles.Systems
|
||||
if (!console.IsValid())
|
||||
{
|
||||
component.Console = null;
|
||||
_input.Contexts.SetActiveContext("human");
|
||||
return;
|
||||
}
|
||||
|
||||
@@ -32,6 +60,7 @@ namespace Content.Client.Shuttles.Systems
|
||||
|
||||
component.Console = shuttleConsoleComponent;
|
||||
ActionBlockerSystem.UpdateCanMove(uid);
|
||||
_input.Contexts.SetActiveContext("shuttle");
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
@@ -83,10 +83,6 @@
|
||||
Align="Right"/>
|
||||
</GridContainer>
|
||||
</BoxContainer>
|
||||
<Button Name="ShuttleModeDisplay"
|
||||
Text="{Loc 'shuttle-console-strafing'}"
|
||||
TextAlign="Center"
|
||||
ToggleMode="True"/>
|
||||
<Button Name="IFFToggle"
|
||||
Text="{Loc 'shuttle-console-iff-toggle'}"
|
||||
TextAlign="Center"
|
||||
|
||||
@@ -40,7 +40,6 @@ public sealed partial class ShuttleConsoleWindow : FancyWindow,
|
||||
/// </summary>
|
||||
public TimeSpan FTLTime;
|
||||
|
||||
public Action<ShuttleMode>? ShuttleModePressed;
|
||||
public Action<EntityUid>? UndockPressed;
|
||||
public Action<EntityUid>? StartAutodockPressed;
|
||||
public Action<EntityUid>? StopAutodockPressed;
|
||||
@@ -61,8 +60,6 @@ public sealed partial class ShuttleConsoleWindow : FancyWindow,
|
||||
DockToggle.OnToggled += OnDockTogglePressed;
|
||||
DockToggle.Pressed = RadarScreen.ShowDocks;
|
||||
|
||||
ShuttleModeDisplay.OnToggled += OnShuttleModePressed;
|
||||
|
||||
UndockButton.OnPressed += OnUndockPressed;
|
||||
}
|
||||
|
||||
@@ -71,11 +68,6 @@ public sealed partial class ShuttleConsoleWindow : FancyWindow,
|
||||
RadarRange.Text = $"{value:0}";
|
||||
}
|
||||
|
||||
private void OnShuttleModePressed(BaseButton.ButtonEventArgs obj)
|
||||
{
|
||||
ShuttleModePressed?.Invoke(obj.Button.Pressed ? ShuttleMode.Strafing : ShuttleMode.Cruise);
|
||||
}
|
||||
|
||||
private void OnIFFTogglePressed(BaseButton.ButtonEventArgs args)
|
||||
{
|
||||
RadarScreen.ShowIFF ^= true;
|
||||
@@ -106,7 +98,6 @@ public sealed partial class ShuttleConsoleWindow : FancyWindow,
|
||||
UpdateFTL(scc.Destinations, scc.FTLState, scc.FTLTime);
|
||||
RadarScreen.UpdateState(scc);
|
||||
MaxRadarRange.Text = $"{scc.MaxRange:0}";
|
||||
ShuttleModeDisplay.Pressed = scc.Mode == ShuttleMode.Strafing;
|
||||
}
|
||||
|
||||
private void UpdateFTL(List<(EntityUid Entity, string Destination, bool Enabled)> destinations, FTLState state, TimeSpan time)
|
||||
|
||||
@@ -1,34 +1,62 @@
|
||||
using Content.Client.Buckle.Strap;
|
||||
using Content.Shared.Vehicle;
|
||||
using Robust.Client.Graphics;
|
||||
using Content.Shared.Vehicle.Components;
|
||||
using Robust.Client.GameObjects;
|
||||
using Robust.Client.Graphics;
|
||||
using Robust.Client.Player;
|
||||
using Robust.Shared.GameStates;
|
||||
|
||||
namespace Content.Client.Vehicle
|
||||
{
|
||||
public sealed class VehicleSystem : EntitySystem
|
||||
public sealed class VehicleSystem : SharedVehicleSystem
|
||||
{
|
||||
[Dependency] private readonly IEyeManager _eyeManager = default!;
|
||||
[Dependency] private readonly IPlayerManager _playerManager = default!;
|
||||
|
||||
public override void Initialize()
|
||||
{
|
||||
base.Initialize();
|
||||
SubscribeNetworkEvent<BuckledToVehicleEvent>(OnBuckle);
|
||||
SubscribeLocalEvent<RiderComponent, ComponentShutdown>(OnRiderShutdown);
|
||||
SubscribeLocalEvent<RiderComponent, ComponentHandleState>(OnRiderHandleState);
|
||||
SubscribeLocalEvent<RiderComponent, PlayerAttachedEvent>(OnRiderAttached);
|
||||
SubscribeLocalEvent<RiderComponent, PlayerDetachedEvent>(OnRiderDetached);
|
||||
}
|
||||
|
||||
private void OnBuckle(BuckledToVehicleEvent args)
|
||||
private void OnRiderShutdown(EntityUid uid, RiderComponent component, ComponentShutdown args)
|
||||
{
|
||||
// Use the vehicle's eye if we get buckled
|
||||
if (args.Buckling)
|
||||
{
|
||||
if (!TryComp<EyeComponent>(args.Vehicle, out var vehicleEye) || vehicleEye.Eye == null)
|
||||
return;
|
||||
_eyeManager.CurrentEye = vehicleEye.Eye;
|
||||
return;
|
||||
}
|
||||
// Reset if we get unbuckled.
|
||||
if (!TryComp<EyeComponent>(args.Rider, out var component) || component.Eye == null)
|
||||
return; // This probably will never happen but in this strange new world we probably want to maintain our old vision
|
||||
_eyeManager.CurrentEye = component.Eye;
|
||||
component.Vehicle = null;
|
||||
UpdateEye(component);
|
||||
}
|
||||
|
||||
private void OnRiderAttached(EntityUid uid, RiderComponent component, PlayerAttachedEvent args)
|
||||
{
|
||||
UpdateEye(component);
|
||||
}
|
||||
|
||||
private void OnRiderDetached(EntityUid uid, RiderComponent component, PlayerDetachedEvent args)
|
||||
{
|
||||
UpdateEye(component);
|
||||
}
|
||||
|
||||
private void UpdateEye(RiderComponent component)
|
||||
{
|
||||
if (!TryComp(component.Vehicle, out EyeComponent? eyeComponent))
|
||||
{
|
||||
TryComp(_playerManager.LocalPlayer?.ControlledEntity, out eyeComponent);
|
||||
}
|
||||
|
||||
if (eyeComponent?.Eye == null) return;
|
||||
|
||||
_eyeManager.CurrentEye = eyeComponent.Eye;
|
||||
}
|
||||
|
||||
private void OnRiderHandleState(EntityUid uid, RiderComponent component, ref ComponentHandleState args)
|
||||
{
|
||||
// Server should only be sending states for our entity.
|
||||
if (args.Current is not RiderComponentState state) return;
|
||||
component.Vehicle = state.Entity;
|
||||
|
||||
UpdateEye(component);
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
@@ -14,12 +14,13 @@ namespace Content.Client.Vehicle
|
||||
if (args.Sprite == null)
|
||||
return;
|
||||
|
||||
/// First check is for the sprite itself
|
||||
// First check is for the sprite itself
|
||||
if (args.Component.TryGetData(VehicleVisuals.DrawDepth, out int drawDepth))
|
||||
{
|
||||
args.Sprite.DrawDepth = drawDepth;
|
||||
}
|
||||
/// Set vehicle layer to animated or not (i.e. are the wheels turning or not)
|
||||
|
||||
// Set vehicle layer to animated or not (i.e. are the wheels turning or not)
|
||||
if (args.Component.TryGetData(VehicleVisuals.AutoAnimate, out bool autoAnimate))
|
||||
{
|
||||
args.Sprite.LayerSetAutoAnimated(VehicleVisualLayers.AutoAnimate, autoAnimate);
|
||||
|
||||
@@ -41,12 +41,6 @@ namespace Content.Server.AI.Commands
|
||||
return;
|
||||
}
|
||||
|
||||
// TODO: IMover refffaaccctttooorrr
|
||||
if (_entities.HasComponent<IMoverComponent>(entId))
|
||||
{
|
||||
_entities.RemoveComponent<IMoverComponent>(entId);
|
||||
}
|
||||
|
||||
var comp = _entities.AddComponent<UtilityAi>(entId);
|
||||
var behaviorManager = IoCManager.Resolve<INpcBehaviorManager>();
|
||||
|
||||
|
||||
@@ -123,7 +123,7 @@ namespace Content.Server.AI.Steering
|
||||
/// <exception cref="InvalidOperationException"></exception>
|
||||
public void Unregister(EntityUid entity)
|
||||
{
|
||||
if (EntityManager.TryGetComponent(entity, out SharedPlayerInputMoverComponent? controller))
|
||||
if (EntityManager.TryGetComponent(entity, out InputMoverComponent? controller))
|
||||
{
|
||||
controller.CurTickSprintMovement = Vector2.Zero;
|
||||
}
|
||||
@@ -231,11 +231,11 @@ namespace Content.Server.AI.Steering
|
||||
_listIndex = (_listIndex + 1) % _agentLists.Count;
|
||||
}
|
||||
|
||||
private void SetDirection(SharedPlayerInputMoverComponent component, Vector2 value)
|
||||
private void SetDirection(InputMoverComponent component, Vector2 value)
|
||||
{
|
||||
component.CurTickSprintMovement = value;
|
||||
component._lastInputTick = _timing.CurTick;
|
||||
component._lastInputSubTick = ushort.MaxValue;
|
||||
component.LastInputTick = _timing.CurTick;
|
||||
component.LastInputSubTick = ushort.MaxValue;
|
||||
}
|
||||
|
||||
/// <summary>
|
||||
@@ -250,7 +250,7 @@ namespace Content.Server.AI.Steering
|
||||
{
|
||||
// Main optimisation to be done below is the redundant calls and adding more variables
|
||||
if (Deleted(entity) ||
|
||||
!EntityManager.TryGetComponent(entity, out SharedPlayerInputMoverComponent? controller) ||
|
||||
!EntityManager.TryGetComponent(entity, out InputMoverComponent? controller) ||
|
||||
!controller.CanMove ||
|
||||
!TryComp(entity, out TransformComponent? xform) ||
|
||||
xform.GridUid == null)
|
||||
|
||||
@@ -18,12 +18,12 @@ namespace Content.Server.Body.Systems
|
||||
public override void Initialize()
|
||||
{
|
||||
base.Initialize();
|
||||
SubscribeLocalEvent<BodyComponent, RelayMoveInputEvent>(OnRelayMoveInput);
|
||||
SubscribeLocalEvent<BodyComponent, MoveInputEvent>(OnRelayMoveInput);
|
||||
SubscribeLocalEvent<BodyComponent, ApplyMetabolicMultiplierEvent>(OnApplyMetabolicMultiplier);
|
||||
SubscribeLocalEvent<BodyComponent, BeingMicrowavedEvent>(OnBeingMicrowaved);
|
||||
}
|
||||
|
||||
private void OnRelayMoveInput(EntityUid uid, BodyComponent component, RelayMoveInputEvent args)
|
||||
private void OnRelayMoveInput(EntityUid uid, BodyComponent component, ref MoveInputEvent args)
|
||||
{
|
||||
if (EntityManager.TryGetComponent<MobStateComponent>(uid, out var mobState) &&
|
||||
mobState.IsDead() &&
|
||||
|
||||
@@ -40,8 +40,7 @@ namespace Content.Server.Body.Systems
|
||||
Comp<GhostOnMoveComponent>(newEntity).MustBeDead = true;
|
||||
|
||||
// TODO: This is an awful solution.
|
||||
if (!EntityManager.HasComponent<IMoverComponent>(newEntity))
|
||||
EntityManager.AddComponent<SharedDummyInputMoverComponent>(newEntity);
|
||||
EnsureComp<InputMoverComponent>(newEntity);
|
||||
|
||||
oldMind.Mind?.TransferTo(newEntity);
|
||||
}
|
||||
|
||||
@@ -68,7 +68,7 @@ namespace Content.Server.Buckle.Components
|
||||
_buckledTo = value;
|
||||
_buckleTime = _gameTiming.CurTime;
|
||||
_sysMan.GetEntitySystem<ActionBlockerSystem>().UpdateCanMove(Owner);
|
||||
Dirty(_entMan);
|
||||
Dirty(EntMan);
|
||||
}
|
||||
}
|
||||
|
||||
@@ -99,33 +99,6 @@ namespace Content.Server.Buckle.Components
|
||||
}
|
||||
}
|
||||
|
||||
/// <summary>
|
||||
/// Reattaches this entity to the strap, modifying its position and rotation.
|
||||
/// </summary>
|
||||
/// <param name="strap">The strap to reattach to.</param>
|
||||
public void ReAttach(StrapComponent strap)
|
||||
{
|
||||
var ownTransform = _entMan.GetComponent<TransformComponent>(Owner);
|
||||
var strapTransform = _entMan.GetComponent<TransformComponent>(strap.Owner);
|
||||
|
||||
ownTransform.AttachParent(strapTransform);
|
||||
ownTransform.LocalRotation = Angle.Zero;
|
||||
|
||||
switch (strap.Position)
|
||||
{
|
||||
case StrapPosition.None:
|
||||
break;
|
||||
case StrapPosition.Stand:
|
||||
EntitySystem.Get<StandingStateSystem>().Stand(Owner);
|
||||
break;
|
||||
case StrapPosition.Down:
|
||||
EntitySystem.Get<StandingStateSystem>().Down(Owner, false, false);
|
||||
break;
|
||||
}
|
||||
|
||||
ownTransform.LocalPosition = strap.BuckleOffset;
|
||||
}
|
||||
|
||||
public bool CanBuckle(EntityUid user, EntityUid to, [NotNullWhen(true)] out StrapComponent? strap)
|
||||
{
|
||||
var popupSystem = EntitySystem.Get<SharedPopupSystem>();
|
||||
@@ -136,7 +109,7 @@ namespace Content.Server.Buckle.Components
|
||||
return false;
|
||||
}
|
||||
|
||||
if (!_entMan.TryGetComponent(to, out strap))
|
||||
if (!EntMan.TryGetComponent(to, out strap))
|
||||
{
|
||||
return false;
|
||||
}
|
||||
@@ -160,7 +133,7 @@ namespace Content.Server.Buckle.Components
|
||||
}
|
||||
}
|
||||
|
||||
if (!_entMan.HasComponent<HandsComponent>(user))
|
||||
if (!EntMan.HasComponent<HandsComponent>(user))
|
||||
{
|
||||
popupSystem.PopupEntity(Loc.GetString("buckle-component-no-hands-message"), user, Filter.Entities(user));
|
||||
return false;
|
||||
@@ -176,10 +149,10 @@ namespace Content.Server.Buckle.Components
|
||||
return false;
|
||||
}
|
||||
|
||||
var parent = _entMan.GetComponent<TransformComponent>(to).Parent;
|
||||
var parent = EntMan.GetComponent<TransformComponent>(to).Parent;
|
||||
while (parent != null)
|
||||
{
|
||||
if (parent == _entMan.GetComponent<TransformComponent>(user))
|
||||
if (parent == EntMan.GetComponent<TransformComponent>(user))
|
||||
{
|
||||
var message = Loc.GetString(Owner == user
|
||||
? "buckle-component-cannot-buckle-message"
|
||||
@@ -224,7 +197,7 @@ namespace Content.Server.Buckle.Components
|
||||
return false;
|
||||
}
|
||||
|
||||
if(_entMan.TryGetComponent<AppearanceComponent>(Owner, out var appearance))
|
||||
if(EntMan.TryGetComponent<AppearanceComponent>(Owner, out var appearance))
|
||||
appearance.SetData(BuckleVisuals.Buckled, true);
|
||||
|
||||
ReAttach(strap);
|
||||
@@ -236,10 +209,10 @@ namespace Content.Server.Buckle.Components
|
||||
UpdateBuckleStatus();
|
||||
|
||||
var ev = new BuckleChangeEvent() { Buckling = true, Strap = BuckledTo.Owner, BuckledEntity = Owner };
|
||||
_entMan.EventBus.RaiseLocalEvent(ev.BuckledEntity, ev, false);
|
||||
_entMan.EventBus.RaiseLocalEvent(ev.Strap, ev, false);
|
||||
EntMan.EventBus.RaiseLocalEvent(ev.BuckledEntity, ev, false);
|
||||
EntMan.EventBus.RaiseLocalEvent(ev.Strap, ev, false);
|
||||
|
||||
if (_entMan.TryGetComponent(Owner, out SharedPullableComponent? ownerPullable))
|
||||
if (EntMan.TryGetComponent(Owner, out SharedPullableComponent? ownerPullable))
|
||||
{
|
||||
if (ownerPullable.Puller != null)
|
||||
{
|
||||
@@ -247,7 +220,7 @@ namespace Content.Server.Buckle.Components
|
||||
}
|
||||
}
|
||||
|
||||
if (_entMan.TryGetComponent(to, out SharedPullableComponent? toPullable))
|
||||
if (EntMan.TryGetComponent(to, out SharedPullableComponent? toPullable))
|
||||
{
|
||||
if (toPullable.Puller == Owner)
|
||||
{
|
||||
@@ -292,7 +265,7 @@ namespace Content.Server.Buckle.Components
|
||||
return false;
|
||||
}
|
||||
// If the strap is a vehicle and the rider is not the person unbuckling, return.
|
||||
if (_entMan.TryGetComponent<VehicleComponent>(oldBuckledTo.Owner, out var vehicle) &&
|
||||
if (EntMan.TryGetComponent<VehicleComponent>(oldBuckledTo.Owner, out var vehicle) &&
|
||||
vehicle.Rider != user)
|
||||
return false;
|
||||
}
|
||||
@@ -312,11 +285,11 @@ namespace Content.Server.Buckle.Components
|
||||
xform.Coordinates = oldBuckledXform.Coordinates.Offset(oldBuckledTo.UnbuckleOffset);
|
||||
}
|
||||
|
||||
if(_entMan.TryGetComponent<AppearanceComponent>(Owner, out var appearance))
|
||||
if(EntMan.TryGetComponent<AppearanceComponent>(Owner, out var appearance))
|
||||
appearance.SetData(BuckleVisuals.Buckled, false);
|
||||
|
||||
if (_entMan.HasComponent<KnockedDownComponent>(Owner)
|
||||
| (_entMan.TryGetComponent<MobStateComponent>(Owner, out var mobState) && mobState.IsIncapacitated()))
|
||||
if (EntMan.HasComponent<KnockedDownComponent>(Owner)
|
||||
| (EntMan.TryGetComponent<MobStateComponent>(Owner, out var mobState) && mobState.IsIncapacitated()))
|
||||
{
|
||||
EntitySystem.Get<StandingStateSystem>().Down(Owner);
|
||||
}
|
||||
@@ -334,8 +307,8 @@ namespace Content.Server.Buckle.Components
|
||||
SoundSystem.Play(oldBuckledTo.UnbuckleSound.GetSound(), Filter.Pvs(Owner), Owner);
|
||||
|
||||
var ev = new BuckleChangeEvent() { Buckling = false, Strap = oldBuckledTo.Owner, BuckledEntity = Owner };
|
||||
_entMan.EventBus.RaiseLocalEvent(Owner, ev, false);
|
||||
_entMan.EventBus.RaiseLocalEvent(oldBuckledTo.Owner, ev, false);
|
||||
EntMan.EventBus.RaiseLocalEvent(Owner, ev, false);
|
||||
EntMan.EventBus.RaiseLocalEvent(oldBuckledTo.Owner, ev, false);
|
||||
|
||||
return true;
|
||||
}
|
||||
@@ -386,8 +359,8 @@ namespace Content.Server.Buckle.Components
|
||||
int? drawDepth = null;
|
||||
|
||||
if (BuckledTo != null &&
|
||||
_entMan.GetComponent<TransformComponent>(BuckledTo.Owner).LocalRotation.GetCardinalDir() == Direction.North &&
|
||||
_entMan.TryGetComponent<SpriteComponent>(BuckledTo.Owner, out var spriteComponent))
|
||||
EntMan.GetComponent<TransformComponent>(BuckledTo.Owner).LocalRotation.GetCardinalDir() == Direction.North &&
|
||||
EntMan.TryGetComponent<SpriteComponent>(BuckledTo.Owner, out var spriteComponent))
|
||||
{
|
||||
drawDepth = spriteComponent.DrawDepth - 1;
|
||||
}
|
||||
|
||||
@@ -10,12 +10,10 @@ namespace Content.Server.Buckle.Components
|
||||
{
|
||||
[RegisterComponent]
|
||||
[ComponentReference(typeof(SharedStrapComponent))]
|
||||
public sealed class StrapComponent : SharedStrapComponent, ISerializationHooks
|
||||
public sealed class StrapComponent : SharedStrapComponent
|
||||
{
|
||||
[Dependency] private readonly IEntityManager _entityManager = default!;
|
||||
|
||||
private readonly HashSet<EntityUid> _buckledEntities = new();
|
||||
|
||||
/// <summary>
|
||||
/// The angle in degrees to rotate the player by when they get strapped
|
||||
/// </summary>
|
||||
@@ -28,13 +26,6 @@ namespace Content.Server.Buckle.Components
|
||||
[ViewVariables] [DataField("size")] private int _size = 100;
|
||||
private int _occupiedSize;
|
||||
|
||||
/// <summary>
|
||||
/// The buckled entity will be offset by this amount from the center of the strap object.
|
||||
/// If this offset it too big, it will be clamped to <see cref="MaxBuckleDistance"/>
|
||||
/// </summary>
|
||||
[DataField("buckleOffset", required: false)]
|
||||
public Vector2 BuckleOffsetUnclamped = Vector2.Zero;
|
||||
|
||||
private bool _enabled = true;
|
||||
|
||||
/// <summary>
|
||||
@@ -51,38 +42,11 @@ namespace Content.Server.Buckle.Components
|
||||
}
|
||||
}
|
||||
|
||||
/// <summary>
|
||||
/// The distance above which a buckled entity will be automatically unbuckled.
|
||||
/// Don't change it unless you really have to
|
||||
/// </summary>
|
||||
[DataField("maxBuckleDistance", required: false)]
|
||||
public float MaxBuckleDistance = 0.1f;
|
||||
|
||||
/// <summary>
|
||||
/// You can specify the offset the entity will have after unbuckling.
|
||||
/// </summary>
|
||||
[DataField("unbuckleOffset", required: false)]
|
||||
public Vector2 UnbuckleOffset = Vector2.Zero;
|
||||
|
||||
/// <summary>
|
||||
/// Gets and clamps the buckle offset to MaxBuckleDistance
|
||||
/// </summary>
|
||||
public Vector2 BuckleOffset => Vector2.Clamp(
|
||||
BuckleOffsetUnclamped,
|
||||
Vector2.One * -MaxBuckleDistance,
|
||||
Vector2.One * MaxBuckleDistance);
|
||||
|
||||
/// <summary>
|
||||
/// The entity that is currently buckled here, synced from <see cref="BuckleComponent.BuckledTo"/>
|
||||
/// </summary>
|
||||
public IReadOnlyCollection<EntityUid> BuckledEntities => _buckledEntities;
|
||||
|
||||
/// <summary>
|
||||
/// The change in position to the strapped mob
|
||||
/// </summary>
|
||||
[DataField("position")]
|
||||
public StrapPosition Position { get; } = StrapPosition.None;
|
||||
|
||||
/// <summary>
|
||||
/// The sound to be played when a mob is buckled
|
||||
/// </summary>
|
||||
@@ -138,7 +102,7 @@ namespace Content.Server.Buckle.Components
|
||||
return false;
|
||||
}
|
||||
|
||||
if (!_buckledEntities.Add(buckle.Owner))
|
||||
if (!BuckledEntities.Add(buckle.Owner))
|
||||
{
|
||||
return false;
|
||||
}
|
||||
@@ -154,6 +118,7 @@ namespace Content.Server.Buckle.Components
|
||||
appearance.SetData("StrapState", true);
|
||||
}
|
||||
|
||||
Dirty();
|
||||
return true;
|
||||
}
|
||||
|
||||
@@ -164,7 +129,7 @@ namespace Content.Server.Buckle.Components
|
||||
/// <param name="buckle">The component to remove</param>
|
||||
public void Remove(BuckleComponent buckle)
|
||||
{
|
||||
if (_buckledEntities.Remove(buckle.Owner))
|
||||
if (BuckledEntities.Remove(buckle.Owner))
|
||||
{
|
||||
if (IoCManager.Resolve<IEntityManager>().TryGetComponent<AppearanceComponent>(Owner, out var appearance))
|
||||
{
|
||||
@@ -172,6 +137,7 @@ namespace Content.Server.Buckle.Components
|
||||
}
|
||||
|
||||
_occupiedSize -= buckle.Size;
|
||||
Dirty();
|
||||
}
|
||||
}
|
||||
|
||||
@@ -186,7 +152,7 @@ namespace Content.Server.Buckle.Components
|
||||
{
|
||||
var entManager = IoCManager.Resolve<IEntityManager>();
|
||||
|
||||
foreach (var entity in _buckledEntities.ToArray())
|
||||
foreach (var entity in BuckledEntities.ToArray())
|
||||
{
|
||||
if (entManager.TryGetComponent<BuckleComponent>(entity, out var buckle))
|
||||
{
|
||||
@@ -194,13 +160,9 @@ namespace Content.Server.Buckle.Components
|
||||
}
|
||||
}
|
||||
|
||||
_buckledEntities.Clear();
|
||||
BuckledEntities.Clear();
|
||||
_occupiedSize = 0;
|
||||
}
|
||||
|
||||
public override ComponentState GetComponentState()
|
||||
{
|
||||
return new StrapComponentState(Position);
|
||||
Dirty();
|
||||
}
|
||||
|
||||
public override bool DragDropOn(DragDropEvent eventArgs)
|
||||
|
||||
@@ -2,11 +2,13 @@ using Content.Server.Buckle.Components;
|
||||
using Content.Server.Interaction;
|
||||
using Content.Server.Storage.Components;
|
||||
using Content.Shared.Buckle;
|
||||
using Content.Shared.Buckle.Components;
|
||||
using Content.Shared.Interaction;
|
||||
using Content.Shared.Verbs;
|
||||
using JetBrains.Annotations;
|
||||
using Robust.Server.GameObjects;
|
||||
using Robust.Shared.Containers;
|
||||
using Robust.Shared.GameStates;
|
||||
|
||||
namespace Content.Server.Buckle.Systems
|
||||
{
|
||||
@@ -20,20 +22,21 @@ namespace Content.Server.Buckle.Systems
|
||||
UpdatesAfter.Add(typeof(InteractionSystem));
|
||||
UpdatesAfter.Add(typeof(InputSystem));
|
||||
|
||||
SubscribeLocalEvent<BuckleComponent, MoveEvent>(MoveEvent);
|
||||
|
||||
SubscribeLocalEvent<StrapComponent, RotateEvent>(RotateEvent);
|
||||
|
||||
SubscribeLocalEvent<StrapComponent, ComponentGetState>(OnStrapGetState);
|
||||
SubscribeLocalEvent<StrapComponent, EntInsertedIntoContainerMessage>(ContainerModifiedStrap);
|
||||
|
||||
SubscribeLocalEvent<StrapComponent, EntRemovedFromContainerMessage>(ContainerModifiedStrap);
|
||||
|
||||
SubscribeLocalEvent<BuckleComponent, MoveEvent>(MoveEvent);
|
||||
SubscribeLocalEvent<BuckleComponent, InteractHandEvent>(HandleInteractHand);
|
||||
|
||||
SubscribeLocalEvent<BuckleComponent, GetVerbsEvent<InteractionVerb>>(AddUnbuckleVerb);
|
||||
SubscribeLocalEvent<BuckleComponent, InsertIntoEntityStorageAttemptEvent>(OnEntityStorageInsertAttempt);
|
||||
}
|
||||
|
||||
private void OnStrapGetState(EntityUid uid, StrapComponent component, ref ComponentGetState args)
|
||||
{
|
||||
args.State = new StrapComponentState(component.Position, component.BuckleOffset, component.BuckledEntities, component.MaxBuckleDistance);
|
||||
}
|
||||
|
||||
private void AddUnbuckleVerb(EntityUid uid, BuckleComponent component, GetVerbsEvent<InteractionVerb> args)
|
||||
{
|
||||
if (!args.CanAccess || !args.CanInteract || !component.Buckled)
|
||||
@@ -80,21 +83,6 @@ namespace Content.Server.Buckle.Systems
|
||||
buckle.TryUnbuckle(buckle.Owner, true);
|
||||
}
|
||||
|
||||
private void RotateEvent(EntityUid uid, StrapComponent strap, ref RotateEvent ev)
|
||||
{
|
||||
// On rotation of a strap, reattach all buckled entities.
|
||||
// This fixes buckle offsets and draw depths.
|
||||
foreach (var buckledEntity in strap.BuckledEntities)
|
||||
{
|
||||
if (!EntityManager.TryGetComponent(buckledEntity, out BuckleComponent? buckled))
|
||||
{
|
||||
continue;
|
||||
}
|
||||
buckled.ReAttach(strap);
|
||||
Dirty(buckled);
|
||||
}
|
||||
}
|
||||
|
||||
private void ContainerModifiedStrap(EntityUid uid, StrapComponent strap, ContainerModifiedMessage message)
|
||||
{
|
||||
foreach (var buckledEntity in strap.BuckledEntities)
|
||||
|
||||
@@ -24,7 +24,7 @@ namespace Content.Server.Disposal.Tube
|
||||
base.Initialize();
|
||||
|
||||
SubscribeLocalEvent<DisposalTubeComponent, PhysicsBodyTypeChangedEvent>(BodyTypeChanged);
|
||||
SubscribeLocalEvent<DisposalTubeComponent, RelayMovementEntityEvent>(OnRelayMovement);
|
||||
SubscribeLocalEvent<DisposalTubeComponent, ContainerRelayMovementEntityEvent>(OnRelayMovement);
|
||||
SubscribeLocalEvent<DisposalTubeComponent, BreakageEventArgs>(OnBreak);
|
||||
SubscribeLocalEvent<DisposalTaggerComponent, GetVerbsEvent<InteractionVerb>>(AddOpenUIVerbs);
|
||||
SubscribeLocalEvent<DisposalRouterComponent, GetVerbsEvent<InteractionVerb>>(AddOpenUIVerbs);
|
||||
@@ -65,7 +65,7 @@ namespace Content.Server.Disposal.Tube
|
||||
args.Verbs.Add(verb);
|
||||
}
|
||||
|
||||
private void OnRelayMovement(EntityUid uid, DisposalTubeComponent component, RelayMovementEntityEvent args)
|
||||
private void OnRelayMovement(EntityUid uid, DisposalTubeComponent component, ref ContainerRelayMovementEntityEvent args)
|
||||
{
|
||||
if (_gameTiming.CurTime < component.LastClang + DisposalTubeComponent.ClangDelay)
|
||||
{
|
||||
|
||||
@@ -53,7 +53,7 @@ namespace Content.Server.Disposal.Unit.EntitySystems
|
||||
// Shouldn't need re-anchoring.
|
||||
SubscribeLocalEvent<DisposalUnitComponent, AnchorStateChangedEvent>(OnAnchorChanged);
|
||||
// TODO: Predict me when hands predicted
|
||||
SubscribeLocalEvent<DisposalUnitComponent, RelayMovementEntityEvent>(HandleMovement);
|
||||
SubscribeLocalEvent<DisposalUnitComponent, ContainerRelayMovementEntityEvent>(HandleMovement);
|
||||
SubscribeLocalEvent<DisposalUnitComponent, PowerChangedEvent>(HandlePowerChange);
|
||||
|
||||
// Component lifetime
|
||||
@@ -376,7 +376,7 @@ namespace Content.Server.Disposal.Unit.EntitySystems
|
||||
}
|
||||
}
|
||||
|
||||
private void HandleMovement(EntityUid uid, DisposalUnitComponent component, RelayMovementEntityEvent args)
|
||||
private void HandleMovement(EntityUid uid, DisposalUnitComponent component, ref ContainerRelayMovementEntityEvent args)
|
||||
{
|
||||
var currentTime = GameTiming.CurTime;
|
||||
|
||||
|
||||
@@ -44,7 +44,7 @@ namespace Content.Server.Ghost
|
||||
SubscribeLocalEvent<GhostComponent, MindRemovedMessage>(OnMindRemovedMessage);
|
||||
SubscribeLocalEvent<GhostComponent, MindUnvisitedMessage>(OnMindUnvisitedMessage);
|
||||
|
||||
SubscribeLocalEvent<GhostOnMoveComponent, RelayMoveInputEvent>(OnRelayMoveInput);
|
||||
SubscribeLocalEvent<GhostOnMoveComponent, MoveInputEvent>(OnRelayMoveInput);
|
||||
|
||||
SubscribeNetworkEvent<GhostWarpsRequestEvent>(OnGhostWarpsRequest);
|
||||
SubscribeNetworkEvent<GhostReturnToBodyRequest>(OnGhostReturnToBodyRequest);
|
||||
@@ -77,7 +77,7 @@ namespace Content.Server.Ghost
|
||||
args.Handled = true;
|
||||
}
|
||||
|
||||
private void OnRelayMoveInput(EntityUid uid, GhostOnMoveComponent component, RelayMoveInputEvent args)
|
||||
private void OnRelayMoveInput(EntityUid uid, GhostOnMoveComponent component, ref MoveInputEvent args)
|
||||
{
|
||||
// Let's not ghost if our mind is visiting...
|
||||
if (EntityManager.HasComponent<VisitingMindComponent>(uid)) return;
|
||||
|
||||
@@ -75,7 +75,7 @@ namespace Content.Server.Medical.CrewMonitoring
|
||||
// the monitor. But in the special case where the monitor IS a player (i.e., admin ghost), we base it off
|
||||
// the players eye rotation. We don't know what that is for sure, but we know their last grid angle, which
|
||||
// should work well enough?
|
||||
if (TryComp(uid, out IMoverComponent? mover))
|
||||
if (TryComp(uid, out InputMoverComponent? mover))
|
||||
worldRot = mover.LastGridAngle;
|
||||
else if (_mapManager.TryGetGrid(xform.GridUid, out var grid))
|
||||
worldRot = grid.WorldRotation;
|
||||
|
||||
@@ -41,7 +41,7 @@ namespace Content.Server.Medical
|
||||
|
||||
SubscribeLocalEvent<MedicalScannerComponent, ComponentInit>(OnComponentInit);
|
||||
SubscribeLocalEvent<MedicalScannerComponent, ActivateInWorldEvent>(OnActivated);
|
||||
SubscribeLocalEvent<MedicalScannerComponent, RelayMovementEntityEvent>(OnRelayMovement);
|
||||
SubscribeLocalEvent<MedicalScannerComponent, ContainerRelayMovementEntityEvent>(OnRelayMovement);
|
||||
SubscribeLocalEvent<MedicalScannerComponent, GetVerbsEvent<InteractionVerb>>(AddInsertOtherVerb);
|
||||
SubscribeLocalEvent<MedicalScannerComponent, GetVerbsEvent<AlternativeVerb>>(AddAlternativeVerbs);
|
||||
SubscribeLocalEvent<MedicalScannerComponent, DestructionEventArgs>(OnDestroyed);
|
||||
@@ -65,7 +65,7 @@ namespace Content.Server.Medical
|
||||
UpdateUserInterface(uid, scannerComponent);
|
||||
}
|
||||
|
||||
private void OnRelayMovement(EntityUid uid, MedicalScannerComponent scannerComponent, RelayMovementEntityEvent args)
|
||||
private void OnRelayMovement(EntityUid uid, MedicalScannerComponent scannerComponent, ref ContainerRelayMovementEntityEvent args)
|
||||
{
|
||||
if (!_blocker.CanInteract(args.Entity, scannerComponent.Owner))
|
||||
return;
|
||||
|
||||
@@ -44,13 +44,12 @@ namespace Content.Server.Mind.Commands
|
||||
|
||||
public static void MakeSentient(EntityUid uid, IEntityManager entityManager)
|
||||
{
|
||||
if(entityManager.HasComponent<AiControllerComponent>(uid))
|
||||
entityManager.RemoveComponent<AiControllerComponent>(uid);
|
||||
|
||||
entityManager.RemoveComponent<AiControllerComponent>(uid);
|
||||
|
||||
entityManager.EnsureComponent<MindComponent>(uid);
|
||||
entityManager.EnsureComponent<SharedPlayerInputMoverComponent>(uid);
|
||||
entityManager.EnsureComponent<SharedPlayerMobMoverComponent>(uid);
|
||||
entityManager.EnsureComponent<InputMoverComponent>(uid);
|
||||
entityManager.EnsureComponent<MobMoverComponent>(uid);
|
||||
entityManager.EnsureComponent<MovementSpeedModifierComponent>(uid);
|
||||
entityManager.EnsureComponent<SharedSpeechComponent>(uid);
|
||||
entityManager.EnsureComponent<SharedEmotingComponent>(uid);
|
||||
entityManager.EnsureComponent<ExaminerComponent>(uid);
|
||||
|
||||
@@ -1,15 +1,12 @@
|
||||
using Content.Server.Cargo.Components;
|
||||
using Content.Server.Shuttles.Components;
|
||||
using Content.Server.Shuttles.Systems;
|
||||
using Content.Shared.Vehicle.Components;
|
||||
using Content.Shared.Movement;
|
||||
using Content.Shared.Movement.Components;
|
||||
using Content.Shared.Movement.Systems;
|
||||
using Content.Shared.Shuttles.Components;
|
||||
using Content.Shared.Shuttles.Systems;
|
||||
using Robust.Shared.Map;
|
||||
using Robust.Shared.Player;
|
||||
using Robust.Shared.Utility;
|
||||
|
||||
namespace Content.Server.Physics.Controllers
|
||||
{
|
||||
@@ -18,14 +15,8 @@ namespace Content.Server.Physics.Controllers
|
||||
[Dependency] private readonly IMapManager _mapManager = default!;
|
||||
[Dependency] private readonly ShuttleSystem _shuttle = default!;
|
||||
[Dependency] private readonly ThrusterSystem _thruster = default!;
|
||||
/// <summary>
|
||||
/// These mobs will get skipped over when checking which mobs
|
||||
/// should be moved. Prediction is handled elsewhere by
|
||||
/// cancelling the movement attempt in the shared and
|
||||
/// client namespace.
|
||||
/// </summary>
|
||||
private HashSet<EntityUid> _excludedMobs = new();
|
||||
private Dictionary<ShuttleComponent, List<(PilotComponent, IMoverComponent, TransformComponent)>> _shuttlePilots = new();
|
||||
|
||||
private Dictionary<ShuttleComponent, List<(PilotComponent, InputMoverComponent, TransformComponent)>> _shuttlePilots = new();
|
||||
|
||||
protected override Filter GetSoundPlayers(EntityUid mover)
|
||||
{
|
||||
@@ -40,31 +31,166 @@ namespace Content.Server.Physics.Controllers
|
||||
public override void UpdateBeforeSolve(bool prediction, float frameTime)
|
||||
{
|
||||
base.UpdateBeforeSolve(prediction, frameTime);
|
||||
_excludedMobs.Clear();
|
||||
|
||||
foreach (var (mobMover, mover, physics, xform) in EntityManager.EntityQuery<IMobMoverComponent, IMoverComponent, PhysicsComponent, TransformComponent>())
|
||||
var bodyQuery = GetEntityQuery<PhysicsComponent>();
|
||||
var relayQuery = GetEntityQuery<RelayInputMoverComponent>();
|
||||
|
||||
foreach (var (mover, xform) in EntityQuery<InputMoverComponent, TransformComponent>())
|
||||
{
|
||||
_excludedMobs.Add(mover.Owner);
|
||||
HandleMobMovement(mover, physics, mobMover, xform, frameTime);
|
||||
if (relayQuery.TryGetComponent(mover.Owner, out var relayed) && relayed != null)
|
||||
{
|
||||
continue;
|
||||
}
|
||||
|
||||
PhysicsComponent? body = null;
|
||||
|
||||
if (mover.ToParent && relayQuery.HasComponent(xform.ParentUid))
|
||||
{
|
||||
if (!bodyQuery.TryGetComponent(xform.ParentUid, out body)) continue;
|
||||
}
|
||||
else if (!bodyQuery.TryGetComponent(mover.Owner, out body))
|
||||
{
|
||||
continue;
|
||||
}
|
||||
|
||||
HandleMobMovement(mover, body, xform, frameTime);
|
||||
}
|
||||
|
||||
HandleShuttleMovement(frameTime);
|
||||
HandleVehicleMovement();
|
||||
}
|
||||
|
||||
foreach (var (mover, physics) in EntityManager.EntityQuery<IMoverComponent, PhysicsComponent>(true))
|
||||
public (Vector2 Strafe, float Rotation, float Brakes) GetPilotVelocityInput(PilotComponent component)
|
||||
{
|
||||
if (!Timing.InSimulation)
|
||||
{
|
||||
if (_excludedMobs.Contains(mover.Owner)) continue;
|
||||
|
||||
HandleKinematicMovement(mover, physics);
|
||||
// Outside of simulation we'll be running client predicted movement per-frame.
|
||||
// So return a full-length vector as if it's a full tick.
|
||||
// Physics system will have the correct time step anyways.
|
||||
ResetSubtick(component);
|
||||
ApplyTick(component, 1f);
|
||||
return (component.CurTickStrafeMovement, component.CurTickRotationMovement, component.CurTickBraking);
|
||||
}
|
||||
|
||||
float remainingFraction;
|
||||
|
||||
if (Timing.CurTick > component.LastInputTick)
|
||||
{
|
||||
component.CurTickStrafeMovement = Vector2.Zero;
|
||||
component.CurTickRotationMovement = 0f;
|
||||
component.CurTickBraking = 0f;
|
||||
remainingFraction = 1;
|
||||
}
|
||||
else
|
||||
{
|
||||
remainingFraction = (ushort.MaxValue - component.LastInputSubTick) / (float) ushort.MaxValue;
|
||||
}
|
||||
|
||||
ApplyTick(component, remainingFraction);
|
||||
|
||||
// Logger.Info($"{curDir}{walk}{sprint}");
|
||||
return (component.CurTickStrafeMovement, component.CurTickRotationMovement, component.CurTickBraking);
|
||||
}
|
||||
|
||||
private void ResetSubtick(PilotComponent component)
|
||||
{
|
||||
if (Timing.CurTick <= component.LastInputTick) return;
|
||||
|
||||
component.CurTickStrafeMovement = Vector2.Zero;
|
||||
component.CurTickRotationMovement = 0f;
|
||||
component.CurTickBraking = 0f;
|
||||
component.LastInputTick = Timing.CurTick;
|
||||
component.LastInputSubTick = 0;
|
||||
}
|
||||
|
||||
protected override void HandleShuttleInput(EntityUid uid, ShuttleButtons button, ushort subTick, bool state)
|
||||
{
|
||||
if (!TryComp<PilotComponent>(uid, out var pilot) || pilot.Console == null) return;
|
||||
|
||||
ResetSubtick(pilot);
|
||||
|
||||
if (subTick >= pilot.LastInputSubTick)
|
||||
{
|
||||
var fraction = (subTick - pilot.LastInputSubTick) / (float) ushort.MaxValue;
|
||||
|
||||
ApplyTick(pilot, fraction);
|
||||
pilot.LastInputSubTick = subTick;
|
||||
}
|
||||
|
||||
var buttons = pilot.HeldButtons;
|
||||
|
||||
if (state)
|
||||
{
|
||||
buttons |= button;
|
||||
}
|
||||
else
|
||||
{
|
||||
buttons &= ~button;
|
||||
}
|
||||
|
||||
pilot.HeldButtons = buttons;
|
||||
}
|
||||
|
||||
private void ApplyTick(PilotComponent component, float fraction)
|
||||
{
|
||||
var x = 0;
|
||||
var y = 0;
|
||||
var rot = 0;
|
||||
int brake;
|
||||
|
||||
if ((component.HeldButtons & ShuttleButtons.StrafeLeft) != 0x0)
|
||||
{
|
||||
x -= 1;
|
||||
}
|
||||
|
||||
if ((component.HeldButtons & ShuttleButtons.StrafeRight) != 0x0)
|
||||
{
|
||||
x += 1;
|
||||
}
|
||||
|
||||
component.CurTickStrafeMovement.X += x * fraction;
|
||||
|
||||
if ((component.HeldButtons & ShuttleButtons.StrafeUp) != 0x0)
|
||||
{
|
||||
y += 1;
|
||||
}
|
||||
|
||||
if ((component.HeldButtons & ShuttleButtons.StrafeDown) != 0x0)
|
||||
{
|
||||
y -= 1;
|
||||
}
|
||||
|
||||
component.CurTickStrafeMovement.Y += y * fraction;
|
||||
|
||||
if ((component.HeldButtons & ShuttleButtons.RotateLeft) != 0x0)
|
||||
{
|
||||
rot -= 1;
|
||||
}
|
||||
|
||||
if ((component.HeldButtons & ShuttleButtons.RotateRight) != 0x0)
|
||||
{
|
||||
rot += 1;
|
||||
}
|
||||
|
||||
component.CurTickRotationMovement += rot * fraction;
|
||||
|
||||
if ((component.HeldButtons & ShuttleButtons.Brake) != 0x0)
|
||||
{
|
||||
brake = 1;
|
||||
}
|
||||
else
|
||||
{
|
||||
brake = 0;
|
||||
}
|
||||
|
||||
component.CurTickBraking += brake * fraction;
|
||||
}
|
||||
|
||||
private void HandleShuttleMovement(float frameTime)
|
||||
{
|
||||
var newPilots = new Dictionary<ShuttleComponent, List<(PilotComponent Pilot, IMoverComponent Mover, TransformComponent ConsoleXform)>>();
|
||||
var newPilots = new Dictionary<ShuttleComponent, List<(PilotComponent Pilot, InputMoverComponent Mover, TransformComponent ConsoleXform)>>();
|
||||
|
||||
// We just mark off their movement and the shuttle itself does its own movement
|
||||
foreach (var (pilot, mover) in EntityManager.EntityQuery<PilotComponent, SharedPlayerInputMoverComponent>())
|
||||
foreach (var (pilot, mover) in EntityManager.EntityQuery<PilotComponent, InputMoverComponent>())
|
||||
{
|
||||
var consoleEnt = pilot.Console?.Owner;
|
||||
|
||||
@@ -76,8 +202,6 @@ namespace Content.Server.Physics.Controllers
|
||||
|
||||
if (!TryComp<TransformComponent>(consoleEnt, out var xform)) continue;
|
||||
|
||||
_excludedMobs.Add(mover.Owner);
|
||||
|
||||
var gridId = xform.GridUid;
|
||||
// This tries to see if the grid is a shuttle and if the console should work.
|
||||
if (!_mapManager.TryGetGrid(gridId, out var grid) ||
|
||||
@@ -86,7 +210,7 @@ namespace Content.Server.Physics.Controllers
|
||||
|
||||
if (!newPilots.TryGetValue(shuttleComponent, out var pilots))
|
||||
{
|
||||
pilots = new List<(PilotComponent, IMoverComponent, TransformComponent)>();
|
||||
pilots = new List<(PilotComponent, InputMoverComponent, TransformComponent)>();
|
||||
newPilots[shuttleComponent] = pilots;
|
||||
}
|
||||
|
||||
@@ -113,37 +237,57 @@ namespace Content.Server.Physics.Controllers
|
||||
var linearInput = Vector2.Zero;
|
||||
var angularInput = 0f;
|
||||
|
||||
switch (shuttle.Mode)
|
||||
foreach (var (pilot, _, consoleXform) in pilots)
|
||||
{
|
||||
case ShuttleMode.Cruise:
|
||||
foreach (var (pilot, mover, consoleXform) in pilots)
|
||||
var pilotInput = GetPilotVelocityInput(pilot);
|
||||
|
||||
// On the one hand we could just make it relay inputs to brake
|
||||
// but uhh may be disorienting? n
|
||||
if (pilotInput.Brakes > 0f)
|
||||
{
|
||||
if (body.LinearVelocity.Length > 0f)
|
||||
{
|
||||
var sprint = mover.VelocityDir.sprinting;
|
||||
var force = body.LinearVelocity.Normalized * pilotInput.Brakes / body.InvMass * 3f;
|
||||
var impulse = force * body.InvMass * frameTime;
|
||||
|
||||
if (sprint.Equals(Vector2.Zero)) continue;
|
||||
|
||||
var offsetRotation = consoleXform.LocalRotation;
|
||||
|
||||
linearInput += offsetRotation.RotateVec(new Vector2(0f, sprint.Y));
|
||||
angularInput += sprint.X;
|
||||
if (impulse.Length > body.LinearVelocity.Length)
|
||||
{
|
||||
body.LinearVelocity = Vector2.Zero;
|
||||
}
|
||||
else
|
||||
{
|
||||
body.ApplyLinearImpulse(-force * frameTime);
|
||||
}
|
||||
}
|
||||
break;
|
||||
case ShuttleMode.Strafing:
|
||||
// No angular input possible
|
||||
foreach (var (pilot, mover, consoleXform) in pilots)
|
||||
|
||||
if (body.AngularVelocity != 0f)
|
||||
{
|
||||
var sprint = mover.VelocityDir.sprinting;
|
||||
var force = body.AngularVelocity * pilotInput.Brakes / body.InvI * 2f;
|
||||
var impulse = force * body.InvI * frameTime;
|
||||
|
||||
if (sprint.Equals(Vector2.Zero)) continue;
|
||||
|
||||
var offsetRotation = consoleXform.LocalRotation;
|
||||
sprint = offsetRotation.RotateVec(sprint);
|
||||
|
||||
linearInput += sprint;
|
||||
if (MathF.Abs(impulse) > MathF.Abs(body.AngularVelocity))
|
||||
{
|
||||
body.AngularVelocity = 0f;
|
||||
}
|
||||
else
|
||||
{
|
||||
body.ApplyAngularImpulse(-force * frameTime);
|
||||
}
|
||||
}
|
||||
break;
|
||||
default:
|
||||
throw new ArgumentOutOfRangeException();
|
||||
|
||||
continue;
|
||||
}
|
||||
|
||||
if (pilotInput.Strafe.Length > 0f)
|
||||
{
|
||||
var offsetRotation = consoleXform.LocalRotation;
|
||||
linearInput += offsetRotation.RotateVec(pilotInput.Strafe);
|
||||
}
|
||||
|
||||
if (pilotInput.Rotation != 0f)
|
||||
{
|
||||
angularInput += pilotInput.Rotation;
|
||||
}
|
||||
}
|
||||
|
||||
var count = pilots.Count;
|
||||
@@ -224,8 +368,7 @@ namespace Content.Server.Physics.Controllers
|
||||
totalForce += force;
|
||||
}
|
||||
|
||||
var dragForce = body.LinearVelocity * (totalForce.Length / _shuttle.ShuttleMaxLinearSpeed);
|
||||
body.ApplyLinearImpulse((totalForce - dragForce) * frameTime);
|
||||
body.ApplyLinearImpulse(totalForce * frameTime);
|
||||
}
|
||||
|
||||
if (MathHelper.CloseTo(angularInput, 0f))
|
||||
@@ -263,26 +406,5 @@ namespace Content.Server.Physics.Controllers
|
||||
(ftl.State & (FTLState.Starting | FTLState.Travelling | FTLState.Arriving)) != 0x0);
|
||||
}
|
||||
|
||||
/// <summary>
|
||||
/// Add mobs riding vehicles to the list of mobs whose input
|
||||
/// should be ignored.
|
||||
/// </summary>
|
||||
private void HandleVehicleMovement()
|
||||
{
|
||||
// TODO: Nuke this code. It's on my list.
|
||||
foreach (var (rider, mover) in EntityQuery<RiderComponent, SharedPlayerInputMoverComponent>())
|
||||
{
|
||||
if (rider.Vehicle == null) continue;
|
||||
_excludedMobs.Add(mover.Owner);
|
||||
|
||||
if (!_excludedMobs.Add(rider.Vehicle.Owner)) continue;
|
||||
|
||||
if (!TryComp<IMoverComponent>(rider.Vehicle.Owner, out var vehicleMover) ||
|
||||
!TryComp<PhysicsComponent>(rider.Vehicle.Owner, out var vehicleBody) ||
|
||||
rider.Vehicle.Owner.IsWeightless(vehicleBody, mapManager: _mapManager, entityManager: EntityManager)) continue;
|
||||
|
||||
HandleKinematicMovement(vehicleMover, vehicleBody);
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
@@ -22,13 +22,13 @@ public sealed class EscapeInventorySystem : EntitySystem
|
||||
{
|
||||
base.Initialize();
|
||||
|
||||
SubscribeLocalEvent<CanEscapeInventoryComponent, RelayMoveInputEvent>(OnRelayMovement);
|
||||
SubscribeLocalEvent<CanEscapeInventoryComponent, MoveInputEvent>(OnRelayMovement);
|
||||
SubscribeLocalEvent<CanEscapeInventoryComponent, UpdateCanMoveEvent>(OnMoveAttempt);
|
||||
SubscribeLocalEvent<CanEscapeInventoryComponent, EscapeDoAfterComplete>(OnEscapeComplete);
|
||||
SubscribeLocalEvent<CanEscapeInventoryComponent, EscapeDoAfterCancel>(OnEscapeFail);
|
||||
}
|
||||
|
||||
private void OnRelayMovement(EntityUid uid, CanEscapeInventoryComponent component, RelayMoveInputEvent args)
|
||||
private void OnRelayMovement(EntityUid uid, CanEscapeInventoryComponent component, ref MoveInputEvent args)
|
||||
{
|
||||
//Prevents the user from creating multiple DoAfters if they're already resisting.
|
||||
if (component.IsResisting == true)
|
||||
|
||||
@@ -21,13 +21,13 @@ public sealed class ResistLockerSystem : EntitySystem
|
||||
public override void Initialize()
|
||||
{
|
||||
base.Initialize();
|
||||
SubscribeLocalEvent<ResistLockerComponent, RelayMovementEntityEvent>(OnRelayMovement);
|
||||
SubscribeLocalEvent<ResistLockerComponent, ContainerRelayMovementEntityEvent>(OnRelayMovement);
|
||||
SubscribeLocalEvent<ResistLockerComponent, ResistDoAfterComplete>(OnDoAfterComplete);
|
||||
SubscribeLocalEvent<ResistLockerComponent, ResistDoAfterCancelled>(OnDoAfterCancelled);
|
||||
SubscribeLocalEvent<ResistLockerComponent, EntRemovedFromContainerMessage>(OnRemovedFromContainer);
|
||||
}
|
||||
|
||||
private void OnRelayMovement(EntityUid uid, ResistLockerComponent component, RelayMovementEntityEvent args)
|
||||
private void OnRelayMovement(EntityUid uid, ResistLockerComponent component, ref ContainerRelayMovementEntityEvent args)
|
||||
{
|
||||
if (component.IsResisting)
|
||||
return;
|
||||
|
||||
@@ -8,9 +8,6 @@ namespace Content.Server.Shuttles.Components
|
||||
[ViewVariables]
|
||||
public bool Enabled = true;
|
||||
|
||||
[ViewVariables]
|
||||
public ShuttleMode Mode = ShuttleMode.Cruise;
|
||||
|
||||
/// <summary>
|
||||
/// The cached thrust available for each cardinal direction
|
||||
/// </summary>
|
||||
|
||||
@@ -1,4 +1,3 @@
|
||||
using Content.Server.Cargo.Components;
|
||||
using Content.Server.Power.Components;
|
||||
using Content.Server.Power.EntitySystems;
|
||||
using Content.Server.Shuttles.Components;
|
||||
@@ -38,7 +37,6 @@ namespace Content.Server.Shuttles.Systems
|
||||
SubscribeLocalEvent<ShuttleConsoleComponent, PowerChangedEvent>(OnConsolePowerChange);
|
||||
SubscribeLocalEvent<ShuttleConsoleComponent, AnchorStateChangedEvent>(OnConsoleAnchorChange);
|
||||
SubscribeLocalEvent<ShuttleConsoleComponent, ActivatableUIOpenAttemptEvent>(OnConsoleUIOpenAttempt);
|
||||
SubscribeLocalEvent<ShuttleConsoleComponent, ShuttleModeRequestMessage>(OnModeRequest);
|
||||
SubscribeLocalEvent<ShuttleConsoleComponent, ShuttleConsoleDestinationMessage>(OnDestinationMessage);
|
||||
SubscribeLocalEvent<ShuttleConsoleComponent, BoundUIClosedEvent>(OnConsoleUIClose);
|
||||
|
||||
@@ -47,6 +45,13 @@ namespace Content.Server.Shuttles.Systems
|
||||
|
||||
SubscribeLocalEvent<PilotComponent, MoveEvent>(HandlePilotMove);
|
||||
SubscribeLocalEvent<PilotComponent, ComponentGetState>(OnGetState);
|
||||
SubscribeLocalEvent<PilotComponent, ComponentGetStateAttemptEvent>(OnGetStateAttempt);
|
||||
}
|
||||
|
||||
private void OnGetStateAttempt(EntityUid uid, PilotComponent component, ref ComponentGetStateAttemptEvent args)
|
||||
{
|
||||
if (args.Cancelled || !TryComp<ActorComponent>(uid, out var actor) || actor.PlayerSession != args.Player)
|
||||
args.Cancelled = true;
|
||||
}
|
||||
|
||||
private void OnDestinationMessage(EntityUid uid, ShuttleConsoleComponent component, ShuttleConsoleDestinationMessage args)
|
||||
@@ -184,64 +189,6 @@ namespace Content.Server.Shuttles.Systems
|
||||
args.State = new PilotComponentState(component.Console?.Owner);
|
||||
}
|
||||
|
||||
/// <summary>
|
||||
/// Client is requesting a change in the shuttle's driving mode.
|
||||
/// </summary>
|
||||
private void OnModeRequest(EntityUid uid, ShuttleConsoleComponent component, ShuttleModeRequestMessage args)
|
||||
{
|
||||
var consoleUid = uid;
|
||||
|
||||
if (TryComp<CargoPilotConsoleComponent>(uid, out var cargoPilot) && cargoPilot.Entity != null)
|
||||
{
|
||||
consoleUid = cargoPilot.Entity.Value;
|
||||
}
|
||||
|
||||
if (args.Session.AttachedEntity is not { } player ||
|
||||
!TryComp<PilotComponent>(player, out var pilot) ||
|
||||
!TryComp<ShuttleConsoleComponent>(consoleUid, out var console) ||
|
||||
!TryComp<TransformComponent>(consoleUid, out var consoleXform)) return;
|
||||
|
||||
// Can't check console pilots as it may be remotely piloted!
|
||||
if (!component.SubscribedPilots.Contains(pilot) ||
|
||||
!TryComp<ShuttleComponent>(consoleXform.GridUid, out var shuttle)) return;
|
||||
|
||||
SetShuttleMode(args.Mode, console, shuttle);
|
||||
UpdateState(component);
|
||||
|
||||
if (uid != consoleUid)
|
||||
{
|
||||
UpdateState(console);
|
||||
}
|
||||
}
|
||||
|
||||
/// <summary>
|
||||
/// Sets the shuttle's movement mode. Does minimal revalidation.
|
||||
/// </summary>
|
||||
private void SetShuttleMode(ShuttleMode mode, ShuttleConsoleComponent consoleComponent,
|
||||
ShuttleComponent shuttleComponent, TransformComponent? consoleXform = null)
|
||||
{
|
||||
// Re-validate
|
||||
if (!this.IsPowered(consoleComponent.Owner, EntityManager) ||
|
||||
!Resolve(consoleComponent.Owner, ref consoleXform) ||
|
||||
!consoleXform.Anchored ||
|
||||
consoleXform.GridUid != Transform(shuttleComponent.Owner).GridUid)
|
||||
{
|
||||
return;
|
||||
}
|
||||
|
||||
shuttleComponent.Mode = mode;
|
||||
|
||||
switch (mode)
|
||||
{
|
||||
case ShuttleMode.Strafing:
|
||||
break;
|
||||
case ShuttleMode.Cruise:
|
||||
break;
|
||||
default:
|
||||
throw new ArgumentOutOfRangeException();
|
||||
}
|
||||
}
|
||||
|
||||
/// <summary>
|
||||
/// Returns the position and angle of all dockingcomponents.
|
||||
/// </summary>
|
||||
@@ -286,7 +233,6 @@ namespace Content.Server.Shuttles.Systems
|
||||
var range = radar?.MaxRange ?? 0f;
|
||||
|
||||
TryComp<ShuttleComponent>(consoleXform?.GridUid, out var shuttle);
|
||||
var mode = shuttle?.Mode ?? ShuttleMode.Cruise;
|
||||
|
||||
var destinations = new List<(EntityUid, string, bool)>();
|
||||
var ftlState = FTLState.Available;
|
||||
@@ -342,7 +288,6 @@ namespace Content.Server.Shuttles.Systems
|
||||
?.SetState(new ShuttleConsoleBoundInterfaceState(
|
||||
ftlState,
|
||||
ftlTime,
|
||||
mode,
|
||||
destinations,
|
||||
range,
|
||||
consoleXform?.Coordinates,
|
||||
|
||||
@@ -67,7 +67,7 @@ namespace Content.Server.Storage.EntitySystems
|
||||
SubscribeLocalEvent<ServerStorageComponent, EntRemovedFromContainerMessage>(OnStorageItemRemoved);
|
||||
|
||||
SubscribeLocalEvent<EntityStorageComponent, GetVerbsEvent<InteractionVerb>>(AddToggleOpenVerb);
|
||||
SubscribeLocalEvent<EntityStorageComponent, RelayMovementEntityEvent>(OnRelayMovement);
|
||||
SubscribeLocalEvent<EntityStorageComponent, ContainerRelayMovementEntityEvent>(OnRelayMovement);
|
||||
|
||||
SubscribeLocalEvent<StorageFillComponent, MapInitEvent>(OnStorageFillMapInit);
|
||||
}
|
||||
@@ -84,7 +84,7 @@ namespace Content.Server.Storage.EntitySystems
|
||||
UpdateStorageUI(uid, storageComp);
|
||||
}
|
||||
|
||||
private void OnRelayMovement(EntityUid uid, EntityStorageComponent component, RelayMovementEntityEvent args)
|
||||
private void OnRelayMovement(EntityUid uid, EntityStorageComponent component, ref ContainerRelayMovementEntityEvent args)
|
||||
{
|
||||
if (!EntityManager.HasComponent<HandsComponent>(args.Entity))
|
||||
return;
|
||||
|
||||
@@ -1,57 +0,0 @@
|
||||
using Content.Shared.Vehicle.Components;
|
||||
using Content.Shared.Vehicle;
|
||||
using Content.Shared.Toggleable;
|
||||
using Content.Shared.Audio;
|
||||
using Robust.Shared.Player;
|
||||
using Robust.Shared.Audio;
|
||||
|
||||
namespace Content.Server.Vehicle
|
||||
{
|
||||
/// <summary>
|
||||
/// Controls all the vehicle horns.
|
||||
/// </summary>
|
||||
public sealed class HonkSystem : EntitySystem
|
||||
{
|
||||
public override void Initialize()
|
||||
{
|
||||
base.Initialize();
|
||||
SubscribeLocalEvent<VehicleComponent, HonkActionEvent>(OnHonk);
|
||||
SubscribeLocalEvent<VehicleComponent, ToggleActionEvent>(OnSirenToggle);
|
||||
}
|
||||
|
||||
/// <summary>
|
||||
/// This fires when the rider presses the honk action
|
||||
/// </summary>
|
||||
private void OnHonk(EntityUid uid, VehicleComponent vehicle, HonkActionEvent args)
|
||||
{
|
||||
if (args.Handled)
|
||||
return;
|
||||
if (vehicle.HornSound != null)
|
||||
{
|
||||
SoundSystem.Play(vehicle.HornSound.GetSound(), Filter.Pvs(uid), uid, AudioHelpers.WithVariation(0.1f).WithVolume(8f));
|
||||
args.Handled = true;
|
||||
}
|
||||
}
|
||||
|
||||
/// <summary>
|
||||
/// For vehicles with horn sirens (like the secway) this uses different logic that makes the siren
|
||||
/// loop instead of using a normal honk.
|
||||
/// </summary>
|
||||
private void OnSirenToggle(EntityUid uid, VehicleComponent vehicle, ToggleActionEvent args)
|
||||
{
|
||||
if (args.Handled || !vehicle.HornIsLooping)
|
||||
return;
|
||||
|
||||
if (!vehicle.LoopingHornIsPlaying)
|
||||
{
|
||||
vehicle.SirenPlayingStream?.Stop();
|
||||
vehicle.LoopingHornIsPlaying = true;
|
||||
if (vehicle.HornSound != null)
|
||||
vehicle.SirenPlayingStream = SoundSystem.Play(vehicle.HornSound.GetSound(), Filter.Pvs(uid), uid, AudioParams.Default.WithLoop(true).WithVolume(1.8f));
|
||||
return;
|
||||
}
|
||||
vehicle.SirenPlayingStream?.Stop();
|
||||
vehicle.LoopingHornIsPlaying = false;
|
||||
}
|
||||
}
|
||||
}
|
||||
@@ -1,57 +0,0 @@
|
||||
using Content.Server.Buckle.Components;
|
||||
using Content.Shared.Vehicle.Components;
|
||||
using Content.Shared.MobState;
|
||||
using Content.Server.Standing;
|
||||
using Content.Shared.Hands;
|
||||
|
||||
namespace Content.Server.Vehicle
|
||||
{
|
||||
public sealed class RiderSystem : EntitySystem
|
||||
{
|
||||
public override void Initialize()
|
||||
{
|
||||
base.Initialize();
|
||||
SubscribeLocalEvent<RiderComponent, VirtualItemDeletedEvent>(OnVirtualItemDeleted);
|
||||
SubscribeLocalEvent<RiderComponent, FellDownEvent>(OnFallDown);
|
||||
SubscribeLocalEvent<RiderComponent, MobStateChangedEvent>(OnMobStateChanged);
|
||||
}
|
||||
|
||||
/// <summary>
|
||||
/// Kick the rider off the vehicle if they press q / drop the virtual item
|
||||
/// </summary>
|
||||
private void OnVirtualItemDeleted(EntityUid uid, RiderComponent component, VirtualItemDeletedEvent args)
|
||||
{
|
||||
if (args.BlockingEntity == component.Vehicle?.Owner)
|
||||
{
|
||||
UnbuckleFromVehicle(uid);
|
||||
}
|
||||
}
|
||||
|
||||
/// <summary>
|
||||
/// Kick the rider off the vehicle if they get stunned
|
||||
/// </summary>
|
||||
private void OnFallDown(EntityUid uid, RiderComponent rider, FellDownEvent args)
|
||||
{
|
||||
UnbuckleFromVehicle(uid);
|
||||
}
|
||||
|
||||
/// <summary>
|
||||
/// Kick the rider off the vehicle if they go into crit or die.
|
||||
/// </summary>
|
||||
private void OnMobStateChanged(EntityUid uid, RiderComponent rider, MobStateChangedEvent args)
|
||||
{
|
||||
if (args.Component.IsCritical() || args.Component.IsDead())
|
||||
{
|
||||
UnbuckleFromVehicle(uid);
|
||||
}
|
||||
}
|
||||
|
||||
public void UnbuckleFromVehicle(EntityUid uid)
|
||||
{
|
||||
if (!TryComp<BuckleComponent>(uid, out var buckle))
|
||||
return;
|
||||
|
||||
buckle.TryUnbuckle(uid, true);
|
||||
}
|
||||
}
|
||||
}
|
||||
92
Content.Server/Vehicle/VehicleSystem.Rider.cs
Normal file
92
Content.Server/Vehicle/VehicleSystem.Rider.cs
Normal file
@@ -0,0 +1,92 @@
|
||||
using Content.Server.Buckle.Components;
|
||||
using Content.Shared.Vehicle.Components;
|
||||
using Content.Shared.MobState;
|
||||
using Content.Server.Standing;
|
||||
using Content.Shared.Hands;
|
||||
using Robust.Shared.GameStates;
|
||||
|
||||
namespace Content.Server.Vehicle
|
||||
{
|
||||
public sealed partial class VehicleSystem
|
||||
{
|
||||
private void InitializeRider()
|
||||
{
|
||||
SubscribeLocalEvent<RiderComponent, ComponentStartup>(OnRiderStartup);
|
||||
SubscribeLocalEvent<RiderComponent, ComponentShutdown>(OnRiderShutdown);
|
||||
SubscribeLocalEvent<RiderComponent, MetaFlagRemoveAttemptEvent>(OnRiderRemoval);
|
||||
SubscribeLocalEvent<RiderComponent, ComponentGetState>(OnRiderGetState);
|
||||
SubscribeLocalEvent<RiderComponent, ComponentGetStateAttemptEvent>(OnRiderGetStateAttempt);
|
||||
SubscribeLocalEvent<RiderComponent, VirtualItemDeletedEvent>(OnVirtualItemDeleted);
|
||||
SubscribeLocalEvent<RiderComponent, FellDownEvent>(OnFallDown);
|
||||
SubscribeLocalEvent<RiderComponent, MobStateChangedEvent>(OnMobStateChanged);
|
||||
}
|
||||
|
||||
private void OnRiderRemoval(EntityUid uid, RiderComponent component, ref MetaFlagRemoveAttemptEvent args)
|
||||
{
|
||||
if ((args.ToRemove & MetaDataFlags.EntitySpecific) != 0x0)
|
||||
args.ToRemove = MetaDataFlags.None;
|
||||
}
|
||||
|
||||
private void OnRiderStartup(EntityUid uid, RiderComponent component, ComponentStartup args)
|
||||
{
|
||||
_metadata.AddFlag(uid, MetaDataFlags.EntitySpecific);
|
||||
}
|
||||
|
||||
private void OnRiderShutdown(EntityUid uid, RiderComponent component, ComponentShutdown args)
|
||||
{
|
||||
_metadata.RemoveFlag(uid, MetaDataFlags.EntitySpecific);
|
||||
}
|
||||
|
||||
private void OnRiderGetStateAttempt(EntityUid uid, RiderComponent component, ref ComponentGetStateAttemptEvent args)
|
||||
{
|
||||
if (uid != args.Player.AttachedEntity)
|
||||
args.Cancelled = true;
|
||||
}
|
||||
|
||||
private void OnRiderGetState(EntityUid uid, RiderComponent component, ref ComponentGetState args)
|
||||
{
|
||||
args.State = new RiderComponentState()
|
||||
{
|
||||
Entity = component.Vehicle,
|
||||
};
|
||||
}
|
||||
|
||||
/// <summary>
|
||||
/// Kick the rider off the vehicle if they press q / drop the virtual item
|
||||
/// </summary>
|
||||
private void OnVirtualItemDeleted(EntityUid uid, RiderComponent component, VirtualItemDeletedEvent args)
|
||||
{
|
||||
if (args.BlockingEntity == component.Vehicle)
|
||||
{
|
||||
UnbuckleFromVehicle(uid);
|
||||
}
|
||||
}
|
||||
|
||||
/// <summary>
|
||||
/// Kick the rider off the vehicle if they get stunned
|
||||
/// </summary>
|
||||
private void OnFallDown(EntityUid uid, RiderComponent rider, FellDownEvent args)
|
||||
{
|
||||
UnbuckleFromVehicle(uid);
|
||||
}
|
||||
|
||||
/// <summary>
|
||||
/// Kick the rider off the vehicle if they go into crit or die.
|
||||
/// </summary>
|
||||
private void OnMobStateChanged(EntityUid uid, RiderComponent rider, MobStateChangedEvent args)
|
||||
{
|
||||
if (args.Component.IsCritical() || args.Component.IsDead())
|
||||
{
|
||||
UnbuckleFromVehicle(uid);
|
||||
}
|
||||
}
|
||||
|
||||
public void UnbuckleFromVehicle(EntityUid uid)
|
||||
{
|
||||
if (!TryComp<BuckleComponent>(uid, out var buckle))
|
||||
return;
|
||||
|
||||
buckle.TryUnbuckle(uid, true);
|
||||
}
|
||||
}
|
||||
}
|
||||
@@ -1,3 +1,4 @@
|
||||
using Content.Server.Buckle.Components;
|
||||
using Content.Shared.Vehicle.Components;
|
||||
using Content.Shared.Vehicle;
|
||||
using Content.Shared.Buckle.Components;
|
||||
@@ -5,44 +6,64 @@ using Content.Shared.Movement.Components;
|
||||
using Content.Shared.Containers.ItemSlots;
|
||||
using Content.Shared.Actions;
|
||||
using Content.Shared.Audio;
|
||||
using Content.Shared.Pulling.Components;
|
||||
using Content.Server.Light.Components;
|
||||
using Content.Server.Buckle.Components;
|
||||
using Content.Server.Hands.Systems;
|
||||
using Content.Shared.Tag;
|
||||
using Content.Server.Mind.Components;
|
||||
using Robust.Shared.Random;
|
||||
using Content.Shared.Movement.Systems;
|
||||
using Robust.Shared.Audio;
|
||||
using Robust.Shared.Containers;
|
||||
using Robust.Shared.Player;
|
||||
using DrawDepth = Content.Shared.DrawDepth.DrawDepth;
|
||||
|
||||
namespace Content.Server.Vehicle
|
||||
{
|
||||
public sealed class VehicleSystem : EntitySystem
|
||||
public sealed partial class VehicleSystem : SharedVehicleSystem
|
||||
{
|
||||
[Dependency] private readonly HandVirtualItemSystem _virtualItemSystem = default!;
|
||||
[Dependency] private readonly IRobustRandom _random = default!;
|
||||
[Dependency] private readonly MetaDataSystem _metadata = default!;
|
||||
[Dependency] private readonly MovementSpeedModifierSystem _modifier = default!;
|
||||
[Dependency] private readonly SharedActionsSystem _actionsSystem = default!;
|
||||
[Dependency] private readonly SharedAmbientSoundSystem _ambientSound = default!;
|
||||
[Dependency] private readonly SharedMoverController _mover = default!;
|
||||
[Dependency] private readonly TagSystem _tagSystem = default!;
|
||||
[Dependency] private readonly ItemSlotsSystem _itemSlotsSystem = default!;
|
||||
[Dependency] private readonly RiderSystem _riderSystem = default!;
|
||||
|
||||
private const string KeySlot = "key_slot";
|
||||
|
||||
public override void Initialize()
|
||||
{
|
||||
base.Initialize();
|
||||
|
||||
InitializeRider();
|
||||
|
||||
SubscribeLocalEvent<VehicleComponent, HonkActionEvent>(OnHonk);
|
||||
SubscribeLocalEvent<VehicleComponent, BuckleChangeEvent>(OnBuckleChange);
|
||||
SubscribeLocalEvent<VehicleComponent, ComponentInit>(OnComponentInit);
|
||||
SubscribeLocalEvent<VehicleComponent, MoveEvent>(OnMove);
|
||||
SubscribeLocalEvent<VehicleComponent, EntInsertedIntoContainerMessage>(OnEntInserted);
|
||||
SubscribeLocalEvent<VehicleComponent, EntRemovedFromContainerMessage>(OnEntRemoved);
|
||||
}
|
||||
|
||||
/// <summary>
|
||||
/// This fires when the rider presses the honk action
|
||||
/// </summary>
|
||||
private void OnHonk(EntityUid uid, VehicleComponent vehicle, HonkActionEvent args)
|
||||
{
|
||||
if (args.Handled || vehicle.HornSound == null)
|
||||
return;
|
||||
|
||||
// TODO: Need audio refactor maybe, just some way to null it when the stream is over.
|
||||
// For now better to just not loop to keep the code much cleaner.
|
||||
vehicle.HonkPlayingStream?.Stop();
|
||||
vehicle.HonkPlayingStream = SoundSystem.Play(vehicle.HornSound.GetSound(), Filter.Pvs(uid), uid, vehicle.HornSound.Params);
|
||||
args.Handled = true;
|
||||
}
|
||||
|
||||
/// <summary>
|
||||
/// This just controls whether the wheels are turning.
|
||||
/// </summary>
|
||||
public override void Update(float frameTime)
|
||||
{
|
||||
foreach (var (vehicle, mover) in EntityQuery<VehicleComponent, SharedPlayerInputMoverComponent>())
|
||||
foreach (var (vehicle, mover) in EntityQuery<VehicleComponent, InputMoverComponent>())
|
||||
{
|
||||
if (mover.VelocityDir.sprinting == Vector2.Zero)
|
||||
if (_mover.GetVelocityInput(mover).Sprinting == Vector2.Zero)
|
||||
{
|
||||
UpdateAutoAnimate(vehicle.Owner, false);
|
||||
continue;
|
||||
@@ -50,103 +71,63 @@ namespace Content.Server.Vehicle
|
||||
UpdateAutoAnimate(vehicle.Owner, true);
|
||||
}
|
||||
}
|
||||
/// <summary>
|
||||
/// Sets the initial appearance / sound, then stores the initial buckle offset and resets it.
|
||||
/// </summary>
|
||||
private void OnComponentInit(EntityUid uid, VehicleComponent component, ComponentInit args)
|
||||
{
|
||||
UpdateDrawDepth(uid, 2);
|
||||
_ambientSound.SetAmbience(uid, false);
|
||||
if (!TryComp<StrapComponent>(uid, out var strap))
|
||||
return;
|
||||
|
||||
component.BaseBuckleOffset = strap.BuckleOffset;
|
||||
strap.BuckleOffsetUnclamped = Vector2.Zero; //You're going to align these facing east, so...
|
||||
}
|
||||
/// <summary>
|
||||
/// Give the user the rider component if they're buckling to the vehicle,
|
||||
/// otherwise remove it.
|
||||
/// </summary>
|
||||
private void OnBuckleChange(EntityUid uid, VehicleComponent component, BuckleChangeEvent args)
|
||||
{
|
||||
// Send an event that our vehicle buckle changed
|
||||
if (TryComp<MindComponent>(args.BuckledEntity, out var mind) && mind.Mind != null && mind.Mind.TryGetSession(out var session))
|
||||
RaiseNetworkEvent(new BuckledToVehicleEvent(uid, args.BuckledEntity, args.Buckling), Filter.SinglePlayer(session));
|
||||
|
||||
// Add Rider
|
||||
if (args.Buckling)
|
||||
{
|
||||
// Add a virtual item to rider's hand, unbuckle if we can't.
|
||||
if (!_virtualItemSystem.TrySpawnVirtualItemInHand(uid, args.BuckledEntity))
|
||||
{
|
||||
_riderSystem.UnbuckleFromVehicle(args.BuckledEntity);
|
||||
UnbuckleFromVehicle(args.BuckledEntity);
|
||||
return;
|
||||
}
|
||||
|
||||
// Set up the rider and vehicle with each other
|
||||
EnsureComp<SharedPlayerInputMoverComponent>(uid);
|
||||
EnsureComp<InputMoverComponent>(uid);
|
||||
var rider = EnsureComp<RiderComponent>(args.BuckledEntity);
|
||||
component.Rider = args.BuckledEntity;
|
||||
rider.Vehicle = component;
|
||||
|
||||
var relay = EnsureComp<RelayInputMoverComponent>(args.BuckledEntity);
|
||||
relay.RelayEntity = uid;
|
||||
rider.Vehicle = uid;
|
||||
component.HasRider = true;
|
||||
|
||||
// Handle pulling
|
||||
RemComp<SharedPullableComponent>(args.BuckledEntity);
|
||||
RemComp<SharedPullableComponent>(uid);
|
||||
|
||||
// Let this open doors if it has the key in it
|
||||
if (component.HasKey)
|
||||
{
|
||||
_tagSystem.AddTag(uid, "DoorBumpOpener");
|
||||
}
|
||||
// Update appearance stuff, add actions
|
||||
UpdateBuckleOffset(Transform(uid), component);
|
||||
UpdateDrawDepth(uid, GetDrawDepth(Transform(uid), component.NorthOnly));
|
||||
|
||||
if (TryComp<ActionsComponent>(args.BuckledEntity, out var actions) && TryComp<UnpoweredFlashlightComponent>(uid, out var flashlight))
|
||||
{
|
||||
_actionsSystem.AddAction(args.BuckledEntity, flashlight.ToggleAction, uid, actions);
|
||||
}
|
||||
|
||||
if (component.HornSound != null)
|
||||
{
|
||||
_actionsSystem.AddAction(args.BuckledEntity, component.HornAction, uid, actions);
|
||||
}
|
||||
_itemSlotsSystem.SetLock(uid, component.Name, true);
|
||||
|
||||
return;
|
||||
}
|
||||
|
||||
// Remove rider
|
||||
|
||||
// Clean up actions and virtual items
|
||||
_actionsSystem.RemoveProvidedActions(args.BuckledEntity, uid);
|
||||
_virtualItemSystem.DeleteInHandsMatching(args.BuckledEntity, uid);
|
||||
// Go back to old pullable behavior
|
||||
_tagSystem.RemoveTag(uid, "DoorBumpOpener");
|
||||
EnsureComp<SharedPullableComponent>(args.BuckledEntity);
|
||||
EnsureComp<SharedPullableComponent>(uid);
|
||||
|
||||
// Entity is no longer riding
|
||||
RemComp<RiderComponent>(args.BuckledEntity);
|
||||
RemComp<RelayInputMoverComponent>(args.BuckledEntity);
|
||||
|
||||
// Reset component
|
||||
component.HasRider = false;
|
||||
component.Rider = null;
|
||||
_itemSlotsSystem.SetLock(uid, component.Name, false);
|
||||
|
||||
}
|
||||
|
||||
/// <summary>
|
||||
/// Every time the vehicle moves we update its visual and buckle positions.
|
||||
/// Not the most beautiful thing but it works.
|
||||
/// </summary>
|
||||
private void OnMove(EntityUid uid, VehicleComponent component, ref MoveEvent args)
|
||||
{
|
||||
// This first check is just for safety
|
||||
if (!HasComp<SharedPlayerInputMoverComponent>(uid))
|
||||
{
|
||||
UpdateAutoAnimate(uid, false);
|
||||
return;
|
||||
}
|
||||
// The random check means the vehicle will stop after a few tiles without a key or without a rider
|
||||
if ((!component.HasRider || !component.HasKey) && _random.Prob(0.015f))
|
||||
{
|
||||
RemComp<SharedPlayerInputMoverComponent>(uid);
|
||||
UpdateAutoAnimate(uid, false);
|
||||
}
|
||||
UpdateBuckleOffset(args.Component, component);
|
||||
UpdateDrawDepth(uid, GetDrawDepth(args.Component, component.NorthOnly));
|
||||
}
|
||||
|
||||
/// <summary>
|
||||
@@ -155,29 +136,19 @@ namespace Content.Server.Vehicle
|
||||
/// </summary>
|
||||
private void OnEntInserted(EntityUid uid, VehicleComponent component, EntInsertedIntoContainerMessage args)
|
||||
{
|
||||
if (args.Container.ID != KeySlot ||
|
||||
!_tagSystem.HasTag(args.Entity, "VehicleKey")) return;
|
||||
|
||||
// Enable vehicle
|
||||
var inVehicle = AddComp<InVehicleComponent>(args.Entity);
|
||||
inVehicle.Vehicle = component;
|
||||
|
||||
if (_tagSystem.HasTag(args.Entity, "VehicleKey"))
|
||||
{
|
||||
// Return if the slot is not the key slot
|
||||
// That slot ID should be inherited from basevehicle in the .yml
|
||||
if (args.Container.ID != "key_slot")
|
||||
{
|
||||
return;
|
||||
}
|
||||
component.HasKey = true;
|
||||
|
||||
// This lets the vehicle move
|
||||
EnsureComp<SharedPlayerInputMoverComponent>(uid);
|
||||
// This lets the vehicle open doors
|
||||
if (component.HasRider)
|
||||
_tagSystem.AddTag(uid, "DoorBumpOpener");
|
||||
|
||||
component.HasKey = true;
|
||||
|
||||
// Audiovisual feedback
|
||||
_ambientSound.SetAmbience(uid, true);
|
||||
}
|
||||
// Audiovisual feedback
|
||||
_ambientSound.SetAmbience(uid, true);
|
||||
_tagSystem.AddTag(uid, "DoorBumpOpener");
|
||||
_modifier.RefreshMovementSpeedModifiers(uid);
|
||||
}
|
||||
|
||||
/// <summary>
|
||||
@@ -185,84 +156,13 @@ namespace Content.Server.Vehicle
|
||||
/// </summary>
|
||||
private void OnEntRemoved(EntityUid uid, VehicleComponent component, EntRemovedFromContainerMessage args)
|
||||
{
|
||||
RemComp<InVehicleComponent>(args.Entity);
|
||||
if (args.Container.ID != KeySlot || !RemComp<InVehicleComponent>(args.Entity)) return;
|
||||
|
||||
if (_tagSystem.HasTag(args.Entity, "VehicleKey"))
|
||||
{
|
||||
component.HasKey = false;
|
||||
_ambientSound.SetAmbience(uid, false);
|
||||
}
|
||||
}
|
||||
|
||||
/// <summary>
|
||||
/// Depending on which direction the vehicle is facing,
|
||||
/// change its draw depth. Vehicles can choose between special drawdetph
|
||||
/// when facing north or south. East and west are easy.
|
||||
/// </summary>
|
||||
private int GetDrawDepth(TransformComponent xform, bool northOnly)
|
||||
{
|
||||
if (northOnly)
|
||||
{
|
||||
return xform.LocalRotation.Degrees switch
|
||||
{
|
||||
< 135f => 5,
|
||||
<= 225f => 2,
|
||||
_ => 5
|
||||
};
|
||||
}
|
||||
return xform.LocalRotation.Degrees switch
|
||||
{
|
||||
< 45f => 5,
|
||||
<= 315f => 2,
|
||||
_ => 5
|
||||
};
|
||||
}
|
||||
|
||||
/// <summary>
|
||||
/// Change the buckle offset based on what direction the vehicle is facing and
|
||||
/// teleport any buckled entities to it. This is the most crucial part of making
|
||||
/// buckled vehicles work.
|
||||
/// </summary>
|
||||
private void UpdateBuckleOffset(TransformComponent xform, VehicleComponent component)
|
||||
{
|
||||
if (!TryComp<StrapComponent>(component.Owner, out var strap))
|
||||
return;
|
||||
strap.BuckleOffsetUnclamped = xform.LocalRotation.Degrees switch
|
||||
{
|
||||
< 45f => (0, component.SouthOverride),
|
||||
<= 135f => component.BaseBuckleOffset,
|
||||
< 225f => (0, component.NorthOverride),
|
||||
<= 315f => (component.BaseBuckleOffset.X * -1, component.BaseBuckleOffset.Y),
|
||||
_ => (0, component.SouthOverride)
|
||||
};
|
||||
|
||||
foreach (var buckledEntity in strap.BuckledEntities)
|
||||
{
|
||||
var buckleXform = Transform(buckledEntity);
|
||||
buckleXform.LocalPosition = strap.BuckleOffset;
|
||||
}
|
||||
|
||||
}
|
||||
|
||||
/// <summary>
|
||||
/// Set the draw depth for the sprite.
|
||||
/// </summary>
|
||||
private void UpdateDrawDepth(EntityUid uid, int drawDepth)
|
||||
{
|
||||
if (!TryComp<AppearanceComponent>(uid, out var appearance))
|
||||
return;
|
||||
|
||||
appearance.SetData(VehicleVisuals.DrawDepth, drawDepth);
|
||||
}
|
||||
|
||||
/// <summary>
|
||||
/// Set whether the vehicle's base layer is animating or not.
|
||||
/// </summary>
|
||||
private void UpdateAutoAnimate(EntityUid uid, bool autoAnimate)
|
||||
{
|
||||
if (!TryComp<AppearanceComponent>(uid, out var appearance))
|
||||
return;
|
||||
appearance.SetData(VehicleVisuals.AutoAnimate, autoAnimate);
|
||||
// Disable vehicle
|
||||
component.HasKey = false;
|
||||
_ambientSound.SetAmbience(uid, false);
|
||||
_tagSystem.RemoveTag(uid, "DoorBumpOpener");
|
||||
_modifier.RefreshMovementSpeedModifiers(uid);
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
@@ -145,7 +145,7 @@ namespace Content.Server.Zombies
|
||||
_popupSystem.PopupEntity(Loc.GetString("zombie-transform", ("target", target)), target, Filter.Pvs(target));
|
||||
|
||||
//Make it sentient if it's an animal or something
|
||||
if (!HasComp<SharedDummyInputMoverComponent>(target)) //this component is cursed and fucks shit up
|
||||
if (!HasComp<InputMoverComponent>(target)) //this component is cursed and fucks shit up
|
||||
MakeSentientCommand.MakeSentient(target, EntityManager);
|
||||
|
||||
//Make the zombie not die in the cold. Good for space zombies
|
||||
|
||||
@@ -22,20 +22,20 @@ namespace Content.Shared.ActionBlocker
|
||||
public override void Initialize()
|
||||
{
|
||||
base.Initialize();
|
||||
SubscribeLocalEvent<IMoverComponent, ComponentStartup>(OnMoverStartup);
|
||||
SubscribeLocalEvent<InputMoverComponent, ComponentStartup>(OnMoverStartup);
|
||||
}
|
||||
|
||||
private void OnMoverStartup(EntityUid uid, IMoverComponent component, ComponentStartup args)
|
||||
private void OnMoverStartup(EntityUid uid, InputMoverComponent component, ComponentStartup args)
|
||||
{
|
||||
UpdateCanMove(uid, component);
|
||||
}
|
||||
|
||||
public bool CanMove(EntityUid uid, IMoverComponent? component = null)
|
||||
public bool CanMove(EntityUid uid, InputMoverComponent? component = null)
|
||||
{
|
||||
return Resolve(uid, ref component, false) && component.CanMove;
|
||||
}
|
||||
|
||||
public bool UpdateCanMove(EntityUid uid, IMoverComponent? component = null)
|
||||
public bool UpdateCanMove(EntityUid uid, InputMoverComponent? component = null)
|
||||
{
|
||||
if (!Resolve(uid, ref component, false))
|
||||
return false;
|
||||
|
||||
@@ -1,5 +1,6 @@
|
||||
using Content.Shared.DragDrop;
|
||||
using Content.Shared.Interaction;
|
||||
using Content.Shared.Standing;
|
||||
using Robust.Shared.GameStates;
|
||||
using Robust.Shared.Serialization;
|
||||
|
||||
@@ -8,6 +9,8 @@ namespace Content.Shared.Buckle.Components
|
||||
[NetworkedComponent()]
|
||||
public abstract class SharedBuckleComponent : Component, IDraggable
|
||||
{
|
||||
[Dependency] protected readonly IEntityManager EntMan = default!;
|
||||
|
||||
/// <summary>
|
||||
/// The range from which this entity can buckle to a <see cref="SharedStrapComponent"/>.
|
||||
/// </summary>
|
||||
@@ -35,6 +38,33 @@ namespace Content.Shared.Buckle.Components
|
||||
{
|
||||
return TryBuckle(args.User, args.Target);
|
||||
}
|
||||
|
||||
/// <summary>
|
||||
/// Reattaches this entity to the strap, modifying its position and rotation.
|
||||
/// </summary>
|
||||
/// <param name="strap">The strap to reattach to.</param>
|
||||
public void ReAttach(SharedStrapComponent strap)
|
||||
{
|
||||
var ownTransform = EntMan.GetComponent<TransformComponent>(Owner);
|
||||
var strapTransform = EntMan.GetComponent<TransformComponent>(strap.Owner);
|
||||
|
||||
ownTransform.AttachParent(strapTransform);
|
||||
ownTransform.LocalRotation = Angle.Zero;
|
||||
|
||||
switch (strap.Position)
|
||||
{
|
||||
case StrapPosition.None:
|
||||
break;
|
||||
case StrapPosition.Stand:
|
||||
EntitySystem.Get<StandingStateSystem>().Stand(Owner);
|
||||
break;
|
||||
case StrapPosition.Down:
|
||||
EntitySystem.Get<StandingStateSystem>().Down(Owner, false, false);
|
||||
break;
|
||||
}
|
||||
|
||||
ownTransform.LocalPosition = strap.BuckleOffset;
|
||||
}
|
||||
}
|
||||
|
||||
[Serializable, NetSerializable]
|
||||
|
||||
@@ -26,6 +26,40 @@ namespace Content.Shared.Buckle.Components
|
||||
[NetworkedComponent()]
|
||||
public abstract class SharedStrapComponent : Component, IDragDropOn
|
||||
{
|
||||
/// <summary>
|
||||
/// The change in position to the strapped mob
|
||||
/// </summary>
|
||||
[DataField("position")]
|
||||
public StrapPosition Position { get; set; } = StrapPosition.None;
|
||||
|
||||
|
||||
/// <summary>
|
||||
/// The entity that is currently buckled here, synced from <see cref="BuckleComponent.BuckledTo"/>
|
||||
/// </summary>
|
||||
public readonly HashSet<EntityUid> BuckledEntities = new();
|
||||
|
||||
/// <summary>
|
||||
/// The distance above which a buckled entity will be automatically unbuckled.
|
||||
/// Don't change it unless you really have to
|
||||
/// </summary>
|
||||
[DataField("maxBuckleDistance", required: false)]
|
||||
public float MaxBuckleDistance = 0.1f;
|
||||
|
||||
/// <summary>
|
||||
/// Gets and clamps the buckle offset to MaxBuckleDistance
|
||||
/// </summary>
|
||||
public Vector2 BuckleOffset => Vector2.Clamp(
|
||||
BuckleOffsetUnclamped,
|
||||
Vector2.One * -MaxBuckleDistance,
|
||||
Vector2.One * MaxBuckleDistance);
|
||||
|
||||
/// <summary>
|
||||
/// The buckled entity will be offset by this amount from the center of the strap object.
|
||||
/// If this offset it too big, it will be clamped to <see cref="MaxBuckleDistance"/>
|
||||
/// </summary>
|
||||
[DataField("buckleOffset", required: false)]
|
||||
public Vector2 BuckleOffsetUnclamped = Vector2.Zero;
|
||||
|
||||
bool IDragDropOn.CanDragDropOn(DragDropEvent eventArgs)
|
||||
{
|
||||
if (!IoCManager.Resolve<IEntityManager>().TryGetComponent(eventArgs.Dragged, out SharedBuckleComponent? buckleComponent)) return false;
|
||||
@@ -40,15 +74,22 @@ namespace Content.Shared.Buckle.Components
|
||||
[Serializable, NetSerializable]
|
||||
public sealed class StrapComponentState : ComponentState
|
||||
{
|
||||
public StrapComponentState(StrapPosition position)
|
||||
{
|
||||
Position = position;
|
||||
}
|
||||
|
||||
/// <summary>
|
||||
/// The change in position that this strap makes to the strapped mob
|
||||
/// </summary>
|
||||
public StrapPosition Position { get; }
|
||||
public StrapPosition Position;
|
||||
|
||||
public float MaxBuckleDistance;
|
||||
public Vector2 BuckleOffsetClamped;
|
||||
public HashSet<EntityUid> BuckledEntities;
|
||||
|
||||
public StrapComponentState(StrapPosition position, Vector2 offset, HashSet<EntityUid> buckled, float maxBuckleDistance)
|
||||
{
|
||||
Position = position;
|
||||
BuckleOffsetClamped = offset;
|
||||
BuckledEntities = buckled;
|
||||
MaxBuckleDistance = maxBuckleDistance;
|
||||
}
|
||||
}
|
||||
|
||||
[Serializable, NetSerializable]
|
||||
|
||||
@@ -13,6 +13,8 @@ namespace Content.Shared.Buckle
|
||||
public override void Initialize()
|
||||
{
|
||||
base.Initialize();
|
||||
SubscribeLocalEvent<SharedStrapComponent, RotateEvent>(OnStrapRotate);
|
||||
|
||||
SubscribeLocalEvent<SharedBuckleComponent, PreventCollideEvent>(PreventCollision);
|
||||
SubscribeLocalEvent<SharedBuckleComponent, DownAttemptEvent>(HandleDown);
|
||||
SubscribeLocalEvent<SharedBuckleComponent, StandAttemptEvent>(HandleStand);
|
||||
@@ -21,6 +23,23 @@ namespace Content.Shared.Buckle
|
||||
SubscribeLocalEvent<SharedBuckleComponent, ChangeDirectionAttemptEvent>(OnBuckleChangeDirectionAttempt);
|
||||
}
|
||||
|
||||
private void OnStrapRotate(EntityUid uid, SharedStrapComponent component, ref RotateEvent args)
|
||||
{
|
||||
// TODO: This looks dirty af.
|
||||
// On rotation of a strap, reattach all buckled entities.
|
||||
// This fixes buckle offsets and draw depths.
|
||||
foreach (var buckledEntity in component.BuckledEntities)
|
||||
{
|
||||
if (!EntityManager.TryGetComponent(buckledEntity, out SharedBuckleComponent? buckled))
|
||||
{
|
||||
continue;
|
||||
}
|
||||
|
||||
buckled.ReAttach(component);
|
||||
Dirty(buckled);
|
||||
}
|
||||
}
|
||||
|
||||
private void OnBuckleChangeDirectionAttempt(EntityUid uid, SharedBuckleComponent component, ChangeDirectionAttemptEvent args)
|
||||
{
|
||||
if (component.Buckled)
|
||||
|
||||
@@ -406,54 +406,6 @@ namespace Content.Shared.CCVar
|
||||
* Physics
|
||||
*/
|
||||
|
||||
/*
|
||||
* WARNING: These are liable to get changed to datafields whenever movement refactor occurs and may no longer be valid.
|
||||
* You were warned!
|
||||
*/
|
||||
|
||||
/// <summary>
|
||||
/// Minimum speed a mob has to be moving before applying movement friction.
|
||||
/// </summary>
|
||||
public static readonly CVarDef<float> MinimumFrictionSpeed =
|
||||
CVarDef.Create("physics.minimum_friction_speed", 0.005f, CVar.ARCHIVE | CVar.REPLICATED);
|
||||
|
||||
/// <summary>
|
||||
/// The acceleration applied to mobs when moving.
|
||||
/// </summary>
|
||||
public static readonly CVarDef<float> MobAcceleration =
|
||||
CVarDef.Create("physics.mob_acceleration", 14f, CVar.ARCHIVE | CVar.REPLICATED);
|
||||
|
||||
/// <summary>
|
||||
/// The negative velocity applied for friction.
|
||||
/// </summary>
|
||||
public static readonly CVarDef<float> MobFriction =
|
||||
CVarDef.Create("physics.mob_friction", 14f, CVar.ARCHIVE | CVar.REPLICATED);
|
||||
|
||||
/// <summary>
|
||||
/// The acceleration applied to mobs when moving and weightless.
|
||||
/// </summary>
|
||||
public static readonly CVarDef<float> MobWeightlessAcceleration =
|
||||
CVarDef.Create("physics.mob_weightless_acceleration", 1f, CVar.ARCHIVE | CVar.REPLICATED);
|
||||
|
||||
/// <summary>
|
||||
/// The negative velocity applied for friction when weightless and providing inputs.
|
||||
/// </summary>
|
||||
public static readonly CVarDef<float> MobWeightlessFriction =
|
||||
CVarDef.Create("physics.mob_weightless_friction", 1f, CVar.ARCHIVE | CVar.REPLICATED);
|
||||
|
||||
/// <summary>
|
||||
/// The negative velocity applied for friction when weightless and not providing inputs.
|
||||
/// This is essentially how much their speed decreases per second.
|
||||
/// </summary>
|
||||
public static readonly CVarDef<float> MobWeightlessFrictionNoInput =
|
||||
CVarDef.Create("physics.mob_weightless_friction_no_input", 0.2f, CVar.ARCHIVE | CVar.REPLICATED);
|
||||
|
||||
/// <summary>
|
||||
/// The movement speed modifier applied to a mob's total input velocity when weightless.
|
||||
/// </summary>
|
||||
public static readonly CVarDef<float> MobWeightlessModifier =
|
||||
CVarDef.Create("physics.mob_weightless_modifier", 0.7f, CVar.ARCHIVE | CVar.REPLICATED);
|
||||
|
||||
/// <summary>
|
||||
/// When a mob is walking should its X / Y movement be relative to its parent (true) or the map (false).
|
||||
/// </summary>
|
||||
|
||||
@@ -14,7 +14,7 @@ public sealed class FollowerSystem : EntitySystem
|
||||
base.Initialize();
|
||||
|
||||
SubscribeLocalEvent<GetVerbsEvent<AlternativeVerb>>(OnGetAlternativeVerbs);
|
||||
SubscribeLocalEvent<FollowerComponent, RelayMoveInputEvent>(OnFollowerMove);
|
||||
SubscribeLocalEvent<FollowerComponent, MoveInputEvent>(OnFollowerMove);
|
||||
SubscribeLocalEvent<FollowedComponent, EntityTerminatingEvent>(OnFollowedTerminating);
|
||||
}
|
||||
|
||||
@@ -41,7 +41,7 @@ public sealed class FollowerSystem : EntitySystem
|
||||
ev.Verbs.Add(verb);
|
||||
}
|
||||
|
||||
private void OnFollowerMove(EntityUid uid, FollowerComponent component, RelayMoveInputEvent args)
|
||||
private void OnFollowerMove(EntityUid uid, FollowerComponent component, ref MoveInputEvent args)
|
||||
{
|
||||
StopFollowingEntity(uid, component.Following);
|
||||
}
|
||||
|
||||
@@ -50,6 +50,13 @@ namespace Content.Shared.Input
|
||||
public static readonly BoundKeyFunction Arcade2 = "Arcade2";
|
||||
public static readonly BoundKeyFunction Arcade3 = "Arcade3";
|
||||
public static readonly BoundKeyFunction OpenActionsMenu = "OpenAbilitiesMenu";
|
||||
public static readonly BoundKeyFunction ShuttleStrafeLeft = "ShuttleStrafeLeft";
|
||||
public static readonly BoundKeyFunction ShuttleStrafeUp = "ShuttleStrafeUp";
|
||||
public static readonly BoundKeyFunction ShuttleStrafeRight = "ShuttleStrafeRight";
|
||||
public static readonly BoundKeyFunction ShuttleStrafeDown = "ShuttleStrafeDown";
|
||||
public static readonly BoundKeyFunction ShuttleRotateLeft = "ShuttleRotateLeft";
|
||||
public static readonly BoundKeyFunction ShuttleRotateRight = "ShuttleRotateRight";
|
||||
public static readonly BoundKeyFunction ShuttleBrake = "ShuttleBrake";
|
||||
public static readonly BoundKeyFunction Hotbar0 = "Hotbar0";
|
||||
public static readonly BoundKeyFunction Hotbar1 = "Hotbar1";
|
||||
public static readonly BoundKeyFunction Hotbar2 = "Hotbar2";
|
||||
|
||||
@@ -1,19 +0,0 @@
|
||||
using Robust.Shared.Map;
|
||||
|
||||
namespace Content.Shared.Movement.Components
|
||||
{
|
||||
public interface IMobMoverComponent : IComponent
|
||||
{
|
||||
const float GrabRangeDefault = 0.6f;
|
||||
const float PushStrengthDefault = 600.0f;
|
||||
const float WeightlessStrengthDefault = 0.4f;
|
||||
|
||||
EntityCoordinates LastPosition { get; set; }
|
||||
|
||||
public float StepSoundDistance { get; set; }
|
||||
|
||||
float GrabRange { get; set; }
|
||||
|
||||
float PushStrength { get; set; }
|
||||
}
|
||||
}
|
||||
@@ -1,37 +0,0 @@
|
||||
namespace Content.Shared.Movement.Components
|
||||
{
|
||||
// Does nothing except ensure uniqueness between mover components.
|
||||
// There can only be one.
|
||||
public interface IMoverComponent : IComponent
|
||||
{
|
||||
/// <summary>
|
||||
/// Is the entity Sprinting (running)?
|
||||
/// </summary>
|
||||
bool Sprinting { get; }
|
||||
|
||||
/// <summary>
|
||||
/// Can the entity currently move. Avoids having to raise move-attempt events every time a player moves.
|
||||
/// Note that this value will be overridden by the action blocker system, and shouldn't just be set directly.
|
||||
/// </summary>
|
||||
bool CanMove { get; set; }
|
||||
|
||||
Angle LastGridAngle { get; set; }
|
||||
|
||||
/// <summary>
|
||||
/// Calculated linear velocity direction of the entity.
|
||||
/// </summary>
|
||||
(Vector2 walking, Vector2 sprinting) VelocityDir { get; }
|
||||
|
||||
/// <summary>
|
||||
/// Toggles one of the four cardinal directions. Each of the four directions are
|
||||
/// composed into a single direction vector, <see cref="SharedPlayerInputMoverComponent.VelocityDir"/>. Enabling
|
||||
/// opposite directions will cancel each other out, resulting in no direction.
|
||||
/// </summary>
|
||||
/// <param name="direction">Direction to toggle.</param>
|
||||
/// <param name="subTick"></param>
|
||||
/// <param name="enabled">If the direction is active.</param>
|
||||
void SetVelocityDirection(Direction direction, ushort subTick, bool enabled);
|
||||
|
||||
void SetSprinting(ushort subTick, bool walking);
|
||||
}
|
||||
}
|
||||
51
Content.Shared/Movement/Components/InputMoverComponent.cs
Normal file
51
Content.Shared/Movement/Components/InputMoverComponent.cs
Normal file
@@ -0,0 +1,51 @@
|
||||
using Robust.Shared.GameStates;
|
||||
using Robust.Shared.Timing;
|
||||
|
||||
namespace Content.Shared.Movement.Components
|
||||
{
|
||||
[RegisterComponent]
|
||||
[NetworkedComponent]
|
||||
public sealed class InputMoverComponent : Component
|
||||
{
|
||||
// This class has to be able to handle server TPS being lower than client FPS.
|
||||
// While still having perfectly responsive movement client side.
|
||||
// We do this by keeping track of the exact sub-tick values that inputs are pressed on the client,
|
||||
// and then building a total movement vector based on those sub-tick steps.
|
||||
//
|
||||
// We keep track of the last sub-tick a movement input came in,
|
||||
// Then when a new input comes in, we calculate the fraction of the tick the LAST input was active for
|
||||
// (new sub-tick - last sub-tick)
|
||||
// and then add to the total-this-tick movement vector
|
||||
// by multiplying that fraction by the movement direction for the last input.
|
||||
// This allows us to incrementally build the movement vector for the current tick,
|
||||
// without having to keep track of some kind of list of inputs and calculating it later.
|
||||
//
|
||||
// We have to keep track of a separate movement vector for walking and sprinting,
|
||||
// since we don't actually know our current movement speed while processing inputs.
|
||||
// We change which vector we write into based on whether we were sprinting after the previous input.
|
||||
// (well maybe we do but the code is designed such that MoverSystem applies movement speed)
|
||||
// (and I'm not changing that)
|
||||
|
||||
/// <summary>
|
||||
/// Should our velocity be applied to our parent?
|
||||
/// </summary>
|
||||
[ViewVariables(VVAccess.ReadWrite), DataField("toParent")]
|
||||
public bool ToParent = false;
|
||||
|
||||
public GameTick LastInputTick;
|
||||
public ushort LastInputSubTick;
|
||||
|
||||
public Vector2 CurTickWalkMovement;
|
||||
public Vector2 CurTickSprintMovement;
|
||||
|
||||
public MoveButtons HeldMoveButtons = MoveButtons.None;
|
||||
|
||||
[ViewVariables]
|
||||
public Angle LastGridAngle { get; set; } = new(0);
|
||||
|
||||
public bool Sprinting => (HeldMoveButtons & MoveButtons.Walk) == 0x0;
|
||||
|
||||
[ViewVariables(VVAccess.ReadWrite)]
|
||||
public bool CanMove { get; set; } = true;
|
||||
}
|
||||
}
|
||||
@@ -8,8 +8,5 @@ namespace Content.Shared.Movement.Components;
|
||||
[RegisterComponent, NetworkedComponent]
|
||||
public sealed class JetpackUserComponent : Component
|
||||
{
|
||||
public float Acceleration = 1f;
|
||||
public float Friction = 0.3f;
|
||||
public float WeightlessModifier = 1.2f;
|
||||
public EntityUid Jetpack;
|
||||
}
|
||||
|
||||
59
Content.Shared/Movement/Components/MobMoverComponent.cs
Normal file
59
Content.Shared/Movement/Components/MobMoverComponent.cs
Normal file
@@ -0,0 +1,59 @@
|
||||
using Robust.Shared.GameStates;
|
||||
using Robust.Shared.Map;
|
||||
|
||||
namespace Content.Shared.Movement.Components
|
||||
{
|
||||
/// <summary>
|
||||
/// Has additional movement data such as footsteps and weightless grab range for an entity.
|
||||
/// </summary>
|
||||
[RegisterComponent]
|
||||
[NetworkedComponent()]
|
||||
public sealed class MobMoverComponent : Component
|
||||
{
|
||||
private float _stepSoundDistance;
|
||||
[DataField("grabRange")] public float GrabRange = 1.0f;
|
||||
|
||||
[DataField("pushStrength")] public float PushStrength = 600f;
|
||||
|
||||
[ViewVariables(VVAccess.ReadWrite)]
|
||||
public EntityCoordinates LastPosition { get; set; }
|
||||
|
||||
/// <summary>
|
||||
/// Used to keep track of how far we have moved before playing a step sound
|
||||
/// </summary>
|
||||
[ViewVariables(VVAccess.ReadWrite)]
|
||||
public float StepSoundDistance
|
||||
{
|
||||
get => _stepSoundDistance;
|
||||
set
|
||||
{
|
||||
if (MathHelper.CloseToPercent(_stepSoundDistance, value)) return;
|
||||
_stepSoundDistance = value;
|
||||
}
|
||||
}
|
||||
|
||||
[ViewVariables(VVAccess.ReadWrite)]
|
||||
public float GrabRangeVV
|
||||
{
|
||||
get => GrabRange;
|
||||
set
|
||||
{
|
||||
if (MathHelper.CloseToPercent(GrabRange, value)) return;
|
||||
GrabRange = value;
|
||||
Dirty();
|
||||
}
|
||||
}
|
||||
|
||||
[ViewVariables(VVAccess.ReadWrite)]
|
||||
public float PushStrengthVV
|
||||
{
|
||||
get => PushStrength;
|
||||
set
|
||||
{
|
||||
if (MathHelper.CloseToPercent(PushStrength, value)) return;
|
||||
PushStrength = value;
|
||||
Dirty();
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
@@ -3,12 +3,27 @@ using Robust.Shared.GameStates;
|
||||
|
||||
namespace Content.Shared.Movement.Components
|
||||
{
|
||||
/// <summary>
|
||||
/// Applies basic movement speed and movement modifiers for an entity.
|
||||
/// If this is not present on the entity then they will use defaults for movement.
|
||||
/// </summary>
|
||||
[RegisterComponent]
|
||||
[NetworkedComponent, Access(typeof(MovementSpeedModifierSystem))]
|
||||
public sealed class MovementSpeedModifierComponent : Component
|
||||
{
|
||||
public const float DefaultBaseWalkSpeed = 3.0f;
|
||||
public const float DefaultBaseSprintSpeed = 5.0f;
|
||||
// Weightless
|
||||
public const float DefaultMinimumFrictionSpeed = 0.005f;
|
||||
public const float DefaultWeightlessFriction = 1f;
|
||||
public const float DefaultWeightlessFrictionNoInput = 0.2f;
|
||||
public const float DefaultWeightlessModifier = 0.7f;
|
||||
public const float DefaultWeightlessAcceleration = 1f;
|
||||
|
||||
public const float DefaultAcceleration = 20f;
|
||||
public const float DefaultFriction = 20f;
|
||||
public const float DefaultFrictionNoInput = 20f;
|
||||
|
||||
public const float DefaultBaseWalkSpeed = 2.5f;
|
||||
public const float DefaultBaseSprintSpeed = 4.5f;
|
||||
|
||||
[ViewVariables]
|
||||
public float WalkSpeedModifier = 1.0f;
|
||||
@@ -38,6 +53,54 @@ namespace Content.Shared.Movement.Components
|
||||
}
|
||||
}
|
||||
|
||||
/// <summary>
|
||||
/// Minimum speed a mob has to be moving before applying movement friction.
|
||||
/// </summary>
|
||||
[DataField("minimumFrictionSpeed")]
|
||||
public float MinimumFrictionSpeed = DefaultMinimumFrictionSpeed;
|
||||
|
||||
/// <summary>
|
||||
/// The negative velocity applied for friction when weightless and providing inputs.
|
||||
/// </summary>
|
||||
[DataField("weightlessFriction")]
|
||||
public float WeightlessFriction = DefaultWeightlessFriction;
|
||||
|
||||
/// <summary>
|
||||
/// The negative velocity applied for friction when weightless and not providing inputs.
|
||||
/// This is essentially how much their speed decreases per second.
|
||||
/// </summary>
|
||||
[DataField("weightlessFrictionNoInput")]
|
||||
public float WeightlessFrictionNoInput = DefaultWeightlessFrictionNoInput;
|
||||
|
||||
/// <summary>
|
||||
/// The movement speed modifier applied to a mob's total input velocity when weightless.
|
||||
/// </summary>
|
||||
[DataField("weightlessModifier")]
|
||||
public float WeightlessModifier = DefaultWeightlessModifier;
|
||||
|
||||
/// <summary>
|
||||
/// The acceleration applied to mobs when moving and weightless.
|
||||
/// </summary>
|
||||
[DataField("weightlessAcceleration")]
|
||||
public float WeightlessAcceleration = DefaultWeightlessAcceleration;
|
||||
|
||||
/// <summary>
|
||||
/// The acceleration applied to mobs when moving.
|
||||
/// </summary>
|
||||
[DataField("acceleration")]
|
||||
public float Acceleration = DefaultAcceleration;
|
||||
|
||||
/// <summary>
|
||||
/// The negative velocity applied for friction.
|
||||
/// </summary>
|
||||
[DataField("friction")]
|
||||
public float Friction = DefaultFriction;
|
||||
|
||||
/// <summary>
|
||||
/// The negative velocity applied for friction.
|
||||
/// </summary>
|
||||
[DataField("frictionNoInput")] public float? FrictionNoInput = null;
|
||||
|
||||
[DataField("baseWalkSpeed")]
|
||||
public float BaseWalkSpeed { get; set; } = DefaultBaseWalkSpeed;
|
||||
|
||||
|
||||
@@ -0,0 +1,13 @@
|
||||
using Robust.Shared.GameStates;
|
||||
|
||||
namespace Content.Shared.Movement.Components;
|
||||
|
||||
/// <summary>
|
||||
/// Raises the engine movement inputs for a particular entity onto the designated entity
|
||||
/// </summary>
|
||||
[RegisterComponent, NetworkedComponent]
|
||||
public sealed class RelayInputMoverComponent : Component
|
||||
{
|
||||
[ViewVariables]
|
||||
public EntityUid? RelayEntity;
|
||||
}
|
||||
@@ -1,24 +0,0 @@
|
||||
namespace Content.Shared.Movement.Components
|
||||
{
|
||||
[RegisterComponent]
|
||||
[ComponentReference(typeof(IMoverComponent))]
|
||||
public sealed class SharedDummyInputMoverComponent : Component, IMoverComponent
|
||||
{
|
||||
public bool IgnorePaused => false;
|
||||
|
||||
public bool CanMove { get; set; } = true;
|
||||
|
||||
public Angle LastGridAngle { get => Angle.Zero; set {} }
|
||||
|
||||
public bool Sprinting => false;
|
||||
public (Vector2 walking, Vector2 sprinting) VelocityDir => (Vector2.Zero, Vector2.Zero);
|
||||
|
||||
public void SetVelocityDirection(Direction direction, ushort subTick, bool enabled)
|
||||
{
|
||||
}
|
||||
|
||||
public void SetSprinting(ushort subTick, bool walking)
|
||||
{
|
||||
}
|
||||
}
|
||||
}
|
||||
@@ -1,257 +0,0 @@
|
||||
using Content.Shared.CCVar;
|
||||
using Robust.Shared.Configuration;
|
||||
using Robust.Shared.GameStates;
|
||||
using Robust.Shared.Serialization;
|
||||
using Robust.Shared.Timing;
|
||||
|
||||
namespace Content.Shared.Movement.Components
|
||||
{
|
||||
[RegisterComponent]
|
||||
[ComponentReference(typeof(IMoverComponent))]
|
||||
[NetworkedComponent()]
|
||||
public sealed class SharedPlayerInputMoverComponent : Component, IMoverComponent
|
||||
{
|
||||
// This class has to be able to handle server TPS being lower than client FPS.
|
||||
// While still having perfectly responsive movement client side.
|
||||
// We do this by keeping track of the exact sub-tick values that inputs are pressed on the client,
|
||||
// and then building a total movement vector based on those sub-tick steps.
|
||||
//
|
||||
// We keep track of the last sub-tick a movement input came in,
|
||||
// Then when a new input comes in, we calculate the fraction of the tick the LAST input was active for
|
||||
// (new sub-tick - last sub-tick)
|
||||
// and then add to the total-this-tick movement vector
|
||||
// by multiplying that fraction by the movement direction for the last input.
|
||||
// This allows us to incrementally build the movement vector for the current tick,
|
||||
// without having to keep track of some kind of list of inputs and calculating it later.
|
||||
//
|
||||
// We have to keep track of a separate movement vector for walking and sprinting,
|
||||
// since we don't actually know our current movement speed while processing inputs.
|
||||
// We change which vector we write into based on whether we were sprinting after the previous input.
|
||||
// (well maybe we do but the code is designed such that MoverSystem applies movement speed)
|
||||
// (and I'm not changing that)
|
||||
|
||||
[Dependency] private readonly IConfigurationManager _configurationManager = default!;
|
||||
[Dependency] private readonly IGameTiming _gameTiming = default!;
|
||||
[Dependency] private readonly IEntityManager _entityManager = default!;
|
||||
public GameTick _lastInputTick;
|
||||
public ushort _lastInputSubTick;
|
||||
public Vector2 CurTickWalkMovement;
|
||||
public Vector2 CurTickSprintMovement;
|
||||
|
||||
private MoveButtons _heldMoveButtons = MoveButtons.None;
|
||||
|
||||
[ViewVariables]
|
||||
public Angle LastGridAngle { get; set; } = new(0);
|
||||
|
||||
public bool Sprinting => !HasFlag(_heldMoveButtons, MoveButtons.Walk);
|
||||
|
||||
[ViewVariables(VVAccess.ReadWrite)]
|
||||
public bool CanMove { get; set; } = true;
|
||||
|
||||
/// <summary>
|
||||
/// Calculated linear velocity direction of the entity.
|
||||
/// </summary>
|
||||
[ViewVariables]
|
||||
public (Vector2 walking, Vector2 sprinting) VelocityDir
|
||||
{
|
||||
get
|
||||
{
|
||||
if (!_gameTiming.InSimulation)
|
||||
{
|
||||
// Outside of simulation we'll be running client predicted movement per-frame.
|
||||
// So return a full-length vector as if it's a full tick.
|
||||
// Physics system will have the correct time step anyways.
|
||||
var immediateDir = DirVecForButtons(_heldMoveButtons);
|
||||
return Sprinting ? (Vector2.Zero, immediateDir) : (immediateDir, Vector2.Zero);
|
||||
}
|
||||
|
||||
Vector2 walk;
|
||||
Vector2 sprint;
|
||||
float remainingFraction;
|
||||
|
||||
if (_gameTiming.CurTick > _lastInputTick)
|
||||
{
|
||||
walk = Vector2.Zero;
|
||||
sprint = Vector2.Zero;
|
||||
remainingFraction = 1;
|
||||
}
|
||||
else
|
||||
{
|
||||
walk = CurTickWalkMovement;
|
||||
sprint = CurTickSprintMovement;
|
||||
remainingFraction = (ushort.MaxValue - _lastInputSubTick) / (float) ushort.MaxValue;
|
||||
}
|
||||
|
||||
var curDir = DirVecForButtons(_heldMoveButtons) * remainingFraction;
|
||||
|
||||
if (Sprinting)
|
||||
{
|
||||
sprint += curDir;
|
||||
}
|
||||
else
|
||||
{
|
||||
walk += curDir;
|
||||
}
|
||||
|
||||
// Logger.Info($"{curDir}{walk}{sprint}");
|
||||
return (walk, sprint);
|
||||
}
|
||||
}
|
||||
|
||||
/// <summary>
|
||||
/// Whether or not the player can move diagonally.
|
||||
/// </summary>
|
||||
[ViewVariables]
|
||||
public bool DiagonalMovementEnabled => _configurationManager.GetCVar<bool>(CCVars.GameDiagonalMovement);
|
||||
|
||||
/// <inheritdoc />
|
||||
protected override void Initialize()
|
||||
{
|
||||
base.Initialize();
|
||||
LastGridAngle = _entityManager.GetComponent<TransformComponent>(Owner).Parent?.WorldRotation ?? new Angle(0);
|
||||
}
|
||||
|
||||
/// <summary>
|
||||
/// Toggles one of the four cardinal directions. Each of the four directions are
|
||||
/// composed into a single direction vector, <see cref="VelocityDir"/>. Enabling
|
||||
/// opposite directions will cancel each other out, resulting in no direction.
|
||||
/// </summary>
|
||||
/// <param name="direction">Direction to toggle.</param>
|
||||
/// <param name="subTick"></param>
|
||||
/// <param name="enabled">If the direction is active.</param>
|
||||
public void SetVelocityDirection(Direction direction, ushort subTick, bool enabled)
|
||||
{
|
||||
// Logger.Info($"[{_gameTiming.CurTick}/{subTick}] {direction}: {enabled}");
|
||||
|
||||
var bit = direction switch
|
||||
{
|
||||
Direction.East => MoveButtons.Right,
|
||||
Direction.North => MoveButtons.Up,
|
||||
Direction.West => MoveButtons.Left,
|
||||
Direction.South => MoveButtons.Down,
|
||||
_ => throw new ArgumentException(nameof(direction))
|
||||
};
|
||||
|
||||
SetMoveInput(subTick, enabled, bit);
|
||||
}
|
||||
|
||||
private void SetMoveInput(ushort subTick, bool enabled, MoveButtons bit)
|
||||
{
|
||||
// Modifies held state of a movement button at a certain sub tick and updates current tick movement vectors.
|
||||
|
||||
if (_gameTiming.CurTick > _lastInputTick)
|
||||
{
|
||||
CurTickWalkMovement = Vector2.Zero;
|
||||
CurTickSprintMovement = Vector2.Zero;
|
||||
_lastInputTick = _gameTiming.CurTick;
|
||||
_lastInputSubTick = 0;
|
||||
}
|
||||
|
||||
if (subTick >= _lastInputSubTick)
|
||||
{
|
||||
var fraction = (subTick - _lastInputSubTick) / (float) ushort.MaxValue;
|
||||
|
||||
ref var lastMoveAmount = ref Sprinting ? ref CurTickSprintMovement : ref CurTickWalkMovement;
|
||||
|
||||
lastMoveAmount += DirVecForButtons(_heldMoveButtons) * fraction;
|
||||
|
||||
_lastInputSubTick = subTick;
|
||||
}
|
||||
|
||||
if (enabled)
|
||||
{
|
||||
_heldMoveButtons |= bit;
|
||||
}
|
||||
else
|
||||
{
|
||||
_heldMoveButtons &= ~bit;
|
||||
}
|
||||
|
||||
Dirty();
|
||||
}
|
||||
|
||||
public void SetSprinting(ushort subTick, bool walking)
|
||||
{
|
||||
// Logger.Info($"[{_gameTiming.CurTick}/{subTick}] Sprint: {enabled}");
|
||||
|
||||
SetMoveInput(subTick, walking, MoveButtons.Walk);
|
||||
}
|
||||
|
||||
public override void HandleComponentState(ComponentState? curState, ComponentState? nextState)
|
||||
{
|
||||
if (curState is MoverComponentState state)
|
||||
{
|
||||
_heldMoveButtons = state.Buttons;
|
||||
_lastInputTick = GameTick.Zero;
|
||||
_lastInputSubTick = 0;
|
||||
CanMove = state.CanMove;
|
||||
}
|
||||
}
|
||||
|
||||
public override ComponentState GetComponentState()
|
||||
{
|
||||
return new MoverComponentState(_heldMoveButtons, CanMove);
|
||||
}
|
||||
|
||||
/// <summary>
|
||||
/// Retrieves the normalized direction vector for a specified combination of movement keys.
|
||||
/// </summary>
|
||||
private Vector2 DirVecForButtons(MoveButtons buttons)
|
||||
{
|
||||
// key directions are in screen coordinates
|
||||
// _moveDir is in world coordinates
|
||||
// if the camera is moved, this needs to be changed
|
||||
|
||||
var x = 0;
|
||||
x -= HasFlag(buttons, MoveButtons.Left) ? 1 : 0;
|
||||
x += HasFlag(buttons, MoveButtons.Right) ? 1 : 0;
|
||||
|
||||
var y = 0;
|
||||
if (DiagonalMovementEnabled || x == 0)
|
||||
{
|
||||
y -= HasFlag(buttons, MoveButtons.Down) ? 1 : 0;
|
||||
y += HasFlag(buttons, MoveButtons.Up) ? 1 : 0;
|
||||
}
|
||||
|
||||
var vec = new Vector2(x, y);
|
||||
|
||||
// can't normalize zero length vector
|
||||
if (vec.LengthSquared > 1.0e-6)
|
||||
{
|
||||
// Normalize so that diagonals aren't faster or something.
|
||||
vec = vec.Normalized;
|
||||
}
|
||||
|
||||
return vec;
|
||||
}
|
||||
|
||||
[Serializable, NetSerializable]
|
||||
private sealed class MoverComponentState : ComponentState
|
||||
{
|
||||
public MoveButtons Buttons { get; }
|
||||
public readonly bool CanMove;
|
||||
|
||||
public MoverComponentState(MoveButtons buttons, bool canMove)
|
||||
{
|
||||
Buttons = buttons;
|
||||
CanMove = canMove;
|
||||
}
|
||||
}
|
||||
|
||||
[Flags]
|
||||
private enum MoveButtons : byte
|
||||
{
|
||||
None = 0,
|
||||
Up = 1,
|
||||
Down = 2,
|
||||
Left = 4,
|
||||
Right = 8,
|
||||
Walk = 16,
|
||||
}
|
||||
|
||||
private static bool HasFlag(MoveButtons buttons, MoveButtons flag)
|
||||
{
|
||||
return (buttons & flag) == flag;
|
||||
}
|
||||
}
|
||||
}
|
||||
@@ -1,88 +0,0 @@
|
||||
using Robust.Shared.GameStates;
|
||||
using Robust.Shared.Map;
|
||||
using Robust.Shared.Serialization;
|
||||
|
||||
namespace Content.Shared.Movement.Components
|
||||
{
|
||||
/// <summary>
|
||||
/// The basic player mover with footsteps and grabbing
|
||||
/// </summary>
|
||||
[RegisterComponent]
|
||||
[ComponentReference(typeof(IMobMoverComponent))]
|
||||
[NetworkedComponent()]
|
||||
public sealed class SharedPlayerMobMoverComponent : Component, IMobMoverComponent
|
||||
{
|
||||
private float _stepSoundDistance;
|
||||
[DataField("grabRange")]
|
||||
private float _grabRange = IMobMoverComponent.GrabRangeDefault;
|
||||
[DataField("pushStrength")]
|
||||
private float _pushStrength = IMobMoverComponent.PushStrengthDefault;
|
||||
|
||||
[ViewVariables(VVAccess.ReadWrite)]
|
||||
public EntityCoordinates LastPosition { get; set; }
|
||||
|
||||
/// <summary>
|
||||
/// Used to keep track of how far we have moved before playing a step sound
|
||||
/// </summary>
|
||||
[ViewVariables(VVAccess.ReadWrite)]
|
||||
public float StepSoundDistance
|
||||
{
|
||||
get => _stepSoundDistance;
|
||||
set
|
||||
{
|
||||
if (MathHelper.CloseToPercent(_stepSoundDistance, value)) return;
|
||||
_stepSoundDistance = value;
|
||||
}
|
||||
}
|
||||
|
||||
[ViewVariables(VVAccess.ReadWrite)]
|
||||
public float GrabRange
|
||||
{
|
||||
get => _grabRange;
|
||||
set
|
||||
{
|
||||
if (MathHelper.CloseToPercent(_grabRange, value)) return;
|
||||
_grabRange = value;
|
||||
Dirty();
|
||||
}
|
||||
}
|
||||
|
||||
[ViewVariables(VVAccess.ReadWrite)]
|
||||
public float PushStrength
|
||||
{
|
||||
get => _pushStrength;
|
||||
set
|
||||
{
|
||||
if (MathHelper.CloseToPercent(_pushStrength, value)) return;
|
||||
_pushStrength = value;
|
||||
Dirty();
|
||||
}
|
||||
}
|
||||
|
||||
public override ComponentState GetComponentState()
|
||||
{
|
||||
return new PlayerMobMoverComponentState(_grabRange, _pushStrength);
|
||||
}
|
||||
|
||||
public override void HandleComponentState(ComponentState? curState, ComponentState? nextState)
|
||||
{
|
||||
base.HandleComponentState(curState, nextState);
|
||||
if (curState is not PlayerMobMoverComponentState playerMoverState) return;
|
||||
GrabRange = playerMoverState.GrabRange;
|
||||
PushStrength = playerMoverState.PushStrength;
|
||||
}
|
||||
|
||||
[Serializable, NetSerializable]
|
||||
private sealed class PlayerMobMoverComponentState : ComponentState
|
||||
{
|
||||
public float GrabRange;
|
||||
public float PushStrength;
|
||||
|
||||
public PlayerMobMoverComponentState(float grabRange, float pushStrength)
|
||||
{
|
||||
GrabRange = grabRange;
|
||||
PushStrength = pushStrength;
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
@@ -0,0 +1,16 @@
|
||||
namespace Content.Shared.Movement.Events
|
||||
{
|
||||
/// <summary>
|
||||
/// Raised on an entity's parent when it has movement inputs while in a container.
|
||||
/// </summary>
|
||||
[ByRefEvent]
|
||||
public readonly struct ContainerRelayMovementEntityEvent
|
||||
{
|
||||
public readonly EntityUid Entity;
|
||||
|
||||
public ContainerRelayMovementEntityEvent(EntityUid entity)
|
||||
{
|
||||
Entity = entity;
|
||||
}
|
||||
}
|
||||
}
|
||||
17
Content.Shared/Movement/Events/MoveInputEvent.cs
Normal file
17
Content.Shared/Movement/Events/MoveInputEvent.cs
Normal file
@@ -0,0 +1,17 @@
|
||||
using Robust.Shared.Players;
|
||||
|
||||
namespace Content.Shared.Movement.Events;
|
||||
|
||||
/// <summary>
|
||||
/// Raised on an entity whenever it has a movement input.
|
||||
/// </summary>
|
||||
[ByRefEvent]
|
||||
public readonly struct MoveInputEvent
|
||||
{
|
||||
public readonly EntityUid Entity;
|
||||
|
||||
public MoveInputEvent(EntityUid entity)
|
||||
{
|
||||
Entity = entity;
|
||||
}
|
||||
}
|
||||
@@ -1,13 +0,0 @@
|
||||
using Robust.Shared.Players;
|
||||
|
||||
namespace Content.Shared.Movement.Events;
|
||||
|
||||
public sealed class RelayMoveInputEvent : EntityEventArgs
|
||||
{
|
||||
public ICommonSession Session { get; }
|
||||
|
||||
public RelayMoveInputEvent(ICommonSession session)
|
||||
{
|
||||
Session = session;
|
||||
}
|
||||
}
|
||||
@@ -1,12 +0,0 @@
|
||||
namespace Content.Shared.Movement.Events
|
||||
{
|
||||
public sealed class RelayMovementEntityEvent : EntityEventArgs
|
||||
{
|
||||
public EntityUid Entity { get; }
|
||||
|
||||
public RelayMovementEntityEvent(EntityUid entity)
|
||||
{
|
||||
Entity = entity;
|
||||
}
|
||||
}
|
||||
}
|
||||
@@ -1,35 +0,0 @@
|
||||
namespace Content.Shared.Movement;
|
||||
|
||||
/// <summary>
|
||||
/// Contains all of the relevant data for mob movement.
|
||||
/// Raised on a mob if something wants to overwrite its movement characteristics.
|
||||
/// </summary>
|
||||
[ByRefEvent]
|
||||
public struct MobMovementProfileEvent
|
||||
{
|
||||
/// <summary>
|
||||
/// Should we use this profile instead of the entity's default?
|
||||
/// </summary>
|
||||
public bool Override = false;
|
||||
|
||||
public readonly bool Touching;
|
||||
public readonly bool Weightless;
|
||||
|
||||
public float Friction;
|
||||
public float WeightlessModifier;
|
||||
public float Acceleration;
|
||||
|
||||
public MobMovementProfileEvent(
|
||||
bool touching,
|
||||
bool weightless,
|
||||
float friction,
|
||||
float weightlessModifier,
|
||||
float acceleration)
|
||||
{
|
||||
Touching = touching;
|
||||
Weightless = weightless;
|
||||
Friction = friction;
|
||||
WeightlessModifier = weightlessModifier;
|
||||
Acceleration = acceleration;
|
||||
}
|
||||
}
|
||||
@@ -29,8 +29,9 @@ public abstract class SharedJetpackSystem : EntitySystem
|
||||
SubscribeLocalEvent<JetpackComponent, GetItemActionsEvent>(OnJetpackGetAction);
|
||||
SubscribeLocalEvent<JetpackComponent, DroppedEvent>(OnJetpackDropped);
|
||||
SubscribeLocalEvent<JetpackComponent, ToggleJetpackEvent>(OnJetpackToggle);
|
||||
SubscribeLocalEvent<JetpackComponent, CanWeightlessMoveEvent>(OnJetpackCanWeightlessMove);
|
||||
|
||||
SubscribeLocalEvent<JetpackUserComponent, CanWeightlessMoveEvent>(OnJetpackUserCanWeightless);
|
||||
SubscribeLocalEvent<JetpackUserComponent, MobMovementProfileEvent>(OnJetpackUserMovement);
|
||||
SubscribeLocalEvent<JetpackUserComponent, EntParentChangedMessage>(OnJetpackUserEntParentChanged);
|
||||
SubscribeLocalEvent<JetpackUserComponent, ComponentGetState>(OnJetpackUserGetState);
|
||||
SubscribeLocalEvent<JetpackUserComponent, ComponentHandleState>(OnJetpackUserHandleState);
|
||||
@@ -38,6 +39,11 @@ public abstract class SharedJetpackSystem : EntitySystem
|
||||
SubscribeLocalEvent<GravityChangedMessage>(OnJetpackUserGravityChanged);
|
||||
}
|
||||
|
||||
private void OnJetpackCanWeightlessMove(EntityUid uid, JetpackComponent component, ref CanWeightlessMoveEvent args)
|
||||
{
|
||||
args.CanMove = true;
|
||||
}
|
||||
|
||||
private void OnJetpackUserGravityChanged(GravityChangedMessage ev)
|
||||
{
|
||||
var gridUid = ev.ChangedGridIndex;
|
||||
@@ -75,17 +81,6 @@ public abstract class SharedJetpackSystem : EntitySystem
|
||||
SetEnabled(component, false, args.User);
|
||||
}
|
||||
|
||||
private void OnJetpackUserMovement(EntityUid uid, JetpackUserComponent component, ref MobMovementProfileEvent args)
|
||||
{
|
||||
// Only overwrite jetpack movement if they're offgrid.
|
||||
if (args.Override || !args.Weightless) return;
|
||||
|
||||
args.Override = true;
|
||||
args.Acceleration = component.Acceleration;
|
||||
args.WeightlessModifier = component.WeightlessModifier;
|
||||
args.Friction = component.Friction;
|
||||
}
|
||||
|
||||
private void OnJetpackUserCanWeightless(EntityUid uid, JetpackUserComponent component, ref CanWeightlessMoveEvent args)
|
||||
{
|
||||
args.CanMove = true;
|
||||
@@ -106,12 +101,17 @@ public abstract class SharedJetpackSystem : EntitySystem
|
||||
private void SetupUser(EntityUid uid, JetpackComponent component)
|
||||
{
|
||||
var user = EnsureComp<JetpackUserComponent>(uid);
|
||||
user.Acceleration = component.Acceleration;
|
||||
user.Friction = component.Friction;
|
||||
user.WeightlessModifier = component.WeightlessModifier;
|
||||
var relay = EnsureComp<RelayInputMoverComponent>(uid);
|
||||
relay.RelayEntity = component.Owner;
|
||||
user.Jetpack = component.Owner;
|
||||
}
|
||||
|
||||
private void RemoveUser(EntityUid uid)
|
||||
{
|
||||
if (!RemComp<JetpackUserComponent>(uid)) return;
|
||||
RemComp<RelayInputMoverComponent>(uid);
|
||||
}
|
||||
|
||||
private void OnJetpackToggle(EntityUid uid, JetpackComponent component, ToggleJetpackEvent args)
|
||||
{
|
||||
if (args.Handled) return;
|
||||
@@ -175,7 +175,7 @@ public abstract class SharedJetpackSystem : EntitySystem
|
||||
}
|
||||
else
|
||||
{
|
||||
RemComp<JetpackUserComponent>(user.Value);
|
||||
RemoveUser(user.Value);
|
||||
}
|
||||
|
||||
_movementSpeedModifier.RefreshMovementSpeedModifiers(user.Value);
|
||||
|
||||
@@ -1,11 +1,14 @@
|
||||
using Content.Shared.MobState.Components;
|
||||
using Content.Shared.CCVar;
|
||||
using Content.Shared.Input;
|
||||
using Content.Shared.Movement.Components;
|
||||
using Content.Shared.Movement.Events;
|
||||
using Content.Shared.Vehicle.Components;
|
||||
using Robust.Shared.Containers;
|
||||
using Content.Shared.Shuttles.Components;
|
||||
using Robust.Shared.GameStates;
|
||||
using Robust.Shared.Input;
|
||||
using Robust.Shared.Input.Binding;
|
||||
using Robust.Shared.Players;
|
||||
using Robust.Shared.Serialization;
|
||||
using Robust.Shared.Timing;
|
||||
|
||||
namespace Content.Shared.Movement.Systems
|
||||
{
|
||||
@@ -27,7 +30,41 @@ namespace Content.Shared.Movement.Systems
|
||||
.Bind(EngineKeyFunctions.MoveRight, moveRightCmdHandler)
|
||||
.Bind(EngineKeyFunctions.MoveDown, moveDownCmdHandler)
|
||||
.Bind(EngineKeyFunctions.Walk, new WalkInputCmdHandler(this))
|
||||
// TODO: Relay
|
||||
// Shuttle
|
||||
.Bind(ContentKeyFunctions.ShuttleStrafeUp, new ShuttleInputCmdHandler(this, ShuttleButtons.StrafeUp))
|
||||
.Bind(ContentKeyFunctions.ShuttleStrafeLeft, new ShuttleInputCmdHandler(this, ShuttleButtons.StrafeLeft))
|
||||
.Bind(ContentKeyFunctions.ShuttleStrafeRight, new ShuttleInputCmdHandler(this, ShuttleButtons.StrafeRight))
|
||||
.Bind(ContentKeyFunctions.ShuttleStrafeDown, new ShuttleInputCmdHandler(this, ShuttleButtons.StrafeDown))
|
||||
.Bind(ContentKeyFunctions.ShuttleRotateLeft, new ShuttleInputCmdHandler(this, ShuttleButtons.RotateLeft))
|
||||
.Bind(ContentKeyFunctions.ShuttleRotateRight, new ShuttleInputCmdHandler(this, ShuttleButtons.RotateRight))
|
||||
.Bind(ContentKeyFunctions.ShuttleBrake, new ShuttleInputCmdHandler(this, ShuttleButtons.Brake))
|
||||
.Register<SharedMoverController>();
|
||||
|
||||
SubscribeLocalEvent<InputMoverComponent, ComponentInit>(OnInputInit);
|
||||
SubscribeLocalEvent<InputMoverComponent, ComponentGetState>(OnInputGetState);
|
||||
SubscribeLocalEvent<InputMoverComponent, ComponentHandleState>(OnInputHandleState);
|
||||
}
|
||||
|
||||
private void SetMoveInput(InputMoverComponent component, MoveButtons buttons)
|
||||
{
|
||||
if (component.HeldMoveButtons == buttons) return;
|
||||
component.HeldMoveButtons = buttons;
|
||||
Dirty(component);
|
||||
}
|
||||
|
||||
private void OnInputHandleState(EntityUid uid, InputMoverComponent component, ref ComponentHandleState args)
|
||||
{
|
||||
if (args.Current is not InputMoverComponentState state) return;
|
||||
component.HeldMoveButtons = state.Buttons;
|
||||
component.LastInputTick = GameTick.Zero;
|
||||
component.LastInputSubTick = 0;
|
||||
component.CanMove = state.CanMove;
|
||||
}
|
||||
|
||||
private void OnInputGetState(EntityUid uid, InputMoverComponent component, ref ComponentGetState args)
|
||||
{
|
||||
args.State = new InputMoverComponentState(component.HeldMoveButtons, component.CanMove);
|
||||
}
|
||||
|
||||
private void ShutdownInput()
|
||||
@@ -35,46 +72,229 @@ namespace Content.Shared.Movement.Systems
|
||||
CommandBinds.Unregister<SharedMoverController>();
|
||||
}
|
||||
|
||||
private void HandleDirChange(ICommonSession? session, Direction dir, ushort subTick, bool state)
|
||||
public bool DiagonalMovementEnabled => _configManager.GetCVar(CCVars.GameDiagonalMovement);
|
||||
|
||||
protected virtual void HandleShuttleInput(EntityUid uid, ShuttleButtons button, ushort subTick, bool state) {}
|
||||
|
||||
private void HandleDirChange(EntityUid entity, Direction dir, ushort subTick, bool state)
|
||||
{
|
||||
if (!TryComp<IMoverComponent>(session?.AttachedEntity, out var moverComp))
|
||||
return;
|
||||
TryComp<InputMoverComponent>(entity, out var moverComp);
|
||||
|
||||
var owner = session?.AttachedEntity;
|
||||
|
||||
if (owner != null && session != null)
|
||||
if (TryComp<RelayInputMoverComponent>(entity, out var relayMover))
|
||||
{
|
||||
EntityManager.EventBus.RaiseLocalEvent(owner.Value, new RelayMoveInputEvent(session), true);
|
||||
// if we swap to relay then stop our existing input if we ever change back.
|
||||
if (moverComp != null)
|
||||
{
|
||||
SetMoveInput(moverComp, MoveButtons.None);
|
||||
}
|
||||
|
||||
// For stuff like "Moving out of locker" or the likes
|
||||
if (owner.Value.IsInContainer() &&
|
||||
(!EntityManager.TryGetComponent(owner.Value, out MobStateComponent? mobState) ||
|
||||
mobState.IsAlive()))
|
||||
{
|
||||
var relayMoveEvent = new RelayMovementEntityEvent(owner.Value);
|
||||
EntityManager.EventBus.RaiseLocalEvent(EntityManager.GetComponent<TransformComponent>(owner.Value).ParentUid, relayMoveEvent, true);
|
||||
}
|
||||
// Pass the rider's inputs to the vehicle (the rider itself is on the ignored list in C.S/MoverController.cs)
|
||||
if (TryComp<RiderComponent>(owner.Value, out var rider) && rider.Vehicle != null && rider.Vehicle.HasKey)
|
||||
{
|
||||
if (TryComp<IMoverComponent>(rider.Vehicle.Owner, out var vehicleMover))
|
||||
{
|
||||
vehicleMover.SetVelocityDirection(dir, subTick, state);
|
||||
}
|
||||
}
|
||||
if (relayMover.RelayEntity == null) return;
|
||||
|
||||
HandleDirChange(relayMover.RelayEntity.Value, dir, subTick, state);
|
||||
return;
|
||||
}
|
||||
|
||||
moverComp.SetVelocityDirection(dir, subTick, state);
|
||||
if (moverComp == null)
|
||||
return;
|
||||
|
||||
// Relay the fact we had any movement event.
|
||||
// TODO: Ideally we'd do these in a tick instead of out of sim.
|
||||
var owner = moverComp.Owner;
|
||||
var moveEvent = new MoveInputEvent(entity);
|
||||
RaiseLocalEvent(owner, ref moveEvent);
|
||||
|
||||
// For stuff like "Moving out of locker" or the likes
|
||||
// We'll relay a movement input to the parent.
|
||||
if (_container.IsEntityInContainer(owner) &&
|
||||
TryComp<TransformComponent>(owner, out var xform) &&
|
||||
xform.ParentUid.IsValid() &&
|
||||
_mobState.IsAlive(owner))
|
||||
{
|
||||
var relayMoveEvent = new ContainerRelayMovementEntityEvent(owner);
|
||||
RaiseLocalEvent(xform.ParentUid, ref relayMoveEvent);
|
||||
}
|
||||
|
||||
SetVelocityDirection(moverComp, dir, subTick, state);
|
||||
}
|
||||
|
||||
private void HandleRunChange(ICommonSession? session, ushort subTick, bool walking)
|
||||
private void OnInputInit(EntityUid uid, InputMoverComponent component, ComponentInit args)
|
||||
{
|
||||
if (!TryComp<IMoverComponent>(session?.AttachedEntity, out var moverComp))
|
||||
var xform = Transform(uid);
|
||||
|
||||
if (!xform.ParentUid.IsValid()) return;
|
||||
|
||||
component.LastGridAngle = Transform(xform.ParentUid).WorldRotation;
|
||||
}
|
||||
|
||||
private void HandleRunChange(EntityUid uid, ushort subTick, bool walking)
|
||||
{
|
||||
TryComp<InputMoverComponent>(uid, out var moverComp);
|
||||
|
||||
if (TryComp<RelayInputMoverComponent>(uid, out var relayMover))
|
||||
{
|
||||
// if we swap to relay then stop our existing input if we ever change back.
|
||||
if (moverComp != null)
|
||||
{
|
||||
SetMoveInput(moverComp, MoveButtons.None);
|
||||
}
|
||||
|
||||
if (relayMover.RelayEntity == null) return;
|
||||
|
||||
HandleRunChange(relayMover.RelayEntity.Value, subTick, walking);
|
||||
return;
|
||||
}
|
||||
|
||||
moverComp.SetSprinting(subTick, walking);
|
||||
if (moverComp == null) return;
|
||||
|
||||
SetSprinting(moverComp, subTick, walking);
|
||||
}
|
||||
|
||||
public (Vector2 Walking, Vector2 Sprinting) GetVelocityInput(InputMoverComponent mover)
|
||||
{
|
||||
if (!Timing.InSimulation)
|
||||
{
|
||||
// Outside of simulation we'll be running client predicted movement per-frame.
|
||||
// So return a full-length vector as if it's a full tick.
|
||||
// Physics system will have the correct time step anyways.
|
||||
var immediateDir = DirVecForButtons(mover.HeldMoveButtons);
|
||||
return mover.Sprinting ? (Vector2.Zero, immediateDir) : (immediateDir, Vector2.Zero);
|
||||
}
|
||||
|
||||
Vector2 walk;
|
||||
Vector2 sprint;
|
||||
float remainingFraction;
|
||||
|
||||
if (Timing.CurTick > mover.LastInputTick)
|
||||
{
|
||||
walk = Vector2.Zero;
|
||||
sprint = Vector2.Zero;
|
||||
remainingFraction = 1;
|
||||
}
|
||||
else
|
||||
{
|
||||
walk = mover.CurTickWalkMovement;
|
||||
sprint = mover.CurTickSprintMovement;
|
||||
remainingFraction = (ushort.MaxValue - mover.LastInputSubTick) / (float) ushort.MaxValue;
|
||||
}
|
||||
|
||||
var curDir = DirVecForButtons(mover.HeldMoveButtons) * remainingFraction;
|
||||
|
||||
if (mover.Sprinting)
|
||||
{
|
||||
sprint += curDir;
|
||||
}
|
||||
else
|
||||
{
|
||||
walk += curDir;
|
||||
}
|
||||
|
||||
// Logger.Info($"{curDir}{walk}{sprint}");
|
||||
return (walk, sprint);
|
||||
}
|
||||
|
||||
/// <summary>
|
||||
/// Toggles one of the four cardinal directions. Each of the four directions are
|
||||
/// composed into a single direction vector, <see cref="VelocityDir"/>. Enabling
|
||||
/// opposite directions will cancel each other out, resulting in no direction.
|
||||
/// </summary>
|
||||
public void SetVelocityDirection(InputMoverComponent component, Direction direction, ushort subTick, bool enabled)
|
||||
{
|
||||
// Logger.Info($"[{_gameTiming.CurTick}/{subTick}] {direction}: {enabled}");
|
||||
|
||||
var bit = direction switch
|
||||
{
|
||||
Direction.East => MoveButtons.Right,
|
||||
Direction.North => MoveButtons.Up,
|
||||
Direction.West => MoveButtons.Left,
|
||||
Direction.South => MoveButtons.Down,
|
||||
_ => throw new ArgumentException(nameof(direction))
|
||||
};
|
||||
|
||||
SetMoveInput(component, subTick, enabled, bit);
|
||||
}
|
||||
|
||||
private void SetMoveInput(InputMoverComponent component, ushort subTick, bool enabled, MoveButtons bit)
|
||||
{
|
||||
// Modifies held state of a movement button at a certain sub tick and updates current tick movement vectors.
|
||||
ResetSubtick(component);
|
||||
|
||||
if (subTick >= component.LastInputSubTick)
|
||||
{
|
||||
var fraction = (subTick - component.LastInputSubTick) / (float) ushort.MaxValue;
|
||||
|
||||
ref var lastMoveAmount = ref component.Sprinting ? ref component.CurTickSprintMovement : ref component.CurTickWalkMovement;
|
||||
|
||||
lastMoveAmount += DirVecForButtons(component.HeldMoveButtons) * fraction;
|
||||
|
||||
component.LastInputSubTick = subTick;
|
||||
}
|
||||
|
||||
var buttons = component.HeldMoveButtons;
|
||||
|
||||
if (enabled)
|
||||
{
|
||||
buttons |= bit;
|
||||
}
|
||||
else
|
||||
{
|
||||
buttons &= ~bit;
|
||||
}
|
||||
|
||||
SetMoveInput(component, buttons);
|
||||
}
|
||||
|
||||
private void ResetSubtick(InputMoverComponent component)
|
||||
{
|
||||
if (Timing.CurTick <= component.LastInputTick) return;
|
||||
|
||||
component.CurTickWalkMovement = Vector2.Zero;
|
||||
component.CurTickSprintMovement = Vector2.Zero;
|
||||
component.LastInputTick = Timing.CurTick;
|
||||
component.LastInputSubTick = 0;
|
||||
}
|
||||
|
||||
public void SetSprinting(InputMoverComponent component, ushort subTick, bool walking)
|
||||
{
|
||||
// Logger.Info($"[{_gameTiming.CurTick}/{subTick}] Sprint: {enabled}");
|
||||
|
||||
SetMoveInput(component, subTick, walking, MoveButtons.Walk);
|
||||
}
|
||||
|
||||
/// <summary>
|
||||
/// Retrieves the normalized direction vector for a specified combination of movement keys.
|
||||
/// </summary>
|
||||
private Vector2 DirVecForButtons(MoveButtons buttons)
|
||||
{
|
||||
// key directions are in screen coordinates
|
||||
// _moveDir is in world coordinates
|
||||
// if the camera is moved, this needs to be changed
|
||||
|
||||
var x = 0;
|
||||
x -= HasFlag(buttons, MoveButtons.Left) ? 1 : 0;
|
||||
x += HasFlag(buttons, MoveButtons.Right) ? 1 : 0;
|
||||
|
||||
var y = 0;
|
||||
if (DiagonalMovementEnabled || x == 0)
|
||||
{
|
||||
y -= HasFlag(buttons, MoveButtons.Down) ? 1 : 0;
|
||||
y += HasFlag(buttons, MoveButtons.Up) ? 1 : 0;
|
||||
}
|
||||
|
||||
var vec = new Vector2(x, y);
|
||||
|
||||
// can't normalize zero length vector
|
||||
if (vec.LengthSquared > 1.0e-6)
|
||||
{
|
||||
// Normalize so that diagonals aren't faster or something.
|
||||
vec = vec.Normalized;
|
||||
}
|
||||
|
||||
return vec;
|
||||
}
|
||||
|
||||
private static bool HasFlag(MoveButtons buttons, MoveButtons flag)
|
||||
{
|
||||
return (buttons & flag) == flag;
|
||||
}
|
||||
|
||||
private sealed class MoverDirInputCmdHandler : InputCmdHandler
|
||||
@@ -90,9 +310,9 @@ namespace Content.Shared.Movement.Systems
|
||||
|
||||
public override bool HandleCmdMessage(ICommonSession? session, InputCmdMessage message)
|
||||
{
|
||||
if (message is not FullInputCmdMessage full) return false;
|
||||
if (message is not FullInputCmdMessage full || session?.AttachedEntity == null) return false;
|
||||
|
||||
_controller.HandleDirChange(session, _dir, message.SubTick, full.State == BoundKeyState.Down);
|
||||
_controller.HandleDirChange(session.AttachedEntity.Value, _dir, message.SubTick, full.State == BoundKeyState.Down);
|
||||
return false;
|
||||
}
|
||||
}
|
||||
@@ -108,11 +328,68 @@ namespace Content.Shared.Movement.Systems
|
||||
|
||||
public override bool HandleCmdMessage(ICommonSession? session, InputCmdMessage message)
|
||||
{
|
||||
if (message is not FullInputCmdMessage full) return false;
|
||||
if (message is not FullInputCmdMessage full || session?.AttachedEntity == null) return false;
|
||||
|
||||
_controller.HandleRunChange(session, full.SubTick, full.State == BoundKeyState.Down);
|
||||
_controller.HandleRunChange(session.AttachedEntity.Value, full.SubTick, full.State == BoundKeyState.Down);
|
||||
return false;
|
||||
}
|
||||
}
|
||||
|
||||
[Serializable, NetSerializable]
|
||||
private sealed class InputMoverComponentState : ComponentState
|
||||
{
|
||||
public MoveButtons Buttons { get; }
|
||||
public readonly bool CanMove;
|
||||
|
||||
public InputMoverComponentState(MoveButtons buttons, bool canMove)
|
||||
{
|
||||
Buttons = buttons;
|
||||
CanMove = canMove;
|
||||
}
|
||||
}
|
||||
|
||||
private sealed class ShuttleInputCmdHandler : InputCmdHandler
|
||||
{
|
||||
private SharedMoverController _controller;
|
||||
private ShuttleButtons _button;
|
||||
|
||||
public ShuttleInputCmdHandler(SharedMoverController controller, ShuttleButtons button)
|
||||
{
|
||||
_controller = controller;
|
||||
_button = button;
|
||||
}
|
||||
|
||||
public override bool HandleCmdMessage(ICommonSession? session, InputCmdMessage message)
|
||||
{
|
||||
if (message is not FullInputCmdMessage full || session?.AttachedEntity == null) return false;
|
||||
|
||||
_controller.HandleShuttleInput(session.AttachedEntity.Value, _button, full.SubTick, full.State == BoundKeyState.Down);
|
||||
return false;
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
[Flags]
|
||||
public enum MoveButtons : byte
|
||||
{
|
||||
None = 0,
|
||||
Up = 1,
|
||||
Down = 2,
|
||||
Left = 4,
|
||||
Right = 8,
|
||||
Walk = 16,
|
||||
}
|
||||
|
||||
[Flags]
|
||||
public enum ShuttleButtons : byte
|
||||
{
|
||||
None = 0,
|
||||
StrafeUp = 1 << 0,
|
||||
StrafeDown = 1 << 1,
|
||||
StrafeLeft = 1 << 2,
|
||||
StrafeRight = 1 << 3,
|
||||
RotateLeft = 1 << 4,
|
||||
RotateRight = 1 << 5,
|
||||
Brake = 1 << 6,
|
||||
}
|
||||
|
||||
39
Content.Shared/Movement/Systems/SharedMoverController.Mob.cs
Normal file
39
Content.Shared/Movement/Systems/SharedMoverController.Mob.cs
Normal file
@@ -0,0 +1,39 @@
|
||||
using Content.Shared.Movement.Components;
|
||||
using Robust.Shared.GameStates;
|
||||
using Robust.Shared.Serialization;
|
||||
|
||||
namespace Content.Shared.Movement.Systems;
|
||||
|
||||
public abstract partial class SharedMoverController
|
||||
{
|
||||
private void InitializeMob()
|
||||
{
|
||||
SubscribeLocalEvent<MobMoverComponent, ComponentGetState>(OnMobGetState);
|
||||
SubscribeLocalEvent<MobMoverComponent, ComponentHandleState>(OnMobHandleState);
|
||||
}
|
||||
|
||||
private void OnMobHandleState(EntityUid uid, MobMoverComponent component, ref ComponentHandleState args)
|
||||
{
|
||||
if (args.Current is not MobMoverComponentState state) return;
|
||||
component.GrabRangeVV = state.GrabRange;
|
||||
component.PushStrengthVV = state.PushStrength;
|
||||
}
|
||||
|
||||
private void OnMobGetState(EntityUid uid, MobMoverComponent component, ref ComponentGetState args)
|
||||
{
|
||||
args.State = new MobMoverComponentState(component.GrabRange, component.PushStrength);
|
||||
}
|
||||
|
||||
[Serializable, NetSerializable]
|
||||
private sealed class MobMoverComponentState : ComponentState
|
||||
{
|
||||
public float GrabRange;
|
||||
public float PushStrength;
|
||||
|
||||
public MobMoverComponentState(float grabRange, float pushStrength)
|
||||
{
|
||||
GrabRange = grabRange;
|
||||
PushStrength = pushStrength;
|
||||
}
|
||||
}
|
||||
}
|
||||
@@ -49,8 +49,8 @@ public abstract partial class SharedMoverController
|
||||
|
||||
if (otherBody.BodyType != BodyType.Dynamic || !otherFixture.Hard) return;
|
||||
|
||||
if (!EntityManager.TryGetComponent(ourFixture.Body.Owner, out IMobMoverComponent? mobMover) || worldNormal == Vector2.Zero) return;
|
||||
if (!EntityManager.TryGetComponent(ourFixture.Body.Owner, out MobMoverComponent? mobMover) || worldNormal == Vector2.Zero) return;
|
||||
|
||||
otherBody.ApplyLinearImpulse(-worldNormal * mobMover.PushStrength * frameTime);
|
||||
otherBody.ApplyLinearImpulse(-worldNormal * mobMover.PushStrengthVV * frameTime);
|
||||
}
|
||||
}
|
||||
|
||||
@@ -0,0 +1,43 @@
|
||||
using Content.Shared.Movement.Components;
|
||||
using Robust.Shared.GameStates;
|
||||
using Robust.Shared.Serialization;
|
||||
|
||||
namespace Content.Shared.Movement.Systems;
|
||||
|
||||
public abstract partial class SharedMoverController
|
||||
{
|
||||
private void InitializeRelay()
|
||||
{
|
||||
SubscribeLocalEvent<RelayInputMoverComponent, ComponentGetState>(OnRelayGetState);
|
||||
SubscribeLocalEvent<RelayInputMoverComponent, ComponentHandleState>(OnRelayHandleState);
|
||||
SubscribeLocalEvent<RelayInputMoverComponent, ComponentShutdown>(OnRelayShutdown);
|
||||
}
|
||||
|
||||
private void OnRelayShutdown(EntityUid uid, RelayInputMoverComponent component, ComponentShutdown args)
|
||||
{
|
||||
// If relay is removed then cancel all inputs.
|
||||
if (!TryComp<InputMoverComponent>(component.RelayEntity, out var inputMover)) return;
|
||||
SetMoveInput(inputMover, MoveButtons.None);
|
||||
}
|
||||
|
||||
private void OnRelayHandleState(EntityUid uid, RelayInputMoverComponent component, ref ComponentHandleState args)
|
||||
{
|
||||
if (args.Current is not RelayInputMoverComponentState state) return;
|
||||
|
||||
component.RelayEntity = state.Entity;
|
||||
}
|
||||
|
||||
private void OnRelayGetState(EntityUid uid, RelayInputMoverComponent component, ref ComponentGetState args)
|
||||
{
|
||||
args.State = new RelayInputMoverComponentState()
|
||||
{
|
||||
Entity = component.RelayEntity,
|
||||
};
|
||||
}
|
||||
|
||||
[Serializable, NetSerializable]
|
||||
private sealed class RelayInputMoverComponentState : ComponentState
|
||||
{
|
||||
public EntityUid? Entity;
|
||||
}
|
||||
}
|
||||
@@ -5,16 +5,19 @@ using Content.Shared.Friction;
|
||||
using Content.Shared.Inventory;
|
||||
using Content.Shared.Maps;
|
||||
using Content.Shared.MobState.Components;
|
||||
using Content.Shared.MobState.EntitySystems;
|
||||
using Content.Shared.Movement.Components;
|
||||
using Content.Shared.Movement.Events;
|
||||
using Content.Shared.Pulling.Components;
|
||||
using Content.Shared.Tag;
|
||||
using Robust.Shared.Audio;
|
||||
using Robust.Shared.Configuration;
|
||||
using Robust.Shared.Containers;
|
||||
using Robust.Shared.Map;
|
||||
using Robust.Shared.Physics;
|
||||
using Robust.Shared.Physics.Controllers;
|
||||
using Robust.Shared.Player;
|
||||
using Robust.Shared.Timing;
|
||||
using Robust.Shared.Utility;
|
||||
|
||||
namespace Content.Shared.Movement.Systems
|
||||
@@ -26,9 +29,12 @@ namespace Content.Shared.Movement.Systems
|
||||
public abstract partial class SharedMoverController : VirtualController
|
||||
{
|
||||
[Dependency] private readonly IConfigurationManager _configManager = default!;
|
||||
[Dependency] protected readonly IGameTiming Timing = default!;
|
||||
[Dependency] private readonly IMapManager _mapManager = default!;
|
||||
[Dependency] private readonly ITileDefinitionManager _tileDefinitionManager = default!;
|
||||
[Dependency] private readonly InventorySystem _inventory = default!;
|
||||
[Dependency] private readonly SharedContainerSystem _container = default!;
|
||||
[Dependency] private readonly SharedMobStateSystem _mobState = default!;
|
||||
[Dependency] private readonly SharedPhysicsSystem _physics = default!;
|
||||
[Dependency] private readonly TagSystem _tags = default!;
|
||||
|
||||
@@ -39,46 +45,11 @@ namespace Content.Shared.Movement.Systems
|
||||
private const float FootstepVolume = 3f;
|
||||
private const float FootstepWalkingAddedVolumeMultiplier = 0f;
|
||||
|
||||
/// <summary>
|
||||
/// <see cref="CCVars.MinimumFrictionSpeed"/>
|
||||
/// </summary>
|
||||
private float _minimumFrictionSpeed;
|
||||
|
||||
/// <summary>
|
||||
/// <see cref="CCVars.StopSpeed"/>
|
||||
/// </summary>
|
||||
private float _stopSpeed;
|
||||
|
||||
/// <summary>
|
||||
/// <see cref="CCVars.MobAcceleration"/>
|
||||
/// </summary>
|
||||
private float _mobAcceleration;
|
||||
|
||||
/// <summary>
|
||||
/// <see cref="CCVars.MobFriction"/>
|
||||
/// </summary>
|
||||
private float _frictionVelocity;
|
||||
|
||||
/// <summary>
|
||||
/// <see cref="CCVars.MobWeightlessAcceleration"/>
|
||||
/// </summary>
|
||||
private float _mobWeightlessAcceleration;
|
||||
|
||||
/// <summary>
|
||||
/// <see cref="CCVars.MobWeightlessFriction"/>
|
||||
/// </summary>
|
||||
private float _weightlessFrictionVelocity;
|
||||
|
||||
/// <summary>
|
||||
/// <see cref="CCVars.MobWeightlessFrictionNoInput"/>
|
||||
/// </summary>
|
||||
private float _weightlessFrictionVelocityNoInput;
|
||||
|
||||
/// <summary>
|
||||
/// <see cref="CCVars.MobWeightlessModifier"/>
|
||||
/// </summary>
|
||||
private float _mobWeightlessModifier;
|
||||
|
||||
private bool _relativeMovement;
|
||||
|
||||
/// <summary>
|
||||
@@ -90,29 +61,16 @@ namespace Content.Shared.Movement.Systems
|
||||
{
|
||||
base.Initialize();
|
||||
InitializeInput();
|
||||
InitializeMob();
|
||||
InitializePushing();
|
||||
// Hello
|
||||
InitializeRelay();
|
||||
_configManager.OnValueChanged(CCVars.RelativeMovement, SetRelativeMovement, true);
|
||||
_configManager.OnValueChanged(CCVars.MinimumFrictionSpeed, SetMinimumFrictionSpeed, true);
|
||||
_configManager.OnValueChanged(CCVars.MobFriction, SetFrictionVelocity, true);
|
||||
_configManager.OnValueChanged(CCVars.MobWeightlessFriction, SetWeightlessFrictionVelocity, true);
|
||||
_configManager.OnValueChanged(CCVars.StopSpeed, SetStopSpeed, true);
|
||||
_configManager.OnValueChanged(CCVars.MobAcceleration, SetMobAcceleration, true);
|
||||
_configManager.OnValueChanged(CCVars.MobWeightlessAcceleration, SetMobWeightlessAcceleration, true);
|
||||
_configManager.OnValueChanged(CCVars.MobWeightlessFrictionNoInput, SetWeightlessFrictionNoInput, true);
|
||||
_configManager.OnValueChanged(CCVars.MobWeightlessModifier, SetMobWeightlessModifier, true);
|
||||
UpdatesBefore.Add(typeof(SharedTileFrictionController));
|
||||
}
|
||||
|
||||
private void SetRelativeMovement(bool value) => _relativeMovement = value;
|
||||
private void SetMinimumFrictionSpeed(float value) => _minimumFrictionSpeed = value;
|
||||
private void SetStopSpeed(float value) => _stopSpeed = value;
|
||||
private void SetFrictionVelocity(float value) => _frictionVelocity = value;
|
||||
private void SetWeightlessFrictionVelocity(float value) => _weightlessFrictionVelocity = value;
|
||||
private void SetMobAcceleration(float value) => _mobAcceleration = value;
|
||||
private void SetMobWeightlessAcceleration(float value) => _mobWeightlessAcceleration = value;
|
||||
private void SetWeightlessFrictionNoInput(float value) => _weightlessFrictionVelocityNoInput = value;
|
||||
private void SetMobWeightlessModifier(float value) => _mobWeightlessModifier = value;
|
||||
|
||||
public override void Shutdown()
|
||||
{
|
||||
@@ -120,14 +78,7 @@ namespace Content.Shared.Movement.Systems
|
||||
ShutdownInput();
|
||||
ShutdownPushing();
|
||||
_configManager.UnsubValueChanged(CCVars.RelativeMovement, SetRelativeMovement);
|
||||
_configManager.UnsubValueChanged(CCVars.MinimumFrictionSpeed, SetMinimumFrictionSpeed);
|
||||
_configManager.UnsubValueChanged(CCVars.StopSpeed, SetStopSpeed);
|
||||
_configManager.UnsubValueChanged(CCVars.MobFriction, SetFrictionVelocity);
|
||||
_configManager.UnsubValueChanged(CCVars.MobWeightlessFriction, SetWeightlessFrictionVelocity);
|
||||
_configManager.UnsubValueChanged(CCVars.MobAcceleration, SetMobAcceleration);
|
||||
_configManager.UnsubValueChanged(CCVars.MobWeightlessAcceleration, SetMobWeightlessAcceleration);
|
||||
_configManager.UnsubValueChanged(CCVars.MobWeightlessFrictionNoInput, SetWeightlessFrictionNoInput);
|
||||
_configManager.UnsubValueChanged(CCVars.MobWeightlessModifier, SetMobWeightlessModifier);
|
||||
}
|
||||
|
||||
public override void UpdateAfterSolve(bool prediction, float frameTime)
|
||||
@@ -136,7 +87,7 @@ namespace Content.Shared.Movement.Systems
|
||||
UsedMobMovement.Clear();
|
||||
}
|
||||
|
||||
protected Angle GetParentGridAngle(TransformComponent xform, IMoverComponent mover)
|
||||
protected Angle GetParentGridAngle(TransformComponent xform, InputMoverComponent mover)
|
||||
{
|
||||
if (!_mapManager.TryGetGrid(xform.GridUid, out var grid))
|
||||
return mover.LastGridAngle;
|
||||
@@ -144,43 +95,12 @@ namespace Content.Shared.Movement.Systems
|
||||
return grid.WorldRotation;
|
||||
}
|
||||
|
||||
/// <summary>
|
||||
/// A generic kinematic mover for entities.
|
||||
/// </summary>
|
||||
protected void HandleKinematicMovement(IMoverComponent mover, PhysicsComponent physicsComponent)
|
||||
{
|
||||
var (walkDir, sprintDir) = mover.VelocityDir;
|
||||
|
||||
var transform = EntityManager.GetComponent<TransformComponent>(mover.Owner);
|
||||
var parentRotation = GetParentGridAngle(transform, mover);
|
||||
|
||||
// Regular movement.
|
||||
// Target velocity.
|
||||
var moveSpeedComponent = CompOrNull<MovementSpeedModifierComponent>(mover.Owner);
|
||||
var walkSpeed = moveSpeedComponent?.CurrentWalkSpeed ?? MovementSpeedModifierComponent.DefaultBaseWalkSpeed;
|
||||
var sprintSpeed = moveSpeedComponent?.CurrentSprintSpeed ?? MovementSpeedModifierComponent.DefaultBaseSprintSpeed;
|
||||
var total = walkDir * walkSpeed + sprintDir * sprintSpeed;
|
||||
|
||||
var worldTotal = _relativeMovement ? parentRotation.RotateVec(total) : total;
|
||||
|
||||
if (transform.GridUid != null)
|
||||
mover.LastGridAngle = parentRotation;
|
||||
|
||||
if (worldTotal != Vector2.Zero)
|
||||
transform.LocalRotation = transform.GridUid != null
|
||||
? total.ToWorldAngle()
|
||||
: worldTotal.ToWorldAngle();
|
||||
|
||||
_physics.SetLinearVelocity(physicsComponent, worldTotal);
|
||||
}
|
||||
|
||||
/// <summary>
|
||||
/// Movement while considering actionblockers, weightlessness, etc.
|
||||
/// </summary>
|
||||
protected void HandleMobMovement(
|
||||
IMoverComponent mover,
|
||||
InputMoverComponent mover,
|
||||
PhysicsComponent physicsComponent,
|
||||
IMobMoverComponent mobMover,
|
||||
TransformComponent xform,
|
||||
float frameTime)
|
||||
{
|
||||
@@ -194,7 +114,7 @@ namespace Content.Shared.Movement.Systems
|
||||
|
||||
UsedMobMovement[mover.Owner] = true;
|
||||
var weightless = mover.Owner.IsWeightless(physicsComponent, mapManager: _mapManager, entityManager: EntityManager);
|
||||
var (walkDir, sprintDir) = mover.VelocityDir;
|
||||
var (walkDir, sprintDir) = GetVelocityInput(mover);
|
||||
var touching = false;
|
||||
|
||||
// Handle wall-pushes.
|
||||
@@ -208,7 +128,10 @@ namespace Content.Shared.Movement.Systems
|
||||
var ev = new CanWeightlessMoveEvent();
|
||||
RaiseLocalEvent(xform.Owner, ref ev);
|
||||
// No gravity: is our entity touching anything?
|
||||
touching = ev.CanMove || IsAroundCollider(_physics, xform, mobMover, physicsComponent);
|
||||
touching = ev.CanMove;
|
||||
|
||||
if (!touching && TryComp<MobMoverComponent>(xform.Owner, out var mobMover))
|
||||
touching |= IsAroundCollider(_physics, xform, mobMover, physicsComponent);
|
||||
}
|
||||
|
||||
if (!touching)
|
||||
@@ -222,8 +145,10 @@ namespace Content.Shared.Movement.Systems
|
||||
// Target velocity.
|
||||
// This is relative to the map / grid we're on.
|
||||
var moveSpeedComponent = CompOrNull<MovementSpeedModifierComponent>(mover.Owner);
|
||||
|
||||
var walkSpeed = moveSpeedComponent?.CurrentWalkSpeed ?? MovementSpeedModifierComponent.DefaultBaseWalkSpeed;
|
||||
var sprintSpeed = moveSpeedComponent?.CurrentSprintSpeed ?? MovementSpeedModifierComponent.DefaultBaseSprintSpeed;
|
||||
|
||||
var total = walkDir * walkSpeed + sprintDir * sprintSpeed;
|
||||
|
||||
var parentRotation = GetParentGridAngle(xform, mover);
|
||||
@@ -239,37 +164,30 @@ namespace Content.Shared.Movement.Systems
|
||||
if (weightless)
|
||||
{
|
||||
if (worldTotal != Vector2.Zero && touching)
|
||||
friction = _weightlessFrictionVelocity;
|
||||
friction = moveSpeedComponent?.WeightlessFriction ?? MovementSpeedModifierComponent.DefaultWeightlessFriction;
|
||||
else
|
||||
friction = _weightlessFrictionVelocityNoInput;
|
||||
friction = moveSpeedComponent?.WeightlessFrictionNoInput ?? MovementSpeedModifierComponent.DefaultWeightlessFrictionNoInput;
|
||||
|
||||
weightlessModifier = _mobWeightlessModifier;
|
||||
accel = _mobWeightlessAcceleration;
|
||||
weightlessModifier = moveSpeedComponent?.WeightlessModifier ?? MovementSpeedModifierComponent.DefaultWeightlessModifier;
|
||||
accel = moveSpeedComponent?.WeightlessAcceleration ?? MovementSpeedModifierComponent.DefaultWeightlessAcceleration;
|
||||
}
|
||||
else
|
||||
{
|
||||
friction = _frictionVelocity;
|
||||
if (worldTotal != Vector2.Zero || moveSpeedComponent?.FrictionNoInput == null)
|
||||
{
|
||||
friction = moveSpeedComponent?.Friction ?? MovementSpeedModifierComponent.DefaultFriction;
|
||||
}
|
||||
else
|
||||
{
|
||||
friction = moveSpeedComponent.FrictionNoInput ?? MovementSpeedModifierComponent.DefaultFrictionNoInput;
|
||||
}
|
||||
|
||||
weightlessModifier = 1f;
|
||||
accel = _mobAcceleration;
|
||||
accel = moveSpeedComponent?.Acceleration ?? MovementSpeedModifierComponent.DefaultAcceleration;
|
||||
}
|
||||
|
||||
var profile = new MobMovementProfileEvent(
|
||||
touching,
|
||||
weightless,
|
||||
friction,
|
||||
weightlessModifier,
|
||||
accel);
|
||||
|
||||
RaiseLocalEvent(xform.Owner, ref profile);
|
||||
|
||||
if (profile.Override)
|
||||
{
|
||||
friction = profile.Friction;
|
||||
weightlessModifier = profile.WeightlessModifier;
|
||||
accel = profile.Acceleration;
|
||||
}
|
||||
|
||||
Friction(frameTime, friction, ref velocity);
|
||||
var minimumFrictionSpeed = moveSpeedComponent?.MinimumFrictionSpeed ?? MovementSpeedModifierComponent.DefaultMinimumFrictionSpeed;
|
||||
Friction(minimumFrictionSpeed, frameTime, friction, ref velocity);
|
||||
|
||||
if (xform.GridUid != EntityUid.Invalid)
|
||||
mover.LastGridAngle = parentRotation;
|
||||
@@ -278,12 +196,24 @@ namespace Content.Shared.Movement.Systems
|
||||
{
|
||||
// This should have its event run during island solver soooo
|
||||
xform.DeferUpdates = true;
|
||||
xform.LocalRotation = xform.GridUid != null
|
||||
TransformComponent rotateXform;
|
||||
|
||||
// If we're in a container then relay rotation to the parent instead
|
||||
if (_container.TryGetContainingContainer(xform.Owner, out var container))
|
||||
{
|
||||
rotateXform = Transform(container.Owner);
|
||||
}
|
||||
else
|
||||
{
|
||||
rotateXform = xform;
|
||||
}
|
||||
|
||||
rotateXform.LocalRotation = xform.GridUid != null
|
||||
? total.ToWorldAngle()
|
||||
: worldTotal.ToWorldAngle();
|
||||
xform.DeferUpdates = false;
|
||||
rotateXform.DeferUpdates = false;
|
||||
|
||||
if (!weightless && TryGetSound(mover, mobMover, xform, out var variation, out var sound))
|
||||
if (!weightless && TryComp<MobMoverComponent>(mover.Owner, out var mobMover) && TryGetSound(mover, mobMover, xform, out var variation, out var sound))
|
||||
{
|
||||
var soundModifier = mover.Sprinting ? 1.0f : FootstepWalkingAddedVolumeMultiplier;
|
||||
SoundSystem.Play(sound,
|
||||
@@ -300,11 +230,11 @@ namespace Content.Shared.Movement.Systems
|
||||
_physics.SetLinearVelocity(physicsComponent, velocity);
|
||||
}
|
||||
|
||||
private void Friction(float frameTime, float friction, ref Vector2 velocity)
|
||||
private void Friction(float minimumFrictionSpeed, float frameTime, float friction, ref Vector2 velocity)
|
||||
{
|
||||
var speed = velocity.Length;
|
||||
|
||||
if (speed < _minimumFrictionSpeed) return;
|
||||
if (speed < minimumFrictionSpeed) return;
|
||||
|
||||
var drop = 0f;
|
||||
|
||||
@@ -340,11 +270,11 @@ namespace Content.Shared.Movement.Systems
|
||||
return UsedMobMovement.TryGetValue(uid, out var used) && used;
|
||||
}
|
||||
|
||||
protected bool UseMobMovement(IMoverComponent mover, PhysicsComponent body)
|
||||
protected bool UseMobMovement(InputMoverComponent mover, PhysicsComponent body)
|
||||
{
|
||||
return mover.CanMove &&
|
||||
body.BodyStatus == BodyStatus.OnGround &&
|
||||
HasComp<MobStateComponent>(body.Owner) &&
|
||||
HasComp<InputMoverComponent>(body.Owner) &&
|
||||
// If we're being pulled then don't mess with our velocity.
|
||||
(!TryComp(body.Owner, out SharedPullableComponent? pullable) || !pullable.BeingPulled);
|
||||
}
|
||||
@@ -352,9 +282,9 @@ namespace Content.Shared.Movement.Systems
|
||||
/// <summary>
|
||||
/// Used for weightlessness to determine if we are near a wall.
|
||||
/// </summary>
|
||||
private bool IsAroundCollider(SharedPhysicsSystem broadPhaseSystem, TransformComponent transform, IMobMoverComponent mover, IPhysBody collider)
|
||||
private bool IsAroundCollider(SharedPhysicsSystem broadPhaseSystem, TransformComponent transform, MobMoverComponent mover, IPhysBody collider)
|
||||
{
|
||||
var enlargedAABB = collider.GetWorldAABB().Enlarged(mover.GrabRange);
|
||||
var enlargedAABB = collider.GetWorldAABB().Enlarged(mover.GrabRangeVV);
|
||||
|
||||
foreach (var otherCollider in broadPhaseSystem.GetCollidingEntities(transform.MapID, enlargedAABB))
|
||||
{
|
||||
@@ -381,7 +311,7 @@ namespace Content.Shared.Movement.Systems
|
||||
|
||||
protected abstract bool CanSound();
|
||||
|
||||
private bool TryGetSound(IMoverComponent mover, IMobMoverComponent mobMover, TransformComponent xform, out float variation, [NotNullWhen(true)] out string? sound)
|
||||
private bool TryGetSound(InputMoverComponent mover, MobMoverComponent mobMover, TransformComponent xform, out float variation, [NotNullWhen(true)] out string? sound)
|
||||
{
|
||||
sound = null;
|
||||
variation = 0f;
|
||||
|
||||
@@ -1,6 +1,6 @@
|
||||
using Content.Shared.ActionBlocker;
|
||||
using Content.Shared.Pulling.Components;
|
||||
using Content.Shared.MobState.Components;
|
||||
using Content.Shared.MobState.EntitySystems;
|
||||
using Content.Shared.Movement.Events;
|
||||
|
||||
namespace Content.Shared.Pulling.Systems
|
||||
@@ -8,19 +8,20 @@ namespace Content.Shared.Pulling.Systems
|
||||
public sealed class SharedPullableSystem : EntitySystem
|
||||
{
|
||||
[Dependency] private readonly ActionBlockerSystem _blocker = default!;
|
||||
[Dependency] private readonly SharedMobStateSystem _mobState = default!;
|
||||
[Dependency] private readonly SharedPullingSystem _pullSystem = default!;
|
||||
|
||||
public override void Initialize()
|
||||
{
|
||||
base.Initialize();
|
||||
SubscribeLocalEvent<SharedPullableComponent, RelayMoveInputEvent>(OnRelayMoveInput);
|
||||
SubscribeLocalEvent<SharedPullableComponent, MoveInputEvent>(OnRelayMoveInput);
|
||||
}
|
||||
|
||||
private void OnRelayMoveInput(EntityUid uid, SharedPullableComponent component, RelayMoveInputEvent args)
|
||||
private void OnRelayMoveInput(EntityUid uid, SharedPullableComponent component, ref MoveInputEvent args)
|
||||
{
|
||||
var entity = args.Session.AttachedEntity;
|
||||
if (entity == null || !_blocker.CanMove(entity.Value)) return;
|
||||
if (TryComp<MobStateComponent>(component.Owner, out var mobState) && mobState.IsIncapacitated()) return;
|
||||
var entity = args.Entity;
|
||||
if (_mobState.IsIncapacitated(entity) || !_blocker.CanMove(entity)) return;
|
||||
|
||||
_pullSystem.TryStopPull(component);
|
||||
}
|
||||
}
|
||||
|
||||
@@ -17,13 +17,12 @@ public sealed class ShuttleConsoleBoundInterfaceState : RadarConsoleBoundInterfa
|
||||
/// When the next FTL state change happens.
|
||||
/// </summary>
|
||||
public readonly TimeSpan FTLTime;
|
||||
public readonly ShuttleMode Mode;
|
||||
|
||||
public List<(EntityUid Entity, string Destination, bool Enabled)> Destinations;
|
||||
|
||||
public ShuttleConsoleBoundInterfaceState(
|
||||
FTLState ftlState,
|
||||
TimeSpan ftlTime,
|
||||
ShuttleMode mode,
|
||||
List<(EntityUid Entity, string Destination, bool Enabled)> destinations,
|
||||
float maxRange,
|
||||
EntityCoordinates? coordinates,
|
||||
@@ -33,6 +32,5 @@ public sealed class ShuttleConsoleBoundInterfaceState : RadarConsoleBoundInterfa
|
||||
FTLState = ftlState;
|
||||
FTLTime = ftlTime;
|
||||
Destinations = destinations;
|
||||
Mode = mode;
|
||||
}
|
||||
}
|
||||
|
||||
@@ -1,5 +1,6 @@
|
||||
using Robust.Shared.GameStates;
|
||||
using Robust.Shared.Map;
|
||||
using Robust.Shared.Timing;
|
||||
|
||||
namespace Content.Shared.Shuttles.Components
|
||||
{
|
||||
@@ -18,5 +19,15 @@ namespace Content.Shared.Shuttles.Components
|
||||
[ViewVariables] public EntityCoordinates? Position { get; set; }
|
||||
|
||||
public const float BreakDistance = 0.25f;
|
||||
|
||||
public Vector2 CurTickStrafeMovement = Vector2.Zero;
|
||||
public float CurTickRotationMovement;
|
||||
public float CurTickBraking;
|
||||
|
||||
public GameTick LastInputTick = GameTick.Zero;
|
||||
public ushort LastInputSubTick = 0;
|
||||
|
||||
[ViewVariables]
|
||||
public ShuttleButtons HeldButtons = ShuttleButtons.None;
|
||||
}
|
||||
}
|
||||
|
||||
@@ -1,8 +0,0 @@
|
||||
namespace Content.Shared.Shuttles.Components
|
||||
{
|
||||
public enum ShuttleMode : byte
|
||||
{
|
||||
Strafing,
|
||||
Cruise,
|
||||
}
|
||||
}
|
||||
@@ -1,13 +0,0 @@
|
||||
using Content.Shared.Shuttles.Components;
|
||||
using Robust.Shared.Serialization;
|
||||
|
||||
namespace Content.Shared.Shuttles.Events;
|
||||
|
||||
/// <summary>
|
||||
/// Raised by the client to request the server change a particular shuttle's mode.
|
||||
/// </summary>
|
||||
[Serializable, NetSerializable]
|
||||
public sealed class ShuttleModeRequestMessage : BoundUserInterfaceMessage
|
||||
{
|
||||
public ShuttleMode Mode;
|
||||
}
|
||||
@@ -33,7 +33,7 @@ public sealed class ThrowingSystem : EntitySystem
|
||||
Vector2 direction,
|
||||
float strength = 1.0f,
|
||||
EntityUid? user = null,
|
||||
float pushbackRatio = 10.0f,
|
||||
float pushbackRatio = 5.0f,
|
||||
PhysicsComponent? physics = null,
|
||||
TransformComponent? transform = null,
|
||||
EntityQuery<PhysicsComponent>? physicsQuery = null,
|
||||
|
||||
@@ -1,16 +1,17 @@
|
||||
using Robust.Shared.GameStates;
|
||||
|
||||
namespace Content.Shared.Vehicle.Components
|
||||
{
|
||||
/// <summary>
|
||||
/// Added to objects inside a vehicle to stop people besides the rider from
|
||||
/// removing them.
|
||||
/// </summary>
|
||||
[RegisterComponent]
|
||||
[RegisterComponent, NetworkedComponent]
|
||||
public sealed class InVehicleComponent : Component
|
||||
{
|
||||
/// <summary>
|
||||
/// The vehicle this rider is currently riding.
|
||||
/// </summary>
|
||||
[ViewVariables]
|
||||
public VehicleComponent Vehicle = default!;
|
||||
[ViewVariables] public VehicleComponent? Vehicle;
|
||||
}
|
||||
}
|
||||
|
||||
@@ -1,15 +1,17 @@
|
||||
using Robust.Shared.GameStates;
|
||||
|
||||
namespace Content.Shared.Vehicle.Components
|
||||
{
|
||||
/// <summary>
|
||||
/// Added to people when they are riding in a vehicle
|
||||
/// used mostly to keep track of them for entityquery.
|
||||
/// </summary>
|
||||
[RegisterComponent]
|
||||
[RegisterComponent, NetworkedComponent]
|
||||
public sealed class RiderComponent : Component
|
||||
{
|
||||
/// <summary>
|
||||
/// The vehicle this rider is currently riding.
|
||||
/// </summary>
|
||||
[ViewVariables] public VehicleComponent? Vehicle;
|
||||
[ViewVariables] public EntityUid? Vehicle;
|
||||
}
|
||||
}
|
||||
|
||||
@@ -1,6 +1,5 @@
|
||||
using Content.Shared.Actions.ActionTypes;
|
||||
using Content.Shared.Sound;
|
||||
using Content.Shared.Containers.ItemSlots;
|
||||
using Robust.Shared.Audio;
|
||||
using Robust.Shared.Utility;
|
||||
|
||||
@@ -17,7 +16,7 @@ namespace Content.Shared.Vehicle.Components
|
||||
{
|
||||
/// <summary>
|
||||
/// Whether someone is currently riding the vehicle
|
||||
/// </summary
|
||||
/// </summary>
|
||||
public bool HasRider = false;
|
||||
|
||||
/// <summary>
|
||||
@@ -27,7 +26,47 @@ namespace Content.Shared.Vehicle.Components
|
||||
public EntityUid? Rider;
|
||||
|
||||
/// <summary>
|
||||
/// Whether the vehicle should treat north as it's unique direction in its visualizer
|
||||
/// The base offset for the vehicle (when facing east)
|
||||
/// </summary>
|
||||
public Vector2 BaseBuckleOffset = Vector2.Zero;
|
||||
|
||||
/// <summary>
|
||||
/// The sound that the horn makes
|
||||
/// </summary>
|
||||
[DataField("hornSound")] public SoundSpecifier? HornSound =
|
||||
new SoundPathSpecifier("/Audio/Effects/Vehicle/carhorn.ogg")
|
||||
{
|
||||
Params =
|
||||
{
|
||||
Volume = -3f,
|
||||
}
|
||||
};
|
||||
|
||||
public IPlayingAudioStream? HonkPlayingStream;
|
||||
|
||||
/// Use ambient sound component for the idle sound.
|
||||
|
||||
/// <summary>
|
||||
/// The action for the horn (if any)
|
||||
/// </summary>
|
||||
[DataField("hornAction")]
|
||||
public InstantAction HornAction = new()
|
||||
{
|
||||
UseDelay = TimeSpan.FromSeconds(3.4),
|
||||
Icon = new SpriteSpecifier.Texture(new ResourcePath("Objects/Fun/bikehorn.rsi/icon.png")),
|
||||
Name = "action-name-honk",
|
||||
Description = "action-desc-honk",
|
||||
Event = new HonkActionEvent(),
|
||||
};
|
||||
|
||||
/// <summary>
|
||||
/// Whether the vehicle has a key currently inside it or not.
|
||||
/// </summary>
|
||||
public bool HasKey = false;
|
||||
|
||||
// TODO: Fix this
|
||||
/// <summary>
|
||||
/// Whether the vehicle should treat north as its unique direction in its visualizer
|
||||
/// </summary>
|
||||
[DataField("northOnly")]
|
||||
public bool NorthOnly = false;
|
||||
@@ -43,55 +82,5 @@ namespace Content.Shared.Vehicle.Components
|
||||
/// </summary>
|
||||
[DataField("southOverride")]
|
||||
public float SouthOverride = 0f;
|
||||
|
||||
/// <summary>
|
||||
/// The base offset for the vehicle (when facing east)
|
||||
/// </summary>
|
||||
public Vector2 BaseBuckleOffset = Vector2.Zero;
|
||||
|
||||
/// <summary>
|
||||
/// The sound that the horn makes
|
||||
/// </summary>
|
||||
[DataField("hornSound")]
|
||||
public SoundSpecifier? HornSound = new SoundPathSpecifier("/Audio/Effects/Vehicle/carhorn.ogg");
|
||||
|
||||
/// <summary>
|
||||
/// Whether the horn is a siren or not.
|
||||
/// </summary>
|
||||
[DataField("hornIsSiren")]
|
||||
public bool HornIsLooping = false;
|
||||
|
||||
/// <summary>
|
||||
/// If this vehicle has a siren currently playing.
|
||||
/// </summary>
|
||||
public bool LoopingHornIsPlaying = false;
|
||||
|
||||
public IPlayingAudioStream? SirenPlayingStream;
|
||||
|
||||
/// Use ambient sound component for the idle sound.
|
||||
|
||||
/// <summary>
|
||||
/// The action for the horn (if any)
|
||||
/// </summary>
|
||||
[DataField("hornAction")]
|
||||
public InstantAction HornAction = new()
|
||||
{
|
||||
UseDelay = TimeSpan.FromSeconds(3.4),
|
||||
Icon = new SpriteSpecifier.Texture(new ResourcePath("Objects/Fun/bikehorn.rsi/icon.png")),
|
||||
Name = "action-name-honk",
|
||||
Description = "action-desc-honk",
|
||||
Event = new HonkActionEvent(),
|
||||
};
|
||||
|
||||
/// <summary>
|
||||
/// The prototype ID of the key that was inserted so it can be
|
||||
/// spawned when the key is removed.
|
||||
/// </summary>
|
||||
public ItemSlot KeySlot = new();
|
||||
|
||||
/// <summary>
|
||||
/// Whether the vehicle has a key currently inside it or not.
|
||||
/// </summary>
|
||||
public bool HasKey = false;
|
||||
}
|
||||
}
|
||||
|
||||
20
Content.Shared/Vehicle/SharedVehicleSystem.Rider.cs
Normal file
20
Content.Shared/Vehicle/SharedVehicleSystem.Rider.cs
Normal file
@@ -0,0 +1,20 @@
|
||||
using Content.Shared.Physics.Pull;
|
||||
using Content.Shared.Vehicle.Components;
|
||||
using Robust.Shared.Serialization;
|
||||
|
||||
namespace Content.Shared.Vehicle;
|
||||
|
||||
public abstract partial class SharedVehicleSystem
|
||||
{
|
||||
[Serializable, NetSerializable]
|
||||
protected sealed class RiderComponentState : ComponentState
|
||||
{
|
||||
public EntityUid? Entity;
|
||||
}
|
||||
|
||||
private void OnRiderPull(EntityUid uid, RiderComponent component, PullAttemptEvent args)
|
||||
{
|
||||
if (component.Vehicle != null)
|
||||
args.Cancelled = true;
|
||||
}
|
||||
}
|
||||
@@ -1,73 +1,174 @@
|
||||
using Content.Shared.Vehicle.Components;
|
||||
using Content.Shared.Actions;
|
||||
using Content.Shared.Buckle.Components;
|
||||
using Content.Shared.Item;
|
||||
using Content.Shared.Movement.Components;
|
||||
using Content.Shared.Movement.Systems;
|
||||
using Content.Shared.Physics.Pull;
|
||||
using Robust.Shared.Serialization;
|
||||
using Robust.Shared.Timing;
|
||||
|
||||
namespace Content.Shared.Vehicle;
|
||||
|
||||
/// <summary>
|
||||
/// Stores the VehicleVisuals and shared event
|
||||
/// Nothing for a system but these need to be put somewhere in
|
||||
/// Content.Shared
|
||||
/// </summary>
|
||||
namespace Content.Shared.Vehicle
|
||||
public abstract partial class SharedVehicleSystem : EntitySystem
|
||||
{
|
||||
public sealed class SharedVehicleSystem : EntitySystem
|
||||
[Dependency] private readonly MovementSpeedModifierSystem _modifier = default!;
|
||||
[Dependency] private readonly SharedTransformSystem _transform = default!;
|
||||
|
||||
public override void Initialize()
|
||||
{
|
||||
public override void Initialize()
|
||||
{
|
||||
base.Initialize();
|
||||
SubscribeLocalEvent<InVehicleComponent, GettingPickedUpAttemptEvent>(OnPickupAttempt);
|
||||
}
|
||||
base.Initialize();
|
||||
SubscribeLocalEvent<InVehicleComponent, GettingPickedUpAttemptEvent>(OnPickupAttempt);
|
||||
SubscribeLocalEvent<RiderComponent, PullAttemptEvent>(OnRiderPull);
|
||||
SubscribeLocalEvent<VehicleComponent, RefreshMovementSpeedModifiersEvent>(OnVehicleModifier);
|
||||
SubscribeLocalEvent<VehicleComponent, ComponentStartup>(OnVehicleStartup);
|
||||
SubscribeLocalEvent<VehicleComponent, RotateEvent>(OnVehicleRotate);
|
||||
}
|
||||
|
||||
private void OnPickupAttempt(EntityUid uid, InVehicleComponent component, GettingPickedUpAttemptEvent args)
|
||||
private void OnVehicleModifier(EntityUid uid, VehicleComponent component, RefreshMovementSpeedModifiersEvent args)
|
||||
{
|
||||
if (!component.HasKey)
|
||||
{
|
||||
if (component.Vehicle == null || !component.Vehicle.HasRider)
|
||||
return;
|
||||
|
||||
if (component.Vehicle.Rider != args.User)
|
||||
args.Cancel();
|
||||
args.ModifySpeed(0f, 0f);
|
||||
}
|
||||
}
|
||||
|
||||
|
||||
/// <summary>
|
||||
/// Stores the vehicle's draw depth mostly
|
||||
/// </summary>
|
||||
[Serializable, NetSerializable]
|
||||
public enum VehicleVisuals : byte
|
||||
private void OnPickupAttempt(EntityUid uid, InVehicleComponent component, GettingPickedUpAttemptEvent args)
|
||||
{
|
||||
/// <summary>
|
||||
/// What layer the vehicle should draw on (assumed integer)
|
||||
/// </summary>
|
||||
DrawDepth,
|
||||
/// <summary>
|
||||
/// Whether the wheels should be turning
|
||||
/// </summary>
|
||||
AutoAnimate
|
||||
if (component.Vehicle == null || component.Vehicle.Rider != null && component.Vehicle.Rider != args.User)
|
||||
args.Cancel();
|
||||
}
|
||||
/// <summary>
|
||||
/// Raised when someone honks a vehicle horn
|
||||
/// </summary>
|
||||
public sealed class HonkActionEvent : InstantActionEvent { }
|
||||
|
||||
/// <summary>
|
||||
/// Raised on the rider when someone is buckled to a vehicle.
|
||||
/// </summary>
|
||||
[Serializable, NetSerializable]
|
||||
public sealed class BuckledToVehicleEvent : EntityEventArgs
|
||||
// TODO: Shitcode, needs to use sprites instead of actual offsets.
|
||||
private void OnVehicleRotate(EntityUid uid, VehicleComponent component, ref RotateEvent args)
|
||||
{
|
||||
public EntityUid Vehicle;
|
||||
|
||||
public EntityUid Rider;
|
||||
|
||||
/// <summary>
|
||||
/// Whether they were buckled or unbuckled
|
||||
/// </summary>
|
||||
public bool Buckling;
|
||||
public BuckledToVehicleEvent(EntityUid vehicle, EntityUid rider, bool buckling)
|
||||
// This first check is just for safety
|
||||
if (!HasComp<InputMoverComponent>(uid))
|
||||
{
|
||||
Vehicle = vehicle;
|
||||
Rider = rider;
|
||||
Buckling = buckling;
|
||||
UpdateAutoAnimate(uid, false);
|
||||
return;
|
||||
}
|
||||
|
||||
UpdateBuckleOffset(args.Component, component);
|
||||
UpdateDrawDepth(uid, GetDrawDepth(args.Component, component.NorthOnly));
|
||||
}
|
||||
|
||||
private void OnVehicleStartup(EntityUid uid, VehicleComponent component, ComponentStartup args)
|
||||
{
|
||||
UpdateDrawDepth(uid, 2);
|
||||
|
||||
// This code should be purged anyway but with that being said this doesn't handle components being changed.
|
||||
if (TryComp<SharedStrapComponent>(uid, out var strap))
|
||||
{
|
||||
component.BaseBuckleOffset = strap.BuckleOffset;
|
||||
strap.BuckleOffsetUnclamped = Vector2.Zero;
|
||||
}
|
||||
|
||||
_modifier.RefreshMovementSpeedModifiers(uid);
|
||||
}
|
||||
|
||||
/// <summary>
|
||||
/// Depending on which direction the vehicle is facing,
|
||||
/// change its draw depth. Vehicles can choose between special drawdetph
|
||||
/// when facing north or south. East and west are easy.
|
||||
/// </summary>
|
||||
protected int GetDrawDepth(TransformComponent xform, bool northOnly)
|
||||
{
|
||||
// TODO: I can't even
|
||||
if (northOnly)
|
||||
{
|
||||
return xform.LocalRotation.Degrees switch
|
||||
{
|
||||
< 135f => (int) DrawDepth.DrawDepth.Doors,
|
||||
<= 225f => (int) DrawDepth.DrawDepth.WallMountedItems,
|
||||
_ => 5
|
||||
};
|
||||
}
|
||||
return xform.LocalRotation.Degrees switch
|
||||
{
|
||||
< 45f => (int) DrawDepth.DrawDepth.Doors,
|
||||
<= 315f => (int) DrawDepth.DrawDepth.WallMountedItems,
|
||||
_ => (int) DrawDepth.DrawDepth.Doors,
|
||||
};
|
||||
}
|
||||
|
||||
/// <summary>
|
||||
/// Change the buckle offset based on what direction the vehicle is facing and
|
||||
/// teleport any buckled entities to it. This is the most crucial part of making
|
||||
/// buckled vehicles work.
|
||||
/// </summary>
|
||||
protected void UpdateBuckleOffset(TransformComponent xform, VehicleComponent component)
|
||||
{
|
||||
if (!TryComp<SharedStrapComponent>(component.Owner, out var strap))
|
||||
return;
|
||||
|
||||
// TODO: Strap should handle this but buckle E/C moment.
|
||||
var oldOffset = strap.BuckleOffsetUnclamped;
|
||||
|
||||
strap.BuckleOffsetUnclamped = xform.LocalRotation.Degrees switch
|
||||
{
|
||||
< 45f => (0, component.SouthOverride),
|
||||
<= 135f => component.BaseBuckleOffset,
|
||||
< 225f => (0, component.NorthOverride),
|
||||
<= 315f => (component.BaseBuckleOffset.X * -1, component.BaseBuckleOffset.Y),
|
||||
_ => (0, component.SouthOverride)
|
||||
};
|
||||
|
||||
if (!oldOffset.Equals(strap.BuckleOffsetUnclamped))
|
||||
Dirty(strap);
|
||||
|
||||
foreach (var buckledEntity in strap.BuckledEntities)
|
||||
{
|
||||
var buckleXform = Transform(buckledEntity);
|
||||
_transform.SetLocalPositionNoLerp(buckleXform, strap.BuckleOffset);
|
||||
}
|
||||
}
|
||||
|
||||
/// <summary>
|
||||
/// Set the draw depth for the sprite.
|
||||
/// </summary>
|
||||
protected void UpdateDrawDepth(EntityUid uid, int drawDepth)
|
||||
{
|
||||
if (!TryComp<AppearanceComponent>(uid, out var appearance))
|
||||
return;
|
||||
|
||||
appearance.SetData(VehicleVisuals.DrawDepth, drawDepth);
|
||||
}
|
||||
|
||||
/// <summary>
|
||||
/// Set whether the vehicle's base layer is animating or not.
|
||||
/// </summary>
|
||||
protected void UpdateAutoAnimate(EntityUid uid, bool autoAnimate)
|
||||
{
|
||||
if (!TryComp<AppearanceComponent>(uid, out var appearance))
|
||||
return;
|
||||
|
||||
appearance.SetData(VehicleVisuals.AutoAnimate, autoAnimate);
|
||||
}
|
||||
}
|
||||
|
||||
/// <summary>
|
||||
/// Stores the vehicle's draw depth mostly
|
||||
/// </summary>
|
||||
[Serializable, NetSerializable]
|
||||
public enum VehicleVisuals : byte
|
||||
{
|
||||
/// <summary>
|
||||
/// What layer the vehicle should draw on (assumed integer)
|
||||
/// </summary>
|
||||
DrawDepth,
|
||||
/// <summary>
|
||||
/// Whether the wheels should be turning
|
||||
/// </summary>
|
||||
AutoAnimate
|
||||
}
|
||||
/// <summary>
|
||||
/// Raised when someone honks a vehicle horn
|
||||
/// </summary>
|
||||
public sealed class HonkActionEvent : InstantActionEvent { }
|
||||
|
||||
|
||||
@@ -1,4 +1,2 @@
|
||||
action-name-honk = Honk
|
||||
action-desc-honk = Honk!
|
||||
action-name-siren = Toggle Siren
|
||||
action-desc-siren = Wee-woo.
|
||||
|
||||
@@ -70,6 +70,7 @@ ui-options-header-interaction-adv = Advanced Interaction
|
||||
ui-options-header-ui = User Interface
|
||||
ui-options-header-misc = Miscellaneous
|
||||
ui-options-header-hotbar = Hotbar
|
||||
ui-options-header-shuttle = Shuttle
|
||||
ui-options-header-map-editor = Map Editor
|
||||
ui-options-header-dev = Development
|
||||
ui-options-header-general = General
|
||||
@@ -157,6 +158,14 @@ ui-options-function-loadout7 = Hotbar Loadout 7
|
||||
ui-options-function-loadout8 = Hotbar Loadout 8
|
||||
ui-options-function-loadout9 = Hotbar Loadout 9
|
||||
|
||||
ui-options-function-shuttle-strafe-up = Strafe up
|
||||
ui-options-function-shuttle-strafe-right = Strafe right
|
||||
ui-options-function-shuttle-strafe-left = Strafe left
|
||||
ui-options-function-shuttle-strafe-down = Strafe down
|
||||
ui-options-function-shuttle-rotate-left = Rotate left
|
||||
ui-options-function-shuttle-rotate-right = Rotate right
|
||||
ui-options-function-shuttle-brake = Brake
|
||||
|
||||
## Network menu
|
||||
|
||||
ui-options-net-interp-ratio = Network Smoothing
|
||||
|
||||
@@ -30,7 +30,10 @@
|
||||
compatibility: Biological
|
||||
- type: Input
|
||||
context: "ghost"
|
||||
- type: DummyInputMover
|
||||
- type: InputMover
|
||||
- type: MovementSpeedModifier
|
||||
baseWalkSpeed: 0
|
||||
baseSprintSpeed: 0
|
||||
- type: GhostOnMove
|
||||
- type: Brain
|
||||
|
||||
|
||||
@@ -58,7 +58,10 @@
|
||||
# deadThreshold: 120
|
||||
- type: Input
|
||||
context: "ghost"
|
||||
- type: DummyInputMover
|
||||
- type: MovementSpeedModifier
|
||||
baseWalkSpeed: 0
|
||||
baseSprintSpeed: 0
|
||||
- type: InputMover
|
||||
- type: GhostOnMove
|
||||
|
||||
- type: entity
|
||||
|
||||
@@ -58,7 +58,10 @@
|
||||
# deadThreshold: 120
|
||||
- type: Input
|
||||
context: "ghost"
|
||||
- type: DummyInputMover
|
||||
- type: MovementSpeedModifier
|
||||
baseWalkSpeed: 0
|
||||
baseSprintSpeed: 0
|
||||
- type: InputMover
|
||||
- type: GhostOnMove
|
||||
|
||||
- type: entity
|
||||
|
||||
@@ -51,7 +51,10 @@
|
||||
# deadThreshold: 120
|
||||
- type: Input
|
||||
context: "ghost"
|
||||
- type: DummyInputMover
|
||||
- type: MovementSpeedModifier
|
||||
baseWalkSpeed: 0
|
||||
baseSprintSpeed: 0
|
||||
- type: InputMover
|
||||
- type: GhostOnMove
|
||||
|
||||
- type: entity
|
||||
|
||||
@@ -59,7 +59,10 @@
|
||||
# deadThreshold: 120
|
||||
- type: Input
|
||||
context: "ghost"
|
||||
- type: DummyInputMover
|
||||
- type: MovementSpeedModifier
|
||||
baseWalkSpeed: 0
|
||||
baseSprintSpeed: 0
|
||||
- type: InputMover
|
||||
- type: GhostOnMove
|
||||
|
||||
- type: entity
|
||||
|
||||
@@ -137,8 +137,8 @@
|
||||
types:
|
||||
Poison: 2
|
||||
Piercing: 1
|
||||
- type: PlayerInputMover
|
||||
- type: PlayerMobMover
|
||||
- type: InputMover
|
||||
- type: MobMover
|
||||
- type: UtilityAI
|
||||
behaviorSets:
|
||||
- UnarmedAttackHostiles
|
||||
@@ -668,8 +668,8 @@
|
||||
damage:
|
||||
types:
|
||||
Blunt: 10
|
||||
- type: PlayerInputMover
|
||||
- type: PlayerMobMover
|
||||
- type: InputMover
|
||||
- type: MobMover
|
||||
- type: UtilityAI
|
||||
behaviorSets:
|
||||
- UnarmedAttackHostiles
|
||||
@@ -1149,8 +1149,8 @@
|
||||
- type: MovementSpeedModifier
|
||||
baseWalkSpeed : 7
|
||||
baseSprintSpeed : 7
|
||||
- type: PlayerInputMover
|
||||
- type: PlayerMobMover
|
||||
- type: InputMover
|
||||
- type: MobMover
|
||||
- type: UtilityAI
|
||||
behaviorSets:
|
||||
- UnarmedAttackHostiles
|
||||
@@ -1317,8 +1317,8 @@
|
||||
- type: AiFactionTag
|
||||
factions:
|
||||
- Xeno
|
||||
- type: PlayerInputMover
|
||||
- type: PlayerMobMover
|
||||
- type: InputMover
|
||||
- type: MobMover
|
||||
- type: UtilityAI
|
||||
behaviorSets:
|
||||
- Idle
|
||||
|
||||
@@ -4,8 +4,8 @@
|
||||
parent: SimpleSpaceMobBase
|
||||
description: It looks friendly. Why don't you give it a hug?
|
||||
components:
|
||||
- type: PlayerInputMover
|
||||
- type: PlayerMobMover
|
||||
- type: InputMover
|
||||
- type: MobMover
|
||||
- type: UtilityAI
|
||||
behaviorSets:
|
||||
- Idle
|
||||
|
||||
@@ -4,8 +4,8 @@
|
||||
parent: SimpleSpaceMobBase
|
||||
description: It's a space carp.
|
||||
components:
|
||||
- type: PlayerInputMover
|
||||
- type: PlayerMobMover
|
||||
- type: InputMover
|
||||
- type: MobMover
|
||||
- type: UtilityAI
|
||||
behaviorSets:
|
||||
- Idle
|
||||
|
||||
@@ -6,8 +6,8 @@
|
||||
description: A miserable pile of secrets.
|
||||
suffix: AI
|
||||
components:
|
||||
- type: PlayerInputMover
|
||||
- type: PlayerMobMover
|
||||
- type: InputMover
|
||||
- type: MobMover
|
||||
- type: UtilityAI
|
||||
startingGear: PassengerGear
|
||||
behaviorSets:
|
||||
|
||||
@@ -4,8 +4,8 @@
|
||||
id: MobCivilian
|
||||
description: A miserable pile of secrets.
|
||||
components:
|
||||
- type: PlayerInputMover
|
||||
- type: PlayerMobMover
|
||||
- type: InputMover
|
||||
- type: MobMover
|
||||
- type: UtilityAI
|
||||
behaviorSets:
|
||||
- Clothing
|
||||
@@ -24,8 +24,8 @@
|
||||
id: MobSpirate
|
||||
description: Yarr!
|
||||
components:
|
||||
- type: PlayerInputMover
|
||||
- type: PlayerMobMover
|
||||
- type: InputMover
|
||||
- type: MobMover
|
||||
- type: UtilityAI
|
||||
behaviorSets:
|
||||
- Clothing
|
||||
|
||||
@@ -7,8 +7,8 @@
|
||||
- type: Tag
|
||||
tags:
|
||||
- FootstepSound
|
||||
- type: PlayerInputMover
|
||||
- type: PlayerMobMover
|
||||
- type: InputMover
|
||||
- type: MobMover
|
||||
- type: UtilityAI
|
||||
behaviorSets:
|
||||
- UnarmedAttackHostiles
|
||||
|
||||
@@ -82,8 +82,8 @@
|
||||
types:
|
||||
Piercing: 5
|
||||
Slash: 5
|
||||
- type: PlayerInputMover
|
||||
- type: PlayerMobMover
|
||||
- type: InputMover
|
||||
- type: MobMover
|
||||
- type: UtilityAI
|
||||
behaviorSets:
|
||||
- UnarmedAttackHostiles
|
||||
|
||||
@@ -8,8 +8,8 @@
|
||||
- type: MovementSpeedModifier
|
||||
baseWalkSpeed : 3.75
|
||||
baseSprintSpeed : 3.75
|
||||
- type: PlayerInputMover
|
||||
- type: PlayerMobMover
|
||||
- type: InputMover
|
||||
- type: MobMover
|
||||
- type: Reactive
|
||||
groups:
|
||||
Flammable: [Touch]
|
||||
@@ -123,8 +123,8 @@
|
||||
- type: MovementSpeedModifier
|
||||
baseWalkSpeed : 3.5
|
||||
baseSprintSpeed : 3.5
|
||||
- type: PlayerInputMover
|
||||
- type: PlayerMobMover
|
||||
- type: InputMover
|
||||
- type: MobMover
|
||||
- type: UtilityAI
|
||||
behaviorSets:
|
||||
- Idle
|
||||
|
||||
@@ -87,8 +87,8 @@
|
||||
acts: [ "Destruction" ]
|
||||
- type: Input
|
||||
context: "human"
|
||||
- type: PlayerInputMover
|
||||
- type: PlayerMobMover
|
||||
- type: InputMover
|
||||
- type: MobMover
|
||||
|
||||
- type: entity
|
||||
parent: MobSiliconBase
|
||||
|
||||
@@ -12,8 +12,8 @@
|
||||
Flammable: [Touch]
|
||||
Extinguish: [Touch]
|
||||
Acidic: [Touch, Ingestion]
|
||||
- type: PlayerInputMover
|
||||
- type: PlayerMobMover
|
||||
- type: InputMover
|
||||
- type: MobMover
|
||||
- type: UtilityAI
|
||||
behaviorSets:
|
||||
# - Clothing
|
||||
@@ -157,8 +157,8 @@
|
||||
parent: SimpleSpaceMobBase
|
||||
suffix: AI
|
||||
components:
|
||||
- type: PlayerInputMover
|
||||
- type: PlayerMobMover
|
||||
- type: InputMover
|
||||
- type: MobMover
|
||||
- type: UtilityAI
|
||||
behaviorSets:
|
||||
- Idle
|
||||
|
||||
@@ -4,8 +4,8 @@
|
||||
parent: SimpleSpaceMobBase
|
||||
description: It's a space tick, watch out for its nasty bite. Centcomm reports that 90 percent of cargo leg amputations are due to space tick bites.
|
||||
components:
|
||||
- type: PlayerInputMover
|
||||
- type: PlayerMobMover
|
||||
- type: InputMover
|
||||
- type: MobMover
|
||||
- type: UtilityAI
|
||||
behaviorSets:
|
||||
- Idle
|
||||
|
||||
@@ -10,8 +10,8 @@
|
||||
protection: 1
|
||||
- type: CombatMode
|
||||
canDisarm: true
|
||||
- type: PlayerInputMover
|
||||
- type: PlayerMobMover
|
||||
- type: InputMover
|
||||
- type: MobMover
|
||||
- type: UtilityAI
|
||||
behaviorSets:
|
||||
- Idle
|
||||
@@ -349,8 +349,8 @@
|
||||
attributes:
|
||||
proper: true
|
||||
gender: male
|
||||
- type: PlayerInputMover
|
||||
- type: PlayerMobMover
|
||||
- type: InputMover
|
||||
- type: MobMover
|
||||
- type: UtilityAI
|
||||
behaviorSets:
|
||||
- Idle
|
||||
|
||||
@@ -16,7 +16,7 @@
|
||||
- type: DoAfter
|
||||
- type: CombatMode
|
||||
- type: Actions
|
||||
- type: PlayerInputMover
|
||||
- type: InputMover
|
||||
- type: MovementSpeedModifier
|
||||
baseSprintSpeed: 12
|
||||
baseWalkSpeed: 8
|
||||
|
||||
@@ -15,8 +15,8 @@
|
||||
enabled: false
|
||||
autoPopulate: false
|
||||
name: action-name-disarm
|
||||
- type: PlayerMobMover
|
||||
- type: PlayerInputMover
|
||||
- type: MobMover
|
||||
- type: InputMover
|
||||
- type: MovementSpeedModifier
|
||||
baseWalkSpeed : 5
|
||||
baseSprintSpeed : 5
|
||||
|
||||
@@ -16,8 +16,8 @@
|
||||
showExamineInfo: true
|
||||
- type: Input
|
||||
context: "human"
|
||||
- type: PlayerMobMover
|
||||
- type: PlayerInputMover
|
||||
- type: MobMover
|
||||
- type: InputMover
|
||||
- type: Alerts
|
||||
- type: Actions
|
||||
- type: Eye
|
||||
|
||||
@@ -43,8 +43,8 @@
|
||||
types:
|
||||
Piercing: 8
|
||||
Slash: 7
|
||||
- type: PlayerInputMover
|
||||
- type: PlayerMobMover
|
||||
- type: InputMover
|
||||
- type: MobMover
|
||||
- type: UtilityAI
|
||||
behaviorSets:
|
||||
- Idle
|
||||
|
||||
@@ -11,8 +11,8 @@
|
||||
description: Listen to your owner. Don't tank damage. Punch people hard.
|
||||
- type: Input
|
||||
context: "human"
|
||||
- type: PlayerMobMover
|
||||
- type: PlayerInputMover
|
||||
- type: MobMover
|
||||
- type: InputMover
|
||||
- type: MovementSpeedModifier
|
||||
baseWalkSpeed : 7
|
||||
baseSprintSpeed : 7
|
||||
|
||||
@@ -16,8 +16,8 @@
|
||||
showExamineInfo: true
|
||||
- type: Input
|
||||
context: "human"
|
||||
- type: PlayerMobMover
|
||||
- type: PlayerInputMover
|
||||
- type: MobMover
|
||||
- type: InputMover
|
||||
- type: Respirator
|
||||
damage:
|
||||
types:
|
||||
|
||||
Some files were not shown because too many files have changed in this diff Show More
Reference in New Issue
Block a user