Traitor (#2566)
* basic implementation * minor fixes * objectives temp commit * proper onstart bind * changes all conditions to be bound to a mind-instance * oops * oops v2 * adds possiblity to enable duplicate assignment of objective equal objectives are unable to be added * minor fixes, adds greentext * refactors incompatability to be defined by requirements * fixes a wrong whitespace * minor fix * addressed reviews v1 * address reviews v2 Co-authored-by: Exp <theexp111@gmail.com> * final sweep * adds/refactors traitor&sss cvars * Update Content.Server/Mobs/Mind.cs * never trust github web * adds datasets & makes codewords use them * addresses exp's reviews * addressed zumos reviews Co-authored-by: Paul <ritter.paul1+git@googlemail.com> Co-authored-by: Exp <theexp111@gmail.com>
This commit is contained in:
@@ -0,0 +1,32 @@
|
||||
using System.Collections.Generic;
|
||||
using Content.Server.Mobs;
|
||||
using Content.Server.Objectives.Interfaces;
|
||||
using Robust.Shared.Serialization;
|
||||
|
||||
namespace Content.Server.Objectives.Requirements
|
||||
{
|
||||
public class IncompatibleConditionsRequirement : IObjectiveRequirement
|
||||
{
|
||||
private List<string> _incompatibleConditions = new();
|
||||
public void ExposeData(ObjectSerializer serializer)
|
||||
{
|
||||
serializer.DataField(this, x=>x._incompatibleConditions, "conditions", new List<string>());
|
||||
}
|
||||
|
||||
public bool CanBeAssigned(Mind mind)
|
||||
{
|
||||
foreach (var objective in mind.AllObjectives)
|
||||
{
|
||||
foreach (var condition in objective.Conditions)
|
||||
{
|
||||
foreach (var incompatibleCondition in _incompatibleConditions)
|
||||
{
|
||||
if (incompatibleCondition == condition.GetType().Name) return false;
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
return true;
|
||||
}
|
||||
}
|
||||
}
|
||||
@@ -0,0 +1,29 @@
|
||||
using System.Collections.Generic;
|
||||
using Content.Server.Mobs;
|
||||
using Content.Server.Objectives.Interfaces;
|
||||
using Robust.Shared.Serialization;
|
||||
|
||||
namespace Content.Server.Objectives.Requirements
|
||||
{
|
||||
public class IncompatibleObjectivesRequirement : IObjectiveRequirement
|
||||
{
|
||||
private List<string> _incompatibleObjectives = new();
|
||||
public void ExposeData(ObjectSerializer serializer)
|
||||
{
|
||||
serializer.DataField(this, x=>x._incompatibleObjectives, "objectives", new List<string>());
|
||||
}
|
||||
|
||||
public bool CanBeAssigned(Mind mind)
|
||||
{
|
||||
foreach (var objective in mind.AllObjectives)
|
||||
{
|
||||
foreach (var incompatibleObjective in _incompatibleObjectives)
|
||||
{
|
||||
if (incompatibleObjective == objective.Prototype.ID) return false;
|
||||
}
|
||||
}
|
||||
|
||||
return true;
|
||||
}
|
||||
}
|
||||
}
|
||||
@@ -1,17 +1,19 @@
|
||||
using Content.Server.Mobs;
|
||||
using Content.Server.Mobs.Roles.Suspicion;
|
||||
using Content.Server.Mobs.Roles.Traitor;
|
||||
using Content.Server.Objectives.Interfaces;
|
||||
using JetBrains.Annotations;
|
||||
using Robust.Shared.Serialization;
|
||||
|
||||
namespace Content.Server.Objectives.Requirements
|
||||
{
|
||||
public class SuspicionTraitorRequirement : IObjectiveRequirement
|
||||
[UsedImplicitly]
|
||||
public class TraitorRequirement : IObjectiveRequirement
|
||||
{
|
||||
public void ExposeData(ObjectSerializer serializer){}
|
||||
|
||||
public bool CanBeAssigned(Mind mind)
|
||||
{
|
||||
return mind.HasRole<SuspicionTraitorRole>();
|
||||
return mind.HasRole<TraitorRole>();
|
||||
}
|
||||
}
|
||||
}
|
||||
Reference in New Issue
Block a user