Skip to content

Commit 014661c

Browse files
TrackerFixtures
1 parent bb5ffab commit 014661c

File tree

10 files changed

+126
-60
lines changed

10 files changed

+126
-60
lines changed

Content.Server/SS220/CriminalRecords/CriminalRecordSystem.cs

+2-3
Original file line numberDiff line numberDiff line change
@@ -15,7 +15,6 @@
1515
using Content.Shared.SS220.Ghost;
1616
using Content.Shared.StationRecords;
1717
using Content.Shared.StatusIcon.Components;
18-
using Robust.Shared.Player;
1918
using Robust.Shared.Prototypes;
2019
using Robust.Shared.Utility;
2120

@@ -191,7 +190,7 @@ public bool RemoveCriminalRecordStatus(StationRecordKey key, int time, EntityUid
191190
_stationRecords.Synchronize(key.OriginStation);
192191
var cardId = UpdateIdCards(key, selectedRecord);
193192
if (cardId.HasValue && TryGetLastRecord(key, out _, out var currentCriminalRecord))
194-
RaiseLocalEvent(cardId.Value, new CriminalStatusDeleted(sender, key, ref currentCriminalRecord));
193+
RaiseLocalEvent<CriminalStatusEvent>(cardId.Value, new CriminalStatusDeleted(sender, key, ref currentCriminalRecord));
195194

196195
if (sender != null)
197196
{
@@ -263,7 +262,7 @@ public bool AddCriminalRecordStatus(StationRecordKey key, string message, string
263262
_stationRecords.Synchronize(key.OriginStation);
264263
var cardId = UpdateIdCards(key, selectedRecord);
265264
if (cardId.HasValue)
266-
RaiseLocalEvent(cardId.Value, new CriminalStatusAdded(sender, key, ref criminalRecord));
265+
RaiseLocalEvent<CriminalStatusEvent>(cardId.Value, new CriminalStatusAdded(sender, key, ref criminalRecord));
267266

268267
_sawmill.Debug("Added new criminal record, synchonizing");
269268

Content.Server/SS220/Objectives/Components/IntimidatePersonConditionComponent.cs

+14
Original file line numberDiff line numberDiff line change
@@ -16,6 +16,7 @@ public sealed partial class IntimidatePersonConditionComponent : Component
1616
[ViewVariables(VVAccess.ReadWrite)]
1717
public bool ObjectiveIsDone = false;
1818

19+
public IntimidatePersonDescriptionType DescriptionType;
1920
// Two descriptions comes to help player differ done object from one which isn't.
2021

2122
/// <summary>
@@ -29,4 +30,17 @@ public sealed partial class IntimidatePersonConditionComponent : Component
2930
/// </summary>
3031
[DataField(required: true)]
3132
public string? SuccessDescription;
33+
34+
/// <summary>
35+
/// Description will be applied when objective is done. No params in it
36+
/// </summary>
37+
[DataField(required: true)]
38+
public string? SSDDescription;
39+
}
40+
41+
public enum IntimidatePersonDescriptionType
42+
{
43+
Start = 0,
44+
Success,
45+
SSD
3246
}

Content.Server/SS220/Objectives/Systems/IntimidatePersonConditionSystem.cs

+27-3
Original file line numberDiff line numberDiff line change
@@ -46,15 +46,16 @@ private void OnGetProgress(Entity<IntimidatePersonConditionComponent> entity, re
4646
|| ssdIndicator.IsSSD)
4747
{
4848
args.Progress = 1f;
49+
SetDescription(entity, IntimidatePersonDescriptionType.SSD);
4950
return;
5051
}
5152

53+
SetDescription(entity, IntimidatePersonDescriptionType.Start);
5254
args.Progress = GetProgress(entity.Comp.TargetMob);
5355
if (args.Progress >= 1f)
5456
{
5557
entity.Comp.ObjectiveIsDone = true;
56-
if (entity.Comp.SuccessDescription != null)
57-
_metaData.SetEntityDescription(entity.Owner, entity.Comp.SuccessDescription);
58+
SetDescription(entity, IntimidatePersonDescriptionType.Success);
5859
}
5960
}
6061

@@ -102,7 +103,7 @@ private void OnPersonAssigned(Entity<IntimidatePersonConditionComponent> entity,
102103
private void OnAfterAssign(Entity<IntimidatePersonConditionComponent> entity, ref ObjectiveAfterAssignEvent args)
103104
{
104105
if (entity.Comp.StartDescription != null)
105-
_metaData.SetEntityDescription(entity.Owner, entity.Comp.StartDescription);
106+
_metaData.SetEntityDescription(entity.Owner, Loc.GetString(entity.Comp.StartDescription));
106107
}
107108

108109
private float GetProgress(EntityUid target, DamageReceivedTrackerComponent? tracker = null)
@@ -117,4 +118,27 @@ private float GetProgress(EntityUid target, DamageReceivedTrackerComponent? trac
117118
{
118119
return GetEntity(Comp<MindComponent>(mindUid).OriginalOwnedEntity);
119120
}
121+
122+
/// <summary>
123+
/// A way to change description mindlessly
124+
/// </summary>
125+
private void SetDescription(Entity<IntimidatePersonConditionComponent> entity, IntimidatePersonDescriptionType type)
126+
{
127+
var (uid, component) = entity;
128+
if (component.DescriptionType == type)
129+
return;
130+
131+
var newDescription = type switch
132+
{
133+
IntimidatePersonDescriptionType.Start => component.StartDescription,
134+
IntimidatePersonDescriptionType.Success => component.SuccessDescription,
135+
IntimidatePersonDescriptionType.SSD => component.SSDDescription,
136+
_ => null
137+
};
138+
139+
if (newDescription == null)
140+
return;
141+
142+
_metaData.SetEntityDescription(uid, Loc.GetString(newDescription));
143+
}
120144
}

Content.Server/SS220/Trackers/Components/CriminalStatusTrackerComponent.cs

+35-17
Original file line numberDiff line numberDiff line change
@@ -2,6 +2,7 @@
22

33
using Content.Shared.SS220.CriminalRecords;
44
using Robust.Shared.Prototypes;
5+
using Serilog;
56

67
namespace Content.Server.SS220.Trackers.Components;
78

@@ -18,35 +19,34 @@ public sealed partial class CriminalStatusTrackerComponent : Component
1819
public CriminalStatusTrackerSpecifier CriminalStatusSpecifier = new();
1920

2021
[ViewVariables(VVAccess.ReadWrite)]
21-
private int _currentNode = 0;
22+
private int _currentNode = InitCurrentNode;
2223

23-
public void ForceFirstNode() => _currentNode = 0;
24+
private const int InitCurrentNode = -1;
25+
26+
public void ForceFirstNode() => _currentNode = InitCurrentNode;
2427
public void ForceLastNode() => _currentNode = CriminalStatusSpecifier.CriminalStatusNodes.Count;
25-
public float GetProgress() => (float)_currentNode / CriminalStatusSpecifier.CriminalStatusNodes.Count;
28+
public float GetProgress() => (float)(_currentNode + 1) / (CriminalStatusSpecifier.CriminalStatusNodes.Count + 1);
2629

2730

2831
/// <summary>
2932
/// Hide logic for deciding if we can move further with new status. Moving to Last entry of the list is prioritized.
3033
/// </summary>
3134
/// <returns>True if node changed, else - false</returns>
32-
public bool TryMove(ProtoId<CriminalStatusPrototype> newStatus)
35+
public bool TryMove(ProtoId<CriminalStatusPrototype> newStatus, EntityUid? mindUid)
3336
{
34-
var newNode = _currentNode + 1; // nope no ++, -- playing
35-
if (CriminalStatusSpecifier.CriminalStatusNodes[newNode].AllowedStatuses.Contains(newStatus))
37+
if (CriminalStatusSpecifier.CriminalStatusNodes.Count == 0)
3638
{
37-
_currentNode = newNode;
38-
return true;
39+
Log.Warning("Tried to move into empty list of criminal status nodes! This may occur to admins adding component");
40+
return false;
3941
}
4042

41-
if (_currentNode == 0)
42-
return false;
43+
var newNode = _currentNode + 1; // nope no ++, -- playing
44+
if (TryChangeNode(newNode, newStatus, mindUid, ref _currentNode))
45+
return true;
4346

4447
newNode = _currentNode - 1;
45-
if (CriminalStatusSpecifier.CriminalStatusNodes[newNode].AllowedStatuses.Contains(newStatus))
46-
{
47-
_currentNode = newNode;
48+
if (TryChangeNode(newNode, newStatus, mindUid, ref _currentNode))
4849
return true;
49-
}
5050

5151
return false;
5252
}
@@ -55,15 +55,33 @@ public bool TryMove(ProtoId<CriminalStatusPrototype> newStatus)
5555
/// Checks if current step is changeable by this mind
5656
/// </summary>
5757
/// <returns>True if current step allowed by CriminalStatusSpecifier</returns>
58-
public bool CanBeChangedByMind(EntityUid mindUid)
58+
public bool CanBeChangedByMind(EntityUid? mindUid)
5959
{
6060
return TrackedByMind != mindUid;
6161
}
6262

6363
/// <returns> False if current step can be done by anyone, otherwise true. </returns>
64-
public bool NeedToCheckMind()
64+
public bool NeedToCheckMind(int node)
6565
{
66-
return !CriminalStatusSpecifier.CriminalStatusNodes[_currentNode].CanBeSetByTracker;
66+
return !CriminalStatusSpecifier.CriminalStatusNodes[node].CanBeSetByTracker;
67+
}
68+
69+
private bool TryChangeNode(int newNode, ProtoId<CriminalStatusPrototype> newStatus, EntityUid? mindUid, ref int currentNode)
70+
{
71+
if (newNode <= InitCurrentNode)
72+
return false;
73+
74+
if (newNode >= CriminalStatusSpecifier.CriminalStatusNodes.Count)
75+
return false;
76+
77+
if (CriminalStatusSpecifier.CriminalStatusNodes[newNode].AllowedStatuses.Contains(newStatus)
78+
&& (!NeedToCheckMind(newNode) || CanBeChangedByMind(mindUid)))
79+
{
80+
currentNode = newNode;
81+
return true;
82+
}
83+
84+
return false;
6785
}
6886
}
6987

Content.Server/SS220/Trackers/Components/DamageReceivedTrackerComponent.cs

+13-2
Original file line numberDiff line numberDiff line change
@@ -4,6 +4,7 @@
44
using Content.Shared.FixedPoint;
55
using Content.Shared.Mobs;
66
using Robust.Shared.Prototypes;
7+
using Serilog;
78

89
namespace Content.Server.SS220.Trackers.Components;
910

@@ -13,18 +14,28 @@ public sealed partial class DamageReceivedTrackerComponent : Component
1314
[ViewVariables(VVAccess.ReadWrite)]
1415
public EntityUid WhomDamageTrack;
1516

17+
// We use this to make damaging more situational like burning after igniting by performer will also counted
18+
[ViewVariables(VVAccess.ReadWrite)]
19+
public TimeSpan ResetTimeDamageOwnerTracked = TimeSpan.Zero;
20+
1621
[ViewVariables(VVAccess.ReadWrite)]
1722
public FixedPoint2 CurrentAmount = 0;
1823

1924
[ViewVariables(VVAccess.ReadOnly)]
2025
[DataField(required: true)]
21-
public DamageTrackerSpecifier DamageTracker = new ();
26+
public DamageTrackerSpecifier DamageTracker = new();
2227

2328
public float GetProgress()
2429
{
2530
if (CurrentAmount > DamageTracker.TargetAmount)
2631
return 1f;
2732

33+
if (DamageTracker.TargetAmount == FixedPoint2.Zero)
34+
{
35+
Log.Warning("Damage tracker target amount is zero! This may occur due to admins adding it.");
36+
return 1f;
37+
}
38+
2839
return (float)CurrentAmount.Value / DamageTracker.TargetAmount.Value;
2940
}
3041

@@ -46,5 +57,5 @@ public sealed partial class DamageTrackerSpecifier
4657

4758
[DataField(required: true)]
4859
[ViewVariables(VVAccess.ReadWrite)]
49-
public FixedPoint2 TargetAmount;
60+
public FixedPoint2 TargetAmount = FixedPoint2.Zero;
5061
}

