forked from DeltaV-Station/Delta-v
-
Notifications
You must be signed in to change notification settings - Fork 16
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
- Loading branch information
Showing
6,671 changed files
with
4,501,882 additions
and
9,951 deletions.
The diff you're trying to view is too large. We only load the first 3000 changed files.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -1,4 +1,5 @@ | ||
{ | ||
"omnisharp.analyzeOpenDocumentsOnly": true, | ||
"dotnet.defaultSolution": "SpaceStation14.sln" | ||
"dotnet.defaultSolution": "SpaceStation14.sln", | ||
"dotnet.preferCSharpExtension": true | ||
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,13 @@ | ||
namespace Content.Server.Corvax.GameTicking; | ||
|
||
public sealed class RoundEndedEvent : EntityEventArgs | ||
{ | ||
public int RoundId { get; } | ||
public TimeSpan RoundDuration { get; } | ||
|
||
public RoundEndedEvent(int roundId, TimeSpan roundDuration) | ||
{ | ||
RoundId = roundId; | ||
RoundDuration = roundDuration; | ||
} | ||
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,11 @@ | ||
namespace Content.Server.Corvax.GameTicking; | ||
|
||
public sealed class RoundStartedEvent : EntityEventArgs | ||
{ | ||
public int RoundId { get; } | ||
|
||
public RoundStartedEvent(int roundId) | ||
{ | ||
RoundId = roundId; | ||
} | ||
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,55 @@ | ||
using System.Linq; | ||
using Content.Server.Administration; | ||
using Content.Shared.Administration; | ||
using Robust.Shared.Console; | ||
using Robust.Shared.Prototypes; | ||
|
||
namespace Content.Server.Corvax.StationGoal | ||
{ | ||
[AdminCommand(AdminFlags.Fun)] | ||
public sealed class StationGoalCommand : IConsoleCommand | ||
{ | ||
public string Command => "sendstationgoal"; | ||
public string Description => Loc.GetString("send-station-goal-command-description"); | ||
public string Help => Loc.GetString("send-station-goal-command-help-text", ("command", Command)); | ||
|
||
public void Execute(IConsoleShell shell, string argStr, string[] args) | ||
{ | ||
if (args.Length != 1) | ||
{ | ||
shell.WriteError(Loc.GetString("shell-need-exactly-one-argument")); | ||
return; | ||
} | ||
|
||
var protoId = args[0]; | ||
var prototypeManager = IoCManager.Resolve<IPrototypeManager>(); | ||
if (!prototypeManager.TryIndex<StationGoalPrototype>(protoId, out var proto)) | ||
{ | ||
shell.WriteError(Loc.GetString("send-station-goal-command-error-no-goal-proto", ("id", protoId))); | ||
return; | ||
} | ||
|
||
var stationGoalPaper = IoCManager.Resolve<IEntityManager>().System<StationGoalPaperSystem>(); | ||
if (!stationGoalPaper.SendStationGoal(proto)) | ||
{ | ||
shell.WriteError(Loc.GetString("send-station-goal-command-error-couldnt-fax")); | ||
return; | ||
} | ||
} | ||
|
||
public CompletionResult GetCompletion(IConsoleShell shell, string[] args) | ||
{ | ||
if (args.Length == 1) | ||
{ | ||
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")); | ||
} | ||
|
||
return CompletionResult.Empty; | ||
} | ||
} | ||
} |
10 changes: 10 additions & 0 deletions
10
Content.Server/Corvax/StationGoal/StationGoalPaperComponent.cs
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,10 @@ | ||
namespace Content.Server.Corvax.StationGoal | ||
{ | ||
/// <summary> | ||
/// Paper with a written station goal in it. | ||
/// </summary> | ||
[RegisterComponent] | ||
public sealed partial class StationGoalPaperComponent : Component | ||
{ | ||
} | ||
} |
113 changes: 113 additions & 0 deletions
113
Content.Server/Corvax/StationGoal/StationGoalPaperSystem.cs
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,113 @@ | ||
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.Random; | ||
using Content.Shared.Random.Helpers; | ||
using Robust.Shared.Configuration; | ||
using Robust.Shared.Prototypes; | ||
using Robust.Shared.Random; | ||
|
||
namespace Content.Server.Corvax.StationGoal; | ||
|
||
/// <summary> | ||
/// System for station goals | ||
/// </summary> | ||
public sealed class StationGoalPaperSystem : EntitySystem | ||
{ | ||
[Dependency] private readonly IPrototypeManager _prototype = default!; | ||
[Dependency] private readonly IRobustRandom _random = default!; | ||
[Dependency] private readonly FaxSystem _fax = default!; | ||
[Dependency] private readonly IConfigurationManager _config = default!; | ||
[Dependency] private readonly StationSystem _station = default!; | ||
|
||
private static readonly Regex StationIdRegex = new(@".*-(\d+)$"); | ||
|
||
private const string RandomPrototype = "StationGoals"; | ||
|
||
|
||
public override void Initialize() | ||
{ | ||
base.Initialize(); | ||
|
||
SubscribeLocalEvent<RoundStartedEvent>(OnRoundStarted); | ||
} | ||
|
||
|
||
private void OnRoundStarted(RoundStartedEvent ev) | ||
{ | ||
if (_config.GetCVar(CCCVars.StationGoalsEnabled)) | ||
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> | ||
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); | ||
|
||
// Send the goal | ||
return SendStationGoal(goal); | ||
} | ||
|
||
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}"); | ||
} | ||
|
||
/// <summary> | ||
/// Send a station goal to all faxes which are authorized to receive it | ||
/// </summary> | ||
/// <returns>True if at least one fax received paper</returns> | ||
public bool SendStationGoal(StationGoalPrototype goal) | ||
{ | ||
var enumerator = EntityManager.EntityQueryEnumerator<FaxMachineComponent>(); | ||
var wasSent = false; | ||
|
||
while (enumerator.MoveNext(out var uid, out var fax)) | ||
{ | ||
if (!fax.ReceiveStationGoal || | ||
!TryComp<MetaDataComponent>(_station.GetOwningStation(uid), out var meta)) | ||
continue; | ||
|
||
var stationId = StationIdRegex.Match(meta.EntityName).Groups[1].Value; | ||
|
||
var printout = new FaxPrintout( | ||
Loc.GetString("station-goal-fax-paper-header", | ||
("date", DateTime.Now.AddYears(1000).ToString("yyyy MMMM dd")), | ||
("station", string.IsNullOrEmpty(stationId) ? "???" : stationId), | ||
("content", goal.Text) | ||
), | ||
Loc.GetString("station-goal-fax-paper-name"), | ||
"StationGoalPaper" | ||
); | ||
|
||
_fax.Receive(uid, printout, null, fax); | ||
|
||
wasSent = true; | ||
} | ||
|
||
return wasSent; | ||
} | ||
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,12 @@ | ||
using Robust.Shared.Prototypes; | ||
|
||
namespace Content.Server.Corvax.StationGoal | ||
{ | ||
[Serializable, Prototype("stationGoal")] | ||
public sealed class StationGoalPrototype : IPrototype | ||
{ | ||
[IdDataFieldAttribute] public string ID { get; } = default!; | ||
|
||
public string Text => Loc.GetString($"station-goal-{ID.ToLower()}"); | ||
} | ||
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
9 changes: 9 additions & 0 deletions
9
Content.Server/SimpleStation14/Clothing/Components/DeleteOnEquipComponent.cs
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,9 @@ | ||
namespace Content.Server.SimpleStation14.Clothing | ||
{ | ||
[RegisterComponent] | ||
public sealed partial class DeleteOnEquipComponent : Component | ||
{ | ||
[DataField("onEquip")] | ||
public bool OnEquip = true; | ||
} | ||
} |
23 changes: 23 additions & 0 deletions
23
Content.Server/SimpleStation14/Clothing/Components/DeleteOnEquipComponentSystem.cs
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,23 @@ | ||
using Content.Shared.Inventory.Events; | ||
|
||
namespace Content.Server.SimpleStation14.Clothing; | ||
|
||
public sealed class DeleteOnEquipSystem : EntitySystem | ||
{ | ||
public override void Initialize() | ||
{ | ||
base.Initialize(); | ||
SubscribeLocalEvent<DeleteOnEquipComponent, GotEquippedEvent>(OnEquip); | ||
SubscribeLocalEvent<DeleteOnEquipComponent, GotUnequippedEvent>(OnUnequip); | ||
} | ||
|
||
private void OnEquip(EntityUid uid, DeleteOnEquipComponent component, GotEquippedEvent args) | ||
{ | ||
if (component.OnEquip == true) QueueDel(args.Equipment); | ||
} | ||
|
||
private void OnUnequip(EntityUid uid, DeleteOnEquipComponent component, GotUnequippedEvent args) | ||
{ | ||
if (component.OnEquip == false) QueueDel(args.Equipment); | ||
} | ||
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Oops, something went wrong.