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

Up240824 #26

Merged
merged 19 commits into from
Aug 24, 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
Expand Up @@ -25,6 +25,7 @@ protected override void Open()
Index = index,
});
};
_window.FinishMission += () => SendMessage(new FinishSalvageMessage()); // Frontier
_window.OnClose += Close;
_window?.OpenCenteredLeft();
}
Expand Down
3 changes: 3 additions & 0 deletions Content.Client/Salvage/UI/SalvageExpeditionWindow.xaml
Original file line number Diff line number Diff line change
Expand Up @@ -19,5 +19,8 @@
<BoxContainer Name="Container"
Orientation="Horizontal"
Margin="5 0 5 0"/>
<Button Name="Finish"
Text="{Loc 'salvage-expedition-window-finish'}"
HorizontalAlignment="Right"/>
</BoxContainer>
</controls:FancyWindow>
11 changes: 11 additions & 0 deletions Content.Client/Salvage/UI/SalvageExpeditionWindow.xaml.cs
Original file line number Diff line number Diff line change
Expand Up @@ -30,6 +30,7 @@ public sealed partial class SalvageExpeditionWindow : FancyWindow,
private readonly SharedSalvageSystem _salvage;

public event Action<ushort>? ClaimMission;
public event Action? FinishMission; // Frontier
private bool _claimed;
private bool _cooldown;
private TimeSpan _nextOffer;
Expand Down Expand Up @@ -266,6 +267,16 @@ public void UpdateState(SalvageExpeditionConsoleState state)

Container.AddChild(box);
}

// Frontier
Finish.OnPressed += _ =>
{
Finish.Disabled = true;
FinishMission?.Invoke();
};

Finish.Disabled = !state.CanFinish;
// Frontier
}

protected override void FrameUpdate(FrameEventArgs args)
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -3,7 +3,7 @@
using Content.Client.UserInterface.Systems.Gameplay;
using Content.Client.UserInterface.Systems.Ghost.Widgets;
using Content.Shared.CCVar;
using Content.Shared.NF14.CCVar;
using Content.Shared._NF.CCVar; // Frontier
using Content.Shared.Ghost;
using Robust.Client.Console;
using Robust.Client.UserInterface;
Expand Down Expand Up @@ -76,8 +76,8 @@ public void UpdateGui()
Gui.Visible = _system?.IsGhost ?? false;
Gui.Update(_system?.AvailableGhostRoleCount, _system?.Player?.CanReturnToBody,
_system?.Player?.TimeOfDeath,
_cfg.GetCVar(NF14CVars.RespawnTime),
_canUncryo && _cfg.GetCVar(NF14CVars.CryoReturnEnabled));
_cfg.GetCVar(NFCCVars.RespawnTime), // Frontier
_canUncryo && _cfg.GetCVar(NFCCVars.CryoReturnEnabled)); // Frontier
}

private void UpdateRespawn(TimeSpan? timeOfDeath)
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -6,8 +6,7 @@
using Robust.Client.UserInterface.XAML;
using Robust.Shared.Timing;
using Robust.Shared.Configuration;
using Content.Shared.CCVar;
using Content.Shared.NF14.CCVar;
using Content.Shared._NF.CCVar; // Frontier

namespace Content.Client.UserInterface.Systems.Ghost.Widgets;

Expand Down Expand Up @@ -58,7 +57,7 @@ public void UpdateRespawn(TimeSpan? todd)
if (todd != null)
{
_timeOfDeath = todd;
_minTimeToRespawn = _configurationManager.GetCVar(NF14CVars.RespawnTime);
_minTimeToRespawn = _configurationManager.GetCVar(NFCCVars.RespawnTime); // Frontier
}
}

