Merge branch 'master' of https://github.com/frosty-dev/ss14-core
This commit is contained in:
@@ -51,6 +51,14 @@ public sealed partial class ItemToggleComponent : Component
|
||||
/// </summary>
|
||||
[ViewVariables(VVAccess.ReadWrite), DataField, AutoNetworkedField]
|
||||
public bool ToggleLight = true;
|
||||
|
||||
// WD added start
|
||||
[DataField]
|
||||
public string ActivatedDescription = "comp-item-toggle-on"; // fallback/standard text
|
||||
|
||||
[DataField]
|
||||
public string DeactivatedDescription = "comp-item-toggle-off"; // fallback/standard text
|
||||
// WD added end
|
||||
}
|
||||
|
||||
/// <summary>
|
||||
|
||||
@@ -1,3 +1,4 @@
|
||||
using Content.Shared.Examine;
|
||||
using Content.Shared.Interaction.Events;
|
||||
using Content.Shared.Item.ItemToggle.Components;
|
||||
using Content.Shared.Popups;
|
||||
@@ -23,6 +24,8 @@ public abstract class SharedItemToggleSystem : EntitySystem
|
||||
[Dependency] private readonly INetManager _netManager = default!;
|
||||
[Dependency] private readonly SharedPopupSystem _popup = default!;
|
||||
|
||||
[Dependency] private readonly SharedItemSystem _item = default!; // WD
|
||||
|
||||
public override void Initialize()
|
||||
{
|
||||
base.Initialize();
|
||||
@@ -35,6 +38,9 @@ public abstract class SharedItemToggleSystem : EntitySystem
|
||||
SubscribeLocalEvent<ItemToggleHotComponent, IsHotEvent>(OnIsHotEvent);
|
||||
|
||||
SubscribeLocalEvent<ItemToggleActiveSoundComponent, ItemToggledEvent>(UpdateActiveSound);
|
||||
|
||||
SubscribeLocalEvent<ItemToggleComponent, ExaminedEvent>(OnExamined); // WD
|
||||
SubscribeLocalEvent<ItemToggleComponent, ItemToggledEvent>(UpdatePrefix); // WD
|
||||
}
|
||||
|
||||
private void OnStartup(Entity<ItemToggleComponent> ent, ref ComponentStartup args)
|
||||
@@ -255,4 +261,21 @@ public abstract class SharedItemToggleSystem : EntitySystem
|
||||
activeSound.PlayingStream = _audio.Stop(activeSound.PlayingStream);
|
||||
}
|
||||
}
|
||||
|
||||
// WD added start
|
||||
private void OnExamined(Entity<ItemToggleComponent> ent, ref ExaminedEvent args)
|
||||
{
|
||||
var onMsg = IsActivated(ent.Owner)
|
||||
? Loc.GetString(ent.Comp.ActivatedDescription)
|
||||
: Loc.GetString(ent.Comp.DeactivatedDescription);
|
||||
|
||||
args.PushMarkup(onMsg);
|
||||
}
|
||||
|
||||
private void UpdatePrefix(Entity<ItemToggleComponent> ent, ref ItemToggledEvent args)
|
||||
{
|
||||
_item.SetHeldPrefix(ent.Owner, args.Activated ? "on" : "off");
|
||||
}
|
||||
|
||||
// WD added end
|
||||
}
|
||||
|
||||
@@ -63,6 +63,21 @@ public sealed class RCDAmmoSystem : EntitySystem
|
||||
|
||||
var user = args.User;
|
||||
args.Handled = true;
|
||||
|
||||
// WD edit start
|
||||
TryComp<StackComponent>(uid, out var stackComponent);
|
||||
if (stackComponent != null)
|
||||
{
|
||||
var realValue = (int) (stackComponent.Count * comp.ChargeCountModifier);
|
||||
comp.Charges = realValue;
|
||||
if (realValue == 0)
|
||||
{
|
||||
_popup.PopupClient(Loc.GetString("rcd-ammo-component-after-interact-not-enough"), target, user);
|
||||
return;
|
||||
}
|
||||
}
|
||||
// WD edit end
|
||||
|
||||
var count = Math.Min(charges.MaxCharges - charges.Charges, comp.Charges);
|
||||
if (count <= 0)
|
||||
{
|
||||
@@ -73,7 +88,7 @@ public sealed class RCDAmmoSystem : EntitySystem
|
||||
_popup.PopupClient(Loc.GetString("rcd-ammo-component-after-interact-refilled"), target, user);
|
||||
|
||||
// WD edit start
|
||||
if (TryComp<StackComponent>(uid, out var stackComponent))
|
||||
if (stackComponent != null)
|
||||
{
|
||||
var spent = (int) (count / comp.ChargeCountModifier) == 0 ? 1 : (int) (count / comp.ChargeCountModifier);
|
||||
_stack.SetCount(uid, stackComponent.Count - spent);
|
||||
|
||||
@@ -26,25 +26,25 @@ public sealed partial class IonStormTargetComponent : Component
|
||||
/// Chance to replace the lawset with a random one
|
||||
/// </summary>
|
||||
[DataField, ViewVariables(VVAccess.ReadWrite)]
|
||||
public float RandomLawsetChance = 0.40f; // WD was 0.25f
|
||||
public float RandomLawsetChance = 0.25f;
|
||||
|
||||
/// <summary>
|
||||
/// Chance to remove a random law.
|
||||
/// </summary>
|
||||
[DataField, ViewVariables(VVAccess.ReadWrite)]
|
||||
public float RemoveChance = 0.15f; // WD was 0.20f
|
||||
public float RemoveChance = 0.20f;
|
||||
|
||||
/// <summary>
|
||||
/// Chance to replace a random law with the new one, rather than have it be a glitched-order law.
|
||||
/// </summary>
|
||||
[DataField, ViewVariables(VVAccess.ReadWrite)]
|
||||
public float ReplaceChance = 0.15f; // WD was 0.20f
|
||||
public float ReplaceChance = 0.20f;
|
||||
|
||||
/// <summary>
|
||||
/// Chance to shuffle laws after everything is done.
|
||||
/// </summary>
|
||||
[DataField, ViewVariables(VVAccess.ReadWrite)]
|
||||
public float ShuffleChance = 0.15f; // WD was 0.20f
|
||||
public float ShuffleChance = 0.20f;
|
||||
}
|
||||
|
||||
/// <summary>
|
||||
|
||||
@@ -123,6 +123,30 @@ namespace Content.Shared.StatusEffect
|
||||
return false;
|
||||
}
|
||||
|
||||
// WD added start
|
||||
// May god forgive us
|
||||
public bool TryAddStatusEffect<T>(EntityUid uid, string key, TimeSpan time, bool refresh, Component component,
|
||||
StatusEffectsComponent? status = null)
|
||||
where T : IComponent, new()
|
||||
{
|
||||
if (!Resolve(uid, ref status, false))
|
||||
return false;
|
||||
|
||||
if (TryAddStatusEffect(uid, key, time, refresh, status))
|
||||
{
|
||||
// If they already have the comp, we just won't bother updating anything.
|
||||
if (!EntityManager.HasComponent<T>(uid))
|
||||
{
|
||||
EntityManager.AddComponent(uid, component);
|
||||
status.ActiveEffects[key].RelevantComponent = _componentFactory.GetComponentName(component.GetType());
|
||||
}
|
||||
return true;
|
||||
}
|
||||
|
||||
return false;
|
||||
}
|
||||
// WD added end
|
||||
|
||||
public bool TryAddStatusEffect(EntityUid uid, string key, TimeSpan time, bool refresh, string component,
|
||||
StatusEffectsComponent? status = null)
|
||||
{
|
||||
|
||||
@@ -1,18 +1,24 @@
|
||||
using Content.Shared.Standing.Systems;
|
||||
using Robust.Shared.Audio;
|
||||
using Robust.Shared.GameStates;
|
||||
using Robust.Shared.Serialization;
|
||||
|
||||
namespace Content.Shared.Stunnable;
|
||||
|
||||
[RegisterComponent, NetworkedComponent, AutoGenerateComponentState, Access(typeof(SharedStunSystem))]
|
||||
public sealed partial class KnockedDownComponent : Component
|
||||
{
|
||||
[DataField("helpInterval"), AutoNetworkedField]
|
||||
[DataField, AutoNetworkedField]
|
||||
public float HelpInterval = 1f;
|
||||
|
||||
[DataField("helpAttemptSound")]
|
||||
[DataField]
|
||||
public SoundSpecifier StunAttemptSound = new SoundPathSpecifier("/Audio/Effects/thudswoosh.ogg");
|
||||
|
||||
[ViewVariables, AutoNetworkedField]
|
||||
public float HelpTimer = 0f;
|
||||
|
||||
// WD added start
|
||||
// Holy shit why is this so long
|
||||
[DataField, AutoNetworkedField]
|
||||
public SharedStandingStateSystem.DropHeldItemsBehavior KnockDownBehavior = SharedStandingStateSystem.DropHeldItemsBehavior.DropIfStanding;
|
||||
// WD added end
|
||||
}
|
||||
|
||||
@@ -106,25 +106,25 @@ public abstract class SharedStunSystem : EntitySystem
|
||||
|
||||
private void OnKnockInit(EntityUid uid, KnockedDownComponent component, ComponentInit args)
|
||||
{
|
||||
RaiseNetworkEvent(new CheckAutoGetUpEvent()); // WD EDIT
|
||||
_standingState.TryLieDown(uid, null, SharedStandingStateSystem.DropHeldItemsBehavior.DropIfStanding);
|
||||
RaiseNetworkEvent(new CheckAutoGetUpEvent()); // WD edit
|
||||
_standingState.TryLieDown(uid, null, component.KnockDownBehavior); // WD edit
|
||||
}
|
||||
|
||||
private void OnKnockShutdown(EntityUid uid, KnockedDownComponent component, ComponentShutdown args)
|
||||
{
|
||||
// WD EDIT START
|
||||
// WD edit start
|
||||
// Don't stand up if we can lie down via keybind
|
||||
if (!TryComp(uid, out StandingStateComponent? standing) || !(!standing.CanLieDown || standing.AutoGetUp)) // WD EDIT
|
||||
if (!TryComp(uid, out StandingStateComponent? standing) || !(!standing.CanLieDown || standing.AutoGetUp)) // WD edit
|
||||
return;
|
||||
|
||||
if (standing.AutoGetUp && !_container.IsEntityInContainer(uid)) // WD EDIT
|
||||
if (standing.AutoGetUp && !_container.IsEntityInContainer(uid)) // WD edit
|
||||
{
|
||||
_standingState.TryStandUp(uid, standing);
|
||||
return;
|
||||
}
|
||||
|
||||
_standingState.Stand(uid, standing);
|
||||
// WD EDIT END
|
||||
// WD edit end
|
||||
}
|
||||
|
||||
private void OnStandAttempt(EntityUid uid, KnockedDownComponent component, StandAttemptEvent args)
|
||||
@@ -178,7 +178,7 @@ public abstract class SharedStunSystem : EntitySystem
|
||||
/// Knocks down the entity, making it fall to the ground.
|
||||
/// </summary>
|
||||
public bool TryKnockdown(EntityUid uid, TimeSpan time, bool refresh,
|
||||
StatusEffectsComponent? status = null)
|
||||
StatusEffectsComponent? status = null, SharedStandingStateSystem.DropHeldItemsBehavior? behavior = null)
|
||||
{
|
||||
if (time <= TimeSpan.Zero)
|
||||
return false;
|
||||
@@ -186,8 +186,24 @@ public abstract class SharedStunSystem : EntitySystem
|
||||
if (!Resolve(uid, ref status, false))
|
||||
return false;
|
||||
|
||||
if (!_statusEffect.TryAddStatusEffect<KnockedDownComponent>(uid, "KnockedDown", time, refresh))
|
||||
return false;
|
||||
// WD added start
|
||||
// May god forgive us
|
||||
if (behavior.HasValue && !HasComp<KnockedDownComponent>(uid))
|
||||
{
|
||||
var knockedDownComponent = new KnockedDownComponent
|
||||
{
|
||||
KnockDownBehavior = behavior.Value
|
||||
};
|
||||
|
||||
if (!_statusEffect.TryAddStatusEffect<KnockedDownComponent>(uid, "KnockedDown", time, refresh, knockedDownComponent))
|
||||
return false;
|
||||
}
|
||||
else
|
||||
{
|
||||
if (!_statusEffect.TryAddStatusEffect<KnockedDownComponent>(uid, "KnockedDown", time, refresh))
|
||||
return false;
|
||||
}
|
||||
// WD added end
|
||||
|
||||
var ev = new KnockedDownEvent();
|
||||
RaiseLocalEvent(uid, ref ev);
|
||||
|
||||
@@ -48,7 +48,7 @@ public sealed partial class MeleeThrowOnHitComponent : Component
|
||||
[AutoNetworkedField]
|
||||
public bool Enabled = true;
|
||||
|
||||
// WD START
|
||||
// WD added
|
||||
[DataField, ViewVariables(VVAccess.ReadWrite)]
|
||||
[AutoNetworkedField]
|
||||
public float StunTime;
|
||||
@@ -56,7 +56,15 @@ public sealed partial class MeleeThrowOnHitComponent : Component
|
||||
[DataField, ViewVariables(VVAccess.ReadWrite)]
|
||||
[AutoNetworkedField]
|
||||
public bool ThrowOnThrowHit;
|
||||
// WD END
|
||||
|
||||
[DataField, ViewVariables(VVAccess.ReadWrite)]
|
||||
[AutoNetworkedField]
|
||||
public bool FallAfterHit;
|
||||
|
||||
[DataField, ViewVariables(VVAccess.ReadWrite)]
|
||||
[AutoNetworkedField]
|
||||
public bool RequireWield = true;
|
||||
// WD added
|
||||
}
|
||||
|
||||
/// <summary>
|
||||
|
||||
@@ -1,9 +1,11 @@
|
||||
using System.Numerics;
|
||||
using Content.Shared.Construction.Components;
|
||||
using Content.Shared.Standing.Systems;
|
||||
using Content.Shared.Stunnable;
|
||||
using Content.Shared.Throwing;
|
||||
using Content.Shared.Weapons.Melee.Components;
|
||||
using Content.Shared.Weapons.Melee.Events;
|
||||
using Content.Shared.Wieldable.Components;
|
||||
using Robust.Shared.Physics;
|
||||
using Robust.Shared.Physics.Components;
|
||||
using Robust.Shared.Physics.Events;
|
||||
@@ -20,8 +22,9 @@ public sealed class MeleeThrowOnHitSystem : EntitySystem
|
||||
[Dependency] private readonly IGameTiming _timing = default!;
|
||||
[Dependency] private readonly SharedTransformSystem _transform = default!;
|
||||
[Dependency] private readonly SharedPhysicsSystem _physics = default!;
|
||||
[Dependency] private readonly SharedStunSystem _stun = default!; // WD
|
||||
[Dependency] private readonly ThrownItemSystem _thrownItem = default!; // WD
|
||||
[Dependency] private readonly SharedStunSystem _stun = default!; // WD added
|
||||
[Dependency] private readonly ThrownItemSystem _thrownItem = default!; // WD added
|
||||
[Dependency] private readonly SharedStandingStateSystem _standingState = default!; // WD added
|
||||
|
||||
/// <inheritdoc/>
|
||||
public override void Initialize()
|
||||
@@ -36,8 +39,10 @@ public sealed class MeleeThrowOnHitSystem : EntitySystem
|
||||
|
||||
private void OnDoHit(Entity<MeleeThrowOnHitComponent> ent, ref ThrowDoHitEvent args) // WD
|
||||
{
|
||||
// WD edit start
|
||||
if (!ent.Comp.ThrowOnThrowHit)
|
||||
return;
|
||||
// WD edit end
|
||||
|
||||
if (!CanThrowOnHit(ent, args.Target))
|
||||
return;
|
||||
@@ -55,9 +60,15 @@ public sealed class MeleeThrowOnHitSystem : EntitySystem
|
||||
MinLifetime = ent.Comp.MinLifetime
|
||||
};
|
||||
AddComp(args.Target, thrownComp);
|
||||
|
||||
// WD added start
|
||||
if (ent.Comp.StunTime != 0f)
|
||||
_stun.TryParalyze(args.Target, TimeSpan.FromSeconds(ent.Comp.StunTime), true);
|
||||
|
||||
else if (ent.Comp.FallAfterHit)
|
||||
_standingState.TryLieDown(ent, null, SharedStandingStateSystem.DropHeldItemsBehavior.DropIfStanding);
|
||||
// WD added end
|
||||
|
||||
_thrownItem.LandComponent(ent, args.Component, physics, false);
|
||||
_physics.SetLinearVelocity(ent, Vector2.Zero);
|
||||
}
|
||||
@@ -67,14 +78,24 @@ public sealed class MeleeThrowOnHitSystem : EntitySystem
|
||||
if (args.Handled) // WD
|
||||
return;
|
||||
|
||||
var (_, comp) = ent;
|
||||
if (!args.IsHit)
|
||||
return;
|
||||
|
||||
// WD START
|
||||
var stunTime = comp.StunTime;
|
||||
var speed = comp.Speed;
|
||||
var lifetime = comp.Lifetime;
|
||||
// WD added start
|
||||
if (ent.Comp.RequireWield)
|
||||
{
|
||||
if (!TryComp<WieldableComponent>(args.Weapon, out var weapon))
|
||||
return;
|
||||
|
||||
if (!weapon.Wielded)
|
||||
return;
|
||||
}
|
||||
// WD added end
|
||||
|
||||
// WD edit start
|
||||
var stunTime = ent.Comp.StunTime;
|
||||
var speed = ent.Comp.Speed;
|
||||
var lifetime = ent.Comp.Lifetime;
|
||||
|
||||
if (args.Direction != null) // Heavy attack
|
||||
{
|
||||
@@ -82,7 +103,7 @@ public sealed class MeleeThrowOnHitSystem : EntitySystem
|
||||
speed *= 0.5f;
|
||||
lifetime *= 0.5f;
|
||||
}
|
||||
// WD END
|
||||
// WD edit end
|
||||
|
||||
var mapPos = _transform.GetMapCoordinates(args.User).Position;
|
||||
foreach (var hit in args.HitEntities)
|
||||
@@ -95,7 +116,7 @@ public sealed class MeleeThrowOnHitSystem : EntitySystem
|
||||
if (!CanThrowOnHit(ent, hit))
|
||||
continue;
|
||||
|
||||
if (comp.UnanchorOnHit && HasComp<AnchorableComponent>(hit))
|
||||
if (ent.Comp.UnanchorOnHit && HasComp<AnchorableComponent>(hit))
|
||||
{
|
||||
_transform.Unanchor(hit, Transform(hit));
|
||||
}
|
||||
@@ -105,13 +126,19 @@ public sealed class MeleeThrowOnHitSystem : EntitySystem
|
||||
RaiseLocalEvent(hit, ref ev);
|
||||
var thrownComp = new MeleeThrownComponent
|
||||
{
|
||||
Velocity = angle.Normalized() * speed, // WD EDIT
|
||||
Lifetime = lifetime, // WD EDIT
|
||||
MinLifetime = comp.MinLifetime
|
||||
Velocity = angle.Normalized() * speed, // WD edit
|
||||
Lifetime = lifetime, // WD edit
|
||||
MinLifetime = ent.Comp.MinLifetime
|
||||
};
|
||||
AddComp(hit, thrownComp);
|
||||
|
||||
// WD added end
|
||||
if (stunTime != 0f)
|
||||
_stun.TryParalyze(hit, TimeSpan.FromSeconds(stunTime), true);
|
||||
|
||||
else if (ent.Comp.FallAfterHit)
|
||||
_standingState.TryLieDown(hit);
|
||||
// WD added start
|
||||
}
|
||||
}
|
||||
|
||||
@@ -126,9 +153,11 @@ public sealed class MeleeThrowOnHitSystem : EntitySystem
|
||||
comp.PreviousStatus = body.BodyStatus;
|
||||
comp.ThrownEndTime = _timing.CurTime + TimeSpan.FromSeconds(comp.Lifetime);
|
||||
comp.MinLifetimeTime = _timing.CurTime + TimeSpan.FromSeconds(comp.MinLifetime);
|
||||
|
||||
_physics.SetBodyStatus(ent, body, BodyStatus.InAir);
|
||||
_physics.SetLinearVelocity(ent, Vector2.Zero, body: body);
|
||||
_physics.ApplyLinearImpulse(ent, comp.Velocity * body.Mass, body: body);
|
||||
|
||||
Dirty(ent, ent.Comp);
|
||||
}
|
||||
|
||||
|
||||
@@ -0,0 +1,17 @@
|
||||
using Content.Shared.Standing.Systems;
|
||||
using Robust.Shared.GameStates;
|
||||
|
||||
namespace Content.Shared._White.Item.KnockDownOnHit;
|
||||
|
||||
[RegisterComponent, NetworkedComponent]
|
||||
public sealed partial class KnockDownOnHitComponent : Component
|
||||
{
|
||||
[DataField, ViewVariables(VVAccess.ReadWrite)]
|
||||
public TimeSpan KnockdownTime = TimeSpan.FromSeconds(1.5f);
|
||||
|
||||
[DataField]
|
||||
public SharedStandingStateSystem.DropHeldItemsBehavior? KnockDownBehavior;
|
||||
|
||||
[DataField]
|
||||
public bool RequireWield;
|
||||
}
|
||||
@@ -0,0 +1,49 @@
|
||||
using Content.Shared.Damage.Events;
|
||||
using Content.Shared.Item.ItemToggle;
|
||||
using Content.Shared.Stunnable;
|
||||
using Content.Shared.Weapons.Melee.Events;
|
||||
using Content.Shared.Wieldable.Components;
|
||||
|
||||
namespace Content.Shared._White.Item.KnockDownOnHit;
|
||||
|
||||
public sealed class KnockDownOnHitSystem : EntitySystem
|
||||
{
|
||||
|
||||
[Dependency] private readonly SharedStunSystem _stun = default!;
|
||||
[Dependency] private readonly SharedItemToggleSystem _itemToggle = default!;
|
||||
|
||||
public override void Initialize()
|
||||
{
|
||||
base.Initialize();
|
||||
|
||||
SubscribeLocalEvent<KnockDownOnHitComponent, StaminaDamageOnHitAttemptEvent>(OnStaminaHitAttempt);
|
||||
SubscribeLocalEvent<KnockDownOnHitComponent, MeleeHitEvent>(OnHit);
|
||||
}
|
||||
|
||||
private void OnHit(Entity<KnockDownOnHitComponent> ent, ref MeleeHitEvent args)
|
||||
{
|
||||
var time = ent.Comp.KnockdownTime;
|
||||
if (time <= TimeSpan.Zero)
|
||||
return;
|
||||
|
||||
foreach (var uid in args.HitEntities)
|
||||
{
|
||||
if (ent.Comp.RequireWield)
|
||||
{
|
||||
if (!TryComp<WieldableComponent>(args.Weapon, out var weapon))
|
||||
continue;
|
||||
|
||||
if (!weapon.Wielded)
|
||||
continue;
|
||||
}
|
||||
|
||||
_stun.TryKnockdown(uid, time, true, behavior: ent.Comp.KnockDownBehavior);
|
||||
}
|
||||
}
|
||||
|
||||
private void OnStaminaHitAttempt(Entity<KnockDownOnHitComponent> entity, ref StaminaDamageOnHitAttemptEvent args)
|
||||
{
|
||||
if (!_itemToggle.IsActivated(entity.Owner))
|
||||
args.Cancelled = true;
|
||||
}
|
||||
}
|
||||
@@ -1,8 +0,0 @@
|
||||
namespace Content.Shared._White.Item.TelescopicBaton;
|
||||
|
||||
[RegisterComponent]
|
||||
public sealed partial class TelescopicBatonComponent : Component
|
||||
{
|
||||
[DataField, ViewVariables(VVAccess.ReadWrite)]
|
||||
public TimeSpan KnockdownTime = TimeSpan.FromSeconds(1.5f);
|
||||
}
|
||||
@@ -1,56 +0,0 @@
|
||||
using Content.Shared.Damage.Events;
|
||||
using Content.Shared.Examine;
|
||||
using Content.Shared.Item;
|
||||
using Content.Shared.Item.ItemToggle;
|
||||
using Content.Shared.Item.ItemToggle.Components;
|
||||
using Content.Shared.Stunnable;
|
||||
|
||||
namespace Content.Shared._White.Item.TelescopicBaton;
|
||||
|
||||
public sealed class TelescopicBatonSystem : EntitySystem
|
||||
{
|
||||
[Dependency] private readonly SharedItemSystem _item = default!;
|
||||
[Dependency] private readonly SharedStunSystem _stun = default!;
|
||||
[Dependency] private readonly SharedItemToggleSystem _itemToggle = default!;
|
||||
|
||||
public override void Initialize()
|
||||
{
|
||||
base.Initialize();
|
||||
|
||||
SubscribeLocalEvent<TelescopicBatonComponent, ExaminedEvent>(OnExamined);
|
||||
SubscribeLocalEvent<TelescopicBatonComponent, StaminaDamageOnHitAttemptEvent>(OnStaminaHitAttempt);
|
||||
SubscribeLocalEvent<TelescopicBatonComponent, ItemToggledEvent>(ToggleDone);
|
||||
SubscribeLocalEvent<TelescopicBatonComponent, StaminaMeleeHitEvent>(OnHit);
|
||||
}
|
||||
|
||||
private void OnHit(Entity<TelescopicBatonComponent> ent, ref StaminaMeleeHitEvent args)
|
||||
{
|
||||
var time = ent.Comp.KnockdownTime;
|
||||
if (time <= TimeSpan.Zero)
|
||||
return;
|
||||
|
||||
foreach (var (uid, _) in args.HitList)
|
||||
{
|
||||
_stun.TryKnockdown(uid, time, true);
|
||||
}
|
||||
}
|
||||
|
||||
private void OnStaminaHitAttempt(Entity<TelescopicBatonComponent> entity, ref StaminaDamageOnHitAttemptEvent args)
|
||||
{
|
||||
if (!_itemToggle.IsActivated(entity.Owner))
|
||||
args.Cancelled = true;
|
||||
}
|
||||
|
||||
private void OnExamined(Entity<TelescopicBatonComponent> entity, ref ExaminedEvent args)
|
||||
{
|
||||
var onMsg = _itemToggle.IsActivated(entity.Owner)
|
||||
? Loc.GetString("comp-telebaton-examined-on")
|
||||
: Loc.GetString("comp-telebaton-examined-off");
|
||||
args.PushMarkup(onMsg);
|
||||
}
|
||||
|
||||
private void ToggleDone(Entity<TelescopicBatonComponent> entity, ref ItemToggledEvent args)
|
||||
{
|
||||
_item.SetHeldPrefix(entity.Owner, args.Activated ? "on" : "off");
|
||||
}
|
||||
}
|
||||
Reference in New Issue
Block a user