fish-station/Content.Server/Arcade/BlockGame/BlockGameArcadeSystem.cs
Rinary 05aeb44b14
[RU] Полный перевод (#236)
* init

* fax translate

* translate

* translate cargo panel

* road map translate

* Fix cargo panel | fix bot craft translate

* fix, steal objectives translate

* do not break my not localized fax!

* fix

* radio guide translate

* Better DefaultRules

* Translate Criminal Records

* Space luw fully translate excluding CrimeList(need to rework)

* Some Guidebook translate

* Перевод глоссария, некоторые термины были переписанны под РУ комьюнити игры, некоторые к сожелению остались прежними

* Fix

* fix, translate

* Обновил структуру SpeakOnUIClosed, пофиксил перевод автоматов

* update and fix

* fully translate

* fix

* not fail but warn

* fix

* fix2

* фикс уже переведённого дерьма от корвахов

* Добавил термин подов в глоссарий

* roles translate fix

* Сикей в глоссарий

* Delete Resources/Locale/ru-RU/_sunrise/info/character-info.ftl

* remove cluster from pool

* new translation

* fully translate borgs

* some fixes

* Mr.Chang moment

* upd

* upd

* upd

* hotfix

* big fix

* fix some hardcode lang

* oh no shitcode language

* some translation

* some actions| admin commands translate start

* some new translation

* fully translate commands | figurines | chat-repo

* upd

* second upd

* upd

* start translating items

* some fixes

* translate wackpack

Из-за игры слов, я не смог нормально интерпритировать это дерьмо, так что пусть будет так, да теряется смысл и смешинка, но извините, я не смог как-то придумать игру слов

* translate

* debug translate

* upd

* Актуализация всего перевода

* fix

* fix

* upd

* some fixes | guns to his folders

* upd

* upd

* upd

* upd

* upd

* upd

* Перевод меток атмоса

* Последние коррективы

* fix

* some hardcode localization fix

* fix

* some fixes

* stats entry fully translate

* upd

* some fixes

* translate server side stats entry

* fix

* fix

* fix2

* fix

* upd

* upd

* fix

* holly shit

* fix

* totaly feed

* upd

* upd

* fix

* upd

* init

* upd

* upd

* access in prototypes

* Sunrise comments on code

* my bad

* я даун
2024-08-14 21:44:32 +03:00

116 lines
3.9 KiB
C#

using Content.Server.Power.Components;
using Content.Shared.UserInterface;
using Content.Server.Advertise;
using Content.Server.Advertise.Components;
using Content.Shared.Arcade;
using Robust.Server.GameObjects;
using Robust.Shared.Player;
namespace Content.Server.Arcade.BlockGame;
public sealed class BlockGameArcadeSystem : EntitySystem
{
[Dependency] private readonly UserInterfaceSystem _uiSystem = default!;
[Dependency] private readonly SpeakOnUIClosedSystem _speakOnUIClosed = default!;
public override void Initialize()
{
base.Initialize();
SubscribeLocalEvent<BlockGameArcadeComponent, ComponentInit>(OnComponentInit);
SubscribeLocalEvent<BlockGameArcadeComponent, AfterActivatableUIOpenEvent>(OnAfterUIOpen);
SubscribeLocalEvent<BlockGameArcadeComponent, PowerChangedEvent>(OnBlockPowerChanged);
Subs.BuiEvents<BlockGameArcadeComponent>(BlockGameUiKey.Key, subs =>
{
subs.Event<BoundUIClosedEvent>(OnAfterUiClose);
subs.Event<BlockGameMessages.BlockGamePlayerActionMessage>(OnPlayerAction);
});
}
public override void Update(float frameTime)
{
var query = EntityManager.EntityQueryEnumerator<BlockGameArcadeComponent>();
while (query.MoveNext(out var _, out var blockGame))
{
blockGame.Game?.GameTick(frameTime);
}
}
private void UpdatePlayerStatus(EntityUid uid, EntityUid actor, BlockGameArcadeComponent? blockGame = null)
{
if (!Resolve(uid, ref blockGame))
return;
_uiSystem.ServerSendUiMessage(uid, BlockGameUiKey.Key, new BlockGameMessages.BlockGameUserStatusMessage(blockGame.Player == actor), actor);
}
private void OnComponentInit(EntityUid uid, BlockGameArcadeComponent component, ComponentInit args)
{
component.Game = new(uid);
}
private void OnAfterUIOpen(EntityUid uid, BlockGameArcadeComponent component, AfterActivatableUIOpenEvent args)
{
if (component.Player == null)
component.Player = args.Actor;
else
component.Spectators.Add(args.Actor);
UpdatePlayerStatus(uid, args.Actor, component);
component.Game?.UpdateNewPlayerUI(args.Actor);
}
private void OnAfterUiClose(EntityUid uid, BlockGameArcadeComponent component, BoundUIClosedEvent args)
{
if (component.Player != args.Actor)
{
component.Spectators.Remove(args.Actor);
UpdatePlayerStatus(uid, args.Actor, blockGame: component);
return;
}
var temp = component.Player;
if (component.Spectators.Count > 0)
{
component.Player = component.Spectators[0];
component.Spectators.Remove(component.Player.Value);
UpdatePlayerStatus(uid, component.Player.Value, blockGame: component);
}
UpdatePlayerStatus(uid, temp.Value, blockGame: component);
}
private void OnBlockPowerChanged(EntityUid uid, BlockGameArcadeComponent component, ref PowerChangedEvent args)
{
if (args.Powered)
return;
_uiSystem.CloseUi(uid, BlockGameUiKey.Key);
component.Player = null;
component.Spectators.Clear();
}
private void OnPlayerAction(EntityUid uid, BlockGameArcadeComponent component, BlockGameMessages.BlockGamePlayerActionMessage msg)
{
if (component.Game == null)
return;
if (!BlockGameUiKey.Key.Equals(msg.UiKey))
return;
if (msg.Actor != component.Player)
return;
if (msg.PlayerAction == BlockGamePlayerAction.NewGame)
{
if (component.Game.Started == true)
component.Game = new(uid);
component.Game.StartGame();
return;
}
if (TryComp<SpeakOnUIClosedComponent>(uid, out var speakComponent))
_speakOnUIClosed.TrySetFlag(uid, speakComponent);
component.Game.ProcessInput(msg.PlayerAction);
}
}