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:
56
Content.Server/Objectives/Objective.cs
Normal file
56
Content.Server/Objectives/Objective.cs
Normal file
@@ -0,0 +1,56 @@
|
||||
using System;
|
||||
using System.Collections.Generic;
|
||||
using Content.Server.Mobs;
|
||||
using Content.Server.Objectives.Interfaces;
|
||||
using Robust.Shared.ViewVariables;
|
||||
|
||||
namespace Content.Server.Objectives
|
||||
{
|
||||
public class Objective : IEquatable<Objective>
|
||||
{
|
||||
[ViewVariables]
|
||||
public readonly Mind Mind;
|
||||
[ViewVariables]
|
||||
public readonly ObjectivePrototype Prototype;
|
||||
private readonly List<IObjectiveCondition> _conditions = new();
|
||||
[ViewVariables]
|
||||
public IReadOnlyList<IObjectiveCondition> Conditions => _conditions;
|
||||
|
||||
public Objective(ObjectivePrototype prototype, Mind mind)
|
||||
{
|
||||
Prototype = prototype;
|
||||
Mind = mind;
|
||||
foreach (var condition in prototype.Conditions)
|
||||
{
|
||||
_conditions.Add(condition.GetAssigned(mind));
|
||||
}
|
||||
}
|
||||
|
||||
public bool Equals(Objective other)
|
||||
{
|
||||
if (other is null) return false;
|
||||
if (ReferenceEquals(this, other)) return true;
|
||||
if (!Equals(Mind, other.Mind) || !Equals(Prototype, other.Prototype)) return false;
|
||||
if (_conditions.Count != other._conditions.Count) return false;
|
||||
for (var i = 0; i < _conditions.Count; i++)
|
||||
{
|
||||
if (!_conditions[i].Equals(other._conditions[i])) return false;
|
||||
}
|
||||
|
||||
return true;
|
||||
}
|
||||
|
||||
public override bool Equals(object obj)
|
||||
{
|
||||
if (ReferenceEquals(null, obj)) return false;
|
||||
if (ReferenceEquals(this, obj)) return true;
|
||||
if (obj.GetType() != GetType()) return false;
|
||||
return Equals((Objective) obj);
|
||||
}
|
||||
|
||||
public override int GetHashCode()
|
||||
{
|
||||
return HashCode.Combine(Mind, Prototype, _conditions);
|
||||
}
|
||||
}
|
||||
}
|
||||
Reference in New Issue
Block a user