Skip to content

Commit

Permalink
Merge branch 'master' into Safe-Restock
Browse files Browse the repository at this point in the history
  • Loading branch information
dvir001 committed Jul 13, 2023
2 parents 2139478 + c4d24c4 commit 68db2cf
Show file tree
Hide file tree
Showing 18 changed files with 466 additions and 286 deletions.
51 changes: 51 additions & 0 deletions Content.Client/Bank/BUI/WithdrawlBankATMMenuBoundUserInterface.cs
Original file line number Diff line number Diff line change
@@ -0,0 +1,51 @@
using Content.Client.Bank.UI;
using Content.Shared.Bank.BUI;
using Content.Shared.Bank.Events;
using Robust.Client.GameObjects;

namespace Content.Client.Cargo.BUI;

public sealed class WithdrawBankATMMenuBoundUserInterface : BoundUserInterface
{
private WithdrawBankATMMenu? _menu;

public WithdrawBankATMMenuBoundUserInterface(ClientUserInterfaceComponent owner, Enum uiKey) : base(owner, uiKey) {}

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

_menu = new WithdrawBankATMMenu();
_menu.WithdrawRequest += OnWithdraw;
_menu.OnClose += Close;
_menu.OpenCentered();
}

protected override void Dispose(bool disposing)
{
base.Dispose(disposing);
if (disposing)
{
_menu?.Dispose();
}
}

private void OnWithdraw()
{
if (_menu?.Amount is not int amount)
return;

SendMessage(new BankWithdrawMessage(amount));
}

protected override void UpdateState(BoundUserInterfaceState state)
{
base.UpdateState(state);

if (state is not BankATMMenuInterfaceState bankState)
return;

_menu?.SetEnabled(bankState.Enabled);
_menu?.SetBalance(bankState.Balance);
}
}
44 changes: 44 additions & 0 deletions Content.Client/Bank/UI/WithdrawBankATMMenu.cs
Original file line number Diff line number Diff line change
@@ -0,0 +1,44 @@
using Content.Client.UserInterface.Controls;
using Robust.Client.AutoGenerated;
using Robust.Client.UserInterface.Controls;
using Robust.Client.UserInterface.XAML;

namespace Content.Client.Bank.UI;

[GenerateTypedNameReferences]
public sealed partial class WithdrawBankATMMenu : FancyWindow
{
public Action? WithdrawRequest;
public Action? DepositRequest;
public int Amount;
public WithdrawBankATMMenu()
{
RobustXamlLoader.Load(this);
WithdrawButton.OnPressed += OnWithdrawPressed;
Title = Loc.GetString("bank-atm-menu-title");
WithdrawEdit.OnTextChanged += OnAmountChanged;
}

public void SetBalance(int amount)
{
BalanceLabel.Text = Loc.GetString("cargo-console-menu-points-amount", ("amount", amount.ToString()));
}

public void SetEnabled(bool enabled)
{
WithdrawButton.Disabled = !enabled;
}

private void OnWithdrawPressed(BaseButton.ButtonEventArgs obj)
{
WithdrawRequest?.Invoke();
}

private void OnAmountChanged(LineEdit.LineEditEventArgs args)
{
if (int.TryParse(args.Text, out var amount))
{
Amount = amount;
}
}
}
17 changes: 17 additions & 0 deletions Content.Client/Bank/UI/WithdrawBankATMMenu.xaml
Original file line number Diff line number Diff line change
@@ -0,0 +1,17 @@
<controls:FancyWindow xmlns="https://spacestation14.io"
xmlns:gfx="clr-namespace:Robust.Client.Graphics;assembly=Robust.Client"
xmlns:controls="clr-namespace:Content.Client.UserInterface.Controls"
SetSize="300 120"
MinSize="300 120">
<BoxContainer Margin="10 2 10 2" Orientation="Vertical">
<BoxContainer Orientation="Horizontal">
<Label Text="{Loc 'bank-atm-menu-balance-label'}"
StyleClasses="LabelKeyText" />
<Label Name="BalanceLabel"
Text="{Loc 'bank-atm-menu-no-bank'}" />
</BoxContainer>
<LineEdit Name="WithdrawEdit" MinSize="80 0" />
<Button Name="WithdrawButton"
Text="{Loc 'bank-atm-menu-withdraw-button'}"/>
</BoxContainer>
</controls:FancyWindow>
5 changes: 5 additions & 0 deletions Content.Server/Salvage/SalvageSystem.Expeditions.cs
Original file line number Diff line number Diff line change
Expand Up @@ -9,6 +9,8 @@
using Robust.Shared.CPUJob.JobQueues.Queues;
using System.Linq;
using System.Threading;
using Content.Server.Shuttles.Systems;
using Content.Server.Station.Systems;
using Content.Shared.Salvage.Expeditions;
using Robust.Shared.GameStates;

