Add fire rate and caliber examine tooltip to guns (#1413)

This commit is contained in:
DrSmugleaf
2020-07-24 14:18:37 +02:00
committed by GitHub
parent cd40eaffff
commit be3db34d1c
2 changed files with 27 additions and 2 deletions

View File

@@ -2,6 +2,7 @@
using System.Collections.Generic; using System.Collections.Generic;
using System.Linq; using System.Linq;
using Content.Server.GameObjects.Components.Weapon.Ranged.Ammunition; using Content.Server.GameObjects.Components.Weapon.Ranged.Ammunition;
using Content.Server.GameObjects.EntitySystems.Click;
using Content.Shared.GameObjects; using Content.Shared.GameObjects;
using Content.Shared.GameObjects.Components.Weapons.Ranged; using Content.Shared.GameObjects.Components.Weapons.Ranged;
using Content.Shared.GameObjects.Components.Weapons.Ranged.Barrels; using Content.Shared.GameObjects.Components.Weapons.Ranged.Barrels;
@@ -19,12 +20,13 @@ using Robust.Shared.Interfaces.GameObjects;
using Robust.Shared.Localization; using Robust.Shared.Localization;
using Robust.Shared.Map; using Robust.Shared.Map;
using Robust.Shared.Serialization; using Robust.Shared.Serialization;
using Robust.Shared.Utility;
using Robust.Shared.ViewVariables; using Robust.Shared.ViewVariables;
namespace Content.Server.GameObjects.Components.Weapon.Ranged.Barrels namespace Content.Server.GameObjects.Components.Weapon.Ranged.Barrels
{ {
[RegisterComponent] [RegisterComponent]
public sealed class ServerMagazineBarrelComponent : ServerRangedBarrelComponent public sealed class ServerMagazineBarrelComponent : ServerRangedBarrelComponent, IExamine
{ {
public override string Name => "MagazineBarrel"; public override string Name => "MagazineBarrel";
public override uint? NetID => ContentNetIDs.MAGAZINE_BARREL; public override uint? NetID => ContentNetIDs.MAGAZINE_BARREL;
@@ -412,6 +414,14 @@ namespace Content.Server.GameObjects.Components.Weapon.Ranged.Barrels
return false; return false;
} }
public override void Examine(FormattedMessage message, bool inDetailsRange)
{
base.Examine(message, inDetailsRange);
var text = Loc.GetString("\nIt uses {0} ammo.", Caliber);
message.AddText(text);
}
[Verb] [Verb]
private sealed class EjectMagazineVerb : Verb<ServerMagazineBarrelComponent> private sealed class EjectMagazineVerb : Verb<ServerMagazineBarrelComponent>
{ {

View File

@@ -4,6 +4,7 @@ using System.Linq;
using Content.Server.GameObjects.Components.Mobs; using Content.Server.GameObjects.Components.Mobs;
using Content.Server.GameObjects.Components.Projectiles; using Content.Server.GameObjects.Components.Projectiles;
using Content.Server.GameObjects.Components.Weapon.Ranged.Ammunition; using Content.Server.GameObjects.Components.Weapon.Ranged.Ammunition;
using Content.Server.GameObjects.EntitySystems.Click;
using Content.Shared.Audio; using Content.Shared.Audio;
using Content.Shared.GameObjects.Components.Weapons.Ranged; using Content.Shared.GameObjects.Components.Weapons.Ranged;
using Content.Shared.Interfaces.GameObjects.Components; using Content.Shared.Interfaces.GameObjects.Components;
@@ -18,6 +19,7 @@ using Robust.Shared.Interfaces.Physics;
using Robust.Shared.Interfaces.Random; using Robust.Shared.Interfaces.Random;
using Robust.Shared.Interfaces.Timing; using Robust.Shared.Interfaces.Timing;
using Robust.Shared.IoC; using Robust.Shared.IoC;
using Robust.Shared.Localization;
using Robust.Shared.Log; using Robust.Shared.Log;
using Robust.Shared.Map; using Robust.Shared.Map;
using Robust.Shared.Maths; using Robust.Shared.Maths;
@@ -32,7 +34,7 @@ namespace Content.Server.GameObjects.Components.Weapon.Ranged.Barrels
/// All of the ranged weapon components inherit from this to share mechanics like shooting etc. /// All of the ranged weapon components inherit from this to share mechanics like shooting etc.
/// Only difference between them is how they retrieve a projectile to shoot (battery, magazine, etc.) /// Only difference between them is how they retrieve a projectile to shoot (battery, magazine, etc.)
/// </summary> /// </summary>
public abstract class ServerRangedBarrelComponent : SharedRangedBarrelComponent, IUse, IInteractUsing public abstract class ServerRangedBarrelComponent : SharedRangedBarrelComponent, IUse, IInteractUsing, IExamine
{ {
// There's still some of py01 and PJB's work left over, especially in underlying shooting logic, // There's still some of py01 and PJB's work left over, especially in underlying shooting logic,
// it's just when I re-organised it changed me as the contributor // it's just when I re-organised it changed me as the contributor
@@ -441,5 +443,18 @@ namespace Content.Server.GameObjects.Components.Weapon.Ranged.Barrels
} }
} }
#endregion #endregion
public virtual void Examine(FormattedMessage message, bool inDetailsRange)
{
var fireRateMessage = Loc.GetString(FireRateSelector switch
{
FireRateSelector.Safety => "Its safety is enabled.",
FireRateSelector.Single => "It's in single fire mode.",
FireRateSelector.Automatic => "It's in automatic fire mode.",
_ => throw new IndexOutOfRangeException()
});
message.AddText(fireRateMessage);
}
} }
} }