Сломал колени
This commit is contained in:
27
Content.Shared/_White/_Engi/Limping/LimpingComponent.cs
Normal file
27
Content.Shared/_White/_Engi/Limping/LimpingComponent.cs
Normal file
@@ -0,0 +1,27 @@
|
||||
using Robust.Shared.GameStates;
|
||||
using Robust.Shared.Serialization;
|
||||
|
||||
namespace Content.Shared._White._Engi.Limping;
|
||||
|
||||
/// <summary>
|
||||
/// WD.
|
||||
/// This is used for the Limping trait.
|
||||
/// </summary>
|
||||
[RegisterComponent, NetworkedComponent]
|
||||
public sealed partial class LimpingComponent : Component
|
||||
{
|
||||
[DataField]
|
||||
public float SpeedModifier = 0.3f;
|
||||
|
||||
}
|
||||
|
||||
[Serializable, NetSerializable]
|
||||
public sealed class LimpingComponentState : ComponentState
|
||||
{
|
||||
public float SpeedModifier;
|
||||
|
||||
public LimpingComponentState(float speedModifier)
|
||||
{
|
||||
SpeedModifier = speedModifier;
|
||||
}
|
||||
}
|
||||
@@ -0,0 +1,11 @@
|
||||
namespace Content.Shared._White._Engi.Limping;
|
||||
|
||||
/// <summary>
|
||||
/// WD.
|
||||
/// This is used for the Limping trait to reduce it.
|
||||
/// </summary>
|
||||
[RegisterComponent]
|
||||
public sealed partial class LimpingHelperComponent : Component
|
||||
{
|
||||
|
||||
}
|
||||
80
Content.Shared/_White/_Engi/Limping/LimpingSystem.cs
Normal file
80
Content.Shared/_White/_Engi/Limping/LimpingSystem.cs
Normal file
@@ -0,0 +1,80 @@
|
||||
using Content.Shared.Hands;
|
||||
using Content.Shared.Movement.Systems;
|
||||
using Robust.Shared.Timing;
|
||||
using Robust.Shared.GameStates;
|
||||
using Robust.Shared.Containers;
|
||||
|
||||
namespace Content.Shared._White._Engi.Limping;
|
||||
|
||||
public sealed class LimpingSystem : EntitySystem
|
||||
{
|
||||
[Dependency] private readonly IGameTiming _gameTiming = default!;
|
||||
[Dependency] private readonly MovementSpeedModifierSystem _movementSpeed = default!;
|
||||
[Dependency] private readonly SharedContainerSystem _container = default!;
|
||||
|
||||
public override void Initialize()
|
||||
{
|
||||
SubscribeLocalEvent<LimpingHelperComponent, GotEquippedHandEvent>(OnGotEquipped);
|
||||
SubscribeLocalEvent<LimpingHelperComponent, GotUnequippedHandEvent>(OnGotUnequipped);
|
||||
|
||||
SubscribeLocalEvent<LimpingComponent, RefreshMovementSpeedModifiersEvent>(OnRefreshMoveSpeed);
|
||||
SubscribeLocalEvent<LimpingComponent, ComponentShutdown>(OnShutdown);
|
||||
|
||||
SubscribeLocalEvent<LimpingComponent, ComponentGetState>(OnGetState);
|
||||
SubscribeLocalEvent<LimpingComponent, ComponentHandleState>(OnHandleState);
|
||||
}
|
||||
|
||||
private void OnShutdown(Entity<LimpingComponent> ent, ref ComponentShutdown args)
|
||||
{
|
||||
_movementSpeed.RefreshMovementSpeedModifiers(ent);
|
||||
}
|
||||
|
||||
private void OnRefreshMoveSpeed(EntityUid uid, LimpingComponent component, RefreshMovementSpeedModifiersEvent args)
|
||||
{
|
||||
args.ModifySpeed(component.SpeedModifier, component.SpeedModifier);
|
||||
}
|
||||
|
||||
private void OnGotEquipped(Entity<LimpingHelperComponent> ent, ref GotEquippedHandEvent args)
|
||||
{
|
||||
if (_gameTiming.ApplyingState)
|
||||
return;
|
||||
|
||||
if (!TryComp<LimpingComponent>(args.User, out var comp))
|
||||
return;
|
||||
|
||||
if (_gameTiming.IsFirstTimePredicted)
|
||||
comp.SpeedModifier = 0.5f;
|
||||
|
||||
_movementSpeed.RefreshMovementSpeedModifiers(args.User);
|
||||
}
|
||||
|
||||
private void OnGotUnequipped(Entity<LimpingHelperComponent> ent, ref GotUnequippedHandEvent args)
|
||||
{
|
||||
if (!TryComp<LimpingComponent>(args.User, out var comp))
|
||||
return;
|
||||
|
||||
if (_gameTiming.IsFirstTimePredicted)
|
||||
comp.SpeedModifier = 0.3f;
|
||||
|
||||
_movementSpeed.RefreshMovementSpeedModifiers(args.User);
|
||||
}
|
||||
|
||||
private void OnGetState(EntityUid uid, LimpingComponent component, ref ComponentGetState args)
|
||||
{
|
||||
args.State = new LimpingComponentState(component.SpeedModifier);
|
||||
}
|
||||
|
||||
private void OnHandleState(EntityUid uid, LimpingComponent component, ref ComponentHandleState args)
|
||||
{
|
||||
if (args.Current is not LimpingComponentState state)
|
||||
return;
|
||||
|
||||
var diff = !MathHelper.CloseTo(component.SpeedModifier, state.SpeedModifier);
|
||||
|
||||
if (diff && _container.TryGetContainingContainer(uid, out var container))
|
||||
{
|
||||
component.SpeedModifier = state.SpeedModifier;
|
||||
_movementSpeed.RefreshMovementSpeedModifiers(container.Owner);
|
||||
}
|
||||
}
|
||||
}
|
||||
@@ -28,6 +28,7 @@
|
||||
Blunt: 3
|
||||
- type: UseDelay
|
||||
delay: 1
|
||||
- type: LimpingHelper # WD
|
||||
|
||||
- type: entity
|
||||
name: cane blade
|
||||
|
||||
@@ -79,3 +79,14 @@
|
||||
description: trait-snoring-desc
|
||||
components:
|
||||
- type: Snoring
|
||||
|
||||
- type: trait # WD
|
||||
id: Limping
|
||||
traitGear: Cane
|
||||
name: Хромота
|
||||
description: Слабость в ногах мешает вам нормально передвигаться, трость может немного помочь.
|
||||
blacklist:
|
||||
components:
|
||||
- BorgChassis
|
||||
components:
|
||||
- type: Limping
|
||||
|
||||
@@ -1,19 +1,9 @@
|
||||
- type: entity
|
||||
parent: BaseItem
|
||||
parent: Cane
|
||||
id: OldCane
|
||||
name: трость старика
|
||||
description: Изношенная деревянная трость.
|
||||
components:
|
||||
- type: Sprite
|
||||
sprite: Objects/Weapons/Melee/cane.rsi
|
||||
state: cane
|
||||
- type: Item
|
||||
size: Normal
|
||||
storedRotation: -44
|
||||
shape:
|
||||
- 0,0,0,2
|
||||
sprite: Objects/Weapons/Melee/cane.rsi
|
||||
- type: Appearance
|
||||
- type: MeleeWeapon
|
||||
wideAnimationRotation: 45
|
||||
damage:
|
||||
|
||||
Reference in New Issue
Block a user