Skip to content

Commit

Permalink
Merge pull request #45 from ss14Starlight/sl-abductor
Browse files Browse the repository at this point in the history
Revamp Abductor System and Add New Organ Functionality
  • Loading branch information
darkrell authored Nov 11, 2024
2 parents 2e0ab3a + ce90d76 commit ac8638c
Show file tree
Hide file tree
Showing 93 changed files with 3,249 additions and 718 deletions.
Original file line number Diff line number Diff line change
@@ -1,27 +1,12 @@
using Content.Client._Starlight;
using Content.Client._Starlight;
using Content.Client._Starlight.Medical.Surgery;
using Content.Client.Administration.UI.CustomControls;
using Content.Client.Hands.Systems;
using Content.Shared.Starlight.Antags.Abductor;
using Content.Shared.Starlight.Medical.Surgery;
using Content.Shared.Body.Part;
using Content.Shared.Starlight.Antags.Abductor;
using JetBrains.Annotations;
using Robust.Client.GameObjects;
using Robust.Client.Graphics;
using Robust.Client.Player;
using Robust.Shared.Prototypes;
using Robust.Shared.Utility;
using static Content.Shared.Pinpointer.SharedNavMapSystem;
using static Robust.Client.UserInterface.Control;

namespace Content.Client._Starlight.Antags.Abductor;

