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:
@@ -15,23 +15,24 @@ namespace Content.Server.Objectives
|
||||
[ViewVariables]
|
||||
public string ID { get; private set; }
|
||||
|
||||
[ViewVariables(VVAccess.ReadWrite)]
|
||||
[ViewVariables]
|
||||
public string Issuer { get; private set; }
|
||||
|
||||
[ViewVariables]
|
||||
public float Probability { get; private set; }
|
||||
|
||||
[ViewVariables]
|
||||
public IReadOnlyList<IObjectiveCondition> Conditions => _conditions;
|
||||
[ViewVariables]
|
||||
public IReadOnlyList<IObjectiveRequirement> Requirements => _requirements;
|
||||
|
||||
[ViewVariables]
|
||||
public float Difficulty => _difficultyOverride ?? _conditions.Sum(c => c.GetDifficulty());
|
||||
public float Difficulty => _difficultyOverride ?? _conditions.Sum(c => c.Difficulty);
|
||||
|
||||
private List<IObjectiveCondition> _conditions = new();
|
||||
private List<IObjectiveRequirement> _requirements = new();
|
||||
|
||||
[ViewVariables]
|
||||
public IReadOnlyList<IObjectiveCondition> Conditions => _conditions;
|
||||
|
||||
[ViewVariables]
|
||||
public bool CanBeDuplicateAssignment { get; private set; }
|
||||
|
||||
[ViewVariables(VVAccess.ReadWrite)]
|
||||
private float? _difficultyOverride = null;
|
||||
|
||||
@@ -42,6 +43,14 @@ namespace Content.Server.Objectives
|
||||
if (!requirement.CanBeAssigned(mind)) return false;
|
||||
}
|
||||
|
||||
if (!CanBeDuplicateAssignment)
|
||||
{
|
||||
foreach (var objective in mind.AllObjectives)
|
||||
{
|
||||
if (objective.Prototype.ID == ID) return false;
|
||||
}
|
||||
}
|
||||
|
||||
return true;
|
||||
}
|
||||
|
||||
@@ -52,9 +61,15 @@ namespace Content.Server.Objectives
|
||||
ser.DataField(this, x => x.ID, "id", string.Empty);
|
||||
ser.DataField(this, x => x.Issuer, "issuer", "Unknown");
|
||||
ser.DataField(this, x => x.Probability, "prob", 0.3f);
|
||||
ser.DataField(this, x => x._conditions, "conditions", new List<IObjectiveCondition>());
|
||||
ser.DataField(this, x => x._requirements, "requirements", new List<IObjectiveRequirement>());
|
||||
ser.DataField(this, x => x._difficultyOverride, "difficultyOverride", null);
|
||||
ser.DataField(ref _conditions, "conditions", new List<IObjectiveCondition>());
|
||||
ser.DataField(ref _requirements, "requirements", new List<IObjectiveRequirement>());
|
||||
ser.DataField(ref _difficultyOverride, "difficultyOverride", null);
|
||||
ser.DataField(this, x => x.CanBeDuplicateAssignment, "canBeDuplicate", false);
|
||||
}
|
||||
|
||||
public Objective GetObjective(Mind mind)
|
||||
{
|
||||
return new(this, mind);
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
Reference in New Issue
Block a user