-
Notifications
You must be signed in to change notification settings - Fork 190
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
<!-- This is a semi-strict format, you can add/remove sections as needed but the order/format should be kept the same Remove these comments before submitting --> # Description <!-- Explain this PR in as much detail as applicable Some example prompts to consider: How might this affect the game? The codebase? What might be some alternatives to this? How/Who does this benefit/hurt [the game/codebase]? --> Implements station AI and all relevant fixes/changes/features. --- # Changelog <!-- You can add an author after the `:cl:` to change the name that appears in the changelog (ex: `:cl: Death`) Leaving it blank will default to your GitHub display name This includes all available types for the changelog --> :cl: - add: Ported Station AI. - add: Saltern is now fitted with a Station AI
- Loading branch information
Showing
216 changed files
with
4,404 additions
and
1,735 deletions.
There are no files selected for viewing
This file was deleted.
Oops, something went wrong.
This file contains 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
This file contains 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
This file contains 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
This file contains 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
This file contains 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
This file contains 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
28 changes: 28 additions & 0 deletions
28
Content.Client/Silicons/StationAi/StationAiBoundUserInterface.cs
This file contains 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,28 @@ | ||
using Content.Shared.Silicons.StationAi; | ||
using Robust.Client.UserInterface; | ||
|
||
namespace Content.Client.Silicons.StationAi; | ||
|
||
public sealed class StationAiBoundUserInterface : BoundUserInterface | ||
{ | ||
private StationAiMenu? _menu; | ||
|
||
public StationAiBoundUserInterface(EntityUid owner, Enum uiKey) : base(owner, uiKey) | ||
{ | ||
} | ||
|
||
protected override void Open() | ||
{ | ||
base.Open(); | ||
_menu = this.CreateWindow<StationAiMenu>(); | ||
_menu.Track(Owner); | ||
|
||
_menu.OnAiRadial += args => | ||
{ | ||
SendPredictedMessage(new StationAiRadialMessage() | ||
{ | ||
Event = args, | ||
}); | ||
}; | ||
} | ||
} |
This file contains 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,13 @@ | ||
<ui:RadialMenu xmlns="https://spacestation14.io" | ||
xmlns:ui="clr-namespace:Content.Client.UserInterface.Controls" | ||
BackButtonStyleClass="RadialMenuBackButton" | ||
CloseButtonStyleClass="RadialMenuCloseButton" | ||
VerticalExpand="True" | ||
HorizontalExpand="True" | ||
MinSize="450 450"> | ||
|
||
<!-- Main --> | ||
<ui:RadialContainer Name="Main" VerticalExpand="True" HorizontalExpand="True" Radius="64" ReserveSpaceForHiddenChildren="False"> | ||
</ui:RadialContainer> | ||
|
||
</ui:RadialMenu> |
128 changes: 128 additions & 0 deletions
128
Content.Client/Silicons/StationAi/StationAiMenu.xaml.cs
This file contains 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,128 @@ | ||
using System.Numerics; | ||
using Content.Client.UserInterface.Controls; | ||
using Content.Shared.Silicons.StationAi; | ||
using Robust.Client.AutoGenerated; | ||
using Robust.Client.GameObjects; | ||
using Robust.Client.Graphics; | ||
using Robust.Client.UserInterface.Controls; | ||
using Robust.Client.UserInterface.XAML; | ||
using Robust.Shared.Timing; | ||
|
||
namespace Content.Client.Silicons.StationAi; | ||
|
||
[GenerateTypedNameReferences] | ||
public sealed partial class StationAiMenu : RadialMenu | ||
{ | ||
[Dependency] private readonly IClyde _clyde = default!; | ||
[Dependency] private readonly IEntityManager _entManager = default!; | ||
[Dependency] private readonly IEyeManager _eyeManager = default!; | ||
|
||
public event Action<BaseStationAiAction>? OnAiRadial; | ||
|
||
private EntityUid _tracked; | ||
|
||
public StationAiMenu() | ||
{ | ||
IoCManager.InjectDependencies(this); | ||
RobustXamlLoader.Load(this); | ||
} | ||
|
||
public void Track(EntityUid owner) | ||
{ | ||
_tracked = owner; | ||
|
||
if (!_entManager.EntityExists(_tracked)) | ||
{ | ||
Close(); | ||
return; | ||
} | ||
|
||
BuildButtons(); | ||
UpdatePosition(); | ||
} | ||
|
||
private void BuildButtons() | ||
{ | ||
var ev = new GetStationAiRadialEvent(); | ||
_entManager.EventBus.RaiseLocalEvent(_tracked, ref ev); | ||
|
||
var main = FindControl<RadialContainer>("Main"); | ||
main.DisposeAllChildren(); | ||
var sprites = _entManager.System<SpriteSystem>(); | ||
|
||
foreach (var action in ev.Actions) | ||
{ | ||
// TODO: This radial boilerplate is quite annoying | ||
var button = new StationAiMenuButton(action.Event) | ||
{ | ||
StyleClasses = { "RadialMenuButton" }, | ||
SetSize = new Vector2(64f, 64f), | ||
ToolTip = action.Tooltip != null ? Loc.GetString(action.Tooltip) : null, | ||
}; | ||
|
||
if (action.Sprite != null) | ||
{ | ||
var texture = sprites.Frame0(action.Sprite); | ||
var scale = Vector2.One; | ||
|
||
if (texture.Width <= 32) | ||
{ | ||
scale *= 2; | ||
} | ||
|
||
var tex = new TextureRect | ||
{ | ||
VerticalAlignment = VAlignment.Center, | ||
HorizontalAlignment = HAlignment.Center, | ||
Texture = texture, | ||
TextureScale = scale, | ||
}; | ||
|
||
button.AddChild(tex); | ||
} | ||
|
||
button.OnPressed += args => | ||
{ | ||
OnAiRadial?.Invoke(action.Event); | ||
Close(); | ||
}; | ||
main.AddChild(button); | ||
} | ||
} | ||
|
||
protected override void FrameUpdate(FrameEventArgs args) | ||
{ | ||
base.FrameUpdate(args); | ||
UpdatePosition(); | ||
} | ||
|
||
private void UpdatePosition() | ||
{ | ||
if (!_entManager.TryGetComponent(_tracked, out TransformComponent? xform)) | ||
{ | ||
Close(); | ||
return; | ||
} | ||
|
||
if (!xform.Coordinates.IsValid(_entManager)) | ||
{ | ||
Close(); | ||
return; | ||
} | ||
|
||
var coords = _entManager.System<SpriteSystem>().GetSpriteScreenCoordinates((_tracked, null, xform)); | ||
|
||
if (!coords.IsValid) | ||
{ | ||
Close(); | ||
return; | ||
} | ||
|
||
OpenScreenAt(coords.Position, _clyde); | ||
} | ||
} | ||
|
||
public sealed class StationAiMenuButton(BaseStationAiAction action) : RadialMenuTextureButton | ||
{ | ||
public BaseStationAiAction Action = action; | ||
} |
This file contains 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
30 changes: 30 additions & 0 deletions
30
Content.Client/Silicons/StationAi/StationAiSystem.Airlock.cs
This file contains 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,30 @@ | ||
using Content.Shared.Doors.Components; | ||
using Content.Shared.Silicons.StationAi; | ||
using Robust.Shared.Utility; | ||
|
||
namespace Content.Client.Silicons.StationAi; | ||
|
||
public sealed partial class StationAiSystem | ||
{ | ||
private void InitializeAirlock() | ||
{ | ||
SubscribeLocalEvent<DoorBoltComponent, GetStationAiRadialEvent>(OnDoorBoltGetRadial); | ||
} | ||
|
||
private void OnDoorBoltGetRadial(Entity<DoorBoltComponent> ent, ref GetStationAiRadialEvent args) | ||
{ | ||
args.Actions.Add(new StationAiRadial() | ||
{ | ||
Sprite = ent.Comp.BoltsDown ? | ||
new SpriteSpecifier.Rsi( | ||
new ResPath("/Textures/Structures/Doors/Airlocks/Standard/basic.rsi"), "open") : | ||
new SpriteSpecifier.Rsi( | ||
new ResPath("/Textures/Structures/Doors/Airlocks/Standard/basic.rsi"), "closed"), | ||
Tooltip = ent.Comp.BoltsDown ? Loc.GetString("bolt-open") : Loc.GetString("bolt-close"), | ||
Event = new StationAiBoltEvent() | ||
{ | ||
Bolted = !ent.Comp.BoltsDown, | ||
} | ||
}); | ||
} | ||
} |
Oops, something went wrong.