Objectives (#2459)
* temp commit to save progress * adds objectives * refactors mind.addobjective a bit * better names for my testobjectives which i'll remove later on anyways * nullable errors * some misc fixes * no sorted or set, what was i thinking here? * removes unused imports * added commands * fully implements stealcondition * started uiwork * moved prototypeicon to engine * removes objective class & uiwork * refactors ui to only update when opened adds progresstexturerect * adds some margin * removes some testing code * ignores objectiveprototypes on clientside * fixes * removes using statements for exp * gets the job * always show issuer * locs & _ * giving commands some love * Update Content.Client/GameObjects/EntitySystems/DoAfter/DoAfterBar.cs Co-authored-by: Exp <theexp111@gmail.com> * makes commands use new thingy * string interpolation * good catch exp * loc'd * linq gone * runtime * moves function from engine * oopsie * Update Content.Server/Objectives/Conditions/StealCondition.cs Co-authored-by: metalgearsloth <31366439+metalgearsloth@users.noreply.github.com> * makes messages directed * base call & validation * shuffle once * No? Money down! Co-authored-by: Paul <ritter.paul1+git@googlemail.com> Co-authored-by: Exp <theexp111@gmail.com> Co-authored-by: metalgearsloth <31366439+metalgearsloth@users.noreply.github.com> Co-authored-by: Metal Gear Sloth <metalgearsloth@gmail.com>
This commit is contained in:
60
Content.Server/Objectives/ObjectivePrototype.cs
Normal file
60
Content.Server/Objectives/ObjectivePrototype.cs
Normal file
@@ -0,0 +1,60 @@
|
||||
using System.Collections.Generic;
|
||||
using System.Linq;
|
||||
using Content.Server.Mobs;
|
||||
using Content.Server.Objectives.Interfaces;
|
||||
using Robust.Shared.Prototypes;
|
||||
using Robust.Shared.Serialization;
|
||||
using Robust.Shared.ViewVariables;
|
||||
using YamlDotNet.RepresentationModel;
|
||||
|
||||
namespace Content.Server.Objectives
|
||||
{
|
||||
[Prototype("objective")]
|
||||
public class ObjectivePrototype : IPrototype, IIndexedPrototype
|
||||
{
|
||||
[ViewVariables]
|
||||
public string ID { get; private set; }
|
||||
|
||||
[ViewVariables(VVAccess.ReadWrite)]
|
||||
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());
|
||||
|
||||
private List<IObjectiveCondition> _conditions = new List<IObjectiveCondition>();
|
||||
private List<IObjectiveRequirement> _requirements = new List<IObjectiveRequirement>();
|
||||
|
||||
[ViewVariables(VVAccess.ReadWrite)]
|
||||
private float? _difficultyOverride = null;
|
||||
|
||||
public bool CanBeAssigned(Mind mind)
|
||||
{
|
||||
foreach (var requirement in _requirements)
|
||||
{
|
||||
if (!requirement.CanBeAssigned(mind)) return false;
|
||||
}
|
||||
|
||||
return true;
|
||||
}
|
||||
|
||||
public void LoadFrom(YamlMappingNode mapping)
|
||||
{
|
||||
var ser = YamlObjectSerializer.NewReader(mapping);
|
||||
|
||||
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);
|
||||
}
|
||||
}
|
||||
}
|
||||
Reference in New Issue
Block a user