Convert atmos device events to ref events (#22843)
This commit is contained in:
@@ -1,60 +1,73 @@
|
||||
namespace Content.Server.Atmos.Piping.Components
|
||||
using Content.Server.Atmos.Components;
|
||||
|
||||
namespace Content.Server.Atmos.Piping.Components;
|
||||
|
||||
/// <summary>
|
||||
/// Component for atmos devices which are updated in line with atmos, as part of a <see cref="GridAtmosphereComponent"/>
|
||||
/// </summary>
|
||||
[RegisterComponent]
|
||||
public sealed partial class AtmosDeviceComponent : Component
|
||||
{
|
||||
/// <summary>
|
||||
/// Adds itself to a <see cref="IAtmosphereComponent"/> to be updated by.
|
||||
/// If true, this device must be anchored before it will receive any AtmosDeviceUpdateEvents.
|
||||
/// </summary>
|
||||
[RegisterComponent]
|
||||
public sealed partial class AtmosDeviceComponent : Component
|
||||
{
|
||||
/// <summary>
|
||||
/// If true, this device must be anchored before it will receive any AtmosDeviceUpdateEvents.
|
||||
/// </summary>
|
||||
[ViewVariables(VVAccess.ReadWrite)]
|
||||
[DataField("requireAnchored")]
|
||||
public bool RequireAnchored { get; private set; } = true;
|
||||
[ViewVariables(VVAccess.ReadWrite)]
|
||||
[DataField]
|
||||
public bool RequireAnchored = true;
|
||||
|
||||
/// <summary>
|
||||
/// If true, update even when there is no grid atmosphere. Normally, atmos devices only
|
||||
/// update when inside a grid atmosphere, because they work with gases in the environment
|
||||
/// and won't do anything useful if there is no environment. This is useful for devices
|
||||
/// like gas canisters whose contents can still react if the canister itself is not inside
|
||||
/// a grid atmosphere.
|
||||
/// </summary>
|
||||
[DataField("joinSystem")]
|
||||
public bool JoinSystem { get; private set; } = false;
|
||||
/// <summary>
|
||||
/// If true, update even when there is no grid atmosphere. Normally, atmos devices only
|
||||
/// update when inside a grid atmosphere, because they work with gases in the environment
|
||||
/// and won't do anything useful if there is no environment. This is useful for devices
|
||||
/// like gas canisters whose contents can still react if the canister itself is not inside
|
||||
/// a grid atmosphere.
|
||||
/// </summary>
|
||||
[DataField]
|
||||
public bool JoinSystem = false;
|
||||
|
||||
/// <summary>
|
||||
/// If non-null, the grid that this device is part of.
|
||||
/// </summary>
|
||||
public EntityUid? JoinedGrid { get; set; }
|
||||
/// <summary>
|
||||
/// If non-null, the grid that this device is part of.
|
||||
/// </summary>
|
||||
[DataField]
|
||||
public EntityUid? JoinedGrid = null;
|
||||
|
||||
/// <summary>
|
||||
/// Indicates that a device is not on a grid atmosphere but still being updated.
|
||||
/// </summary>
|
||||
[ViewVariables]
|
||||
public bool JoinedSystem { get; set; } = false;
|
||||
/// <summary>
|
||||
/// Indicates that a device is not on a grid atmosphere but still being updated.
|
||||
/// </summary>
|
||||
[ViewVariables]
|
||||
public bool JoinedSystem = false;
|
||||
|
||||
[ViewVariables]
|
||||
public TimeSpan LastProcess { get; set; } = TimeSpan.Zero;
|
||||
}
|
||||
|
||||
public sealed class AtmosDeviceUpdateEvent : EntityEventArgs
|
||||
{
|
||||
/// <summary>
|
||||
/// Time elapsed since last update, in seconds. Multiply values used in the update handler
|
||||
/// by this number to make them tickrate-invariant. Use this number instead of AtmosphereSystem.AtmosTime.
|
||||
/// </summary>
|
||||
public float dt;
|
||||
|
||||
public AtmosDeviceUpdateEvent(float dt)
|
||||
{
|
||||
this.dt = dt;
|
||||
}
|
||||
}
|
||||
|
||||
public sealed class AtmosDeviceEnabledEvent : EntityEventArgs
|
||||
{}
|
||||
|
||||
public sealed class AtmosDeviceDisabledEvent : EntityEventArgs
|
||||
{}
|
||||
[ViewVariables]
|
||||
public TimeSpan LastProcess = TimeSpan.Zero;
|
||||
}
|
||||
|
||||
/// <summary>
|
||||
/// Raised directed on an atmos device as part of the atmos update loop when the device should do processing.
|
||||
/// Use this for atmos devices instead of <see cref="EntitySystem.Update"/>.
|
||||
/// </summary>
|
||||
[ByRefEvent]
|
||||
public readonly struct AtmosDeviceUpdateEvent
|
||||
{
|
||||
/// <summary>
|
||||
/// Time elapsed since last update, in seconds. Multiply values used in the update handler
|
||||
/// by this number to make them tickrate-invariant. Use this number instead of AtmosphereSystem.AtmosTime.
|
||||
/// </summary>
|
||||
public readonly float dt;
|
||||
|
||||
public AtmosDeviceUpdateEvent(float dt)
|
||||
{
|
||||
this.dt = dt;
|
||||
}
|
||||
}
|
||||
|
||||
/// <summary>
|
||||
/// Raised directed on an atmos device when it is enabled.
|
||||
/// </summary>
|
||||
[ByRefEvent]
|
||||
public record struct AtmosDeviceEnabledEvent;
|
||||
|
||||
/// <summary>
|
||||
/// Raised directed on an atmos device when it is enabled.
|
||||
/// </summary>
|
||||
[ByRefEvent]
|
||||
public record struct AtmosDeviceDisabledEvent;
|
||||
|
||||
Reference in New Issue
Block a user