Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

add lavaland real #2380

Merged
merged 24 commits into from
Dec 10, 2024
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
Original file line number Diff line number Diff line change
@@ -0,0 +1,5 @@
using Content.Shared.DeltaV.Shuttles.Systems;

namespace Content.Client.DeltaV.Shuttles.Systems;

public sealed class DockingConsoleSystem : SharedDockingConsoleSystem;
Original file line number Diff line number Diff line change
@@ -0,0 +1,38 @@
using Content.Shared.DeltaV.Shuttles;

namespace Content.Client.DeltaV.Shuttles.UI;

public sealed class DockingConsoleBoundUserInterface : BoundUserInterface
{
[ViewVariables]
private DockingConsoleWindow? _window;

public DockingConsoleBoundUserInterface(EntityUid owner, Enum uiKey) : base(owner, uiKey)
{
}

protected override void Open()
{
base.Open();

_window = new DockingConsoleWindow(Owner);
_window.OnFTL += index => SendMessage(new DockingConsoleFTLMessage(index));
_window.OnClose += Close;
_window.OpenCentered();
}

protected override void UpdateState(BoundUserInterfaceState state)
{
base.UpdateState(state);
if (state is DockingConsoleState cast)
_window?.UpdateState(cast);
}

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

if (disposing)
_window?.Orphan();
}
}
17 changes: 17 additions & 0 deletions Content.Client/DeltaV/Shuttles/UI/DockingConsoleWindow.xaml
Original file line number Diff line number Diff line change
@@ -0,0 +1,17 @@
<controls:FancyWindow xmlns="https://spacestation14.io"
xmlns:controls="clr-namespace:Content.Client.UserInterface.Controls"
SetSize="500 500">
<BoxContainer Orientation="Vertical">
<ScrollContainer SetHeight="256" HorizontalExpand="True">
<ItemList Name="Destinations"/> <!-- Populated from comp.Destinations -->
</ScrollContainer>
<controls:StripeBack MinSize="48 48">
<Label Text="{Loc 'shuttle-console-ftl-label'}" VerticalExpand="True" HorizontalAlignment="Center"/>
</controls:StripeBack>
<Label Name="MapFTLState" Text="{Loc 'shuttle-console-ftl-state-Available'}" VerticalAlignment="Stretch" HorizontalAlignment="Center"/>
<ProgressBar Name="FTLBar" HorizontalExpand="True" Margin="5" MinValue="0.0" MaxValue="1.0" Value="1.0" SetHeight="32"/>
<controls:StripeBack HorizontalExpand="True">
<Button Name="FTLButton" Text="{Loc 'docking-console-ftl'}" Disabled="True" SetSize="128 48" Margin="5"/>
</controls:StripeBack>
</BoxContainer>
</controls:FancyWindow>
112 changes: 112 additions & 0 deletions Content.Client/DeltaV/Shuttles/UI/DockingConsoleWindow.xaml.cs
Original file line number Diff line number Diff line change
@@ -0,0 +1,112 @@
using Content.Client.UserInterface.Controls;
using Content.Shared.Access.Systems;
using Content.Shared.DeltaV.Shuttles;
using Content.Shared.DeltaV.Shuttles.Components;
using Content.Shared.Shuttles.Systems;
using Content.Shared.Timing;
using Robust.Client.AutoGenerated;
using Robust.Client.Graphics;
using Robust.Client.Player;
using Robust.Client.UserInterface.XAML;
using Robust.Shared.Timing;

namespace Content.Client.DeltaV.Shuttles.UI;

