Steal condition tells you where to steal it from (#9605)

This commit is contained in:
Rane
2022-07-14 23:09:11 -04:00
committed by GitHub
parent 2420d281bb
commit 8de2590e29
3 changed files with 30 additions and 17 deletions

View File

@@ -14,7 +14,13 @@ namespace Content.Server.Objectives.Conditions
{
private Mind.Mind? _mind;
[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)
{
@@ -22,26 +28,16 @@ namespace Content.Server.Objectives.Conditions
{
_mind = mind,
_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 =>
IoCManager.Resolve<IPrototypeManager>().TryIndex<EntityPrototype>(_prototypeId, out var prototype)
? prototype.Name
: "[CANNOT FIND NAME]";
public string Title => Loc.GetString("objective-condition-steal-title",
("amount", _amount > 1 ? $"{_amount}x " : string.Empty),
("itemName", Loc.GetString(PrototypeName)));
public string Title => Loc.GetString("objective-condition-steal-title", ("owner", Loc.GetString(_owner)), ("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 (!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);
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 &&
Equals(_mind, stealCondition._mind) &&
_prototypeId == stealCondition._prototypeId && _amount == stealCondition._amount;
_prototypeId == stealCondition._prototypeId;
}
public override bool Equals(object? obj)
@@ -78,7 +78,7 @@ namespace Content.Server.Objectives.Conditions
public override int GetHashCode()
{
return HashCode.Combine(_mind, _prototypeId, _amount);
return HashCode.Combine(_mind, _prototypeId);
}
}
}

View File

@@ -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-station = station
objective-condition-steal-Ian = head of personnel's corgi

View File

@@ -11,6 +11,7 @@
conditions:
- !type:StealCondition
prototype: CaptainIDCard
owner: job-name-captain
- type: objective
id: KillRandomObjective
@@ -74,6 +75,7 @@
conditions:
- !type:StealCondition
prototype: Hypospray
owner: job-name-cmo
- type: objective
id: RDHardsuitStealObjective
@@ -88,6 +90,7 @@
conditions:
- !type:StealCondition
prototype: ClothingOuterHardsuitRd
owner: job-name-rd
- type: objective
id: NukeDiskStealObjective
@@ -101,6 +104,7 @@
conditions:
- !type:StealCondition
prototype: NukeDisk
owner: objective-condition-steal-station
- type: objective
id: IDComputerBoardStealObjective
@@ -114,6 +118,7 @@
conditions:
- !type:StealCondition
prototype: IDComputerCircuitboard
owner: job-name-hop
- type: objective
id: MagbootsStealObjective
@@ -128,6 +133,7 @@
conditions:
- !type:StealCondition
prototype: ClothingShoesBootsMagAdv
owner: job-name-ce
- type: objective
id: SupplyConsoleBoardStealObjective
@@ -141,6 +147,7 @@
conditions:
- !type:StealCondition
prototype: SupplyComputerCircuitboard
owner: job-name-qm
- type: objective
id: CorgiMeatStealObjective
@@ -154,6 +161,7 @@
conditions:
- !type:StealCondition
prototype: FoodMeatCorgi
owner: objective-condition-steal-Ian
- type: objective
id: CaptainGunStealObjective
@@ -168,6 +176,7 @@
conditions:
- !type:StealCondition
prototype: WeaponAntiqueLaser
owner: job-name-captain
- type: objective
id: CaptainJetpackStealObjective
@@ -182,3 +191,4 @@
conditions:
- !type:StealCondition
prototype: JetpackCaptainFilled
owner: job-name-captain