From 311227de33913a98026e57332f9ce073c63c81c4 Mon Sep 17 00:00:00 2001 From: Pspritechologist Date: Thu, 8 Feb 2024 02:33:22 -0500 Subject: [PATCH] Lots of using hardcoded values less, switched collision to a whitelist. Should Holograms collide with windows? --- .../Holograms/Systems/HologramServerSystem.cs | 2 +- .../Holograms/Systems/HologramSystem.cs | 9 ++-- .../Holograms/Components/HologramComponent.cs | 53 +++++++++++++++++-- .../HologramServerLinkedComponent.cs | 2 - .../Systems/SharedHologramSystem.Projected.cs | 23 ++++---- .../Holograms/Systems/SharedHologramSystem.cs | 18 +++---- .../Entities/Mobs/Player/hologram.yml | 6 ++- 7 files changed, 81 insertions(+), 32 deletions(-) diff --git a/Content.Server/SimpleStation14/Holograms/Systems/HologramServerSystem.cs b/Content.Server/SimpleStation14/Holograms/Systems/HologramServerSystem.cs index e61621d8e4..1ac876c674 100644 --- a/Content.Server/SimpleStation14/Holograms/Systems/HologramServerSystem.cs +++ b/Content.Server/SimpleStation14/Holograms/Systems/HologramServerSystem.cs @@ -61,7 +61,7 @@ private void OnEntInserted(EntityUid uid, HologramServerComponent component, Ent /// private void OnEntRemoved(EntityUid uid, HologramServerComponent component, EntRemovedFromContainerMessage args) { - if (args.Container.ID != component.DiskSlot || !_tags.HasTag(args.Entity, "HoloDisk")) + if (args.Container.ID != component.DiskSlot || !_tags.HasTag(args.Entity, TagHoloDisk)) return; if (Exists(component.LinkedHologram)) diff --git a/Content.Server/SimpleStation14/Holograms/Systems/HologramSystem.cs b/Content.Server/SimpleStation14/Holograms/Systems/HologramSystem.cs index 5f3f446c50..f5b67677e0 100644 --- a/Content.Server/SimpleStation14/Holograms/Systems/HologramSystem.cs +++ b/Content.Server/SimpleStation14/Holograms/Systems/HologramSystem.cs @@ -71,15 +71,18 @@ public sealed class HologramSystem : SharedHologramSystem /// public override void DoKillHologram(EntityUid hologram, HologramComponent? holoComp = null) // TODOPark: HOLO Move this to Shared once Upstream merge. { + if (!Resolve(hologram, ref holoComp)) + return; + var meta = MetaData(hologram); var holoPos = Transform(hologram).Coordinates; if (TryComp(hologram, out var mindComp) && mindComp.Mind != null) _gameTicker.OnGhostAttempt(mindComp.Mind, false); - _audio.Play(filename: "/Audio/SimpleStation14/Effects/Hologram/holo_off.ogg", playerFilter: Filter.Pvs(hologram), coordinates: holoPos, false); - _popup.PopupCoordinates(Loc.GetString(PopupDisappearOther, ("name", meta.EntityName)), holoPos, Filter.PvsExcept(hologram), false, PopupType.MediumCaution); - _popup.PopupCoordinates(Loc.GetString(PopupDeathSelf), holoPos, hologram, PopupType.LargeCaution); + _audio.Play(holoComp.OffSound, playerFilter: Filter.Pvs(hologram), coordinates: holoPos, false); + _popup.PopupCoordinates(Loc.GetString(holoComp.PopupDisappearOther, ("name", meta.EntityName)), holoPos, Filter.PvsExcept(hologram), false, PopupType.MediumCaution); + _popup.PopupCoordinates(Loc.GetString(holoComp.PopupDeathSelf), holoPos, hologram, PopupType.LargeCaution); _entityManager.QueueDeleteEntity(hologram); diff --git a/Content.Shared/SimpleStation14/Holograms/Components/HologramComponent.cs b/Content.Shared/SimpleStation14/Holograms/Components/HologramComponent.cs index 1460e6b1c3..3aefe19ec8 100644 --- a/Content.Shared/SimpleStation14/Holograms/Components/HologramComponent.cs +++ b/Content.Shared/SimpleStation14/Holograms/Components/HologramComponent.cs @@ -1,8 +1,6 @@ -using Content.Shared.Tag; +using Content.Shared.Whitelist; using Robust.Shared.Audio; using Robust.Shared.GameStates; -using Robust.Shared.Serialization.TypeSerializers.Implementations; -using Robust.Shared.Serialization.TypeSerializers.Implementations.Custom.Prototype.List; namespace Content.Shared.SimpleStation14.Holograms; @@ -18,20 +16,65 @@ public sealed class HologramComponent : Component /// The sound to play when the Hologram is turned on. /// [DataField("onSound"), ViewVariables(VVAccess.ReadWrite)] + [AutoNetworkedField] public SoundSpecifier OnSound = new SoundPathSpecifier("/Audio/SimpleStation14/Effects/Hologram/holo_on.ogg"); /// /// The sound to play when the Hologram is turned off. /// [DataField("offSound"), ViewVariables(VVAccess.ReadWrite)] + [AutoNetworkedField] public SoundSpecifier OffSound = new SoundPathSpecifier("/Audio/SimpleStation14/Effects/Hologram/holo_off.ogg"); + /// + /// The string to use for the popup when the Hologram appears, shown to others. + /// + [DataField("popupAppearOther"), ViewVariables(VVAccess.ReadWrite)] + [AutoNetworkedField] + public string PopupAppearOther = "system-hologram-phasing-appear-others"; + + /// + /// The string to use for the popup when the Hologram appears, shown to themselves. + /// + [DataField("popupAppearSelf"), ViewVariables(VVAccess.ReadWrite)] + [AutoNetworkedField] + public string PopupAppearSelf = "system-hologram-phasing-appear-self"; + + /// + /// The string to use for the popup when the Hologram disappears, shown to others. + /// + [DataField("popupDisappearOther"), ViewVariables(VVAccess.ReadWrite)] + [AutoNetworkedField] + public string PopupDisappearOther = "system-hologram-phasing-disappear-others"; + + /// + /// The string to use for the popup when the Hologram is killed, shown to themselves. + /// + [DataField("popupDeathSelf"), ViewVariables(VVAccess.ReadWrite)] + [AutoNetworkedField] + public string PopupDeathSelf = "system-hologram-phasing-death-self"; + + /// + /// The string to use for the popup when the Hologram fails to interact with something, due to their non-solid nature. + /// + [DataField("popupHoloInteractionFail"), ViewVariables(VVAccess.ReadWrite)] + [AutoNetworkedField] + public string PopupHoloInteractionFail = "system-hologram-interaction-with-others-fail"; + + /// + /// The string to use for the popup when the someone fails to interact with the Hologram, due to their non-holographic nature. + /// + [DataField("popupInteractionWithHoloFail"), ViewVariables(VVAccess.ReadWrite)] + [AutoNetworkedField] + public string PopupInteractionWithHoloFail = "system-hologram-interaction-with-holo-fail"; + /// /// A list of tags for the Hologram to collide with, assuming they're not hardlight. /// /// /// This should generally include the 'Wall' tag. /// - [DataField("collideTags", customTypeSerializer: typeof(PrototypeIdListSerializer)), ViewVariables(VVAccess.ReadWrite)] - public List CollideTags = new() { "Wall", "Airlock" }; + [DataField("collideWhitelist"), ViewVariables(VVAccess.ReadWrite)] + [AutoNetworkedField] + public EntityWhitelist CollideWhitelist = new(); } diff --git a/Content.Shared/SimpleStation14/Holograms/Components/HologramServerLinkedComponent.cs b/Content.Shared/SimpleStation14/Holograms/Components/HologramServerLinkedComponent.cs index cb7644129d..e5794ad6f3 100644 --- a/Content.Shared/SimpleStation14/Holograms/Components/HologramServerLinkedComponent.cs +++ b/Content.Shared/SimpleStation14/Holograms/Components/HologramServerLinkedComponent.cs @@ -17,7 +17,6 @@ public sealed partial class HologramServerLinkedComponent : Component /// [ViewVariables(VVAccess.ReadWrite)] [DataField("gridBound"), AutoNetworkedField] - [AutoNetworkedField] public bool GridBound = true; /// @@ -28,6 +27,5 @@ public sealed partial class HologramServerLinkedComponent : Component /// [ViewVariables(VVAccess.ReadOnly)] [AutoNetworkedField] - [AutoNetworkedField] public EntityUid? LinkedServer; } diff --git a/Content.Shared/SimpleStation14/Holograms/Systems/SharedHologramSystem.Projected.cs b/Content.Shared/SimpleStation14/Holograms/Systems/SharedHologramSystem.Projected.cs index f06f588994..4333f49559 100644 --- a/Content.Shared/SimpleStation14/Holograms/Systems/SharedHologramSystem.Projected.cs +++ b/Content.Shared/SimpleStation14/Holograms/Systems/SharedHologramSystem.Projected.cs @@ -44,9 +44,9 @@ public virtual void DoReturnHologram(EntityUid hologram, HologramProjectedCompon // If their last visited Projector is invalid ignoring occlusion and none is found if (!IsHoloProjectorValid(hologram, holoProjectedComp.CurProjector, 0, false) && - !TryGetHoloProjector(hologram, holoProjectedComp.ProjectorRange, out holoProjectedComp.CurProjector, holoProjectedComp, false)) + !TryGetHoloProjector(hologram, holoProjectedComp.ProjectorRange, out holoProjectedComp.CurProjector, holoProjectedComp, false)) { - // Kill the hologram. + // Kill the hologram. TryKillHologram(hologram); return; } @@ -190,8 +190,11 @@ public bool IsHoloProjectorValid(MapCoordinates hologram, [NotNullWhen(true)] En /// /// The hologram to move. /// The projector to move it to, or the projector's position. - public void MoveHologram(EntityUid hologram, EntityCoordinates projector) + public void MoveHologram(EntityUid hologram, EntityCoordinates projector, HologramComponent? holoComp = null) { + if (!Resolve(hologram, ref holoComp)) + return; + // Stops any pulling goin on. if (TryComp(hologram, out var pullable) && pullable.BeingPulled) _pulling.TryStopPull(pullable); @@ -206,8 +209,8 @@ public void MoveHologram(EntityUid hologram, EntityCoordinates projector) if (!_timing.InPrediction) // TODOPark: HOLO Change this to run on the first prediction once it predicts reliably. { var holoPos = Transform(hologram).Coordinates; - _audio.Play(filename: "/Audio/SimpleStation14/Effects/Hologram/holo_off.ogg", playerFilter: Filter.Pvs(hologram), coordinates: holoPos, false); - _popup.PopupCoordinates(Loc.GetString(PopupDisappearOther, ("name", meta.EntityName)), holoPos, Filter.PvsExcept(hologram), false, PopupType.MediumCaution); + _audio.Play(holoComp.OffSound, playerFilter: Filter.Pvs(hologram), coordinates: holoPos, false); + _popup.PopupCoordinates(Loc.GetString(holoComp.PopupDisappearOther, ("name", meta.EntityName)), holoPos, Filter.PvsExcept(hologram), false, PopupType.MediumCaution); } // Does the do. @@ -217,16 +220,16 @@ public void MoveHologram(EntityUid hologram, EntityCoordinates projector) // Plays the appearing effects. if (!_timing.InPrediction) { - _audio.PlayPvs("/Audio/SimpleStation14/Effects/Hologram/holo_on.ogg", hologram); - _popup.PopupEntity(Loc.GetString(PopupAppearOther, ("name", meta.EntityName)), hologram, Filter.PvsExcept(hologram), false, PopupType.Medium); - _popup.PopupEntity(Loc.GetString(PopupAppearSelf, ("name", meta.EntityName)), hologram, hologram, PopupType.Large); + _audio.PlayPvs(holoComp.OnSound, hologram); + _popup.PopupEntity(Loc.GetString(holoComp.PopupAppearOther, ("name", meta.EntityName)), hologram, Filter.PvsExcept(hologram), false, PopupType.Medium); + _popup.PopupEntity(Loc.GetString(holoComp.PopupAppearSelf, ("name", meta.EntityName)), hologram, hologram, PopupType.Large); } } /// - public void MoveHologramToProjector(EntityUid hologram, EntityUid projector) + public void MoveHologramToProjector(EntityUid hologram, EntityUid projector, HologramComponent? holoComp = null) { - MoveHologram(hologram, Transform(projector).Coordinates); + MoveHologram(hologram, Transform(projector).Coordinates, holoComp); } protected bool ProjectedUpdate(EntityUid hologram, HologramProjectedComponent hologramProjectedComp, float frameTime) diff --git a/Content.Shared/SimpleStation14/Holograms/Systems/SharedHologramSystem.cs b/Content.Shared/SimpleStation14/Holograms/Systems/SharedHologramSystem.cs index 8227139bb3..dc3171afe5 100644 --- a/Content.Shared/SimpleStation14/Holograms/Systems/SharedHologramSystem.cs +++ b/Content.Shared/SimpleStation14/Holograms/Systems/SharedHologramSystem.cs @@ -21,13 +21,6 @@ public abstract partial class SharedHologramSystem : EntitySystem [Dependency] private readonly SharedPullingSystem _pulling = default!; [Dependency] private readonly IGameTiming _timing = default!; - protected const string PopupAppearOther = "system-hologram-phasing-appear-others"; - protected const string PopupAppearSelf = "system-hologram-phasing-appear-self"; - protected const string PopupDisappearOther = "system-hologram-phasing-disappear-others"; - protected const string PopupDeathSelf = "system-hologram-phasing-death-self"; - protected const string PopupHoloInteractionFail = "system-hologram-interaction-with-others-fail"; - protected const string PopupInteractionWithHoloFail = "system-hologram-interaction-with-holo-fail"; - public const string TagHardLight = "Hardlight"; public const string TagHoloMapped = "HoloMapped"; // TODO: HOLO @@ -73,7 +66,7 @@ private void OnInteractionWithHoloAttempt(EntityUid uid, HologramComponent compo private void OnHoloCollide(EntityUid uid, HologramComponent component, ref PreventCollideEvent args) { - if (Transform(args.OtherEntity).Anchored || HoloInteractionAllowed(args.OurEntity, args.OtherEntity, component)) + if (HoloInteractionAllowed(args.OurEntity, args.OtherEntity, component)) return; args.Cancelled = true; @@ -89,7 +82,14 @@ public bool HoloInteractionAllowed(EntityUid hologram, EntityUid? potential, Hol { if (potential == null) return true; - return _tags.HasTag(hologram, TagHardLight) || _tags.HasTag(potential.Value, TagHardLight) || Resolve(hologram, ref holoComp) == HasComp(potential); + + if (!Resolve(hologram, ref holoComp)) + return false; + + return _tags.HasTag(hologram, TagHardLight) || // Is the hologram hardlight? + _tags.HasTag(potential.Value, TagHardLight) || // Is the collider hardlight? + HasComp(potential) || // Is the collider a hologram? + holoComp.CollideWhitelist.IsValid(potential.Value); // Is the collider whitelisted in the hologram's collision whitelist? } /// diff --git a/Resources/Prototypes/SimpleStation14/Entities/Mobs/Player/hologram.yml b/Resources/Prototypes/SimpleStation14/Entities/Mobs/Player/hologram.yml index 7e966b3d81..2a330a3972 100644 --- a/Resources/Prototypes/SimpleStation14/Entities/Mobs/Player/hologram.yml +++ b/Resources/Prototypes/SimpleStation14/Entities/Mobs/Player/hologram.yml @@ -145,9 +145,11 @@ components: - type: Hologram isHardLight: false - collideTags: - - Wall + collideWhitelist: + components: - Airlock + tags: + - Wall - type: HologramProjected gracePeriod: 0.08 validProjectorWhitelist: