Mind ecs (#14412)
This commit is contained in:
@@ -1,4 +1,5 @@
|
||||
using Content.Server.Administration;
|
||||
using Content.Server.Mind;
|
||||
using Content.Server.Players;
|
||||
using Content.Shared.Administration;
|
||||
using Robust.Server.Player;
|
||||
@@ -10,6 +11,8 @@ namespace Content.Server.Objectives.Commands
|
||||
[AdminCommand(AdminFlags.Admin)]
|
||||
public sealed class AddObjectiveCommand : IConsoleCommand
|
||||
{
|
||||
[Dependency] private readonly IEntityManager _entityManager = default!;
|
||||
|
||||
public string Command => "addobjective";
|
||||
public string Description => "Adds an objective to the player's mind.";
|
||||
public string Help => "addobjective <username> <objectiveID>";
|
||||
@@ -42,8 +45,10 @@ namespace Content.Server.Objectives.Commands
|
||||
shell.WriteLine($"Can't find matching ObjectivePrototype {objectivePrototype}");
|
||||
return;
|
||||
}
|
||||
|
||||
var mindSystem = _entityManager.System<MindSystem>();
|
||||
|
||||
if (!mind.TryAddObjective(objectivePrototype))
|
||||
if (!mindSystem.TryAddObjective(mind, objectivePrototype))
|
||||
{
|
||||
shell.WriteLine("Objective requirements dont allow that objective to be added.");
|
||||
}
|
||||
|
||||
@@ -1,4 +1,5 @@
|
||||
using Content.Server.Administration;
|
||||
using Content.Server.Mind;
|
||||
using Content.Server.Players;
|
||||
using Content.Shared.Administration;
|
||||
using Robust.Server.Player;
|
||||
@@ -9,6 +10,8 @@ namespace Content.Server.Objectives.Commands
|
||||
[AdminCommand(AdminFlags.Admin)]
|
||||
public sealed class RemoveObjectiveCommand : IConsoleCommand
|
||||
{
|
||||
[Dependency] private readonly IEntityManager _entityManager = default!;
|
||||
|
||||
public string Command => "rmobjective";
|
||||
public string Description => "Removes an objective from the player's mind.";
|
||||
public string Help => "rmobjective <username> <index>";
|
||||
@@ -32,7 +35,8 @@ namespace Content.Server.Objectives.Commands
|
||||
|
||||
if (int.TryParse(args[1], out var i))
|
||||
{
|
||||
shell.WriteLine(mind.TryRemoveObjective(i)
|
||||
var mindSystem = _entityManager.System<MindSystem>();
|
||||
shell.WriteLine(mindSystem.TryRemoveObjective(mind, i)
|
||||
? "Objective successfully removed!"
|
||||
: "Objective removing failed. Maybe the index is out of bounds? Check lsobjectives!");
|
||||
}
|
||||
|
||||
@@ -1,3 +1,4 @@
|
||||
using Content.Server.Mind;
|
||||
using Content.Server.Objectives.Interfaces;
|
||||
using JetBrains.Annotations;
|
||||
using Robust.Shared.Utility;
|
||||
@@ -21,7 +22,15 @@ namespace Content.Server.Objectives.Conditions
|
||||
|
||||
public SpriteSpecifier Icon => new SpriteSpecifier.Rsi(new ResourcePath("Mobs/Ghosts/ghost_human.rsi"), "icon");
|
||||
|
||||
public float Progress => (_mind?.CharacterDeadIC ?? true) ? 1f : 0f;
|
||||
public float Progress
|
||||
{
|
||||
get
|
||||
{
|
||||
var entityManager = IoCManager.Resolve<EntityManager>();
|
||||
var mindSystem = entityManager.System<MindSystem>();
|
||||
return _mind == null || mindSystem.IsCharacterDeadIc(_mind) ? 1f : 0f;
|
||||
}
|
||||
}
|
||||
|
||||
public float Difficulty => 0.5f;
|
||||
|
||||
|
||||
@@ -1,3 +1,4 @@
|
||||
using Content.Server.Mind;
|
||||
using Content.Server.Objectives.Interfaces;
|
||||
using Content.Server.Station.Components;
|
||||
using Content.Shared.Cuffs.Components;
|
||||
@@ -46,13 +47,14 @@ namespace Content.Server.Objectives.Conditions
|
||||
{
|
||||
get {
|
||||
var entMan = IoCManager.Resolve<IEntityManager>();
|
||||
var mindSystem = entMan.System<MindSystem>();
|
||||
|
||||
if (_mind?.OwnedEntity == null
|
||||
|| !entMan.TryGetComponent<TransformComponent>(_mind.OwnedEntity, out var xform))
|
||||
return 0f;
|
||||
|
||||
var shuttleContainsAgent = false;
|
||||
var agentIsAlive = !_mind.CharacterDeadIC;
|
||||
var agentIsAlive = !mindSystem.IsCharacterDeadIc(_mind);
|
||||
var agentIsEscaping = true;
|
||||
|
||||
if (entMan.TryGetComponent<CuffableComponent>(_mind.OwnedEntity, out var cuffed)
|
||||
|
||||
@@ -1,3 +1,4 @@
|
||||
using Content.Server.Mind;
|
||||
using Content.Server.Objectives.Interfaces;
|
||||
using Content.Shared.Mobs.Systems;
|
||||
using Robust.Shared.Utility;
|
||||
@@ -32,7 +33,15 @@ namespace Content.Server.Objectives.Conditions
|
||||
|
||||
public SpriteSpecifier Icon => new SpriteSpecifier.Rsi(new ResourcePath("Objects/Weapons/Guns/Pistols/viper.rsi"), "icon");
|
||||
|
||||
public float Progress => (Target?.CharacterDeadIC ?? true) ? 1f : 0f;
|
||||
public float Progress
|
||||
{
|
||||
get
|
||||
{
|
||||
var entityManager = IoCManager.Resolve<EntityManager>();
|
||||
var mindSystem = entityManager.System<MindSystem>();
|
||||
return Target == null || mindSystem.IsCharacterDeadIc(Target) ? 1f : 0f;
|
||||
}
|
||||
}
|
||||
|
||||
public float Difficulty => 2f;
|
||||
|
||||
|
||||
@@ -13,7 +13,7 @@ namespace Content.Server.Objectives.Conditions
|
||||
{
|
||||
public override IObjectiveCondition GetAssigned(Mind.Mind mind)
|
||||
{
|
||||
var allHumans = EntityManager.EntityQuery<MindComponent>(true).Where(mc =>
|
||||
var allHumans = EntityManager.EntityQuery<MindContainerComponent>(true).Where(mc =>
|
||||
{
|
||||
var entity = mc.Mind?.OwnedEntity;
|
||||
|
||||
|
||||
@@ -3,6 +3,7 @@ using Content.Server.Objectives.Interfaces;
|
||||
using Robust.Shared.Random;
|
||||
using Robust.Shared.Utility;
|
||||
using Content.Server.GameTicking.Rules;
|
||||
using Content.Server.Mind;
|
||||
|
||||
namespace Content.Server.Objectives.Conditions
|
||||
{
|
||||
@@ -41,7 +42,15 @@ namespace Content.Server.Objectives.Conditions
|
||||
|
||||
public SpriteSpecifier Icon => new SpriteSpecifier.Rsi(new ResourcePath("Objects/Misc/bureaucracy.rsi"), "folder-white");
|
||||
|
||||
public float Progress => (!_target?.CharacterDeadIC ?? true) ? 1f : 0f;
|
||||
public float Progress
|
||||
{
|
||||
get
|
||||
{
|
||||
var entityManager = IoCManager.Resolve<EntityManager>();
|
||||
var mindSystem = entityManager.System<MindSystem>();
|
||||
return _target == null || mindSystem.IsCharacterDeadIc(_target) ? 1f : 0f;
|
||||
}
|
||||
}
|
||||
|
||||
public float Difficulty => 1.75f;
|
||||
|
||||
|
||||
@@ -1,4 +1,5 @@
|
||||
using Content.Server.Objectives.Interfaces;
|
||||
using Content.Server.Mind;
|
||||
using Content.Server.Objectives.Interfaces;
|
||||
using Content.Server.Traitor;
|
||||
using JetBrains.Annotations;
|
||||
|
||||
@@ -10,7 +11,9 @@ namespace Content.Server.Objectives.Requirements
|
||||
{
|
||||
public bool CanBeAssigned(Mind.Mind mind)
|
||||
{
|
||||
return mind.HasRole<TraitorRole>();
|
||||
var entityManager = IoCManager.Resolve<IEntityManager>();
|
||||
var mindSystem = entityManager.System<MindSystem>();
|
||||
return mindSystem.HasRole<TraitorRole>(mind);
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
Reference in New Issue
Block a user