Salvage magnet revamp (#23119)

* Generic offering window

* More work

* weh

* Parity

* Progression meter

* magnet

* rona

* PG asteroid work

* code red

* Asteroid spawnings

* clams

* a

* Marker fixes

* More fixes

* Workings of biome asteroids

* A

* Fix this loading code

* a

* Fix masking

* weh

* Fixes

* Magnet claiming

* toe

* petogue

* magnet

* Bunch of fixes

* Fix default

* Fixes

* asteroids

* Fix offerings

* Localisation and a bunch of fixes

* a

* Fixes

* Preliminary draft

* Announcement fixes

* Fixes and bump spawn rate

* Fix asteroid spawns and UI

* More fixes

* Expeditions fix

* fix

* Gravity

* Fix announcement rounding

* a

* Offset tweak

* sus

* jankass

* Fix merge
This commit is contained in:
metalgearsloth
2024-01-04 14:25:32 +11:00
committed by GitHub
parent 98f5f47355
commit bf79acd127
66 changed files with 2257 additions and 1252 deletions

View File

@@ -1,6 +1,14 @@
using System.Linq;
using Content.Client.Stylesheets;
using Content.Shared.CCVar;
using Content.Shared.Procedural;
using Content.Shared.Salvage.Expeditions;
using Content.Shared.Salvage.Expeditions.Modifiers;
using JetBrains.Annotations;
using Robust.Client.GameObjects;
using Robust.Client.UserInterface;
using Robust.Client.UserInterface.Controls;
using Robust.Shared.Configuration;
using Robust.Shared.Prototypes;
namespace Content.Client.Salvage.UI;
@@ -8,23 +16,21 @@ namespace Content.Client.Salvage.UI;
public sealed class SalvageExpeditionConsoleBoundUserInterface : BoundUserInterface
{
[ViewVariables]
private SalvageExpeditionWindow? _window;
private OfferingWindow? _window;
[Dependency] private readonly IConfigurationManager _cfgManager = default!;
[Dependency] private readonly IEntityManager _entManager = default!;
[Dependency] private readonly IPrototypeManager _protoManager = default!;
public SalvageExpeditionConsoleBoundUserInterface(EntityUid owner, Enum uiKey) : base(owner, uiKey)
{
IoCManager.InjectDependencies(this);
}
protected override void Open()
{
base.Open();
_window = new SalvageExpeditionWindow();
_window.ClaimMission += index =>
{
SendMessage(new ClaimSalvageMessage()
{
Index = index,
});
};
_window = new OfferingWindow();
_window.OnClose += Close;
_window?.OpenCenteredLeft();
}
@@ -40,9 +46,133 @@ public sealed class SalvageExpeditionConsoleBoundUserInterface : BoundUserInterf
{
base.UpdateState(state);
if (state is not SalvageExpeditionConsoleState current)
if (state is not SalvageExpeditionConsoleState current || _window == null)
return;
_window?.UpdateState(current);
_window.Progression = null;
_window.Cooldown = TimeSpan.FromSeconds(_cfgManager.GetCVar(CCVars.SalvageExpeditionCooldown));
_window.NextOffer = current.NextOffer;
_window.Claimed = current.Claimed;
_window.ClearOptions();
var salvage = _entManager.System<SalvageSystem>();
for (var i = 0; i < current.Missions.Count; i++)
{
var missionParams = current.Missions[i];
var offering = new OfferingWindowOption();
offering.Title = Loc.GetString($"salvage-expedition-type");
var difficultyId = "Moderate";
var difficultyProto = _protoManager.Index<SalvageDifficultyPrototype>(difficultyId);
// TODO: Selectable difficulty soon.
var mission = salvage.GetMission(difficultyProto, missionParams.Seed);
// Difficulty
// Details
offering.AddContent(new Label()
{
Text = Loc.GetString("salvage-expedition-window-difficulty")
});
var difficultyColor = difficultyProto.Color;
offering.AddContent(new Label
{
Text = Loc.GetString("salvage-expedition-difficulty-Moderate"),
FontColorOverride = difficultyColor,
HorizontalAlignment = Control.HAlignment.Left,
Margin = new Thickness(0f, 0f, 0f, 5f),
});
offering.AddContent(new Label
{
Text = Loc.GetString("salvage-expedition-difficulty-players"),
HorizontalAlignment = Control.HAlignment.Left,
});
offering.AddContent(new Label
{
Text = difficultyProto.RecommendedPlayers.ToString(),
FontColorOverride = StyleNano.NanoGold,
HorizontalAlignment = Control.HAlignment.Left,
Margin = new Thickness(0f, 0f, 0f, 5f),
});
// Details
offering.AddContent(new Label
{
Text = Loc.GetString("salvage-expedition-window-hostiles")
});
var faction = mission.Faction;
offering.AddContent(new Label
{
Text = faction,
FontColorOverride = StyleNano.NanoGold,
HorizontalAlignment = Control.HAlignment.Left,
Margin = new Thickness(0f, 0f, 0f, 5f),
});
// Duration
offering.AddContent(new Label
{
Text = Loc.GetString("salvage-expedition-window-duration")
});
offering.AddContent(new Label
{
Text = mission.Duration.ToString(),
FontColorOverride = StyleNano.NanoGold,
HorizontalAlignment = Control.HAlignment.Left,
Margin = new Thickness(0f, 0f, 0f, 5f),
});
// Biome
offering.AddContent(new Label
{
Text = Loc.GetString("salvage-expedition-window-biome")
});
var biome = mission.Biome;
offering.AddContent(new Label
{
Text = Loc.GetString(_protoManager.Index<SalvageBiomeModPrototype>(biome).ID),
FontColorOverride = StyleNano.NanoGold,
HorizontalAlignment = Control.HAlignment.Left,
Margin = new Thickness(0f, 0f, 0f, 5f),
});
// Modifiers
offering.AddContent(new Label
{
Text = Loc.GetString("salvage-expedition-window-modifiers")
});
var mods = mission.Modifiers;
offering.AddContent(new Label
{
Text = string.Join("\n", mods.Select(o => "- " + o)).TrimEnd(),
FontColorOverride = StyleNano.NanoGold,
HorizontalAlignment = Control.HAlignment.Left,
Margin = new Thickness(0f, 0f, 0f, 5f),
});
offering.ClaimPressed += args =>
{
SendMessage(new ClaimSalvageMessage()
{
Index = missionParams.Index,
});
};
offering.Claimed = current.ActiveMission == missionParams.Index;
offering.Disabled = current.Claimed || current.Cooldown;
_window.AddOption(offering);
}
}
}