Skip to content

Commit

Permalink
round flow and oligarchy
Browse files Browse the repository at this point in the history
  • Loading branch information
DEATHB4DEFEAT committed Dec 17, 2023
1 parent 2893095 commit d2c964d
Show file tree
Hide file tree
Showing 8 changed files with 68 additions and 21 deletions.
2 changes: 1 addition & 1 deletion Content.Server/Corvax/GameTicking/RoundEndedEvent.cs
Original file line number Diff line number Diff line change
@@ -1,4 +1,4 @@
namespace Content.Shared.GameTicking;
namespace Content.Server.Corvax.GameTicking;

public sealed class RoundEndedEvent : EntityEventArgs
{
Expand Down
4 changes: 2 additions & 2 deletions Content.Server/Corvax/GameTicking/RoundStartedEvent.cs
Original file line number Diff line number Diff line change
@@ -1,9 +1,9 @@
namespace Content.Shared.GameTicking;
namespace Content.Server.Corvax.GameTicking;

public sealed class RoundStartedEvent : EntityEventArgs
{
public int RoundId { get; }

public RoundStartedEvent(int roundId)
{
RoundId = roundId;
Expand Down
1 change: 1 addition & 0 deletions Content.Server/Corvax/StationGoal/StationGoalCommand.cs
Original file line number Diff line number Diff line change
Expand Up @@ -43,6 +43,7 @@ public CompletionResult GetCompletion(IConsoleShell shell, string[] args)
{
var options = IoCManager.Resolve<IPrototypeManager>()
.EnumeratePrototypes<StationGoalPrototype>()
.OrderBy(p => p.ID)
.Select(p => new CompletionOption(p.ID));

return CompletionResult.FromHintOptions(options, Loc.GetString("send-station-goal-command-arg-id"));
Expand Down
27 changes: 12 additions & 15 deletions Content.Server/Corvax/StationGoal/StationGoalPaperSystem.cs
Original file line number Diff line number Diff line change
@@ -1,9 +1,9 @@
using System.Data;
using System.Text.RegularExpressions;
using Content.Server.Corvax.GameTicking;
using Content.Server.Fax;
using Content.Server.Station.Systems;
using Content.Shared.Corvax.CCCVars;
using Content.Shared.GameTicking;
using Content.Shared.Random;
using Content.Shared.Random.Helpers;
using Robust.Shared.Configuration;
Expand All @@ -13,9 +13,9 @@
namespace Content.Server.Corvax.StationGoal;

/// <summary>
/// System to spawn paper with station goal.
/// System for station goals
/// </summary>
public sealed partial class StationGoalPaperSystem : EntitySystem
public sealed class StationGoalPaperSystem : EntitySystem
{
[Dependency] private readonly IPrototypeManager _prototype = default!;
[Dependency] private readonly IRobustRandom _random = default!;
Expand All @@ -27,19 +27,19 @@ public sealed partial class StationGoalPaperSystem : EntitySystem

private const string RandomPrototype = "StationGoals";


public override void Initialize()
{
base.Initialize();

SubscribeLocalEvent<RoundStartedEvent>(OnRoundStarted);
}


private void OnRoundStarted(RoundStartedEvent ev)
{
if (_config.GetCVar(CCCVars.StationGoalsEnabled) != true)
return;

SendRandomGoal();
if (_config.GetCVar(CCCVars.StationGoalsEnabled))
SendRandomGoal();
}

/// <summary>
Expand All @@ -51,7 +51,10 @@ public bool SendRandomGoal()
{
// Get the random station goal list
if (!_prototype.TryIndex<WeightedRandomPrototype>(RandomPrototype, out var goals))
{
Log.Error($"StationGoalPaperSystem: Random station goal prototype '{RandomPrototype}' not found");
return false;
}

// Get a random goal
var goal = RecursiveRandom(goals);
Expand All @@ -65,14 +68,10 @@ private StationGoalPrototype RecursiveRandom(WeightedRandomPrototype random)
var goal = random.Pick(_random);

if (_prototype.TryIndex<StationGoalPrototype>(goal, out var goalPrototype))
{
return goalPrototype;
}

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}");
}
Expand All @@ -88,10 +87,8 @@ public bool SendStationGoal(StationGoalPrototype goal)

while (enumerator.MoveNext(out var uid, out var fax))
{
if (!fax.ReceiveStationGoal)
continue;

if (!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
3 changes: 3 additions & 0 deletions Content.Server/GameTicking/GameTicker.RoundFlow.cs
Original file line number Diff line number Diff line change
@@ -1,5 +1,6 @@
using System.Linq;
using Content.Server.Announcements;
using Content.Server.Corvax.GameTicking;
using Content.Server.Discord;
using Content.Server.GameTicking.Events;
using Content.Server.Ghost;
Expand Down Expand Up @@ -252,6 +253,7 @@ public void StartRound(bool force = false)
AnnounceRound();
UpdateInfoText();
SendRoundStartedDiscordMessage();
RaiseLocalEvent(new RoundStartedEvent(RoundId)); // Corvax-RoundFlow

#if EXCEPTION_TOLERANCE
}
Expand Down Expand Up @@ -388,6 +390,7 @@ public void ShowRoundEndScoreboard(string text = "")
RaiseNetworkEvent(new RoundEndMessageEvent(gamemodeTitle, roundEndText, roundDuration, RoundId,
listOfPlayerInfoFinal.Length, listOfPlayerInfoFinal, LobbySong,
new SoundCollectionSpecifier("RoundEnd").GetSound()));
RaiseLocalEvent(new RoundEndedEvent(RoundId, roundDuration)); // Corvax-RoundFlow
}

private async void SendRoundEndDiscordMessage()
Expand Down
48 changes: 47 additions & 1 deletion Resources/Prototypes/Corvax/Objectives/goals.yml
Original file line number Diff line number Diff line change
Expand Up @@ -32,10 +32,56 @@
id: Combat

- type: stationGoal
id: SpaceArtifacts
id: Artifacts

- type: stationGoal
id: Labor

- type: stationGoal
id: Lectures



- type: weightedRandom
id: StationGoals
weights:
StationGoalDepartment: 1
StationGoalPower: 1
StationGoalStation: 1


- type: weightedRandom
id: StationGoalDepartment
weights:
StationGoalScience: 1
StationGoalSecurity: 1


- type: weightedRandom
id: StationGoalPower
weights:
Singularity: 1
SolarPanels: 1

- type: weightedRandom
id: StationGoalScience
weights:
Anomalies: 1
Artifacts: 1
Xeno: 1

- type: weightedRandom
id: StationGoalSecurity
weights:
Combat: 1

- type: weightedRandom
id: StationGoalStation
weights:
Area: 1
BureaucraticError: 1
Labor: 1
Lectures: 1
Museum: 1
Shuttle: 1
Zoo: 1
Original file line number Diff line number Diff line change
Expand Up @@ -99,10 +99,10 @@
- type: entity
parent: FaxMachineBase
id: FaxMachineCaptain
name: captain long range fax machine
name: command long range fax machine # Parkstation-Oligarchy
suffix: NukeCodes
components:
- type: FaxMachine
name: "Captain's Office"
name: "Command" # Parkstation-Oligarchy
receiveNukeCodes: true
receiveStationGoal: true # Corvax-StationGoal

0 comments on commit d2c964d

Please sign in to comment.