Remove mech component references (#15246)
This commit is contained in:
@@ -1,12 +0,0 @@
|
|||||||
using Content.Shared.Mech.Components;
|
|
||||||
using Robust.Shared.GameStates;
|
|
||||||
|
|
||||||
namespace Content.Client.Mech;
|
|
||||||
|
|
||||||
/// <inheritdoc/>
|
|
||||||
[RegisterComponent, NetworkedComponent]
|
|
||||||
[ComponentReference(typeof(SharedMechComponent))]
|
|
||||||
public sealed class MechComponent : SharedMechComponent
|
|
||||||
{
|
|
||||||
|
|
||||||
}
|
|
||||||
@@ -1,4 +1,5 @@
|
|||||||
using Content.Shared.Mech;
|
using Content.Shared.Mech;
|
||||||
|
using Content.Shared.Mech.Components;
|
||||||
using Content.Shared.Mech.EntitySystems;
|
using Content.Shared.Mech.EntitySystems;
|
||||||
using Robust.Client.GameObjects;
|
using Robust.Client.GameObjects;
|
||||||
using DrawDepth = Content.Shared.DrawDepth.DrawDepth;
|
using DrawDepth = Content.Shared.DrawDepth.DrawDepth;
|
||||||
|
|||||||
@@ -1,5 +1,6 @@
|
|||||||
using Content.Client.UserInterface.Fragments;
|
using Content.Client.UserInterface.Fragments;
|
||||||
using Content.Shared.Mech;
|
using Content.Shared.Mech;
|
||||||
|
using Content.Shared.Mech.Components;
|
||||||
using JetBrains.Annotations;
|
using JetBrains.Annotations;
|
||||||
using Robust.Client.GameObjects;
|
using Robust.Client.GameObjects;
|
||||||
|
|
||||||
|
|||||||
@@ -31,7 +31,7 @@ public sealed partial class MechMenu : FancyWindow
|
|||||||
|
|
||||||
public void UpdateMechStats()
|
public void UpdateMechStats()
|
||||||
{
|
{
|
||||||
if (!_ent.TryGetComponent<SharedMechComponent>(_mech, out var mechComp))
|
if (!_ent.TryGetComponent<MechComponent>(_mech, out var mechComp))
|
||||||
return;
|
return;
|
||||||
|
|
||||||
var integrityPercent = mechComp.Integrity / mechComp.MaxIntegrity;
|
var integrityPercent = mechComp.Integrity / mechComp.MaxIntegrity;
|
||||||
|
|||||||
@@ -1,7 +1,7 @@
|
|||||||
using Content.Server.Mech.Components;
|
|
||||||
using Content.Server.Mech.Systems;
|
using Content.Server.Mech.Systems;
|
||||||
using Content.Server.Power.Components;
|
using Content.Server.Power.Components;
|
||||||
using Content.Shared.Construction;
|
using Content.Shared.Construction;
|
||||||
|
using Content.Shared.Mech.Components;
|
||||||
using JetBrains.Annotations;
|
using JetBrains.Annotations;
|
||||||
using Robust.Server.Containers;
|
using Robust.Server.Containers;
|
||||||
using Robust.Shared.Containers;
|
using Robust.Shared.Containers;
|
||||||
|
|||||||
12
Content.Server/Mech/Components/MechAirComponent.cs
Normal file
12
Content.Server/Mech/Components/MechAirComponent.cs
Normal file
@@ -0,0 +1,12 @@
|
|||||||
|
using Content.Server.Atmos;
|
||||||
|
|
||||||
|
namespace Content.Server.Mech.Components;
|
||||||
|
|
||||||
|
[RegisterComponent]
|
||||||
|
public sealed class MechAirComponent : Component
|
||||||
|
{
|
||||||
|
//TODO: this doesn't support a tank implant for mechs or anything like that
|
||||||
|
[ViewVariables(VVAccess.ReadWrite)]
|
||||||
|
public GasMixture Air = new (GasMixVolume);
|
||||||
|
public const float GasMixVolume = 70f;
|
||||||
|
}
|
||||||
@@ -1,115 +0,0 @@
|
|||||||
using Content.Server.Atmos;
|
|
||||||
using Content.Shared.Mech.Components;
|
|
||||||
using Robust.Shared.GameStates;
|
|
||||||
using Robust.Shared.Prototypes;
|
|
||||||
using Robust.Shared.Serialization.TypeSerializers.Implementations.Custom.Prototype;
|
|
||||||
using Robust.Shared.Serialization.TypeSerializers.Implementations.Custom.Prototype.List;
|
|
||||||
|
|
||||||
namespace Content.Server.Mech.Components;
|
|
||||||
|
|
||||||
/// <inheritdoc/>
|
|
||||||
[RegisterComponent, NetworkedComponent]
|
|
||||||
[ComponentReference(typeof(SharedMechComponent))]
|
|
||||||
public sealed class MechComponent : SharedMechComponent
|
|
||||||
{
|
|
||||||
/// <summary>
|
|
||||||
/// How long it takes to enter the mech.
|
|
||||||
/// </summary>
|
|
||||||
[DataField("entryDelay")]
|
|
||||||
public float EntryDelay = 3;
|
|
||||||
|
|
||||||
/// <summary>
|
|
||||||
/// How long it takes to pull *another person*
|
|
||||||
/// outside of the mech. You can exit instantly yourself.
|
|
||||||
/// </summary>
|
|
||||||
[DataField("exitDelay")]
|
|
||||||
public float ExitDelay = 3;
|
|
||||||
|
|
||||||
/// <summary>
|
|
||||||
/// How long it takes to pull out the battery.
|
|
||||||
/// </summary>
|
|
||||||
[DataField("batteryRemovalDelay")]
|
|
||||||
public float BatteryRemovalDelay = 2;
|
|
||||||
|
|
||||||
/// <summary>
|
|
||||||
/// Whether or not the mech is airtight.
|
|
||||||
/// </summary>
|
|
||||||
/// <remarks>
|
|
||||||
/// This needs to be redone
|
|
||||||
/// when mech internals are added
|
|
||||||
/// </remarks>
|
|
||||||
[DataField("airtight"), ViewVariables(VVAccess.ReadWrite)]
|
|
||||||
public bool Airtight;
|
|
||||||
|
|
||||||
/// <summary>
|
|
||||||
/// The equipment that the mech initially has when it spawns.
|
|
||||||
/// Good for things like nukie mechs that start with guns.
|
|
||||||
/// </summary>
|
|
||||||
[DataField("startingEquipment", customTypeSerializer: typeof(PrototypeIdListSerializer<EntityPrototype>))]
|
|
||||||
public List<string> StartingEquipment = new();
|
|
||||||
|
|
||||||
/// <summary>
|
|
||||||
/// The battery the mech initially has when it spawns
|
|
||||||
/// Good for admemes and nukie mechs.
|
|
||||||
/// </summary>
|
|
||||||
[DataField("startingBattery", customTypeSerializer: typeof(PrototypeIdSerializer<EntityPrototype>))]
|
|
||||||
public string? StartingBattery;
|
|
||||||
|
|
||||||
//TODO: this doesn't support a tank implant for mechs or anything like that
|
|
||||||
[ViewVariables(VVAccess.ReadWrite)]
|
|
||||||
public GasMixture Air = new (GasMixVolume);
|
|
||||||
public const float GasMixVolume = 70f;
|
|
||||||
}
|
|
||||||
|
|
||||||
/// <summary>
|
|
||||||
/// Event raised when a person successfully enters a mech
|
|
||||||
/// </summary>
|
|
||||||
public sealed class MechEntryFinishedEvent : EntityEventArgs
|
|
||||||
{
|
|
||||||
public EntityUid User;
|
|
||||||
|
|
||||||
public MechEntryFinishedEvent(EntityUid user)
|
|
||||||
{
|
|
||||||
User = user;
|
|
||||||
}
|
|
||||||
}
|
|
||||||
|
|
||||||
/// <summary>
|
|
||||||
/// Event raised when a person fails to enter a mech
|
|
||||||
/// </summary>
|
|
||||||
public sealed class MechEntryCanclledEvent : EntityEventArgs
|
|
||||||
{
|
|
||||||
|
|
||||||
}
|
|
||||||
|
|
||||||
/// <summary>
|
|
||||||
/// Event raised when a person successfully removes someone from a mech
|
|
||||||
/// </summary>
|
|
||||||
public sealed class MechExitFinishedEvent : EntityEventArgs
|
|
||||||
{
|
|
||||||
|
|
||||||
}
|
|
||||||
|
|
||||||
/// <summary>
|
|
||||||
/// Event raised when a person fails to remove someone from a mech
|
|
||||||
/// </summary>
|
|
||||||
public sealed class MechExitCanclledEvent : EntityEventArgs
|
|
||||||
{
|
|
||||||
|
|
||||||
}
|
|
||||||
|
|
||||||
/// <summary>
|
|
||||||
/// Event raised when the battery is successfully removed from the mech
|
|
||||||
/// </summary>
|
|
||||||
public sealed class MechRemoveBatteryFinishedEvent : EntityEventArgs
|
|
||||||
{
|
|
||||||
|
|
||||||
}
|
|
||||||
|
|
||||||
/// <summary>
|
|
||||||
/// Event raised when the battery fails to be removed from the mech
|
|
||||||
/// </summary>
|
|
||||||
public sealed class MechRemoveBatteryCancelledEvent : EntityEventArgs
|
|
||||||
{
|
|
||||||
|
|
||||||
}
|
|
||||||
@@ -1,11 +1,11 @@
|
|||||||
using System.Linq;
|
using System.Linq;
|
||||||
using Content.Server.Interaction;
|
using Content.Server.Interaction;
|
||||||
using Content.Server.Mech.Components;
|
|
||||||
using Content.Server.Mech.Equipment.Components;
|
using Content.Server.Mech.Equipment.Components;
|
||||||
using Content.Server.Mech.Systems;
|
using Content.Server.Mech.Systems;
|
||||||
using Content.Shared.DoAfter;
|
using Content.Shared.DoAfter;
|
||||||
using Content.Shared.Interaction;
|
using Content.Shared.Interaction;
|
||||||
using Content.Shared.Mech;
|
using Content.Shared.Mech;
|
||||||
|
using Content.Shared.Mech.Components;
|
||||||
using Content.Shared.Mech.Equipment.Components;
|
using Content.Shared.Mech.Equipment.Components;
|
||||||
using Content.Shared.Mobs.Components;
|
using Content.Shared.Mobs.Components;
|
||||||
using Content.Shared.Wall;
|
using Content.Shared.Wall;
|
||||||
|
|||||||
@@ -1,7 +1,7 @@
|
|||||||
using Content.Server.Mech.Components;
|
using Content.Server.Popups;
|
||||||
using Content.Server.Popups;
|
|
||||||
using Content.Shared.DoAfter;
|
using Content.Shared.DoAfter;
|
||||||
using Content.Shared.Interaction;
|
using Content.Shared.Interaction;
|
||||||
|
using Content.Shared.Mech.Components;
|
||||||
using Content.Shared.Mech.Equipment.Components;
|
using Content.Shared.Mech.Equipment.Components;
|
||||||
|
|
||||||
namespace Content.Server.Mech.Systems;
|
namespace Content.Server.Mech.Systems;
|
||||||
|
|||||||
@@ -125,7 +125,7 @@ public sealed class MechSystem : SharedMechSystem
|
|||||||
Dirty(component);
|
Dirty(component);
|
||||||
}
|
}
|
||||||
|
|
||||||
private void OnRemoveEquipmentMessage(EntityUid uid, SharedMechComponent component, MechEquipmentRemoveMessage args)
|
private void OnRemoveEquipmentMessage(EntityUid uid, MechComponent component, MechEquipmentRemoveMessage args)
|
||||||
{
|
{
|
||||||
if (!Exists(args.Equipment) || Deleted(args.Equipment))
|
if (!Exists(args.Equipment) || Deleted(args.Equipment))
|
||||||
return;
|
return;
|
||||||
@@ -224,7 +224,7 @@ public sealed class MechSystem : SharedMechSystem
|
|||||||
args.Handled = true;
|
args.Handled = true;
|
||||||
}
|
}
|
||||||
|
|
||||||
private void OnDamageChanged(EntityUid uid, SharedMechComponent component, DamageChangedEvent args)
|
private void OnDamageChanged(EntityUid uid, MechComponent component, DamageChangedEvent args)
|
||||||
{
|
{
|
||||||
var integrity = component.MaxIntegrity - args.Damageable.TotalDamage;
|
var integrity = component.MaxIntegrity - args.Damageable.TotalDamage;
|
||||||
SetIntegrity(uid, integrity, component);
|
SetIntegrity(uid, integrity, component);
|
||||||
@@ -264,7 +264,7 @@ public sealed class MechSystem : SharedMechSystem
|
|||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
public override void UpdateUserInterface(EntityUid uid, SharedMechComponent? component = null)
|
public override void UpdateUserInterface(EntityUid uid, MechComponent? component = null)
|
||||||
{
|
{
|
||||||
if (!Resolve(uid, ref component))
|
if (!Resolve(uid, ref component))
|
||||||
return;
|
return;
|
||||||
@@ -285,7 +285,7 @@ public sealed class MechSystem : SharedMechSystem
|
|||||||
_ui.SetUiState(ui, state);
|
_ui.SetUiState(ui, state);
|
||||||
}
|
}
|
||||||
|
|
||||||
public override bool TryInsert(EntityUid uid, EntityUid? toInsert, SharedMechComponent? component = null)
|
public override bool TryInsert(EntityUid uid, EntityUid? toInsert, MechComponent? component = null)
|
||||||
{
|
{
|
||||||
if (!Resolve(uid, ref component))
|
if (!Resolve(uid, ref component))
|
||||||
return false;
|
return false;
|
||||||
@@ -293,9 +293,7 @@ public sealed class MechSystem : SharedMechSystem
|
|||||||
if (!base.TryInsert(uid, toInsert, component))
|
if (!base.TryInsert(uid, toInsert, component))
|
||||||
return false;
|
return false;
|
||||||
|
|
||||||
var mech = (MechComponent) component;
|
if (component.Airtight && TryComp(uid, out MechAirComponent? mechAir))
|
||||||
|
|
||||||
if (mech.Airtight)
|
|
||||||
{
|
{
|
||||||
var coordinates = Transform(uid).MapPosition;
|
var coordinates = Transform(uid).MapPosition;
|
||||||
if (_map.TryFindGridAt(coordinates, out var grid))
|
if (_map.TryFindGridAt(coordinates, out var grid))
|
||||||
@@ -304,14 +302,14 @@ public sealed class MechSystem : SharedMechSystem
|
|||||||
|
|
||||||
if (_atmosphere.GetTileMixture(tile.GridUid, null, tile.GridIndices, true) is {} environment)
|
if (_atmosphere.GetTileMixture(tile.GridUid, null, tile.GridIndices, true) is {} environment)
|
||||||
{
|
{
|
||||||
_atmosphere.Merge(mech.Air, environment.RemoveVolume(MechComponent.GasMixVolume));
|
_atmosphere.Merge(mechAir.Air, environment.RemoveVolume(MechAirComponent.GasMixVolume));
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
return true;
|
return true;
|
||||||
}
|
}
|
||||||
|
|
||||||
public override bool TryEject(EntityUid uid, SharedMechComponent? component = null)
|
public override bool TryEject(EntityUid uid, MechComponent? component = null)
|
||||||
{
|
{
|
||||||
if (!Resolve(uid, ref component))
|
if (!Resolve(uid, ref component))
|
||||||
return false;
|
return false;
|
||||||
@@ -319,9 +317,7 @@ public sealed class MechSystem : SharedMechSystem
|
|||||||
if (!base.TryEject(uid, component))
|
if (!base.TryEject(uid, component))
|
||||||
return false;
|
return false;
|
||||||
|
|
||||||
var mech = (MechComponent) component;
|
if (component.Airtight && TryComp(uid, out MechAirComponent? mechAir))
|
||||||
|
|
||||||
if (mech.Airtight)
|
|
||||||
{
|
{
|
||||||
var coordinates = Transform(uid).MapPosition;
|
var coordinates = Transform(uid).MapPosition;
|
||||||
if (_map.TryFindGridAt(coordinates, out var grid))
|
if (_map.TryFindGridAt(coordinates, out var grid))
|
||||||
@@ -330,8 +326,8 @@ public sealed class MechSystem : SharedMechSystem
|
|||||||
|
|
||||||
if (_atmosphere.GetTileMixture(tile.GridUid, null, tile.GridIndices, true) is {} environment)
|
if (_atmosphere.GetTileMixture(tile.GridUid, null, tile.GridIndices, true) is {} environment)
|
||||||
{
|
{
|
||||||
_atmosphere.Merge(environment, mech.Air);
|
_atmosphere.Merge(environment, mechAir.Air);
|
||||||
mech.Air.Clear();
|
mechAir.Air.Clear();
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
@@ -339,7 +335,7 @@ public sealed class MechSystem : SharedMechSystem
|
|||||||
return true;
|
return true;
|
||||||
}
|
}
|
||||||
|
|
||||||
public override void BreakMech(EntityUid uid, SharedMechComponent? component = null)
|
public override void BreakMech(EntityUid uid, MechComponent? component = null)
|
||||||
{
|
{
|
||||||
base.BreakMech(uid, component);
|
base.BreakMech(uid, component);
|
||||||
|
|
||||||
@@ -347,7 +343,7 @@ public sealed class MechSystem : SharedMechSystem
|
|||||||
_actionBlocker.UpdateCanMove(uid);
|
_actionBlocker.UpdateCanMove(uid);
|
||||||
}
|
}
|
||||||
|
|
||||||
public override bool TryChangeEnergy(EntityUid uid, FixedPoint2 delta, SharedMechComponent? component = null)
|
public override bool TryChangeEnergy(EntityUid uid, FixedPoint2 delta, MechComponent? component = null)
|
||||||
{
|
{
|
||||||
if (!Resolve(uid, ref component))
|
if (!Resolve(uid, ref component))
|
||||||
return false;
|
return false;
|
||||||
@@ -409,20 +405,26 @@ public sealed class MechSystem : SharedMechSystem
|
|||||||
#region Atmos Handling
|
#region Atmos Handling
|
||||||
private void OnInhale(EntityUid uid, MechPilotComponent component, InhaleLocationEvent args)
|
private void OnInhale(EntityUid uid, MechPilotComponent component, InhaleLocationEvent args)
|
||||||
{
|
{
|
||||||
if (!TryComp<MechComponent>(component.Mech, out var mech))
|
if (!TryComp<MechComponent>(component.Mech, out var mech) ||
|
||||||
|
!TryComp<MechAirComponent>(component.Mech, out var mechAir))
|
||||||
|
{
|
||||||
return;
|
return;
|
||||||
|
}
|
||||||
|
|
||||||
if (mech.Airtight)
|
if (mech.Airtight)
|
||||||
args.Gas = mech.Air;
|
args.Gas = mechAir.Air;
|
||||||
}
|
}
|
||||||
|
|
||||||
private void OnExhale(EntityUid uid, MechPilotComponent component, ExhaleLocationEvent args)
|
private void OnExhale(EntityUid uid, MechPilotComponent component, ExhaleLocationEvent args)
|
||||||
{
|
{
|
||||||
if (!TryComp<MechComponent>(component.Mech, out var mech))
|
if (!TryComp<MechComponent>(component.Mech, out var mech) ||
|
||||||
|
!TryComp<MechAirComponent>(component.Mech, out var mechAir))
|
||||||
|
{
|
||||||
return;
|
return;
|
||||||
|
}
|
||||||
|
|
||||||
if (mech.Airtight)
|
if (mech.Airtight)
|
||||||
args.Gas = mech.Air;
|
args.Gas = mechAir.Air;
|
||||||
}
|
}
|
||||||
|
|
||||||
private void OnExpose(EntityUid uid, MechPilotComponent component, ref AtmosExposedGetAirEvent args)
|
private void OnExpose(EntityUid uid, MechPilotComponent component, ref AtmosExposedGetAirEvent args)
|
||||||
@@ -430,10 +432,13 @@ public sealed class MechSystem : SharedMechSystem
|
|||||||
if (args.Handled)
|
if (args.Handled)
|
||||||
return;
|
return;
|
||||||
|
|
||||||
if (!TryComp<MechComponent>(component.Mech, out var mech))
|
if (!TryComp<MechComponent>(component.Mech, out var mech) ||
|
||||||
|
!TryComp<MechAirComponent>(component.Mech, out var mechAir))
|
||||||
|
{
|
||||||
return;
|
return;
|
||||||
|
}
|
||||||
|
|
||||||
args.Gas = mech.Airtight ? mech.Air : _atmosphere.GetContainingMixture(component.Mech);
|
args.Gas = mech.Airtight ? mechAir.Air : _atmosphere.GetContainingMixture(component.Mech);
|
||||||
|
|
||||||
args.Handled = true;
|
args.Handled = true;
|
||||||
}
|
}
|
||||||
|
|||||||
@@ -2,8 +2,11 @@
|
|||||||
using Content.Shared.FixedPoint;
|
using Content.Shared.FixedPoint;
|
||||||
using Content.Shared.Whitelist;
|
using Content.Shared.Whitelist;
|
||||||
using Robust.Shared.Containers;
|
using Robust.Shared.Containers;
|
||||||
|
using Robust.Shared.GameStates;
|
||||||
|
using Robust.Shared.Prototypes;
|
||||||
using Robust.Shared.Serialization;
|
using Robust.Shared.Serialization;
|
||||||
using Robust.Shared.Serialization.TypeSerializers.Implementations.Custom.Prototype;
|
using Robust.Shared.Serialization.TypeSerializers.Implementations.Custom.Prototype;
|
||||||
|
using Robust.Shared.Serialization.TypeSerializers.Implementations.Custom.Prototype.List;
|
||||||
|
|
||||||
namespace Content.Shared.Mech.Components;
|
namespace Content.Shared.Mech.Components;
|
||||||
|
|
||||||
@@ -11,7 +14,8 @@ namespace Content.Shared.Mech.Components;
|
|||||||
/// A large, pilotable machine that has equipment that is
|
/// A large, pilotable machine that has equipment that is
|
||||||
/// powered via an internal battery.
|
/// powered via an internal battery.
|
||||||
/// </summary>
|
/// </summary>
|
||||||
public abstract class SharedMechComponent : Component
|
[RegisterComponent, NetworkedComponent]
|
||||||
|
public sealed class MechComponent : Component
|
||||||
{
|
{
|
||||||
/// <summary>
|
/// <summary>
|
||||||
/// How much "health" the mech has left.
|
/// How much "health" the mech has left.
|
||||||
@@ -98,6 +102,49 @@ public abstract class SharedMechComponent : Component
|
|||||||
[ViewVariables]
|
[ViewVariables]
|
||||||
public readonly string EquipmentContainerId = "mech-equipment-container";
|
public readonly string EquipmentContainerId = "mech-equipment-container";
|
||||||
|
|
||||||
|
/// <summary>
|
||||||
|
/// How long it takes to enter the mech.
|
||||||
|
/// </summary>
|
||||||
|
[DataField("entryDelay")]
|
||||||
|
public float EntryDelay = 3;
|
||||||
|
|
||||||
|
/// <summary>
|
||||||
|
/// How long it takes to pull *another person*
|
||||||
|
/// outside of the mech. You can exit instantly yourself.
|
||||||
|
/// </summary>
|
||||||
|
[DataField("exitDelay")]
|
||||||
|
public float ExitDelay = 3;
|
||||||
|
|
||||||
|
/// <summary>
|
||||||
|
/// How long it takes to pull out the battery.
|
||||||
|
/// </summary>
|
||||||
|
[DataField("batteryRemovalDelay")]
|
||||||
|
public float BatteryRemovalDelay = 2;
|
||||||
|
|
||||||
|
/// <summary>
|
||||||
|
/// Whether or not the mech is airtight.
|
||||||
|
/// </summary>
|
||||||
|
/// <remarks>
|
||||||
|
/// This needs to be redone
|
||||||
|
/// when mech internals are added
|
||||||
|
/// </remarks>
|
||||||
|
[DataField("airtight"), ViewVariables(VVAccess.ReadWrite)]
|
||||||
|
public bool Airtight;
|
||||||
|
|
||||||
|
/// <summary>
|
||||||
|
/// The equipment that the mech initially has when it spawns.
|
||||||
|
/// Good for things like nukie mechs that start with guns.
|
||||||
|
/// </summary>
|
||||||
|
[DataField("startingEquipment", customTypeSerializer: typeof(PrototypeIdListSerializer<EntityPrototype>))]
|
||||||
|
public List<string> StartingEquipment = new();
|
||||||
|
|
||||||
|
/// <summary>
|
||||||
|
/// The battery the mech initially has when it spawns
|
||||||
|
/// Good for admemes and nukie mechs.
|
||||||
|
/// </summary>
|
||||||
|
[DataField("startingBattery", customTypeSerializer: typeof(PrototypeIdSerializer<EntityPrototype>))]
|
||||||
|
public string? StartingBattery;
|
||||||
|
|
||||||
#region Action Prototypes
|
#region Action Prototypes
|
||||||
[DataField("mechCycleAction", customTypeSerializer: typeof(PrototypeIdSerializer<InstantActionPrototype>))]
|
[DataField("mechCycleAction", customTypeSerializer: typeof(PrototypeIdSerializer<InstantActionPrototype>))]
|
||||||
public string MechCycleAction = "MechCycleEquipment";
|
public string MechCycleAction = "MechCycleEquipment";
|
||||||
@@ -118,7 +165,7 @@ public abstract class SharedMechComponent : Component
|
|||||||
}
|
}
|
||||||
|
|
||||||
/// <summary>
|
/// <summary>
|
||||||
/// Contains network state for <see cref="SharedMechComponent"/>.
|
/// Contains network state for <see cref="MechComponent"/>.
|
||||||
/// </summary>
|
/// </summary>
|
||||||
[Serializable, NetSerializable]
|
[Serializable, NetSerializable]
|
||||||
public sealed class MechComponentState : ComponentState
|
public sealed class MechComponentState : ComponentState
|
||||||
@@ -4,7 +4,7 @@ using Robust.Shared.Serialization;
|
|||||||
namespace Content.Shared.Mech.Components;
|
namespace Content.Shared.Mech.Components;
|
||||||
|
|
||||||
/// <summary>
|
/// <summary>
|
||||||
/// Attached to entities piloting a <see cref="SharedMechComponent"/>
|
/// Attached to entities piloting a <see cref="MechComponent"/>
|
||||||
/// </summary>
|
/// </summary>
|
||||||
/// <remarks>
|
/// <remarks>
|
||||||
/// Get in the robot, Shinji
|
/// Get in the robot, Shinji
|
||||||
|
|||||||
@@ -26,7 +26,7 @@ using Robust.Shared.Timing;
|
|||||||
namespace Content.Shared.Mech.EntitySystems;
|
namespace Content.Shared.Mech.EntitySystems;
|
||||||
|
|
||||||
/// <summary>
|
/// <summary>
|
||||||
/// Handles all of the interactions, UI handling, and items shennanigans for <see cref="SharedMechComponent"/>
|
/// Handles all of the interactions, UI handling, and items shennanigans for <see cref="MechComponent"/>
|
||||||
/// </summary>
|
/// </summary>
|
||||||
public abstract class SharedMechSystem : EntitySystem
|
public abstract class SharedMechSystem : EntitySystem
|
||||||
{
|
{
|
||||||
@@ -44,17 +44,17 @@ public abstract class SharedMechSystem : EntitySystem
|
|||||||
/// <inheritdoc/>
|
/// <inheritdoc/>
|
||||||
public override void Initialize()
|
public override void Initialize()
|
||||||
{
|
{
|
||||||
SubscribeLocalEvent<SharedMechComponent, ComponentGetState>(OnGetState);
|
SubscribeLocalEvent<MechComponent, ComponentGetState>(OnGetState);
|
||||||
SubscribeLocalEvent<SharedMechComponent, ComponentHandleState>(OnHandleState);
|
SubscribeLocalEvent<MechComponent, ComponentHandleState>(OnHandleState);
|
||||||
SubscribeLocalEvent<MechPilotComponent, ComponentGetState>(OnPilotGetState);
|
SubscribeLocalEvent<MechPilotComponent, ComponentGetState>(OnPilotGetState);
|
||||||
SubscribeLocalEvent<MechPilotComponent, ComponentHandleState>(OnPilotHandleState);
|
SubscribeLocalEvent<MechPilotComponent, ComponentHandleState>(OnPilotHandleState);
|
||||||
|
|
||||||
SubscribeLocalEvent<SharedMechComponent, MechToggleEquipmentEvent>(OnToggleEquipmentAction);
|
SubscribeLocalEvent<MechComponent, MechToggleEquipmentEvent>(OnToggleEquipmentAction);
|
||||||
SubscribeLocalEvent<SharedMechComponent, MechEjectPilotEvent>(OnEjectPilotEvent);
|
SubscribeLocalEvent<MechComponent, MechEjectPilotEvent>(OnEjectPilotEvent);
|
||||||
SubscribeLocalEvent<SharedMechComponent, InteractNoHandEvent>(RelayInteractionEvent);
|
SubscribeLocalEvent<MechComponent, InteractNoHandEvent>(RelayInteractionEvent);
|
||||||
SubscribeLocalEvent<SharedMechComponent, ComponentStartup>(OnStartup);
|
SubscribeLocalEvent<MechComponent, ComponentStartup>(OnStartup);
|
||||||
SubscribeLocalEvent<SharedMechComponent, DestructionEventArgs>(OnDestruction);
|
SubscribeLocalEvent<MechComponent, DestructionEventArgs>(OnDestruction);
|
||||||
SubscribeLocalEvent<SharedMechComponent, GetAdditionalAccessEvent>(OnGetAdditionalAccess);
|
SubscribeLocalEvent<MechComponent, GetAdditionalAccessEvent>(OnGetAdditionalAccess);
|
||||||
|
|
||||||
SubscribeLocalEvent<MechPilotComponent, GetMeleeWeaponEvent>(OnGetMeleeWeapon);
|
SubscribeLocalEvent<MechPilotComponent, GetMeleeWeaponEvent>(OnGetMeleeWeapon);
|
||||||
SubscribeLocalEvent<MechPilotComponent, CanAttackFromContainerEvent>(OnCanAttackFromContainer);
|
SubscribeLocalEvent<MechPilotComponent, CanAttackFromContainerEvent>(OnCanAttackFromContainer);
|
||||||
@@ -63,7 +63,7 @@ public abstract class SharedMechSystem : EntitySystem
|
|||||||
|
|
||||||
#region State Handling
|
#region State Handling
|
||||||
|
|
||||||
private void OnGetState(EntityUid uid, SharedMechComponent component, ref ComponentGetState args)
|
private void OnGetState(EntityUid uid, MechComponent component, ref ComponentGetState args)
|
||||||
{
|
{
|
||||||
args.State = new MechComponentState
|
args.State = new MechComponentState
|
||||||
{
|
{
|
||||||
@@ -76,7 +76,7 @@ public abstract class SharedMechSystem : EntitySystem
|
|||||||
};
|
};
|
||||||
}
|
}
|
||||||
|
|
||||||
private void OnHandleState(EntityUid uid, SharedMechComponent component, ref ComponentHandleState args)
|
private void OnHandleState(EntityUid uid, MechComponent component, ref ComponentHandleState args)
|
||||||
{
|
{
|
||||||
if (args.Current is not MechComponentState state)
|
if (args.Current is not MechComponentState state)
|
||||||
return;
|
return;
|
||||||
@@ -107,7 +107,7 @@ public abstract class SharedMechSystem : EntitySystem
|
|||||||
|
|
||||||
#endregion
|
#endregion
|
||||||
|
|
||||||
private void OnToggleEquipmentAction(EntityUid uid, SharedMechComponent component, MechToggleEquipmentEvent args)
|
private void OnToggleEquipmentAction(EntityUid uid, MechComponent component, MechToggleEquipmentEvent args)
|
||||||
{
|
{
|
||||||
if (args.Handled)
|
if (args.Handled)
|
||||||
return;
|
return;
|
||||||
@@ -115,7 +115,7 @@ public abstract class SharedMechSystem : EntitySystem
|
|||||||
CycleEquipment(uid);
|
CycleEquipment(uid);
|
||||||
}
|
}
|
||||||
|
|
||||||
private void OnEjectPilotEvent(EntityUid uid, SharedMechComponent component, MechEjectPilotEvent args)
|
private void OnEjectPilotEvent(EntityUid uid, MechComponent component, MechEjectPilotEvent args)
|
||||||
{
|
{
|
||||||
if (args.Handled)
|
if (args.Handled)
|
||||||
return;
|
return;
|
||||||
@@ -123,7 +123,7 @@ public abstract class SharedMechSystem : EntitySystem
|
|||||||
TryEject(uid, component);
|
TryEject(uid, component);
|
||||||
}
|
}
|
||||||
|
|
||||||
private void RelayInteractionEvent(EntityUid uid, SharedMechComponent component, InteractNoHandEvent args)
|
private void RelayInteractionEvent(EntityUid uid, MechComponent component, InteractNoHandEvent args)
|
||||||
{
|
{
|
||||||
var pilot = component.PilotSlot.ContainedEntity;
|
var pilot = component.PilotSlot.ContainedEntity;
|
||||||
if (pilot == null)
|
if (pilot == null)
|
||||||
@@ -139,7 +139,7 @@ public abstract class SharedMechSystem : EntitySystem
|
|||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
private void OnStartup(EntityUid uid, SharedMechComponent component, ComponentStartup args)
|
private void OnStartup(EntityUid uid, MechComponent component, ComponentStartup args)
|
||||||
{
|
{
|
||||||
component.PilotSlot = _container.EnsureContainer<ContainerSlot>(uid, component.PilotSlotId);
|
component.PilotSlot = _container.EnsureContainer<ContainerSlot>(uid, component.PilotSlotId);
|
||||||
component.EquipmentContainer = _container.EnsureContainer<Container>(uid, component.EquipmentContainerId);
|
component.EquipmentContainer = _container.EnsureContainer<Container>(uid, component.EquipmentContainerId);
|
||||||
@@ -147,12 +147,12 @@ public abstract class SharedMechSystem : EntitySystem
|
|||||||
UpdateAppearance(uid, component);
|
UpdateAppearance(uid, component);
|
||||||
}
|
}
|
||||||
|
|
||||||
private void OnDestruction(EntityUid uid, SharedMechComponent component, DestructionEventArgs args)
|
private void OnDestruction(EntityUid uid, MechComponent component, DestructionEventArgs args)
|
||||||
{
|
{
|
||||||
BreakMech(uid, component);
|
BreakMech(uid, component);
|
||||||
}
|
}
|
||||||
|
|
||||||
private void OnGetAdditionalAccess(EntityUid uid, SharedMechComponent component, ref GetAdditionalAccessEvent args)
|
private void OnGetAdditionalAccess(EntityUid uid, MechComponent component, ref GetAdditionalAccessEvent args)
|
||||||
{
|
{
|
||||||
var pilot = component.PilotSlot.ContainedEntity;
|
var pilot = component.PilotSlot.ContainedEntity;
|
||||||
if (pilot == null)
|
if (pilot == null)
|
||||||
@@ -163,7 +163,7 @@ public abstract class SharedMechSystem : EntitySystem
|
|||||||
args.Entities.UnionWith(items);
|
args.Entities.UnionWith(items);
|
||||||
}
|
}
|
||||||
|
|
||||||
private void SetupUser(EntityUid mech, EntityUid pilot, SharedMechComponent? component = null)
|
private void SetupUser(EntityUid mech, EntityUid pilot, MechComponent? component = null)
|
||||||
{
|
{
|
||||||
if (!Resolve(mech, ref component))
|
if (!Resolve(mech, ref component))
|
||||||
return;
|
return;
|
||||||
@@ -202,7 +202,7 @@ public abstract class SharedMechSystem : EntitySystem
|
|||||||
/// </summary>
|
/// </summary>
|
||||||
/// <param name="uid"></param>
|
/// <param name="uid"></param>
|
||||||
/// <param name="component"></param>
|
/// <param name="component"></param>
|
||||||
public virtual void BreakMech(EntityUid uid, SharedMechComponent? component = null)
|
public virtual void BreakMech(EntityUid uid, MechComponent? component = null)
|
||||||
{
|
{
|
||||||
if (!Resolve(uid, ref component))
|
if (!Resolve(uid, ref component))
|
||||||
return;
|
return;
|
||||||
@@ -223,7 +223,7 @@ public abstract class SharedMechSystem : EntitySystem
|
|||||||
/// </summary>
|
/// </summary>
|
||||||
/// <param name="uid"></param>
|
/// <param name="uid"></param>
|
||||||
/// <param name="component"></param>
|
/// <param name="component"></param>
|
||||||
public void CycleEquipment(EntityUid uid, SharedMechComponent? component = null)
|
public void CycleEquipment(EntityUid uid, MechComponent? component = null)
|
||||||
{
|
{
|
||||||
if (!Resolve(uid, ref component))
|
if (!Resolve(uid, ref component))
|
||||||
return;
|
return;
|
||||||
@@ -259,7 +259,7 @@ public abstract class SharedMechSystem : EntitySystem
|
|||||||
/// <param name="toInsert"></param>
|
/// <param name="toInsert"></param>
|
||||||
/// <param name="component"></param>
|
/// <param name="component"></param>
|
||||||
/// <param name="equipmentComponent"></param>
|
/// <param name="equipmentComponent"></param>
|
||||||
public void InsertEquipment(EntityUid uid, EntityUid toInsert, SharedMechComponent? component = null,
|
public void InsertEquipment(EntityUid uid, EntityUid toInsert, MechComponent? component = null,
|
||||||
MechEquipmentComponent? equipmentComponent = null)
|
MechEquipmentComponent? equipmentComponent = null)
|
||||||
{
|
{
|
||||||
if (!Resolve(uid, ref component))
|
if (!Resolve(uid, ref component))
|
||||||
@@ -289,7 +289,7 @@ public abstract class SharedMechSystem : EntitySystem
|
|||||||
/// <param name="component"></param>
|
/// <param name="component"></param>
|
||||||
/// <param name="equipmentComponent"></param>
|
/// <param name="equipmentComponent"></param>
|
||||||
/// <param name="forced">Whether or not the removal can be cancelled</param>
|
/// <param name="forced">Whether or not the removal can be cancelled</param>
|
||||||
public void RemoveEquipment(EntityUid uid, EntityUid toRemove, SharedMechComponent? component = null,
|
public void RemoveEquipment(EntityUid uid, EntityUid toRemove, MechComponent? component = null,
|
||||||
MechEquipmentComponent? equipmentComponent = null, bool forced = false)
|
MechEquipmentComponent? equipmentComponent = null, bool forced = false)
|
||||||
{
|
{
|
||||||
if (!Resolve(uid, ref component))
|
if (!Resolve(uid, ref component))
|
||||||
@@ -324,7 +324,7 @@ public abstract class SharedMechSystem : EntitySystem
|
|||||||
/// <param name="delta">The change in energy</param>
|
/// <param name="delta">The change in energy</param>
|
||||||
/// <param name="component"></param>
|
/// <param name="component"></param>
|
||||||
/// <returns>If the energy was successfully changed.</returns>
|
/// <returns>If the energy was successfully changed.</returns>
|
||||||
public virtual bool TryChangeEnergy(EntityUid uid, FixedPoint2 delta, SharedMechComponent? component = null)
|
public virtual bool TryChangeEnergy(EntityUid uid, FixedPoint2 delta, MechComponent? component = null)
|
||||||
{
|
{
|
||||||
if (!Resolve(uid, ref component))
|
if (!Resolve(uid, ref component))
|
||||||
return false;
|
return false;
|
||||||
@@ -344,7 +344,7 @@ public abstract class SharedMechSystem : EntitySystem
|
|||||||
/// <param name="uid">The mech itself</param>
|
/// <param name="uid">The mech itself</param>
|
||||||
/// <param name="value">The value the integrity will be set at</param>
|
/// <param name="value">The value the integrity will be set at</param>
|
||||||
/// <param name="component"></param>
|
/// <param name="component"></param>
|
||||||
public void SetIntegrity(EntityUid uid, FixedPoint2 value, SharedMechComponent? component = null)
|
public void SetIntegrity(EntityUid uid, FixedPoint2 value, MechComponent? component = null)
|
||||||
{
|
{
|
||||||
if (!Resolve(uid, ref component))
|
if (!Resolve(uid, ref component))
|
||||||
return;
|
return;
|
||||||
@@ -370,7 +370,7 @@ public abstract class SharedMechSystem : EntitySystem
|
|||||||
/// </summary>
|
/// </summary>
|
||||||
/// <param name="component"></param>
|
/// <param name="component"></param>
|
||||||
/// <returns>Whether or not the pilot is present</returns>
|
/// <returns>Whether or not the pilot is present</returns>
|
||||||
public bool IsEmpty(SharedMechComponent component)
|
public bool IsEmpty(MechComponent component)
|
||||||
{
|
{
|
||||||
return component.PilotSlot.ContainedEntity == null;
|
return component.PilotSlot.ContainedEntity == null;
|
||||||
}
|
}
|
||||||
@@ -382,7 +382,7 @@ public abstract class SharedMechSystem : EntitySystem
|
|||||||
/// <param name="toInsert"></param>
|
/// <param name="toInsert"></param>
|
||||||
/// <param name="component"></param>
|
/// <param name="component"></param>
|
||||||
/// <returns></returns>
|
/// <returns></returns>
|
||||||
public bool CanInsert(EntityUid uid, EntityUid toInsert, SharedMechComponent? component = null)
|
public bool CanInsert(EntityUid uid, EntityUid toInsert, MechComponent? component = null)
|
||||||
{
|
{
|
||||||
if (!Resolve(uid, ref component))
|
if (!Resolve(uid, ref component))
|
||||||
return false;
|
return false;
|
||||||
@@ -396,7 +396,7 @@ public abstract class SharedMechSystem : EntitySystem
|
|||||||
/// <remarks>
|
/// <remarks>
|
||||||
/// This is defined here so that UI updates can be accessed from shared.
|
/// This is defined here so that UI updates can be accessed from shared.
|
||||||
/// </remarks>
|
/// </remarks>
|
||||||
public virtual void UpdateUserInterface(EntityUid uid, SharedMechComponent? component = null)
|
public virtual void UpdateUserInterface(EntityUid uid, MechComponent? component = null)
|
||||||
{
|
{
|
||||||
}
|
}
|
||||||
|
|
||||||
@@ -407,7 +407,7 @@ public abstract class SharedMechSystem : EntitySystem
|
|||||||
/// <param name="toInsert"></param>
|
/// <param name="toInsert"></param>
|
||||||
/// <param name="component"></param>
|
/// <param name="component"></param>
|
||||||
/// <returns>Whether or not the entity was inserted</returns>
|
/// <returns>Whether or not the entity was inserted</returns>
|
||||||
public virtual bool TryInsert(EntityUid uid, EntityUid? toInsert, SharedMechComponent? component = null)
|
public virtual bool TryInsert(EntityUid uid, EntityUid? toInsert, MechComponent? component = null)
|
||||||
{
|
{
|
||||||
if (!Resolve(uid, ref component))
|
if (!Resolve(uid, ref component))
|
||||||
return false;
|
return false;
|
||||||
@@ -430,7 +430,7 @@ public abstract class SharedMechSystem : EntitySystem
|
|||||||
/// <param name="uid"></param>
|
/// <param name="uid"></param>
|
||||||
/// <param name="component"></param>
|
/// <param name="component"></param>
|
||||||
/// <returns>Whether or not the pilot was ejected.</returns>
|
/// <returns>Whether or not the pilot was ejected.</returns>
|
||||||
public virtual bool TryEject(EntityUid uid, SharedMechComponent? component = null)
|
public virtual bool TryEject(EntityUid uid, MechComponent? component = null)
|
||||||
{
|
{
|
||||||
if (!Resolve(uid, ref component))
|
if (!Resolve(uid, ref component))
|
||||||
return false;
|
return false;
|
||||||
@@ -451,7 +451,7 @@ public abstract class SharedMechSystem : EntitySystem
|
|||||||
if (args.Handled)
|
if (args.Handled)
|
||||||
return;
|
return;
|
||||||
|
|
||||||
if (!TryComp<SharedMechComponent>(component.Mech, out var mech))
|
if (!TryComp<MechComponent>(component.Mech, out var mech))
|
||||||
return;
|
return;
|
||||||
|
|
||||||
var weapon = mech.CurrentSelectedEquipment ?? component.Mech;
|
var weapon = mech.CurrentSelectedEquipment ?? component.Mech;
|
||||||
@@ -470,7 +470,7 @@ public abstract class SharedMechSystem : EntitySystem
|
|||||||
args.Cancel();
|
args.Cancel();
|
||||||
}
|
}
|
||||||
|
|
||||||
private void UpdateAppearance(EntityUid uid, SharedMechComponent? component = null,
|
private void UpdateAppearance(EntityUid uid, MechComponent? component = null,
|
||||||
AppearanceComponent? appearance = null)
|
AppearanceComponent? appearance = null)
|
||||||
{
|
{
|
||||||
if (!Resolve(uid, ref component, ref appearance, false))
|
if (!Resolve(uid, ref component, ref appearance, false))
|
||||||
|
|||||||
@@ -1,12 +1,11 @@
|
|||||||
using System.Threading;
|
using Content.Shared.DoAfter;
|
||||||
using Content.Shared.DoAfter;
|
|
||||||
using Content.Shared.Mech.Components;
|
using Content.Shared.Mech.Components;
|
||||||
using Robust.Shared.Serialization;
|
using Robust.Shared.Serialization;
|
||||||
|
|
||||||
namespace Content.Shared.Mech.Equipment.Components;
|
namespace Content.Shared.Mech.Equipment.Components;
|
||||||
|
|
||||||
/// <summary>
|
/// <summary>
|
||||||
/// A piece of equipment that can be installed into <see cref="SharedMechComponent"/>
|
/// A piece of equipment that can be installed into <see cref="MechComponent"/>
|
||||||
/// </summary>
|
/// </summary>
|
||||||
[RegisterComponent]
|
[RegisterComponent]
|
||||||
public sealed class MechEquipmentComponent : Component
|
public sealed class MechEquipmentComponent : Component
|
||||||
|
|||||||
@@ -16,6 +16,7 @@
|
|||||||
baseState: ripley
|
baseState: ripley
|
||||||
openState: ripley-open
|
openState: ripley-open
|
||||||
brokenState: ripley-broken
|
brokenState: ripley-broken
|
||||||
|
- type: MechAir
|
||||||
- type: DoAfter
|
- type: DoAfter
|
||||||
- type: Repairable
|
- type: Repairable
|
||||||
fuelCost: 25
|
fuelCost: 25
|
||||||
|
|||||||
Reference in New Issue
Block a user