Content.Server/SS220/Trackers/Systems/CriminalStatusTrackerSystem.cs

+6-6
Original file line numberDiff line numberDiff line change
@@ -21,15 +21,15 @@ private void OnStatusChanged(Entity<CriminalStatusTrackerComponent> entity, ref
2121
{
2222
var (_, comp) = entity;
2323

24-
// we check if sender is able to move the progress
25-
if (comp.NeedToCheckMind() && TryComp<MindContainerComponent>(args.Sender, out var mindContainer)
26-
&& mindContainer.HasMind && comp.CanBeChangedByMind(mindContainer.Mind.Value))
27-
return;
28-
2924
if (args.CurrentCriminalRecord.RecordType == null)
3025
return;
3126

32-
comp.TryMove(args.CurrentCriminalRecord.RecordType.Value);
27+
EntityUid? mindUid = null;
28+
// we check if sender is able to move the progress
29+
if (TryComp<MindContainerComponent>(args.Sender, out var mindContainer))
30+
mindUid = mindContainer.Mind;
31+
32+
comp.TryMove(args.CurrentCriminalRecord.RecordType.Value, mindUid);
3333
}
3434
}
3535

Content.Server/SS220/Trackers/Systems/DamageReceivedTrackerSystem.cs

+10-2
Original file line numberDiff line numberDiff line change
@@ -5,13 +5,17 @@
55
using Content.Shared.Mobs.Components;
66
using Content.Shared.Mobs.Systems;
77
using Robust.Shared.Prototypes;
8+
using Robust.Shared.Timing;
89

