Ion storm event (#20277)

* ion storm event prototype + locale

* add lawsets

* use lawsets, make borgs ion storm targets

* ion storm rule and ion storm target

* lawset prototype

* use lawsets

* update silicon law system to use lawsets and support ion storm event

* new toys

* fix

* more fix

* fixy

* ion storm admin logging

* assigning laws makes borg provide its own laws, other stuff

* 1h reoccurence

* 50% chance

* better call saul

* emagLaws is required

* add announcment audio

* fixy

* family friendly gaming

* fixy

* address reviews

* fixy

* more fixy and no erp

* pro

---------

Co-authored-by: deltanedas <@deltanedas:kde.org>
This commit is contained in:
deltanedas
2023-10-27 03:40:13 +01:00
committed by GitHub
parent 7144894173
commit b9af991e04
18 changed files with 1675 additions and 58 deletions

View File

@@ -1,12 +1,11 @@
using Content.Shared.Roles;
using Robust.Shared.GameStates;
using Robust.Shared.Serialization.TypeSerializers.Implementations.Custom.Prototype;
using Robust.Shared.Serialization.TypeSerializers.Implementations.Custom.Prototype.List;
using Robust.Shared.Prototypes;
namespace Content.Shared.Silicons.Laws.Components;
/// <summary>
/// This is used for an entity that grants a special "obey" law when emagge.d
/// This is used for an entity that grants a special "obey" law when emagged.
/// </summary>
[RegisterComponent, NetworkedComponent, Access(typeof(SharedSiliconLawSystem))]
public sealed partial class EmagSiliconLawComponent : Component
@@ -14,31 +13,39 @@ public sealed partial class EmagSiliconLawComponent : Component
/// <summary>
/// The name of the person who emagged this law provider.
/// </summary>
[DataField("ownerName"), ViewVariables(VVAccess.ReadWrite)]
[DataField, ViewVariables(VVAccess.ReadWrite)]
public string? OwnerName;
/// <summary>
/// Does the panel need to be open to EMAG this law provider.
/// </summary>
[DataField("requireOpenPanel"), ViewVariables(VVAccess.ReadWrite)]
[DataField, ViewVariables(VVAccess.ReadWrite)]
public bool RequireOpenPanel = true;
/// <summary>
/// The laws that the borg is given when emagged.
/// The laws that the borg is given when emagged.
/// Law 0 is prepended to this, so this can only include the static laws.
/// </summary>
[DataField("emagLaws", required: true, customTypeSerializer: typeof(PrototypeIdListSerializer<SiliconLawPrototype>))]
public List<string> EmagLaws = new();
[DataField(required: true), ViewVariables(VVAccess.ReadWrite)]
public ProtoId<SiliconLawsetPrototype> EmagLaws = string.Empty;
/// <summary>
/// How long the borg is stunned when it's emagged. Setting to 0 will disable it.
/// Lawset created from the prototype id and law 0.
/// Cached when getting laws and only modified during an ion storm event.
/// </summary>
[DataField("stunTime"), ViewVariables(VVAccess.ReadWrite)]
[DataField, ViewVariables(VVAccess.ReadWrite)]
public SiliconLawset? Lawset;
/// <summary>
/// How long the borg is stunned when it's emagged. Setting to 0 will disable it.
/// </summary>
[DataField, ViewVariables(VVAccess.ReadWrite)]
public TimeSpan StunTime = TimeSpan.Zero;
/// <summary>
/// A role given to entities with this component when they are emagged.
/// Mostly just for admin purposes.
/// </summary>
[DataField("antagonistRole", customTypeSerializer: typeof(PrototypeIdSerializer<AntagPrototype>))]
public string? AntagonistRole = "SubvertedSilicon";
[DataField]
public ProtoId<AntagPrototype>? AntagonistRole = "SubvertedSilicon";
}

View File

