Steal condition tells you where to steal it from (#9605)
This commit is contained in:
@@ -14,7 +14,13 @@ namespace Content.Server.Objectives.Conditions
|
|||||||
{
|
{
|
||||||
private Mind.Mind? _mind;
|
private Mind.Mind? _mind;
|
||||||
[DataField("prototype")] private string _prototypeId = string.Empty;
|
[DataField("prototype")] private string _prototypeId = string.Empty;
|
||||||
[DataField("amount")] private int _amount = 1;
|
|
||||||
|
/// <summary>
|
||||||
|
/// Help newer players by saying e.g. "steal the chief engineer's advanced magboots"
|
||||||
|
/// instead of "steal advanced magboots. Should be a loc string.
|
||||||
|
/// </summary>
|
||||||
|
[ViewVariables]
|
||||||
|
[DataField("owner", required: true)] private string _owner = string.Empty;
|
||||||
|
|
||||||
public IObjectiveCondition GetAssigned(Mind.Mind mind)
|
public IObjectiveCondition GetAssigned(Mind.Mind mind)
|
||||||
{
|
{
|
||||||
@@ -22,26 +28,16 @@ namespace Content.Server.Objectives.Conditions
|
|||||||
{
|
{
|
||||||
_mind = mind,
|
_mind = mind,
|
||||||
_prototypeId = _prototypeId,
|
_prototypeId = _prototypeId,
|
||||||
_amount = _amount
|
_owner = _owner
|
||||||
};
|
};
|
||||||
}
|
}
|
||||||
|
|
||||||
void ISerializationHooks.AfterDeserialization()
|
|
||||||
{
|
|
||||||
if (_amount < 1)
|
|
||||||
{
|
|
||||||
Logger.Error("StealCondition has an amount less than 1 ({0})", _amount);
|
|
||||||
}
|
|
||||||
}
|
|
||||||
|
|
||||||
private string PrototypeName =>
|
private string PrototypeName =>
|
||||||
IoCManager.Resolve<IPrototypeManager>().TryIndex<EntityPrototype>(_prototypeId, out var prototype)
|
IoCManager.Resolve<IPrototypeManager>().TryIndex<EntityPrototype>(_prototypeId, out var prototype)
|
||||||
? prototype.Name
|
? prototype.Name
|
||||||
: "[CANNOT FIND NAME]";
|
: "[CANNOT FIND NAME]";
|
||||||
|
|
||||||
public string Title => Loc.GetString("objective-condition-steal-title",
|
public string Title => Loc.GetString("objective-condition-steal-title", ("owner", Loc.GetString(_owner)), ("itemName", Loc.GetString(PrototypeName)));
|
||||||
("amount", _amount > 1 ? $"{_amount}x " : string.Empty),
|
|
||||||
("itemName", Loc.GetString(PrototypeName)));
|
|
||||||
|
|
||||||
public string Description => Loc.GetString("objective-condition-steal-description",("itemName", Loc.GetString(PrototypeName)));
|
public string Description => Loc.GetString("objective-condition-steal-description",("itemName", Loc.GetString(PrototypeName)));
|
||||||
|
|
||||||
@@ -54,8 +50,12 @@ namespace Content.Server.Objectives.Conditions
|
|||||||
if (_mind?.OwnedEntity is not {Valid: true} owned) return 0f;
|
if (_mind?.OwnedEntity is not {Valid: true} owned) return 0f;
|
||||||
if (!IoCManager.Resolve<IEntityManager>().TryGetComponent<ContainerManagerComponent?>(owned, out var containerManagerComponent)) return 0f;
|
if (!IoCManager.Resolve<IEntityManager>().TryGetComponent<ContainerManagerComponent?>(owned, out var containerManagerComponent)) return 0f;
|
||||||
|
|
||||||
|
// slightly ugly but fixing it would just be duplicating it with a different return value
|
||||||
float count = containerManagerComponent.CountPrototypeOccurencesRecursive(_prototypeId);
|
float count = containerManagerComponent.CountPrototypeOccurencesRecursive(_prototypeId);
|
||||||
return count/_amount;
|
if (count >= 1)
|
||||||
|
return 1;
|
||||||
|
else
|
||||||
|
return 0;
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
@@ -65,7 +65,7 @@ namespace Content.Server.Objectives.Conditions
|
|||||||
{
|
{
|
||||||
return other is StealCondition stealCondition &&
|
return other is StealCondition stealCondition &&
|
||||||
Equals(_mind, stealCondition._mind) &&
|
Equals(_mind, stealCondition._mind) &&
|
||||||
_prototypeId == stealCondition._prototypeId && _amount == stealCondition._amount;
|
_prototypeId == stealCondition._prototypeId;
|
||||||
}
|
}
|
||||||
|
|
||||||
public override bool Equals(object? obj)
|
public override bool Equals(object? obj)
|
||||||
@@ -78,7 +78,7 @@ namespace Content.Server.Objectives.Conditions
|
|||||||
|
|
||||||
public override int GetHashCode()
|
public override int GetHashCode()
|
||||||
{
|
{
|
||||||
return HashCode.Combine(_mind, _prototypeId, _amount);
|
return HashCode.Combine(_mind, _prototypeId);
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|||||||
@@ -1,2 +1,5 @@
|
|||||||
objective-condition-steal-title = Steal {$amount}{$itemName}.
|
objective-condition-steal-title = Steal the {$owner}'s {$itemName}.
|
||||||
objective-condition-steal-description = We need you to steal {$itemName}. Don't get caught.
|
objective-condition-steal-description = We need you to steal {$itemName}. Don't get caught.
|
||||||
|
|
||||||
|
objective-condition-steal-station = station
|
||||||
|
objective-condition-steal-Ian = head of personnel's corgi
|
||||||
|
|||||||
@@ -11,6 +11,7 @@
|
|||||||
conditions:
|
conditions:
|
||||||
- !type:StealCondition
|
- !type:StealCondition
|
||||||
prototype: CaptainIDCard
|
prototype: CaptainIDCard
|
||||||
|
owner: job-name-captain
|
||||||
|
|
||||||
- type: objective
|
- type: objective
|
||||||
id: KillRandomObjective
|
id: KillRandomObjective
|
||||||
@@ -74,6 +75,7 @@
|
|||||||
conditions:
|
conditions:
|
||||||
- !type:StealCondition
|
- !type:StealCondition
|
||||||
prototype: Hypospray
|
prototype: Hypospray
|
||||||
|
owner: job-name-cmo
|
||||||
|
|
||||||
- type: objective
|
- type: objective
|
||||||
id: RDHardsuitStealObjective
|
id: RDHardsuitStealObjective
|
||||||
@@ -88,6 +90,7 @@
|
|||||||
conditions:
|
conditions:
|
||||||
- !type:StealCondition
|
- !type:StealCondition
|
||||||
prototype: ClothingOuterHardsuitRd
|
prototype: ClothingOuterHardsuitRd
|
||||||
|
owner: job-name-rd
|
||||||
|
|
||||||
- type: objective
|
- type: objective
|
||||||
id: NukeDiskStealObjective
|
id: NukeDiskStealObjective
|
||||||
@@ -101,6 +104,7 @@
|
|||||||
conditions:
|
conditions:
|
||||||
- !type:StealCondition
|
- !type:StealCondition
|
||||||
prototype: NukeDisk
|
prototype: NukeDisk
|
||||||
|
owner: objective-condition-steal-station
|
||||||
|
|
||||||
- type: objective
|
- type: objective
|
||||||
id: IDComputerBoardStealObjective
|
id: IDComputerBoardStealObjective
|
||||||
@@ -114,6 +118,7 @@
|
|||||||
conditions:
|
conditions:
|
||||||
- !type:StealCondition
|
- !type:StealCondition
|
||||||
prototype: IDComputerCircuitboard
|
prototype: IDComputerCircuitboard
|
||||||
|
owner: job-name-hop
|
||||||
|
|
||||||
- type: objective
|
- type: objective
|
||||||
id: MagbootsStealObjective
|
id: MagbootsStealObjective
|
||||||
@@ -128,6 +133,7 @@
|
|||||||
conditions:
|
conditions:
|
||||||
- !type:StealCondition
|
- !type:StealCondition
|
||||||
prototype: ClothingShoesBootsMagAdv
|
prototype: ClothingShoesBootsMagAdv
|
||||||
|
owner: job-name-ce
|
||||||
|
|
||||||
- type: objective
|
- type: objective
|
||||||
id: SupplyConsoleBoardStealObjective
|
id: SupplyConsoleBoardStealObjective
|
||||||
@@ -141,6 +147,7 @@
|
|||||||
conditions:
|
conditions:
|
||||||
- !type:StealCondition
|
- !type:StealCondition
|
||||||
prototype: SupplyComputerCircuitboard
|
prototype: SupplyComputerCircuitboard
|
||||||
|
owner: job-name-qm
|
||||||
|
|
||||||
- type: objective
|
- type: objective
|
||||||
id: CorgiMeatStealObjective
|
id: CorgiMeatStealObjective
|
||||||
@@ -154,6 +161,7 @@
|
|||||||
conditions:
|
conditions:
|
||||||
- !type:StealCondition
|
- !type:StealCondition
|
||||||
prototype: FoodMeatCorgi
|
prototype: FoodMeatCorgi
|
||||||
|
owner: objective-condition-steal-Ian
|
||||||
|
|
||||||
- type: objective
|
- type: objective
|
||||||
id: CaptainGunStealObjective
|
id: CaptainGunStealObjective
|
||||||
@@ -168,6 +176,7 @@
|
|||||||
conditions:
|
conditions:
|
||||||
- !type:StealCondition
|
- !type:StealCondition
|
||||||
prototype: WeaponAntiqueLaser
|
prototype: WeaponAntiqueLaser
|
||||||
|
owner: job-name-captain
|
||||||
|
|
||||||
- type: objective
|
- type: objective
|
||||||
id: CaptainJetpackStealObjective
|
id: CaptainJetpackStealObjective
|
||||||
@@ -182,3 +191,4 @@
|
|||||||
conditions:
|
conditions:
|
||||||
- !type:StealCondition
|
- !type:StealCondition
|
||||||
prototype: JetpackCaptainFilled
|
prototype: JetpackCaptainFilled
|
||||||
|
owner: job-name-captain
|
||||||
Reference in New Issue
Block a user