Gun bolt fixes and QoL (#19349)
Co-authored-by: Errant <35878406+errant@users.noreply.github.com>
This commit is contained in:
@@ -25,7 +25,6 @@ public abstract partial class SharedGunSystem
|
|||||||
* Racking does both in one hit and has a different sound (to avoid RSI + sounds cooler).
|
* Racking does both in one hit and has a different sound (to avoid RSI + sounds cooler).
|
||||||
*/
|
*/
|
||||||
|
|
||||||
SubscribeLocalEvent<ChamberMagazineAmmoProviderComponent, GetVerbsEvent<Verb>>(OnChamberVerb);
|
|
||||||
SubscribeLocalEvent<ChamberMagazineAmmoProviderComponent, GetVerbsEvent<ActivationVerb>>(OnChamberActivationVerb);
|
SubscribeLocalEvent<ChamberMagazineAmmoProviderComponent, GetVerbsEvent<ActivationVerb>>(OnChamberActivationVerb);
|
||||||
SubscribeLocalEvent<ChamberMagazineAmmoProviderComponent, GetVerbsEvent<InteractionVerb>>(OnChamberInteractionVerb);
|
SubscribeLocalEvent<ChamberMagazineAmmoProviderComponent, GetVerbsEvent<InteractionVerb>>(OnChamberInteractionVerb);
|
||||||
SubscribeLocalEvent<ChamberMagazineAmmoProviderComponent, GetVerbsEvent<AlternativeVerb>>(OnMagazineVerb);
|
SubscribeLocalEvent<ChamberMagazineAmmoProviderComponent, GetVerbsEvent<AlternativeVerb>>(OnMagazineVerb);
|
||||||
@@ -47,18 +46,9 @@ public abstract partial class SharedGunSystem
|
|||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
private void OnChamberVerb(EntityUid uid, ChamberMagazineAmmoProviderComponent component, GetVerbsEvent<Verb> args)
|
/// <summary>
|
||||||
{
|
/// Called when user "Activated In World" (E) with the gun as the target
|
||||||
if (component.BoltClosed != null)
|
/// </summary>
|
||||||
{
|
|
||||||
args.Verbs.Add(new Verb()
|
|
||||||
{
|
|
||||||
Text = component.BoltClosed.Value ? Loc.GetString("gun-chamber-bolt-open") : Loc.GetString("gun-chamber-bolt-close"),
|
|
||||||
Act = () => ToggleBolt(uid, component, args.User),
|
|
||||||
});
|
|
||||||
}
|
|
||||||
}
|
|
||||||
|
|
||||||
private void OnChamberActivate(EntityUid uid, ChamberMagazineAmmoProviderComponent component, ActivateInWorldEvent args)
|
private void OnChamberActivate(EntityUid uid, ChamberMagazineAmmoProviderComponent component, ActivateInWorldEvent args)
|
||||||
{
|
{
|
||||||
if (args.Handled)
|
if (args.Handled)
|
||||||
@@ -68,6 +58,9 @@ public abstract partial class SharedGunSystem
|
|||||||
ToggleBolt(uid, component, args.User);
|
ToggleBolt(uid, component, args.User);
|
||||||
}
|
}
|
||||||
|
|
||||||
|
/// <summary>
|
||||||
|
/// Called when gun was "Activated In Hand" (Z)
|
||||||
|
/// </summary>
|
||||||
private void OnChamberUse(EntityUid uid, ChamberMagazineAmmoProviderComponent component, UseInHandEvent args)
|
private void OnChamberUse(EntityUid uid, ChamberMagazineAmmoProviderComponent component, UseInHandEvent args)
|
||||||
{
|
{
|
||||||
if (args.Handled)
|
if (args.Handled)
|
||||||
@@ -77,6 +70,9 @@ public abstract partial class SharedGunSystem
|
|||||||
UseChambered(uid, component, args.User);
|
UseChambered(uid, component, args.User);
|
||||||
}
|
}
|
||||||
|
|
||||||
|
/// <summary>
|
||||||
|
/// Creates "Rack" verb on the gun
|
||||||
|
/// </summary>
|
||||||
private void OnChamberActivationVerb(EntityUid uid, ChamberMagazineAmmoProviderComponent component, GetVerbsEvent<ActivationVerb> args)
|
private void OnChamberActivationVerb(EntityUid uid, ChamberMagazineAmmoProviderComponent component, GetVerbsEvent<ActivationVerb> args)
|
||||||
{
|
{
|
||||||
if (!args.CanAccess || !args.CanInteract || component.BoltClosed == null)
|
if (!args.CanAccess || !args.CanInteract || component.BoltClosed == null)
|
||||||
@@ -92,10 +88,16 @@ public abstract partial class SharedGunSystem
|
|||||||
});
|
});
|
||||||
}
|
}
|
||||||
|
|
||||||
|
/// <summary>
|
||||||
|
/// Opens then closes the bolt, or just closes it if currently open.
|
||||||
|
/// </summary>
|
||||||
private void UseChambered(EntityUid uid, ChamberMagazineAmmoProviderComponent component, EntityUid? user = null)
|
private void UseChambered(EntityUid uid, ChamberMagazineAmmoProviderComponent component, EntityUid? user = null)
|
||||||
{
|
{
|
||||||
if (component.BoltClosed == false)
|
if (component.BoltClosed == false)
|
||||||
|
{
|
||||||
|
ToggleBolt(uid, component, user);
|
||||||
return;
|
return;
|
||||||
|
}
|
||||||
|
|
||||||
if (TryTakeChamberEntity(uid, out var chamberEnt))
|
if (TryTakeChamberEntity(uid, out var chamberEnt))
|
||||||
{
|
{
|
||||||
@@ -118,6 +120,9 @@ public abstract partial class SharedGunSystem
|
|||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
/// <summary>
|
||||||
|
/// Creates "Open/Close bolt" verb on the gun
|
||||||
|
/// </summary>
|
||||||
private void OnChamberInteractionVerb(EntityUid uid, ChamberMagazineAmmoProviderComponent component, GetVerbsEvent<InteractionVerb> args)
|
private void OnChamberInteractionVerb(EntityUid uid, ChamberMagazineAmmoProviderComponent component, GetVerbsEvent<InteractionVerb> args)
|
||||||
{
|
{
|
||||||
if (!args.CanAccess || !args.CanInteract || component.BoltClosed == null)
|
if (!args.CanAccess || !args.CanInteract || component.BoltClosed == null)
|
||||||
@@ -134,6 +139,9 @@ public abstract partial class SharedGunSystem
|
|||||||
});
|
});
|
||||||
}
|
}
|
||||||
|
|
||||||
|
/// <summary>
|
||||||
|
/// Updates the bolt to its new state
|
||||||
|
/// </summary>
|
||||||
public void SetBoltClosed(EntityUid uid, ChamberMagazineAmmoProviderComponent component, bool value, EntityUid? user = null, AppearanceComponent? appearance = null, ItemSlotsComponent? slots = null)
|
public void SetBoltClosed(EntityUid uid, ChamberMagazineAmmoProviderComponent component, bool value, EntityUid? user = null, AppearanceComponent? appearance = null, ItemSlotsComponent? slots = null)
|
||||||
{
|
{
|
||||||
if (component.BoltClosed == null || value == component.BoltClosed)
|
if (component.BoltClosed == null || value == component.BoltClosed)
|
||||||
@@ -235,6 +243,9 @@ public abstract partial class SharedGunSystem
|
|||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
/// <summary>
|
||||||
|
/// Sets the bolt's positional value to the other state
|
||||||
|
/// </summary>
|
||||||
public void ToggleBolt(EntityUid uid, ChamberMagazineAmmoProviderComponent component, EntityUid? user = null)
|
public void ToggleBolt(EntityUid uid, ChamberMagazineAmmoProviderComponent component, EntityUid? user = null)
|
||||||
{
|
{
|
||||||
if (component.BoltClosed == null)
|
if (component.BoltClosed == null)
|
||||||
@@ -243,16 +254,24 @@ public abstract partial class SharedGunSystem
|
|||||||
SetBoltClosed(uid, component, !component.BoltClosed.Value, user);
|
SetBoltClosed(uid, component, !component.BoltClosed.Value, user);
|
||||||
}
|
}
|
||||||
|
|
||||||
|
/// <summary>
|
||||||
|
/// Called when the gun was Examined
|
||||||
|
/// </summary>
|
||||||
private void OnChamberMagazineExamine(EntityUid uid, ChamberMagazineAmmoProviderComponent component, ExaminedEvent args)
|
private void OnChamberMagazineExamine(EntityUid uid, ChamberMagazineAmmoProviderComponent component, ExaminedEvent args)
|
||||||
{
|
{
|
||||||
if (!args.IsInDetailsRange)
|
if (!args.IsInDetailsRange)
|
||||||
return;
|
return;
|
||||||
|
|
||||||
var (count, _) = GetChamberMagazineCountCapacity(uid, component);
|
var (count, _) = GetChamberMagazineCountCapacity(uid, component);
|
||||||
|
string boltState;
|
||||||
|
|
||||||
if (component.BoltClosed != null)
|
if (component.BoltClosed != null)
|
||||||
{
|
{
|
||||||
args.PushMarkup(Loc.GetString("gun-chamber-bolt", ("bolt", component.BoltClosed), ("color", component.BoltClosed.Value ? Color.FromHex("#94e1f2") : Color.FromHex("#f29d94"))));
|
if (component.BoltClosed == true)
|
||||||
|
boltState = Loc.GetString("gun-chamber-bolt-open-state");
|
||||||
|
else
|
||||||
|
boltState = Loc.GetString("gun-chamber-bolt-closed-state");
|
||||||
|
args.PushMarkup(Loc.GetString("gun-chamber-bolt", ("bolt", boltState), ("color", component.BoltClosed.Value ? Color.FromHex("#94e1f2") : Color.FromHex("#f29d94"))));
|
||||||
}
|
}
|
||||||
|
|
||||||
args.PushMarkup(Loc.GetString("gun-magazine-examine", ("color", AmmoExamineColor), ("count", count)));
|
args.PushMarkup(Loc.GetString("gun-magazine-examine", ("color", AmmoExamineColor), ("count", count)));
|
||||||
|
|||||||
@@ -34,6 +34,8 @@ gun-chamber-bolt-closed = Closed bolt
|
|||||||
gun-chamber-bolt-opened = Opened bolt
|
gun-chamber-bolt-opened = Opened bolt
|
||||||
gun-chamber-bolt-close = Close bolt
|
gun-chamber-bolt-close = Close bolt
|
||||||
gun-chamber-bolt-open = Open bolt
|
gun-chamber-bolt-open = Open bolt
|
||||||
|
gun-chamber-bolt-closed-state = open
|
||||||
|
gun-chamber-bolt-open-state = closed
|
||||||
gun-chamber-rack = Rack
|
gun-chamber-rack = Rack
|
||||||
|
|
||||||
# MagazineAmmoProvider
|
# MagazineAmmoProvider
|
||||||
|
|||||||
Reference in New Issue
Block a user