Skip to content

Commit

Permalink
Merge pull request DeltaV-Station#2 from EndrAnimet/тест
Browse files Browse the repository at this point in the history
тест
  • Loading branch information
GeneralGaws authored May 2, 2024
2 parents 7167855 + c48f17f commit 37b74a6
Show file tree
Hide file tree
Showing 1,098 changed files with 8,524 additions and 503 deletions.
44 changes: 6 additions & 38 deletions .github/PULL_REQUEST_TEMPLATE.md
Original file line number Diff line number Diff line change
@@ -1,43 +1,11 @@
<!-- Please read these guidelines before opening your PR: https://docs.spacestation14.io/en/getting-started/pr-guideline -->
<!-- The text between the arrows are comments - they will not be visible on your PR. -->

## About the PR
<!-- What did you change in this PR? -->
## О чем PR

## Why / Balance
<!-- Why was it changed? Link any discussions or issues here. Please discuss how this would affect game balance. -->
## Почему

## Technical details
<!-- If this is a code change, summarize at high level how your new code works. This makes it easier to review. -->
## Технические детали

## Media
<!--
PRs which make ingame changes (adding clothing, items, new features, etc) are required to have media attached that showcase the changes.
Small fixes/refactors are exempt.
Any media may be used in SS14 progress reports, with clear credit given.
## Медиа

If you're unsure whether your PR will require media, ask a maintainer.
Check the box below to confirm that you have in fact seen this (put an X in the brackets, like [X]):
-->

- [ ] I have added screenshots/videos to this PR showcasing its changes ingame, **or** this PR does not require an ingame showcase

## Breaking changes
<!--
List any breaking changes, including namespace, public class/method/field changes, prototype renames; and provide instructions for fixing them. This will be pasted in #codebase-changes.
-->

**Changelog**
<!--
Make players aware of new features and changes that could affect how they play the game by adding a Changelog entry. Please read the Changelog guidelines located at: https://docs.spacestation14.io/en/getting-started/pr-guideline#changelog
-->

<!--
Make sure to take this Changelog template out of the comment block in order for it to show up.
:cl:
- add: Added fun!
- remove: Removed fun!
- tweak: Changed fun!
- fix: Fixed fun!
-->
- [ ] Я добавил скриншот/видео, показывающее изменения в игре **или** PR не нуждается в показе
- [ ] Я проверил изменения на предмет багов
1 change: 1 addition & 0 deletions Content.Client/Entry/EntryPoint.cs
Original file line number Diff line number Diff line change
Expand Up @@ -119,6 +119,7 @@ public override void Init()
_prototypeManager.RegisterIgnore("alertLevels");
_prototypeManager.RegisterIgnore("nukeopsRole");
_prototypeManager.RegisterIgnore("candyFlavor"); // Delta-V
_prototypeManager.RegisterIgnore("stationGoal");

_componentFactory.GenerateNetIds();
_adminManager.Initialize();
Expand Down
13 changes: 13 additions & 0 deletions Content.Server/Corvax/GameTicking/RoundEndedEvent.cs
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;
}
}
11 changes: 11 additions & 0 deletions Content.Server/Corvax/GameTicking/RoundStartedEvent.cs
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;
}
}
55 changes: 55 additions & 0 deletions Content.Server/Corvax/StationGoal/StationGoalCommand.cs
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 Content.Server/Corvax/StationGoal/StationGoalPaperComponent.cs
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 Content.Server/Corvax/StationGoal/StationGoalPaperSystem.cs
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;
}
}
12 changes: 12 additions & 0 deletions Content.Server/Corvax/StationGoal/StationGoalPrototype.cs
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()}");
}
}
4 changes: 4 additions & 0 deletions Content.Server/Fax/FaxMachineComponent.cs
Original file line number Diff line number Diff line change
Expand Up @@ -51,6 +51,10 @@ public sealed partial class FaxMachineComponent : Component
[DataField("receiveNukeCodes")]
public bool ReceiveNukeCodes { get; set; } = false;

[ViewVariables(VVAccess.ReadWrite)]
[DataField("receiveStationGoal")]
public bool ReceiveStationGoal { get; set; } = false;

/// <summary>
/// Sound to play when fax has been emagged
/// </summary>
Expand Down
15 changes: 9 additions & 6 deletions Content.Server/Speech/EntitySystems/BarkAccentSystem.cs
Original file line number Diff line number Diff line change
Expand Up @@ -8,15 +8,17 @@ public sealed class BarkAccentSystem : EntitySystem
[Dependency] private readonly IRobustRandom _random = default!;

private static readonly IReadOnlyList<string> Barks = new List<string>{
" Woof!", " WOOF", " wof-wof"
" Гав!", " ГАВ", " вуф-вуф" // Corvax-Localization
}.AsReadOnly();

private static readonly IReadOnlyDictionary<string, string> SpecialWords = new Dictionary<string, string>()
{
{ "ah", "arf" },
{ "Ah", "Arf" },
{ "oh", "oof" },
{ "Oh", "Oof" },
//Corvax-Localization-Start
{ "га", "гаф" },
{ "Га", "Гаф" },
{ "угу", "вуф" },
{ "Угу", "Вуф" },
//Corvax-Localization-End
};

public override void Initialize()
Expand All @@ -32,7 +34,8 @@ public string Accentuate(string message)
}

return message.Replace("!", _random.Pick(Barks))
.Replace("l", "r").Replace("L", "R");
.Replace("l", "r").Replace("L", "R")
.Replace("л", "р").Replace("Л", "Р");
}

private void OnAccent(EntityUid uid, BarkAccentComponent component, AccentGetEvent args)
Expand Down
12 changes: 11 additions & 1 deletion Content.Server/Speech/EntitySystems/FrontalLispSystem.cs
Original file line number Diff line number Diff line change
@@ -1,11 +1,13 @@
using System.Text.RegularExpressions;
using Content.Server.Speech.Components;
using Robust.Shared.Random; // Corvax-Localization

namespace Content.Server.Speech.EntitySystems;

public sealed class FrontalLispSystem : EntitySystem
{
public override void Initialize()
[Dependency] private readonly IRobustRandom _random = default!; // Corvax-Localization
public override void Initialize()
{
base.Initialize();
SubscribeLocalEvent<FrontalLispComponent, AccentGetEvent>(OnAccent);
Expand All @@ -21,6 +23,14 @@ private void OnAccent(EntityUid uid, FrontalLispComponent component, AccentGetEv
// handles ex(c), x
message = Regex.Replace(message, @"[E]+[Xx]+[Cc]*|[X]+", "EKTH");
message = Regex.Replace(message, @"[e]+[x]+[c]*|[x]+", "ekth");
// Corvax-Localization Start
// с, в, ч, т in ф or ш
message = Regex.Replace(message, @"\B[СВЧТ]\B", _random.Prob(0.5f) ? "Ф" : "Ш");
message = Regex.Replace(message, @"\B[свчт]\B", _random.Prob(0.5f) ? "ф" : "ш");
// д in ф
message = Regex.Replace(message, @"\b[Д](?![ИЕЁЮЯЬ])\b|\B[Д]\B", "Ф");
message = Regex.Replace(message, @"\b[Дд](?![ИиЕеЁёЮюЯяЬь])\b|\B[Дд]\B", "ф");
// Corvax-Localization End

args.Message = message;
}
Expand Down
Loading

0 comments on commit 37b74a6

Please sign in to comment.