* Локализация (#746) * Правка мелочей * Имя клоуну * Перевод оповещений для РНД * перевод занавесок * перевод столов * Перевод и обновление кода гипоспрея для боргов (#745) * Я только хотел перевести... * refactor * ещё перевод * Revert "refactor" This reverts commit 355c2724c4ed9cd1357661e3ba889a88bdf17db7. * инверсия условия для проверки наличия прототипа * Больше вещей в пояса охраны (#748) * Подкрутки и докрутки (#749) * Добавил отображение защиты от горения и подправил описание защиты от взрывов (#747) * Добавил отображение защиты от горения * Update Content.Shared/Clothing/EntitySystems/FireProtectionSystem.cs Co-authored-by: ThereDrD <88589686+ThereDrD0@users.noreply.github.com> * Update Resources/Locale/ru-RU/_white/info/fire-protection.ftl Co-authored-by: ThereDrD <88589686+ThereDrD0@users.noreply.github.com> * Правки * негативный ноль с плавающей точкой --------- Co-authored-by: ThereDrD <88589686+ThereDrD0@users.noreply.github.com> * Фикс текстурок внешних шлюзов (#751) * Микромелочь * Ещё одна мелочь * Починка прозрачности * Ребаланс РНД (#750) * Третий тир больше нас не остановит * More less * Ребаланс * правочки подправочки * СКОРАЯ!!! ПОМОГИТЕ!!! * Конфета или жизнь (#757) * Конфета или жизнь * gremlins invasion * Я ДОБАВИЛ БОЛЬШЕ МУСОРА НА СТАНЦИЮ!!! * Переводы (много) (#755) * Перевод технологий РНД * Перевод действий поглаживающего характера * Целая куча мелочей * Ещё больше мелочей * Слишком много мелочей * маленькая мелочь * unshit some ftl shit * [Tweak] Random updates (#760) * Security random updates * Engineering random updates * ERT random updates * Really random * Important random update --------- Co-authored-by: BIGZi0348 <118811750+BIGZi0348@users.noreply.github.com> Co-authored-by: ThereDrD <88589686+ThereDrD0@users.noreply.github.com> Co-authored-by: keslik <114428094+keslik1313@users.noreply.github.com>
135 lines
4.9 KiB
C#
135 lines
4.9 KiB
C#
using Content.Shared.Chemistry.EntitySystems;
|
|
using Content.Server.Chemistry.EntitySystems;
|
|
using Content.Server.Popups;
|
|
using Content.Shared.Examine;
|
|
using Content.Shared.Interaction.Events;
|
|
using Content.Shared.Verbs;
|
|
using Robust.Shared.Timing;
|
|
using Robust.Shared.Prototypes;
|
|
|
|
namespace Content.Server._White.AutoRegenReagent
|
|
{
|
|
/// <summary>
|
|
/// So we have a solution name in AutoRegenReagent comp. We will try to get it and start generating reagents. When we switch reagents we clear the solution and start generating different reagent.
|
|
/// </summary>
|
|
public sealed class AutoRegenReagentSystem : EntitySystem
|
|
{
|
|
[Dependency] private readonly SharedSolutionContainerSystem _solutionSystem = default!;
|
|
[Dependency] private readonly PopupSystem _popups = default!;
|
|
[Dependency] private readonly IGameTiming _timing = default!;
|
|
[Dependency] private readonly IPrototypeManager _prototypeManager = default!;
|
|
|
|
public override void Initialize()
|
|
{
|
|
base.Initialize();
|
|
|
|
SubscribeLocalEvent<AutoRegenReagentComponent, ComponentInit>(OnCompInit);
|
|
SubscribeLocalEvent<AutoRegenReagentComponent, GetVerbsEvent<AlternativeVerb>>(AddSwitchVerb);
|
|
SubscribeLocalEvent<AutoRegenReagentComponent, ExaminedEvent>(OnExamined);
|
|
SubscribeLocalEvent<AutoRegenReagentComponent, UseInHandEvent>(OnUseInHand,
|
|
before: new[] { typeof(ChemistrySystem) });
|
|
}
|
|
|
|
public override void Update(float frameTime)
|
|
{
|
|
base.Update(frameTime);
|
|
var query = EntityQueryEnumerator<AutoRegenReagentComponent>();
|
|
while (query.MoveNext(out var uid, out var autoComp))
|
|
{
|
|
if (_timing.CurTime < autoComp.NextUpdate)
|
|
return;
|
|
|
|
autoComp.NextUpdate += autoComp.Interval;
|
|
|
|
if (autoComp.Solution == null)
|
|
TryGetSolution(uid, autoComp);
|
|
|
|
if (autoComp.Solution == null)
|
|
return;
|
|
|
|
_solutionSystem.TryAddReagent(autoComp.Solution.Value, autoComp.CurrentReagent, autoComp.UnitsPerInterval, out _);
|
|
}
|
|
}
|
|
|
|
private void OnCompInit(EntityUid uid, AutoRegenReagentComponent component, ComponentInit args)
|
|
{
|
|
component.NextUpdate = _timing.CurTime + component.Interval;
|
|
SwitchReagent(component);
|
|
}
|
|
|
|
private void OnUseInHand(EntityUid uid, AutoRegenReagentComponent component, UseInHandEvent args)
|
|
{
|
|
if (args.Handled)
|
|
return;
|
|
|
|
if (component.Reagents.Count <= 1)
|
|
return;
|
|
|
|
SwitchReagent(component, args.User);
|
|
args.Handled = true;
|
|
}
|
|
|
|
private void OnExamined(EntityUid uid, AutoRegenReagentComponent component, ExaminedEvent args)
|
|
{
|
|
if (_prototypeManager.TryIndex(component.CurrentReagent, out var reagentProto))
|
|
args.PushMarkup(Loc.GetString("reagent-name", ("reagent", reagentProto.LocalizedName)));
|
|
}
|
|
|
|
private void AddSwitchVerb(EntityUid uid, AutoRegenReagentComponent component,
|
|
GetVerbsEvent<AlternativeVerb> args)
|
|
{
|
|
if (!args.CanInteract || !args.CanAccess)
|
|
return;
|
|
|
|
if (component.Reagents.Count <= 1)
|
|
return;
|
|
|
|
AlternativeVerb verb = new()
|
|
{
|
|
Act = () =>
|
|
{
|
|
SwitchReagent(component, args.User);
|
|
},
|
|
Text = Loc.GetString("autoreagent-switch"),
|
|
Priority = 2
|
|
};
|
|
args.Verbs.Add(verb);
|
|
}
|
|
|
|
private void TryGetSolution(EntityUid uid, AutoRegenReagentComponent component)
|
|
{
|
|
if (component.SolutionName == null)
|
|
return;
|
|
|
|
if (!_solutionSystem.TryGetSolution(uid, component.SolutionName, out var solution))
|
|
return;
|
|
|
|
component.Solution = solution;
|
|
|
|
component.CurrentReagent = component.Reagents[component.CurrentIndex];
|
|
}
|
|
|
|
private void SwitchReagent(AutoRegenReagentComponent component, EntityUid? user = null)
|
|
{
|
|
if (component.CurrentIndex + 1 == component.Reagents.Count)
|
|
component.CurrentIndex = 0;
|
|
else
|
|
component.CurrentIndex++;
|
|
|
|
if (component.Solution != null)
|
|
_solutionSystem.RemoveAllSolution(component.Solution.Value);
|
|
|
|
component.CurrentReagent = component.Reagents[component.CurrentIndex];
|
|
|
|
if (user == null)
|
|
return;
|
|
|
|
if (!_prototypeManager.TryIndex(component.CurrentReagent, out var reagentProto))
|
|
return;
|
|
|
|
_popups.PopupEntity(Loc.GetString("autoregen-switched", ("reagent", reagentProto.LocalizedName)), user.Value, user.Value);
|
|
|
|
}
|
|
}
|
|
}
|