@@ -0,0 +1,54 @@
using Content.Shared.Random;
using Robust.Shared.Prototypes;
namespace Content.Shared.Silicons.Laws.Components;
/// <summary>
/// During the ion storm event, this entity will have <see cref="IonStormLawsEvent"/> raised on it if it has laws.
/// New laws can be modified in multiple ways depending on the fields below.
/// </summary>
[RegisterComponent]
public sealed partial class IonStormTargetComponent : Component
{
/// <summary>
/// <see cref="WeightedRandomPrototype"/> for a random lawset to possibly replace the old one with.
/// </summary>
[DataField, ViewVariables(VVAccess.ReadWrite)]
public ProtoId<WeightedRandomPrototype> RandomLawsets = "IonStormLawsets";
/// <summary>
/// Chance for this borg to be affected at all.
/// </summary>
[DataField, ViewVariables(VVAccess.ReadWrite)]
public float Chance = 0.5f;
/// <summary>
/// Chance to replace the lawset with a random one
/// </summary>
[DataField, ViewVariables(VVAccess.ReadWrite)]
public float RandomLawsetChance = 0.25f;
/// <summary>
/// Chance to remove a random law.
/// </summary>
[DataField, ViewVariables(VVAccess.ReadWrite)]
public float RemoveChance = 0.1f;
/// <summary>
/// Chance to replace a random law with the new one, rather than have it be a glitched-order law.
/// </summary>
[DataField, ViewVariables(VVAccess.ReadWrite)]
public float ReplaceChance = 0.1f;
/// <summary>
/// Chance to shuffle laws after everything is done.
/// </summary>
[DataField, ViewVariables(VVAccess.ReadWrite)]
public float ShuffleChance = 0.1f;
}
/// <summary>
/// Raised on an ion storm target to modify its laws.
/// </summary>
[ByRefEvent]
public record struct IonStormLawsEvent(SiliconLawset Lawset);

View File

@@ -1,7 +1,6 @@
using Content.Shared.Actions;
using Robust.Shared.Prototypes;
using Robust.Shared.Serialization;
using Robust.Shared.Serialization.TypeSerializers.Implementations.Custom.Prototype;
namespace Content.Shared.Silicons.Laws.Components;
@@ -14,19 +13,19 @@ public sealed partial class SiliconLawBoundComponent : Component
/// <summary>
/// The sidebar action that toggles the laws screen.
/// </summary>
[DataField("viewLawsAction", customTypeSerializer: typeof(PrototypeIdSerializer<EntityPrototype>))]
public string ViewLawsAction = "ActionViewLaws";
[DataField]
public EntProtoId ViewLawsAction = "ActionViewLaws";
/// <summary>
/// The action for toggling laws. Stored here so we can remove it later.
/// </summary>
[DataField("viewLawsActionEntity")]
[DataField]
public EntityUid? ViewLawsActionEntity;
/// <summary>
/// The last entity that provided laws to this entity.
/// </summary>
[DataField("lastLawProvider")]
[DataField]
public EntityUid? LastLawProvider;
}
@@ -43,7 +42,7 @@ public record struct GetSiliconLawsEvent(EntityUid Entity)
{
public EntityUid Entity = Entity;
public readonly List<SiliconLaw> Laws = new();
public SiliconLawset Laws = new();
public bool Handled = false;
}

View File

@@ -1,4 +1,4 @@
using Robust.Shared.Serialization.TypeSerializers.Implementations.Custom.Prototype.List;
using Robust.Shared.Prototypes;
namespace Content.Shared.Silicons.Laws.Components;
@@ -9,8 +9,15 @@ namespace Content.Shared.Silicons.Laws.Components;
public sealed partial class SiliconLawProviderComponent : Component
{
/// <summary>
/// The laws that are provided.
/// The id of the lawset that is being provided.
/// </summary>
[DataField("laws", required: true, customTypeSerializer: typeof(PrototypeIdListSerializer<SiliconLawPrototype>))]
public List<string> Laws = new();
[DataField(required: true)]
public ProtoId<SiliconLawsetPrototype> Laws = string.Empty;
/// <summary>
/// Lawset created from the prototype id.
/// Cached when getting laws and only modified during an ion storm event.
/// </summary>
[DataField, ViewVariables(VVAccess.ReadWrite)]
public SiliconLawset? Lawset;
}