remove a bunch of instances of component reference (#13164)

This commit is contained in:
Nemanja
2022-12-23 23:55:31 -05:00
committed by GitHub
parent 4a37f7b917
commit 6c04811e66
64 changed files with 355 additions and 537 deletions

View File

@@ -1,11 +0,0 @@
using Content.Shared.Buckle.Components;
namespace Content.Client.Buckle;
[RegisterComponent]
[ComponentReference(typeof(SharedBuckleComponent))]
[Access(typeof(BuckleSystem))]
public sealed class BuckleComponent : SharedBuckleComponent
{
public int? OriginalDrawDepth { get; set; }
}

View File

@@ -1,4 +1,3 @@
using Content.Client.Buckle.Strap;
using Content.Client.Rotation;
using Content.Shared.ActionBlocker;
using Content.Shared.Buckle;
@@ -12,15 +11,14 @@ namespace Content.Client.Buckle
internal sealed class BuckleSystem : SharedBuckleSystem
{
[Dependency] private readonly ActionBlockerSystem _actionBlocker = default!;
[Dependency] private readonly AppearanceSystem AppearanceSystem = default!;
[Dependency] private readonly RotationVisualizerSystem RotationVisualizerSystem = default!;
[Dependency] private readonly AppearanceSystem _appearanceSystem = default!;
[Dependency] private readonly RotationVisualizerSystem _rotationVisualizerSystem = default!;
public override void Initialize()
{
base.Initialize();
SubscribeLocalEvent<BuckleComponent, ComponentHandleState>(OnBuckleHandleState);
SubscribeLocalEvent<StrapComponent, ComponentHandleState>(OnStrapHandleState);
SubscribeLocalEvent<BuckleComponent, AppearanceChangeEvent>(OnAppearanceChange);
}
@@ -65,22 +63,10 @@ namespace Content.Client.Buckle
}
}
private void OnStrapHandleState(EntityUid uid, StrapComponent component, ref ComponentHandleState args)
{
if (args.Current is not StrapComponentState state)
return;
component.Position = state.Position;
component.BuckleOffsetUnclamped = state.BuckleOffsetClamped;
component.BuckledEntities.Clear();
component.BuckledEntities.UnionWith(state.BuckledEntities);
component.MaxBuckleDistance = state.MaxBuckleDistance;
}
private void OnAppearanceChange(EntityUid uid, BuckleComponent component, ref AppearanceChangeEvent args)
{
if (!AppearanceSystem.TryGetData<int>(uid, StrapVisuals.RotationAngle, out var angle, args.Component) ||
!AppearanceSystem.TryGetData<bool>(uid, BuckleVisuals.Buckled, out var buckled, args.Component) ||
if (!_appearanceSystem.TryGetData<int>(uid, StrapVisuals.RotationAngle, out var angle, args.Component) ||
!_appearanceSystem.TryGetData<bool>(uid, BuckleVisuals.Buckled, out var buckled, args.Component) ||
!buckled ||
args.Sprite == null)
{
@@ -88,7 +74,7 @@ namespace Content.Client.Buckle
}
// Animate strapping yourself to something at a given angle
RotationVisualizerSystem.AnimateSpriteRotation(args.Sprite, Angle.FromDegrees(angle), 0.125f);
_rotationVisualizerSystem.AnimateSpriteRotation(args.Sprite, Angle.FromDegrees(angle), 0.125f);
}
}
}

View File

@@ -1,10 +0,0 @@
using Content.Shared.Buckle.Components;
namespace Content.Client.Buckle.Strap;
[RegisterComponent]
[ComponentReference(typeof(SharedStrapComponent))]
[Access(typeof(BuckleSystem))]
public sealed class StrapComponent : SharedStrapComponent
{
}

View File

@@ -6,10 +6,3 @@ public sealed class CartridgeLoaderSystem : SharedCartridgeLoaderSystem
{
//Empty client system for component replication
}
[RegisterComponent]
[ComponentReference(typeof(SharedCartridgeLoaderComponent))]
public sealed class CartridgeLoaderComponent : SharedCartridgeLoaderComponent
{
}

View File

