Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Steal condition tells you where to steal it from #9605

Merged
merged 3 commits into from
Jul 15, 2022
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
32 changes: 16 additions & 16 deletions Content.Server/Objectives/Conditions/StealCondition.cs
Original file line number Diff line number Diff line change
Expand Up @@ -14,34 +14,30 @@ public sealed class StealCondition : IObjectiveCondition, ISerializationHooks
{
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)
{
return new StealCondition
{
_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)));

Expand All @@ -54,8 +50,12 @@ public float Progress
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;
}
}

Expand All @@ -65,7 +65,7 @@ public bool Equals(IObjectiveCondition? other)
{
return other is StealCondition stealCondition &&
Equals(_mind, stealCondition._mind) &&
_prototypeId == stealCondition._prototypeId && _amount == stealCondition._amount;
_prototypeId == stealCondition._prototypeId;
}

public override bool Equals(object? obj)
Expand All @@ -78,7 +78,7 @@ public override bool Equals(object? obj)

public override int GetHashCode()
{
return HashCode.Combine(_mind, _prototypeId, _amount);
return HashCode.Combine(_mind, _prototypeId);
}
}
}
Original file line number Diff line number Diff line change
@@ -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
Original file line number Diff line number Diff line change
Expand Up @@ -11,6 +11,7 @@
conditions:
- !type:StealCondition
prototype: CaptainIDCard
owner: job-name-captain

- type: objective
id: KillRandomObjective
Expand Down Expand Up @@ -74,6 +75,7 @@
conditions:
- !type:StealCondition
prototype: Hypospray
owner: job-name-cmo

- type: objective
id: RDHardsuitStealObjective
Expand All @@ -88,6 +90,7 @@
conditions:
- !type:StealCondition
prototype: ClothingOuterHardsuitRd
owner: job-name-rd

- type: objective
id: NukeDiskStealObjective
Expand All @@ -101,6 +104,7 @@
conditions:
- !type:StealCondition
prototype: NukeDisk
owner: objective-condition-steal-station

- type: objective
id: IDComputerBoardStealObjective
Expand All @@ -114,6 +118,7 @@
conditions:
- !type:StealCondition
prototype: IDComputerCircuitboard
owner: job-name-hop

- type: objective
id: MagbootsStealObjective
Expand All @@ -128,6 +133,7 @@
conditions:
- !type:StealCondition
prototype: ClothingShoesBootsMagAdv
owner: job-name-ce

- type: objective
id: SupplyConsoleBoardStealObjective
Expand All @@ -141,6 +147,7 @@
conditions:
- !type:StealCondition
prototype: SupplyComputerCircuitboard
owner: job-name-qm

- type: objective
id: CorgiMeatStealObjective
Expand All @@ -154,6 +161,7 @@
conditions:
- !type:StealCondition
prototype: FoodMeatCorgi
owner: objective-condition-steal-Ian

- type: objective
id: CaptainGunStealObjective
Expand All @@ -168,6 +176,7 @@
conditions:
- !type:StealCondition
prototype: WeaponAntiqueLaser
owner: job-name-captain

- type: objective
id: CaptainJetpackStealObjective
Expand All @@ -182,3 +191,4 @@
conditions:
- !type:StealCondition
prototype: JetpackCaptainFilled
owner: job-name-captain