* Refactor pacified block logic to action system Moved pacified block functionality from magic spell components to the new CP14ActionSystem and related components. Removed CP14MagicEffectPacifiedBlockComponent and its logic, and introduced CP14ActionDangerousComponent for handling pacified checks. Updated examine and checks logic to use the new action-based components, improving separation of concerns between magic and action systems. * finish pacified * mobtargetstate refactor * skillpoint cost refactor * somaticAspect refactor * material cost refactor * mana cost now * stamina cost * SSD + verbal aspect * religion * music tool refactor * vampire * get rid of this event * manacost refac * Remove magicType field from spell definitions Eliminated the 'magicType' property from all CP14MagicEffect components in spell YAML files across Electric, Fire, Life, Light, and Water categories. This streamlines spell configuration and may reflect a change in how magic types are handled in the system. * Remove mana cost reduction effects from skill tiers Eliminated the ModifyManacost effects from tier 2 and tier 3 skills in electromancy, healing, hydrosophistry, illusion, and pyrokinetic. This change standardizes skill progression and may be part of a balance update to mana cost mechanics. * comment out T3 tiers * namespace refactor * fix hands
162 lines
5.6 KiB
C#
162 lines
5.6 KiB
C#
using Content.Server.GameTicking;
|
||
using Content.Shared.CCVar;
|
||
using Robust.Shared.Audio;
|
||
using Robust.Shared.Console;
|
||
|
||
namespace Content.Server._CP14.RoundEnd;
|
||
|
||
public sealed partial class CP14RoundEndSystem
|
||
{
|
||
[Dependency] private readonly IConsoleHost _consoleHost = default!;
|
||
[Dependency] private readonly GameTicker _ticker = default!;
|
||
|
||
private TimeSpan _nextUpdateTime = TimeSpan.Zero;
|
||
private readonly TimeSpan _updateFrequency = TimeSpan.FromSeconds(60f);
|
||
|
||
private bool _enabled;
|
||
|
||
private void InitCbt()
|
||
{
|
||
_enabled = _cfg.GetCVar(CCVars.CP14ClosedBetaTest);
|
||
_cfg.OnValueChanged(CCVars.CP14ClosedBetaTest,
|
||
_ => { _enabled = _cfg.GetCVar(CCVars.CP14ClosedBetaTest); },
|
||
true);
|
||
}
|
||
|
||
// Вы можете сказать: Эд, ты ебанулся? Это же лютый щиткод!
|
||
// И я вам отвечу: Да. Но сама система ограничения времени работы сервера - временная штука на этап разработки, которая будет удалена.
|
||
// Мне просто лень каждый раз запускать и выключать сервер ручками.
|
||
private void UpdateCbt(float _)
|
||
{
|
||
if (!_enabled || _timing.CurTime < _nextUpdateTime)
|
||
return;
|
||
|
||
_nextUpdateTime = _timing.CurTime + _updateFrequency;
|
||
var now = DateTime.UtcNow.AddHours(3); // Moscow time
|
||
|
||
OpenWeekendRule(now);
|
||
LanguageRule(now);
|
||
LimitPlaytimeRule(now);
|
||
ApplyAnnouncements(now);
|
||
}
|
||
|
||
private void OpenWeekendRule(DateTime now)
|
||
{
|
||
var whitelistEnabled = _cfg.GetCVar(CCVars.WhitelistEnabled);
|
||
var isOpenWeekend = now.DayOfWeek is DayOfWeek.Saturday || now.DayOfWeek is DayOfWeek.Sunday;
|
||
|
||
if (isOpenWeekend && whitelistEnabled)
|
||
{
|
||
_cfg.SetCVar(CCVars.WhitelistEnabled, false);
|
||
}
|
||
else if (!isOpenWeekend && !whitelistEnabled)
|
||
{
|
||
_cfg.SetCVar(CCVars.WhitelistEnabled, true);
|
||
}
|
||
}
|
||
|
||
private void LanguageRule(DateTime now)
|
||
{
|
||
var curLang = _cfg.GetCVar(CCVars.Language);
|
||
|
||
var ruDays = now.DayOfWeek is DayOfWeek.Tuesday || now.DayOfWeek is DayOfWeek.Thursday || now.DayOfWeek is DayOfWeek.Saturday;
|
||
|
||
if (ruDays && curLang != "ru-RU")
|
||
{
|
||
_cfg.SetCVar(CCVars.Language, "ru-RU");
|
||
|
||
_chatSystem.DispatchGlobalAnnouncement(
|
||
"WARNING: The server changes its language to Russian. For the changes to apply to your device, reconnect to the server.",
|
||
announcementSound: new SoundPathSpecifier("/Audio/Effects/beep1.ogg"),
|
||
sender: "Server"
|
||
);
|
||
}
|
||
else if (!ruDays && curLang != "en-US")
|
||
{
|
||
_cfg.SetCVar(CCVars.Language, "en-US");
|
||
|
||
_chatSystem.DispatchGlobalAnnouncement(
|
||
"WARNING: The server changes its language to English. For the changes to apply to your device, reconnect to the server.",
|
||
announcementSound: new SoundPathSpecifier("/Audio/Effects/beep1.ogg"),
|
||
sender: "Server"
|
||
);
|
||
}
|
||
}
|
||
|
||
private void LimitPlaytimeRule(DateTime now)
|
||
{
|
||
var ruDays = now.DayOfWeek is DayOfWeek.Tuesday || now.DayOfWeek is DayOfWeek.Thursday || now.DayOfWeek is DayOfWeek.Saturday;
|
||
|
||
var isWeekend = now.DayOfWeek is DayOfWeek.Saturday || now.DayOfWeek is DayOfWeek.Sunday;
|
||
|
||
var allowedRuPlaytime = isWeekend ? now.Hour is >= 16 and < 20 : now.Hour is >= 18 and < 22;
|
||
var allowedEngPlaytime = now.Hour is >= 20 and < 24;
|
||
var isMonday = now.DayOfWeek is DayOfWeek.Monday;
|
||
|
||
if (((ruDays && allowedRuPlaytime) || (!ruDays && allowedEngPlaytime)) && !isMonday)
|
||
{
|
||
if (_ticker.Paused)
|
||
_ticker.TogglePause();
|
||
}
|
||
else
|
||
{
|
||
if (_ticker.RunLevel == GameRunLevel.InRound)
|
||
_roundEnd.EndRound();
|
||
|
||
if (!_ticker.Paused)
|
||
_ticker.TogglePause();
|
||
}
|
||
}
|
||
|
||
private void ApplyAnnouncements(DateTime now)
|
||
{
|
||
var ruDays = now.DayOfWeek is DayOfWeek.Tuesday || now.DayOfWeek is DayOfWeek.Thursday || now.DayOfWeek is DayOfWeek.Saturday;
|
||
|
||
var timeMap = new (int Hour, int Minute, System.Action Action)[]
|
||
{
|
||
(21, 45, () =>
|
||
{
|
||
if (!ruDays)
|
||
return;
|
||
|
||
_chatSystem.DispatchGlobalAnnouncement(
|
||
Loc.GetString("cp14-cbt-close-15m"),
|
||
announcementSound: new SoundPathSpecifier("/Audio/Effects/beep1.ogg"),
|
||
sender: "Server"
|
||
);
|
||
}),
|
||
(22, 2, () =>
|
||
{
|
||
if (!ruDays)
|
||
return;
|
||
|
||
_consoleHost.ExecuteCommand("golobby");
|
||
}),
|
||
(23, 44, () =>
|
||
{
|
||
if (ruDays)
|
||
return;
|
||
|
||
_chatSystem.DispatchGlobalAnnouncement(
|
||
Loc.GetString("cp14-cbt-close-15m"),
|
||
announcementSound: new SoundPathSpecifier("/Audio/Effects/beep1.ogg"),
|
||
sender: "Server"
|
||
);
|
||
}),
|
||
(23, 59, () =>
|
||
{
|
||
if (ruDays)
|
||
return;
|
||
|
||
_consoleHost.ExecuteCommand("golobby");
|
||
}),
|
||
};
|
||
|
||
foreach (var (hour, minute, action) in timeMap)
|
||
{
|
||
if (now.Hour == hour && now.Minute == minute)
|
||
action.Invoke();
|
||
}
|
||
}
|
||
}
|