Expand Down
2 changes: 1 addition & 1 deletion Content.Server/Cargo/Systems/CargoSystem.Shuttle.cs
Original file line number Diff line number Diff line change
Expand Up @@ -278,7 +278,7 @@ private bool SellPallets(EntityUid consoleUid, EntityUid gridUid, out double amo
return false;


var ev = new EntitySoldEvent(toSell, gridUid);
var ev = new EntitySoldEvent(toSell, gridUid); // Frontier: add gridUid
RaiseLocalEvent(ref ev);

foreach (var ent in toSell)
Expand Down
164 changes: 131 additions & 33 deletions Content.Server/Salvage/SalvageSystem.ExpeditionConsole.cs
Original file line number Diff line number Diff line change
@@ -1,4 +1,3 @@
using Content.Server._NF.Salvage; // Frontier: graceful exped spawn failures
using Content.Server.Station.Components;
using Content.Shared.Popups;
using Content.Shared.Shuttles.Components;
Expand All @@ -9,6 +8,15 @@
using Robust.Shared.Physics.Components;
using Content.Shared.Dataset;
using Robust.Shared.Prototypes;
using Content.Server.Salvage.Expeditions; // Frontier
using Content.Shared._NF.CCVar; // Frontier
using Content.Shared.Mind.Components; // Frontier
using Content.Shared.Mobs.Components; // Frontier
using Content.Shared.Bank.Components; // Frontier
using Content.Shared.NPC.Components; // Frontier
using Content.Shared.IdentityManagement; // Frontier
using Content.Shared.NPC; // Frontier
using Content.Server._NF.Salvage; // Frontier

namespace Content.Server.Salvage;

Expand All @@ -26,47 +34,66 @@ private void OnSalvageClaimMessage(EntityUid uid, SalvageExpeditionConsoleCompon
{
var station = _station.GetOwningStation(uid);

if (!TryComp<SalvageExpeditionDataComponent>(station, out var data) || data.Claimed)
return;

if (!data.Missions.TryGetValue(args.Index, out var missionparams))
return;
// Frontier
var activeExpeditionCount = 0;
var expeditionQuery = AllEntityQuery<SalvageExpeditionDataComponent, MetaDataComponent>();
while (expeditionQuery.MoveNext(out var expeditionUid, out _, out _))
if (TryComp<SalvageExpeditionDataComponent>(expeditionUid, out var expeditionData) && expeditionData.Claimed)
activeExpeditionCount++;

// On Frontier, FTL travel is currently restricted to expeditions and such, and so we need to put this here
// until FTL changes for us in some way.
if (!TryComp<StationDataComponent>(station, out var stationData))
return;
if (_station.GetLargestGrid(stationData) is not {Valid : true} grid)
return;
if (!TryComp<MapGridComponent>(grid, out var gridComp))
if (!TryComp<SalvageExpeditionDataComponent>(station, out var data) || data.Claimed) // Moved up before the active expedition count
return;

var xform = Transform(grid);
var bounds = xform.WorldMatrix.TransformBox(gridComp.LocalAABB).Enlarged(ShuttleFTLRange);
var bodyQuery = GetEntityQuery<PhysicsComponent>();
foreach (var other in _mapManager.FindGridsIntersecting(xform.MapID, bounds))
if (activeExpeditionCount >= _configurationManager.GetCVar(NFCCVars.SalvageExpeditionMaxActive))
{
if (grid == other.Owner ||
!bodyQuery.TryGetComponent(other.Owner, out var body) ||
body.Mass < ShuttleFTLMassThreshold)
{
continue;
}

PlayDenySound(uid, component);
_popupSystem.PopupEntity(Loc.GetString("shuttle-ftl-proximity"), uid, PopupType.MediumCaution);
_popupSystem.PopupEntity(Loc.GetString("shuttle-ftl-too-many"), uid, PopupType.MediumCaution);
UpdateConsoles(data);
return;
}
// end of Frontier proximity check
// End Frontier

// Frontier: check for FTL component - if one exists, the station won't be taken into FTL.
if (HasComp<FTLComponent>(grid))
{
PlayDenySound(uid, component);
_popupSystem.PopupEntity(Loc.GetString("shuttle-ftl-recharge"), uid, PopupType.MediumCaution);
UpdateConsoles(data); // Sure, why not?
if (!data.Missions.TryGetValue(args.Index, out var missionparams))
return;

// Frontier: FTL travel is currently restricted to expeditions and such, and so we need to put this here
// until FTL changes for us in some way.
if (!component.Debug) // Skip the test
{
if (!TryComp<StationDataComponent>(station, out var stationData))
return;
if (_station.GetLargestGrid(stationData) is not { Valid: true } grid)
return;
if (!TryComp<MapGridComponent>(grid, out var gridComp))
return;

var xform = Transform(grid);
var bounds = xform.WorldMatrix.TransformBox(gridComp.LocalAABB).Enlarged(ShuttleFTLRange);
var bodyQuery = GetEntityQuery<PhysicsComponent>();
foreach (var other in _mapManager.FindGridsIntersecting(xform.MapID, bounds))
{
if (grid == other.Owner ||
!bodyQuery.TryGetComponent(other.Owner, out var body) ||
body.Mass < ShuttleFTLMassThreshold)
{
continue;
}

PlayDenySound(uid, component);
_popupSystem.PopupEntity(Loc.GetString("shuttle-ftl-proximity"), uid, PopupType.MediumCaution);
UpdateConsoles(data);
return;
}
// end of Frontier proximity check

// Frontier: check for FTL component - if one exists, the station won't be taken into FTL.
if (HasComp<FTLComponent>(grid))
{
PlayDenySound(uid, component);
_popupSystem.PopupEntity(Loc.GetString("shuttle-ftl-recharge"), uid, PopupType.MediumCaution);
UpdateConsoles(data); // Sure, why not?
return;
}
}
// End Frontier

Expand All @@ -85,6 +112,76 @@ private void OnSalvageClaimMessage(EntityUid uid, SalvageExpeditionConsoleCompon
UpdateConsoles(data);
}

// Frontier: early expedition end
private void OnSalvageFinishMessage(EntityUid entity, SalvageExpeditionConsoleComponent component, FinishSalvageMessage e)
{
if (!TryComp<SalvageExpeditionDataComponent>(_station.GetOwningStation(entity), out var data) || !data.CanFinish)
return;

// Based on SalvageSystem.Runner:OnConsoleFTLAttempt
if (!TryComp(entity, out TransformComponent? xform)) // Get the console's grid (if you move it, rip you)
{
PlayDenySound(entity, component);
_popupSystem.PopupEntity(Loc.GetString("salvage-expedition-shuttle-not-found"), entity, PopupType.MediumCaution);
UpdateConsoles(data);
return;
}

// Frontier: check if any player characters or friendly ghost roles are outside
var query = EntityQueryEnumerator<MindContainerComponent, MobStateComponent, TransformComponent>();
while (query.MoveNext(out var uid, out var mindContainer, out var _, out var mobXform))
{
if (mobXform.MapUid != xform.MapUid)
continue;

// Not player controlled (ghosted)
if (!mindContainer.HasMind)
continue;

// NPC, definitely not a person
if (HasComp<ActiveNPCComponent>(uid) || HasComp<SalvageMobRestrictionsNFComponent>(uid))
continue;

// Hostile ghost role, continue
if (TryComp(uid, out NpcFactionMemberComponent? npcFaction))
{
var hostileFactions = npcFaction.HostileFactions;
if (hostileFactions.Contains("NanoTrasen")) // Nasty - what if we need pirate expeditions?
continue;
}

// Okay they're on salvage, so are they on the shuttle.
if (mobXform.GridUid != xform.GridUid)
{
PlayDenySound(entity, component);
_popupSystem.PopupEntity(Loc.GetString("salvage-expedition-not-everyone-aboard", ("target", Identity.Entity(uid, EntityManager))), entity, PopupType.MediumCaution);
UpdateConsoles(data);
return;
}
}
// End SalvageSystem.Runner:OnConsoleFTLAttempt

data.CanFinish = false;
UpdateConsoles(data);

var map = Transform(entity).MapUid;

if (!TryComp<SalvageExpeditionComponent>(map, out var expedition))
return;

const int departTime = 20;
var newEndTime = _timing.CurTime + TimeSpan.FromSeconds(departTime);

if (expedition.EndTime <= newEndTime)
return;

expedition.EndTime = newEndTime;
expedition.Stage = ExpeditionStage.FinalCountdown;

Announce(map.Value, Loc.GetString("salvage-expedition-announcement-early-finish", ("departTime", departTime)));
}
// End Frontier: early expedition end

private void OnSalvageConsoleInit(Entity<SalvageExpeditionConsoleComponent> console, ref ComponentInit args)
{
UpdateConsole(console);
Expand Down Expand Up @@ -131,7 +228,7 @@ private void UpdateConsole(Entity<SalvageExpeditionConsoleComponent> component)
}
else
{
state = new SalvageExpeditionConsoleState(TimeSpan.Zero, false, true, 0, new List<SalvageMissionParams>());
state = new SalvageExpeditionConsoleState(TimeSpan.Zero, false, true, false, 0, new List<SalvageMissionParams>()); // Frontier: add false as 4th param
}

// Frontier: if we have a lingering FTL component, we cannot start a new mission
Expand All @@ -145,6 +242,7 @@ private void UpdateConsole(Entity<SalvageExpeditionConsoleComponent> component)

_ui.SetUiState(component.Owner, SalvageConsoleUiKey.Expedition, state);
}

private void PlayDenySound(EntityUid uid, SalvageExpeditionConsoleComponent component)
{
_audio.PlayPvs(_audio.GetSound(component.ErrorSound), uid);
Expand Down
21 changes: 12 additions & 9 deletions Content.Server/Salvage/SalvageSystem.Expeditions.cs
Original file line number Diff line number Diff line change
Expand Up @@ -6,6 +6,7 @@
using Content.Server.Salvage.Expeditions;
using Content.Server.Salvage.Expeditions.Structure;
using Content.Shared.CCVar;
using Content.Shared._NF.CCVar; // Frontier
using Content.Shared.Examine;
using Content.Shared.Random.Helpers;
using Content.Shared.Salvage.Expeditions;
Expand All @@ -24,6 +25,7 @@
using Robust.Shared.GameStates;
using Robust.Shared.Random;
using Robust.Shared.Map;
using Content.Shared.Shuttles.Components; // Frontier

namespace Content.Server.Salvage;

Expand All @@ -49,20 +51,19 @@ private void InitializeExpeditions()
SubscribeLocalEvent<SalvageExpeditionConsoleComponent, EntParentChangedMessage>(OnSalvageConsoleParent);
SubscribeLocalEvent<SalvageExpeditionConsoleComponent, ClaimSalvageMessage>(OnSalvageClaimMessage);
SubscribeLocalEvent<SalvageExpeditionDataComponent, ExpeditionSpawnCompleteEvent>(OnExpeditionSpawnComplete); // Frontier: more gracefully handle expedition generation failures
SubscribeLocalEvent<SalvageExpeditionConsoleComponent, FinishSalvageMessage>(OnSalvageFinishMessage); // Frontier: For early finish

SubscribeLocalEvent<SalvageExpeditionComponent, MapInitEvent>(OnExpeditionMapInit);
// SubscribeLocalEvent<SalvageExpeditionDataComponent, EntityUnpausedEvent>(OnDataUnpaused);
// SubscribeLocalEvent<SalvageExpeditionDataComponent, EntityUnpausedEvent>(OnDataUnpaused); // Frontier

SubscribeLocalEvent<SalvageExpeditionComponent, ComponentShutdown>(OnExpeditionShutdown);
// SubscribeLocalEvent<SalvageExpeditionComponent, EntityUnpausedEvent>(OnExpeditionUnpaused);
// SubscribeLocalEvent<SalvageExpeditionComponent, EntityUnpausedEvent>(OnExpeditionUnpaused); // Frontier
SubscribeLocalEvent<SalvageExpeditionComponent, ComponentGetState>(OnExpeditionGetState);

SubscribeLocalEvent<SalvageStructureComponent, ExaminedEvent>(OnStructureExamine);

_cooldown = _configurationManager.GetCVar(CCVars.SalvageExpeditionCooldown);
_failedCooldown = _configurationManager.GetCVar(CCVars.SalvageExpeditionFailedCooldown);
_configurationManager.OnValueChanged(CCVars.SalvageExpeditionCooldown, SetCooldownChange);
_configurationManager.OnValueChanged(CCVars.SalvageExpeditionFailedCooldown, SetFailedCooldownChange);
Subs.CVar(_configurationManager, CCVars.SalvageExpeditionCooldown, SetCooldownChange, true); // Frontier
Subs.CVar(_configurationManager, CCVars.SalvageExpeditionFailedCooldown, SetFailedCooldownChange, true); // Frontier
}

private void OnExpeditionGetState(EntityUid uid, SalvageExpeditionComponent component, ref ComponentGetState args)
Expand Down Expand Up @@ -133,7 +134,7 @@ private void OnExpeditionShutdown(EntityUid uid, SalvageExpeditionComponent comp
// Finish mission
if (TryComp<SalvageExpeditionDataComponent>(component.Station, out var data))
{
FinishExpedition(data, uid, component, null);
FinishExpedition(data, uid, component, component.Station); // Frontier: null<component.Station
}
}

Expand Down Expand Up @@ -169,7 +170,8 @@ private void UpdateExpeditions()
if (comp.NextOffer > currentTime || comp.Claimed)
continue;

comp.Cooldown = false;
if (!HasComp<FTLComponent>(_station.GetLargestGrid(Comp<StationDataComponent>(uid)))) // Frontier
comp.Cooldown = false;
//comp.NextOffer += TimeSpan.FromSeconds(_cooldown); // Frontier
comp.NextOffer = currentTime + TimeSpan.FromSeconds(_cooldown); // Frontier
GenerateMissions(comp);
Expand Down Expand Up @@ -289,7 +291,8 @@ private void GenerateMissions(SalvageExpeditionDataComponent component)
private SalvageExpeditionConsoleState GetState(SalvageExpeditionDataComponent component)
{
var missions = component.Missions.Values.ToList();
return new SalvageExpeditionConsoleState(component.NextOffer, component.Claimed, component.Cooldown, component.ActiveMission, missions);
//return new SalvageExpeditionConsoleState(component.NextOffer, component.Claimed, component.Cooldown, component.ActiveMission, missions);
return new SalvageExpeditionConsoleState(component.NextOffer, component.Claimed, component.Cooldown, component.CanFinish, component.ActiveMission, missions); // Frontier
}

private void SpawnMission(SalvageMissionParams missionParams, EntityUid station, EntityUid? coordinatesDisk)
Expand Down
Loading
Loading