Skip to content

Commit 75c2f55

Browse files
committed
sort of works
1 parent 1edfde7 commit 75c2f55

29 files changed

+17949
-3
lines changed
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,5 @@
1+
using Content.Shared._Emberfall.Planetside.Systems;
2+
3+
namespace Content.Client._Emberfall.Planetside.Systems;
4+
5+
public sealed class SpaceElevatorConsoleSystem : SharedSpaceElevatorConsoleSystem;
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,5 @@
1+
using Content.Shared._Emberfall.Planetside.Systems;
2+
3+
namespace Content.Client._Emberfall.Planetside.Systems;
4+
5+
public sealed class SpaceElevatorSystem : SharedSpaceElevatorSystem;
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,37 @@
1+
using Content.Shared._Emberfall.Planetside;
2+
3+
namespace Content.Client._Emberfall.Planetside.UI;
4+
5+
public sealed class SpaceElevatorBoundUserInterface(EntityUid owner, Enum uiKey) : BoundUserInterface(owner, uiKey)
6+
{
7+
[ViewVariables]
8+
private SpaceElevatorConsoleWindow? _window;
9+
10+
protected override void Open()
11+
{
12+
base.Open();
13+
14+
_window = new SpaceElevatorConsoleWindow(Owner);
15+
_window.OpenCentered();
16+
_window.OnClose += Close;
17+
_window.OnFTL += index => SendMessage(new DockingConsoleFTLMessage(index));
18+
}
19+
20+
protected override void UpdateState(BoundUserInterfaceState state)
21+
{
22+
base.UpdateState(state);
23+
24+
if (state is not SpaceElevatorConsoleState cast)
25+
return;
26+
27+
_window?.UpdateState(cast);
28+
}
29+
30+
protected override void Dispose(bool disposing)
31+
{
32+
base.Dispose(disposing);
33+
34+
if (disposing)
35+
_window?.Orphan();
36+
}
37+
}
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,68 @@
1+
<controls:FancyWindow xmlns="https://spacestation14.io"
2+
xmlns:x="http://schemas.microsoft.com/winfx/2006/xaml"
3+
xmlns:controls="clr-namespace:Content.Client.UserInterface.Controls"
4+
xmlns:gfx="clr-namespace:Robust.Client.Graphics;assembly=Robust.Client"
5+
Title="{Loc 'space-elevator-console-title'}"
6+
MinSize="400 500">
7+
<BoxContainer Orientation="Vertical" Margin="5 5 5 5">
8+
<!-- Status header -->
9+
<controls:StripeBack MinSize="48 48">
10+
<BoxContainer Orientation="Horizontal" HorizontalExpand="True" Margin="8 0">
11+
<BoxContainer Orientation="Vertical" HorizontalExpand="True">
12+
<Label Text="{Loc 'space-elevator-status-label'}" StyleClasses="LabelHeading"/>
13+
<Label Name="MapFTLState" StyleClasses="LabelSubText"/>
14+
</BoxContainer>
15+
<PanelContainer StyleClasses="Inset" VerticalAlignment="Center">
16+
<ProgressBar Name="FTLBar"
17+
MinValue="0.0"
18+
MaxValue="1.0"
19+
Value="1.0"
20+
MinSize="100 20"/>
21+
</PanelContainer>
22+
</BoxContainer>
23+
</controls:StripeBack>
24+
25+
<!-- Destinations panel -->
26+
<PanelContainer StyleClasses="AngleRect" VerticalExpand="True" Margin="0 5 0 5">
27+
<BoxContainer Orientation="Vertical">
28+
<controls:StripeBack>
29+
<Label Text="{Loc 'space-elevator-destinations-label'}"
30+
StyleClasses="LabelHeading"
31+
Margin="8 0"/>
32+
</controls:StripeBack>
33+
<ScrollContainer VerticalExpand="True" HorizontalExpand="True" Margin="1">
34+
<PanelContainer VerticalExpand="True">
35+
<PanelContainer.PanelOverride>
36+
<gfx:StyleBoxFlat BackgroundColor="#1B1B1E"/>
37+
</PanelContainer.PanelOverride>
38+
<ItemList Name="Destinations"
39+
VerticalExpand="True"
40+
HorizontalExpand="True"
41+
SelectMode="Single"
42+
Margin="2"/>
43+
</PanelContainer>
44+
</ScrollContainer>
45+
</BoxContainer>
46+
</PanelContainer>
47+
48+
<!-- Control panel -->
49+
<PanelContainer StyleClasses="AngleRect">
50+
<BoxContainer Orientation="Vertical">
51+
<controls:StripeBack>
52+
<Label Text="{Loc 'space-elevator-controls-label'}"
53+
StyleClasses="LabelHeading"
54+
Margin="8 0"/>
55+
</controls:StripeBack>
56+
<BoxContainer Orientation="Horizontal"
57+
HorizontalAlignment="Center"
58+
Margin="8">
59+
<Button Name="FTLButton"
60+
Text="{Loc 'space-elevator-ftl'}"
61+
TextAlign="Center"
62+
MinSize="200 38"
63+
Disabled="True"/>
64+
</BoxContainer>
65+
</BoxContainer>
66+
</PanelContainer>
67+
</BoxContainer>
68+
</controls:FancyWindow>
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,125 @@
1+
using Content.Client.UserInterface.Controls;
2+
using Content.Shared._Emberfall.Planetside;
3+
using Content.Shared._Emberfall.Planetside.Components;
4+
using Content.Shared.Shuttles.Systems;
5+
using Content.Shared.Timing;
6+
using Robust.Client.AutoGenerated;
7+
using Robust.Client.Graphics;
8+
using Robust.Client.UserInterface.XAML;
9+
using Robust.Shared.Timing;
10+
11+
namespace Content.Client._Emberfall.Planetside.UI;
12+
13+
[GenerateTypedNameReferences]
14+
public sealed partial class SpaceElevatorConsoleWindow : FancyWindow
15+
{
16+
[Dependency] private readonly IEntityManager _entMan = default!;
17+
[Dependency] private readonly IGameTiming _timing = default!;
18+
19+
public event Action<int>? OnFTL;
20+
21+
private readonly Dictionary<FTLState, (string Color, string Loc)> _stateData = new()
22+
{
23+
{ FTLState.Available, ("#80C71F", "shuttle-console-ftl-state-Available") },
24+
{ FTLState.Starting, ("#169C9C", "shuttle-console-ftl-state-Starting") },
25+
{ FTLState.Travelling, ("#8932B8", "shuttle-console-ftl-state-Travelling") },
26+
{ FTLState.Arriving, ("#F9801D", "shuttle-console-ftl-state-Arriving") },
27+
};
28+
29+
private readonly StyleBoxFlat _ftlStyle;
30+
private FTLState _state;
31+
private int? _selected;
32+
private StartEndTime _ftlTime;
33+
34+
public SpaceElevatorConsoleWindow(EntityUid owner)
35+
{
36+
RobustXamlLoader.Load(this);
37+
IoCManager.InjectDependencies(this);
38+
39+
_ftlStyle = new StyleBoxFlat()
40+
{
41+
BackgroundColor = Color.FromHex("#80C71F"),
42+
ContentMarginLeftOverride = 4,
43+
ContentMarginRightOverride = 4
44+
};
45+
FTLBar.ForegroundStyleBoxOverride = _ftlStyle;
46+
47+
if (!_entMan.TryGetComponent<SpaceElevatorConsoleComponent>(owner, out var comp))
48+
return;
49+
50+
if (!comp.HasPlatform)
51+
{
52+
MapFTLState.Text = Loc.GetString("docking-console-no-shuttle");
53+
_ftlStyle.BackgroundColor = Color.FromHex("#B02E26");
54+
}
55+
56+
SetupEventHandlers();
57+
}
58+
59+
private void SetupEventHandlers()
60+
{
61+
Destinations.OnItemSelected += args =>
62+
{
63+
_selected = args.ItemIndex;
64+
UpdateButton();
65+
};
66+
67+
Destinations.OnItemDeselected += _ =>
68+
{
69+
_selected = null;
70+
UpdateButton();
71+
};
72+
73+
FTLButton.OnPressed += _ =>
74+
{
75+
if (_selected is { } index)
76+
{
77+
OnFTL?.Invoke(index);
78+
FTLButton.Disabled = true;
79+
}
80+
};
81+
}
82+
83+
public void UpdateState(SpaceElevatorConsoleState state)
84+
{
85+
_state = state.FTLState;
86+
_ftlTime = state.FTLTime;
87+
88+
var (color, locString) = _stateData.GetValueOrDefault(_state,
89+
("#B02E26", "shuttle-console-ftl-state-Cooldown"));
90+
91+
MapFTLState.Text = Loc.GetString(locString);
92+
_ftlStyle.BackgroundColor = Color.FromHex(color);
93+
94+
if (Destinations.Count != state.Destinations.Count)
95+
{
96+
UpdateDestinations(state.Destinations);
97+
}
98+
99+
UpdateButton();
100+
}
101+
102+
private void UpdateDestinations(List<ElevatorDestination> destinations)
103+
{
104+
Destinations.Clear();
105+
foreach (var dest in destinations)
106+
{
107+
Destinations.AddItem(dest.Name);
108+
}
109+
}
110+
111+
protected override void FrameUpdate(FrameEventArgs args)
112+
{
113+
base.FrameUpdate(args);
114+
115+
var progress = _ftlTime.ProgressAt(_timing.CurTime);
116+
FTLBar.Value = float.IsFinite(progress) ? progress : 1;
117+
118+
UpdateButton();
119+
}
120+
121+
private void UpdateButton()
122+
{
123+
FTLButton.Disabled = _selected == null || _state != FTLState.Available;
124+
}
125+
}

