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:
Paul Ritter
2020-11-22 08:38:07 +01:00
committed by GitHub
parent 392454b4cb
commit 6602c8c972
24 changed files with 724 additions and 27 deletions

View File

@@ -3,6 +3,7 @@ using System.Collections.Generic;
using System.Linq;
using Content.Server.GameObjects.Components.Mobs;
using Content.Server.Mobs.Roles;
using Content.Server.Objectives;
using Content.Server.Players;
using Robust.Server.Interfaces.GameObjects;
using Robust.Server.Interfaces.Player;
@@ -27,6 +28,8 @@ namespace Content.Server.Mobs
{
private readonly ISet<Role> _roles = new HashSet<Role>();
private readonly List<ObjectivePrototype> _objectives = new List<ObjectivePrototype>();
/// <summary>
/// Creates the new mind attached to a specific player session.
/// </summary>
@@ -74,6 +77,12 @@ namespace Content.Server.Mobs
[ViewVariables]
public IEnumerable<Role> AllRoles => _roles;
/// <summary>
/// An enumerable over all the objectives this mind has.
/// </summary>
[ViewVariables]
public IEnumerable<ObjectivePrototype> AllObjectives => _objectives;
/// <summary>
/// The session of the player owning this mind.
/// Can be null, in which case the player is currently not logged in.
@@ -144,6 +153,32 @@ namespace Content.Server.Mobs
return _roles.Any(role => role.GetType() == t);
}
/// <summary>
/// Adds an objective to this mind.
/// </summary>
public bool TryAddObjective(ObjectivePrototype objective)
{
if (!objective.CanBeAssigned(this))
return false;
_objectives.Add(objective);
return true;
}
/// <summary>
/// Removes an objective to this mind.
/// </summary>
/// <returns>Returns true if the removal succeeded.</returns>
public bool TryRemoveObjective(int index)
{
if (_objectives.Count >= index) return false;
var objective = _objectives[index];
_objectives.Remove(objective);
return true;
}
/// <summary>
/// Transfer this mind's control over to a new entity.
/// </summary>