Stunprod fixes & add new sprites (#334)
* - tweak: Cleanup snatcherprod and tentacle gun. * - fix: Cleanup StunprodSystem. * - add: Snatcherprod on inhand sprites.
This commit is contained in:
@@ -10,6 +10,7 @@ public sealed class SnatcherprodSystem : EntitySystem
|
||||
{
|
||||
[Dependency] private readonly SharedHandsSystem _hands = default!;
|
||||
[Dependency] private readonly SharedItemToggleSystem _itemToggle = default!;
|
||||
[Dependency] private readonly SharedHandsSystem _handsSystem = default!;
|
||||
|
||||
public override void Initialize()
|
||||
{
|
||||
@@ -18,7 +19,6 @@ public sealed class SnatcherprodSystem : EntitySystem
|
||||
SubscribeLocalEvent<SnatcherprodComponent, StaminaMeleeHitEvent>(OnHit);
|
||||
}
|
||||
|
||||
|
||||
private void OnHit(EntityUid uid, SnatcherprodComponent component, StaminaMeleeHitEvent args)
|
||||
{
|
||||
if (!_itemToggle.IsActivated(uid) || args.HitList.Count == 0)
|
||||
@@ -29,28 +29,13 @@ public sealed class SnatcherprodSystem : EntitySystem
|
||||
if (entity == uid || !TryComp(entity, out HandsComponent? hands))
|
||||
return;
|
||||
|
||||
EntityUid? heldEntity = null;
|
||||
|
||||
if (hands.ActiveHandEntity != null)
|
||||
heldEntity = hands.ActiveHandEntity;
|
||||
else
|
||||
foreach (var heldEntity in _handsSystem.EnumerateHeld(entity, hands))
|
||||
{
|
||||
foreach (var hand in hands.Hands)
|
||||
{
|
||||
if (hand.Value.HeldEntity == null)
|
||||
continue;
|
||||
if (!_hands.TryDrop(entity, heldEntity, null, false, false, handsComp: hands))
|
||||
continue;
|
||||
|
||||
heldEntity = hand.Value.HeldEntity;
|
||||
break;
|
||||
}
|
||||
|
||||
if (heldEntity == null)
|
||||
return;
|
||||
_hands.PickupOrDrop(args.User, heldEntity, false);
|
||||
break;
|
||||
}
|
||||
|
||||
if (!_hands.TryDrop(entity, heldEntity.Value, null, false, false, handsComp: hands))
|
||||
return;
|
||||
|
||||
_hands.PickupOrDrop(args.User, heldEntity.Value, false);
|
||||
}
|
||||
}
|
||||
|
||||
@@ -33,16 +33,20 @@ public sealed class StunprodSystem : EntitySystem
|
||||
SubscribeLocalEvent<StunprodComponent, EntInsertedIntoContainerMessage>(OnEntInserted);
|
||||
SubscribeLocalEvent<StunprodComponent, ItemToggleActivateAttemptEvent>(TryTurnOn);
|
||||
SubscribeLocalEvent<StunprodComponent, ItemToggledEvent>(ToggleDone);
|
||||
SubscribeLocalEvent<StunprodComponent, ComponentStartup>(OnStartup,
|
||||
after: new[] {typeof(SharedItemToggleSystem)});
|
||||
}
|
||||
|
||||
private void OnStartup(Entity<StunprodComponent> ent, ref ComponentStartup args)
|
||||
{
|
||||
_appearance.SetData(ent, ToggleVisuals.Toggled, "nocell");
|
||||
}
|
||||
|
||||
private void OnEntInserted(EntityUid uid, StunprodComponent component, EntInsertedIntoContainerMessage args)
|
||||
{
|
||||
_itemToggle.TryDeactivate(uid, predicted: false);
|
||||
|
||||
if (TryComp<AppearanceComponent>(uid, out var appearance))
|
||||
{
|
||||
_appearance.SetData(uid, ToggleVisuals.Toggled, false, appearance);
|
||||
}
|
||||
_appearance.SetData(uid, ToggleVisuals.Toggled, false);
|
||||
}
|
||||
|
||||
private void OnEntRemoved(EntityUid uid, StunprodComponent component, EntRemovedFromContainerMessage args)
|
||||
@@ -50,15 +54,9 @@ public sealed class StunprodSystem : EntitySystem
|
||||
if (TerminatingOrDeleted(uid))
|
||||
return;
|
||||
|
||||
if (!_itemToggle.IsActivated(uid))
|
||||
{
|
||||
if (TryComp<AppearanceComponent>(uid, out var appearance))
|
||||
{
|
||||
_appearance.SetData(uid, ToggleVisuals.Toggled, "nocell", appearance);
|
||||
}
|
||||
}
|
||||
else
|
||||
_itemToggle.TryDeactivate(uid, predicted: false);
|
||||
_itemToggle.TryDeactivate(uid, predicted: false);
|
||||
|
||||
_appearance.SetData(uid, ToggleVisuals.Toggled, "nocell");
|
||||
}
|
||||
|
||||
private void OnStaminaHitAttempt(EntityUid uid, StunprodComponent component,
|
||||
@@ -72,9 +70,7 @@ public sealed class StunprodSystem : EntitySystem
|
||||
}
|
||||
|
||||
if (battery.CurrentCharge < component.EnergyPerUse)
|
||||
{
|
||||
_itemToggle.TryDeactivate(uid, predicted: false);
|
||||
}
|
||||
}
|
||||
|
||||
private void OnExamined(EntityUid uid, StunprodComponent comp, ExaminedEvent args)
|
||||
@@ -90,10 +86,8 @@ public sealed class StunprodSystem : EntitySystem
|
||||
if (entity.Comp.HasHeldPrefix && TryComp<ItemComponent>(entity, out var item))
|
||||
_item.SetHeldPrefix(entity.Owner, args.Activated ? "on" : "off", component: item);
|
||||
|
||||
if (TryGetBatteryComponent(entity, out _, out _) || !TryComp<AppearanceComponent>(entity, out var appearance))
|
||||
return;
|
||||
|
||||
_appearance.SetData(entity, ToggleVisuals.Toggled, "nocell", appearance);
|
||||
if (!TryGetBatteryComponent(entity, out _, out _))
|
||||
_appearance.SetData(entity, ToggleVisuals.Toggled, "nocell");
|
||||
}
|
||||
|
||||
private void TryTurnOn(Entity<StunprodComponent> entity, ref ItemToggleActivateAttemptEvent args)
|
||||
@@ -104,10 +98,7 @@ public sealed class StunprodSystem : EntitySystem
|
||||
|
||||
args.Cancelled = true;
|
||||
|
||||
if (TryComp<AppearanceComponent>(entity, out var appearance))
|
||||
{
|
||||
_appearance.SetData(entity, ToggleVisuals.Toggled, battery == null ? "nocell" : false, appearance);
|
||||
}
|
||||
_appearance.SetData(entity, ToggleVisuals.Toggled, battery == null ? "nocell" : false);
|
||||
|
||||
if (args.User != null)
|
||||
{
|
||||
|
||||
Reference in New Issue
Block a user