monkey reinforcement teleporters can now select between kobold or monkey with a verb (#25982)
* inital * Update animals.yml * Update animals.yml * Update Content.Server/Ghost/Roles/Components/GhostRoleMobSpawnerComponent.cs Co-authored-by: Tayrtahn <tayrtahn@gmail.com> * Update Content.Server/Ghost/Roles/Components/GhostRoleMobSpawnerComponent.cs Co-authored-by: Tayrtahn <tayrtahn@gmail.com> * Update Content.Server/Ghost/Roles/Components/GhostRoleMobSpawnerComponent.cs Co-authored-by: Tayrtahn <tayrtahn@gmail.com> * Update Content.Server/Ghost/Roles/Components/GhostRoleMobSpawnerComponent.cs Co-authored-by: Tayrtahn <tayrtahn@gmail.com> * Update Content.Server/Ghost/Roles/Components/GhostRoleMobSpawnerComponent.cs Co-authored-by: Tayrtahn <tayrtahn@gmail.com> * selecting different role will change the description and name * fix name * gargh * the review Hello * e --------- Co-authored-by: Tayrtahn <tayrtahn@gmail.com>
This commit is contained in:
@@ -23,6 +23,10 @@ using Robust.Shared.Enums;
|
||||
using Robust.Shared.Player;
|
||||
using Robust.Shared.Random;
|
||||
using Robust.Shared.Utility;
|
||||
using Content.Server.Popups;
|
||||
using Content.Shared.Verbs;
|
||||
using Robust.Shared.Prototypes;
|
||||
using Robust.Shared.Collections;
|
||||
|
||||
namespace Content.Server.Ghost.Roles
|
||||
{
|
||||
@@ -37,6 +41,8 @@ namespace Content.Server.Ghost.Roles
|
||||
[Dependency] private readonly TransformSystem _transform = default!;
|
||||
[Dependency] private readonly SharedMindSystem _mindSystem = default!;
|
||||
[Dependency] private readonly SharedRoleSystem _roleSystem = default!;
|
||||
[Dependency] private readonly PopupSystem _popupSystem = default!;
|
||||
[Dependency] private readonly IPrototypeManager _prototype = default!;
|
||||
|
||||
private uint _nextRoleIdentifier;
|
||||
private bool _needsUpdateGhostRoleCount = true;
|
||||
@@ -63,6 +69,7 @@ namespace Content.Server.Ghost.Roles
|
||||
SubscribeLocalEvent<GhostRoleComponent, EntityUnpausedEvent>(OnUnpaused);
|
||||
SubscribeLocalEvent<GhostRoleMobSpawnerComponent, TakeGhostRoleEvent>(OnSpawnerTakeRole);
|
||||
SubscribeLocalEvent<GhostTakeoverAvailableComponent, TakeGhostRoleEvent>(OnTakeoverTakeRole);
|
||||
SubscribeLocalEvent<GhostRoleMobSpawnerComponent, GetVerbsEvent<Verb>>(OnVerb);
|
||||
_playerManager.PlayerStatusChanged += PlayerStatusChanged;
|
||||
}
|
||||
|
||||
@@ -74,11 +81,11 @@ namespace Content.Server.Ghost.Roles
|
||||
switch (args.NewMobState)
|
||||
{
|
||||
case MobState.Alive:
|
||||
{
|
||||
if (!ghostRole.Taken)
|
||||
RegisterGhostRole((component, ghostRole));
|
||||
break;
|
||||
}
|
||||
{
|
||||
if (!ghostRole.Taken)
|
||||
RegisterGhostRole((component, ghostRole));
|
||||
break;
|
||||
}
|
||||
case MobState.Critical:
|
||||
case MobState.Dead:
|
||||
UnregisterGhostRole((component, ghostRole));
|
||||
@@ -100,11 +107,11 @@ namespace Content.Server.Ghost.Roles
|
||||
|
||||
public void OpenEui(ICommonSession session)
|
||||
{
|
||||
if (session.AttachedEntity is not {Valid: true} attached ||
|
||||
if (session.AttachedEntity is not { Valid: true } attached ||
|
||||
!EntityManager.HasComponent<GhostComponent>(attached))
|
||||
return;
|
||||
|
||||
if(_openUis.ContainsKey(session))
|
||||
if (_openUis.ContainsKey(session))
|
||||
CloseEui(session);
|
||||
|
||||
var eui = _openUis[session] = new GhostRolesEui();
|
||||
@@ -250,7 +257,7 @@ namespace Content.Server.Ghost.Roles
|
||||
if (metaQuery.GetComponent(uid).EntityPaused)
|
||||
continue;
|
||||
|
||||
roles.Add(new GhostRoleInfo {Identifier = id, Name = role.RoleName, Description = role.RoleDescription, Rules = role.RoleRules, Requirements = role.Requirements});
|
||||
roles.Add(new GhostRoleInfo { Identifier = id, Name = role.RoleName, Description = role.RoleDescription, Rules = role.RoleRules, Requirements = role.Requirements });
|
||||
}
|
||||
|
||||
return roles.ToArray();
|
||||
@@ -407,6 +414,63 @@ namespace Content.Server.Ghost.Roles
|
||||
|
||||
args.TookRole = true;
|
||||
}
|
||||
|
||||
private void OnVerb(EntityUid uid, GhostRoleMobSpawnerComponent component, GetVerbsEvent<Verb> args)
|
||||
{
|
||||
var prototypes = component.SelectablePrototypes;
|
||||
if (prototypes.Count < 1)
|
||||
return;
|
||||
|
||||
if (!args.CanAccess || !args.CanInteract || args.Hands == null)
|
||||
return;
|
||||
|
||||
var verbs = new ValueList<Verb>();
|
||||
|
||||
foreach (var prototypeID in prototypes)
|
||||
{
|
||||
if (_prototype.TryIndex<GhostRolePrototype>(prototypeID, out var prototype))
|
||||
{
|
||||
var verb = CreateVerb(uid, component, args.User, prototype);
|
||||
verbs.Add(verb);
|
||||
}
|
||||
}
|
||||
|
||||
args.Verbs.UnionWith(verbs);
|
||||
}
|
||||
|
||||
private Verb CreateVerb(EntityUid uid, GhostRoleMobSpawnerComponent component, EntityUid userUid, GhostRolePrototype prototype)
|
||||
{
|
||||
var verbText = Loc.GetString(prototype.Name);
|
||||
|
||||
return new Verb()
|
||||
{
|
||||
Text = verbText,
|
||||
Disabled = component.Prototype == prototype.EntityPrototype,
|
||||
Category = VerbCategory.SelectType,
|
||||
Act = () => SetMode(uid, prototype, verbText, component, userUid)
|
||||
};
|
||||
}
|
||||
|
||||
public void SetMode(EntityUid uid, GhostRolePrototype prototype, string verbText, GhostRoleMobSpawnerComponent? component, EntityUid? userUid = null)
|
||||
{
|
||||
if (!Resolve(uid, ref component))
|
||||
return;
|
||||
|
||||
var ghostrolecomp = EnsureComp<GhostRoleComponent>(uid);
|
||||
|
||||
component.Prototype = prototype.EntityPrototype;
|
||||
ghostrolecomp.RoleName = verbText;
|
||||
ghostrolecomp.RoleDescription = prototype.Description;
|
||||
ghostrolecomp.RoleRules = prototype.Rules;
|
||||
|
||||
// Dirty(ghostrolecomp);
|
||||
|
||||
if (userUid != null)
|
||||
{
|
||||
var msg = Loc.GetString("ghostrole-spawner-select", ("mode", verbText));
|
||||
_popupSystem.PopupEntity(msg, uid, userUid.Value);
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
[AnyCommand]
|
||||
@@ -417,7 +481,7 @@ namespace Content.Server.Ghost.Roles
|
||||
public string Help => $"{Command}";
|
||||
public void Execute(IConsoleShell shell, string argStr, string[] args)
|
||||
{
|
||||
if(shell.Player != null)
|
||||
if (shell.Player != null)
|
||||
EntitySystem.Get<GhostRoleSystem>().OpenEui(shell.Player);
|
||||
else
|
||||
shell.WriteLine("You can only open the ghost roles UI on a client.");
|
||||
|
||||
Reference in New Issue
Block a user