Diff for: Content.Server/Shuttles/Systems/ArrivalsSystem.cs

+3-3
Original file line numberDiff line numberDiff line change
@@ -83,8 +83,8 @@ public sealed class ArrivalsSystem : EntitySystem
8383

8484
private readonly List<ProtoId<BiomeTemplatePrototype>> _arrivalsBiomeOptions = new()
8585
{
86-
"Grasslands",
87-
"LowDesert",
86+
// "Grasslands", // Emberfall
87+
// "LowDesert", // Emberfall
8888
"Snow",
8989
};
9090

@@ -534,7 +534,7 @@ private void SetupArrivalsStation()
534534
_biomes.EnsurePlanet(mapUid, _protoManager.Index(template));
535535
var restricted = new RestrictedRangeComponent
536536
{
537-
Range = 32f
537+
Range = 64f // Emberfall, was 32
538538
};
539539
AddComp(mapUid, restricted);
540540
}
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,31 @@
1+
using Content.Server._Emberfall.Planetside.Systems;
2+
using Content.Shared._Emberfall.Planetside;
3+
using Robust.Shared.Prototypes;
4+
using Robust.Shared.Utility;
5+
6+
namespace Content.Server._Emberfall.Planetside.Components;
7+
8+
/// <summary>
9+
/// This is used to load a map and then spawn a grid on it.
10+
/// </summary>
11+
[RegisterComponent, Access(typeof(PlanetsideTerrainSpawnerSystem))]
12+
public sealed partial class PlanetsideTerrainSpawnerComponent : Component
13+
{
14+
/// <summary>
15+
/// The terrain template to use.
16+
/// </summary>
17+
[DataField(required: true)]
18+
public ProtoId<TerrainTemplatePrototype> Terrain;
19+
20+
/// <summary>
21+
/// The grid to load when spawning the map.
22+
/// </summary>
23+
[DataField]
24+
public ResPath? GridPath;
25+
26+
/// <summary>
27+
/// The loaded map entity.
28+
/// </summary>
29+
[DataField]
30+
public EntityUid? Map;
31+
}
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,36 @@
1+
using Content.Server._Emberfall.Planetside.Components;
2+
3+
namespace Content.Server._Emberfall.Planetside.Systems;
4+
5+
/// <summary>
6+
/// This handles spawning a new map from a TerrainTemplatePrototype.
7+
/// <seealso cref="PlanetsideTerrainSystem"/>
8+
/// </summary>
9+
public sealed class PlanetsideTerrainSpawnerSystem : EntitySystem
10+
{
11+
[Dependency] private readonly PlanetsideTerrainSystem _planetside = default!;
12+
13+
public override void Initialize()
14+
{
15+
base.Initialize();
16+
17+
SubscribeLocalEvent<PlanetsideTerrainSpawnerComponent, ComponentShutdown>(OnShutdown);
18+
SubscribeLocalEvent<PlanetsideTerrainSpawnerComponent, MapInitEvent>(OnMapInit);
19+
}
20+
21+
private void OnShutdown(Entity<PlanetsideTerrainSpawnerComponent> ent, ref ComponentShutdown args)
22+
{
23+
QueueDel(ent.Comp.Map);
24+
}
25+
26+
private void OnMapInit(Entity<PlanetsideTerrainSpawnerComponent> ent, ref MapInitEvent args)
27+
{
28+
if (ent.Comp.GridPath is { } path)
29+
{
30+
ent.Comp.Map = _planetside.GenerateTerrainWithStructures(ent.Comp.Terrain, path.ToString());
31+
return;
32+
}
33+
34+
ent.Comp.Map = _planetside.GenerateTerrain(ent.Comp.Terrain);
35+
}
36+
}

0 commit comments

Comments
 (0)