Expand All @@ -21,6 +23,7 @@ public sealed partial class SalvageSystem
*/

[Dependency] private readonly CargoSystem _cargo = default!;
[Dependency] private readonly StationSystem _stationSystem = default!;

private const int MissionLimit = 5;

Expand Down Expand Up @@ -272,6 +275,8 @@ private void SpawnMission(SalvageMissionParams missionParams, EntityUid station)
_tileDefManager,
_biome,
_dungeon,
_shuttle,
_stationSystem,
this,
station,
missionParams,
Expand Down
28 changes: 23 additions & 5 deletions Content.Server/Salvage/SpawnSalvageMissionJob.cs
Original file line number Diff line number Diff line change
Expand Up @@ -10,6 +10,10 @@
using Content.Server.Procedural;
using Content.Server.Salvage.Expeditions;
using Content.Server.Salvage.Expeditions.Structure;
using Content.Server.Shuttles.Components;
using Content.Server.Shuttles.Systems;
using Content.Server.Station.Components;
using Content.Server.Station.Systems;
using Content.Shared.Atmos;
using Content.Shared.Dataset;
using Content.Shared.Gravity;
Expand Down Expand Up @@ -43,7 +47,8 @@ public sealed class SpawnSalvageMissionJob : Job<bool>
private readonly BiomeSystem _biome;
private readonly DungeonSystem _dungeon;
private readonly SalvageSystem _salvage;

private readonly ShuttleSystem _shuttle;
private readonly StationSystem _stationSystem;
public readonly EntityUid Station;
private readonly SalvageMissionParams _missionParams;

