Skip to content
Open
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
46 changes: 43 additions & 3 deletions Content.Shared/Clothing/ClothingSpeedModifierSystem.cs
Original file line number Diff line number Diff line change
Expand Up @@ -25,6 +25,8 @@ public override void Initialize()
SubscribeLocalEvent<ClothingSpeedModifierComponent, ComponentGetState>(OnGetState);
SubscribeLocalEvent<ClothingSpeedModifierComponent, ComponentHandleState>(OnHandleState);
SubscribeLocalEvent<ClothingSpeedModifierComponent, InventoryRelayedEvent<RefreshMovementSpeedModifiersEvent>>(OnRefreshMoveSpeed);
SubscribeLocalEvent<ClothingSpeedModifierComponent, InventoryRelayedEvent<RefreshFrictionModifiersEvent>>(OnRefreshFriction); // Mono
SubscribeLocalEvent<ClothingSpeedModifierComponent, InventoryRelayedEvent<RefreshWeightlessModifiersEvent>>(OnRefreshWeightless); // Mono
SubscribeLocalEvent<ClothingSpeedModifierComponent, GetVerbsEvent<ExamineVerb>>(OnClothingVerbExamine);
SubscribeLocalEvent<ClothingSpeedModifierComponent, ItemToggledEvent>(OnToggled);
}
Expand All @@ -49,7 +51,7 @@ private void OnHandleState(EntityUid uid, ClothingSpeedModifierComponent compone
// We'll still set the values in case they're slightly different but within tolerance.
if (diff && _container.TryGetContainingContainer((uid, null, null), out var container))
{
_movementSpeed.RefreshMovementSpeedModifiers(container.Owner);
_movementSpeed.RefreshMovementSpeedModifiers(container.Owner, alsoFriction: true); // Mono
}
}

Expand All @@ -73,6 +75,44 @@ private void OnRefreshMoveSpeed(EntityUid uid, ClothingSpeedModifierComponent co
// DeltaV End - Introduce ClothingSlowResistance to Species
}

// Mono
private void OnRefreshFriction(Entity<ClothingSpeedModifierComponent> ent, ref InventoryRelayedEvent<RefreshFrictionModifiersEvent> args)
{
if (!_toggle.IsActivated(ent.Owner))
return;
Log.Info($"got");

if (_container.TryGetContainingContainer(ent.Owner, out var container))
{
var ev = new ModifyClothingSlowdownEvent(ent.Comp.WalkModifier, ent.Comp.SprintModifier);
RaiseLocalEvent(container.Owner, ref ev);
args.Args.ModifyAcceleration(ev.RunModifier);
}
else
{
args.Args.ModifyAcceleration(ent.Comp.SprintModifier);
}
}

// Mono
private void OnRefreshWeightless(Entity<ClothingSpeedModifierComponent> ent, ref InventoryRelayedEvent<RefreshWeightlessModifiersEvent> args)
{
if (!_toggle.IsActivated(ent.Owner))
return;
Log.Info($"got");

if (_container.TryGetContainingContainer(ent.Owner, out var container))
{
var ev = new ModifyClothingSlowdownEvent(ent.Comp.WalkModifier, ent.Comp.SprintModifier);
RaiseLocalEvent(container.Owner, ref ev);
args.Args.ModifyAcceleration(ev.RunModifier);
}
else
{
args.Args.ModifyAcceleration(ent.Comp.SprintModifier);
}
}

