Splits the singularity into its component parts + ECS singularity + Support for singularities in containers. (#12132)
* InitialCommit (Broken) * Fixes compile errors * PR comments. More doc comments. Fixes * Makes a singularity/event horizon without radiation/physics a valid state to be in * VV 'fake' setters, fixes the visualizer, fixes the singularity trying to eat itself instead of nearby things. * Removes unused dependency from Content.Client.GravityWellSystem * Testing containment and fake VV setters for SingularityGeneratorComponent * Fixes gravity wells (broken due to LookupFlags.None). Adds recursive Event Horizon consumption * Fix merge skew * Fixes for the master merge * Fix engine commit * Dirty is obsolete * Switch over dirty * Fix requested changes * ambiant -> ambient * Moves EventHorionComponent to Shared * Proper container handling * Fixes master merge. Fixes post insertion assertions for singularities. Extends proper container handling to gravity wells and the distortion shader. * Better support for admemes throwing singularities. * Moves update timing from accumulators to target times * Update doc comments
This commit is contained in:
@@ -0,0 +1,71 @@
|
||||
using Robust.Shared.GameStates;
|
||||
using Content.Shared.Singularity.EntitySystems;
|
||||
|
||||
namespace Content.Shared.Singularity.Components;
|
||||
|
||||
/// <summary>
|
||||
/// A component that makes the associated entity destroy other within some distance of itself.
|
||||
/// Also makes the associated entity destroy other entities upon contact.
|
||||
/// Primarily managed by <see cref="SharedEventHorizonSystem"/> and its server/client versions.
|
||||
/// </summary>
|
||||
[RegisterComponent, NetworkedComponent]
|
||||
public sealed class EventHorizonComponent : Component
|
||||
{
|
||||
/// <summary>
|
||||
/// The radius of the event horizon within which it will destroy all entities and tiles.
|
||||
/// If < 0.0 this behavior will not be active.
|
||||
/// If you want to set this go through <see cref="SharedEventHorizonSystem.SetRadius"/>.
|
||||
/// </summary>
|
||||
[DataField("radius")]
|
||||
[Access(friends:typeof(SharedEventHorizonSystem))]
|
||||
public float Radius;
|
||||
|
||||
/// <summary>
|
||||
/// Whether the event horizon can consume/destroy the devices built to contain it.
|
||||
/// If you want to set this go through <see cref="SharedEventHorizonSystem.SetCanBreachContainment"/>.
|
||||
/// </summary>
|
||||
[DataField("canBreachContainment")]
|
||||
[Access(friends:typeof(SharedEventHorizonSystem))]
|
||||
public bool CanBreachContainment = false;
|
||||
|
||||
/// <summary>
|
||||
/// The ID of the fixture used to detect if the event horizon has collided with any physics objects.
|
||||
/// Can be set to null, in which case no such fixture is used.
|
||||
/// If you want to set this go through <see cref="SharedEventHorizonSystem.SetHorizonFixtureId"/>.
|
||||
/// </summary>
|
||||
[DataField("horizonFixtureId")]
|
||||
[Access(friends:typeof(SharedEventHorizonSystem))]
|
||||
public string? HorizonFixtureId = "EventHorizon";
|
||||
|
||||
/// <summary>
|
||||
/// Whether the entity this event horizon is attached to is being consumed by another event horizon.
|
||||
/// </summary>
|
||||
[ViewVariables(VVAccess.ReadOnly)]
|
||||
public bool BeingConsumedByAnotherEventHorizon = false;
|
||||
|
||||
#region Update Timing
|
||||
|
||||
/// <summary>
|
||||
/// The amount of time that should elapse between this event horizon consuming everything it overlaps with.
|
||||
/// </summary>
|
||||
[DataField("consumePeriod")]
|
||||
[ViewVariables(VVAccess.ReadOnly)]
|
||||
[Access(typeof(SharedEventHorizonSystem))]
|
||||
public TimeSpan TargetConsumePeriod { get; set; } = TimeSpan.FromSeconds(0.5);
|
||||
|
||||
/// <summary>
|
||||
/// The last time at which this consumed everything it overlapped with.
|
||||
/// </summary>
|
||||
[ViewVariables(VVAccess.ReadOnly)]
|
||||
[Access(typeof(SharedEventHorizonSystem))]
|
||||
public TimeSpan LastConsumeWaveTime { get; set; } = default!;
|
||||
|
||||
/// <summary>
|
||||
/// The next time at which this consumed everything it overlapped with.
|
||||
/// </summary>
|
||||
[ViewVariables(VVAccess.ReadOnly)]
|
||||
[Access(typeof(SharedEventHorizonSystem))]
|
||||
public TimeSpan NextConsumeWaveTime { get; set; } = default!;
|
||||
|
||||
#endregion Update Timing
|
||||
}
|
||||
@@ -1,42 +1,32 @@
|
||||
using Robust.Shared.GameStates;
|
||||
using Robust.Shared.Serialization;
|
||||
|
||||
namespace Content.Shared.Singularity.Components
|
||||
using Content.Shared.Singularity.EntitySystems;
|
||||
|
||||
namespace Content.Shared.Singularity.Components;
|
||||
|
||||
/// <summary>
|
||||
/// A component that makes the associated entity accumulate energy when an associated event horizon consumes things.
|
||||
/// Energy management is server-side.
|
||||
/// </summary>
|
||||
[NetworkedComponent]
|
||||
public abstract class SharedSingularityComponent : Component
|
||||
{
|
||||
[NetworkedComponent]
|
||||
public abstract class SharedSingularityComponent : Component
|
||||
{
|
||||
/// <summary>
|
||||
/// The radiation pulse component's radsPerSecond is set to the singularity's level multiplied by this number.
|
||||
/// </summary>
|
||||
[DataField("radsPerLevel")]
|
||||
public float RadsPerLevel = 1;
|
||||
/// <summary>
|
||||
/// The current level of the singularity.
|
||||
/// Used as a scaling factor for things like visual size, event horizon radius, gravity well radius, radiation output, etc.
|
||||
/// If you want to set this use <see cref="SharedSingularitySystem.SetLevel"/>().
|
||||
/// </summary>
|
||||
[DataField("level")]
|
||||
[Access(friends:typeof(SharedSingularitySystem), Other=AccessPermissions.Read, Self=AccessPermissions.Read)]
|
||||
public byte Level = 1;
|
||||
|
||||
/// <summary>
|
||||
/// Changed by <see cref="SharedSingularitySystem.ChangeSingularityLevel"/>
|
||||
/// </summary>
|
||||
[ViewVariables]
|
||||
public int Level { get; set; }
|
||||
|
||||
public override void HandleComponentState(ComponentState? curState, ComponentState? nextState)
|
||||
{
|
||||
if (curState is not SingularityComponentState state)
|
||||
{
|
||||
return;
|
||||
}
|
||||
|
||||
EntitySystem.Get<SharedSingularitySystem>().ChangeSingularityLevel(this, state.Level);
|
||||
}
|
||||
}
|
||||
|
||||
[Serializable, NetSerializable]
|
||||
public sealed class SingularityComponentState : ComponentState
|
||||
{
|
||||
public int Level { get; }
|
||||
|
||||
public SingularityComponentState(int level)
|
||||
{
|
||||
Level = level;
|
||||
}
|
||||
}
|
||||
/// <summary>
|
||||
/// The amount of radiation this singularity emits per its level.
|
||||
/// Has to be on shared in case someone attaches a RadiationPulseComponent to the singularity.
|
||||
/// If you want to set this use <see cref="SharedSingularitySystem.SetRadsPerLevel"/>().
|
||||
/// </summary>
|
||||
[DataField("radsPerLevel")]
|
||||
[Access(friends:typeof(SharedSingularitySystem), Other=AccessPermissions.Read, Self=AccessPermissions.Read)]
|
||||
[ViewVariables(VVAccess.ReadWrite)]
|
||||
public float RadsPerLevel = 2f;
|
||||
}
|
||||
|
||||
Reference in New Issue
Block a user