(Re)Adds open bolt animations for gun sprites (#17219)

Co-authored-by: and_a <and_a@DESKTOP-RJENGIR>
Co-authored-by: metalgearsloth <comedian_vs_clown@hotmail.com>
This commit is contained in:
TaralGit
2023-08-12 22:58:07 -07:00
committed by GitHub
parent 82180fd04c
commit 8acac895fc
72 changed files with 726 additions and 353 deletions

View File

@@ -132,12 +132,17 @@ public abstract partial class SharedGunSystem
{
if (!args.CanAccess || !args.CanInteract || args.Hands == null || !component.Cycleable)
return;
args.Verbs.Add(new Verb()
if (component.Cycleable)
{
Text = Loc.GetString("gun-ballistic-cycle"),
Disabled = GetBallisticShots(component) == 0,
Act = () => ManualCycle(uid, component, Transform(uid).MapPosition, args.User),
});
args.Verbs.Add(new Verb()
{
Text = Loc.GetString("gun-ballistic-cycle"),
Disabled = GetBallisticShots(component) == 0,
Act = () => ManualCycle(uid, component, Transform(uid).MapPosition, args.User),
});
}
}
private void OnBallisticExamine(EntityUid uid, BallisticAmmoProviderComponent component, ExaminedEvent args)
@@ -165,8 +170,6 @@ public abstract partial class SharedGunSystem
Audio.PlayPredicted(component.SoundRack, uid, user);
var shots = GetBallisticShots(component);
component.Cycled = true;
Cycle(uid, component, coordinates);
var text = Loc.GetString(shots == 0 ? "gun-ballistic-cycled-empty" : "gun-ballistic-cycled");
@@ -181,6 +184,9 @@ public abstract partial class SharedGunSystem
private void OnBallisticInit(EntityUid uid, BallisticAmmoProviderComponent component, ComponentInit args)
{
component.Container = Containers.EnsureContainer<Container>(uid, "ballistic-ammo");
// TODO: This is called twice though we need to support loading appearance data (and we need to call it on MapInit
// to ensure it's correct).
UpdateBallisticAppearance(uid, component);
}
private void OnBallisticMapInit(EntityUid uid, BallisticAmmoProviderComponent component, MapInitEvent args)
@@ -190,6 +196,7 @@ public abstract partial class SharedGunSystem
if (component.FillProto != null)
{
component.UnspawnedCount = Math.Max(0, component.Capacity - component.Container.ContainedEntities.Count);
UpdateBallisticAppearance(uid, component);
Dirty(uid, component);
}
}
@@ -203,9 +210,6 @@ public abstract partial class SharedGunSystem
{
for (var i = 0; i < args.Shots; i++)
{
if (!component.Cycled)
break;
EntityUid entity;
if (component.Entities.Count > 0)
@@ -213,14 +217,6 @@ public abstract partial class SharedGunSystem
entity = component.Entities[^1];
args.Ammo.Add((entity, EnsureComp<AmmoComponent>(entity)));
// Leave the entity as is if it doesn't auto cycle
// TODO: Suss this out with NewAmmoComponent as I don't think it gets removed from container properly
if (!component.AutoCycle)
{
return;
}
component.Entities.RemoveAt(component.Entities.Count - 1);
component.Container.Remove(entity);
}
@@ -229,25 +225,6 @@ public abstract partial class SharedGunSystem
component.UnspawnedCount--;
entity = Spawn(component.FillProto, args.Coordinates);
args.Ammo.Add((entity, EnsureComp<AmmoComponent>(entity)));
// Put it back in if it doesn't auto-cycle
if (HasComp<CartridgeAmmoComponent>(entity) && !component.AutoCycle)
{
if (!entity.IsClientSide())
{
component.Entities.Add(entity);
component.Container.Insert(entity);
}
else
{
component.UnspawnedCount++;
}
}
}
if (!component.AutoCycle)
{
component.Cycled = false;
}
}