Add HUD button that displays your SSS role and allies (#1895)
* Add button that displays your SSS role and allies * Capitalize button name * Add cases for 0, 1 and invalid number of allies * Make the ally syncing system saner
This commit is contained in:
@@ -2,6 +2,7 @@
|
||||
using System.Collections.Generic;
|
||||
using System.Linq;
|
||||
using Content.Server.GameObjects.Components.Mobs;
|
||||
using Content.Server.Mobs.Roles;
|
||||
using Content.Server.Players;
|
||||
using Robust.Server.Interfaces.GameObjects;
|
||||
using Robust.Server.Interfaces.Player;
|
||||
@@ -95,7 +96,7 @@ namespace Content.Server.Mobs
|
||||
/// <summary>
|
||||
/// Gives this mind a new role.
|
||||
/// </summary>
|
||||
/// <param name="t">The type of the role to give.</param>
|
||||
/// <param name="role">The type of the role to give.</param>
|
||||
/// <returns>The instance of the role.</returns>
|
||||
/// <exception cref="ArgumentException">
|
||||
/// Thrown if we already have a role with this type.
|
||||
@@ -109,13 +110,17 @@ namespace Content.Server.Mobs
|
||||
|
||||
_roles.Add(role);
|
||||
role.Greet();
|
||||
|
||||
var message = new RoleAddedMessage(role);
|
||||
OwnedEntity?.SendMessage(OwnedMob, message);
|
||||
|
||||
return role;
|
||||
}
|
||||
|
||||
/// <summary>
|
||||
/// Removes a role from this mind.
|
||||
/// </summary>
|
||||
/// <param name="t">The type of the role to remove.</param>
|
||||
/// <param name="role">The type of the role to remove.</param>
|
||||
/// <exception cref="ArgumentException">
|
||||
/// Thrown if we do not have this role.
|
||||
/// </exception>
|
||||
@@ -126,9 +131,10 @@ namespace Content.Server.Mobs
|
||||
throw new ArgumentException($"We do not have this role: {role}");
|
||||
}
|
||||
|
||||
// This can definitely get more complex removal hooks later,
|
||||
// when we need it.
|
||||
_roles.Remove(role);
|
||||
|
||||
var message = new RoleRemovedMessage(role);
|
||||
OwnedEntity?.SendMessage(OwnedMob, message);
|
||||
}
|
||||
|
||||
public bool HasRole<T>() where T : Role
|
||||
|
||||
7
Content.Server/Mobs/Roles/RoleAddedMessage.cs
Normal file
7
Content.Server/Mobs/Roles/RoleAddedMessage.cs
Normal file
@@ -0,0 +1,7 @@
|
||||
namespace Content.Server.Mobs.Roles
|
||||
{
|
||||
public class RoleAddedMessage : RoleMessage
|
||||
{
|
||||
public RoleAddedMessage(Role role) : base(role) { }
|
||||
}
|
||||
}
|
||||
14
Content.Server/Mobs/Roles/RoleMessage.cs
Normal file
14
Content.Server/Mobs/Roles/RoleMessage.cs
Normal file
@@ -0,0 +1,14 @@
|
||||
using Robust.Shared.GameObjects;
|
||||
|
||||
namespace Content.Server.Mobs.Roles
|
||||
{
|
||||
public class RoleMessage : ComponentMessage
|
||||
{
|
||||
public readonly Role Role;
|
||||
|
||||
public RoleMessage(Role role)
|
||||
{
|
||||
Role = role;
|
||||
}
|
||||
}
|
||||
}
|
||||
7
Content.Server/Mobs/Roles/RoleRemovedMessage.cs
Normal file
7
Content.Server/Mobs/Roles/RoleRemovedMessage.cs
Normal file
@@ -0,0 +1,7 @@
|
||||
namespace Content.Server.Mobs.Roles
|
||||
{
|
||||
public class RoleRemovedMessage : RoleMessage
|
||||
{
|
||||
public RoleRemovedMessage(Role role) : base(role) { }
|
||||
}
|
||||
}
|
||||
@@ -2,9 +2,9 @@ using Content.Server.Interfaces.Chat;
|
||||
using Content.Shared.Roles;
|
||||
using Robust.Shared.IoC;
|
||||
|
||||
namespace Content.Server.Mobs.Roles
|
||||
namespace Content.Server.Mobs.Roles.Suspicion
|
||||
{
|
||||
public class SuspicionInnocentRole : Role
|
||||
public class SuspicionInnocentRole : SuspicionRole
|
||||
{
|
||||
public AntagPrototype Prototype { get; }
|
||||
|
||||
7
Content.Server/Mobs/Roles/Suspicion/SuspicionRole.cs
Normal file
7
Content.Server/Mobs/Roles/Suspicion/SuspicionRole.cs
Normal file
@@ -0,0 +1,7 @@
|
||||
namespace Content.Server.Mobs.Roles.Suspicion
|
||||
{
|
||||
public abstract class SuspicionRole : Role
|
||||
{
|
||||
protected SuspicionRole(Mind mind) : base(mind) { }
|
||||
}
|
||||
}
|
||||
@@ -1,6 +1,7 @@
|
||||
using System.Collections.Generic;
|
||||
using System.Linq;
|
||||
using Content.Server.Interfaces.Chat;
|
||||
using Content.Server.Mobs.Roles.Suspicion;
|
||||
using Content.Shared.Roles;
|
||||
using Robust.Server.GameObjects.EntitySystems;
|
||||
using Robust.Shared.Audio;
|
||||
@@ -9,7 +10,7 @@ using Robust.Shared.Localization;
|
||||
|
||||
namespace Content.Server.Mobs.Roles
|
||||
{
|
||||
public sealed class SuspicionTraitorRole : Role
|
||||
public sealed class SuspicionTraitorRole : SuspicionRole
|
||||
{
|
||||
public AntagPrototype Prototype { get; }
|
||||
|
||||
Reference in New Issue
Block a user