Longer bounties (#18053)

This commit is contained in:
Nemanja
2023-07-15 14:15:12 -04:00
committed by GitHub
parent b21957d86d
commit da72b802e9
2 changed files with 12 additions and 17 deletions

View File

@@ -27,21 +27,14 @@ public sealed class StationCargoBountyDatabaseComponent : Component
public int TotalBounties; public int TotalBounties;
/// <summary> /// <summary>
/// A poor-man's weighted list of the durations for how long /// The minimum amount of time the bounty lasts before being removed.
/// each bounty will last.
/// </summary> /// </summary>
[DataField("bountyDurations")] [DataField("minBountyTime"), ViewVariables(VVAccess.ReadWrite)]
public List<TimeSpan> BountyDurations = new() public float MinBountyTime = 600f;
{
TimeSpan.FromMinutes(5), /// <summary>
TimeSpan.FromMinutes(7.5f), /// The maxmium amount of time the bounty lasts before being removed.
TimeSpan.FromMinutes(7.5f), /// </summary>
TimeSpan.FromMinutes(7.5f), [DataField("maxBountyTime"), ViewVariables(VVAccess.ReadWrite)]
TimeSpan.FromMinutes(10), public float MaxBountyTime = 905f;
TimeSpan.FromMinutes(10),
TimeSpan.FromMinutes(10),
TimeSpan.FromMinutes(10),
TimeSpan.FromMinutes(10),
TimeSpan.FromMinutes(15)
};
} }

View File

@@ -256,7 +256,9 @@ public sealed partial class CargoSystem
if (component.Bounties.Count >= component.MaxBounties) if (component.Bounties.Count >= component.MaxBounties)
return false; return false;
var endTime = _timing.CurTime + _random.Pick(component.BountyDurations) + TimeSpan.FromSeconds(_random.Next(-10, 10)); var duration = MathF.Round(_random.NextFloat(component.MinBountyTime, component.MaxBountyTime) / 15) * 15;
var endTime = _timing.CurTime + TimeSpan.FromSeconds(duration);
component.Bounties.Add(new CargoBountyData(component.TotalBounties, bounty.ID, endTime)); component.Bounties.Add(new CargoBountyData(component.TotalBounties, bounty.ID, endTime));
_adminLogger.Add(LogType.Action, LogImpact.Low, $"Added bounty \"{bounty.ID}\" (id:{component.TotalBounties}) to station {ToPrettyString(uid)}"); _adminLogger.Add(LogType.Action, LogImpact.Low, $"Added bounty \"{bounty.ID}\" (id:{component.TotalBounties}) to station {ToPrettyString(uid)}");
component.TotalBounties++; component.TotalBounties++;