Merge branch 'Transfer/Engi' into EngiTransfer
This commit is contained in:
@@ -59,6 +59,14 @@ public sealed partial class FaxMachineComponent : Component
|
||||
[DataField]
|
||||
public bool ReceiveNukeCodes { get; set; } = false;
|
||||
|
||||
/// <summary>
|
||||
/// WD.
|
||||
/// Should that fax receive station goal info
|
||||
/// </summary>
|
||||
[ViewVariables(VVAccess.ReadWrite)]
|
||||
[DataField("receiveStationGoal")]
|
||||
public bool ReceiveStationGoal { get; set; } = false;
|
||||
|
||||
/// <summary>
|
||||
/// Sound to play when fax has been emagged
|
||||
/// </summary>
|
||||
|
||||
@@ -0,0 +1,11 @@
|
||||
namespace Content.Shared._White._Engi.BucketHelmet;
|
||||
|
||||
/// <summary>
|
||||
/// WD.
|
||||
/// This is used for bucket helmet.
|
||||
/// </summary>
|
||||
[RegisterComponent]
|
||||
public sealed partial class BucketHelmetComponent : Component
|
||||
{
|
||||
|
||||
}
|
||||
@@ -0,0 +1,11 @@
|
||||
namespace Content.Shared._White._Engi.BucketHelmet;
|
||||
|
||||
/// <summary>
|
||||
/// WD.
|
||||
/// This is used to block stripping headsets when bucket helmet is on.
|
||||
/// </summary>
|
||||
[RegisterComponent]
|
||||
public sealed partial class PreventStrippingFromEarsComponent : Component
|
||||
{
|
||||
|
||||
}
|
||||
@@ -0,0 +1,26 @@
|
||||
using Content.Shared.Damage;
|
||||
using Robust.Shared.GameStates;
|
||||
|
||||
namespace Content.Shared._White._Engi.DamageableClothing;
|
||||
|
||||
/// <summary>
|
||||
/// WD.
|
||||
/// This component goes on an equippable item that should take damage while in use.
|
||||
/// </summary>
|
||||
[RegisterComponent, NetworkedComponent, AutoGenerateComponentState]
|
||||
public sealed partial class DamageableClothingComponent : Component
|
||||
{
|
||||
|
||||
/// <summary>
|
||||
/// The entity that's wearing the item.
|
||||
/// </summary>
|
||||
[ViewVariables, AutoNetworkedField]
|
||||
public EntityUid? User;
|
||||
|
||||
/// <summary>
|
||||
/// The damage modifier to use on item.
|
||||
/// </summary>
|
||||
[DataField]
|
||||
public DamageModifierSet DamageModifier = default!;
|
||||
|
||||
}
|
||||
@@ -0,0 +1,16 @@
|
||||
namespace Content.Shared._White._Engi.DamageableClothing;
|
||||
|
||||
/// <summary>
|
||||
/// WD.
|
||||
/// This component gets dynamically added to an Entity via the <see cref="DamageableClothing"/>.
|
||||
/// </summary>
|
||||
[RegisterComponent]
|
||||
public sealed partial class DamageableClothingUserComponent : Component
|
||||
{
|
||||
/// <summary>
|
||||
/// The entity that's also being damaged.
|
||||
/// </summary>
|
||||
[DataField]
|
||||
public EntityUid? ItemId;
|
||||
|
||||
}
|
||||
@@ -0,0 +1,46 @@
|
||||
using Robust.Shared.Timing;
|
||||
using Content.Shared.Inventory.Events;
|
||||
|
||||
namespace Content.Shared._White._Engi.DamageableClothing;
|
||||
|
||||
/// <summary>
|
||||
/// WD
|
||||
/// </summary>
|
||||
public sealed partial class DamageableClothingSystem : EntitySystem
|
||||
{
|
||||
[Dependency] private readonly IGameTiming _gameTiming = default!;
|
||||
|
||||
public override void Initialize()
|
||||
{
|
||||
base.Initialize();
|
||||
InitializeUser();
|
||||
|
||||
SubscribeLocalEvent<DamageableClothingComponent, GotEquippedEvent>(OnEquipped);
|
||||
SubscribeLocalEvent<DamageableClothingComponent, GotUnequippedEvent>(OnUnequipped);
|
||||
SubscribeLocalEvent<DamageableClothingComponent, ComponentShutdown>(OnShutdown);
|
||||
}
|
||||
|
||||
private void OnEquipped(EntityUid uid, DamageableClothingComponent component, GotEquippedEvent args)
|
||||
{
|
||||
if (_gameTiming.ApplyingState)
|
||||
return;
|
||||
component.User = args.Equipee;
|
||||
var userComp = EnsureComp<DamageableClothingUserComponent>(args.Equipee);
|
||||
userComp.ItemId = args.Equipment;
|
||||
}
|
||||
|
||||
private void OnUnequipped(EntityUid uid, DamageableClothingComponent component, GotUnequippedEvent args)
|
||||
{
|
||||
RemCompDeferred<DamageableClothingUserComponent>(args.Equipee);
|
||||
component.User = null;
|
||||
}
|
||||
|
||||
private void OnShutdown(EntityUid uid, DamageableClothingComponent component, ComponentShutdown args)
|
||||
{
|
||||
if (component.User != null)
|
||||
{
|
||||
RemCompDeferred<DamageableClothingUserComponent>(component.User.Value);
|
||||
component.User = null;
|
||||
}
|
||||
}
|
||||
}
|
||||
@@ -0,0 +1,49 @@
|
||||
using Content.Shared.Damage;
|
||||
|
||||
namespace Content.Shared._White._Engi.DamageableClothing;
|
||||
|
||||
/// <summary>
|
||||
/// WD
|
||||
/// </summary>
|
||||
public sealed partial class DamageableClothingSystem
|
||||
{
|
||||
[Dependency] private readonly DamageableSystem _damageable = default!;
|
||||
|
||||
private void InitializeUser()
|
||||
{
|
||||
SubscribeLocalEvent<DamageableClothingUserComponent, DamageModifyEvent>(OnUserDamageModified);
|
||||
SubscribeLocalEvent<DamageableClothingComponent, DamageModifyEvent>(OnDamageModified);
|
||||
SubscribeLocalEvent<DamageableClothingUserComponent, EntityTerminatingEvent>(OnEntityTerminating);
|
||||
}
|
||||
|
||||
private void OnUserDamageModified(EntityUid uid, DamageableClothingUserComponent component, DamageModifyEvent args)
|
||||
{
|
||||
if (TryComp<DamageableClothingComponent>(component.ItemId, out var blocking))
|
||||
{
|
||||
if (args.Damage.GetTotal() <= 0)
|
||||
return;
|
||||
|
||||
if (!TryComp<DamageableComponent>(component.ItemId, out var dmgComp))
|
||||
return;
|
||||
|
||||
var blockFraction = 1;
|
||||
blockFraction = Math.Clamp(blockFraction, 0, 1);
|
||||
_damageable.TryChangeDamage(component.ItemId, blockFraction * args.OriginalDamage);
|
||||
}
|
||||
}
|
||||
|
||||
private void OnDamageModified(EntityUid uid, DamageableClothingComponent component, DamageModifyEvent args)
|
||||
{
|
||||
var modifier = component.DamageModifier;
|
||||
args.Damage = DamageSpecifier.ApplyModifierSet(args.Damage, modifier);
|
||||
}
|
||||
|
||||
private void OnEntityTerminating(EntityUid uid, DamageableClothingUserComponent component, ref EntityTerminatingEvent args)
|
||||
{
|
||||
if (!TryComp<DamageableClothingComponent>(component.ItemId, out var blockingComponent))
|
||||
return;
|
||||
|
||||
RemCompDeferred<DamageableClothingUserComponent>(uid);
|
||||
}
|
||||
|
||||
}
|
||||
Reference in New Issue
Block a user