2024-01-28 18:18:54 +07:00
|
|
|
|
using Content.Server._White.Cult.Items.Components;
|
2024-01-27 15:19:52 +03:00
|
|
|
|
using Content.Shared.Damage;
|
|
|
|
|
|
using Content.Shared.Inventory.Events;
|
|
|
|
|
|
using Content.Shared.Movement.Components;
|
|
|
|
|
|
using Content.Shared.Movement.Systems;
|
2024-01-28 18:37:24 +07:00
|
|
|
|
using Content.Shared._White.Cult;
|
2024-01-29 01:02:37 +07:00
|
|
|
|
using CultistComponent = Content.Shared._White.Cult.Components.CultistComponent;
|
2024-01-27 15:19:52 +03:00
|
|
|
|
|
2024-01-28 18:18:54 +07:00
|
|
|
|
namespace Content.Server._White.Cult.Items.Systems;
|
2024-01-27 15:19:52 +03:00
|
|
|
|
|
|
|
|
|
|
public sealed class CultRobeModifierSystem : EntitySystem
|
|
|
|
|
|
{
|
|
|
|
|
|
[Dependency] private readonly MovementSpeedModifierSystem _movement = default!;
|
|
|
|
|
|
[Dependency] private readonly DamageableSystem _damageable = default!;
|
|
|
|
|
|
|
|
|
|
|
|
public override void Initialize()
|
|
|
|
|
|
{
|
|
|
|
|
|
base.Initialize();
|
|
|
|
|
|
|
|
|
|
|
|
SubscribeLocalEvent<CultRobeModifierComponent, GotEquippedEvent>(OnEquip);
|
|
|
|
|
|
SubscribeLocalEvent<CultRobeModifierComponent, GotUnequippedEvent>(OnUnequip);
|
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
|
|
private void OnEquip(EntityUid uid, CultRobeModifierComponent component, GotEquippedEvent args)
|
|
|
|
|
|
{
|
|
|
|
|
|
if (!HasComp<CultistComponent>(args.Equipee))
|
|
|
|
|
|
return;
|
|
|
|
|
|
|
|
|
|
|
|
if (args.Slot != "outerClothing")
|
|
|
|
|
|
return;
|
|
|
|
|
|
|
2024-06-20 16:24:10 +00:00
|
|
|
|
component.Active = true;
|
|
|
|
|
|
|
2024-01-27 15:19:52 +03:00
|
|
|
|
ModifySpeed(args.Equipee, component, true);
|
|
|
|
|
|
ModifyDamage(args.Equipee, component, true);
|
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
|
|
private void OnUnequip(EntityUid uid, CultRobeModifierComponent component, GotUnequippedEvent args)
|
|
|
|
|
|
{
|
2024-06-20 16:24:10 +00:00
|
|
|
|
if (!component.Active)
|
2024-01-27 15:19:52 +03:00
|
|
|
|
return;
|
|
|
|
|
|
|
|
|
|
|
|
if (args.Slot != "outerClothing")
|
|
|
|
|
|
return;
|
|
|
|
|
|
|
2024-06-20 16:24:10 +00:00
|
|
|
|
component.Active = false;
|
|
|
|
|
|
|
2024-01-27 15:19:52 +03:00
|
|
|
|
ModifySpeed(args.Equipee, component, false);
|
|
|
|
|
|
ModifyDamage(args.Equipee, component, false);
|
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
|
|
private void ModifySpeed(EntityUid uid, CultRobeModifierComponent comp, bool increase)
|
|
|
|
|
|
{
|
|
|
|
|
|
if (!TryComp<MovementSpeedModifierComponent>(uid, out var move))
|
|
|
|
|
|
return;
|
|
|
|
|
|
|
|
|
|
|
|
var walkSpeed = increase ? move.BaseWalkSpeed * comp.SpeedModifier : move.BaseWalkSpeed / comp.SpeedModifier;
|
|
|
|
|
|
|
|
|
|
|
|
var sprintSpeed =
|
|
|
|
|
|
increase ? move.BaseSprintSpeed * comp.SpeedModifier : move.BaseSprintSpeed / comp.SpeedModifier;
|
|
|
|
|
|
|
|
|
|
|
|
_movement.ChangeBaseSpeed(uid, walkSpeed, sprintSpeed, move.Acceleration, move);
|
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
|
|
private void ModifyDamage(EntityUid uid, CultRobeModifierComponent comp, bool increase)
|
|
|
|
|
|
{
|
|
|
|
|
|
var damageSet = string.Empty;
|
|
|
|
|
|
if (increase)
|
|
|
|
|
|
{
|
|
|
|
|
|
if (!TryComp<DamageableComponent>(uid, out var damage))
|
|
|
|
|
|
return;
|
|
|
|
|
|
|
|
|
|
|
|
comp.StoredDamageSetId = damage.DamageModifierSetId;
|
|
|
|
|
|
damageSet = comp.DamageModifierSetId;
|
|
|
|
|
|
}
|
|
|
|
|
|
else
|
|
|
|
|
|
{
|
|
|
|
|
|
if (comp.StoredDamageSetId != null)
|
|
|
|
|
|
damageSet = comp.StoredDamageSetId;
|
|
|
|
|
|
|
|
|
|
|
|
comp.StoredDamageSetId = null;
|
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
|
|
_damageable.SetDamageModifierSetId(uid, damageSet);
|
|
|
|
|
|
}
|
|
|
|
|
|
}
|