Remove mech component references (#15246)
This commit is contained in:
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 Content.Server.Interaction;
|
||||
using Content.Server.Mech.Components;
|
||||
using Content.Server.Mech.Equipment.Components;
|
||||
using Content.Server.Mech.Systems;
|
||||
using Content.Shared.DoAfter;
|
||||
using Content.Shared.Interaction;
|
||||
using Content.Shared.Mech;
|
||||
using Content.Shared.Mech.Components;
|
||||
using Content.Shared.Mech.Equipment.Components;
|
||||
using Content.Shared.Mobs.Components;
|
||||
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.Interaction;
|
||||
using Content.Shared.Mech.Components;
|
||||
using Content.Shared.Mech.Equipment.Components;
|
||||
|
||||
namespace Content.Server.Mech.Systems;
|
||||
|
||||
@@ -125,7 +125,7 @@ public sealed class MechSystem : SharedMechSystem
|
||||
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))
|
||||
return;
|
||||
@@ -224,7 +224,7 @@ public sealed class MechSystem : SharedMechSystem
|
||||
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;
|
||||
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))
|
||||
return;
|
||||
@@ -285,7 +285,7 @@ public sealed class MechSystem : SharedMechSystem
|
||||
_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))
|
||||
return false;
|
||||
@@ -293,9 +293,7 @@ public sealed class MechSystem : SharedMechSystem
|
||||
if (!base.TryInsert(uid, toInsert, component))
|
||||
return false;
|
||||
|
||||
var mech = (MechComponent) component;
|
||||
|
||||
if (mech.Airtight)
|
||||
if (component.Airtight && TryComp(uid, out MechAirComponent? mechAir))
|
||||
{
|
||||
var coordinates = Transform(uid).MapPosition;
|
||||
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)
|
||||
{
|
||||
_atmosphere.Merge(mech.Air, environment.RemoveVolume(MechComponent.GasMixVolume));
|
||||
_atmosphere.Merge(mechAir.Air, environment.RemoveVolume(MechAirComponent.GasMixVolume));
|
||||
}
|
||||
}
|
||||
}
|
||||
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))
|
||||
return false;
|
||||
@@ -319,9 +317,7 @@ public sealed class MechSystem : SharedMechSystem
|
||||
if (!base.TryEject(uid, component))
|
||||
return false;
|
||||
|
||||
var mech = (MechComponent) component;
|
||||
|
||||
if (mech.Airtight)
|
||||
if (component.Airtight && TryComp(uid, out MechAirComponent? mechAir))
|
||||
{
|
||||
var coordinates = Transform(uid).MapPosition;
|
||||
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)
|
||||
{
|
||||
_atmosphere.Merge(environment, mech.Air);
|
||||
mech.Air.Clear();
|
||||
_atmosphere.Merge(environment, mechAir.Air);
|
||||
mechAir.Air.Clear();
|
||||
}
|
||||
}
|
||||
}
|
||||
@@ -339,7 +335,7 @@ public sealed class MechSystem : SharedMechSystem
|
||||
return true;
|
||||
}
|
||||
|
||||
public override void BreakMech(EntityUid uid, SharedMechComponent? component = null)
|
||||
public override void BreakMech(EntityUid uid, MechComponent? component = null)
|
||||
{
|
||||
base.BreakMech(uid, component);
|
||||
|
||||
@@ -347,7 +343,7 @@ public sealed class MechSystem : SharedMechSystem
|
||||
_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))
|
||||
return false;
|
||||
@@ -409,20 +405,26 @@ public sealed class MechSystem : SharedMechSystem
|
||||
#region Atmos Handling
|
||||
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;
|
||||
}
|
||||
|
||||
if (mech.Airtight)
|
||||
args.Gas = mech.Air;
|
||||
args.Gas = mechAir.Air;
|
||||
}
|
||||
|
||||
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;
|
||||
}
|
||||
|
||||
if (mech.Airtight)
|
||||
args.Gas = mech.Air;
|
||||
args.Gas = mechAir.Air;
|
||||
}
|
||||
|
||||
private void OnExpose(EntityUid uid, MechPilotComponent component, ref AtmosExposedGetAirEvent args)
|
||||
@@ -430,10 +432,13 @@ public sealed class MechSystem : SharedMechSystem
|
||||
if (args.Handled)
|
||||
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;
|
||||
}
|
||||
|
||||
args.Gas = mech.Airtight ? mech.Air : _atmosphere.GetContainingMixture(component.Mech);
|
||||
args.Gas = mech.Airtight ? mechAir.Air : _atmosphere.GetContainingMixture(component.Mech);
|
||||
|
||||
args.Handled = true;
|
||||
}
|
||||
|
||||
Reference in New Issue
Block a user