shield values examine (#17245)
This commit is contained in:
@@ -58,10 +58,7 @@ public sealed partial class BlockingSystem
|
||||
|
||||
private void OnDamageModified(EntityUid uid, BlockingComponent component, DamageModifyEvent args)
|
||||
{
|
||||
_proto.TryIndex<DamageModifierSetPrototype>(component.PassiveBlockDamageModifer, out var passiveblockModifier);
|
||||
_proto.TryIndex<DamageModifierSetPrototype>(component.ActiveBlockDamageModifier, out var activeBlockModifier);
|
||||
|
||||
var modifier = component.IsBlocking ? activeBlockModifier : passiveblockModifier;
|
||||
var modifier = component.IsBlocking ? component.ActiveBlockDamageModifier : component.PassiveBlockDamageModifer;
|
||||
if (modifier == null)
|
||||
{
|
||||
return;
|
||||
|
||||
@@ -1,7 +1,9 @@
|
||||
using System.Linq;
|
||||
using Content.Shared.Actions;
|
||||
using Content.Shared.Actions.ActionTypes;
|
||||
using Content.Shared.Doors.Components;
|
||||
using Content.Shared.Damage;
|
||||
using Content.Shared.Damage.Prototypes;
|
||||
using Content.Shared.Examine;
|
||||
using Content.Shared.Hands;
|
||||
using Content.Shared.Hands.Components;
|
||||
using Content.Shared.Hands.EntitySystems;
|
||||
@@ -12,11 +14,14 @@ using Content.Shared.Mobs.Components;
|
||||
using Content.Shared.Physics;
|
||||
using Content.Shared.Popups;
|
||||
using Content.Shared.Toggleable;
|
||||
using Content.Shared.Verbs;
|
||||
using Robust.Shared.Network;
|
||||
using Robust.Shared.Physics;
|
||||
using Robust.Shared.Physics.Components;
|
||||
using Robust.Shared.Physics.Systems;
|
||||
using Robust.Shared.Player;
|
||||
using Robust.Shared.Prototypes;
|
||||
using Robust.Shared.Utility;
|
||||
|
||||
namespace Content.Shared.Blocking;
|
||||
|
||||
@@ -30,6 +35,8 @@ public sealed partial class BlockingSystem : EntitySystem
|
||||
[Dependency] private readonly SharedPopupSystem _popupSystem = default!;
|
||||
[Dependency] private readonly EntityLookupSystem _lookup = default!;
|
||||
[Dependency] private readonly SharedPhysicsSystem _physics = default!;
|
||||
[Dependency] private readonly ExamineSystemShared _examine = default!;
|
||||
[Dependency] private readonly INetManager _net = default!;
|
||||
|
||||
public override void Initialize()
|
||||
{
|
||||
@@ -44,6 +51,8 @@ public sealed partial class BlockingSystem : EntitySystem
|
||||
SubscribeLocalEvent<BlockingComponent, ToggleActionEvent>(OnToggleAction);
|
||||
|
||||
SubscribeLocalEvent<BlockingComponent, ComponentShutdown>(OnShutdown);
|
||||
|
||||
SubscribeLocalEvent<BlockingComponent, GetVerbsEvent<ExamineVerb>>(OnVerbExamine);
|
||||
}
|
||||
|
||||
private void OnEquip(EntityUid uid, BlockingComponent component, GotEquippedHandEvent args)
|
||||
@@ -80,7 +89,7 @@ public sealed partial class BlockingSystem : EntitySystem
|
||||
|
||||
private void OnToggleAction(EntityUid uid, BlockingComponent component, ToggleActionEvent args)
|
||||
{
|
||||
if(args.Handled)
|
||||
if (args.Handled)
|
||||
return;
|
||||
|
||||
var blockQuery = GetEntityQuery<BlockingComponent>();
|
||||
@@ -281,4 +290,50 @@ public sealed partial class BlockingSystem : EntitySystem
|
||||
component.User = null;
|
||||
}
|
||||
|
||||
private void OnVerbExamine(EntityUid uid, BlockingComponent component, GetVerbsEvent<ExamineVerb> args)
|
||||
{
|
||||
if (!args.CanInteract || !args.CanAccess || !_net.IsServer)
|
||||
return;
|
||||
|
||||
var fraction = component.IsBlocking ? component.ActiveBlockFraction : component.PassiveBlockFraction;
|
||||
var modifier = component.IsBlocking ? component.ActiveBlockDamageModifier : component.PassiveBlockDamageModifer;
|
||||
|
||||
var msg = new FormattedMessage();
|
||||
|
||||
msg.AddMarkup(Loc.GetString("blocking-fraction", ("value", MathF.Round(fraction * 100, 1))));
|
||||
|
||||
if (modifier != null)
|
||||
{
|
||||
AppendCoefficients(modifier, msg);
|
||||
}
|
||||
|
||||
_examine.AddDetailedExamineVerb(args, component, msg,
|
||||
Loc.GetString("blocking-examinable-verb-text"),
|
||||
"/Textures/Interface/VerbIcons/dot.svg.192dpi.png",
|
||||
Loc.GetString("blocking-examinable-verb-message")
|
||||
);
|
||||
}
|
||||
|
||||
private static FormattedMessage AppendCoefficients(DamageModifierSet modifiers, FormattedMessage msg)
|
||||
{
|
||||
foreach (var coefficient in modifiers.Coefficients)
|
||||
{
|
||||
msg.PushNewline();
|
||||
msg.AddMarkup(Loc.GetString("blocking-coefficient-value",
|
||||
("type", coefficient.Key),
|
||||
("value", MathF.Round(coefficient.Value * 100, 1))
|
||||
));
|
||||
}
|
||||
|
||||
foreach (var flat in modifiers.FlatReduction)
|
||||
{
|
||||
msg.PushNewline();
|
||||
msg.AddMarkup(Loc.GetString("blocking-reduction-value",
|
||||
("type", flat.Key),
|
||||
("value", flat.Value)
|
||||
));
|
||||
}
|
||||
|
||||
return msg;
|
||||
}
|
||||
}
|
||||
|
||||
@@ -1,4 +1,5 @@
|
||||
using Content.Shared.Actions.ActionTypes;
|
||||
using Content.Shared.Damage;
|
||||
using Robust.Shared.Audio;
|
||||
using Robust.Shared.Physics.Collision.Shapes;
|
||||
using Robust.Shared.Serialization.TypeSerializers.Implementations.Custom.Prototype;
|
||||
@@ -31,24 +32,22 @@ public sealed class BlockingComponent : Component
|
||||
/// <summary>
|
||||
/// The shape of the blocking fixture that will be dynamically spawned
|
||||
/// </summary>
|
||||
[ViewVariables(VVAccess.ReadWrite)] [DataField("shape")]
|
||||
[DataField("shape"), ViewVariables(VVAccess.ReadWrite)]
|
||||
public IPhysShape Shape = new PhysShapeCircle(0.5f);
|
||||
|
||||
/// <summary>
|
||||
/// The damage modifer to use while passively blocking
|
||||
/// </summary>
|
||||
[ViewVariables(VVAccess.ReadWrite)]
|
||||
[DataField("passiveBlockModifier")]
|
||||
public string PassiveBlockDamageModifer = "Metallic";
|
||||
[DataField("passiveBlockModifier", required: true)]
|
||||
public DamageModifierSet PassiveBlockDamageModifer = default!;
|
||||
|
||||
/// <summary>
|
||||
/// The damage modifier to use while actively blocking.
|
||||
/// </summary>
|
||||
[ViewVariables(VVAccess.ReadWrite)]
|
||||
[DataField("activeBlockModifier")]
|
||||
public string ActiveBlockDamageModifier = "Metallic";
|
||||
[DataField("activeBlockModifier", required: true)]
|
||||
public DamageModifierSet ActiveBlockDamageModifier = default!;
|
||||
|
||||
[DataField("blockingToggleActionId", customTypeSerializer:typeof(PrototypeIdSerializer<InstantActionPrototype>))]
|
||||
[DataField("blockingToggleActionId", customTypeSerializer: typeof(PrototypeIdSerializer<InstantActionPrototype>))]
|
||||
public string BlockingToggleActionId = "ToggleBlock";
|
||||
|
||||
[DataField("blockingToggleAction")]
|
||||
|
||||
@@ -1,5 +1,4 @@
|
||||
using Content.Shared.Damage;
|
||||
using Robust.Shared.Physics;
|
||||
using Robust.Shared.Physics;
|
||||
|
||||
namespace Content.Shared.Blocking;
|
||||
|
||||
@@ -15,14 +14,10 @@ public sealed class BlockingUserComponent : Component
|
||||
[DataField("blockingItem")]
|
||||
public EntityUid? BlockingItem;
|
||||
|
||||
[DataField("modifiers")]
|
||||
public DamageModifierSet Modifiers = default!;
|
||||
|
||||
/// <summary>
|
||||
/// Stores the entities original bodytype
|
||||
/// Used so that it can be put back to what it was after anchoring
|
||||
/// </summary>
|
||||
[DataField("originalBodyType")]
|
||||
public BodyType OriginalBodyType;
|
||||
|
||||
}
|
||||
|
||||
Reference in New Issue
Block a user