Expand All @@ -56,6 +61,8 @@ public SpawnSalvageMissionJob(
ITileDefinitionManager tileDefManager,
BiomeSystem biome,
DungeonSystem dungeon,
ShuttleSystem shuttle,
StationSystem stationSystem,
SalvageSystem salvage,
EntityUid station,
SalvageMissionParams missionParams,
Expand All @@ -68,6 +75,8 @@ public SpawnSalvageMissionJob(
_tileDefManager = tileDefManager;
_biome = biome;
_dungeon = dungeon;
_shuttle = shuttle;
_stationSystem = stationSystem;
_salvage = salvage;
Station = station;
_missionParams = missionParams;
Expand Down Expand Up @@ -138,12 +147,21 @@ protected override async Task<bool> Process()
expedition.Difficulty = _missionParams.Difficulty;
expedition.Rewards = mission.Rewards;

// Don't want consoles to have the incorrect name until refreshed.
var ftlUid = _entManager.CreateEntityUninitialized("FTLPoint", new EntityCoordinates(mapUid, Vector2.Zero));
// On Frontier, we cant share our locations it breaks ftl in a bad bad way
/*var ftlUid = _entManager.CreateEntityUninitialized("FTLPoint", new EntityCoordinates(mapUid, Vector2.Zero));
_entManager.GetComponent<MetaDataComponent>(ftlUid).EntityName = SharedSalvageSystem.GetFTLName(_prototypeManager.Index<DatasetPrototype>("names_borer"), _missionParams.Seed);
_entManager.InitializeAndStartEntity(ftlUid);
_entManager.InitializeAndStartEntity(ftlUid);*/

// so we just gunna yeet them there instead why not. they chose this life.
var stationData = _entManager.GetComponent<StationDataComponent>(Station);
var shuttleUid = _stationSystem.GetLargestGrid(stationData);
if (shuttleUid is { Valid : true } vesselUid)
{
var shuttle = _entManager.GetComponent<ShuttleComponent>(vesselUid);
_shuttle.FTLTravel(vesselUid, shuttle, new EntityCoordinates(mapUid, Vector2.Zero), 8f, 50f);
}

var landingPadRadius = 24;
var landingPadRadius = 38; //we go a liiitle bigger for the shipses
var minDungeonOffset = landingPadRadius + 4;

// We'll use the dungeon rotation as the spawn angle
Expand Down
28 changes: 25 additions & 3 deletions Content.Server/_NF/GameRule/NfAdventureRuleSystem.cs
Original file line number Diff line number Diff line change
Expand Up @@ -80,9 +80,9 @@ private void OnPlayerSpawningEvent(PlayerSpawnCompleteEvent ev)
private void OnStartup(RoundStartingEvent ev)
{
var depotMap = "/Maps/cargodepot.yml";
var mapId = GameTicker.DefaultMap;
var depotOffset = _random.NextVector2(1500f, 3000f);
var depotColor = new Color(55, 200, 55);
var mapId = GameTicker.DefaultMap;
var depotOffset = _random.NextVector2(1500f, 2400f);
if (_map.TryLoad(mapId, depotMap, out var depotUids, new MapLoadOptions
{
Offset = depotOffset
Expand All @@ -105,7 +105,29 @@ private void OnStartup(RoundStartingEvent ev)
}

;
depotOffset = _random.NextVector2(2300f, 3400f);
if (_map.TryLoad(mapId, depotMap, out var depotUid3s, new MapLoadOptions
{
Offset = depotOffset
}))
{
var meta = EnsureComp<MetaDataComponent>(depotUid3s[0]);
meta.EntityName = "NT Cargo Depot C NF14";
_shuttle.SetIFFColor(depotUid3s[0], depotColor);
}

;
if (_map.TryLoad(mapId, depotMap, out var depotUid4s, new MapLoadOptions
{
Offset = -depotOffset
}))
{
var meta = EnsureComp<MetaDataComponent>(depotUid4s[0]);
meta.EntityName = "NT Cargo Depot D NF14";
_shuttle.SetIFFColor(depotUid4s[0], depotColor);
}

;
var dungenTypes = _prototypeManager.EnumeratePrototypes<DungeonConfigPrototype>();

foreach (var dunGen in dungenTypes)
Expand Down Expand Up @@ -151,7 +173,7 @@ private void OnStartup(RoundStartingEvent ev)

//pls fit the grid I beg, this is so hacky
//its better now but i think i need to do a normalization pass on the dungeon configs
//because they are all offset
//because they are all offset. confirmed good size grid, just need to fix all the offsets.
_dunGen.GenerateDungeon(dunGen, grids[0], mapGrid, (Vector2i) offset, seed);
}
}
Expand Down
2 changes: 1 addition & 1 deletion Content.Shared/CCVar/CCVars.cs
Original file line number Diff line number Diff line change
Expand Up @@ -28,7 +28,7 @@ public sealed class CCVars : CVars
/// A loc string for what should be displayed as the title on the Rules window.
/// </summary>
public static readonly CVarDef<string> RulesHeader =
CVarDef.Create("server.rules_header", "ui-rules-header", CVar.REPLICATED | CVar.SERVER);
CVarDef.Create("server.rules_header", "Frontier Server Rules", CVar.REPLICATED | CVar.SERVER);

/*
* Ambience
Expand Down
3 changes: 1 addition & 2 deletions Content.Shared/_NF/Bank/SharedBankSystem.cs
Original file line number Diff line number Diff line change
Expand Up @@ -8,8 +8,7 @@ namespace Content.Shared.Bank;
[NetSerializable, Serializable]
public enum BankATMMenuUiKey : byte
{
ATM,
StationATM
ATM
}

public sealed partial class SharedBankSystem : EntitySystem
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -72,3 +72,6 @@ ent-CrateVendingMachineRestockDiscountDans = { ent-CrateVendingMachineRestockDis
ent-CrateVendingMachineRestockDonut = { ent-CrateVendingMachineRestockDonutFilled }
.desc = { ent-CrateVendingMachineRestockDonutFilled.desc }
ent-CrateVendingMachineRestockChemVend = { ent-CrateVendingMachineRestockChemVendFilled }
.desc = { CrateVendingMachineRestockChemVendFilled.desc }
Original file line number Diff line number Diff line change
Expand Up @@ -72,3 +72,6 @@ ent-CrateVendingMachineRestockDiscountDansFilled = Discount Dans restock crate
ent-CrateVendingMachineRestockDonutFilled = Donut restock crate
.desc = Contains a restock box for a Monkin' Donuts dispenser.
ent-CrateVendingMachineRestockChemVendFilled = ChemVend restock crate
.desc = Contains a restock box for the ChemVend.
Loading

0 comments on commit 68db2cf

Please sign in to comment.