using Content.Client.Computer;
using Content.Client.Stylesheets;
using Content.Client.UserInterface.Controls;
+using Content.Shared.CCVar;
using Content.Shared.Parallax.Biomes;
using Content.Shared.Procedural.Loot;
using Content.Shared.Salvage;
using Robust.Client.UserInterface;
using Robust.Client.UserInterface.Controls;
using Robust.Client.UserInterface.XAML;
+using Robust.Shared.Configuration;
using Robust.Shared.Prototypes;
using Robust.Shared.Timing;
public sealed partial class SalvageExpeditionWindow : FancyWindow,
IComputerWindow<EmergencyConsoleBoundUserInterfaceState>
{
+ private readonly IConfigurationManager _cfgManager;
private readonly IGameTiming _timing;
private readonly IPrototypeManager _prototype;
private readonly SharedSalvageSystem _salvage;
public SalvageExpeditionWindow()
{
RobustXamlLoader.Load(this);
+ _cfgManager = IoCManager.Resolve<IConfigurationManager>();
_timing = IoCManager.Resolve<IGameTiming>();
_prototype = IoCManager.Resolve<IPrototypeManager>();
_salvage = IoCManager.Resolve<IEntityManager>().EntitySysManager.GetEntitySystem<SharedSalvageSystem>();
switch (missionParams.Difficulty)
{
- case DifficultyRating.None:
+ case DifficultyRating.Minimal:
difficultyColor = Color.FromHex("#52B4E996");
break;
case DifficultyRating.Minor:
else
{
var cooldown = _cooldown
- ? SharedSalvageSystem.MissionFailedCooldown
- : SharedSalvageSystem.MissionCooldown;
+ ? TimeSpan.FromSeconds(_cfgManager.GetCVar(CCVars.SalvageExpeditionFailedCooldown))
+ : TimeSpan.FromSeconds(_cfgManager.GetCVar(CCVars.SalvageExpeditionCooldown));
NextOfferBar.Value = 1f - (float) (remaining / cooldown);
NextOfferText.Text = $"{remaining.Minutes:00}:{remaining.Seconds:00}";
using Content.Server.Salvage.Expeditions;
using Content.Server.Salvage.Expeditions.Structure;
using Content.Server.Station.Systems;
+using Content.Shared.CCVar;
using Content.Shared.Examine;
using Content.Shared.Salvage;
private readonly List<(SpawnSalvageMissionJob Job, CancellationTokenSource CancelToken)> _salvageJobs = new();
private const double SalvageJobTime = 0.002;
+ private float _cooldown;
+ private float _failedCooldown;
+
private void InitializeExpeditions()
{
SubscribeLocalEvent<StationInitializedEvent>(OnSalvageExpStationInit);
SubscribeLocalEvent<SalvageExpeditionComponent, EntityUnpausedEvent>(OnExpeditionUnpaused);
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)
continue;
comp.Cooldown = false;
- comp.NextOffer += MissionCooldown;
+ comp.NextOffer += TimeSpan.FromSeconds(_cooldown);
GenerateMissions(comp);
UpdateConsoles(comp);
}
if (expedition.Completed)
{
_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"));
}
else
{
_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"));
}
InitializeRunner();
}
+ public override void Shutdown()
+ {
+ base.Shutdown();
+ ShutdownExpeditions();
+ }
+
private void OnRoundEnd(GameRunLevelChangedEvent ev)
{
if(ev.New != GameRunLevel.InRound)
public static readonly CVarDef<string>
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
*/
[Dependency] private readonly ILocalizationManager _loc = 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
public string GetMissionDescription(SalvageMission mission)
{
switch (rating)
{
- case DifficultyRating.None:
+ case DifficultyRating.Minimal:
return 1;
case DifficultyRating.Minor:
return 2;
[Serializable, NetSerializable]
public enum DifficultyRating : byte
{
- None,
+ Minimal,
Minor,
Moderate,
Hazardous,
[procgen]
preload = false
+[salvage]
+expedition_cooldown = 30.0
+expedition_failed_cooldown = 30.0
+
[shuttle]
# Wastes startup time
auto_call_time = 0
salvage-expedition-type-Mining = Mining
salvage-expedition-type-Destruction = Destruction
-salvage-expedition-difficulty-None = None
+salvage-expedition-difficulty-None = Minimal
salvage-expedition-difficulty-Minor = Minor
salvage-expedition-difficulty-Moderate = Moderate
salvage-expedition-difficulty-Hazardous = Hazardous