910
namespace Content.Server.SS220.Trackers.Systems;
1011

1112
public sealed class DamageReceivedTrackerSystem : EntitySystem
1213
{
14+
[Dependency] private readonly IGameTiming _gameTiming = default!;
1315
[Dependency] private readonly IPrototypeManager _prototype = default!;
1416

17+
private const float ResetDamageOwnerDelaySeconds = 3f;
18+
1519
public override void Initialize()
1620
{
1721
base.Initialize();
@@ -22,8 +26,11 @@ public override void Initialize()
2226
private void OnDamageChanged(Entity<DamageReceivedTrackerComponent> entity, ref DamageChangedEvent args)
2327
{
2428

25-
if (args.DamageDelta == null || !args.DamageIncreased
26-
|| args.Origin != entity.Comp.WhomDamageTrack)
29+
if (args.DamageDelta == null || !args.DamageIncreased)
30+
return;
31+
32+
if (args.Origin != entity.Comp.WhomDamageTrack
33+
&& entity.Comp.ResetTimeDamageOwnerTracked < _gameTiming.CurTime)
2734
return;
2835

2936
if (entity.Comp.DamageTracker.AllowedState == null
@@ -34,5 +41,6 @@ private void OnDamageChanged(Entity<DamageReceivedTrackerComponent> entity, ref
3441
var damageGroup = _prototype.Index(entity.Comp.DamageTracker.DamageGroup);
3542
args.DamageDelta.TryGetDamageInGroup(damageGroup, out var trackableDamage);
3643
entity.Comp.CurrentAmount += trackableDamage;
44+
entity.Comp.ResetTimeDamageOwnerTracked = _gameTiming.CurTime + TimeSpan.FromSeconds(ResetDamageOwnerDelaySeconds);
3745
}
3846
}
Original file line numberDiff line numberDiff line change
@@ -1,15 +1,19 @@
1-
objective-condition-frame-target = Подставьте { $targetName }, должность: { CAPITALIZE($job) }.
2-
NinjaFrameTargetObjective =
1+
objective-condition-frame-target-title = Подставьте { $targetName }, в должности { CAPITALIZE($job) }.
2+
ent-NinjaFrameTargetObjective = Подставить цель
33
.desc = Этот сотрудник избегает правосудия, исправьте это. Подставьте цель так, что дойдёт до заключения в бриге станции. Следите чтобы пометки оставались и в криминальных записях.
44
5-
objective-condition-intimidate-target-brute-title = Преподайте урок { $targetName }, должность: { CAPITALIZE($job) }.
6-
objective-condition-intimidate-target-brute-desc =
7-
objective-condition-intimidate-target-brute-desc-success =
5+
# SS220_TODO: add color markings of progress checkpoints
6+
objective-condition-intimidate-target-brute-title = Заказ на устрашение { $targetName }, в должности { CAPITALIZE($job) }.
7+
objective-condition-intimidate-target-brute-desc = Вам заказали [color=#bf1d1d]преподать урок[/color] члену экипажа станции. Избейте вашу цель несколько раз, пока она в ясном сознании.
8+
objective-condition-intimidate-target-brute-desc-ssd= [color=#ffe269]ССД[/color].
9+
objective-condition-intimidate-target-brute-desc-success = Вы [color=#50d967]успешно[/color] преподали урок.
810
9-
objective-condition-intimidate-target-burn-title = Преподайте урок { $targetName }, должность: { CAPITALIZE($job) }.
10-
objective-condition-intimidate-target-burn-desc =
11-
objective-condition-intimidate-target-burn-desc-success =
11+
objective-condition-intimidate-target-burn-title = Заказ на устрашение { $targetName }, в должности { CAPITALIZE($job) }.
12+
objective-condition-intimidate-target-burn-desc = Вам заказали [color=#bf1d1d]преподать урок[/color] члену экипажа станции. Нанесите вашей цели достаточно ожогов, пока она в ясном сознании.
13+
objective-condition-intimidate-target-burn-desc-ssd= [color=#ffe269]ССД[/color].
14+
objective-condition-intimidate-target-burn-desc-success = Вы [color=#50d967]успешно[/color] преподали урок.
1215
13-
objective-condition-intimidate-target-toxin-title = Преподайте урок { $targetName }, должность: { CAPITALIZE($job) }.
14-
objective-condition-intimidate-target-toxin-desc =
15-
objective-condition-intimidate-target-toxin-desc-success =
16+
objective-condition-intimidate-target-toxin-title = Заказ на устрашение { $targetName }, в должности { CAPITALIZE($job) }.
17+
objective-condition-intimidate-target-toxin-desc = Вам заказали [color=#bf1d1d]преподать урок[/color]члену экипажа станции. Отравите вашу цель несколько раз, пока она в ясном сознании.
18+
objective-condition-intimidate-target-toxin-desc-ssd= [color=#ffe269]ССД[/color].
19+
objective-condition-intimidate-target-toxin-desc-success = Вы [color=#50d967]успешно[/color] преподали урок.

Resources/Locale/ru-RU/ss220/prototypes/objectives/ninja-objective.ftl

-15
This file was deleted.

Resources/Prototypes/SS220/Objectives/ninja.yml

+4-1
Original file line numberDiff line numberDiff line change
@@ -6,7 +6,7 @@
66
- type: Objective
77
icon:
88
sprite: SS220/Objectives/frame.rsi
9-
state: snake_green
9+
state: snake_white
1010
- type: TargetObjective
1111
title: objective-condition-frame-target-title
1212
- type: FramePersonCondition
@@ -35,6 +35,7 @@
3535
- type: IntimidatePersonCondition
3636
startDescription: objective-condition-intimidate-target-brute-desc
3737
successDescription: objective-condition-intimidate-target-brute-desc-success
38+
sSDDescription: objective-condition-intimidate-target-brute-desc-ssd
3839
damageTrackerSpecifier:
3940
damageGroup: Brute
4041
allowedState: [Alive]
@@ -53,6 +54,7 @@
5354
- type: IntimidatePersonCondition
5455
startDescription: objective-condition-intimidate-target-burn-desc
5556
successDescription: objective-condition-intimidate-target-burn-desc-success
57+
sSDDescription: objective-condition-intimidate-target-burn-desc-ssd
5658
damageTrackerSpecifier:
5759
damageGroup: Burn
5860
allowedState: [Alive]
@@ -71,6 +73,7 @@
7173
- type: IntimidatePersonCondition
7274
startDescription: objective-condition-intimidate-target-toxin-desc
7375
successDescription: objective-condition-intimidate-target-toxin-desc-success
76+
sSDDescription: objective-condition-intimidate-target-toxin-desc-ssd
7477
damageTrackerSpecifier:
7578
damageGroup: Toxin
7679
allowedState: [Alive]

0 commit comments

Comments
 (0)