[UsedImplicitly]
public sealed class AbductorCameraConsoleBui : BoundUserInterface
{
[Dependency] private readonly IEntityManager _entities = default!;

[ViewVariables]
private AbductorCameraConsoleWindow? _window;
private int? _station;
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -7,7 +7,7 @@
<BoxContainer Orientation="Horizontal" HorizontalExpand="True" Margin="0 0 0 10">
<Button Name="StationsButton" Access="Public" Text="&lt; Stations"
HorizontalExpand="True" StyleClasses="OpenBoth" />
<Button Name="BeaconsButton" Access="Public" Text="Beacons"
<Button Name="BeaconsButton" Access="Public" Text="{Loc 'abductors-ui-beacons'}"
HorizontalExpand="True" StyleClasses="OpenBoth" />
</BoxContainer>
<cc:HSeparator Color="#A04B81" />
Expand Down
118 changes: 118 additions & 0 deletions Content.Client/_Starlight/Antags/Abductor/AbductorConsoleBui.cs
Original file line number Diff line number Diff line change
@@ -0,0 +1,118 @@
using Content.Shared.Starlight.Antags.Abductor;
using JetBrains.Annotations;
using Robust.Client.UserInterface.Controls;
using Robust.Client.UserInterface.RichText;
using Robust.Shared.Utility;
using static Content.Shared.Pinpointer.SharedNavMapSystem;

namespace Content.Client._Starlight.Antags.Abductor;

[UsedImplicitly]
public sealed class AbductorConsoleBui : BoundUserInterface
{
[Dependency] private readonly IEntityManager _entities = default!;

[ViewVariables]
private AbductorConsoleWindow? _window;
public AbductorConsoleBui(EntityUid owner, Enum uiKey) : base(owner, uiKey)
{

}
protected override void Open() => UpdateState(State);
protected override void UpdateState(BoundUserInterfaceState? state)
{
if (state is AbductorConsoleBuiState s)
Update(s);
}

private void Update(AbductorConsoleBuiState state)
{
TryInitWindow();

View(ViewType.Teleport);

RefreshUI();

if (!_window!.IsOpen)
_window.OpenCentered();
}

private void TryInitWindow()
{
if (_window != null) return;
_window = new AbductorConsoleWindow();
_window.OnClose += Close;
_window.Title = "console";

_window.TeleportTabButton.OnPressed += _ => View(ViewType.Teleport);

_window.ExperimentTabButton.OnPressed += _ => View(ViewType.Experiment);
}

private void RefreshUI()
{
if (_window == null || State is not AbductorConsoleBuiState state)
return;

// teleportTab
_window.TargetLabel.Children.Clear();

var padMsg = new FormattedMessage();
padMsg.AddMarkupOrThrow(state.AlienPadFound ? "pad: [color=green]connected[/color]" : "pad: [color=red]not found[/color]");
_window.PadLabel.SetMessage(padMsg);

var msg = new FormattedMessage();
msg.AddMarkupOrThrow(state.Target == null ? "target: [color=red]NONE[/color]" : $"target: [color=green]{state.TargetName}[/color]");
_window.TeleportButton.Disabled = state.Target == null || !state.AlienPadFound;
_window.TeleportButton.OnPressed += _ =>
{
SendMessage(new AbductorAttractBuiMsg());
Close();
};
_window.TargetLabel.SetMessage(msg, new Type[1] { typeof(ColorTag) });

// experiment tab

var experimentatorMsg = new FormattedMessage();
experimentatorMsg.AddMarkupOrThrow(state.AlienPadFound ? "experimentator: [color=green]connected[/color]" : "experimentator: [color=red]not found[/color]");
_window.ExperimentatorLabel.SetMessage(experimentatorMsg);

var victimMsg = new FormattedMessage();
victimMsg.AddMarkupOrThrow(state.VictimName == null ? "victim: [color=red]NONE[/color]" : $"victim: [color=green]{state.VictimName}[/color]");
_window.VictimLabel.SetMessage(victimMsg);

_window.CompleteExperimentButton.Disabled = state.VictimName == null;
_window.CompleteExperimentButton.OnPressed += _ =>
{
SendMessage(new AbductorCompleteExperimentBuiMsg());
Close();
};
}

private void View(ViewType type)
{
if (_window == null)
return;

_window.TeleportTabButton.Parent!.Margin = new Thickness(0, 0, 0, 10);

_window.TeleportTabButton.Disabled = type == ViewType.Teleport;
_window.ExperimentTabButton.Disabled = type == ViewType.Experiment;
_window.TeleportTab.Visible = type == ViewType.Teleport;
_window.ExperimentTab.Visible = type == ViewType.Experiment;
}

private enum ViewType
{
Teleport,
Experiment
}

protected override void Dispose(bool disposing)
{
base.Dispose(disposing);

if (disposing)
_window?.Dispose();
}
}
Original file line number Diff line number Diff line change
@@ -0,0 +1,26 @@
<controls:AbductorConsoleWindow
xmlns="https://spacestation14.io"
xmlns:controls="clr-namespace:Content.Client._Starlight.Antags.Abductor"
xmlns:cc="clr-namespace:Content.Client.Administration.UI.CustomControls"
MinSize="400 400">
<BoxContainer Orientation="Vertical" HorizontalExpand="True" VerticalExpand="True">
<BoxContainer Orientation="Horizontal" HorizontalExpand="True" Margin="0 0 0 10">
<Button Name="TeleportTabButton" Access="Public" Text="{Loc 'abductors-ui-teleport'}" HorizontalExpand="True" StyleClasses="OpenBoth" />
<Button Name="ExperimentTabButton" Access="Public" Text="{Loc 'abductors-ui-experiment'}" HorizontalExpand="True" StyleClasses="OpenBoth" />
</BoxContainer>
<cc:HSeparator Color="#A04B81" />
<ScrollContainer VScrollEnabled="True" HorizontalExpand="True" VerticalExpand="True">
<BoxContainer Name="TeleportTab" Access="Public" Orientation="Vertical" Visible="False">
<RichTextLabel Name="PadLabel" Access="Public"/>
<RichTextLabel Name="TargetLabel" Access="Public" />
<Button Name="TeleportButton" Access="Public" Text="{Loc 'abductors-ui-attract'}" HorizontalExpand="True" StyleClasses="OpenBoth" />
</BoxContainer>
<BoxContainer Name="ExperimentTab" Access="Public" Orientation="Vertical" Visible="False">
<RichTextLabel Name="ExperimentLabel" Access="Public"/>
<RichTextLabel Name="ExperimentatorLabel" Access="Public"/>
<RichTextLabel Name="VictimLabel" Access="Public"/>
<Button Name="CompleteExperimentButton" Access="Public" Text="{Loc 'abductors-ui-complete-experiment'}" HorizontalExpand="True" StyleClasses="OpenBoth" />
</BoxContainer>
</ScrollContainer>
</BoxContainer>
</controls:AbductorConsoleWindow>
Original file line number Diff line number Diff line change
@@ -0,0 +1,10 @@
using Robust.Client.AutoGenerated;
using Robust.Client.UserInterface.CustomControls;
using Robust.Client.UserInterface.XAML;

namespace Content.Client._Starlight.Antags.Abductor;
[GenerateTypedNameReferences]
public sealed partial class AbductorConsoleWindow : DefaultWindow
{
public AbductorConsoleWindow() => RobustXamlLoader.Load(this);
}
11 changes: 11 additions & 0 deletions Content.Client/_Starlight/Antags/Abductor/AbductorSystem.cs
Original file line number Diff line number Diff line change
@@ -0,0 +1,11 @@
using Content.Shared.Starlight.Antags.Abductor;

namespace Content.Client._Starlight.Antags.Abductor;

public sealed class AbductorSystem : SharedAbductorSystem
{
public override void Initialize()
{
base.Initialize();
}
}
7 changes: 0 additions & 7 deletions Content.Client/_Starlight/TextToSpeech/TTSSystem.cs
Original file line number Diff line number Diff line change
@@ -1,17 +1,13 @@
using System.Collections.Concurrent;
using System.IO;
using System.Linq;
using Content.Shared.Starlight;
using Content.Shared.Starlight.CCVar;
using Content.Shared.Starlight.TextToSpeech;
using Robust.Client.Audio;
using Robust.Client.ResourceManagement;
using Robust.Shared.Audio;
using Robust.Shared.Audio.Components;
using Robust.Shared.Audio.Systems;
using Robust.Shared.Configuration;
using Robust.Shared.ContentPack;
using Robust.Shared.Utility;

namespace Content.Client._Starlight.TTS;

Expand All @@ -21,11 +17,8 @@ namespace Content.Client._Starlight.TTS;
public sealed class TextToSpeechSystem : EntitySystem
{
[Dependency] private readonly IConfigurationManager _cfg = default!;
[Dependency] private readonly IResourceManager _res = default!;
[Dependency] private readonly AudioSystem _audio = default!;
[Dependency] private readonly SharedAudioSystem _sharedAudio = default!;
[Dependency] private readonly IResourceCache _resourceCache = default!;
[Dependency] private readonly IDependencyCollection _dependencyCollection = default!;
[Dependency] private readonly IAudioManager _audioManager = default!;

private readonly ConcurrentQueue<(byte[] file, SoundSpecifier? specifier)> _ttsQueue = [];
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -31,7 +31,6 @@ private void OnSelectEntity(Entity<AntagLoadProfileRuleComponent> ent, ref Antag
? _prefs.GetPreferences(args.Session.UserId).SelectedCharacter as HumanoidCharacterProfile
: HumanoidCharacterProfile.RandomWithSpecies();


if (profile?.Species is not { } speciesId || !_proto.TryIndex(speciesId, out var species))
{
species = _proto.Index<SpeciesPrototype>(SharedHumanoidAppearanceSystem.DefaultSpecies);
Expand All @@ -43,6 +42,9 @@ private void OnSelectEntity(Entity<AntagLoadProfileRuleComponent> ent, ref Antag
species = _proto.Index(ent.Comp.SpeciesOverride.Value);
}

if(ent.Comp.SpeciesHardOverride is not null)
species = _proto.Index(ent.Comp.SpeciesHardOverride.Value);

args.Entity = Spawn(species.Prototype);
_humanoid.LoadProfile(args.Entity.Value, profile?.WithSpecies(species.ID));
}
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -15,6 +15,9 @@ public sealed partial class AntagLoadProfileRuleComponent : Component
[DataField]
public ProtoId<SpeciesPrototype>? SpeciesOverride;

[DataField]
public ProtoId<SpeciesPrototype>? SpeciesHardOverride;

/// <summary>
/// List of species that trigger the override
/// </summary>
Expand Down
Loading

0 comments on commit ac8638c

Please sign in to comment.