mirror of
https://github.com/WWhiteDreamProject/wwdpublic.git
synced 2026-04-23 00:27:50 +03:00
<!-- This is a semi-strict format, you can add/remove sections as needed but the order/format should be kept the same Remove these comments before submitting --> <!-- Explain this PR in as much detail as applicable Some example prompts to consider: How might this affect the game? The codebase? What might be some alternatives to this? How/Who does this benefit/hurt [the game/codebase]? --> This PR ports https://github.com/Goob-Station/Goob-Station/pull/2409 https://github.com/Goob-Station/Goob-Station/pull/2591 https://github.com/Goob-Station/Goob-Station/pull/2599 This PR was initially intended to be merged into White Dream repo, so my changes are marked as WD edit. <!-- A list of everything you have to do before this PR is "complete" You probably won't have to complete everything before merging but it's good to leave future references --> - [ ] Port pain numbness - [ ] Port nullrods - [ ] Port tile movement --- <!-- This is default collapsed, readers click to expand it and see all your media The PR media section can get very large at times, so this is a good way to keep it clean The title is written using HTML tags The title must be within the <summary> tags or you won't see it --> <details><summary><h1>Media</h1></summary> <p>     </p> </details> --- <!-- You can add an author after the `🆑` to change the name that appears in the changelog (ex: `🆑 Death`) Leaving it blank will default to your GitHub display name This includes all available types for the changelog --> 🆑 - add: Ported Devil antag from Goobstation --------- Signed-off-by: Kai5 <68296202+Kai518@users.noreply.github.com> Signed-off-by: VMSolidus <evilexecutive@gmail.com> Co-authored-by: Solstice <solsticeofthewinter@gmail.com> Co-authored-by: VMSolidus <evilexecutive@gmail.com>
97 lines
3.5 KiB
C#
97 lines
3.5 KiB
C#
// SPDX-FileCopyrightText: 2025 GoobBot <uristmchands@proton.me>
|
|
// SPDX-FileCopyrightText: 2025 Solstice <solsticeofthewinter@gmail.com>
|
|
// SPDX-FileCopyrightText: 2025 SolsticeOfTheWinter <solsticeofthewinter@gmail.com>
|
|
//
|
|
// SPDX-License-Identifier: AGPL-3.0-or-later
|
|
|
|
using System.Text;
|
|
using Content.Server._Goobstation.Devil.Roles;
|
|
using Content.Shared._Goobstation.Devil;
|
|
using Content.Server.Antag;
|
|
using Content.Server.GameTicking.Rules;
|
|
using Content.Server.Mind;
|
|
using Content.Server.Objectives;
|
|
using Content.Server.Roles;
|
|
using Content.Shared.NPC.Prototypes;
|
|
using Content.Shared.NPC.Systems;
|
|
using Content.Shared.Roles;
|
|
using Robust.Shared.Audio;
|
|
using Robust.Shared.Prototypes;
|
|
|
|
namespace Content.Server._Goobstation.Devil.GameTicking.Rules;
|
|
|
|
public sealed class DevilRuleSystem : GameRuleSystem<DevilRuleComponent>
|
|
{
|
|
[Dependency] private readonly MindSystem _mind = default!;
|
|
[Dependency] private readonly AntagSelectionSystem _antag = default!;
|
|
[Dependency] private readonly NpcFactionSystem _npcFaction = default!;
|
|
[Dependency] private readonly ObjectivesSystem _objective = default!;
|
|
public override void Initialize()
|
|
{
|
|
base.Initialize();
|
|
|
|
SubscribeLocalEvent<DevilRuleComponent, AfterAntagEntitySelectedEvent>(OnSelectAntag);
|
|
SubscribeLocalEvent<DevilRuleComponent, ObjectivesTextPrependEvent>(OnTextPrepend);
|
|
SubscribeLocalEvent<DevilRoleComponent, GetBriefingEvent>(OnGetBrief);
|
|
}
|
|
|
|
private void OnSelectAntag(EntityUid uid, DevilRuleComponent comp, ref AfterAntagEntitySelectedEvent args)
|
|
{
|
|
MakeDevil(args.EntityUid, comp);
|
|
}
|
|
|
|
private bool MakeDevil(EntityUid target, DevilRuleComponent rule)
|
|
{
|
|
var devilComp = EnsureComp<DevilComponent>(target);
|
|
|
|
var briefing = Loc.GetString("devil-role-greeting", ("trueName", devilComp.TrueName), ("playerName", Name(target)));
|
|
_antag.SendBriefing(target, briefing, Color.DarkRed, rule.BriefingSound);
|
|
|
|
_npcFaction.RemoveFaction(target, rule.NanotrasenFaction);
|
|
_npcFaction.AddFaction(target, rule.DevilFaction);
|
|
|
|
return true;
|
|
}
|
|
|
|
private void OnGetBrief(Entity<DevilRoleComponent> role, ref GetBriefingEvent args)
|
|
{
|
|
var ent = args.Mind.Comp.OwnedEntity;
|
|
|
|
if (ent is null)
|
|
return;
|
|
|
|
args.Append(MakeBriefing(ent.Value));
|
|
}
|
|
|
|
private string MakeBriefing(EntityUid ent)
|
|
{
|
|
return !TryComp<DevilComponent>(ent, out var devilComp)
|
|
? null!
|
|
: Loc.GetString("devil-role-greeting", ("trueName", devilComp.TrueName), ("playerName", Name(ent)));
|
|
}
|
|
|
|
private void OnTextPrepend(EntityUid uid, DevilRuleComponent comp, ref ObjectivesTextPrependEvent args)
|
|
|
|
{
|
|
var mostContractsName = string.Empty;
|
|
var mostContracts = 0f;
|
|
|
|
var query = EntityQueryEnumerator<DevilComponent>();
|
|
while (query.MoveNext(out var devil, out var devilComp))
|
|
{
|
|
if (!_mind.TryGetMind(devil, out var mindId, out var mind))
|
|
continue;
|
|
|
|
var metaData = MetaData(devil);
|
|
if (devilComp.Souls < mostContracts)
|
|
continue;
|
|
|
|
mostContracts = devilComp.Souls;
|
|
mostContractsName = _objective.GetTitle((mindId, mind), metaData.EntityName);
|
|
}
|
|
var sb = new StringBuilder();
|
|
sb.AppendLine(Loc.GetString($"roundend-prepend-devil-contracts{(!string.IsNullOrWhiteSpace(mostContractsName) ? "-named" : "")}", ("name", mostContractsName), ("number", mostContracts)));
|
|
args.Text = sb.ToString();
|
|
}
|
|
}
|