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:
Aviu00
2024-06-06 11:30:00 +00:00
committed by GitHub
parent 19b3d5bcc9
commit e72db9d701
9 changed files with 70 additions and 50 deletions

View File

@@ -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);
}
}

View File

@@ -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)
{

View File

@@ -143,8 +143,8 @@ public abstract class SharedTentacleGun : EntitySystem
if(!TryComp<PhysicsComponent>(activeItem, out var physicsComponent))
continue;
var coords = Transform(args.Embedded).Coordinates;
_handsSystem.TryDrop(args.Embedded, activeItem, coords);
if (!_handsSystem.TryDrop(args.Embedded, activeItem))
continue;
var force = physicsComponent.Mass * 2.5f / 2;

View File

@@ -42,6 +42,7 @@
sound: /Audio/Weapons/egloves.ogg
- type: UseDelay
- type: Item
heldPrefix: off
size: Normal
- type: Clothing
quickEquip: false
@@ -70,7 +71,6 @@
cell_slot: !type:ContainerSlot {}
- type: Snatcherprod
- type: Stunprod
hasHeldPrefix: false
- type: Construction
deconstructionTarget: cuffs
graph: StunprodGraph

View File

@@ -1,7 +1,7 @@
{
"version": 1,
"license": "CC-BY-SA-3.0",
"copyright": "Taken from tgstation at https://github.com/tgstation/ at d0dffe7ca643db2624424fdcebf45863f85c0448",
"copyright": "Taken from tgstation at https://github.com/tgstation/ at d0dffe7ca643db2624424fdcebf45863f85c0448, on inhand sprites by Aviu",
"size": {
"x": 32,
"y": 32
@@ -23,12 +23,56 @@
]
},
{
"name": "inhand-left",
"name": "off-inhand-left",
"directions": 4
},
{
"name": "inhand-right",
"name": "off-inhand-right",
"directions": 4
},
{
"name": "on-inhand-left",
"directions": 4,
"delays": [
[
0.1,
0.1
],
[
0.1,
0.1
],
[
0.1,
0.1
],
[
0.1,
0.1
]
]
},
{
"name": "on-inhand-right",
"directions": 4,
"delays": [
[
0.1,
0.1
],
[
0.1,
0.1
],
[
0.1,
0.1
],
[
0.1,
0.1
]
]
}
]
}

Binary file not shown.

After

Width:  |  Height:  |  Size: 735 B

Binary file not shown.

After

Width:  |  Height:  |  Size: 730 B