[GenerateTypedNameReferences]
public sealed partial class DockingConsoleWindow : FancyWindow
{
[Dependency] private readonly IEntityManager _entMan = default!;
[Dependency] private readonly IGameTiming _timing = default!;
[Dependency] private readonly IPlayerManager _player = default!;
private readonly AccessReaderSystem _access;

public event Action<int>? OnFTL;

private readonly EntityUid _owner;
private readonly StyleBoxFlat _ftlStyle;

private FTLState _state;
private int? _selected;
private StartEndTime _ftlTime;

public DockingConsoleWindow(EntityUid owner)
{
RobustXamlLoader.Load(this);
IoCManager.InjectDependencies(this);

_access = _entMan.System<AccessReaderSystem>();

_owner = owner;

_ftlStyle = new StyleBoxFlat(Color.LimeGreen);
FTLBar.ForegroundStyleBoxOverride = _ftlStyle;

if (!_entMan.TryGetComponent<DockingConsoleComponent>(owner, out var comp))
return;

Title = Loc.GetString(comp.WindowTitle);

if (!comp.HasShuttle)
{
MapFTLState.Text = Loc.GetString("docking-console-no-shuttle");
_ftlStyle.BackgroundColor = Color.FromHex("#B02E26");
return;
}

Destinations.OnItemSelected += args => _selected = args.ItemIndex;
Destinations.OnItemDeselected += _ => _selected = null;

FTLButton.OnPressed += _ =>
{
if (_selected is {} index)
OnFTL?.Invoke(index);
};
}

public void UpdateState(DockingConsoleState state)
{
_state = state.FTLState;
_ftlTime = state.FTLTime;

MapFTLState.Text = Loc.GetString($"shuttle-console-ftl-state-{_state.ToString()}");
_ftlStyle.BackgroundColor = Color.FromHex(_state switch
{
FTLState.Available => "#80C71F",
FTLState.Starting => "#169C9C",
FTLState.Travelling => "#8932B8",
FTLState.Arriving => "#F9801D",
_ => "#B02E26" // cooldown and fallback
});

UpdateButton();

if (Destinations.Count == state.Destinations.Count)
return;

Destinations.Clear();
foreach (var dest in state.Destinations)
{
Destinations.AddItem(dest.Name);
}
}

private void UpdateButton()
{
FTLButton.Disabled = _selected == null || _state != FTLState.Available || !HasAccess();
}

private bool HasAccess()
{
return _player.LocalSession?.AttachedEntity is {} player && _access.IsAllowed(player, _owner);
}

protected override void FrameUpdate(FrameEventArgs args)
{
base.FrameUpdate(args);

UpdateButton();

var progress = _ftlTime.ProgressAt(_timing.CurTime);
FTLBar.Value = float.IsFinite(progress) ? progress : 1;
}
}
76 changes: 76 additions & 0 deletions Content.Server/DeltaV/Planet/PlanetSystem.cs
Original file line number Diff line number Diff line change
@@ -0,0 +1,76 @@
using Content.Server.Atmos.EntitySystems;
using Content.Server.Parallax;
using Content.Shared.DeltaV.Planet;
using Content.Shared.Parallax.Biomes;
using Robust.Server.GameObjects;
using Robust.Shared.Map;
using Robust.Shared.Map.Components;
using Robust.Shared.Prototypes;

namespace Content.Server.DeltaV.Planet;

public sealed class PlanetSystem : EntitySystem
{
[Dependency] private readonly AtmosphereSystem _atmos = default!;
[Dependency] private readonly BiomeSystem _biome = default!;
[Dependency] private readonly IPrototypeManager _proto = default!;
[Dependency] private readonly MapSystem _map = default!;
[Dependency] private readonly MapLoaderSystem _mapLoader = default!;
[Dependency] private readonly MetaDataSystem _meta = default!;

private readonly List<(Vector2i, Tile)> _setTiles = new();

/// <summary>
/// Spawn a planet map from a planet prototype.
/// </summary>
public EntityUid SpawnPlanet(ProtoId<PlanetPrototype> id, bool runMapInit = true)
{
var planet = _proto.Index(id);

var map = _map.CreateMap(out _, runMapInit: runMapInit);
_biome.EnsurePlanet(map, _proto.Index(planet.Biome), mapLight: planet.MapLight);

// add each marker layer
var biome = Comp<BiomeComponent>(map);
foreach (var layer in planet.BiomeMarkerLayers)
{
_biome.AddMarkerLayer(map, biome, layer);
}

if (planet.AddedComponents is {} added)
EntityManager.AddComponents(map, added);

_atmos.SetMapAtmosphere(map, false, planet.Atmosphere);

_meta.SetEntityName(map, Loc.GetString(planet.MapName));

return map;
}

/// <summary>
/// Spawns an initialized planet map from a planet prototype and loads a grid onto it.
/// Returns the map entity if loading succeeded.
/// </summary>
public EntityUid? LoadPlanet(ProtoId<PlanetPrototype> id, string path)
{
var map = SpawnPlanet(id, runMapInit: false);
var mapId = Comp<MapComponent>(map).MapId;
if (!_mapLoader.TryLoad(mapId, path, out var grids))
{
Log.Error($"Failed to load planet grid {path} for planet {id}!");
Del(map);
return null;
}

// don't want rocks spawning inside the base
foreach (var gridUid in grids)
{
_setTiles.Clear();
var aabb = Comp<MapGridComponent>(gridUid).LocalAABB;
_biome.ReserveTiles(map, aabb.Enlarged(0.2f), _setTiles);
}

_map.InitializeMap(map);
return map;
}
}
Loading
Loading