* Movement acceleration

* tweaks

* Weightless refactor coz fuck it

* CCVars

* weightless movement tweaks

* Some cleanup while I'm here

* dorkpacks

* thanks fork

* fixes

* zoomies

* toggles

* hmm

* yamls

* b

* so true

* Effects refactor

* namespace

* review
This commit is contained in:
metalgearsloth
2022-06-24 17:44:30 +10:00
committed by GitHub
parent 271d34f005
commit 2b6c352aff
107 changed files with 1197 additions and 206 deletions

View File

@@ -1,5 +1,4 @@
using Content.Shared.Clothing; using Content.Shared.Clothing;
using Content.Shared.Movement.EntitySystems;
namespace Content.Client.Clothing namespace Content.Client.Clothing
{ {

View File

@@ -1,3 +1,4 @@
using Content.Client.Movement.Systems;
using Content.Shared.Climbing; using Content.Shared.Climbing;
namespace Content.Client.Movement.Components; namespace Content.Client.Movement.Components;

View File

@@ -1,4 +1,5 @@
using Content.Shared.Climbing; using Content.Client.Movement.Systems;
using Content.Shared.Climbing;
namespace Content.Client.Movement.Components; namespace Content.Client.Movement.Components;

View File

@@ -4,12 +4,12 @@ using Content.Shared.Climbing;
using Content.Shared.DragDrop; using Content.Shared.DragDrop;
using Robust.Shared.GameStates; using Robust.Shared.GameStates;
namespace Content.Client.Movement; namespace Content.Client.Movement.Systems;
public sealed class ClimbSystem : SharedClimbSystem public sealed class ClimbSystem : SharedClimbSystem
{ {
[Dependency] private readonly InteractionSystem _interactionSystem = default!; [Dependency] private readonly InteractionSystem _interactionSystem = default!;
public override void Initialize() public override void Initialize()
{ {
base.Initialize(); base.Initialize();

View File

@@ -0,0 +1,80 @@
using Content.Client.Clothing;
using Content.Shared.Movement.Components;
using Content.Shared.Movement.Systems;
using Content.Shared.Weapons.Ranged.Systems;
using Robust.Client.Animations;
using Robust.Client.GameObjects;
using Robust.Shared.GameStates;
using Robust.Shared.Map;
using Robust.Shared.Timing;
namespace Content.Client.Movement.Systems;
public sealed class JetpackSystem : SharedJetpackSystem
{
[Dependency] private readonly IGameTiming _timing = default!;
[Dependency] private readonly IMapManager _mapManager = default!;
public override void Initialize()
{
base.Initialize();
SubscribeLocalEvent<JetpackComponent, AppearanceChangeEvent>(OnJetpackAppearance);
}
protected override bool CanEnable(JetpackComponent component)
{
// No predicted atmos so you'd have to do a lot of funny to get this working.
return false;
}
private void OnJetpackAppearance(EntityUid uid, JetpackComponent component, ref AppearanceChangeEvent args)
{
args.Component.TryGetData(JetpackVisuals.Enabled, out bool enabled);
var state = "icon" + (enabled ? "-on" : "");
args.Sprite?.LayerSetState(0, state);
if (TryComp<ClothingComponent>(uid, out var clothing))
clothing.EquippedPrefix = enabled ? "on" : null;
}
public override void Update(float frameTime)
{
base.Update(frameTime);
if (!_timing.IsFirstTimePredicted) return;
foreach (var comp in EntityQuery<ActiveJetpackComponent>())
{
comp.Accumulator += frameTime;
if (comp.Accumulator < comp.EffectCooldown) continue;
comp.Accumulator -= comp.EffectCooldown;
CreateParticles(comp.Owner);
}
}
private void CreateParticles(EntityUid uid)
{
var uidXform = Transform(uid);
var coordinates = uidXform.Coordinates;
var gridUid = coordinates.GetGridUid(EntityManager);
if (_mapManager.TryGetGrid(gridUid, out var grid))
{
coordinates = new EntityCoordinates(grid.GridEntityId, grid.WorldToLocal(coordinates.ToMapPos(EntityManager)));
}
else if (uidXform.MapUid != null)
{
coordinates = new EntityCoordinates(uidXform.MapUid.Value, uidXform.WorldPosition);
}
else
{
return;
}
var ent = Spawn("JetpackEffect", coordinates);
var xform = Transform(ent);
xform.Coordinates = coordinates;
}
}

View File

@@ -1,5 +1,5 @@
using Content.Shared.Movement.Components; using Content.Shared.Movement.Components;
using Content.Shared.Movement.EntitySystems; using Content.Shared.Movement.Systems;
using Content.Shared.Nutrition.Components; using Content.Shared.Nutrition.Components;
using Robust.Shared.GameObjects; using Robust.Shared.GameObjects;

View File

@@ -1,6 +1,7 @@
using Content.Shared.MobState.Components; using Content.Shared.MobState.Components;
using Content.Shared.Movement; using Content.Shared.Movement;
using Content.Shared.Movement.Components; using Content.Shared.Movement.Components;
using Content.Shared.Movement.Systems;
using Content.Shared.Pulling.Components; using Content.Shared.Pulling.Components;
using Robust.Client.Player; using Robust.Client.Player;
using Robust.Shared.Map; using Robust.Shared.Map;

View File

@@ -0,0 +1,11 @@
using Content.Shared.Spawners.EntitySystems;
namespace Content.Client.Spawners;
public sealed class TimedDespawnSystem : SharedTimedDespawnSystem
{
protected override bool CanDelete(EntityUid uid)
{
return uid.IsClientSide();
}
}

View File

@@ -145,6 +145,10 @@ namespace Content.Server.Atmos.Components
if (internals == null) return; if (internals == null) return;
IsConnected = internals.TryConnectTank(Owner); IsConnected = internals.TryConnectTank(Owner);
EntitySystem.Get<SharedActionsSystem>().SetToggled(ToggleAction, IsConnected); EntitySystem.Get<SharedActionsSystem>().SetToggled(ToggleAction, IsConnected);
// Couldn't toggle!
if (!IsConnected) return;
_connectStream?.Stop(); _connectStream?.Stop();
if (_connectSound != null) if (_connectSound != null)
@@ -158,6 +162,7 @@ namespace Content.Server.Atmos.Components
if (!IsConnected) return; if (!IsConnected) return;
IsConnected = false; IsConnected = false;
EntitySystem.Get<SharedActionsSystem>().SetToggled(ToggleAction, false); EntitySystem.Get<SharedActionsSystem>().SetToggled(ToggleAction, false);
GetInternalsComponent(owner)?.DisconnectTank(); GetInternalsComponent(owner)?.DisconnectTank();
_disconnectStream?.Stop(); _disconnectStream?.Stop();

View File

@@ -5,7 +5,7 @@ using Content.Server.Kitchen.Components;
using Content.Server.Mind.Components; using Content.Server.Mind.Components;
using Content.Shared.Body.Components; using Content.Shared.Body.Components;
using Content.Shared.MobState.Components; using Content.Shared.MobState.Components;
using Content.Shared.Movement.EntitySystems; using Content.Shared.Movement.Events;
using Robust.Shared.Timing; using Robust.Shared.Timing;
namespace Content.Server.Body.Systems namespace Content.Server.Body.Systems

View File

@@ -1,6 +1,6 @@
using Content.Shared.Chemistry.Components; using Content.Shared.Chemistry.Components;
using Content.Shared.Chemistry.Reagent; using Content.Shared.Chemistry.Reagent;
using Content.Shared.Movement.EntitySystems; using Content.Shared.Movement.Systems;
using Robust.Shared.Timing; using Robust.Shared.Timing;
namespace Content.Server.Chemistry.ReagentEffects namespace Content.Server.Chemistry.ReagentEffects

View File

@@ -3,6 +3,7 @@ using Content.Server.UserInterface;
using Content.Server.Hands.Components; using Content.Server.Hands.Components;
using Content.Shared.Destructible; using Content.Shared.Destructible;
using Content.Shared.Movement; using Content.Shared.Movement;
using Content.Shared.Movement.Events;
using Content.Shared.Verbs; using Content.Shared.Verbs;
using Content.Shared.Popups; using Content.Shared.Popups;
using Robust.Server.GameObjects; using Robust.Server.GameObjects;

View File

@@ -18,6 +18,7 @@ using Content.Shared.Hands.EntitySystems;
using Content.Shared.Interaction; using Content.Shared.Interaction;
using Content.Shared.Item; using Content.Shared.Item;
using Content.Shared.Movement; using Content.Shared.Movement;
using Content.Shared.Movement.Events;
using Content.Shared.Throwing; using Content.Shared.Throwing;
using Content.Shared.Verbs; using Content.Shared.Verbs;
using Robust.Server.GameObjects; using Robust.Server.GameObjects;

View File

@@ -11,7 +11,7 @@ using Content.Shared.Examine;
using Content.Shared.Follower; using Content.Shared.Follower;
using Content.Shared.Ghost; using Content.Shared.Ghost;
using Content.Shared.MobState.Components; using Content.Shared.MobState.Components;
using Content.Shared.Movement.EntitySystems; using Content.Shared.Movement.Events;
using JetBrains.Annotations; using JetBrains.Annotations;
using Robust.Server.GameObjects; using Robust.Server.GameObjects;
using Robust.Server.Player; using Robust.Server.Player;

View File

@@ -16,6 +16,7 @@ using Content.Shared.Doors.Systems;
using Content.Shared.Interaction.Events; using Content.Shared.Interaction.Events;
using Content.Shared.Maps; using Content.Shared.Maps;
using Content.Shared.Physics; using Content.Shared.Physics;
using Content.Shared.Spawners.Components;
using Content.Shared.Storage; using Content.Shared.Storage;
using Robust.Shared.Audio; using Robust.Shared.Audio;
using Robust.Shared.Map; using Robust.Shared.Map;

View File

@@ -14,6 +14,7 @@ using Content.Shared.DragDrop;
using Content.Shared.Interaction; using Content.Shared.Interaction;
using Content.Shared.MobState.Components; using Content.Shared.MobState.Components;
using Content.Shared.Movement; using Content.Shared.Movement;
using Content.Shared.Movement.Events;
using Content.Shared.Preferences; using Content.Shared.Preferences;
using Content.Shared.Verbs; using Content.Shared.Verbs;
using Robust.Shared.Containers; using Robust.Shared.Containers;

View File

@@ -0,0 +1,48 @@
using Content.Server.Atmos.Components;
using Content.Server.Atmos.EntitySystems;
using Content.Server.Movement.Components;
using Content.Shared.Movement.Components;
using Content.Shared.Movement.Systems;
using Robust.Shared.Collections;
using Robust.Shared.GameStates;
namespace Content.Server.Movement.Systems;
public sealed class JetpackSystem : SharedJetpackSystem
{
private const float UpdateCooldown = 0.5f;
protected override bool CanEnable(JetpackComponent component)
{
return TryComp<GasTankComponent>(component.Owner, out var gasTank) && !(gasTank.Air.Pressure < component.VolumeUsage);
}
public override void Update(float frameTime)
{
base.Update(frameTime);
var toDisable = new ValueList<JetpackComponent>();
foreach (var (active, comp, gasTank) in EntityQuery<ActiveJetpackComponent, JetpackComponent, GasTankComponent>())
{
active.Accumulator += frameTime;
if (active.Accumulator < UpdateCooldown) continue;
active.Accumulator -= UpdateCooldown;
if (gasTank.Air.Pressure < comp.VolumeUsage)
{
toDisable.Add(comp);
continue;
}
gasTank.RemoveAirVolume(comp.VolumeUsage);
gasTank.UpdateUserInterface();
}
foreach (var comp in toDisable)
{
SetEnabled(comp, false);
}
}
}

View File

@@ -4,7 +4,7 @@ using Content.Shared.Damage;
using Content.Shared.Database; using Content.Shared.Database;
using Content.Shared.MobState.Components; using Content.Shared.MobState.Components;
using Content.Shared.Movement.Components; using Content.Shared.Movement.Components;
using Content.Shared.Movement.EntitySystems; using Content.Shared.Movement.Systems;
using Content.Shared.Nutrition.Components; using Content.Shared.Nutrition.Components;
using Robust.Shared.Random; using Robust.Shared.Random;

View File

@@ -1,6 +1,5 @@
using Content.Server.Nutrition.Components; using Content.Server.Nutrition.Components;
using JetBrains.Annotations; using JetBrains.Annotations;
using Content.Shared.Movement.EntitySystems;
using Robust.Shared.Random; using Robust.Shared.Random;
using Content.Shared.MobState.Components; using Content.Shared.MobState.Components;
using Content.Shared.Movement.Components; using Content.Shared.Movement.Components;
@@ -8,6 +7,7 @@ using Content.Shared.Alert;
using Content.Server.Administration.Logs; using Content.Server.Administration.Logs;
using Content.Shared.Database; using Content.Shared.Database;
using Content.Shared.Damage; using Content.Shared.Damage;
using Content.Shared.Movement.Systems;
namespace Content.Server.Nutrition.EntitySystems namespace Content.Server.Nutrition.EntitySystems
{ {

View File

@@ -4,6 +4,7 @@ using Content.Server.Shuttles.Systems;
using Content.Shared.Vehicle.Components; using Content.Shared.Vehicle.Components;
using Content.Shared.Movement; using Content.Shared.Movement;
using Content.Shared.Movement.Components; using Content.Shared.Movement.Components;
using Content.Shared.Movement.Systems;
using Content.Shared.Shuttles.Components; using Content.Shared.Shuttles.Components;
using Robust.Shared.Map; using Robust.Shared.Map;
using Robust.Shared.Player; using Robust.Shared.Player;

View File

@@ -2,12 +2,12 @@ using Content.Shared.Movement;
using Content.Server.DoAfter; using Content.Server.DoAfter;
using Robust.Shared.Containers; using Robust.Shared.Containers;
using Content.Server.Popups; using Content.Server.Popups;
using Content.Shared.Movement.EntitySystems;
using Robust.Shared.Player; using Robust.Shared.Player;
using Content.Shared.Storage; using Content.Shared.Storage;
using Content.Shared.Inventory; using Content.Shared.Inventory;
using Content.Shared.Hands.Components; using Content.Shared.Hands.Components;
using Content.Shared.ActionBlocker; using Content.Shared.ActionBlocker;
using Content.Shared.Movement.Events;
namespace Content.Server.Resist; namespace Content.Server.Resist;

View File

@@ -5,6 +5,7 @@ using Content.Server.Lock;
using Robust.Shared.Player; using Robust.Shared.Player;
using Robust.Shared.Containers; using Robust.Shared.Containers;
using Content.Server.Popups; using Content.Server.Popups;
using Content.Shared.Movement.Events;
namespace Content.Server.Resist; namespace Content.Server.Resist;

View File

@@ -1,19 +1,11 @@
using Content.Server.Spawners.Components; using Content.Shared.Spawners.EntitySystems;
namespace Content.Server.Spawners.EntitySystems; namespace Content.Server.Spawners.EntitySystems;
public sealed class TimedDespawnSystem : EntitySystem public sealed class TimedDespawnSystem : SharedTimedDespawnSystem
{ {
public override void Update(float frameTime) protected override bool CanDelete(EntityUid uid)
{ {
base.Update(frameTime); return true;
foreach (var entity in EntityQuery<TimedDespawnComponent>())
{
entity.Lifetime -= frameTime;
if (entity.Lifetime <= 0)
EntityManager.QueueDeleteEntity(entity.Owner);
}
} }
} }

View File

@@ -28,6 +28,7 @@ using Content.Server.Popups;
using Content.Shared.Destructible; using Content.Shared.Destructible;
using static Content.Shared.Storage.SharedStorageComponent; using static Content.Shared.Storage.SharedStorageComponent;
using Content.Shared.ActionBlocker; using Content.Shared.ActionBlocker;
using Content.Shared.Movement.Events;
namespace Content.Server.Storage.EntitySystems namespace Content.Server.Storage.EntitySystems
{ {

View File

@@ -6,6 +6,7 @@ using Content.Shared.Interaction.Events;
using Content.Shared.Item; using Content.Shared.Item;
using Content.Shared.Movement; using Content.Shared.Movement;
using Content.Shared.Movement.Components; using Content.Shared.Movement.Components;
using Content.Shared.Movement.Events;
using Content.Shared.Speech; using Content.Shared.Speech;
using Content.Shared.Throwing; using Content.Shared.Throwing;
using JetBrains.Annotations; using JetBrains.Annotations;

View File

@@ -2,6 +2,7 @@ using Content.Shared.ActionBlocker;
using Content.Shared.Interaction.Events; using Content.Shared.Interaction.Events;
using Content.Shared.Item; using Content.Shared.Item;
using Content.Shared.Movement; using Content.Shared.Movement;
using Content.Shared.Movement.Events;
using Content.Shared.Physics.Pull; using Content.Shared.Physics.Pull;
using Content.Shared.Pulling; using Content.Shared.Pulling;
using Content.Shared.Pulling.Components; using Content.Shared.Pulling.Components;

View File

@@ -1,6 +1,7 @@
using Content.Shared.Buckle.Components; using Content.Shared.Buckle.Components;
using Content.Shared.Interaction.Events; using Content.Shared.Interaction.Events;
using Content.Shared.Movement; using Content.Shared.Movement;
using Content.Shared.Movement.Events;
using Content.Shared.Standing; using Content.Shared.Standing;
using Content.Shared.Throwing; using Content.Shared.Throwing;
using Robust.Shared.Physics.Dynamics; using Robust.Shared.Physics.Dynamics;

View File

@@ -2,7 +2,7 @@ using Content.Shared.Chemistry.Components;
using Robust.Shared.GameStates; using Robust.Shared.GameStates;
using Robust.Shared.Timing; using Robust.Shared.Timing;
using Content.Shared.Movement.Components; using Content.Shared.Movement.Components;
using Content.Shared.Movement.EntitySystems; using Content.Shared.Movement.Systems;
using static Content.Shared.Chemistry.Components.MovespeedModifierMetabolismComponent; using static Content.Shared.Chemistry.Components.MovespeedModifierMetabolismComponent;
namespace Content.Shared.Chemistry namespace Content.Shared.Chemistry

View File

@@ -1,5 +1,6 @@
using Content.Shared.DragDrop; using Content.Shared.DragDrop;
using Content.Shared.Movement; using Content.Shared.Movement;
using Content.Shared.Movement.Events;
namespace Content.Shared.Climbing; namespace Content.Shared.Climbing;

View File

@@ -1,4 +1,4 @@
using Content.Shared.Movement.EntitySystems; using Content.Shared.Movement.Systems;
using Robust.Shared.Containers; using Robust.Shared.Containers;
using Robust.Shared.GameStates; using Robust.Shared.GameStates;

View File

@@ -5,6 +5,7 @@ using Content.Shared.Interaction.Events;
using Content.Shared.Inventory.Events; using Content.Shared.Inventory.Events;
using Content.Shared.Item; using Content.Shared.Item;
using Content.Shared.Movement; using Content.Shared.Movement;
using Content.Shared.Movement.Events;
using Content.Shared.Physics.Pull; using Content.Shared.Physics.Pull;
using Content.Shared.Pulling.Components; using Content.Shared.Pulling.Components;
using Content.Shared.Pulling.Events; using Content.Shared.Pulling.Events;

View File

@@ -1,6 +1,6 @@
using Content.Shared.Damage.Components; using Content.Shared.Damage.Components;
using Content.Shared.FixedPoint; using Content.Shared.FixedPoint;
using Content.Shared.Movement.EntitySystems; using Content.Shared.Movement.Systems;
namespace Content.Shared.Damage namespace Content.Shared.Damage
{ {

View File

@@ -1,7 +1,7 @@
using Content.Shared.Database; using Content.Shared.Database;
using Content.Shared.Follower.Components; using Content.Shared.Follower.Components;
using Content.Shared.Ghost; using Content.Shared.Ghost;
using Content.Shared.Movement.EntitySystems; using Content.Shared.Movement.Events;
using Content.Shared.Verbs; using Content.Shared.Verbs;
namespace Content.Shared.Follower; namespace Content.Shared.Follower;

View File

@@ -1,6 +1,7 @@
using Content.Shared.CCVar; using Content.Shared.CCVar;
using Content.Shared.Movement; using Content.Shared.Movement;
using Content.Shared.Movement.Components; using Content.Shared.Movement.Components;
using Content.Shared.Movement.Systems;
using JetBrains.Annotations; using JetBrains.Annotations;
using Robust.Shared.Configuration; using Robust.Shared.Configuration;
using Robust.Shared.GameStates; using Robust.Shared.GameStates;

View File

@@ -8,7 +8,7 @@ using Content.Shared.Interaction;
using Content.Shared.Interaction.Events; using Content.Shared.Interaction.Events;
using Content.Shared.Inventory.Events; using Content.Shared.Inventory.Events;
using Content.Shared.Item; using Content.Shared.Item;
using Content.Shared.Movement.EntitySystems; using Content.Shared.Movement.Systems;
using Content.Shared.Popups; using Content.Shared.Popups;
using Content.Shared.Strip.Components; using Content.Shared.Strip.Components;
using Robust.Shared.Audio; using Robust.Shared.Audio;

View File

@@ -1,7 +1,7 @@
using Content.Shared.Damage; using Content.Shared.Damage;
using Content.Shared.Electrocution; using Content.Shared.Electrocution;
using Content.Shared.Explosion; using Content.Shared.Explosion;
using Content.Shared.Movement.EntitySystems; using Content.Shared.Movement.Systems;
using Content.Shared.Slippery; using Content.Shared.Slippery;
namespace Content.Shared.Inventory; namespace Content.Shared.Inventory;

View File

@@ -8,6 +8,7 @@ using Content.Shared.Item;
using Content.Shared.MobState.Components; using Content.Shared.MobState.Components;
using Content.Shared.MobState.State; using Content.Shared.MobState.State;
using Content.Shared.Movement; using Content.Shared.Movement;
using Content.Shared.Movement.Events;
using Content.Shared.Pulling.Events; using Content.Shared.Pulling.Events;
using Content.Shared.Speech; using Content.Shared.Speech;
using Content.Shared.Standing; using Content.Shared.Standing;

View File

@@ -0,0 +1,13 @@
using Robust.Shared.GameStates;
namespace Content.Shared.Movement.Components;
/// <summary>
/// Added to an enabled jetpack. Tracks gas usage on server / effect spawning on client.
/// </summary>
[RegisterComponent, NetworkedComponent]
public sealed class ActiveJetpackComponent : Component
{
public float EffectCooldown = 0.3f;
public float Accumulator = 0f;
}

View File

@@ -0,0 +1,24 @@
using Content.Shared.Actions.ActionTypes;
using Content.Shared.Atmos;
using Robust.Shared.GameStates;
namespace Content.Shared.Movement.Components;
[RegisterComponent, NetworkedComponent]
public sealed class JetpackComponent : Component
{
[ViewVariables(VVAccess.ReadWrite), DataField("volumeUsage")]
public float VolumeUsage = Atmospherics.BreathVolume;
[ViewVariables, DataField("toggleAction", required: true)]
public InstantAction ToggleAction = new();
[ViewVariables(VVAccess.ReadWrite), DataField("acceleration")]
public float Acceleration = 1f;
[ViewVariables(VVAccess.ReadWrite), DataField("friction")]
public float Friction = 0.3f;
[ViewVariables(VVAccess.ReadWrite), DataField("weightlessModifier")]
public float WeightlessModifier = 1.2f;
}

View File

@@ -0,0 +1,14 @@
using Robust.Shared.GameStates;
namespace Content.Shared.Movement.Components;
/// <summary>
/// Added to someone using a jetpack for movement purposes
/// </summary>
[RegisterComponent, NetworkedComponent]
public sealed class JetpackUserComponent : Component
{
public float Acceleration = 1f;
public float Friction = 0.3f;
public float WeightlessModifier = 1.2f;
}

View File

@@ -1,4 +1,4 @@
using Content.Shared.Movement.EntitySystems; using Content.Shared.Movement.Systems;
using Robust.Shared.GameStates; using Robust.Shared.GameStates;
namespace Content.Shared.Movement.Components namespace Content.Shared.Movement.Components

View File

@@ -1,48 +0,0 @@
using Content.Shared.CCVar;
using Content.Shared.Movement.Components;
using Robust.Shared.Configuration;
using Robust.Shared.Physics;
using Robust.Shared.Physics.Dynamics;
namespace Content.Shared.Movement.EntitySystems
{
public sealed class SharedMobMoverSystem : EntitySystem
{
private bool _pushingEnabled;
public override void Initialize()
{
base.Initialize();
Get<SharedPhysicsSystem>().KinematicControllerCollision += OnMobCollision;
IoCManager.Resolve<IConfigurationManager>().OnValueChanged(CCVars.MobPushing, SetPushing, true);
}
private void SetPushing(bool value)
{
_pushingEnabled = value;
}
public override void Shutdown()
{
base.Shutdown();
IoCManager.Resolve<IConfigurationManager>().UnsubValueChanged(CCVars.MobPushing, SetPushing);
Get<SharedPhysicsSystem>().KinematicControllerCollision -= OnMobCollision;
}
/// <summary>
/// Fake pushing for player collisions.
/// </summary>
private void OnMobCollision(Fixture ourFixture, Fixture otherFixture, float frameTime, Vector2 worldNormal)
{
if (!_pushingEnabled) return;
var otherBody = otherFixture.Body;
if (otherBody.BodyType != BodyType.Dynamic || !otherFixture.Hard) return;
if (!EntityManager.TryGetComponent(ourFixture.Body.Owner, out IMobMoverComponent? mobMover) || worldNormal == Vector2.Zero) return;
otherBody.ApplyLinearImpulse(-worldNormal * mobMover.PushStrength * frameTime);
}
}
}

View File

@@ -0,0 +1,13 @@
using Robust.Shared.Players;
namespace Content.Shared.Movement.Events;
public sealed class RelayMoveInputEvent : EntityEventArgs
{
public ICommonSession Session { get; }
public RelayMoveInputEvent(ICommonSession session)
{
Session = session;
}
}

View File

@@ -1,4 +1,4 @@
namespace Content.Shared.Movement namespace Content.Shared.Movement.Events
{ {
public sealed class RelayMovementEntityEvent : EntityEventArgs public sealed class RelayMovementEntityEvent : EntityEventArgs
{ {

View File

@@ -0,0 +1,8 @@
using Content.Shared.Actions;
namespace Content.Shared.Movement.Events;
/// <summary>
/// Raised on a jetpack whenever it is toggled.
/// </summary>
public sealed class ToggleJetpackEvent : InstantActionEvent {}

View File

@@ -1,6 +1,6 @@
using Content.Shared.Movement.Components; using Content.Shared.Movement.Components;
namespace Content.Shared.Movement; namespace Content.Shared.Movement.Events;
/// <summary> /// <summary>
/// Raised whenever <see cref="IMoverComponent.CanMove"/> needs to be updated. Cancel this event to prevent a /// Raised whenever <see cref="IMoverComponent.CanMove"/> needs to be updated. Cancel this event to prevent a

View File

@@ -0,0 +1,14 @@
namespace Content.Shared.Movement.Events;
/// <summary>
/// Raised on an entity to check if it can move while weightless.
/// </summary>
[ByRefEvent]
public struct CanWeightlessMoveEvent
{
public bool CanMove = false;
public CanWeightlessMoveEvent()
{
}
}

View File

@@ -0,0 +1,35 @@
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;
}
}

View File

@@ -1,8 +1,7 @@
using Content.Shared.Alert; using Content.Shared.Movement.Components;
using Content.Shared.Movement.Components;
using Robust.Shared.GameStates; using Robust.Shared.GameStates;
namespace Content.Shared.Movement.EntitySystems; namespace Content.Shared.Movement.Systems;
public sealed class MovementIgnoreGravitySystem : EntitySystem public sealed class MovementIgnoreGravitySystem : EntitySystem
{ {

View File

@@ -3,26 +3,13 @@ using Content.Shared.Movement.Components;
using Robust.Shared.GameStates; using Robust.Shared.GameStates;
using Robust.Shared.Serialization; using Robust.Shared.Serialization;
namespace Content.Shared.Movement.EntitySystems namespace Content.Shared.Movement.Systems
{ {
public sealed class MovementSpeedModifierSystem : EntitySystem public sealed class MovementSpeedModifierSystem : EntitySystem
{ {
private readonly HashSet<EntityUid> _needsRefresh = new();
public override void Update(float frameTime)
{
foreach (var uid in _needsRefresh)
{
RecalculateMovementSpeedModifiers(uid);
}
_needsRefresh.Clear();
}
public override void Initialize() public override void Initialize()
{ {
base.Initialize(); base.Initialize();
UpdatesOutsidePrediction = true;
SubscribeLocalEvent<MovementSpeedModifierComponent, ComponentGetState>(OnGetState); SubscribeLocalEvent<MovementSpeedModifierComponent, ComponentGetState>(OnGetState);
SubscribeLocalEvent<MovementSpeedModifierComponent, ComponentHandleState>(OnHandleState); SubscribeLocalEvent<MovementSpeedModifierComponent, ComponentHandleState>(OnHandleState);
} }
@@ -47,23 +34,18 @@ namespace Content.Shared.Movement.EntitySystems
component.SprintSpeedModifier = state.SprintSpeedModifier; component.SprintSpeedModifier = state.SprintSpeedModifier;
} }
public void RefreshMovementSpeedModifiers(EntityUid uid) public void RefreshMovementSpeedModifiers(EntityUid uid, MovementSpeedModifierComponent? move = null)
{
_needsRefresh.Add(uid);
}
private void RecalculateMovementSpeedModifiers(EntityUid uid, MovementSpeedModifierComponent? move = null)
{ {
if (!Resolve(uid, ref move, false)) if (!Resolve(uid, ref move, false))
return; return;
var ev = new RefreshMovementSpeedModifiersEvent(); var ev = new RefreshMovementSpeedModifiersEvent();
RaiseLocalEvent(uid, ev, false); RaiseLocalEvent(uid, ev);
move.WalkSpeedModifier = ev.WalkSpeedModifier; move.WalkSpeedModifier = ev.WalkSpeedModifier;
move.SprintSpeedModifier = ev.SprintSpeedModifier; move.SprintSpeedModifier = ev.SprintSpeedModifier;
move.Dirty(); Dirty(move);
} }
[Serializable, NetSerializable] [Serializable, NetSerializable]

View File

@@ -0,0 +1,124 @@
using Content.Shared.Actions;
using Content.Shared.Interaction.Events;
using Content.Shared.Inventory;
using Content.Shared.Movement.Components;
using Content.Shared.Movement.Events;
using Robust.Shared.Containers;
using Robust.Shared.Serialization;
namespace Content.Shared.Movement.Systems;
public abstract class SharedJetpackSystem : EntitySystem
{
[Dependency] protected readonly SharedContainerSystem Container = default!;
public override void Initialize()
{
base.Initialize();
SubscribeLocalEvent<JetpackComponent, GetItemActionsEvent>(OnJetpackGetAction);
SubscribeLocalEvent<JetpackComponent, DroppedEvent>(OnJetpackDropped);
SubscribeLocalEvent<JetpackComponent, ToggleJetpackEvent>(OnJetpackToggle);
SubscribeLocalEvent<JetpackUserComponent, CanWeightlessMoveEvent>(OnJetpackUserCanWeightless);
SubscribeLocalEvent<JetpackUserComponent, MobMovementProfileEvent>(OnJetpackUserMovement);
}
private void OnJetpackDropped(EntityUid uid, JetpackComponent component, DroppedEvent args)
{
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;
}
private void SetupUser(EntityUid uid, JetpackComponent component)
{
var user = EnsureComp<JetpackUserComponent>(uid);
user.Acceleration = component.Acceleration;
user.Friction = component.Friction;
user.WeightlessModifier = component.WeightlessModifier;
}
private void OnJetpackToggle(EntityUid uid, JetpackComponent component, ToggleJetpackEvent args)
{
if (args.Handled) return;
SetEnabled(component, !IsEnabled(uid));
}
private void OnJetpackGetAction(EntityUid uid, JetpackComponent component, GetItemActionsEvent args)
{
args.Actions.Add(component.ToggleAction);
}
private bool IsEnabled(EntityUid uid)
{
return HasComp<ActiveJetpackComponent>(uid);
}
public void SetEnabled(JetpackComponent component, bool enabled, EntityUid? user = null)
{
if (IsEnabled(component.Owner) == enabled ||
enabled && !CanEnable(component)) return;
if (enabled)
{
EnsureComp<ActiveJetpackComponent>(component.Owner);
}
else
{
RemComp<ActiveJetpackComponent>(component.Owner);
}
if (user == null)
{
Container.TryGetContainingContainer(component.Owner, out var container);
user = container?.Owner;
}
// Can't activate if no one's using.
if (user == null && enabled) return;
if (user != null)
{
if (enabled)
{
SetupUser(user.Value, component);
}
else
{
RemComp<JetpackUserComponent>(user.Value);
}
}
TryComp<AppearanceComponent>(component.Owner, out var appearance);
appearance?.SetData(JetpackVisuals.Enabled, enabled);
Dirty(component);
}
protected abstract bool CanEnable(JetpackComponent component);
[Serializable, NetSerializable]
protected sealed class JetpackComponentState : ComponentState
{
public bool Enabled;
}
}
[Serializable, NetSerializable]
public enum JetpackVisuals : byte
{
Enabled,
}

View File

@@ -1,47 +1,43 @@
using System.Diagnostics.CodeAnalysis;
using Content.Shared.MobState.Components; using Content.Shared.MobState.Components;
using Content.Shared.Movement.Components; using Content.Shared.Movement.Components;
using Content.Shared.Movement.Events;
using Content.Shared.Vehicle.Components; using Content.Shared.Vehicle.Components;
using Robust.Shared.Containers; using Robust.Shared.Containers;
using Robust.Shared.Input; using Robust.Shared.Input;
using Robust.Shared.Input.Binding; using Robust.Shared.Input.Binding;
using Robust.Shared.Players; using Robust.Shared.Players;
namespace Content.Shared.Movement.EntitySystems namespace Content.Shared.Movement.Systems
{ {
/// <summary> /// <summary>
/// Handles converting inputs into movement. /// Handles converting inputs into movement.
/// </summary> /// </summary>
public sealed class SharedMoverSystem : EntitySystem public abstract partial class SharedMoverController
{ {
public override void Initialize() private void InitializeInput()
{ {
base.Initialize(); var moveUpCmdHandler = new MoverDirInputCmdHandler(this, Direction.North);
var moveLeftCmdHandler = new MoverDirInputCmdHandler(this, Direction.West);
var moveUpCmdHandler = new MoverDirInputCmdHandler(Direction.North); var moveRightCmdHandler = new MoverDirInputCmdHandler(this, Direction.East);
var moveLeftCmdHandler = new MoverDirInputCmdHandler(Direction.West); var moveDownCmdHandler = new MoverDirInputCmdHandler(this, Direction.South);
var moveRightCmdHandler = new MoverDirInputCmdHandler(Direction.East);
var moveDownCmdHandler = new MoverDirInputCmdHandler(Direction.South);
CommandBinds.Builder CommandBinds.Builder
.Bind(EngineKeyFunctions.MoveUp, moveUpCmdHandler) .Bind(EngineKeyFunctions.MoveUp, moveUpCmdHandler)
.Bind(EngineKeyFunctions.MoveLeft, moveLeftCmdHandler) .Bind(EngineKeyFunctions.MoveLeft, moveLeftCmdHandler)
.Bind(EngineKeyFunctions.MoveRight, moveRightCmdHandler) .Bind(EngineKeyFunctions.MoveRight, moveRightCmdHandler)
.Bind(EngineKeyFunctions.MoveDown, moveDownCmdHandler) .Bind(EngineKeyFunctions.MoveDown, moveDownCmdHandler)
.Bind(EngineKeyFunctions.Walk, new WalkInputCmdHandler()) .Bind(EngineKeyFunctions.Walk, new WalkInputCmdHandler(this))
.Register<SharedMoverSystem>(); .Register<SharedMoverController>();
} }
/// <inheritdoc /> private void ShutdownInput()
public override void Shutdown()
{ {
CommandBinds.Unregister<SharedMoverSystem>(); CommandBinds.Unregister<SharedMoverController>();
base.Shutdown();
} }
private void HandleDirChange(ICommonSession? session, Direction dir, ushort subTick, bool state) private void HandleDirChange(ICommonSession? session, Direction dir, ushort subTick, bool state)
{ {
if (!TryGetAttachedComponent<IMoverComponent>(session, out var moverComp)) if (!TryComp<IMoverComponent>(session?.AttachedEntity, out var moverComp))
return; return;
var owner = session?.AttachedEntity; var owner = session?.AttachedEntity;
@@ -71,9 +67,9 @@ namespace Content.Shared.Movement.EntitySystems
moverComp.SetVelocityDirection(dir, subTick, state); moverComp.SetVelocityDirection(dir, subTick, state);
} }
private static void HandleRunChange(ICommonSession? session, ushort subTick, bool walking) private void HandleRunChange(ICommonSession? session, ushort subTick, bool walking)
{ {
if (!TryGetAttachedComponent<IMoverComponent>(session, out var moverComp)) if (!TryComp<IMoverComponent>(session?.AttachedEntity, out var moverComp))
{ {
return; return;
} }
@@ -81,68 +77,42 @@ namespace Content.Shared.Movement.EntitySystems
moverComp.SetSprinting(subTick, walking); moverComp.SetSprinting(subTick, walking);
} }
private static bool TryGetAttachedComponent<T>(ICommonSession? session, [NotNullWhen(true)] out T? component)
where T : class, IComponent
{
component = default;
var ent = session?.AttachedEntity;
var entMan = IoCManager.Resolve<IEntityManager>();
if (ent == null || !entMan.EntityExists(ent.Value))
return false;
if (!entMan.TryGetComponent(ent.Value, out T? comp))
return false;
component = comp;
return true;
}
private sealed class MoverDirInputCmdHandler : InputCmdHandler private sealed class MoverDirInputCmdHandler : InputCmdHandler
{ {
private SharedMoverController _controller;
private readonly Direction _dir; private readonly Direction _dir;
public MoverDirInputCmdHandler(Direction dir) public MoverDirInputCmdHandler(SharedMoverController controller, Direction dir)
{ {
_controller = controller;
_dir = dir; _dir = dir;
} }
public override bool HandleCmdMessage(ICommonSession? session, InputCmdMessage message) public override bool HandleCmdMessage(ICommonSession? session, InputCmdMessage message)
{ {
if (message is not FullInputCmdMessage full) if (message is not FullInputCmdMessage full) return false;
{
return false;
}
Get<SharedMoverSystem>().HandleDirChange(session, _dir, message.SubTick, full.State == BoundKeyState.Down); _controller.HandleDirChange(session, _dir, message.SubTick, full.State == BoundKeyState.Down);
return false; return false;
} }
} }
private sealed class WalkInputCmdHandler : InputCmdHandler private sealed class WalkInputCmdHandler : InputCmdHandler
{ {
private SharedMoverController _controller;
public WalkInputCmdHandler(SharedMoverController controller)
{
_controller = controller;
}
public override bool HandleCmdMessage(ICommonSession? session, InputCmdMessage message) public override bool HandleCmdMessage(ICommonSession? session, InputCmdMessage message)
{ {
if (message is not FullInputCmdMessage full) if (message is not FullInputCmdMessage full) return false;
{
return false;
}
HandleRunChange(session, full.SubTick, full.State == BoundKeyState.Down); _controller.HandleRunChange(session, full.SubTick, full.State == BoundKeyState.Down);
return false; return false;
} }
} }
} }
public sealed class RelayMoveInputEvent : EntityEventArgs
{
public ICommonSession Session { get; }
public RelayMoveInputEvent(ICommonSession session)
{
Session = session;
}
}
} }

View File

@@ -0,0 +1,56 @@
using Content.Shared.CCVar;
using Content.Shared.Movement.Components;
using Robust.Shared.Physics;
using Robust.Shared.Physics.Dynamics;
namespace Content.Shared.Movement.Systems;
public abstract partial class SharedMoverController
{
private bool _pushingEnabled;
private void InitializePushing()
{
_configManager.OnValueChanged(CCVars.MobPushing, SetPushing, true);
}
private void SetPushing(bool value)
{
if (_pushingEnabled == value) return;
_pushingEnabled = value;
if (_pushingEnabled)
{
_physics.KinematicControllerCollision += OnMobCollision;
}
else
{
_physics.KinematicControllerCollision -= OnMobCollision;
}
}
private void ShutdownPushing()
{
if (_pushingEnabled)
_physics.KinematicControllerCollision -= OnMobCollision;
_configManager.UnsubValueChanged(CCVars.MobPushing, SetPushing);
}
/// <summary>
/// Fake pushing for player collisions.
/// </summary>
private void OnMobCollision(Fixture ourFixture, Fixture otherFixture, float frameTime, Vector2 worldNormal)
{
if (!_pushingEnabled) return;
var otherBody = otherFixture.Body;
if (otherBody.BodyType != BodyType.Dynamic || !otherFixture.Hard) return;
if (!EntityManager.TryGetComponent(ourFixture.Body.Owner, out IMobMoverComponent? mobMover) || worldNormal == Vector2.Zero) return;
otherBody.ApplyLinearImpulse(-worldNormal * mobMover.PushStrength * frameTime);
}
}

View File

@@ -6,6 +6,7 @@ using Content.Shared.Inventory;
using Content.Shared.Maps; using Content.Shared.Maps;
using Content.Shared.MobState.Components; using Content.Shared.MobState.Components;
using Content.Shared.Movement.Components; using Content.Shared.Movement.Components;
using Content.Shared.Movement.Events;
using Content.Shared.Pulling.Components; using Content.Shared.Pulling.Components;
using Content.Shared.Tag; using Content.Shared.Tag;
using Robust.Shared.Audio; using Robust.Shared.Audio;
@@ -16,14 +17,15 @@ using Robust.Shared.Physics.Controllers;
using Robust.Shared.Player; using Robust.Shared.Player;
using Robust.Shared.Utility; using Robust.Shared.Utility;
namespace Content.Shared.Movement namespace Content.Shared.Movement.Systems
{ {
/// <summary> /// <summary>
/// Handles player and NPC mob movement. /// Handles player and NPC mob movement.
/// NPCs are handled server-side only. /// NPCs are handled server-side only.
/// </summary> /// </summary>
public abstract class SharedMoverController : VirtualController public abstract partial class SharedMoverController : VirtualController
{ {
[Dependency] private readonly IConfigurationManager _configManager = default!;
[Dependency] private readonly IMapManager _mapManager = default!; [Dependency] private readonly IMapManager _mapManager = default!;
[Dependency] private readonly ITileDefinitionManager _tileDefinitionManager = default!; [Dependency] private readonly ITileDefinitionManager _tileDefinitionManager = default!;
[Dependency] private readonly InventorySystem _inventory = default!; [Dependency] private readonly InventorySystem _inventory = default!;
@@ -86,17 +88,18 @@ namespace Content.Shared.Movement
public override void Initialize() public override void Initialize()
{ {
base.Initialize(); base.Initialize();
var configManager = IoCManager.Resolve<IConfigurationManager>(); InitializeInput();
InitializePushing();
// Hello // Hello
configManager.OnValueChanged(CCVars.RelativeMovement, SetRelativeMovement, true); _configManager.OnValueChanged(CCVars.RelativeMovement, SetRelativeMovement, true);
configManager.OnValueChanged(CCVars.MinimumFrictionSpeed, SetMinimumFrictionSpeed, true); _configManager.OnValueChanged(CCVars.MinimumFrictionSpeed, SetMinimumFrictionSpeed, true);
configManager.OnValueChanged(CCVars.MobFriction, SetFrictionVelocity, true); _configManager.OnValueChanged(CCVars.MobFriction, SetFrictionVelocity, true);
configManager.OnValueChanged(CCVars.MobWeightlessFriction, SetWeightlessFrictionVelocity, true); _configManager.OnValueChanged(CCVars.MobWeightlessFriction, SetWeightlessFrictionVelocity, true);
configManager.OnValueChanged(CCVars.StopSpeed, SetStopSpeed, true); _configManager.OnValueChanged(CCVars.StopSpeed, SetStopSpeed, true);
configManager.OnValueChanged(CCVars.MobAcceleration, SetMobAcceleration, true); _configManager.OnValueChanged(CCVars.MobAcceleration, SetMobAcceleration, true);
configManager.OnValueChanged(CCVars.MobWeightlessAcceleration, SetMobWeightlessAcceleration, true); _configManager.OnValueChanged(CCVars.MobWeightlessAcceleration, SetMobWeightlessAcceleration, true);
configManager.OnValueChanged(CCVars.MobWeightlessFrictionNoInput, SetWeightlessFrictionNoInput, true); _configManager.OnValueChanged(CCVars.MobWeightlessFrictionNoInput, SetWeightlessFrictionNoInput, true);
configManager.OnValueChanged(CCVars.MobWeightlessModifier, SetMobWeightlessModifier, true); _configManager.OnValueChanged(CCVars.MobWeightlessModifier, SetMobWeightlessModifier, true);
UpdatesBefore.Add(typeof(SharedTileFrictionController)); UpdatesBefore.Add(typeof(SharedTileFrictionController));
} }
@@ -113,16 +116,17 @@ namespace Content.Shared.Movement
public override void Shutdown() public override void Shutdown()
{ {
base.Shutdown(); base.Shutdown();
var configManager = IoCManager.Resolve<IConfigurationManager>(); ShutdownInput();
configManager.UnsubValueChanged(CCVars.RelativeMovement, SetRelativeMovement); ShutdownPushing();
configManager.UnsubValueChanged(CCVars.MinimumFrictionSpeed, SetMinimumFrictionSpeed); _configManager.UnsubValueChanged(CCVars.RelativeMovement, SetRelativeMovement);
configManager.UnsubValueChanged(CCVars.StopSpeed, SetStopSpeed); _configManager.UnsubValueChanged(CCVars.MinimumFrictionSpeed, SetMinimumFrictionSpeed);
configManager.UnsubValueChanged(CCVars.MobFriction, SetFrictionVelocity); _configManager.UnsubValueChanged(CCVars.StopSpeed, SetStopSpeed);
configManager.UnsubValueChanged(CCVars.MobWeightlessFriction, SetWeightlessFrictionVelocity); _configManager.UnsubValueChanged(CCVars.MobFriction, SetFrictionVelocity);
configManager.UnsubValueChanged(CCVars.MobAcceleration, SetMobAcceleration); _configManager.UnsubValueChanged(CCVars.MobWeightlessFriction, SetWeightlessFrictionVelocity);
configManager.UnsubValueChanged(CCVars.MobWeightlessAcceleration, SetMobWeightlessAcceleration); _configManager.UnsubValueChanged(CCVars.MobAcceleration, SetMobAcceleration);
configManager.UnsubValueChanged(CCVars.MobWeightlessFrictionNoInput, SetWeightlessFrictionNoInput); _configManager.UnsubValueChanged(CCVars.MobWeightlessAcceleration, SetMobWeightlessAcceleration);
configManager.UnsubValueChanged(CCVars.MobWeightlessModifier, SetMobWeightlessModifier); _configManager.UnsubValueChanged(CCVars.MobWeightlessFrictionNoInput, SetWeightlessFrictionNoInput);
_configManager.UnsubValueChanged(CCVars.MobWeightlessModifier, SetMobWeightlessModifier);
} }
public override void UpdateAfterSolve(bool prediction, float frameTime) public override void UpdateAfterSolve(bool prediction, float frameTime)
@@ -187,13 +191,21 @@ namespace Content.Shared.Movement
UsedMobMovement[mover.Owner] = true; UsedMobMovement[mover.Owner] = true;
var weightless = mover.Owner.IsWeightless(physicsComponent, mapManager: _mapManager, entityManager: EntityManager); var weightless = mover.Owner.IsWeightless(physicsComponent, mapManager: _mapManager, entityManager: EntityManager);
var (walkDir, sprintDir) = mover.VelocityDir; var (walkDir, sprintDir) = mover.VelocityDir;
bool touching = true; var touching = false;
// Handle wall-pushes. // Handle wall-pushes.
if (weightless) if (weightless)
{ {
// No gravity: is our entity touching anything? if (xform.GridUid != null)
touching = xform.GridUid != null || IsAroundCollider(_physics, xform, mobMover, physicsComponent); touching = true;
if (!touching)
{
var ev = new CanWeightlessMoveEvent();
RaiseLocalEvent(xform.Owner, ref ev);
// No gravity: is our entity touching anything?
touching = ev.CanMove || IsAroundCollider(_physics, xform, mobMover, physicsComponent);
}
if (!touching) if (!touching)
{ {
@@ -233,6 +245,22 @@ namespace Content.Shared.Movement
accel = _mobAcceleration; accel = _mobAcceleration;
} }
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); Friction(frameTime, friction, ref velocity);
if (xform.GridUid != EntityUid.Invalid) if (xform.GridUid != EntityUid.Invalid)
@@ -242,7 +270,7 @@ namespace Content.Shared.Movement
{ {
// This should have its event run during island solver soooo // This should have its event run during island solver soooo
xform.DeferUpdates = true; xform.DeferUpdates = true;
xform.LocalRotation = xform.GridUid != EntityUid.Invalid xform.LocalRotation = xform.GridUid != null
? total.ToWorldAngle() ? total.ToWorldAngle()
: worldTotal.ToWorldAngle(); : worldTotal.ToWorldAngle();
xform.DeferUpdates = false; xform.DeferUpdates = false;
@@ -257,7 +285,7 @@ namespace Content.Shared.Movement
worldTotal *= weightlessModifier; worldTotal *= weightlessModifier;
if (touching) if (!weightless || touching)
Accelerate(ref velocity, in worldTotal, accel, frameTime); Accelerate(ref velocity, in worldTotal, accel, frameTime);
_physics.SetLinearVelocity(physicsComponent, velocity); _physics.SetLinearVelocity(physicsComponent, velocity);

View File

@@ -1,7 +1,7 @@
using Content.Shared.Movement.Components; using Content.Shared.Movement.Components;
using Robust.Shared.Physics.Dynamics; using Robust.Shared.Physics.Dynamics;
namespace Content.Shared.Movement.EntitySystems; namespace Content.Shared.Movement.Systems;
public sealed class SlowContactsSystem : EntitySystem public sealed class SlowContactsSystem : EntitySystem
{ {
@@ -52,7 +52,7 @@ public sealed class SlowContactsSystem : EntitySystem
Logger.ErrorS("slowscontacts", $"The entity {otherUid} left a body ({uid}) it was never in."); Logger.ErrorS("slowscontacts", $"The entity {otherUid} left a body ({uid}) it was never in.");
_statusCapableInContact[otherUid]--; _statusCapableInContact[otherUid]--;
if (_statusCapableInContact[otherUid] == 0) if (_statusCapableInContact[otherUid] == 0)
EntityManager.RemoveComponent<SlowsOnContactComponent>(otherUid); EntityManager.RemoveComponentDeferred<SlowsOnContactComponent>(otherUid);
_speedModifierSystem.RefreshMovementSpeedModifiers(otherUid); _speedModifierSystem.RefreshMovementSpeedModifiers(otherUid);
} }
@@ -65,8 +65,8 @@ public sealed class SlowContactsSystem : EntitySystem
if (!_statusCapableInContact.ContainsKey(otherUid)) if (!_statusCapableInContact.ContainsKey(otherUid))
_statusCapableInContact[otherUid] = 0; _statusCapableInContact[otherUid] = 0;
_statusCapableInContact[otherUid]++; _statusCapableInContact[otherUid]++;
if (!EntityManager.HasComponent<SlowsOnContactComponent>(otherUid))
EntityManager.AddComponent<SlowsOnContactComponent>(otherUid); EnsureComp<SlowsOnContactComponent>(otherUid);
_speedModifierSystem.RefreshMovementSpeedModifiers(otherUid); _speedModifierSystem.RefreshMovementSpeedModifiers(otherUid);
} }
} }

View File

@@ -1,4 +1,4 @@
using Content.Shared.Movement.EntitySystems; using Content.Shared.Movement.Systems;
using Content.Shared.Nutrition.Components; using Content.Shared.Nutrition.Components;
namespace Content.Shared.Nutrition.EntitySystems namespace Content.Shared.Nutrition.EntitySystems

View File

@@ -4,6 +4,7 @@ using Content.Shared.DragDrop;
using Content.Shared.Interaction.Events; using Content.Shared.Interaction.Events;
using Content.Shared.Item; using Content.Shared.Item;
using Content.Shared.Movement; using Content.Shared.Movement;
using Content.Shared.Movement.Events;
using Robust.Shared.Serialization; using Robust.Shared.Serialization;
namespace Content.Shared.PAI namespace Content.Shared.PAI

View File

@@ -1,7 +1,7 @@
using Content.Shared.ActionBlocker; using Content.Shared.ActionBlocker;
using Content.Shared.Movement.EntitySystems;
using Content.Shared.Pulling.Components; using Content.Shared.Pulling.Components;
using Content.Shared.MobState.Components; using Content.Shared.MobState.Components;
using Content.Shared.Movement.Events;
namespace Content.Shared.Pulling.Systems namespace Content.Shared.Pulling.Systems
{ {

View File

@@ -1,6 +1,6 @@
using Content.Shared.Alert; using Content.Shared.Alert;
using Content.Shared.Hands; using Content.Shared.Hands;
using Content.Shared.Movement.EntitySystems; using Content.Shared.Movement.Systems;
using Content.Shared.Physics.Pull; using Content.Shared.Physics.Pull;
using Content.Shared.Pulling.Components; using Content.Shared.Pulling.Components;
using JetBrains.Annotations; using JetBrains.Annotations;

View File

@@ -1,5 +1,6 @@
using Content.Shared.ActionBlocker; using Content.Shared.ActionBlocker;
using Content.Shared.Movement; using Content.Shared.Movement;
using Content.Shared.Movement.Events;
using Content.Shared.Shuttles.Components; using Content.Shared.Shuttles.Components;
using Robust.Shared.Serialization; using Robust.Shared.Serialization;

View File

@@ -1,4 +1,4 @@
namespace Content.Server.Spawners.Components; namespace Content.Shared.Spawners.Components;
/// <summary> /// <summary>
/// Put this component on something you would like to despawn after a certain amount of time /// Put this component on something you would like to despawn after a certain amount of time

View File

@@ -0,0 +1,28 @@
using Content.Shared.Spawners.Components;
using Robust.Shared.Timing;
namespace Content.Shared.Spawners.EntitySystems;
public abstract class SharedTimedDespawnSystem : EntitySystem
{
[Dependency] private readonly IGameTiming _timing = default!;
public override void Update(float frameTime)
{
base.Update(frameTime);
if (!_timing.IsFirstTimePredicted) return;
foreach (var comp in EntityQuery<TimedDespawnComponent>())
{
if (!CanDelete(comp.Owner)) continue;
comp.Lifetime -= frameTime;
if (comp.Lifetime <= 0)
EntityManager.QueueDeleteEntity(comp.Owner);
}
}
protected abstract bool CanDelete(EntityUid uid);
}

View File

@@ -6,7 +6,8 @@ using Content.Shared.Interaction.Events;
using Content.Shared.Inventory.Events; using Content.Shared.Inventory.Events;
using Content.Shared.Item; using Content.Shared.Item;
using Content.Shared.Movement; using Content.Shared.Movement;
using Content.Shared.Movement.EntitySystems; using Content.Shared.Movement.Events;
using Content.Shared.Movement.Systems;
using Content.Shared.Standing; using Content.Shared.Standing;
using Content.Shared.StatusEffect; using Content.Shared.StatusEffect;
using Content.Shared.Throwing; using Content.Shared.Throwing;
@@ -31,7 +32,7 @@ namespace Content.Shared.Stunnable
SubscribeLocalEvent<KnockedDownComponent, ComponentRemove>(OnKnockRemove); SubscribeLocalEvent<KnockedDownComponent, ComponentRemove>(OnKnockRemove);
SubscribeLocalEvent<SlowedDownComponent, ComponentInit>(OnSlowInit); SubscribeLocalEvent<SlowedDownComponent, ComponentInit>(OnSlowInit);
SubscribeLocalEvent<SlowedDownComponent, ComponentRemove>(OnSlowRemove); SubscribeLocalEvent<SlowedDownComponent, ComponentShutdown>(OnSlowRemove);
SubscribeLocalEvent<StunnedComponent, ComponentStartup>(UpdateCanMove); SubscribeLocalEvent<StunnedComponent, ComponentStartup>(UpdateCanMove);
SubscribeLocalEvent<StunnedComponent, ComponentShutdown>(UpdateCanMove); SubscribeLocalEvent<StunnedComponent, ComponentShutdown>(UpdateCanMove);
@@ -105,7 +106,7 @@ namespace Content.Shared.Stunnable
_movementSpeedModifierSystem.RefreshMovementSpeedModifiers(uid); _movementSpeedModifierSystem.RefreshMovementSpeedModifiers(uid);
} }
private void OnSlowRemove(EntityUid uid, SlowedDownComponent component, ComponentRemove args) private void OnSlowRemove(EntityUid uid, SlowedDownComponent component, ComponentShutdown args)
{ {
_movementSpeedModifierSystem.RefreshMovementSpeedModifiers(uid); _movementSpeedModifierSystem.RefreshMovementSpeedModifiers(uid);
} }

View File

@@ -384,11 +384,11 @@ public abstract partial class SharedGunSystem : EntitySystem
{ {
public List<(EntityCoordinates coordinates, Angle angle, SpriteSpecifier Sprite, float Distance)> Sprites = new(); public List<(EntityCoordinates coordinates, Angle angle, SpriteSpecifier Sprite, float Distance)> Sprites = new();
} }
}
public enum EffectLayers : byte public enum EffectLayers : byte
{ {
Unshaded, Unshaded,
}
} }
[Serializable, NetSerializable] [Serializable, NetSerializable]

View File

@@ -0,0 +1,235 @@
- type: entity
id: JetpackEffect
noSpawn: true
components:
- type: TimedDespawn
lifetime: 2
- type: Sprite
netsync: false
drawdepth: Effects
noRot: true
layers:
- shader: unshaded
map: ["enum.EffectLayers.Unshaded"]
sprite: Effects/atmospherics.rsi
state: freon_old
- type: EffectVisuals
- type: AnimationPlayer
- type: entity
parent: GasTankBase
abstract: true
id: BaseJetpack
name: Jetpack
description: It's a jetpack.
components:
- type: Sprite
sprite: Objects/Tanks/Jetpacks/blue.rsi
state: icon
netsync: false
- type: Item
size: 100
- type: UserInterface
interfaces:
- key: enum.SharedGasTankUiKey.Key
type: GasTankBoundUserInterface
- type: Clothing
sprite: Objects/Tanks/Jetpacks/blue.rsi
QuickEquip: false
size: 100
Slots:
- Back
- type: GasTank
outputPressure: 21.27825
air:
volume: 70
temperature: 293.15
- type: Jetpack
toggleAction:
icon:
sprite: Objects/Tanks/Jetpacks/blue.rsi
state: icon
iconOn:
sprite: Objects/Tanks/Jetpacks/blue.rsi
state: icon-on
name: action-name-jetpack-toggle
description: action-decription-jetpack-toggle
itemIconStyle: NoItem
event: !type:ToggleJetpackEvent
- type: Appearance
#Empty blue
- type: entity
id: JetpackBlue
parent: BaseJetpack
name: jetpack
suffix: Empty
components:
- type: Sprite
sprite: Objects/Tanks/Jetpacks/blue.rsi
- type: Clothing
sprite: Objects/Tanks/Jetpacks/blue.rsi
Slots:
- Back
# Filled blue
- type: entity
id: JetpackBlueFilled
parent: JetpackBlue
name: jetpack
suffix: Filled
components:
- type: GasTank
outputPressure: 21.27825
air:
volume: 70
temperature: 293.15
moles:
- 22.6293856
#Empty black
- type: entity
id: JetpackBlack
parent: BaseJetpack
name: jetpack
suffix: Empty
components:
- type: Sprite
sprite: Objects/Tanks/Jetpacks/black.rsi
- type: Clothing
sprite: Objects/Tanks/Jetpacks/black.rsi
Slots:
- Back
# Filled black
- type: entity
id: JetpackBlackFilled
parent: JetpackBlack
name: jetpack
suffix: Filled
components:
- type: GasTank
outputPressure: 21.27825
air:
volume: 70
temperature: 293.15
moles:
- 22.6293856
#Empty captain
- type: entity
id: JetpackCaptain
parent: BaseJetpack
name: captain's jetpack
suffix: Empty
components:
- type: Sprite
sprite: Objects/Tanks/Jetpacks/captain.rsi
- type: Clothing
size: 30
sprite: Objects/Tanks/Jetpacks/captain.rsi
Slots:
- Back
# Filled captain
- type: entity
id: JetpackCaptainFilled
parent: JetpackCaptain
name: captain's jetpack
suffix: Filled
components:
- type: GasTank
outputPressure: 21.27825
air:
volume: 70
temperature: 293.15
moles:
- 22.6293856
#Empty mini
- type: entity
id: JetpackMini
parent: BaseJetpack
name: mini jetpack
suffix: Empty
components:
- type: Sprite
sprite: Objects/Tanks/Jetpacks/mini.rsi
- type: Clothing
size: 50
sprite: Objects/Tanks/Jetpacks/mini.rsi
Slots:
- Back
# Filled mini
- type: entity
id: JetpackMiniFilled
parent: JetpackMini
name: mini jetpack
suffix: Filled
components:
- type: GasTank
outputPressure: 21.27825
air:
temperature: 293.15
volume: 2
moles:
- 0.323460326
#Empty security
- type: entity
id: JetpackSecurity
parent: BaseJetpack
name: security jetpack
suffix: Empty
components:
- type: Sprite
sprite: Objects/Tanks/Jetpacks/security.rsi
- type: Clothing
sprite: Objects/Tanks/Jetpacks/security.rsi
Slots:
- Back
#Filled security
- type: entity
id: JetpackSecurityFilled
parent: JetpackSecurity
name: security jetpack
suffix: Filled
components:
- type: GasTank
outputPressure: 21.27825
air:
volume: 70
temperature: 293.15
moles:
- 22.6293856
#Empty void
- type: entity
id: JetpackVoid
parent: BaseJetpack
name: void jetpack
suffix: Empty
components:
- type: Sprite
sprite: Objects/Tanks/Jetpacks/void.rsi
- type: Clothing
sprite: Objects/Tanks/Jetpacks/void.rsi
Slots:
- Back
# Filled void
- type: entity
id: JetpackVoidFilled
parent: JetpackVoid
name: void jetpack
suffix: Filled
components:
- type: GasTank
outputPressure: 21.27825
air:
volume: 70
temperature: 293.15
moles:
- 22.6293856

Binary file not shown.

After

Width:  |  Height:  |  Size: 810 B

Binary file not shown.

After

Width:  |  Height:  |  Size: 580 B

Binary file not shown.

After

Width:  |  Height:  |  Size: 461 B

Binary file not shown.

After

Width:  |  Height:  |  Size: 516 B

Binary file not shown.

After

Width:  |  Height:  |  Size: 529 B

View File

@@ -0,0 +1,59 @@
{
"version": 1,
"license": "CC-BY-SA-3.0",
"copyright": "Taken from tgstation at commit https://github.com/tgstation/tgstation/commit/1592a112e3d33eec4a0704b518a138d5a976f455",
"size": {
"x": 32,
"y": 32
},
"states": [
{
"name": "icon",
"directions": 1
},
{
"name": "icon-on",
"directions": 1,
"delays": [
[
0.2,
0.2
]
]
},
{
"name": "inhand-left",
"directions": 4
},
{
"name": "inhand-right",
"directions": 4
},
{
"name": "equipped-BACKPACK",
"directions": 4
},
{
"name": "on-equipped-BACKPACK",
"directions": 4,
"delays": [
[
0.2,
0.2
],
[
0.2,
0.2
],
[
0.2,
0.2
],
[
0.2,
0.2
]
]
}
]
}

Binary file not shown.

After

Width:  |  Height:  |  Size: 1.1 KiB

Binary file not shown.

After

Width:  |  Height:  |  Size: 835 B

Binary file not shown.

After

Width:  |  Height:  |  Size: 592 B

Binary file not shown.

After

Width:  |  Height:  |  Size: 476 B

Binary file not shown.

After

Width:  |  Height:  |  Size: 534 B

Binary file not shown.

After

Width:  |  Height:  |  Size: 555 B

View File

@@ -0,0 +1,59 @@
{
"version": 1,
"license": "CC-BY-SA-3.0",
"copyright": "Taken from tgstation at commit https://github.com/tgstation/tgstation/commit/1592a112e3d33eec4a0704b518a138d5a976f455",
"size": {
"x": 32,
"y": 32
},
"states": [
{
"name": "icon",
"directions": 1
},
{
"name": "icon-on",
"directions": 1,
"delays": [
[
0.2,
0.2
]
]
},
{
"name": "inhand-left",
"directions": 4
},
{
"name": "inhand-right",
"directions": 4
},
{
"name": "equipped-BACKPACK",
"directions": 4
},
{
"name": "on-equipped-BACKPACK",
"directions": 4,
"delays": [
[
0.2,
0.2
],
[
0.2,
0.2
],
[
0.2,
0.2
],
[
0.2,
0.2
]
]
}
]
}

Binary file not shown.

After

Width:  |  Height:  |  Size: 1.0 KiB

Binary file not shown.

After

Width:  |  Height:  |  Size: 838 B

Binary file not shown.

After

Width:  |  Height:  |  Size: 599 B

Binary file not shown.

After

Width:  |  Height:  |  Size: 508 B

Binary file not shown.

After

Width:  |  Height:  |  Size: 530 B

Binary file not shown.

After

Width:  |  Height:  |  Size: 551 B

View File

@@ -0,0 +1,59 @@
{
"version": 1,
"license": "CC-BY-SA-3.0",
"copyright": "Taken from tgstation at commit https://github.com/tgstation/tgstation/commit/1592a112e3d33eec4a0704b518a138d5a976f455",
"size": {
"x": 32,
"y": 32
},
"states": [
{
"name": "icon",
"directions": 1
},
{
"name": "icon-on",
"directions": 1,
"delays": [
[
0.2,
0.2
]
]
},
{
"name": "inhand-left",
"directions": 4
},
{
"name": "inhand-right",
"directions": 4
},
{
"name": "equipped-BACKPACK",
"directions": 4
},
{
"name": "on-equipped-BACKPACK",
"directions": 4,
"delays": [
[
0.2,
0.2
],
[
0.2,
0.2
],
[
0.2,
0.2
],
[
0.2,
0.2
]
]
}
]
}

Binary file not shown.

After

Width:  |  Height:  |  Size: 1.1 KiB

Binary file not shown.

After

Width:  |  Height:  |  Size: 1021 B

Binary file not shown.

After

Width:  |  Height:  |  Size: 1.4 KiB

Binary file not shown.

After

Width:  |  Height:  |  Size: 616 B

Binary file not shown.

After

Width:  |  Height:  |  Size: 516 B

Binary file not shown.

After

Width:  |  Height:  |  Size: 529 B

View File

@@ -0,0 +1,64 @@
{
"version": 1,
"license": "CC-BY-SA-3.0",
"copyright": "Taken from tgstation at commit https://github.com/tgstation/tgstation/commit/1592a112e3d33eec4a0704b518a138d5a976f455",
"size": {
"x": 32,
"y": 32
},
"states": [
{
"name": "icon",
"directions": 1
},
{
"name": "icon-on",
"directions": 1,
"delays": [
[
0.5,
0.1,
0.1
]
]
},
{
"name": "inhand-left",
"directions": 4
},
{
"name": "inhand-right",
"directions": 4
},
{
"name": "equipped-BACKPACK",
"directions": 4
},
{
"name": "on-equipped-BACKPACK",
"directions": 4,
"delays": [
[
0.5,
0.2,
0.1
],
[
0.5,
0.2,
0.1
],
[
0.5,
0.2,
0.1
],
[
0.5,
0.2,
0.1
]
]
}
]
}

Binary file not shown.

After

Width:  |  Height:  |  Size: 2.1 KiB

Binary file not shown.

After

Width:  |  Height:  |  Size: 839 B

Binary file not shown.

After

Width:  |  Height:  |  Size: 574 B

Binary file not shown.

After

Width:  |  Height:  |  Size: 479 B

Binary file not shown.

After

Width:  |  Height:  |  Size: 563 B

Binary file not shown.

After

Width:  |  Height:  |  Size: 564 B

View File

@@ -0,0 +1,59 @@
{
"version": 1,
"license": "CC-BY-SA-3.0",
"copyright": "Taken from tgstation at commit https://github.com/tgstation/tgstation/commit/1592a112e3d33eec4a0704b518a138d5a976f455",
"size": {
"x": 32,
"y": 32
},
"states": [
{
"name": "icon",
"directions": 1
},
{
"name": "icon-on",
"directions": 1,
"delays": [
[
0.2,
0.2
]
]
},
{
"name": "inhand-left",
"directions": 4
},
{
"name": "inhand-right",
"directions": 4
},
{
"name": "equipped-BACKPACK",
"directions": 4
},
{
"name": "on-equipped-BACKPACK",
"directions": 4,
"delays": [
[
0.2,
0.2
],
[
0.2,
0.2
],
[
0.2,
0.2
],
[
0.2,
0.2
]
]
}
]
}

Binary file not shown.

After

Width:  |  Height:  |  Size: 1.1 KiB

Some files were not shown because too many files have changed in this diff Show More