wizard admin verb (#374)
* done * oops * some wizard rule tweaks * Update WizardRuleSystem.cs resolve
This commit is contained in:
@@ -9,6 +9,7 @@ using Content.Shared.Verbs;
|
||||
using Robust.Shared.Player;
|
||||
using Robust.Shared.Utility;
|
||||
using Content.Server._White.Cult.GameRule;
|
||||
using Content.Server._White.Wizard;
|
||||
|
||||
namespace Content.Server.Administration.Systems;
|
||||
|
||||
@@ -22,6 +23,7 @@ public sealed partial class AdminVerbSystem
|
||||
[Dependency] private readonly PiratesRuleSystem _piratesRule = default!;
|
||||
[Dependency] private readonly RevolutionaryRuleSystem _revolutionaryRule = default!;
|
||||
[Dependency] private readonly CultRuleSystem _cultRule = default!;
|
||||
[Dependency] private readonly WizardRuleSystem _wizardRule = default!;
|
||||
|
||||
// All antag verbs have names so invokeverb works.
|
||||
private void AddAntagVerbs(GetVerbsEvent<Verb> args)
|
||||
@@ -150,8 +152,21 @@ public sealed partial class AdminVerbSystem
|
||||
Impact = LogImpact.High,
|
||||
Message = Loc.GetString("admin-verb-make-changeling"),
|
||||
};
|
||||
|
||||
args.Verbs.Add(changeling);
|
||||
//WD edit end
|
||||
|
||||
Verb wizard = new()
|
||||
{
|
||||
Text = Loc.GetString("admin-verb-text-make-wizard"),
|
||||
Category = VerbCategory.Antag,
|
||||
Icon = new SpriteSpecifier.Texture(new ResPath("/Textures/Clothing/Head/Hats/wizardhat.rsi/icon.png")),
|
||||
Act = () =>
|
||||
{
|
||||
_wizardRule.AdminMakeWizard(args.Target);
|
||||
},
|
||||
Impact = LogImpact.High,
|
||||
Message = Loc.GetString("admin-verb-make-wizard"),
|
||||
};
|
||||
args.Verbs.Add(wizard);
|
||||
}
|
||||
//WD edit end
|
||||
}
|
||||
|
||||
@@ -300,10 +300,10 @@ public sealed class WizardRuleSystem : GameRuleSystem<WizardRuleComponent>
|
||||
_npcFaction.AddFaction(mob, "Wizard");
|
||||
}
|
||||
|
||||
private void SpawnWizard(ICommonSession? session, WizardRuleComponent component, bool spawnGhostRoles = true)
|
||||
private EntityCoordinates WizardSpawnPoint(WizardRuleComponent component)
|
||||
{
|
||||
if (component.ShuttleMap is not {Valid: true} mapUid)
|
||||
return;
|
||||
return EntityCoordinates.Invalid;
|
||||
|
||||
var spawn = new EntityCoordinates();
|
||||
foreach (var (_, meta, xform) in EntityQuery<SpawnPointComponent, MetaDataComponent, TransformComponent>(true))
|
||||
@@ -318,13 +318,25 @@ public sealed class WizardRuleSystem : GameRuleSystem<WizardRuleComponent>
|
||||
break;
|
||||
}
|
||||
|
||||
//Fallback, spawn at the centre of the map
|
||||
// Fallback, spawn at the centre of the map
|
||||
if (spawn == new EntityCoordinates())
|
||||
{
|
||||
spawn = Transform(mapUid).Coordinates;
|
||||
_sawmill.Warning("Fell back to default spawn for wizard!");
|
||||
}
|
||||
|
||||
return spawn;
|
||||
}
|
||||
|
||||
private void SpawnWizard(ICommonSession? session, WizardRuleComponent component, bool spawnGhostRoles = true)
|
||||
{
|
||||
var spawn = WizardSpawnPoint(component);
|
||||
if (spawn == EntityCoordinates.Invalid)
|
||||
{
|
||||
_sawmill.Error("Failed to calculate wizard spawn point");
|
||||
return;
|
||||
}
|
||||
|
||||
var wizardAntag = _prototypeManager.Index(component.WizardRoleProto);
|
||||
|
||||
//If a session is available, spawn mob and transfer mind into it
|
||||
@@ -395,4 +407,62 @@ public sealed class WizardRuleSystem : GameRuleSystem<WizardRuleComponent>
|
||||
ICommonSession? session = null;
|
||||
SpawnWizard(session, component, true);
|
||||
}
|
||||
|
||||
/// <summary>
|
||||
/// Makes mob a wizard through admin verb button
|
||||
/// </summary>
|
||||
public void AdminMakeWizard(EntityUid uid)
|
||||
{
|
||||
var rule = EntityQuery<WizardRuleComponent>().FirstOrDefault();
|
||||
|
||||
if (rule == null)
|
||||
{
|
||||
GameTicker.StartGameRule("Wizard", out var ruleEntity);
|
||||
rule = Comp<WizardRuleComponent>(ruleEntity);
|
||||
}
|
||||
|
||||
if (HasComp<WizardComponent>(uid))
|
||||
return;
|
||||
|
||||
MakeWizard(uid, rule, true);
|
||||
}
|
||||
|
||||
private bool MakeWizard(EntityUid wizard, WizardRuleComponent rule,
|
||||
bool giveObjectives = true)
|
||||
{
|
||||
if (!_mind.TryGetMind(wizard, out var mindId, out var mind))
|
||||
{
|
||||
Log.Info("Failed getting mind for picked wizard.");
|
||||
return false;
|
||||
}
|
||||
|
||||
if (HasComp<WizardRoleComponent>(mindId))
|
||||
{
|
||||
Log.Error($"Player {mind.CharacterName} is already a wizard.");
|
||||
return false;
|
||||
}
|
||||
|
||||
HumanoidCharacterProfile? profile = null;
|
||||
if (TryComp(wizard, out ActorComponent? actor))
|
||||
profile = _prefs.GetPreferences(actor.PlayerSession.UserId).SelectedCharacter as HumanoidCharacterProfile;
|
||||
|
||||
if (giveObjectives)
|
||||
{
|
||||
AddRole(mindId, mind, rule);
|
||||
}
|
||||
|
||||
if (!_prototypeManager.TryIndex(rule.StartingGear, out var gear))
|
||||
{
|
||||
_sawmill.Error("Failed to load wizard gear prototype");
|
||||
return false;
|
||||
}
|
||||
|
||||
SetupWizardEntity(wizard, rule.Points, gear, profile);
|
||||
|
||||
var spawnpoint = WizardSpawnPoint(rule);
|
||||
var transform = EnsureComp<TransformComponent>(wizard);
|
||||
transform.Coordinates = spawnpoint;
|
||||
|
||||
return true;
|
||||
}
|
||||
}
|
||||
|
||||
@@ -6,6 +6,7 @@ admin-verb-make-nuclear-operative = Make target into a lone Nuclear Operative.
|
||||
admin-verb-make-pirate = Make the target into a pirate. Note this doesn't configure the game rule.
|
||||
admin-verb-make-head-rev = Make the target into a Head Revolutionary.
|
||||
admin-verb-make-thief = Make the target into a thief.
|
||||
admin-verb-make-wizard = Make the target into a wizard.
|
||||
|
||||
admin-verb-text-make-traitor = Make Traitor
|
||||
admin-verb-text-make-changeling = Make Changeling
|
||||
@@ -14,3 +15,4 @@ admin-verb-text-make-nuclear-operative = Make Nuclear Operative
|
||||
admin-verb-text-make-pirate = Make Pirate
|
||||
admin-verb-text-make-head-rev = Make Head Rev
|
||||
admin-verb-text-make-thief = Make Thief
|
||||
admin-verb-text-make-wizard = Make wizard
|
||||
|
||||
@@ -6,6 +6,7 @@ admin-verb-make-nuclear-operative = Сделать цель одиноким Я
|
||||
admin-verb-make-pirate = Сделать цель пиратом\капером. Учтите, что это не меняет игровой режим.
|
||||
admin-verb-make-head-rev = Сделать цель главой революции.
|
||||
admin-verb-make-thief = Сделать цель вором.
|
||||
admin-verb-make-wizard = Сделать цель магом.
|
||||
|
||||
admin-verb-text-make-traitor = Сделать предателем
|
||||
admin-verb-text-make-changeling = Сделать генокрадом
|
||||
@@ -14,3 +15,4 @@ admin-verb-text-make-nuclear-operative = Сделать одиноким яде
|
||||
admin-verb-text-make-pirate = Сделать пиратом
|
||||
admin-verb-text-make-head-rev = Сделать главой революции
|
||||
admin-verb-text-make-thief = Сделать вором
|
||||
admin-verb-text-make-wizard = Сделать магом
|
||||
|
||||
Reference in New Issue
Block a user