private void OnClothingVerbExamine(EntityUid uid, ClothingSpeedModifierComponent component, GetVerbsEvent<ExamineVerb> args)
{
if (!args.CanInteract || !args.CanAccess)
Expand Down Expand Up @@ -128,12 +168,12 @@ private void OnClothingVerbExamine(EntityUid uid, ClothingSpeedModifierComponent
private void OnToggled(Entity<ClothingSpeedModifierComponent> ent, ref ItemToggledEvent args)
{
// make sentient boots slow or fast too
_movementSpeed.RefreshMovementSpeedModifiers(ent);
_movementSpeed.RefreshMovementSpeedModifiers(ent, alsoFriction: true); // Mono

if (_container.TryGetContainingContainer((ent.Owner, null, null), out var container))
{
// inventory system will automatically hook into the event raised by this and update accordingly
_movementSpeed.RefreshMovementSpeedModifiers(container.Owner);
_movementSpeed.RefreshMovementSpeedModifiers(container.Owner, alsoFriction: true); // Mono
}
}
}
4 changes: 2 additions & 2 deletions Content.Shared/Inventory/InventorySystem.Equip.cs
Original file line number Diff line number Diff line change
Expand Up @@ -195,7 +195,7 @@ public bool TryEquip(EntityUid actor, EntityUid target, EntityUid itemUid, strin

Dirty(target, inventory);

_movementSpeed.RefreshMovementSpeedModifiers(target);
_movementSpeed.RefreshMovementSpeedModifiers(target, alsoFriction: true); // Mono

return true;
}
Expand Down Expand Up @@ -519,7 +519,7 @@ private bool TryUnequip(

Dirty(target, inventory);

_movementSpeed.RefreshMovementSpeedModifiers(target);
_movementSpeed.RefreshMovementSpeedModifiers(target, alsoFriction: true); // Mono

return true;
}
Expand Down
1 change: 1 addition & 0 deletions Content.Shared/Inventory/InventorySystem.Relay.cs
Original file line number Diff line number Diff line change
Expand Up @@ -53,6 +53,7 @@ public void InitializeRelay()

// by-ref events
SubscribeLocalEvent<InventoryComponent, RefreshFrictionModifiersEvent>(RefRelayInventoryEvent);
SubscribeLocalEvent<InventoryComponent, RefreshWeightlessModifiersEvent>(RefRelayInventoryEvent); // Mono
SubscribeLocalEvent<InventoryComponent, GetExplosionResistanceEvent>(RefRelayInventoryEvent);
SubscribeLocalEvent<InventoryComponent, IsWeightlessEvent>(RefRelayInventoryEvent);
SubscribeLocalEvent<InventoryComponent, GetSpeedModifierContactCapEvent>(RefRelayInventoryEvent);
Expand Down
13 changes: 11 additions & 2 deletions Content.Shared/Movement/Systems/MovementSpeedModifierSystem.cs
Original file line number Diff line number Diff line change
Expand Up @@ -77,7 +77,8 @@ public void RefreshWeightlessModifiers(EntityUid uid, MovementSpeedModifierCompo
Dirty(uid, move);
}

public void RefreshMovementSpeedModifiers(EntityUid uid, MovementSpeedModifierComponent? move = null)
public void RefreshMovementSpeedModifiers(EntityUid uid, MovementSpeedModifierComponent? move = null,
bool alsoFriction = false) // Mono
{
if (!Resolve(uid, ref move, false))
return;
Expand All @@ -88,6 +89,13 @@ public void RefreshMovementSpeedModifiers(EntityUid uid, MovementSpeedModifierCo
var ev = new RefreshMovementSpeedModifiersEvent();
RaiseLocalEvent(uid, ev);

// Mono
if (alsoFriction)
{
RefreshFrictionModifiers(uid, move);
RefreshWeightlessModifiers(uid, move);
}

if (MathHelper.CloseTo(ev.WalkSpeedModifier, move.WalkSpeedModifier) &&
MathHelper.CloseTo(ev.SprintSpeedModifier, move.SprintSpeedModifier))
return;
Expand Down Expand Up @@ -173,7 +181,7 @@ public void ModifySpeed(float mod)
}

[ByRefEvent]
public record struct RefreshWeightlessModifiersEvent
public record struct RefreshWeightlessModifiersEvent : IInventoryRelayEvent // Mono
{
public float WeightlessAcceleration;
public float WeightlessAccelerationMod;
Expand Down Expand Up @@ -207,6 +215,7 @@ public void ModifyAcceleration(float modifier)
{
ModifyAcceleration(modifier, modifier);
}
SlotFlags IInventoryRelayEvent.TargetSlots => ~SlotFlags.POCKET;
}
[ByRefEvent]
public record struct RefreshFrictionModifiersEvent : IInventoryRelayEvent
Expand Down
Loading