Re-organize all projects (#4166)

This commit is contained in:
DrSmugleaf
2021-06-09 22:19:39 +02:00
committed by GitHub
parent 9f50e4061b
commit ff1a2d97ea
1773 changed files with 5258 additions and 5508 deletions

View 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);
}
}
}

View 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!");
}
}
}
}

View 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);
}
}
}

View 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()
{
}
}
}

View File

@@ -0,0 +1,7 @@
namespace Content.Server.Roles
{
public class RoleAddedMessage : RoleMessage
{
public RoleAddedMessage(Role role) : base(role) { }
}
}

View 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;
}
}
}

View File

@@ -0,0 +1,7 @@
namespace Content.Server.Roles
{
public class RoleRemovedMessage : RoleMessage
{
public RoleRemovedMessage(Role role) : base(role) { }
}
}