CatStation/Content.Shared/Explosion/Components/ScatteringGrenadeComponent.cs
Ewanderer d7f7a91183
Documentation of e api (#44395)
* documentation pass on content.server -> E!

* APi pass on content.server for the E folder.

* documentation pass on content.shared for e.

* Apply suggestions from code review

Co-authored-by: SlamBamActionman <83650252+SlamBamActionman@users.noreply.github.com>

* Apply suggestions from code review

Co-authored-by: SlamBamActionman <83650252+SlamBamActionman@users.noreply.github.com>

* Apply suggestions from code review

Co-authored-by: SlamBamActionman <83650252+SlamBamActionman@users.noreply.github.com>

* fixing documentation according to review part 1.

* typo

* Very minor fixes

* And a short explanation about EUI

---------

Co-authored-by: SlamBamActionman <83650252+SlamBamActionman@users.noreply.github.com>
Co-authored-by: SlamBamActionman <slambamactionman@gmail.com>
2026-07-01 08:38:04 +00:00

124 lines
3.6 KiB
C#

using Content.Shared.Explosion.EntitySystems;
using Content.Shared.Whitelist;
using Robust.Shared.Containers;
using Robust.Shared.GameStates;
using Robust.Shared.Prototypes;
namespace Content.Shared.Explosion.Components;
/// <summary>
/// Use this component if the grenade splits into entities that make use of Timers
/// or if you just want it to throw entities out in the world
/// </summary>
[RegisterComponent, NetworkedComponent, AutoGenerateComponentState, Access(typeof(SharedScatteringGrenadeSystem))]
public sealed partial class ScatteringGrenadeComponent : Component
{
public Container Container = default!;
/// <summary>
/// Whitelist what can be inserted into the cluster.
/// </summary>
[DataField]
public EntityWhitelist? Whitelist;
/// <summary>
/// What we fill our prototype with if we want to pre-spawn with entities.
/// </summary>
[DataField]
public EntProtoId? FillPrototype;
/// <summary>
/// If we have a pre-fill how many more can we spawn.
/// </summary>
[ViewVariables(VVAccess.ReadOnly), AutoNetworkedField]
public int UnspawnedCount;
/// <summary>
/// Max amount of entities inside the container
/// </summary>
[DataField]
public int Capacity = 3;
/// <summary>
/// Number of grenades currently contained in the cluster (both spawned and unspawned)
/// </summary>
[ViewVariables(VVAccess.ReadOnly)]
public int Count => UnspawnedCount + Container.ContainedEntities.Count;
/// <summary>
/// Decides if contained entities trigger after getting launched
/// </summary>
[DataField]
public bool TriggerContents = true;
#region Trigger time parameters for scattered entities
/// <summary>
/// Minimum delay in seconds before any entities start to be triggered.
/// </summary>
[DataField]
public float DelayBeforeTriggerContents = 1.0f;
/// <summary>
/// Maximum delay in seconds to add between individual entity triggers
/// </summary>
[DataField]
public float IntervalBetweenTriggersMax;
/// <summary>
/// Minimum delay in seconds to add between individual entity triggers
/// </summary>
[DataField]
public float IntervalBetweenTriggersMin;
#endregion
#region Throwing parameters for the scattered entities
/// <summary>
/// Should the angle the entities get thrown at be random
/// instead of uniformly distributed
/// </summary>
[DataField]
public bool RandomAngle;
/// <summary>
/// The speed at which the entities get thrown
/// </summary>
[DataField]
public float Velocity = 5;
/// <summary>
/// Static distance grenades will be thrown to if RandomDistance is false.
/// </summary>
[DataField]
public float Distance = 1f;
/// <summary>
/// Should the distance the entities get thrown be random
/// </summary>
[DataField]
public bool RandomDistance;
/// <summary>
/// Max distance grenades can randomly be thrown to.
/// </summary>
[DataField]
public float RandomThrowDistanceMax = 2.5f;
/// <summary>
/// Minimal distance grenades can randomly be thrown to.
/// </summary>
[DataField]
public float RandomThrowDistanceMin;
#endregion
/// <summary>
/// Whether the main grenade has been triggered or not
/// We need to store this because we are only allowed to spawn and trigger timed entities on the next available frame update
/// </summary>
public bool IsTriggered = false;
/// <summary>
/// The trigger key that will activate the grenade.
/// </summary>
[DataField]
public string TriggerKey = "timer";
}