Re-organize all projects (#4166)
This commit is contained in:
49
Content.Server/Roles/AddRoleCommand.cs
Normal file
49
Content.Server/Roles/AddRoleCommand.cs
Normal file
@@ -0,0 +1,49 @@
|
||||
using Content.Server.Administration;
|
||||
using Content.Server.Players;
|
||||
using Content.Shared.Administration;
|
||||
using Content.Shared.Roles;
|
||||
using Robust.Server.Player;
|
||||
using Robust.Shared.Console;
|
||||
using Robust.Shared.IoC;
|
||||
using Robust.Shared.Prototypes;
|
||||
|
||||
namespace Content.Server.Roles
|
||||
{
|
||||
[AdminCommand(AdminFlags.Fun)]
|
||||
public class AddRoleCommand : IConsoleCommand
|
||||
{
|
||||
[Dependency] private readonly IPrototypeManager _prototypeManager = default!;
|
||||
|
||||
public string Command => "addrole";
|
||||
|
||||
public string Description => "Adds a role to a player's mind.";
|
||||
|
||||
public string Help => "addrole <session ID> <Role Type>\nThat role type is the actual C# type name.";
|
||||
|
||||
public void Execute(IConsoleShell shell, string argStr, string[] args)
|
||||
{
|
||||
if (args.Length != 2)
|
||||
{
|
||||
shell.WriteLine("Expected exactly 2 arguments.");
|
||||
return;
|
||||
}
|
||||
|
||||
var mgr = IoCManager.Resolve<IPlayerManager>();
|
||||
if (!mgr.TryGetPlayerDataByUsername(args[0], out var data))
|
||||
{
|
||||
shell.WriteLine("Can't find that mind");
|
||||
return;
|
||||
}
|
||||
|
||||
var mind = data.ContentData()?.Mind;
|
||||
if (mind == null)
|
||||
{
|
||||
shell.WriteLine("Can't find that mind");
|
||||
return;
|
||||
}
|
||||
|
||||
var role = new Job(mind, _prototypeManager.Index<JobPrototype>(args[1]));
|
||||
mind.AddRole(role);
|
||||
}
|
||||
}
|
||||
}
|
||||
33
Content.Server/Roles/Job.cs
Normal file
33
Content.Server/Roles/Job.cs
Normal file
@@ -0,0 +1,33 @@
|
||||
using Content.Server.Chat.Managers;
|
||||
using Content.Shared.Roles;
|
||||
using Robust.Shared.IoC;
|
||||
|
||||
namespace Content.Server.Roles
|
||||
{
|
||||
public class Job : Role
|
||||
{
|
||||
public JobPrototype Prototype { get; }
|
||||
|
||||
public override string Name { get; }
|
||||
public override bool Antagonist => false;
|
||||
|
||||
public string? StartingGear => Prototype.StartingGear;
|
||||
|
||||
public Job(Mind.Mind mind, JobPrototype jobPrototype) : base(mind)
|
||||
{
|
||||
Prototype = jobPrototype;
|
||||
Name = jobPrototype.Name;
|
||||
}
|
||||
|
||||
public override void Greet()
|
||||
{
|
||||
base.Greet();
|
||||
|
||||
if (Mind.TryGetSession(out var session))
|
||||
{
|
||||
var chat = IoCManager.Resolve<IChatManager>();
|
||||
chat.DispatchServerMessage(session, $"You're a new {Name}. Do your best!");
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
50
Content.Server/Roles/RemoveRoleCommand.cs
Normal file
50
Content.Server/Roles/RemoveRoleCommand.cs
Normal file
@@ -0,0 +1,50 @@
|
||||
using Content.Server.Administration;
|
||||
using Content.Server.Players;
|
||||
using Content.Shared.Administration;
|
||||
using Content.Shared.Roles;
|
||||
using Robust.Server.Player;
|
||||
using Robust.Shared.Console;
|
||||
using Robust.Shared.IoC;
|
||||
using Robust.Shared.Prototypes;
|
||||
|
||||
namespace Content.Server.Roles
|
||||
{
|
||||
[AdminCommand(AdminFlags.Fun)]
|
||||
public class RemoveRoleCommand : IConsoleCommand
|
||||
{
|
||||
[Dependency] private readonly IPrototypeManager _prototypeManager = default!;
|
||||
|
||||
public string Command => "rmrole";
|
||||
|
||||
public string Description => "Removes a role from a player's mind.";
|
||||
|
||||
public string Help => "rmrole <session ID> <Role Type>\nThat role type is the actual C# type name.";
|
||||
|
||||
public void Execute(IConsoleShell shell, string argStr, string[] args)
|
||||
{
|
||||
if (args.Length != 2)
|
||||
{
|
||||
shell.WriteLine("Expected exactly 2 arguments.");
|
||||
return;
|
||||
}
|
||||
|
||||
var mgr = IoCManager.Resolve<IPlayerManager>();
|
||||
if (!mgr.TryGetPlayerDataByUsername(args[0], out var data))
|
||||
{
|
||||
shell.WriteLine("Can't find that mind");
|
||||
return;
|
||||
}
|
||||
|
||||
var mind = data.ContentData()?.Mind;
|
||||
|
||||
if (mind == null)
|
||||
{
|
||||
shell.WriteLine("Can't find that mind");
|
||||
return;
|
||||
}
|
||||
|
||||
var role = new Job(mind, _prototypeManager.Index<JobPrototype>(args[1]));
|
||||
mind.RemoveRole(role);
|
||||
}
|
||||
}
|
||||
}
|
||||
41
Content.Server/Roles/Role.cs
Normal file
41
Content.Server/Roles/Role.cs
Normal file
@@ -0,0 +1,41 @@
|
||||
// Hey look,
|
||||
// Antag Datums.
|
||||
|
||||
namespace Content.Server.Roles
|
||||
{
|
||||
/// <summary>
|
||||
/// The Role is a basic building block for,
|
||||
/// well, IC roles.
|
||||
/// This can be anything and is not necessarily limited to antagonists.
|
||||
/// </summary>
|
||||
public abstract class Role
|
||||
{
|
||||
/// <summary>
|
||||
/// The mind owning this role instance.
|
||||
/// </summary>
|
||||
public Mind.Mind Mind { get; }
|
||||
|
||||
/// <summary>
|
||||
/// A friendly name for this role type.
|
||||
/// </summary>
|
||||
public abstract string Name { get; }
|
||||
|
||||
/// <summary>
|
||||
/// Whether this role should be considered antagonistic or not.
|
||||
/// </summary>
|
||||
public abstract bool Antagonist { get; }
|
||||
|
||||
protected Role(Mind.Mind mind)
|
||||
{
|
||||
Mind = mind;
|
||||
}
|
||||
|
||||
/// <summary>
|
||||
/// Called when a mind (player) first gets this role, to greet them.
|
||||
/// </summary>
|
||||
public virtual void Greet()
|
||||
{
|
||||
|
||||
}
|
||||
}
|
||||
}
|
||||
7
Content.Server/Roles/RoleAddedMessage.cs
Normal file
7
Content.Server/Roles/RoleAddedMessage.cs
Normal file
@@ -0,0 +1,7 @@
|
||||
namespace Content.Server.Roles
|
||||
{
|
||||
public class RoleAddedMessage : RoleMessage
|
||||
{
|
||||
public RoleAddedMessage(Role role) : base(role) { }
|
||||
}
|
||||
}
|
||||
14
Content.Server/Roles/RoleMessage.cs
Normal file
14
Content.Server/Roles/RoleMessage.cs
Normal file
@@ -0,0 +1,14 @@
|
||||
using Robust.Shared.GameObjects;
|
||||
|
||||
namespace Content.Server.Roles
|
||||
{
|
||||
public class RoleMessage : ComponentMessage
|
||||
{
|
||||
public readonly Role Role;
|
||||
|
||||
public RoleMessage(Role role)
|
||||
{
|
||||
Role = role;
|
||||
}
|
||||
}
|
||||
}
|
||||
7
Content.Server/Roles/RoleRemovedMessage.cs
Normal file
7
Content.Server/Roles/RoleRemovedMessage.cs
Normal file
@@ -0,0 +1,7 @@
|
||||
namespace Content.Server.Roles
|
||||
{
|
||||
public class RoleRemovedMessage : RoleMessage
|
||||
{
|
||||
public RoleRemovedMessage(Role role) : base(role) { }
|
||||
}
|
||||
}
|
||||
Reference in New Issue
Block a user