This repository was archived by the owner on Dec 30, 2024. It is now read-only.
-
Notifications
You must be signed in to change notification settings - Fork 46
Holograms #233
Open
Pspritechologist
wants to merge
26
commits into
master
Choose a base branch
from
holograms
base: master
Could not load branches
Branch not found: {{ refName }}
Loading
Could not load tags
Nothing to show
Loading
Are you sure you want to change the base?
Some commits from the old base branch may be removed from the timeline,
and old review comments may become outdated.
Open
Holograms #233
Changes from all commits
Commits
Show all changes
26 commits
Select commit
Hold shift + click to select a range
707cd02
Added a new mob typed named Hologram, set up a clone of the Drone whi…
Pspritechologist 51f9f7a
adds early scutters, and the basis of a charging system.
Pspritechologist dda4ecb
Working on it
Pspritechologist a130117
Lots more work towards holograms, probably too long without committin…
Pspritechologist be2c58e
Committing more
Pspritechologist c0c4f96
More work on Holograms. Moved most things over to events, bug where h…
Pspritechologist b1cefe2
Fixed holocorgi ID
Pspritechologist 4f45ffd
Fuckin working again. Stuff is networked now, though not to any real …
Pspritechologist 6e1458c
Prepared for projected, lightbee, and hardlight holos by separating t…
Pspritechologist 3688ea1
Removed some unneeded things, cleaned some files, made it Holograms c…
Pspritechologist 731832e
Added damage sets for Holograms, kinda fixed rotation on spawn, begun…
Pspritechologist f8c39b3
Removed unneeded files
Pspritechologist aa7ec26
Removed unused component
Pspritechologist 232b0c6
Death's tweaks, filtered :)
Pspritechologist 10e158e
Made Enum worked, cleaned up a bit, and fixed all namespaces
Pspritechologist 7986db5
Substantial cleanup to the code post rebase
Pspritechologist 45a55d5
Fixes double-playing audio
Pspritechologist 5279c73
Completely overhauled large portions.
Pspritechologist 15995ca
Bulk of work done towards the HologramProjectedComponent's functional…
Pspritechologist 4718be2
Ton of work refactoring Holograms, generally cleaning it up, and addi…
Pspritechologist 29de297
Merge branch 'master' into holograms
Pspritechologist d29cb66
Work towards cleaning up, making the Eye better.
Pspritechologist 22d3845
Apply suggestions from code review
Pspritechologist 311227d
Lots of using hardcoded values less, switched collision to a whitelist.
Pspritechologist f6706a9
Making more things holograms
Pspritechologist bc384d3
CCTV System is in place for getting Holodisks... *
Pspritechologist File filter
Filter by extension
Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
There are no files selected for viewing
43 changes: 43 additions & 0 deletions
43
Content.Client/SimpleStation14/Holograms/AcceptHologramEui.cs
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
| Original file line number | Diff line number | Diff line change |
|---|---|---|
| @@ -0,0 +1,43 @@ | ||
| using Content.Client.Eui; | ||
| using Content.Client.Holograms; | ||
| using Content.Shared.SimpleStation14.Holograms; | ||
| using JetBrains.Annotations; | ||
| using Robust.Client.Graphics; | ||
|
|
||
| namespace Content.Client.SimpleStation14.Holograms; | ||
|
|
||
| [UsedImplicitly] | ||
| public sealed class AcceptHologramEui : BaseEui | ||
| { | ||
| private readonly AcceptHologramWindow _window; | ||
|
|
||
| public AcceptHologramEui() | ||
| { | ||
| _window = new AcceptHologramWindow(); | ||
|
|
||
| _window.DenyButton.OnPressed += _ => | ||
| { | ||
| SendMessage(new AcceptHologramChoiceMessage(AcceptHologramUiButton.Deny)); | ||
| _window.Close(); | ||
| }; | ||
|
|
||
| _window.OnClose += () => SendMessage(new AcceptHologramChoiceMessage(AcceptHologramUiButton.Deny)); | ||
|
|
||
| _window.AcceptButton.OnPressed += _ => | ||
| { | ||
| SendMessage(new AcceptHologramChoiceMessage(AcceptHologramUiButton.Accept)); | ||
| _window.Close(); | ||
| }; | ||
| } | ||
|
|
||
| public override void Opened() | ||
| { | ||
| IoCManager.Resolve<IClyde>().RequestWindowAttention(); | ||
| _window.OpenCentered(); | ||
| } | ||
|
|
||
| public override void Closed() | ||
| { | ||
| _window.Close(); | ||
| } | ||
| } |
60 changes: 60 additions & 0 deletions
60
Content.Client/SimpleStation14/Holograms/AcceptHologramWindow.cs
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
| Original file line number | Diff line number | Diff line change |
|---|---|---|
| @@ -0,0 +1,60 @@ | ||
| using System.Numerics; | ||
| using Robust.Client.UserInterface; | ||
| using Robust.Client.UserInterface.Controls; | ||
| using Robust.Client.UserInterface.CustomControls; | ||
| using static Robust.Client.UserInterface.Controls.BoxContainer; | ||
|
|
||
| namespace Content.Client.Holograms; | ||
|
|
||
| public sealed class AcceptHologramWindow : DefaultWindow | ||
| { | ||
| public readonly Button DenyButton; | ||
| public readonly Button AcceptButton; | ||
|
|
||
| public AcceptHologramWindow() | ||
| { | ||
|
|
||
| Title = Loc.GetString("accept-hologram-window-title"); | ||
|
|
||
| Contents.AddChild(new BoxContainer | ||
| { | ||
| Orientation = LayoutOrientation.Vertical, | ||
| Children = | ||
| { | ||
| new BoxContainer | ||
| { | ||
| Orientation = LayoutOrientation.Vertical, | ||
| Children = | ||
| { | ||
| new Label() | ||
| { | ||
| Text = Loc.GetString("accept-hologram-window-prompt-text-part") | ||
| }, | ||
| new BoxContainer | ||
| { | ||
| Orientation = LayoutOrientation.Horizontal, | ||
| Align = AlignMode.Center, | ||
| Children = | ||
| { | ||
| (AcceptButton = new Button | ||
| { | ||
| Text = Loc.GetString("accept-hologram-window-accept-button"), | ||
| }), | ||
|
|
||
| new Control() | ||
| { | ||
| MinSize = new Vector2(20, 0) | ||
| }, | ||
|
|
||
| (DenyButton = new Button | ||
| { | ||
| Text = Loc.GetString("accept-hologram-window-deny-button"), | ||
| }) | ||
| } | ||
| }, | ||
| } | ||
| }, | ||
| } | ||
| }); | ||
| } | ||
| } |
51 changes: 51 additions & 0 deletions
51
Content.Client/SimpleStation14/Holograms/CctvDatabaseUi/CctvDatabaseBoundUserInterface.cs
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
| Original file line number | Diff line number | Diff line change |
|---|---|---|
| @@ -0,0 +1,51 @@ | ||
| using Content.Shared.SimpleStation14.Holograms; | ||
| using Robust.Client.GameObjects; | ||
|
|
||
| namespace Content.Client.SimpleStation14.Holograms.CctvDatabaseUi; | ||
|
|
||
| public sealed class CctvDatabaseBoundUserInterface : BoundUserInterface | ||
| { | ||
| [ViewVariables] | ||
| private CctvDatabaseWindow? _menu; | ||
|
|
||
| public CctvDatabaseBoundUserInterface(EntityUid owner, Enum uiKey) : base(owner, uiKey) | ||
| { | ||
| } | ||
|
|
||
| protected override void Open() | ||
| { | ||
| _menu = new CctvDatabaseWindow(); | ||
|
|
||
| _menu.OpenCentered(); | ||
| _menu.OnClose += Close; | ||
|
|
||
| _menu.PrintRequested += SendPrintRequest; | ||
| } | ||
|
|
||
| private void SendPrintRequest(int index) | ||
| { | ||
| Logger.Error($"Sending message for index {index}"); | ||
| SendMessage(new CctvDatabasePrintRequestMessage(index)); | ||
| } | ||
|
|
||
| protected override void UpdateState(BoundUserInterfaceState state) | ||
| { | ||
| base.UpdateState(state); | ||
|
|
||
| switch (state) | ||
| { | ||
| case CctvDatabaseState cctvState: | ||
| _menu?.UpdateState(cctvState); | ||
| break; | ||
| } | ||
| } | ||
|
|
||
| protected override void Dispose(bool disposing) | ||
| { | ||
| base.Dispose(disposing); | ||
| if (!disposing) | ||
| return; | ||
|
|
||
| _menu?.Dispose(); | ||
| } | ||
| } |
33 changes: 33 additions & 0 deletions
33
Content.Client/SimpleStation14/Holograms/CctvDatabaseUi/CctvDatabaseWindow.xaml
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
| Original file line number | Diff line number | Diff line change |
|---|---|---|
| @@ -0,0 +1,33 @@ | ||
| <controls:FancyWindow | ||
| xmlns="https://spacestation14.io" | ||
| xmlns:ui="clr-namespace:Content.Client.UserInterface.Controls" | ||
| xmlns:controls="clr-namespace:Content.Client.UserInterface.Controls" | ||
| Title="{Loc 'cctv-database-user-interface-title'}" | ||
| SetSize="250 550" | ||
| MinSize="200 350"> | ||
| <BoxContainer | ||
| HorizontalExpand="True" | ||
| VerticalExpand="True" | ||
| Orientation="Vertical"> | ||
| <BoxContainer | ||
| HorizontalExpand="True" | ||
| VerticalExpand="False" | ||
| Orientation="Horizontal"> | ||
| <Label | ||
| Name="MessageLabel" | ||
| Text="{Loc 'cctv-database-user-interface-message-idle'}"/> | ||
| </BoxContainer> | ||
| <ScrollContainer | ||
| HorizontalExpand="False" | ||
| VerticalExpand="True" | ||
| Margin="8, 8, 8, 8"> | ||
| <GridContainer | ||
| Name="TargetList" | ||
| HorizontalExpand="True" | ||
| VerticalExpand="True" | ||
| HSeparationOverride="8" | ||
| Columns="2"> | ||
| </GridContainer> | ||
| </ScrollContainer> | ||
| </BoxContainer> | ||
| </controls:FancyWindow> |
64 changes: 64 additions & 0 deletions
64
Content.Client/SimpleStation14/Holograms/CctvDatabaseUi/CctvDatabaseWindow.xaml.cs
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
| Original file line number | Diff line number | Diff line change |
|---|---|---|
| @@ -0,0 +1,64 @@ | ||
| using Content.Client.UserInterface.Controls; | ||
| using Content.Shared.SimpleStation14.Holograms; | ||
| using Robust.Client.AutoGenerated; | ||
| using Robust.Client.UserInterface.Controls; | ||
| using Robust.Shared.Timing; | ||
|
|
||
| namespace Content.Client.SimpleStation14.Holograms.CctvDatabaseUi; | ||
|
|
||
| [GenerateTypedNameReferences] | ||
| public sealed partial class CctvDatabaseWindow : FancyWindow | ||
| { | ||
| [Dependency] private readonly IGameTiming _timing = default!; | ||
|
|
||
| public Action<int>? PrintRequested; | ||
|
|
||
| private const string IdleMessage = "cctv-database-user-interface-message-idle"; | ||
| private const string PrintingMessage = "cctv-database-user-interface-message-printing"; | ||
|
|
||
| private TimeSpan? _printTime; | ||
|
|
||
| public void UpdateState(CctvDatabaseState state) | ||
| { | ||
| var entries = state.CrewManifest; | ||
| _printTime = state.FinishedPrintingTime; | ||
|
|
||
| TargetList.RemoveAllChildren(); | ||
|
|
||
| var disabled = state.FinishedPrintingTime != null; | ||
| for (var i = 0; i < entries.Count; i++) | ||
| { | ||
| var label = new Label | ||
| { | ||
| Text = entries[i], | ||
| }; | ||
|
|
||
| var button = new Button | ||
| { | ||
| Text = "Print", | ||
| Disabled = disabled, | ||
| }; | ||
|
|
||
| var index = i; | ||
| button.OnPressed += _ => PrintRequested?.Invoke(index); | ||
|
|
||
| TargetList.AddChild(label); | ||
| TargetList.AddChild(button); | ||
| } | ||
|
|
||
| MessageLabel.Text = state.FinishedPrintingTime.ToString() ?? Loc.GetString(IdleMessage); | ||
| } | ||
|
|
||
| protected override void FrameUpdate(FrameEventArgs args) | ||
| { | ||
| base.FrameUpdate(args); | ||
|
|
||
| if (_printTime == null) | ||
| return; | ||
|
|
||
| var timeLeft = _printTime.Value - _timing.CurTime; | ||
| MessageLabel.Text = timeLeft > TimeSpan.Zero | ||
| ? $"{Loc.GetString(PrintingMessage)}: {timeLeft.TotalSeconds:0.0}" | ||
| : Loc.GetString(IdleMessage); | ||
| } | ||
| } |
129 changes: 129 additions & 0 deletions
129
Content.Client/SimpleStation14/Holograms/HologramSystem.cs
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
| Original file line number | Diff line number | Diff line change |
|---|---|---|
| @@ -0,0 +1,129 @@ | ||
| using System.Numerics; | ||
| using Content.Shared.SimpleStation14.Holograms; | ||
| using Content.Shared.SimpleStation14.Holograms.Components; | ||
| using Robust.Client.GameObjects; | ||
| using Robust.Client.Player; | ||
| using Robust.Shared.Map; | ||
|
|
||
| namespace Content.Client.SimpleStation14.Holograms; | ||
|
|
||
| public sealed class HologramSystem : SharedHologramSystem | ||
| { | ||
| [Dependency] private readonly IPlayerManager _player = default!; | ||
| [Dependency] private readonly TransformSystem _transform = default!; | ||
|
|
||
| public override void Initialize() | ||
| { | ||
| base.Initialize(); | ||
|
|
||
| SubscribeLocalEvent<HologramProjectedComponent, ComponentShutdown>(OnProjectedShutdown); | ||
| } | ||
|
|
||
| public override void Update(float frameTime) | ||
| { | ||
| var player = _player.LocalPlayer?.ControlledEntity; | ||
| if (TryComp<HologramProjectedComponent>(player, out var holoProjComp)) | ||
| { | ||
| ProjectedUpdate(player.Value, holoProjComp, frameTime); // This makes it so only the currently controlled entity is predicted, assuming they're a hologram. | ||
|
|
||
| // Check if we should be setting the eye target of the hologram. | ||
| if (holoProjComp.SetEyeTarget && TryComp<EyeComponent>(player.Value, out var eyeComp)) | ||
| eyeComp.Target = holoProjComp.CurProjector; | ||
| } | ||
|
|
||
| HandleProjectedEffects(EntityQueryEnumerator<HologramProjectedComponent>()); | ||
| } | ||
|
|
||
| private void OnProjectedShutdown(EntityUid hologram, HologramProjectedComponent component, ComponentShutdown args) | ||
| { | ||
| DeleteEffect(component); | ||
|
|
||
| if (component.SetEyeTarget && TryComp<EyeComponent>(hologram, out var eyeComp)) | ||
| eyeComp.Target = null; // This should be fine? I guess if you're a hologram riding a vehicle when this happens it'd be a bit weird. | ||
| } | ||
|
|
||
| private void HandleProjectedEffects(EntityQueryEnumerator<HologramProjectedComponent> query) | ||
| { | ||
| while (query.MoveNext(out var hologram, out var holoProjectedComp)) | ||
| { | ||
| if (holoProjectedComp.EffectPrototype == null) | ||
| { | ||
| DeleteEffect(holoProjectedComp); | ||
| continue; | ||
| } | ||
|
|
||
| if (!holoProjectedComp.CurrentlyInProjector || holoProjectedComp.CurProjector == null || !Exists(holoProjectedComp.CurProjector.Value)) | ||
| { | ||
| DeleteEffect(holoProjectedComp); | ||
| continue; | ||
| } | ||
|
|
||
| var projector = holoProjectedComp.CurProjector.Value; | ||
|
|
||
| var holoXformComp = Transform(hologram); | ||
| var holoCoords = _transform.GetMoverCoordinates(hologram, holoXformComp); | ||
|
|
||
| var projXformComp = Transform(projector); | ||
| var projCoords = _transform.GetMoverCoordinates(projector, projXformComp); | ||
|
|
||
| if (holoCoords.EntityId != projCoords.EntityId) // ¯\_(ツ)_/¯ | ||
| { | ||
| DeleteEffect(holoProjectedComp); | ||
| continue; | ||
| } | ||
|
|
||
| var originPos = projCoords.Position; | ||
|
|
||
| // Add the effect's offset, if applicable. | ||
| if (TryComp<HologramProjectorComponent>(projector, out var projComp)) | ||
| { | ||
| var direction = projXformComp.LocalRotation.GetCardinalDir(); | ||
|
|
||
| var offset = direction switch | ||
| { | ||
| Direction.North => projComp.EffectOffsets[Direction.South], | ||
| Direction.South => projComp.EffectOffsets[Direction.North], | ||
| Direction.East => projComp.EffectOffsets[Direction.West], | ||
| Direction.West => projComp.EffectOffsets[Direction.East], | ||
| _ => Vector2.Zero | ||
| }; | ||
|
|
||
| originPos += offset; | ||
| } | ||
|
|
||
| // Determine a middle point between the hologram and the projector. | ||
| var effectPos = (holoCoords.Position + originPos) / 2; | ||
|
|
||
| // Determine a rotation that points from the projector to the hologram. | ||
| var effectRot = (holoCoords.Position - originPos).ToAngle() - MathHelper.PiOver2; | ||
|
|
||
| var effectCoords = new EntityCoordinates(holoCoords.EntityId, effectPos); | ||
| if (!effectCoords.IsValid(EntityManager)) | ||
| { | ||
| DeleteEffect(holoProjectedComp); | ||
| continue; | ||
| } | ||
|
|
||
| // Set or spawn the effect. | ||
| if (holoProjectedComp.EffectEntity == null || !Exists(holoProjectedComp.EffectEntity.Value)) | ||
| holoProjectedComp.EffectEntity = Spawn(holoProjectedComp.EffectPrototype, effectCoords); | ||
| else | ||
| _transform.SetLocalPosition(holoProjectedComp.EffectEntity.Value, effectPos); | ||
|
|
||
| _transform.SetLocalRotation(holoProjectedComp.EffectEntity.Value, effectRot); | ||
|
|
||
| // Determine the scaling factor to make it fit between the hologram and the projector. | ||
| var yScale = (holoCoords.Position - originPos).Length(); | ||
| var effectScale = new Vector2(1, Math.Max(0.1f, yScale)); // No smaller than 0.1. | ||
| Comp<SpriteComponent>(holoProjectedComp.EffectEntity.Value).Scale = effectScale; | ||
| } | ||
| } | ||
|
|
||
| private void DeleteEffect(HologramProjectedComponent component) | ||
| { | ||
| if (component.EffectEntity != null && Exists(component.EffectEntity.Value)) | ||
| QueueDel(component.EffectEntity.Value); | ||
|
|
||
| component.EffectEntity = null; | ||
| } | ||
| } | ||
This file was deleted.
Oops, something went wrong.
Oops, something went wrong.
Add this suggestion to a batch that can be applied as a single commit.
This suggestion is invalid because no changes were made to the code.
Suggestions cannot be applied while the pull request is closed.
Suggestions cannot be applied while viewing a subset of changes.
Only one suggestion per line can be applied in a batch.
Add this suggestion to a batch that can be applied as a single commit.
Applying suggestions on deleted lines is not supported.
You must change the existing code in this line in order to create a valid suggestion.
Outdated suggestions cannot be applied.
This suggestion has been applied or marked resolved.
Suggestions cannot be applied from pending reviews.
Suggestions cannot be applied on multi-line comments.
Suggestions cannot be applied while the pull request is queued to merge.
Suggestion cannot be applied right now. Please check back later.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.