-
Notifications
You must be signed in to change notification settings - Fork 1
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
- Loading branch information
Showing
29 changed files
with
17,949 additions
and
3 deletions.
There are no files selected for viewing
5 changes: 5 additions & 0 deletions
5
Content.Client/_Emberfall/Planetside/Systems/SpaceElevatorConsoleSystem.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,5 @@ | ||
using Content.Shared._Emberfall.Planetside.Systems; | ||
|
||
namespace Content.Client._Emberfall.Planetside.Systems; | ||
|
||
public sealed class SpaceElevatorConsoleSystem : SharedSpaceElevatorConsoleSystem; |
5 changes: 5 additions & 0 deletions
5
Content.Client/_Emberfall/Planetside/Systems/SpaceElevatorSystem.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,5 @@ | ||
using Content.Shared._Emberfall.Planetside.Systems; | ||
|
||
namespace Content.Client._Emberfall.Planetside.Systems; | ||
|
||
public sealed class SpaceElevatorSystem : SharedSpaceElevatorSystem; |
37 changes: 37 additions & 0 deletions
37
Content.Client/_Emberfall/Planetside/UI/SpaceElevatorBoundUserInterface.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,37 @@ | ||
using Content.Shared._Emberfall.Planetside; | ||
|
||
namespace Content.Client._Emberfall.Planetside.UI; | ||
|
||
public sealed class SpaceElevatorBoundUserInterface(EntityUid owner, Enum uiKey) : BoundUserInterface(owner, uiKey) | ||
{ | ||
[ViewVariables] | ||
private SpaceElevatorConsoleWindow? _window; | ||
|
||
protected override void Open() | ||
{ | ||
base.Open(); | ||
|
||
_window = new SpaceElevatorConsoleWindow(Owner); | ||
_window.OpenCentered(); | ||
_window.OnClose += Close; | ||
_window.OnFTL += index => SendMessage(new DockingConsoleFTLMessage(index)); | ||
} | ||
|
||
protected override void UpdateState(BoundUserInterfaceState state) | ||
{ | ||
base.UpdateState(state); | ||
|
||
if (state is not SpaceElevatorConsoleState cast) | ||
return; | ||
|
||
_window?.UpdateState(cast); | ||
} | ||
|
||
protected override void Dispose(bool disposing) | ||
{ | ||
base.Dispose(disposing); | ||
|
||
if (disposing) | ||
_window?.Orphan(); | ||
} | ||
} |
68 changes: 68 additions & 0 deletions
68
Content.Client/_Emberfall/Planetside/UI/SpaceElevatorConsoleWindow.xaml
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,68 @@ | ||
<controls:FancyWindow xmlns="https://spacestation14.io" | ||
xmlns:x="http://schemas.microsoft.com/winfx/2006/xaml" | ||
xmlns:controls="clr-namespace:Content.Client.UserInterface.Controls" | ||
xmlns:gfx="clr-namespace:Robust.Client.Graphics;assembly=Robust.Client" | ||
Title="{Loc 'space-elevator-console-title'}" | ||
MinSize="400 500"> | ||
<BoxContainer Orientation="Vertical" Margin="5 5 5 5"> | ||
<!-- Status header --> | ||
<controls:StripeBack MinSize="48 48"> | ||
<BoxContainer Orientation="Horizontal" HorizontalExpand="True" Margin="8 0"> | ||
<BoxContainer Orientation="Vertical" HorizontalExpand="True"> | ||
<Label Text="{Loc 'space-elevator-status-label'}" StyleClasses="LabelHeading"/> | ||
<Label Name="MapFTLState" StyleClasses="LabelSubText"/> | ||
</BoxContainer> | ||
<PanelContainer StyleClasses="Inset" VerticalAlignment="Center"> | ||
<ProgressBar Name="FTLBar" | ||
MinValue="0.0" | ||
MaxValue="1.0" | ||
Value="1.0" | ||
MinSize="100 20"/> | ||
</PanelContainer> | ||
</BoxContainer> | ||
</controls:StripeBack> | ||
|
||
<!-- Destinations panel --> | ||
<PanelContainer StyleClasses="AngleRect" VerticalExpand="True" Margin="0 5 0 5"> | ||
<BoxContainer Orientation="Vertical"> | ||
<controls:StripeBack> | ||
<Label Text="{Loc 'space-elevator-destinations-label'}" | ||
StyleClasses="LabelHeading" | ||
Margin="8 0"/> | ||
</controls:StripeBack> | ||
<ScrollContainer VerticalExpand="True" HorizontalExpand="True" Margin="1"> | ||
<PanelContainer VerticalExpand="True"> | ||
<PanelContainer.PanelOverride> | ||
<gfx:StyleBoxFlat BackgroundColor="#1B1B1E"/> | ||
</PanelContainer.PanelOverride> | ||
<ItemList Name="Destinations" | ||
VerticalExpand="True" | ||
HorizontalExpand="True" | ||
SelectMode="Single" | ||
Margin="2"/> | ||
</PanelContainer> | ||
</ScrollContainer> | ||
</BoxContainer> | ||
</PanelContainer> | ||
|
||
<!-- Control panel --> | ||
<PanelContainer StyleClasses="AngleRect"> | ||
<BoxContainer Orientation="Vertical"> | ||
<controls:StripeBack> | ||
<Label Text="{Loc 'space-elevator-controls-label'}" | ||
StyleClasses="LabelHeading" | ||
Margin="8 0"/> | ||
</controls:StripeBack> | ||
<BoxContainer Orientation="Horizontal" | ||
HorizontalAlignment="Center" | ||
Margin="8"> | ||
<Button Name="FTLButton" | ||
Text="{Loc 'space-elevator-ftl'}" | ||
TextAlign="Center" | ||
MinSize="200 38" | ||
Disabled="True"/> | ||
</BoxContainer> | ||
</BoxContainer> | ||
</PanelContainer> | ||
</BoxContainer> | ||
</controls:FancyWindow> |
125 changes: 125 additions & 0 deletions
125
Content.Client/_Emberfall/Planetside/UI/SpaceElevatorConsoleWindow.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,125 @@ | ||
using Content.Client.UserInterface.Controls; | ||
using Content.Shared._Emberfall.Planetside; | ||
using Content.Shared._Emberfall.Planetside.Components; | ||
using Content.Shared.Shuttles.Systems; | ||
using Content.Shared.Timing; | ||
using Robust.Client.AutoGenerated; | ||
using Robust.Client.Graphics; | ||
using Robust.Client.UserInterface.XAML; | ||
using Robust.Shared.Timing; | ||
|
||
namespace Content.Client._Emberfall.Planetside.UI; | ||
|
||
[GenerateTypedNameReferences] | ||
public sealed partial class SpaceElevatorConsoleWindow : FancyWindow | ||
{ | ||
[Dependency] private readonly IEntityManager _entMan = default!; | ||
[Dependency] private readonly IGameTiming _timing = default!; | ||
|
||
public event Action<int>? OnFTL; | ||
|
||
private readonly Dictionary<FTLState, (string Color, string Loc)> _stateData = new() | ||
{ | ||
{ FTLState.Available, ("#80C71F", "shuttle-console-ftl-state-Available") }, | ||
{ FTLState.Starting, ("#169C9C", "shuttle-console-ftl-state-Starting") }, | ||
{ FTLState.Travelling, ("#8932B8", "shuttle-console-ftl-state-Travelling") }, | ||
{ FTLState.Arriving, ("#F9801D", "shuttle-console-ftl-state-Arriving") }, | ||
}; | ||
|
||
private readonly StyleBoxFlat _ftlStyle; | ||
private FTLState _state; | ||
private int? _selected; | ||
private StartEndTime _ftlTime; | ||
|
||
public SpaceElevatorConsoleWindow(EntityUid owner) | ||
{ | ||
RobustXamlLoader.Load(this); | ||
IoCManager.InjectDependencies(this); | ||
|
||
_ftlStyle = new StyleBoxFlat() | ||
{ | ||
BackgroundColor = Color.FromHex("#80C71F"), | ||
ContentMarginLeftOverride = 4, | ||
ContentMarginRightOverride = 4 | ||
}; | ||
FTLBar.ForegroundStyleBoxOverride = _ftlStyle; | ||
|
||
if (!_entMan.TryGetComponent<SpaceElevatorConsoleComponent>(owner, out var comp)) | ||
return; | ||
|
||
if (!comp.HasPlatform) | ||
{ | ||
MapFTLState.Text = Loc.GetString("docking-console-no-shuttle"); | ||
_ftlStyle.BackgroundColor = Color.FromHex("#B02E26"); | ||
} | ||
|
||
SetupEventHandlers(); | ||
} | ||
|
||
private void SetupEventHandlers() | ||
{ | ||
Destinations.OnItemSelected += args => | ||
{ | ||
_selected = args.ItemIndex; | ||
UpdateButton(); | ||
}; | ||
|
||
Destinations.OnItemDeselected += _ => | ||
{ | ||
_selected = null; | ||
UpdateButton(); | ||
}; | ||
|
||
FTLButton.OnPressed += _ => | ||
{ | ||
if (_selected is { } index) | ||
{ | ||
OnFTL?.Invoke(index); | ||
FTLButton.Disabled = true; | ||
} | ||
}; | ||
} | ||
|
||
public void UpdateState(SpaceElevatorConsoleState state) | ||
{ | ||
_state = state.FTLState; | ||
_ftlTime = state.FTLTime; | ||
|
||
var (color, locString) = _stateData.GetValueOrDefault(_state, | ||
("#B02E26", "shuttle-console-ftl-state-Cooldown")); | ||
|
||
MapFTLState.Text = Loc.GetString(locString); | ||
_ftlStyle.BackgroundColor = Color.FromHex(color); | ||
|
||
if (Destinations.Count != state.Destinations.Count) | ||
{ | ||
UpdateDestinations(state.Destinations); | ||
} | ||
|
||
UpdateButton(); | ||
} | ||
|
||
private void UpdateDestinations(List<ElevatorDestination> destinations) | ||
{ | ||
Destinations.Clear(); | ||
foreach (var dest in destinations) | ||
{ | ||
Destinations.AddItem(dest.Name); | ||
} | ||
} | ||
|
||
protected override void FrameUpdate(FrameEventArgs args) | ||
{ | ||
base.FrameUpdate(args); | ||
|
||
var progress = _ftlTime.ProgressAt(_timing.CurTime); | ||
FTLBar.Value = float.IsFinite(progress) ? progress : 1; | ||
|
||
UpdateButton(); | ||
} | ||
|
||
private void UpdateButton() | ||
{ | ||
FTLButton.Disabled = _selected == null || _state != FTLState.Available; | ||
} | ||
} |
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
31 changes: 31 additions & 0 deletions
31
Content.Server/_Emberfall/Planetside/Components/PlanetsideTerrainSpawnerComponent.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,31 @@ | ||
using Content.Server._Emberfall.Planetside.Systems; | ||
using Content.Shared._Emberfall.Planetside; | ||
using Robust.Shared.Prototypes; | ||
using Robust.Shared.Utility; | ||
|
||
namespace Content.Server._Emberfall.Planetside.Components; | ||
|
||
/// <summary> | ||
/// This is used to load a map and then spawn a grid on it. | ||
/// </summary> | ||
[RegisterComponent, Access(typeof(PlanetsideTerrainSpawnerSystem))] | ||
public sealed partial class PlanetsideTerrainSpawnerComponent : Component | ||
{ | ||
/// <summary> | ||
/// The terrain template to use. | ||
/// </summary> | ||
[DataField(required: true)] | ||
public ProtoId<TerrainTemplatePrototype> Terrain; | ||
|
||
/// <summary> | ||
/// The grid to load when spawning the map. | ||
/// </summary> | ||
[DataField] | ||
public ResPath? GridPath; | ||
|
||
/// <summary> | ||
/// The loaded map entity. | ||
/// </summary> | ||
[DataField] | ||
public EntityUid? Map; | ||
} |
36 changes: 36 additions & 0 deletions
36
Content.Server/_Emberfall/Planetside/Systems/PlanetsideTerrainSpawnerSystem.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,36 @@ | ||
using Content.Server._Emberfall.Planetside.Components; | ||
|
||
namespace Content.Server._Emberfall.Planetside.Systems; | ||
|
||
/// <summary> | ||
/// This handles spawning a new map from a TerrainTemplatePrototype. | ||
/// <seealso cref="PlanetsideTerrainSystem"/> | ||
/// </summary> | ||
public sealed class PlanetsideTerrainSpawnerSystem : EntitySystem | ||
{ | ||
[Dependency] private readonly PlanetsideTerrainSystem _planetside = default!; | ||
|
||
public override void Initialize() | ||
{ | ||
base.Initialize(); | ||
|
||
SubscribeLocalEvent<PlanetsideTerrainSpawnerComponent, ComponentShutdown>(OnShutdown); | ||
SubscribeLocalEvent<PlanetsideTerrainSpawnerComponent, MapInitEvent>(OnMapInit); | ||
} | ||
|
||
private void OnShutdown(Entity<PlanetsideTerrainSpawnerComponent> ent, ref ComponentShutdown args) | ||
{ | ||
QueueDel(ent.Comp.Map); | ||
} | ||
|
||
private void OnMapInit(Entity<PlanetsideTerrainSpawnerComponent> ent, ref MapInitEvent args) | ||
{ | ||
if (ent.Comp.GridPath is { } path) | ||
{ | ||
ent.Comp.Map = _planetside.GenerateTerrainWithStructures(ent.Comp.Terrain, path.ToString()); | ||
return; | ||
} | ||
|
||
ent.Comp.Map = _planetside.GenerateTerrain(ent.Comp.Terrain); | ||
} | ||
} |
Oops, something went wrong.