Skip to content

Commit

Permalink
Merge branch 'port-station-goals' of https://github.com/VMSolidus/Ein…
Browse files Browse the repository at this point in the history
…stein-Engines into port-station-goals
  • Loading branch information
VMSolidus committed Jun 16, 2024
2 parents 8b07729 + 1ce9243 commit a372209
Show file tree
Hide file tree
Showing 6 changed files with 16 additions and 24 deletions.
5 changes: 2 additions & 3 deletions Content.Server/Fax/FaxMachineComponent.cs
Original file line number Diff line number Diff line change
Expand Up @@ -52,10 +52,9 @@ public sealed partial class FaxMachineComponent : Component
public bool ReceiveNukeCodes { get; set; } = false;

/// <summary>
/// Should that fax receive station goal info
/// Should this fax receive station goals
/// </summary>
[ViewVariables(VVAccess.ReadWrite)]
[DataField("receiveStationGoal")]
[DataField]
public bool ReceiveStationGoal { get; set; } = false;

/// <summary>
Expand Down
4 changes: 1 addition & 3 deletions Content.Server/StationGoal/StationGoalPaperComponent.cs
Original file line number Diff line number Diff line change
Expand Up @@ -4,8 +4,6 @@ namespace Content.Server.StationGoal
/// Paper with a written station goal in it.
/// </summary>
[RegisterComponent]
public sealed partial class StationGoalPaperComponent : Component
{
}
public sealed partial class StationGoalPaperComponent : Component { }
}

20 changes: 7 additions & 13 deletions Content.Server/StationGoal/StationGoalPaperSystem.cs
Original file line number Diff line number Diff line change
Expand Up @@ -39,22 +39,16 @@ public override void Initialize()

private void OnRoundStarted(RoundStartedEvent ev)
{
if (_config.GetCVar(CCVars.StationGoalsEnabled))
{
if (_config.GetCVar(CCVars.StationGoalsRandomNoGoal) && _random.Prob(0.1f))
{
if (_random.Prob(0.1f))
SendRandomGoal();
}
else SendRandomGoal();
}
if (_config.GetCVar(CCVars.StationGoalsEnabled)
&& _random.Prob(_config.GetCVar(CCVars.StationGoalsChance)))
SendRandomGoal();
}

/// <summary>
/// Send a random station goal to all faxes which are authorized to receive it
/// </summary>
/// <returns>If the fax was successful</returns>
/// <exception cref="ConstraintException">Raised when station goal types in the prototype is invalid</exception>
/// <exception cref="Exception">Raised when station goal types in the prototype is invalid</exception>
public bool SendRandomGoal()
{
// Get the random station goal list
Expand All @@ -81,7 +75,7 @@ private StationGoalPrototype RecursiveRandom(WeightedRandomPrototype random)
if (_prototype.TryIndex<WeightedRandomPrototype>(goal, out var goalRandom))
return RecursiveRandom(goalRandom);

throw new Exception($"StationGoalPaperSystem: Random station goal could not be found from origin prototype {RandomPrototype}");
throw new Exception($"StationGoalPaperSystem: Random station goal could not be found from prototypes {RandomPrototype} and {random.ID}");
}

/// <summary>
Expand All @@ -95,8 +89,8 @@ public bool SendStationGoal(StationGoalPrototype goal)

while (enumerator.MoveNext(out var uid, out var fax))
{
if (!fax.ReceiveStationGoal ||
!TryComp<MetaDataComponent>(_station.GetOwningStation(uid), out var meta))
if (!fax.ReceiveStationGoal
|| !TryComp<MetaDataComponent>(_station.GetOwningStation(uid), out var meta))
continue;

var stationId = StationIdRegex.Match(meta.EntityName).Groups[1].Value;
Expand Down
6 changes: 3 additions & 3 deletions Content.Shared/CCVar/CCVars.cs
Original file line number Diff line number Diff line change
Expand Up @@ -2114,9 +2114,9 @@ public static readonly CVarDef<float>
CVarDef.Create("game.station_goals", true, CVar.SERVERONLY);

/// <summary>
/// If enabled, station goals have a 10% chance to not generate
/// Chance for a station goal to be sent
/// </summary>
public static readonly CVarDef<bool> StationGoalsRandomNoGoal =
CVarDef.Create("game.station_goals_random_none", false, CVar.SERVERONLY);
public static readonly CVarDef<float> StationGoalsChance =
CVarDef.Create("game.station_goals_chance", 0.1f, CVar.SERVERONLY);
}
}
4 changes: 2 additions & 2 deletions Resources/Prototypes/Entities/Objects/Misc/paper.yml
Original file line number Diff line number Diff line change
Expand Up @@ -258,8 +258,8 @@
- type: entity
parent: Paper
id: StationGoalPaper
name: station goal centcomm message
description: 'It looks like you have a lot of work to do.'
name: station goal
description: It looks like you have a lot of work to do.
components:
- type: Paper
stampState: paper_stamp-centcom
Expand Down
1 change: 1 addition & 0 deletions Resources/Prototypes/Objectives/goals.yml
Original file line number Diff line number Diff line change
Expand Up @@ -40,6 +40,7 @@
- type: stationGoal
id: Zoo


- type: weightedRandom
id: StationGoals
weights:
Expand Down

0 comments on commit a372209

Please sign in to comment.