Mega Antag Refactor (#25786)
* Mega Antag Refactor * last minute delta save * more workshopping * more shit * ok tested this for once * okkkkk sure * generic delays for starting rules * well darn * nukies partially * ouagh * ballin' faded and smonkin wed * obliterated the diff * Spread my arms and soak up congratulations * I've got plenty of love, but nothing to show for it * but there’s too much sunlight Shining on my laptop monitor, so I Can’t see anything with any amount of clarity * ok this junk * OOK! * fubar * most of sloth's review * oh boy * eek * hell yea! * ASDFJASDJFvsakcvjkzjnhhhyh
This commit is contained in:
@@ -62,6 +62,32 @@ public abstract class SharedRoleSystem : EntitySystem
|
||||
_antagTypes.Add(typeof(T));
|
||||
}
|
||||
|
||||
public void MindAddRole(EntityUid mindId, Component component, MindComponent? mind = null, bool silent = false)
|
||||
{
|
||||
if (!Resolve(mindId, ref mind))
|
||||
return;
|
||||
|
||||
if (HasComp(mindId, component.GetType()))
|
||||
{
|
||||
throw new ArgumentException($"We already have this role: {component}");
|
||||
}
|
||||
|
||||
EntityManager.AddComponent(mindId, component);
|
||||
var antagonist = IsAntagonistRole(component.GetType());
|
||||
|
||||
var mindEv = new MindRoleAddedEvent(silent);
|
||||
RaiseLocalEvent(mindId, ref mindEv);
|
||||
|
||||
var message = new RoleAddedEvent(mindId, mind, antagonist, silent);
|
||||
if (mind.OwnedEntity != null)
|
||||
{
|
||||
RaiseLocalEvent(mind.OwnedEntity.Value, message, true);
|
||||
}
|
||||
|
||||
_adminLogger.Add(LogType.Mind, LogImpact.Low,
|
||||
$"'Role {component}' added to mind of {_minds.MindOwnerLoggingString(mind)}");
|
||||
}
|
||||
|
||||
/// <summary>
|
||||
/// Gives this mind a new role.
|
||||
/// </summary>
|
||||
@@ -180,6 +206,11 @@ public abstract class SharedRoleSystem : EntitySystem
|
||||
return _antagTypes.Contains(typeof(T));
|
||||
}
|
||||
|
||||
public bool IsAntagonistRole(Type component)
|
||||
{
|
||||
return _antagTypes.Contains(component);
|
||||
}
|
||||
|
||||
/// <summary>
|
||||
/// Play a sound for the mind, if it has a session attached.
|
||||
/// Use this for role greeting sounds.
|
||||
|
||||
Reference in New Issue
Block a user