Skip to content
This repository was archived by the owner on Aug 22, 2025. It is now read-only.
Open
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
31 changes: 31 additions & 0 deletions Content.Server/_White/BodyArmor/ArmorPlates/ArmorPlateComponent.cs
Original file line number Diff line number Diff line change
@@ -0,0 +1,31 @@
using Content.Shared.FixedPoint;

namespace Content.Server._White.BodyArmor.ArmorPlates;

[RegisterComponent]
public sealed partial class ArmorPlateComponent : Component
{
[DataField]
public int AllowedDamage = 100;

[DataField]
public int ReceivedDamage;

[DataField("tier")]
public PlateTier PlateTier = 0;

[DataField]
public Dictionary<PlateTier, FixedPoint2> DamageOfTier = new()
{
{ PlateTier.TierOne, 7 },
{ PlateTier.TierTwo, 12 },
{ PlateTier.TierThree, 14 }
};
}

public enum PlateTier : byte
{
TierOne = 0,
TierTwo = 1,
TierThree = 2,
}
97 changes: 97 additions & 0 deletions Content.Server/_White/BodyArmor/ArmorPlates/ArmorPlateSystem.cs
Original file line number Diff line number Diff line change
@@ -0,0 +1,97 @@
using Content.Server._White.BodyArmor.PlateCarrier;
using Content.Server.DoAfter;
using Content.Shared._White.BodyArmor;
using Content.Shared.DoAfter;
using Content.Shared.Examine;
using Content.Shared.Interaction;
using Robust.Server.Containers;
using Robust.Shared.Containers;

namespace Content.Server._White.BodyArmor.ArmorPlates;

public sealed class ArmorPlateSystem : EntitySystem
{
[Dependency] private readonly DoAfterSystem _doAfterSystem = default!;
[Dependency] private readonly ContainerSystem _containerSystem = default!;
public override void Initialize()
{
base.Initialize();

SubscribeLocalEvent<ArmorPlateComponent, AfterInteractEvent>(OnInteract);
SubscribeLocalEvent<ArmorPlateComponent, PutPlateDoAfterEvent>(OnPutPlateDoAfter);
SubscribeLocalEvent<ArmorPlateComponent, ExaminedEvent>(OnExamined);
}

private void OnExamined(EntityUid uid, ArmorPlateComponent component, ExaminedEvent args)
{
var hasDamage = component.ReceivedDamage > 0 ? "имеются визуальные повреждения." : "визуальные повреждения отсутствуют.";
Dictionary<PlateTier, string> tierList = new()
{
{ PlateTier.TierOne, "первый уровень броне-защиты" },
{ PlateTier.TierTwo, "второй уровень броне-защиты" },
{ PlateTier.TierThree, "третий уровень броне-защиты" }
};

using (args.PushGroup(nameof(ArmorPlateComponent)))
{
args.PushMarkup(Loc.GetString("armorplate-tier", ("tier", tierList[component.PlateTier])));
args.PushMarkup(Loc.GetString("armorplate-damage", ("hasdamage", hasDamage)));
}
}

private void OnInteract(EntityUid uid, ArmorPlateComponent component, AfterInteractEvent args)
{
var platecarrier = args.Target;

if(!TryComp<PlateCarrierComponent>(platecarrier, out var plateCarrierComponent))
return;

if(plateCarrierComponent.PlateIsClosed)
return;

if(plateCarrierComponent.HasPlate)
return;

var doAfterEventArgs = new DoAfterArgs(EntityManager,
args.User,
plateCarrierComponent.TimeToPutPlate,
new PutPlateDoAfterEvent(),
uid,
used: uid,
target: platecarrier)
{
BreakOnMove = true,
BreakOnDamage = true,
NeedHand = true
};

if(!_doAfterSystem.TryStartDoAfter(doAfterEventArgs))
return;

args.Handled = true;
}

private void OnPutPlateDoAfter(EntityUid uid, ArmorPlateComponent component, PutPlateDoAfterEvent args)
{
if (args.Handled || args.Cancelled)
return;

if(args.Target == null || args.Used == null)
return;

var platecarrier = (EntityUid)args.Target;

if (!TryComp<PlateCarrierComponent>(platecarrier, out var plateCarrierComponent))
return;

var armorplate = (EntityUid)args.Used;

var armorPlateContainer =
_containerSystem.EnsureContainer<Container>(platecarrier, PlateCarrierComponent.ArmorPlateContainer);

_containerSystem.Insert(armorplate, armorPlateContainer);
plateCarrierComponent.HasPlate = true;

args.Handled = true;
}
}
Original file line number Diff line number Diff line change
@@ -0,0 +1,42 @@
using Robust.Shared.Audio;

namespace Content.Server._White.BodyArmor.PlateCarrier;

[RegisterComponent]
public sealed partial class PlateCarrierComponent : Component
{
public static string ArmorPlateContainer = "armor_plate";

[DataField]
public bool PlateIsClosed = true; // true - застегнут отдел для бронеплит

[DataField]
public bool HasPlate = false;

[DataField]
public string PlateCarrierSlot = "outerClothing";

[DataField]
public bool IsBreak = false;

[DataField]
public float ChanceOfBreak = 0.05F;

[DataField]
[ViewVariables(VVAccess.ReadWrite)]
public SoundSpecifier BreakSound = new SoundPathSpecifier("/Audio/White/BodyArmor/PlateCarrier/break.ogg");

[DataField]
public int PlateCarrierDamage = 0;

[DataField]
[ViewVariables(VVAccess.ReadWrite)]
public SoundSpecifier OpenSound = new SoundPathSpecifier("/Audio/White/BodyArmor/PlateCarrier/open.ogg");

[DataField]
[ViewVariables(VVAccess.ReadWrite)]
public SoundSpecifier CloseSound = new SoundPathSpecifier("/Audio/White/BodyArmor/PlateCarrier/close.ogg");

[DataField]
public TimeSpan TimeToPutPlate = TimeSpan.FromSeconds(3);
}
Original file line number Diff line number Diff line change
@@ -0,0 +1,8 @@
namespace Content.Server._White.BodyArmor.PlateCarrier;

[RegisterComponent]
public sealed partial class PlateCarrierOnUserComponent : Component
{
[DataField]
public EntityUid? PlateCarrier;
}
Loading