Replace StayAliveObjective with EscapeShuttleObjective. (#11642)
This commit is contained in:
@@ -0,0 +1,92 @@
|
||||
using Content.Server.Cuffs.Components;
|
||||
using Content.Server.Objectives.Interfaces;
|
||||
using Content.Server.Station.Components;
|
||||
using JetBrains.Annotations;
|
||||
using Robust.Shared.Utility;
|
||||
|
||||
namespace Content.Server.Objectives.Conditions
|
||||
{
|
||||
[UsedImplicitly]
|
||||
[DataDefinition]
|
||||
public sealed class EscapeShuttleCondition : IObjectiveCondition
|
||||
{
|
||||
private Mind.Mind? _mind;
|
||||
|
||||
public IObjectiveCondition GetAssigned(Mind.Mind mind)
|
||||
{
|
||||
return new EscapeShuttleCondition {
|
||||
_mind = mind,
|
||||
};
|
||||
}
|
||||
|
||||
public string Title => Loc.GetString("objective-condition-escape-shuttle-title");
|
||||
|
||||
public string Description => Loc.GetString("objective-condition-escape-shuttle-description");
|
||||
|
||||
public SpriteSpecifier Icon => new SpriteSpecifier.Rsi(new ResourcePath("Structures/Furniture/chairs.rsi"), "shuttle");
|
||||
|
||||
private bool IsAgentOnShuttle(TransformComponent agentXform, EntityUid? shuttle)
|
||||
{
|
||||
if (shuttle == null)
|
||||
return false;
|
||||
|
||||
var entMan = IoCManager.Resolve<IEntityManager>();
|
||||
|
||||
if (!entMan.TryGetComponent<IMapGridComponent>(shuttle, out var shuttleGrid))
|
||||
return false;
|
||||
|
||||
return shuttleGrid.Grid.WorldAABB.Contains(agentXform.WorldPosition);
|
||||
}
|
||||
|
||||
public float Progress
|
||||
{
|
||||
get {
|
||||
var entMan = IoCManager.Resolve<IEntityManager>();
|
||||
|
||||
if (_mind?.OwnedEntity == null
|
||||
|| !entMan.TryGetComponent<TransformComponent>(_mind.OwnedEntity, out var xform))
|
||||
return 0f;
|
||||
|
||||
var shuttleContainsAgent = false;
|
||||
var agentIsAlive = !_mind.CharacterDeadIC;
|
||||
var agentIsEscaping = true;
|
||||
|
||||
if (entMan.TryGetComponent<CuffableComponent>(_mind.OwnedEntity, out var cuffed)
|
||||
&& cuffed.CuffedHandCount > 0)
|
||||
// You're not escaping if you're restrained!
|
||||
agentIsEscaping = false;
|
||||
|
||||
// Any emergency shuttle counts for this objective.
|
||||
foreach (var stationData in entMan.EntityQuery<StationDataComponent>())
|
||||
{
|
||||
if (IsAgentOnShuttle(xform, stationData.EmergencyShuttle)) {
|
||||
shuttleContainsAgent = true;
|
||||
break;
|
||||
}
|
||||
}
|
||||
|
||||
return (shuttleContainsAgent && agentIsAlive && agentIsEscaping) ? 1f : 0f;
|
||||
}
|
||||
}
|
||||
|
||||
public float Difficulty => 1.3f;
|
||||
|
||||
public bool Equals(IObjectiveCondition? other)
|
||||
{
|
||||
return other is EscapeShuttleCondition esc && Equals(_mind, esc._mind);
|
||||
}
|
||||
|
||||
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((EscapeShuttleCondition) obj);
|
||||
}
|
||||
|
||||
public override int GetHashCode()
|
||||
{
|
||||
return _mind != null ? _mind.GetHashCode() : 0;
|
||||
}
|
||||
}
|
||||
}
|
||||
@@ -1,46 +0,0 @@
|
||||
using Content.Server.Objectives.Interfaces;
|
||||
using JetBrains.Annotations;
|
||||
using Robust.Shared.Utility;
|
||||
|
||||
namespace Content.Server.Objectives.Conditions
|
||||
{
|
||||
[UsedImplicitly]
|
||||
[DataDefinition]
|
||||
public sealed class StayAliveCondition : IObjectiveCondition
|
||||
{
|
||||
private Mind.Mind? _mind;
|
||||
|
||||
public IObjectiveCondition GetAssigned(Mind.Mind mind)
|
||||
{
|
||||
return new StayAliveCondition {_mind = mind};
|
||||
}
|
||||
|
||||
public string Title => Loc.GetString("objective-condition-stay-alive-title");
|
||||
|
||||
public string Description => Loc.GetString("objective-condition-stay-alive-description");
|
||||
|
||||
public SpriteSpecifier Icon => new SpriteSpecifier.Rsi(new ResourcePath("Objects/Misc/bureaucracy.rsi"), "folder-white");
|
||||
|
||||
public float Progress => (_mind?.CharacterDeadIC ?? false) ? 0f : 1f;
|
||||
|
||||
public float Difficulty => 1.25f;
|
||||
|
||||
public bool Equals(IObjectiveCondition? other)
|
||||
{
|
||||
return other is StayAliveCondition sac && Equals(_mind, sac._mind);
|
||||
}
|
||||
|
||||
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((StayAliveCondition) obj);
|
||||
}
|
||||
|
||||
public override int GetHashCode()
|
||||
{
|
||||
return (_mind != null ? _mind.GetHashCode() : 0);
|
||||
}
|
||||
}
|
||||
}
|
||||
@@ -0,0 +1,2 @@
|
||||
objective-condition-escape-shuttle-title = Escape on the emergency shuttle alive and unrestrained.
|
||||
objective-condition-escape-shuttle-description = One of our undercover agents will debrief you when you arrive. Don't show up in cuffs.
|
||||
@@ -1,2 +0,0 @@
|
||||
objective-condition-stay-alive-title = Stay alive.
|
||||
objective-condition-stay-alive-description = Survive this shift, we need you for another assignment.
|
||||
@@ -39,17 +39,6 @@
|
||||
- !type:RandomTraitorAliveCondition {}
|
||||
canBeDuplicate: true
|
||||
|
||||
- type: objective
|
||||
id: StayAliveObjective
|
||||
issuer: syndicate
|
||||
requirements:
|
||||
- !type:TraitorRequirement {}
|
||||
- !type:IncompatibleConditionsRequirement
|
||||
conditions:
|
||||
- DieCondition
|
||||
conditions:
|
||||
- !type:StayAliveCondition {}
|
||||
|
||||
- type: objective
|
||||
id: DieObjective
|
||||
issuer: syndicate
|
||||
@@ -58,8 +47,8 @@
|
||||
- !type:TraitorRequirement {}
|
||||
- !type:IncompatibleConditionsRequirement
|
||||
conditions:
|
||||
- StayAliveCondition
|
||||
- StealCondition
|
||||
- EscapeShuttleCondition
|
||||
conditions:
|
||||
- !type:DieCondition {}
|
||||
|
||||
@@ -221,3 +210,14 @@
|
||||
conditions:
|
||||
- !type:StealCondition
|
||||
prototype: JetpackCaptainFilled
|
||||
|
||||
- type: objective
|
||||
id: EscapeShuttleObjective
|
||||
issuer: syndicate
|
||||
requirements:
|
||||
- !type:TraitorRequirement {}
|
||||
- !type:IncompatibleConditionsRequirement
|
||||
conditions:
|
||||
- DieCondition
|
||||
conditions:
|
||||
- !type:EscapeShuttleCondition {}
|
||||
|
||||
Reference in New Issue
Block a user