* 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 * я даун
65 lines
No EOL
2.3 KiB
C#
65 lines
No EOL
2.3 KiB
C#
using Content.Server.Advertise.Components;
|
|
using Content.Server.Chat.Systems;
|
|
using Content.Shared.Dataset;
|
|
using Robust.Shared.Log;
|
|
using Robust.Shared.Prototypes;
|
|
using Robust.Shared.Random;
|
|
using Robust.Shared.GameObjects;
|
|
using Robust.Shared.IoC;
|
|
using ActivatableUIComponent = Content.Shared.UserInterface.ActivatableUIComponent;
|
|
|
|
namespace Content.Server.Advertise
|
|
{
|
|
public sealed partial class SpeakOnUIClosedSystem : EntitySystem
|
|
{
|
|
[Dependency] private readonly IRobustRandom _random = default!;
|
|
[Dependency] private readonly IPrototypeManager _prototypeManager = default!;
|
|
[Dependency] private readonly ChatSystem _chat = default!;
|
|
|
|
public override void Initialize()
|
|
{
|
|
base.Initialize();
|
|
SubscribeLocalEvent<SpeakOnUIClosedComponent, BoundUIClosedEvent>(OnBoundUIClosed);
|
|
}
|
|
|
|
private void OnBoundUIClosed(EntityUid uid, SpeakOnUIClosedComponent component, BoundUIClosedEvent args)
|
|
{
|
|
if (!TryComp<ActivatableUIComponent>(uid, out var activatable) || !args.UiKey.Equals(activatable.Key))
|
|
return;
|
|
|
|
if (component.RequireFlag && !component.Flag)
|
|
return;
|
|
|
|
TrySpeak(uid, component);
|
|
}
|
|
|
|
public bool TrySpeak(EntityUid uid, SpeakOnUIClosedComponent? component)
|
|
{
|
|
if (component == null || !component.Enabled)
|
|
return false;
|
|
|
|
if (!_prototypeManager.TryIndex(component.Pack, out LocalizedDatasetPrototype? messagePack))
|
|
{
|
|
Logger.Warning($"Failed to find localized dataset prototype with ID: {component.Pack}");
|
|
return false;
|
|
}
|
|
|
|
var messageKey = _random.Pick(messagePack.Values);
|
|
var message = Loc.GetString(messageKey, ("name", Name(uid)));
|
|
|
|
//Logger.Info($"Localized message: {message}, messageKey: {messageKey}");
|
|
_chat.TrySendInGameICMessage(uid, message, InGameICChatType.Speak, true);
|
|
component.Flag = false;
|
|
return true;
|
|
}
|
|
|
|
public bool TrySetFlag(EntityUid uid, SpeakOnUIClosedComponent? component, bool value = true)
|
|
{
|
|
if (component == null)
|
|
return false;
|
|
|
|
component.Flag = value;
|
|
return true;
|
|
}
|
|
}
|
|
} |