Expeditions QOL (#15599)
This commit is contained in:
@@ -2,6 +2,7 @@ using System.Linq;
|
|||||||
using Content.Client.Computer;
|
using Content.Client.Computer;
|
||||||
using Content.Client.Stylesheets;
|
using Content.Client.Stylesheets;
|
||||||
using Content.Client.UserInterface.Controls;
|
using Content.Client.UserInterface.Controls;
|
||||||
|
using Content.Shared.CCVar;
|
||||||
using Content.Shared.Parallax.Biomes;
|
using Content.Shared.Parallax.Biomes;
|
||||||
using Content.Shared.Procedural.Loot;
|
using Content.Shared.Procedural.Loot;
|
||||||
using Content.Shared.Salvage;
|
using Content.Shared.Salvage;
|
||||||
@@ -12,6 +13,7 @@ using Robust.Client.Graphics;
|
|||||||
using Robust.Client.UserInterface;
|
using Robust.Client.UserInterface;
|
||||||
using Robust.Client.UserInterface.Controls;
|
using Robust.Client.UserInterface.Controls;
|
||||||
using Robust.Client.UserInterface.XAML;
|
using Robust.Client.UserInterface.XAML;
|
||||||
|
using Robust.Shared.Configuration;
|
||||||
using Robust.Shared.Prototypes;
|
using Robust.Shared.Prototypes;
|
||||||
using Robust.Shared.Timing;
|
using Robust.Shared.Timing;
|
||||||
|
|
||||||
@@ -21,6 +23,7 @@ namespace Content.Client.Salvage.UI;
|
|||||||
public sealed partial class SalvageExpeditionWindow : FancyWindow,
|
public sealed partial class SalvageExpeditionWindow : FancyWindow,
|
||||||
IComputerWindow<EmergencyConsoleBoundUserInterfaceState>
|
IComputerWindow<EmergencyConsoleBoundUserInterfaceState>
|
||||||
{
|
{
|
||||||
|
private readonly IConfigurationManager _cfgManager;
|
||||||
private readonly IGameTiming _timing;
|
private readonly IGameTiming _timing;
|
||||||
private readonly IPrototypeManager _prototype;
|
private readonly IPrototypeManager _prototype;
|
||||||
private readonly SharedSalvageSystem _salvage;
|
private readonly SharedSalvageSystem _salvage;
|
||||||
@@ -33,6 +36,7 @@ public sealed partial class SalvageExpeditionWindow : FancyWindow,
|
|||||||
public SalvageExpeditionWindow()
|
public SalvageExpeditionWindow()
|
||||||
{
|
{
|
||||||
RobustXamlLoader.Load(this);
|
RobustXamlLoader.Load(this);
|
||||||
|
_cfgManager = IoCManager.Resolve<IConfigurationManager>();
|
||||||
_timing = IoCManager.Resolve<IGameTiming>();
|
_timing = IoCManager.Resolve<IGameTiming>();
|
||||||
_prototype = IoCManager.Resolve<IPrototypeManager>();
|
_prototype = IoCManager.Resolve<IPrototypeManager>();
|
||||||
_salvage = IoCManager.Resolve<IEntityManager>().EntitySysManager.GetEntitySystem<SharedSalvageSystem>();
|
_salvage = IoCManager.Resolve<IEntityManager>().EntitySysManager.GetEntitySystem<SharedSalvageSystem>();
|
||||||
@@ -80,7 +84,7 @@ public sealed partial class SalvageExpeditionWindow : FancyWindow,
|
|||||||
|
|
||||||
switch (missionParams.Difficulty)
|
switch (missionParams.Difficulty)
|
||||||
{
|
{
|
||||||
case DifficultyRating.None:
|
case DifficultyRating.Minimal:
|
||||||
difficultyColor = Color.FromHex("#52B4E996");
|
difficultyColor = Color.FromHex("#52B4E996");
|
||||||
break;
|
break;
|
||||||
case DifficultyRating.Minor:
|
case DifficultyRating.Minor:
|
||||||
@@ -287,8 +291,8 @@ public sealed partial class SalvageExpeditionWindow : FancyWindow,
|
|||||||
else
|
else
|
||||||
{
|
{
|
||||||
var cooldown = _cooldown
|
var cooldown = _cooldown
|
||||||
? SharedSalvageSystem.MissionFailedCooldown
|
? TimeSpan.FromSeconds(_cfgManager.GetCVar(CCVars.SalvageExpeditionFailedCooldown))
|
||||||
: SharedSalvageSystem.MissionCooldown;
|
: TimeSpan.FromSeconds(_cfgManager.GetCVar(CCVars.SalvageExpeditionCooldown));
|
||||||
|
|
||||||
NextOfferBar.Value = 1f - (float) (remaining / cooldown);
|
NextOfferBar.Value = 1f - (float) (remaining / cooldown);
|
||||||
NextOfferText.Text = $"{remaining.Minutes:00}:{remaining.Seconds:00}";
|
NextOfferText.Text = $"{remaining.Minutes:00}:{remaining.Seconds:00}";
|
||||||
|
|||||||
@@ -5,6 +5,7 @@ using Content.Server.CPUJob.JobQueues.Queues;
|
|||||||
using Content.Server.Salvage.Expeditions;
|
using Content.Server.Salvage.Expeditions;
|
||||||
using Content.Server.Salvage.Expeditions.Structure;
|
using Content.Server.Salvage.Expeditions.Structure;
|
||||||
using Content.Server.Station.Systems;
|
using Content.Server.Station.Systems;
|
||||||
|
using Content.Shared.CCVar;
|
||||||
using Content.Shared.Examine;
|
using Content.Shared.Examine;
|
||||||
using Content.Shared.Salvage;
|
using Content.Shared.Salvage;
|
||||||
|
|
||||||
@@ -22,6 +23,9 @@ public sealed partial class SalvageSystem
|
|||||||
private readonly List<(SpawnSalvageMissionJob Job, CancellationTokenSource CancelToken)> _salvageJobs = new();
|
private readonly List<(SpawnSalvageMissionJob Job, CancellationTokenSource CancelToken)> _salvageJobs = new();
|
||||||
private const double SalvageJobTime = 0.002;
|
private const double SalvageJobTime = 0.002;
|
||||||
|
|
||||||
|
private float _cooldown;
|
||||||
|
private float _failedCooldown;
|
||||||
|
|
||||||
private void InitializeExpeditions()
|
private void InitializeExpeditions()
|
||||||
{
|
{
|
||||||
SubscribeLocalEvent<StationInitializedEvent>(OnSalvageExpStationInit);
|
SubscribeLocalEvent<StationInitializedEvent>(OnSalvageExpStationInit);
|
||||||
@@ -36,6 +40,46 @@ public sealed partial class SalvageSystem
|
|||||||
SubscribeLocalEvent<SalvageExpeditionComponent, EntityUnpausedEvent>(OnExpeditionUnpaused);
|
SubscribeLocalEvent<SalvageExpeditionComponent, EntityUnpausedEvent>(OnExpeditionUnpaused);
|
||||||
|
|
||||||
SubscribeLocalEvent<SalvageStructureComponent, ExaminedEvent>(OnStructureExamine);
|
SubscribeLocalEvent<SalvageStructureComponent, ExaminedEvent>(OnStructureExamine);
|
||||||
|
|
||||||
|
_cooldown = _configurationManager.GetCVar(CCVars.SalvageExpeditionCooldown);
|
||||||
|
_failedCooldown = _configurationManager.GetCVar(CCVars.SalvageExpeditionFailedCooldown);
|
||||||
|
_configurationManager.OnValueChanged(CCVars.SalvageExpeditionCooldown, SetCooldownChange);
|
||||||
|
_configurationManager.OnValueChanged(CCVars.SalvageExpeditionFailedCooldown, SetFailedCooldownChange);
|
||||||
|
}
|
||||||
|
|
||||||
|
private void ShutdownExpeditions()
|
||||||
|
{
|
||||||
|
_configurationManager.UnsubValueChanged(CCVars.SalvageExpeditionCooldown, SetCooldownChange);
|
||||||
|
_configurationManager.UnsubValueChanged(CCVars.SalvageExpeditionFailedCooldown, SetFailedCooldownChange);
|
||||||
|
}
|
||||||
|
|
||||||
|
private void SetCooldownChange(float obj)
|
||||||
|
{
|
||||||
|
// Update the active cooldowns if we change it.
|
||||||
|
var diff = obj - _cooldown;
|
||||||
|
|
||||||
|
var query = AllEntityQuery<SalvageExpeditionDataComponent>();
|
||||||
|
|
||||||
|
while (query.MoveNext(out var comp))
|
||||||
|
{
|
||||||
|
comp.NextOffer += TimeSpan.FromSeconds(diff);
|
||||||
|
}
|
||||||
|
|
||||||
|
_cooldown = obj;
|
||||||
|
}
|
||||||
|
|
||||||
|
private void SetFailedCooldownChange(float obj)
|
||||||
|
{
|
||||||
|
var diff = obj - _failedCooldown;
|
||||||
|
|
||||||
|
var query = AllEntityQuery<SalvageExpeditionDataComponent>();
|
||||||
|
|
||||||
|
while (query.MoveNext(out var comp))
|
||||||
|
{
|
||||||
|
comp.NextOffer += TimeSpan.FromSeconds(diff);
|
||||||
|
}
|
||||||
|
|
||||||
|
_failedCooldown = obj;
|
||||||
}
|
}
|
||||||
|
|
||||||
private void OnExpeditionShutdown(EntityUid uid, SalvageExpeditionComponent component, ComponentShutdown args)
|
private void OnExpeditionShutdown(EntityUid uid, SalvageExpeditionComponent component, ComponentShutdown args)
|
||||||
@@ -96,7 +140,7 @@ public sealed partial class SalvageSystem
|
|||||||
continue;
|
continue;
|
||||||
|
|
||||||
comp.Cooldown = false;
|
comp.Cooldown = false;
|
||||||
comp.NextOffer += MissionCooldown;
|
comp.NextOffer += TimeSpan.FromSeconds(_cooldown);
|
||||||
GenerateMissions(comp);
|
GenerateMissions(comp);
|
||||||
UpdateConsoles(comp);
|
UpdateConsoles(comp);
|
||||||
}
|
}
|
||||||
@@ -144,13 +188,13 @@ public sealed partial class SalvageSystem
|
|||||||
if (expedition.Completed)
|
if (expedition.Completed)
|
||||||
{
|
{
|
||||||
_sawmill.Debug($"Completed mission {expedition.MissionParams.MissionType} with seed {expedition.MissionParams.Seed}");
|
_sawmill.Debug($"Completed mission {expedition.MissionParams.MissionType} with seed {expedition.MissionParams.Seed}");
|
||||||
component.NextOffer = _timing.CurTime + MissionCooldown;
|
component.NextOffer = _timing.CurTime + TimeSpan.FromSeconds(_cooldown);
|
||||||
Announce(expedition.Owner, Loc.GetString("salvage-expedition-mission-completed"));
|
Announce(expedition.Owner, Loc.GetString("salvage-expedition-mission-completed"));
|
||||||
}
|
}
|
||||||
else
|
else
|
||||||
{
|
{
|
||||||
_sawmill.Debug($"Failed mission {expedition.MissionParams.MissionType} with seed {expedition.MissionParams.Seed}");
|
_sawmill.Debug($"Failed mission {expedition.MissionParams.MissionType} with seed {expedition.MissionParams.Seed}");
|
||||||
component.NextOffer = _timing.CurTime + MissionFailedCooldown;
|
component.NextOffer = _timing.CurTime + TimeSpan.FromSeconds(_failedCooldown);
|
||||||
Announce(expedition.Owner, Loc.GetString("salvage-expedition-mission-failed"));
|
Announce(expedition.Owner, Loc.GetString("salvage-expedition-mission-failed"));
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|||||||
@@ -71,6 +71,12 @@ namespace Content.Server.Salvage
|
|||||||
InitializeRunner();
|
InitializeRunner();
|
||||||
}
|
}
|
||||||
|
|
||||||
|
public override void Shutdown()
|
||||||
|
{
|
||||||
|
base.Shutdown();
|
||||||
|
ShutdownExpeditions();
|
||||||
|
}
|
||||||
|
|
||||||
private void OnRoundEnd(GameRunLevelChangedEvent ev)
|
private void OnRoundEnd(GameRunLevelChangedEvent ev)
|
||||||
{
|
{
|
||||||
if(ev.New != GameRunLevel.InRound)
|
if(ev.New != GameRunLevel.InRound)
|
||||||
|
|||||||
@@ -1328,8 +1328,16 @@ namespace Content.Shared.CCVar
|
|||||||
public static readonly CVarDef<string>
|
public static readonly CVarDef<string>
|
||||||
SalvageForced = CVarDef.Create("salvage.forced", "", CVar.SERVERONLY);
|
SalvageForced = CVarDef.Create("salvage.forced", "", CVar.SERVERONLY);
|
||||||
|
|
||||||
/*
|
/// <summary>
|
||||||
|
/// Cooldown for successful missions.
|
||||||
|
/// </summary>
|
||||||
|
public static readonly CVarDef<float>
|
||||||
|
SalvageExpeditionCooldown = CVarDef.Create("salvage.expedition_cooldown", 300f, CVar.REPLICATED);
|
||||||
|
|
||||||
|
public static readonly CVarDef<float>
|
||||||
|
SalvageExpeditionFailedCooldown = CVarDef.Create("salvage.expedition_failed_cooldown", 900f, CVar.REPLICATED);
|
||||||
|
|
||||||
|
/*
|
||||||
* Flavor
|
* Flavor
|
||||||
*/
|
*/
|
||||||
|
|
||||||
|
|||||||
@@ -17,9 +17,6 @@ public abstract class SharedSalvageSystem : EntitySystem
|
|||||||
[Dependency] private readonly ILocalizationManager _loc = default!;
|
[Dependency] private readonly ILocalizationManager _loc = default!;
|
||||||
[Dependency] private readonly IPrototypeManager _proto = default!;
|
[Dependency] private readonly IPrototypeManager _proto = default!;
|
||||||
|
|
||||||
public static readonly TimeSpan MissionCooldown = TimeSpan.FromMinutes(5);
|
|
||||||
public static readonly TimeSpan MissionFailedCooldown = TimeSpan.FromMinutes(15);
|
|
||||||
|
|
||||||
#region Descriptions
|
#region Descriptions
|
||||||
|
|
||||||
public string GetMissionDescription(SalvageMission mission)
|
public string GetMissionDescription(SalvageMission mission)
|
||||||
@@ -60,7 +57,7 @@ public abstract class SharedSalvageSystem : EntitySystem
|
|||||||
{
|
{
|
||||||
switch (rating)
|
switch (rating)
|
||||||
{
|
{
|
||||||
case DifficultyRating.None:
|
case DifficultyRating.Minimal:
|
||||||
return 1;
|
return 1;
|
||||||
case DifficultyRating.Minor:
|
case DifficultyRating.Minor:
|
||||||
return 2;
|
return 2;
|
||||||
@@ -227,7 +224,7 @@ public enum SalvageMissionType : byte
|
|||||||
[Serializable, NetSerializable]
|
[Serializable, NetSerializable]
|
||||||
public enum DifficultyRating : byte
|
public enum DifficultyRating : byte
|
||||||
{
|
{
|
||||||
None,
|
Minimal,
|
||||||
Minor,
|
Minor,
|
||||||
Moderate,
|
Moderate,
|
||||||
Hazardous,
|
Hazardous,
|
||||||
|
|||||||
@@ -11,6 +11,10 @@ grid_splitting = false
|
|||||||
[procgen]
|
[procgen]
|
||||||
preload = false
|
preload = false
|
||||||
|
|
||||||
|
[salvage]
|
||||||
|
expedition_cooldown = 30.0
|
||||||
|
expedition_failed_cooldown = 30.0
|
||||||
|
|
||||||
[shuttle]
|
[shuttle]
|
||||||
# Wastes startup time
|
# Wastes startup time
|
||||||
auto_call_time = 0
|
auto_call_time = 0
|
||||||
|
|||||||
@@ -23,7 +23,7 @@ salvage-expedition-desc-structure = Destroy {$count} {$structure} inside the are
|
|||||||
salvage-expedition-type-Mining = Mining
|
salvage-expedition-type-Mining = Mining
|
||||||
salvage-expedition-type-Destruction = Destruction
|
salvage-expedition-type-Destruction = Destruction
|
||||||
|
|
||||||
salvage-expedition-difficulty-None = None
|
salvage-expedition-difficulty-None = Minimal
|
||||||
salvage-expedition-difficulty-Minor = Minor
|
salvage-expedition-difficulty-Minor = Minor
|
||||||
salvage-expedition-difficulty-Moderate = Moderate
|
salvage-expedition-difficulty-Moderate = Moderate
|
||||||
salvage-expedition-difficulty-Hazardous = Hazardous
|
salvage-expedition-difficulty-Hazardous = Hazardous
|
||||||
|
|||||||
Reference in New Issue
Block a user