@@ -2,7 +2,7 @@
using System.Text.RegularExpressions;
using Robust.Client.GameObjects;
using Robust.Shared.GameObjects;
using static Content.Shared.Configurable.SharedConfigurationComponent;
using static Content.Shared.Configurable.ConfigurationComponent;
namespace Content.Client.Configurable.UI
{

View File

@@ -4,7 +4,7 @@ using Robust.Client.UserInterface.Controls;
using Robust.Client.UserInterface.CustomControls;
using Robust.Shared.Localization;
using Robust.Shared.Maths;
using static Content.Shared.Configurable.SharedConfigurationComponent;
using static Content.Shared.Configurable.ConfigurationComponent;
using static Robust.Client.UserInterface.Controls.BaseButton;
using static Robust.Client.UserInterface.Controls.BoxContainer;

View File

@@ -1,13 +0,0 @@
using Content.Shared.Ensnaring.Components;
namespace Content.Client.Ensnaring.Components;
[RegisterComponent]
[ComponentReference(typeof(SharedEnsnareableComponent))]
public sealed class EnsnareableComponent : SharedEnsnareableComponent
{
[DataField("sprite")]
public string? Sprite;
[DataField("state")]
public string? State;
}

View File

@@ -1,9 +1,3 @@
using Content.Shared.Ensnaring.Components;
namespace Content.Client.Ensnaring.Components;
[RegisterComponent]
[ComponentReference(typeof(SharedEnsnaringComponent))]
public sealed class EnsnaringComponent : SharedEnsnaringComponent
{
}

View File

@@ -1,5 +1,5 @@
using Content.Client.Ensnaring.Components;
using Content.Shared.Ensnaring;
using Content.Shared.Ensnaring.Components;
using Robust.Client.GameObjects;
namespace Content.Client.Ensnaring.Visualizers;

View File

@@ -120,7 +120,7 @@ namespace Content.Client.Inventory
}
// snare-removal button. This is just the old button before the change to item slots. It is pretty out of place.
if (_entMan.TryGetComponent(Owner.Owner, out SharedEnsnareableComponent? snare) && snare.IsEnsnared)
if (_entMan.TryGetComponent(Owner.Owner, out EnsnareableComponent? snare) && snare.IsEnsnared)
{
var button = new Button()
{

View File

@@ -1,9 +0,0 @@
using Content.Client.Movement.Systems;
using Content.Shared.Climbing;
namespace Content.Client.Movement.Components;
[RegisterComponent]
[Access(typeof(ClimbSystem))]
[ComponentReference(typeof(SharedClimbableComponent))]
public sealed class ClimbableComponent : SharedClimbableComponent { }

View File

@@ -1,9 +0,0 @@
using Content.Client.Movement.Systems;
using Content.Shared.Climbing;
namespace Content.Client.Movement.Components;
[RegisterComponent]
[Access(typeof(ClimbSystem))]
[ComponentReference(typeof(SharedClimbingComponent))]
public sealed class ClimbingComponent : SharedClimbingComponent { }

View File

@@ -1,5 +1,4 @@
using Content.Client.Interactable;
using Content.Client.Movement.Components;
using Content.Shared.Climbing;
using Content.Shared.DragDrop;
using Robust.Shared.GameStates;
@@ -18,14 +17,14 @@ public sealed class ClimbSystem : SharedClimbSystem
private static void OnClimbingState(EntityUid uid, ClimbingComponent component, ref ComponentHandleState args)
{
if (args.Current is not SharedClimbingComponent.ClimbModeComponentState climbModeState)
if (args.Current is not ClimbingComponent.ClimbModeComponentState climbModeState)
return;
component.IsClimbing = climbModeState.Climbing;
component.OwnerIsTransitioning = climbModeState.IsTransitioning;
}
protected override void OnCanDragDropOn(EntityUid uid, SharedClimbableComponent component, CanDragDropOnEvent args)
protected override void OnCanDragDropOn(EntityUid uid, ClimbableComponent component, CanDragDropOnEvent args)
{
base.OnCanDragDropOn(uid, component, args);

View File

@@ -1,7 +0,0 @@
using Content.Shared.Singularity.Components;
namespace Content.Client.Singularity.Components;
[RegisterComponent]
[ComponentReference(typeof(SharedContainmentFieldComponent))]
public sealed class ContainmentFieldComponent : SharedContainmentFieldComponent { }

View File

@@ -1,6 +0,0 @@
using Content.Shared.Singularity.Components;
namespace Content.Client.Singularity.Components;
[RegisterComponent]
[ComponentReference(typeof(SharedContainmentFieldGeneratorComponent))]
public sealed class ContainmentFieldGeneratorComponent : SharedContainmentFieldGeneratorComponent { }

View File

@@ -1,11 +1,11 @@
using System.Threading.Tasks;
using Content.Server.Body.Systems;
using Content.Server.Buckle.Components;
using Content.Server.Buckle.Systems;
using Content.Server.Hands.Components;
using Content.Shared.ActionBlocker;
using Content.Shared.Body.Components;
using Content.Shared.Body.Part;
using Content.Shared.Buckle.Components;
using Content.Shared.Hands.EntitySystems;
using Content.Shared.Standing;
using NUnit.Framework;

View File

@@ -2,6 +2,7 @@
using System.Threading.Tasks;
using Content.Server.Climbing.Components;
using Content.Shared.Climbing;
using NUnit.Framework;
using Robust.Shared.GameObjects;
using Robust.Shared.IoC;

View File

@@ -14,6 +14,7 @@ using Content.Server.Prayer;
using Content.Server.Xenoarchaeology.XenoArtifacts;
using Content.Server.Xenoarchaeology.XenoArtifacts.Triggers.Components;
using Content.Shared.Administration;
using Content.Shared.Configurable;
using Content.Shared.Database;
using Content.Shared.GameTicking;
using Content.Shared.Interaction.Helpers;
@@ -27,7 +28,7 @@ using Robust.Shared.Console;
using Robust.Shared.Map;
using Robust.Shared.Prototypes;
using Robust.Shared.Timing;
using static Content.Shared.Configurable.SharedConfigurationComponent;
using static Content.Shared.Configurable.ConfigurationComponent;
namespace Content.Server.Administration.Systems
{

View File

@@ -1,6 +1,6 @@
using Content.Server.Ensnaring;
using Content.Server.Ensnaring.Components;
using Content.Shared.Alert;
using Content.Shared.Ensnaring.Components;
using JetBrains.Annotations;
namespace Content.Server.Alert.Click;

View File

@@ -2,7 +2,6 @@ using Content.Server.Actions;
using Content.Server.Bed.Components;
using Content.Server.Bed.Sleep;
using Content.Server.Body.Systems;
using Content.Server.Buckle.Components;
using Content.Server.MobState;
using Content.Server.Power.Components;
using Content.Server.Power.EntitySystems;

View File

@@ -1,38 +0,0 @@
using Content.Server.Buckle.Systems;
using Content.Shared.Buckle.Components;
namespace Content.Server.Buckle.Components;
/// <summary>
/// Component that handles sitting entities into <see cref="StrapComponent"/>s.
/// </summary>
[RegisterComponent]
[ComponentReference(typeof(SharedBuckleComponent))]
[Access(typeof(BuckleSystem))]
public sealed class BuckleComponent : SharedBuckleComponent
{
/// <summary>
/// The amount of time that must pass for this entity to
/// be able to unbuckle after recently buckling.
/// </summary>
[DataField("delay")]
public TimeSpan UnbuckleDelay = TimeSpan.FromSeconds(0.25f);
/// <summary>
/// The time that this entity buckled at.
/// </summary>
[ViewVariables] public TimeSpan BuckleTime;
/// <summary>
/// The strap that this component is buckled to.
/// </summary>
[ViewVariables]
public StrapComponent? BuckledTo { get; set; }
/// <summary>
/// The amount of space that this entity occupies in a
/// <see cref="StrapComponent"/>.
/// </summary>
[DataField("size")]
public int Size = 100;
}

View File

@@ -1,57 +0,0 @@
using Content.Server.Buckle.Systems;
using Content.Shared.Alert;
using Content.Shared.Buckle.Components;
using Robust.Shared.Audio;
namespace Content.Server.Buckle.Components;
[RegisterComponent]
[ComponentReference(typeof(SharedStrapComponent))]
[Access(typeof(BuckleSystem))]
public sealed class StrapComponent : SharedStrapComponent
{
/// <summary>
/// The angle in degrees to rotate the player by when they get strapped
/// </summary>
[DataField("rotation")]
public int Rotation { get; set; }
/// <summary>
/// The size of the strap which is compared against when buckling entities
/// </summary>
[DataField("size")]
public int Size { get; set; } = 100;
/// <summary>
/// If disabled, nothing can be buckled on this object, and it will unbuckle anything that's already buckled
/// </summary>
public bool Enabled { get; set; } = true;
/// <summary>
/// You can specify the offset the entity will have after unbuckling.
/// </summary>
[DataField("unbuckleOffset", required: false)]
public Vector2 UnbuckleOffset = Vector2.Zero;
/// <summary>
/// The sound to be played when a mob is buckled
/// </summary>
[DataField("buckleSound")]
public SoundSpecifier BuckleSound { get; } = new SoundPathSpecifier("/Audio/Effects/buckle.ogg");
/// <summary>
/// The sound to be played when a mob is unbuckled
/// </summary>
[DataField("unbuckleSound")]
public SoundSpecifier UnbuckleSound { get; } = new SoundPathSpecifier("/Audio/Effects/unbuckle.ogg");
/// <summary>
/// ID of the alert to show when buckled
/// </summary>
[DataField("buckledAlertType")]
public AlertType BuckledAlertType { get; } = AlertType.Buckled;
/// <summary>
/// The sum of the sizes of all the buckled entities in this strap
/// </summary>
public int OccupiedSize { get; set; }
}

View File

@@ -1,5 +1,4 @@
using System.Diagnostics.CodeAnalysis;
using Content.Server.Buckle.Components;
using Content.Server.Storage.Components;
using Content.Shared.Alert;
using Content.Shared.Bed.Sleep;
@@ -14,7 +13,6 @@ using Content.Shared.Stunnable;
using Content.Shared.Vehicle.Components;
using Content.Shared.Verbs;
using Robust.Shared.GameStates;
using Robust.Shared.Player;
namespace Content.Server.Buckle.Systems;

View File

@@ -1,5 +1,4 @@
using System.Linq;
using Content.Server.Buckle.Components;
using Content.Server.Construction.Completions;
using Content.Shared.Buckle.Components;
using Content.Shared.Destructible;

View File

@@ -1,18 +0,0 @@
using Content.Shared.CartridgeLoader;
using Robust.Shared.Serialization.TypeSerializers.Implementations;
namespace Content.Server.CartridgeLoader;
[RegisterComponent]
[ComponentReference(typeof(SharedCartridgeLoaderComponent))]
public sealed class CartridgeLoaderComponent : SharedCartridgeLoaderComponent
{
/// <summary>
/// The maximum amount of programs that can be installed on the cartridge loader entity
/// </summary>
[DataField("diskSpace")]
public int DiskSpace = 5;
[DataField("uiKey", readOnly: true, required: true, customTypeSerializer: typeof(EnumSerializer))]
public Enum UiKey = default!;
}

View File

@@ -241,13 +241,13 @@ public sealed class CartridgeLoaderSystem : SharedCartridgeLoaderSystem
loader.BackgroundPrograms.Remove(cartridgeUid);
}
protected override void OnItemInserted(EntityUid uid, SharedCartridgeLoaderComponent loader, EntInsertedIntoContainerMessage args)
protected override void OnItemInserted(EntityUid uid, Shared.CartridgeLoader.CartridgeLoaderComponent loader, EntInsertedIntoContainerMessage args)
{
RaiseLocalEvent(args.Entity, new CartridgeAddedEvent(uid));
base.OnItemInserted(uid, loader, args);
}
protected override void OnItemRemoved(EntityUid uid, SharedCartridgeLoaderComponent loader, EntRemovedFromContainerMessage args)
protected override void OnItemRemoved(EntityUid uid, Shared.CartridgeLoader.CartridgeLoaderComponent loader, EntRemovedFromContainerMessage args)
{
var deactivate = loader.BackgroundPrograms.Remove(args.Entity);

View File

@@ -66,7 +66,7 @@ public sealed class ClimbSystem : SharedClimbSystem
SubscribeLocalEvent<GlassTableComponent, ClimbedOnEvent>(OnGlassClimbed);
}
protected override void OnCanDragDropOn(EntityUid uid, SharedClimbableComponent component, CanDragDropOnEvent args)
protected override void OnCanDragDropOn(EntityUid uid, ClimbableComponent component, CanDragDropOnEvent args)
{
base.OnCanDragDropOn(uid, component, args);
@@ -166,6 +166,7 @@ public sealed class ClimbSystem : SharedClimbSystem
return;
climbing.IsClimbing = true;
Dirty(climbing);
MoveEntityToward(uid, climbable, physics, climbing);
// we may potentially need additional logic since we're forcing a player onto a climbable
@@ -265,6 +266,7 @@ public sealed class ClimbSystem : SharedClimbSystem
climbing.IsClimbing = false;
climbing.OwnerIsTransitioning = false;
Dirty(climbing);
}
/// <summary>
@@ -275,7 +277,7 @@ public sealed class ClimbSystem : SharedClimbSystem
/// <param name="target">The object that is being vaulted</param>
/// <param name="reason">The reason why it cant be dropped</param>
/// <returns></returns>
private bool CanVault(SharedClimbableComponent component, EntityUid user, EntityUid target, out string reason)
private bool CanVault(ClimbableComponent component, EntityUid user, EntityUid target, out string reason)
{
if (!_actionBlockerSystem.CanInteract(user, target))
{
@@ -311,7 +313,7 @@ public sealed class ClimbSystem : SharedClimbSystem
/// <param name="target">The object that is being vaulted onto</param>
/// <param name="reason">The reason why it cant be dropped</param>
/// <returns></returns>
private bool CanVault(SharedClimbableComponent component, EntityUid user, EntityUid dragged, EntityUid target,
private bool CanVault(ClimbableComponent component, EntityUid user, EntityUid dragged, EntityUid target,
out string reason)
{
if (!_actionBlockerSystem.CanInteract(user, dragged) || !_actionBlockerSystem.CanInteract(user, target))
@@ -353,7 +355,7 @@ public sealed class ClimbSystem : SharedClimbSystem
private static void OnClimbingGetState(EntityUid uid, ClimbingComponent component, ref ComponentGetState args)
{
args.State = new SharedClimbingComponent.ClimbModeComponentState(component.IsClimbing, component.OwnerIsTransitioning);
args.State = new ClimbingComponent.ClimbModeComponentState(component.IsClimbing, component.OwnerIsTransitioning);
}
private void OnGlassClimbed(EntityUid uid, GlassTableComponent component, ClimbedOnEvent args)
@@ -401,7 +403,7 @@ public sealed class ClimbSystem : SharedClimbSystem
_actionBlockerSystem.UpdateCanMove(uid);
// Transition back to KinematicController after BufferTime
climbing.Owner.SpawnTimer((int) (SharedClimbingComponent.BufferTime * 1000), () =>
climbing.Owner.SpawnTimer((int) (ClimbingComponent.BufferTime * 1000), () =>
{
if (climbing.Deleted) return;
physics.BodyType = BodyType.KinematicController;

View File

@@ -1,49 +0,0 @@
using Content.Shared.CCVar;
using Content.Shared.Climbing;
using Content.Shared.Damage;
using Robust.Shared.Audio;
namespace Content.Server.Climbing.Components;
[RegisterComponent]
[ComponentReference(typeof(SharedClimbableComponent))]
public sealed class ClimbableComponent : SharedClimbableComponent
{
/// <summary>
/// The time it takes to climb onto the entity.
/// </summary>
[DataField("delay")]
public float ClimbDelay = 0.8f;
/// <summary>
/// If set, people can bonk on this if <see cref="CCVars.GameTableBonk"/> is set or if they are clumsy.
/// </summary>
[DataField("bonk")] public bool Bonk = false;
/// <summary>
/// Chance of bonk triggering if the user is clumsy.
/// </summary>
[DataField("bonkClumsyChance")]
public float BonkClumsyChance = 0.75f;
/// <summary>
/// Sound to play when bonking.
/// </summary>
/// <seealso cref="Bonk"/>
[DataField("bonkSound")]
public SoundSpecifier? BonkSound;
/// <summary>
/// How long to stun players on bonk, in seconds.
/// </summary>
/// <seealso cref="Bonk"/>
[DataField("bonkTime")]
public float BonkTime = 2;
/// <summary>
/// How much damage to apply on bonk.
/// </summary>
/// <seealso cref="Bonk"/>
[DataField("bonkDamage")]
public DamageSpecifier? BonkDamage;
}

View File

@@ -1,35 +0,0 @@
using Content.Shared.Climbing;
namespace Content.Server.Climbing.Components;
[RegisterComponent]
[ComponentReference(typeof(SharedClimbingComponent))]
[Access(typeof(ClimbSystem))]
public sealed class ClimbingComponent : SharedClimbingComponent
{
[ViewVariables(VVAccess.ReadWrite)]
public override bool IsClimbing
{
get => base.IsClimbing;
set
{
if (base.IsClimbing == value) return;
base.IsClimbing = value;
Dirty();
}
}
public override bool OwnerIsTransitioning
{
get => base.OwnerIsTransitioning;
set
{
if (value == base.OwnerIsTransitioning) return;
base.OwnerIsTransitioning = value;
Dirty();
}
}
[ViewVariables]
public Dictionary<string, int> DisabledFixtureMasks { get; } = new();
}

View File

@@ -1,16 +0,0 @@
using Content.Shared.Configurable;
using Content.Shared.Tools;
using Robust.Shared.Serialization.TypeSerializers.Implementations.Custom.Prototype;
namespace Content.Server.Configurable;
[RegisterComponent]
[ComponentReference(typeof(SharedConfigurationComponent))]
public sealed class ConfigurationComponent : SharedConfigurationComponent
{
[DataField("config")]
public readonly Dictionary<string, string> Config = new();
[DataField("qualityNeeded", customTypeSerializer: typeof(PrototypeIdSerializer<ToolQualityPrototype>))]
public string QualityNeeded = "Pulsing";
}

View File

@@ -1,8 +1,9 @@
using Content.Shared.Configurable;
using Content.Shared.Interaction;
using Content.Shared.Tools.Components;
using Robust.Server.GameObjects;
using Robust.Shared.Containers;
using static Content.Shared.Configurable.SharedConfigurationComponent;
using static Content.Shared.Configurable.ConfigurationComponent;
namespace Content.Server.Configurable;

View File

@@ -1,6 +1,6 @@
using Content.Server.Bed.Components;
using Content.Server.Buckle.Components;
using Content.Shared.Bed.Sleep;
using Content.Shared.Buckle.Components;
using Content.Shared.Disease;
namespace Content.Server.Disease.Cures

View File

@@ -1,13 +0,0 @@
using Content.Shared.Ensnaring.Components;
using Robust.Shared.Containers;
namespace Content.Server.Ensnaring.Components;
[RegisterComponent]
[ComponentReference(typeof(SharedEnsnareableComponent))]
public sealed class EnsnareableComponent : SharedEnsnareableComponent
{
/// <summary>
/// The container where the <see cref="EnsnaringComponent"/> entity will be stored
/// </summary>
public Container Container = default!;
}

View File

@@ -1,43 +1,5 @@
using System.Threading;
using Content.Shared.Ensnaring.Components;
namespace Content.Server.Ensnaring.Components;
[RegisterComponent]
[ComponentReference(typeof(SharedEnsnaringComponent))]
public sealed class EnsnaringComponent : SharedEnsnaringComponent
{
/// <summary>
/// Should movement cancel breaking out?
/// </summary>
[ViewVariables(VVAccess.ReadWrite)]
[DataField("canMoveBreakout")]
public bool CanMoveBreakout;
public CancellationTokenSource? CancelToken;
}
/// <summary>
/// Used for the do after event to free the entity that owns the <see cref="EnsnareableComponent"/>
/// </summary>
public sealed class FreeEnsnareDoAfterComplete : EntityEventArgs
{
public readonly EntityUid EnsnaringEntity;
public FreeEnsnareDoAfterComplete(EntityUid ensnaringEntity)
{
EnsnaringEntity = ensnaringEntity;
}
}
/// <summary>
/// Used for the do after event when it fails to free the entity that owns the <see cref="EnsnareableComponent"/>
/// </summary>
public sealed class FreeEnsnareDoAfterCancel : EntityEventArgs
{
public readonly EntityUid EnsnaringEntity;
public FreeEnsnareDoAfterCancel(EntityUid ensnaringEntity)
{
EnsnaringEntity = ensnaringEntity;
}
}

View File

@@ -1,12 +1,10 @@
using System.Threading;
using Content.Server.DoAfter;
using Content.Server.Ensnaring.Components;
using Content.Shared.Alert;
using Content.Shared.Ensnaring.Components;
using Content.Shared.IdentityManagement;
using Content.Shared.StepTrigger.Systems;
using Content.Shared.Throwing;
using Robust.Shared.Player;
namespace Content.Server.Ensnaring;

View File

@@ -1,11 +1,9 @@
using Content.Server.Ensnaring.Components;
using Content.Server.Popups;
using Content.Shared.Ensnaring;
using Content.Shared.Ensnaring.Components;
using Content.Shared.Popups;
using Robust.Server.Containers;
using Robust.Shared.Containers;
using Robust.Shared.Player;
namespace Content.Server.Ensnaring;

View File

@@ -1,7 +1,7 @@
using System.Linq;
using Content.Server.Buckle.Components;
using Content.Server.Buckle.Systems;
using Content.Server.Storage.Components;
using Content.Shared.Buckle.Components;
using Content.Shared.Foldable;
using Content.Shared.Verbs;
using JetBrains.Annotations;

View File

@@ -1,4 +1,3 @@
using Content.Server.Buckle.Components;
using Content.Server.Doors.Components;
using Content.Server.Doors.Systems;
using Content.Server.Shuttles.Components;
@@ -14,7 +13,7 @@ using Robust.Shared.Player;
using Robust.Shared.Utility;
using System.Diagnostics.CodeAnalysis;
using Content.Server.Shuttles.Events;
using Content.Server.Station.Components;
using Content.Shared.Buckle.Components;
using Robust.Shared.Map.Components;
using Robust.Shared.Physics.Components;

View File

@@ -1,20 +1,15 @@
using Content.Server.Singularity.Components;
using Content.Server.Singularity.Events;
using Content.Shared.Singularity.Components;
using Content.Shared.Tag;
using Robust.Server.GameObjects;
using Robust.Shared.Physics;
using Robust.Shared.Physics.Dynamics;
using System.Linq;
using Content.Server.Popups;
using Content.Shared.Construction.Components;
using Content.Shared.Examine;
using Content.Shared.Interaction;
using Content.Shared.Popups;
using Content.Shared.Throwing;
using Robust.Shared.Physics.Components;
using Robust.Shared.Physics.Events;
using Robust.Shared.Player;
namespace Content.Server.Singularity.EntitySystems;

View File

@@ -1,13 +1,11 @@
using Content.Server.Popups;
using Content.Server.Shuttles.Components;
using Content.Server.Singularity.Components;
using Content.Server.Singularity.EntitySystems;
using Content.Server.Singularity.Events;
using Content.Shared.Popups;
using Content.Shared.Singularity.Components;
using Content.Shared.Throwing;
using Robust.Shared.Physics.Components;
using Robust.Shared.Physics.Events;
using Robust.Shared.Player;
namespace Content.Server.Singularity.EntitySystems;

View File

@@ -1,7 +1,6 @@
using Content.Server.Cuffs.Components;
using Content.Server.DoAfter;
using Content.Server.Ensnaring;
using Content.Server.Ensnaring.Components;
using Content.Server.Hands.Components;
using Content.Shared.CombatMode;
using Content.Shared.Hands.Components;
@@ -13,10 +12,10 @@ using Content.Shared.Popups;
using Content.Shared.Strip.Components;
using Content.Shared.Verbs;
using Robust.Server.GameObjects;
using Robust.Shared.Player;
using System.Threading;
using Content.Server.Administration.Logs;
using Content.Shared.Database;
using Content.Shared.Ensnaring.Components;
namespace Content.Server.Strip
{

View File

@@ -1,5 +1,4 @@
using Content.Server.Body.Systems;
using Content.Server.Buckle.Components;
using Content.Server.Buckle.Systems;
using Content.Server.Popups;
using Content.Server.Storage.Components;
@@ -7,6 +6,7 @@ using Content.Server.Storage.EntitySystems;
using Content.Server.Tools;
using Content.Shared.Body.Components;
using Content.Shared.Body.Part;
using Content.Shared.Buckle.Components;
using Content.Shared.Examine;
using Content.Shared.IdentityManagement;
using Content.Shared.Interaction;

View File

@@ -4,15 +4,14 @@ using Robust.Shared.Serialization;
namespace Content.Shared.Buckle.Components;
[NetworkedComponent]
[Access(typeof(SharedBuckleSystem))]
public abstract class SharedBuckleComponent : Component
[RegisterComponent, NetworkedComponent]
public sealed class BuckleComponent : Component
{
/// <summary>
/// The range from which this entity can buckle to a <see cref="SharedStrapComponent"/>.
/// The range from which this entity can buckle to a <see cref="StrapComponent"/>.
/// </summary>
[DataField("range")]
public float Range { get; protected set; } = SharedInteractionSystem.InteractionRange / 1.4f;
public float Range = SharedInteractionSystem.InteractionRange / 1.4f;
/// <summary>
/// True if the entity is buckled, false otherwise.
@@ -22,6 +21,36 @@ public abstract class SharedBuckleComponent : Component
public EntityUid? LastEntityBuckledTo { get; set; }
public bool DontCollide { get; set; }
/// <summary>
/// The amount of time that must pass for this entity to
/// be able to unbuckle after recently buckling.
/// </summary>
[DataField("delay")]
public TimeSpan UnbuckleDelay = TimeSpan.FromSeconds(0.25f);
/// <summary>
/// The time that this entity buckled at.
/// </summary>
[ViewVariables] public TimeSpan BuckleTime;
/// <summary>
/// The strap that this component is buckled to.
/// </summary>
[ViewVariables]
public StrapComponent? BuckledTo { get; set; }
/// <summary>
/// The amount of space that this entity occupies in a
/// <see cref="StrapComponent"/>.
/// </summary>
[DataField("size")]
public int Size = 100;
/// <summary>
/// Used for client rendering
/// </summary>
public int? OriginalDrawDepth { get; set; }
}
[Serializable, NetSerializable]

View File

@@ -1,3 +1,5 @@
using Content.Shared.Alert;
using Robust.Shared.Audio;
using Robust.Shared.GameStates;
using Robust.Shared.Serialization;
@@ -21,9 +23,8 @@ public enum StrapPosition
Down
}
[NetworkedComponent]
[Access(typeof(SharedBuckleSystem))]
public abstract class SharedStrapComponent : Component
[RegisterComponent, NetworkedComponent]
public sealed class StrapComponent : Component
{
/// <summary>
/// The change in position to the strapped mob
@@ -58,6 +59,52 @@ public abstract class SharedStrapComponent : Component
[DataField("buckleOffset", required: false)]
[Access(Other = AccessPermissions.ReadWrite)]
public Vector2 BuckleOffsetUnclamped = Vector2.Zero;
/// <summary>
/// The angle in degrees to rotate the player by when they get strapped
/// </summary>
[DataField("rotation")]
public int Rotation { get; set; }
/// <summary>
/// The size of the strap which is compared against when buckling entities
/// </summary>
[DataField("size")]
public int Size { get; set; } = 100;
/// <summary>
/// If disabled, nothing can be buckled on this object, and it will unbuckle anything that's already buckled
/// </summary>
public bool Enabled { get; set; } = true;
/// <summary>
/// You can specify the offset the entity will have after unbuckling.
/// </summary>
[DataField("unbuckleOffset", required: false)]
public Vector2 UnbuckleOffset = Vector2.Zero;
/// <summary>
/// The sound to be played when a mob is buckled
/// </summary>
[DataField("buckleSound")]
public SoundSpecifier BuckleSound { get; } = new SoundPathSpecifier("/Audio/Effects/buckle.ogg");
/// <summary>
/// The sound to be played when a mob is unbuckled
/// </summary>
[DataField("unbuckleSound")]
public SoundSpecifier UnbuckleSound { get; } = new SoundPathSpecifier("/Audio/Effects/unbuckle.ogg");
/// <summary>
/// ID of the alert to show when buckled
/// </summary>
[DataField("buckledAlertType")]
public AlertType BuckledAlertType { get; } = AlertType.Buckled;
/// <summary>
/// The sum of the sizes of all the buckled entities in this strap
/// </summary>
public int OccupiedSize { get; set; }
}
[Serializable, NetSerializable]

View File

@@ -13,15 +13,15 @@ public abstract partial class SharedBuckleSystem
{
private void InitializeBuckle()
{
SubscribeLocalEvent<SharedBuckleComponent, PreventCollideEvent>(PreventCollision);
SubscribeLocalEvent<SharedBuckleComponent, DownAttemptEvent>(HandleDown);
SubscribeLocalEvent<SharedBuckleComponent, StandAttemptEvent>(HandleStand);
SubscribeLocalEvent<SharedBuckleComponent, ThrowPushbackAttemptEvent>(HandleThrowPushback);
SubscribeLocalEvent<SharedBuckleComponent, UpdateCanMoveEvent>(HandleMove);
SubscribeLocalEvent<SharedBuckleComponent, ChangeDirectionAttemptEvent>(OnBuckleChangeDirectionAttempt);
SubscribeLocalEvent<BuckleComponent, PreventCollideEvent>(PreventCollision);
SubscribeLocalEvent<BuckleComponent, DownAttemptEvent>(HandleDown);
SubscribeLocalEvent<BuckleComponent, StandAttemptEvent>(HandleStand);
SubscribeLocalEvent<BuckleComponent, ThrowPushbackAttemptEvent>(HandleThrowPushback);
SubscribeLocalEvent<BuckleComponent, UpdateCanMoveEvent>(HandleMove);
SubscribeLocalEvent<BuckleComponent, ChangeDirectionAttemptEvent>(OnBuckleChangeDirectionAttempt);
}
private void PreventCollision(EntityUid uid, SharedBuckleComponent component, ref PreventCollideEvent args)
private void PreventCollision(EntityUid uid, BuckleComponent component, ref PreventCollideEvent args)
{
if (args.BodyB.Owner != component.LastEntityBuckledTo)
return;
@@ -30,25 +30,25 @@ public abstract partial class SharedBuckleSystem
args.Cancelled = true;
}
private void HandleDown(EntityUid uid, SharedBuckleComponent component, DownAttemptEvent args)
private void HandleDown(EntityUid uid, BuckleComponent component, DownAttemptEvent args)
{
if (component.Buckled)
args.Cancel();
}
private void HandleStand(EntityUid uid, SharedBuckleComponent component, StandAttemptEvent args)
private void HandleStand(EntityUid uid, BuckleComponent component, StandAttemptEvent args)
{
if (component.Buckled)
args.Cancel();
}
private void HandleThrowPushback(EntityUid uid, SharedBuckleComponent component, ThrowPushbackAttemptEvent args)
private void HandleThrowPushback(EntityUid uid, BuckleComponent component, ThrowPushbackAttemptEvent args)
{
if (component.Buckled)
args.Cancel();
}
private void HandleMove(EntityUid uid, SharedBuckleComponent component, UpdateCanMoveEvent args)
private void HandleMove(EntityUid uid, BuckleComponent component, UpdateCanMoveEvent args)
{
if (component.LifeStage > ComponentLifeStage.Running)
return;
@@ -58,13 +58,13 @@ public abstract partial class SharedBuckleSystem
args.Cancel();
}
private void OnBuckleChangeDirectionAttempt(EntityUid uid, SharedBuckleComponent component, ChangeDirectionAttemptEvent args)
private void OnBuckleChangeDirectionAttempt(EntityUid uid, BuckleComponent component, ChangeDirectionAttemptEvent args)
{
if (component.Buckled)
args.Cancel();
}
public bool IsBuckled(EntityUid uid, SharedBuckleComponent? component = null)
public bool IsBuckled(EntityUid uid, BuckleComponent? component = null)
{
return Resolve(uid, ref component, false) && component.Buckled;
}
@@ -75,7 +75,7 @@ public abstract partial class SharedBuckleSystem
/// <param name="buckleId">The entity to reattach.</param>
/// <param name="strap">The strap to reattach to.</param>
/// <param name="buckle">The buckle component of the entity to reattach.</param>
public void ReAttach(EntityUid buckleId, SharedStrapComponent strap, SharedBuckleComponent? buckle = null)
public void ReAttach(EntityUid buckleId, StrapComponent strap, BuckleComponent? buckle = null)
{
if (!Resolve(buckleId, ref buckle, false))
return;

View File

@@ -11,12 +11,12 @@ public abstract partial class SharedBuckleSystem
private void InitializeStrap()
{
SubscribeLocalEvent<SharedStrapComponent, MoveEvent>(OnStrapRotate);
SubscribeLocalEvent<SharedStrapComponent, ComponentHandleState>(OnStrapHandleState);
SubscribeLocalEvent<SharedStrapComponent, CanDragDropOnEvent>(OnStrapCanDragDropOn);
SubscribeLocalEvent<StrapComponent, MoveEvent>(OnStrapRotate);
SubscribeLocalEvent<StrapComponent, ComponentHandleState>(OnStrapHandleState);
SubscribeLocalEvent<StrapComponent, CanDragDropOnEvent>(OnStrapCanDragDropOn);
}
private void OnStrapHandleState(EntityUid uid, SharedStrapComponent component, ref ComponentHandleState args)
private void OnStrapHandleState(EntityUid uid, StrapComponent component, ref ComponentHandleState args)
{
if (args.Current is not StrapComponentState state)
return;
@@ -28,7 +28,7 @@ public abstract partial class SharedBuckleSystem
component.MaxBuckleDistance = state.MaxBuckleDistance;
}
private void OnStrapRotate(EntityUid uid, SharedStrapComponent component, ref MoveEvent args)
private void OnStrapRotate(EntityUid uid, StrapComponent component, ref MoveEvent args)
{
// TODO: This looks dirty af.
// On rotation of a strap, reattach all buckled entities.
@@ -50,7 +50,7 @@ public abstract partial class SharedBuckleSystem
foreach (var buckledEntity in component.BuckledEntities)
{
if (!EntityManager.TryGetComponent(buckledEntity, out SharedBuckleComponent? buckled))
if (!EntityManager.TryGetComponent(buckledEntity, out BuckleComponent? buckled))
{
continue;
}
@@ -71,8 +71,8 @@ public abstract partial class SharedBuckleSystem
EntityUid user,
EntityUid target,
EntityUid buckleId,
SharedStrapComponent? strap = null,
SharedBuckleComponent? buckle = null)
StrapComponent? strap = null,
BuckleComponent? buckle = null)
{
if (!Resolve(strapId, ref strap, false) ||
!Resolve(buckleId, ref buckle, false))
@@ -85,7 +85,7 @@ public abstract partial class SharedBuckleSystem
return _interactions.InRangeUnobstructed(target, buckleId, buckle.Range, predicate: Ignored);
}
private void OnStrapCanDragDropOn(EntityUid uid, SharedStrapComponent strap, CanDragDropOnEvent args)
private void OnStrapCanDragDropOn(EntityUid uid, StrapComponent strap, CanDragDropOnEvent args)
{
args.CanDrop = StrapCanDragDropOn(args.Target, args.User, args.Target, args.Dragged, strap);
args.Handled = true;

View File

@@ -1,9 +1,11 @@
using Content.Shared.Containers.ItemSlots;
using Robust.Shared.GameStates;
using Robust.Shared.Serialization.TypeSerializers.Implementations;
namespace Content.Shared.CartridgeLoader;
[Access(typeof(SharedCartridgeLoaderSystem))]
public abstract class SharedCartridgeLoaderComponent : Component
[RegisterComponent, NetworkedComponent]
public sealed class CartridgeLoaderComponent : Component
{
public const string CartridgeSlotId = "Cartridge-Slot";
@@ -33,4 +35,13 @@ public abstract class SharedCartridgeLoaderComponent : Component
/// </summary>
[DataField("installedCartridges")]
public List<EntityUid> InstalledPrograms = new();
/// <summary>
/// The maximum amount of programs that can be installed on the cartridge loader entity
/// </summary>
[DataField("diskSpace")]
public int DiskSpace = 5;
[DataField("uiKey", readOnly: true, required: true, customTypeSerializer: typeof(EnumSerializer))]
public Enum UiKey = default!;
}

View File

@@ -14,26 +14,26 @@ public abstract class SharedCartridgeLoaderSystem : EntitySystem
{
base.Initialize();
SubscribeLocalEvent<SharedCartridgeLoaderComponent, ComponentInit>(OnComponentInit);
SubscribeLocalEvent<SharedCartridgeLoaderComponent, ComponentRemove>(OnComponentRemove);
SubscribeLocalEvent<CartridgeLoaderComponent, ComponentInit>(OnComponentInit);
SubscribeLocalEvent<CartridgeLoaderComponent, ComponentRemove>(OnComponentRemove);
SubscribeLocalEvent<SharedCartridgeLoaderComponent, EntInsertedIntoContainerMessage>(OnItemInserted);
SubscribeLocalEvent<SharedCartridgeLoaderComponent, EntRemovedFromContainerMessage>(OnItemRemoved);
SubscribeLocalEvent<CartridgeLoaderComponent, EntInsertedIntoContainerMessage>(OnItemInserted);
SubscribeLocalEvent<CartridgeLoaderComponent, EntRemovedFromContainerMessage>(OnItemRemoved);
SubscribeLocalEvent<CartridgeComponent, ComponentGetState>(OnGetState);
SubscribeLocalEvent<CartridgeComponent, ComponentHandleState>(OnHandleState);
}
private void OnComponentInit(EntityUid uid, SharedCartridgeLoaderComponent loader, ComponentInit args)
private void OnComponentInit(EntityUid uid, CartridgeLoaderComponent loader, ComponentInit args)
{
_itemSlotsSystem.AddItemSlot(uid, SharedCartridgeLoaderComponent.CartridgeSlotId, loader.CartridgeSlot);
_itemSlotsSystem.AddItemSlot(uid, CartridgeLoaderComponent.CartridgeSlotId, loader.CartridgeSlot);
}
/// <summary>
/// Marks installed program entities for deletion when the component gets removed
/// </summary>
private void OnComponentRemove(EntityUid uid, SharedCartridgeLoaderComponent loader, ComponentRemove args)
private void OnComponentRemove(EntityUid uid, CartridgeLoaderComponent loader, ComponentRemove args)
{
_itemSlotsSystem.RemoveItemSlot(uid, loader.CartridgeSlot);
@@ -43,12 +43,12 @@ public abstract class SharedCartridgeLoaderSystem : EntitySystem
}
}
protected virtual void OnItemInserted(EntityUid uid, SharedCartridgeLoaderComponent loader, EntInsertedIntoContainerMessage args)
protected virtual void OnItemInserted(EntityUid uid, CartridgeLoaderComponent loader, EntInsertedIntoContainerMessage args)
{
UpdateAppearanceData(uid, loader);
}
protected virtual void OnItemRemoved(EntityUid uid, SharedCartridgeLoaderComponent loader, EntRemovedFromContainerMessage args)
protected virtual void OnItemRemoved(EntityUid uid, CartridgeLoaderComponent loader, EntRemovedFromContainerMessage args)
{
UpdateAppearanceData(uid, loader);
}
@@ -69,7 +69,7 @@ public abstract class SharedCartridgeLoaderSystem : EntitySystem
component.InstallationStatus = state.InstallationStatus;
}
private void UpdateAppearanceData(EntityUid uid, SharedCartridgeLoaderComponent loader)
private void UpdateAppearanceData(EntityUid uid, CartridgeLoaderComponent loader)
{
_appearanceSystem.SetData(uid, CartridgeLoaderVisuals.CartridgeInserted, loader.CartridgeSlot.HasItem);
}

View File

@@ -0,0 +1,55 @@
using Content.Shared.CCVar;
using Content.Shared.Damage;
using Content.Shared.Interaction;
using Robust.Shared.Audio;
using Robust.Shared.GameStates;
namespace Content.Shared.Climbing
{
[RegisterComponent, NetworkedComponent]
public sealed class ClimbableComponent : Component
{
/// <summary>
/// The range from which this entity can be climbed.
/// </summary>
[DataField("range")] public float Range = SharedInteractionSystem.InteractionRange / 1.4f;
/// <summary>
/// The time it takes to climb onto the entity.
/// </summary>
[DataField("delay")]
public float ClimbDelay = 0.8f;
/// <summary>
/// If set, people can bonk on this if <see cref="CCVars.GameTableBonk"/> is set or if they are clumsy.
/// </summary>
[DataField("bonk")] public bool Bonk = false;
/// <summary>
/// Chance of bonk triggering if the user is clumsy.
/// </summary>
[DataField("bonkClumsyChance")]
public float BonkClumsyChance = 0.75f;
/// <summary>
/// Sound to play when bonking.
/// </summary>
/// <seealso cref="Bonk"/>
[DataField("bonkSound")]
public SoundSpecifier? BonkSound;
/// <summary>
/// How long to stun players on bonk, in seconds.
/// </summary>
/// <seealso cref="Bonk"/>
[DataField("bonkTime")]
public float BonkTime = 2;
/// <summary>
/// How much damage to apply on bonk.
/// </summary>
/// <seealso cref="Bonk"/>
[DataField("bonkDamage")]
public DamageSpecifier? BonkDamage;
}
}

View File

@@ -3,26 +3,29 @@ using Robust.Shared.Serialization;
namespace Content.Shared.Climbing;
[NetworkedComponent]
public abstract class SharedClimbingComponent : Component
[RegisterComponent, NetworkedComponent]
public sealed class ClimbingComponent : Component
{
/// <summary>
/// Whether the owner is climbing on a climbable entity.
/// </summary>
[ViewVariables]
public virtual bool IsClimbing { get; set; }
public bool IsClimbing { get; set; }
/// <summary>
/// Whether the owner is being moved onto the climbed entity.
/// </summary>
[ViewVariables]
public virtual bool OwnerIsTransitioning { get; set; }
public bool OwnerIsTransitioning { get; set; }
/// <summary>
/// We'll launch the mob onto the table and give them at least this amount of time to be on it.
/// </summary>
public const float BufferTime = 0.3f;
[ViewVariables]
public Dictionary<string, int> DisabledFixtureMasks { get; } = new();
[Serializable, NetSerializable]
public sealed class ClimbModeComponentState : ComponentState
{

View File

@@ -9,11 +9,11 @@ public abstract class SharedClimbSystem : EntitySystem
public override void Initialize()
{
base.Initialize();
SubscribeLocalEvent<SharedClimbingComponent, UpdateCanMoveEvent>(HandleMoveAttempt);
SubscribeLocalEvent<SharedClimbableComponent, CanDragDropOnEvent>(OnCanDragDropOn);
SubscribeLocalEvent<ClimbingComponent, UpdateCanMoveEvent>(HandleMoveAttempt);
SubscribeLocalEvent<ClimbableComponent, CanDragDropOnEvent>(OnCanDragDropOn);
}
private static void HandleMoveAttempt(EntityUid uid, SharedClimbingComponent component, UpdateCanMoveEvent args)
private static void HandleMoveAttempt(EntityUid uid, ClimbingComponent component, UpdateCanMoveEvent args)
{
if (component.LifeStage > ComponentLifeStage.Running)
return;
@@ -22,8 +22,8 @@ public abstract class SharedClimbSystem : EntitySystem
args.Cancel();
}
protected virtual void OnCanDragDropOn(EntityUid uid, SharedClimbableComponent component, CanDragDropOnEvent args)
protected virtual void OnCanDragDropOn(EntityUid uid, ClimbableComponent component, CanDragDropOnEvent args)
{
args.CanDrop = HasComp<SharedClimbingComponent>(args.Dragged);
args.CanDrop = HasComp<ClimbingComponent>(args.Dragged);
}
}

View File

@@ -1,12 +0,0 @@
using Content.Shared.Interaction;
namespace Content.Shared.Climbing
{
public abstract class SharedClimbableComponent : Component
{
/// <summary>
/// The range from which this entity can be climbed.
/// </summary>
[DataField("range")] public float Range = SharedInteractionSystem.InteractionRange / 1.4f;
}
}

View File

@@ -1,11 +1,20 @@
using System.Text.RegularExpressions;
using Content.Shared.Tools;
using Robust.Shared.GameStates;
using Robust.Shared.Serialization;
using Robust.Shared.Serialization.TypeSerializers.Implementations.Custom.Prototype;
namespace Content.Shared.Configurable
{
[Virtual]
public class SharedConfigurationComponent : Component
[RegisterComponent, NetworkedComponent]
public sealed class ConfigurationComponent : Component
{
[DataField("config")]
public readonly Dictionary<string, string> Config = new();
[DataField("qualityNeeded", customTypeSerializer: typeof(PrototypeIdSerializer<ToolQualityPrototype>))]
public string QualityNeeded = "Pulsing";
[DataField("validation")]
public readonly Regex Validation = new("^[a-zA-Z0-9 ]*$", RegexOptions.Compiled);

View File

@@ -1,12 +1,13 @@
using Robust.Shared.Containers;
using Robust.Shared.GameStates;
using Robust.Shared.Serialization;
namespace Content.Shared.Ensnaring.Components;
/// <summary>
/// Use this on an entity that you would like to be ensnared by anything that has the <see cref="SharedEnsnaringComponent"/>
/// Use this on an entity that you would like to be ensnared by anything that has the <see cref="EnsnaringComponent"/>
/// </summary>
[NetworkedComponent]
public abstract class SharedEnsnareableComponent : Component
[RegisterComponent, NetworkedComponent]
public sealed class EnsnareableComponent : Component
{
/// <summary>
/// How much should this slow down the entities walk?
@@ -28,6 +29,17 @@ public abstract class SharedEnsnareableComponent : Component
[ViewVariables(VVAccess.ReadWrite)]
[DataField("isEnsnared")]
public bool IsEnsnared;
/// <summary>
/// The container where the <see cref="EnsnaringComponent"/> entity will be stored
/// </summary>
public Container Container = default!;
[DataField("sprite")]
public string? Sprite;
[DataField("state")]
public string? State;
}
[Serializable, NetSerializable]

View File

@@ -1,8 +1,12 @@
namespace Content.Shared.Ensnaring.Components;
using System.Threading;
using Robust.Shared.GameStates;
namespace Content.Shared.Ensnaring.Components;
/// <summary>
/// Use this on something you want to use to ensnare an entity with
/// </summary>
public abstract class SharedEnsnaringComponent : Component
[RegisterComponent, NetworkedComponent]
public sealed class EnsnaringComponent : Component
{
/// <summary>
/// How long it should take to free someone else.
@@ -45,10 +49,19 @@ public abstract class SharedEnsnaringComponent : Component
[ViewVariables(VVAccess.ReadWrite)]
[DataField("ensnared")]
public EntityUid? Ensnared;
/// <summary>
/// Should movement cancel breaking out?
/// </summary>
[ViewVariables(VVAccess.ReadWrite)]
[DataField("canMoveBreakout")]
public bool CanMoveBreakout;
public CancellationTokenSource? CancelToken;
}
/// <summary>
/// Used whenever you want to do something when someone becomes ensnared by the <see cref="SharedEnsnaringComponent"/>
/// Used whenever you want to do something when someone becomes ensnared by the <see cref="EnsnaringComponent"/>
/// </summary>
public sealed class EnsnareEvent : EntityEventArgs
{
@@ -63,9 +76,35 @@ public sealed class EnsnareEvent : EntityEventArgs
}
/// <summary>
/// Used whenever you want to do something when someone is freed by the <see cref="SharedEnsnaringComponent"/>
/// Used whenever you want to do something when someone is freed by the <see cref="EnsnaringComponent"/>
/// </summary>
public sealed class EnsnareRemoveEvent : CancellableEntityEventArgs
{
}
/// <summary>
/// Used for the do after event to free the entity that owns the <see cref="EnsnareableComponent"/>
/// </summary>
public sealed class FreeEnsnareDoAfterComplete : EntityEventArgs
{
public readonly EntityUid EnsnaringEntity;
public FreeEnsnareDoAfterComplete(EntityUid ensnaringEntity)
{
EnsnaringEntity = ensnaringEntity;
}
}
/// <summary>
/// Used for the do after event when it fails to free the entity that owns the <see cref="EnsnareableComponent"/>
/// </summary>
public sealed class FreeEnsnareDoAfterCancel : EntityEventArgs
{
public readonly EntityUid EnsnaringEntity;
public FreeEnsnareDoAfterCancel(EntityUid ensnaringEntity)
{
EnsnaringEntity = ensnaringEntity;
}
}

View File

@@ -13,15 +13,15 @@ public abstract class SharedEnsnareableSystem : EntitySystem
{
base.Initialize();
SubscribeLocalEvent<SharedEnsnareableComponent, RefreshMovementSpeedModifiersEvent>(MovementSpeedModify);
SubscribeLocalEvent<SharedEnsnareableComponent, EnsnareEvent>(OnEnsnare);
SubscribeLocalEvent<SharedEnsnareableComponent, EnsnareRemoveEvent>(OnEnsnareRemove);
SubscribeLocalEvent<SharedEnsnareableComponent, EnsnaredChangedEvent>(OnEnsnareChange);
SubscribeLocalEvent<SharedEnsnareableComponent, ComponentGetState>(OnGetState);
SubscribeLocalEvent<SharedEnsnareableComponent, ComponentHandleState>(OnHandleState);
SubscribeLocalEvent<EnsnareableComponent, RefreshMovementSpeedModifiersEvent>(MovementSpeedModify);
SubscribeLocalEvent<EnsnareableComponent, EnsnareEvent>(OnEnsnare);
SubscribeLocalEvent<EnsnareableComponent, EnsnareRemoveEvent>(OnEnsnareRemove);
SubscribeLocalEvent<EnsnareableComponent, EnsnaredChangedEvent>(OnEnsnareChange);
SubscribeLocalEvent<EnsnareableComponent, ComponentGetState>(OnGetState);
SubscribeLocalEvent<EnsnareableComponent, ComponentHandleState>(OnHandleState);
}
private void OnHandleState(EntityUid uid, SharedEnsnareableComponent component, ref ComponentHandleState args)
private void OnHandleState(EntityUid uid, EnsnareableComponent component, ref ComponentHandleState args)
{
if (args.Current is not EnsnareableComponentState state)
return;
@@ -33,12 +33,12 @@ public abstract class SharedEnsnareableSystem : EntitySystem
RaiseLocalEvent(uid, new EnsnaredChangedEvent(component.IsEnsnared));
}
private void OnGetState(EntityUid uid, SharedEnsnareableComponent component, ref ComponentGetState args)
private void OnGetState(EntityUid uid, EnsnareableComponent component, ref ComponentGetState args)
{
args.State = new EnsnareableComponentState(component.IsEnsnared);
}
private void OnEnsnare(EntityUid uid, SharedEnsnareableComponent component, EnsnareEvent args)
private void OnEnsnare(EntityUid uid, EnsnareableComponent component, EnsnareEvent args)
{
component.WalkSpeed = args.WalkSpeed;
component.SprintSpeed = args.SprintSpeed;
@@ -49,7 +49,7 @@ public abstract class SharedEnsnareableSystem : EntitySystem
RaiseLocalEvent(uid, ev);
}
private void OnEnsnareRemove(EntityUid uid, SharedEnsnareableComponent component, EnsnareRemoveEvent args)
private void OnEnsnareRemove(EntityUid uid, EnsnareableComponent component, EnsnareRemoveEvent args)
{
_speedModifier.RefreshMovementSpeedModifiers(uid);
@@ -57,17 +57,17 @@ public abstract class SharedEnsnareableSystem : EntitySystem
RaiseLocalEvent(uid, ev);
}
private void OnEnsnareChange(EntityUid uid, SharedEnsnareableComponent component, EnsnaredChangedEvent args)
private void OnEnsnareChange(EntityUid uid, EnsnareableComponent component, EnsnaredChangedEvent args)
{
UpdateAppearance(uid, component);
}
private void UpdateAppearance(EntityUid uid, SharedEnsnareableComponent component, AppearanceComponent? appearance = null)
private void UpdateAppearance(EntityUid uid, EnsnareableComponent component, AppearanceComponent? appearance = null)
{
Appearance.SetData(uid, EnsnareableVisuals.IsEnsnared, component.IsEnsnared, appearance);
}
private void MovementSpeedModify(EntityUid uid, SharedEnsnareableComponent component, RefreshMovementSpeedModifiersEvent args)
private void MovementSpeedModify(EntityUid uid, EnsnareableComponent component, RefreshMovementSpeedModifiersEvent args)
{
if (!component.IsEnsnared)
return;

View File

@@ -89,7 +89,7 @@ namespace Content.Shared.Interaction
return true;
}
if (EntityManager.TryGetComponent(user, out SharedBuckleComponent? buckle) && buckle.Buckled)
if (EntityManager.TryGetComponent(user, out BuckleComponent? buckle) && buckle.Buckled)
{
var suid = buckle.LastEntityBuckledTo;
if (suid != null)

View File

@@ -59,7 +59,7 @@ namespace Content.Shared.Pulling
return false;
}
if (EntityManager.TryGetComponent<SharedBuckleComponent?>(puller, out var buckle))
if (EntityManager.TryGetComponent<BuckleComponent?>(puller, out var buckle))
{
// Prevent people pulling the chair they're on, etc.
if (buckle.Buckled && (buckle.LastEntityBuckledTo == pulled))

View File

@@ -1,10 +1,9 @@
using Content.Shared.Singularity.Components;
using Robust.Shared.GameStates;
namespace Content.Server.Singularity.Components;
namespace Content.Shared.Singularity.Components;
[RegisterComponent]
[ComponentReference(typeof(SharedContainmentFieldComponent))]
public sealed class ContainmentFieldComponent : SharedContainmentFieldComponent
[RegisterComponent, NetworkedComponent]
public sealed class ContainmentFieldComponent : Component
{
/// <summary>
/// The throw force for the field if an entity collides with it

View File

@@ -1,15 +1,16 @@
using Content.Shared.Physics;
using Content.Shared.Singularity.Components;
using Content.Shared.Tag;
using Robust.Shared.GameStates;
using Robust.Shared.Prototypes;
using Robust.Shared.Serialization;
using Robust.Shared.Serialization.TypeSerializers.Implementations.Custom.Prototype;
namespace Content.Server.Singularity.Components;
[RegisterComponent]
[ComponentReference(typeof(SharedContainmentFieldGeneratorComponent))]
public sealed class ContainmentFieldGeneratorComponent : SharedContainmentFieldGeneratorComponent
namespace Content.Shared.Singularity.Components;
[RegisterComponent, NetworkedComponent]
public sealed class ContainmentFieldGeneratorComponent : Component
{
private int _powerBuffer;
private int _powerBuffer;
/// <summary>
/// Store power with a cap. Decrease over time if not being powered from source.
@@ -100,3 +101,29 @@ public sealed class ContainmentFieldGeneratorComponent : SharedContainmentFieldG
[DataField("createdField", customTypeSerializer: typeof(PrototypeIdSerializer<EntityPrototype>))]
public string CreatedField = "ContainmentField";
}
[Serializable, NetSerializable]
public enum ContainmentFieldGeneratorVisuals : byte
{
PowerLight,
FieldLight,
OnLight,
}
[Serializable, NetSerializable]
public enum PowerLevelVisuals : byte
{
NoPower,
LowPower,
MediumPower,
HighPower,
}
[Serializable, NetSerializable]
public enum FieldLevelVisuals : byte
{
NoLevel,
On,
OneField,
MultipleFields,
}

View File

@@ -1,2 +0,0 @@
namespace Content.Shared.Singularity.Components;
public abstract class SharedContainmentFieldComponent : Component { }

View File

@@ -1,30 +0,0 @@
using Robust.Shared.Serialization;
namespace Content.Shared.Singularity.Components;
public abstract class SharedContainmentFieldGeneratorComponent : Component { }
[Serializable, NetSerializable]
public enum ContainmentFieldGeneratorVisuals : byte
{
PowerLight,
FieldLight,
OnLight,
}
[Serializable, NetSerializable]
public enum PowerLevelVisuals : byte
{
NoPower,
LowPower,
MediumPower,
HighPower,
}
[Serializable, NetSerializable]
public enum FieldLevelVisuals : byte
{
NoLevel,
On,
OneField,
MultipleFields,
}

View File

@@ -190,8 +190,8 @@ public abstract class SharedEventHorizonSystem : EntitySystem
// If we can, breach containment
// otherwise, check if it's containment and just keep the collision
if (EntityManager.HasComponent<SharedContainmentFieldComponent>(otherUid) ||
EntityManager.HasComponent<SharedContainmentFieldGeneratorComponent>(otherUid))
if (EntityManager.HasComponent<ContainmentFieldComponent>(otherUid) ||
EntityManager.HasComponent<ContainmentFieldGeneratorComponent>(otherUid))
{
if (comp.CanBreachContainment)
args.Cancelled = true;

View File

@@ -118,7 +118,7 @@ public abstract partial class SharedVehicleSystem : EntitySystem
UpdateDrawDepth(uid, 2);
// This code should be purged anyway but with that being said this doesn't handle components being changed.
if (TryComp<SharedStrapComponent>(uid, out var strap))
if (TryComp<StrapComponent>(uid, out var strap))
{
component.BaseBuckleOffset = strap.BuckleOffset;
strap.BuckleOffsetUnclamped = Vector2.Zero;
@@ -159,7 +159,7 @@ public abstract partial class SharedVehicleSystem : EntitySystem
/// </summary>
protected void UpdateBuckleOffset(TransformComponent xform, VehicleComponent component)
{
if (!TryComp<SharedStrapComponent>(component.Owner, out var strap))
if (!TryComp<StrapComponent>(component.Owner, out var strap))
return;
// TODO: Strap should handle this but buckle E/C moment.