Skip to content

Commit e50a9de

Browse files
Aranclanoscorp-0
authored andcommitted
Fixes warops withdraw machine (unitystation#7116)
* Changes the temp duck sprite from the syndie tc withdraw console to its proper one. Fixes TC's not being transferred to the the player's PDA. The withdraw console will now transfer 5 TC's per use. Simplifies the syndicate war console code. * Fixes the TC count number not updating properly when using the PDA on the syndie withdraw machine.
1 parent f542fea commit e50a9de

4 files changed

Lines changed: 47 additions & 68 deletions

File tree

UnityProject/Assets/Prefabs/Objects/Misc/SyndicateWithdrawStation.prefab

Lines changed: 16 additions & 3 deletions
Some generated files are not rendered by default. Learn more about customizing how changed files appear on GitHub.

UnityProject/Assets/Scripts/Items/PDA/PDALogic.cs

Lines changed: 9 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -354,14 +354,19 @@ private void ServerInsertItem(GameObject item, ItemSlot fromSlot, GameObject pla
354354
$"After a moment it disappears, your Telecrystal counter ticks up a second later";
355355

356356
Chat.AddExamineMsgFromServer(player, uplinkMessage);
357-
if (PDAGui)
358-
{
359-
PDAGui.uplinkPage.UpdateTCCounter();
360-
}
357+
UpdateTCCountGui();
361358
}
362359
}
363360
}
364361

362+
public void UpdateTCCountGui()
363+
{
364+
if (PDAGui)
365+
{
366+
PDAGui.uplinkPage.UpdateTCCounter();
367+
}
368+
}
369+
365370
#endregion Interaction
366371

367372
#region Uplink-Init

UnityProject/Assets/Scripts/Objects/Consoles/SyndicateOpConsole.cs

Lines changed: 9 additions & 53 deletions
Original file line numberDiff line numberDiff line change
@@ -16,13 +16,11 @@ public class SyndicateOpConsole : MonoBehaviour
1616
public int TcIncrement = 14;
1717

1818
private bool warDeclared = false;
19-
private bool rewardGiven = false;
19+
2020
[SerializeField] private int timer = 1200;
2121

2222
[SerializeField] private int tcToGive = 280;
2323

24-
[NonSerialized] public List<SpawnedAntag> Operatives = new List<SpawnedAntag>();
25-
2624
public int Timer => timer;
2725

2826
private void Awake()
@@ -37,20 +35,9 @@ private void Awake()
3735
}
3836
}
3937

40-
private void OnEnable()
41-
{
42-
if (CustomNetworkManager.IsServer)
43-
{
44-
UpdateManager.Add(ServerUpdateTimer, 1f);
45-
}
46-
}
47-
4838
private void OnDisable()
4939
{
50-
if (CustomNetworkManager.IsServer)
51-
{
52-
UpdateManager.Remove(CallbackType.PERIODIC_UPDATE, ServerUpdateTimer);
53-
}
40+
UpdateManager.Remove(CallbackType.PERIODIC_UPDATE, RewardTelecrystals);
5441
}
5542

5643
public void AnnounceWar(string declarationMessage)
@@ -60,54 +47,23 @@ public void AnnounceWar(string declarationMessage)
6047
warDeclared = true;
6148

6249
GameManager.Instance.CentComm.ChangeAlertLevel(CentComm.AlertLevel.Red, true);
63-
CentComm.MakeAnnouncement(ChatTemplates.PriorityAnnouncement,
50+
CentComm.MakeAnnouncement(ChatTemplates.PriorityAnnouncement,
6451
$"Attention all crew! An open message from the syndicate has been picked up on local radiowaves! Message Reads:\n" +
6552
$"{declarationMessage}" ,CentComm.UpdateSound.Alert);
66-
67-
var antagPlayers = AntagManager.Instance.ActiveAntags;
68-
69-
foreach (var antag in antagPlayers )
70-
{
71-
if (antag.Antagonist.AntagJobType == JobType.SYNDICATE)
72-
{
73-
Operatives.Add(antag);
74-
}
75-
}
53+
UpdateManager.Add(RewardTelecrystals, 60);
7654
}
7755
}
7856

79-
public void ServerUpdateTimer()
80-
{
81-
if (warDeclared == false || rewardGiven) return;
82-
83-
if (timer > 0)
84-
{
85-
timer--;
86-
}
87-
88-
if (timer % 60 == 0)
89-
{
90-
RewardTelecrystals();
91-
}
92-
}
9357
public void RewardTelecrystals()
9458
{
95-
if (tcToGive <= TcIncrement)
59+
var amount = Mathf.Min(TcIncrement, tcToGive);
60+
TcReserve += amount;
61+
tcToGive -= amount;
62+
if (tcToGive == 0)
9663
{
97-
rewardGiven = true;
98-
}
99-
100-
if (tcToGive >= TcIncrement)
101-
{
102-
TcReserve += TcIncrement;
103-
tcToGive -= TcIncrement;
64+
UpdateManager.Remove(CallbackType.PERIODIC_UPDATE, RewardTelecrystals);
10465
}
10566

106-
if (tcToGive < TcIncrement)
107-
{
108-
TcReserve += tcToGive;
109-
tcToGive = 0;
110-
}
11167
}
11268
}
11369
}

UnityProject/Assets/Scripts/Objects/Consoles/SyndicateTelecrystalStation.cs

Lines changed: 13 additions & 8 deletions
Original file line numberDiff line numberDiff line change
@@ -6,6 +6,7 @@ namespace SyndicateOps
66
{
77
class SyndicateTelecrystalStation : MonoBehaviour, ICheckedInteractable<HandApply>, IExaminable
88
{
9+
private static int TransferAmount = 5;
910
public bool WillInteract(HandApply interaction, NetworkSide side)
1011
{
1112
if (DefaultWillInteract.Default(interaction, side)) return true;
@@ -19,30 +20,34 @@ public void ServerPerformInteraction(HandApply interaction)
1920

2021
public void WithdrawTeleCrystals(HandApply interaction)
2122
{
23+
if (SyndicateOpConsole.Instance.TcReserve == 0)
24+
{
25+
Chat.AddExamineMsgFromServer(interaction.Performer, $"There are no telecrystals in reserve");
26+
return;
27+
}
2228
if (interaction.UsedObject == null)
2329
{
24-
Chat.AddExamineMsgFromServer(interaction.Performer, $"It seems to have {SyndicateOpConsole.Instance.TcReserve} telecrystals in reserve");
30+
Chat.AddExamineMsgFromServer(interaction.Performer, $"There are {SyndicateOpConsole.Instance.TcReserve} telecrystals in reserve");
2531
return;
2632
}
2733
PDALogic pdaComp = interaction.UsedObject.GetComponent<PDALogic>();
2834
if (pdaComp != null)
2935
{
3036
if (pdaComp.IsUplinkLocked == false)
3137
{
32-
33-
int tc = Mathf.FloorToInt(SyndicateOpConsole.Instance.Operatives.Count / SyndicateOpConsole.Instance.TcIncrement);
34-
//this is to prevent tc being unobtainable when the value above is bigger then the amount of tc left within the reserves
35-
tc = Math.Min(tc, SyndicateOpConsole.Instance.TcReserve);
36-
pdaComp.UplinkTC += tc;
37-
SyndicateOpConsole.Instance.TcReserve -= tc;
38+
var amount = Math.Min(TransferAmount, SyndicateOpConsole.Instance.TcReserve);
39+
pdaComp.UplinkTC += amount;
40+
pdaComp.UpdateTCCountGui();
41+
SyndicateOpConsole.Instance.TcReserve -= amount;
42+
Chat.AddExamineMsgFromServer(interaction.Performer, $"You successfully transfer {amount} telecrystals into the {interaction.TargetObject.ExpensiveName()}");
3843
}
3944
else
4045
{
4146
Chat.AddExamineMsgFromServer(interaction.Performer, $"Your {interaction.TargetObject.ExpensiveName()} must be unlocked to transfer TC!");
4247
}
4348
}
4449
}
45-
50+
4651
public string Examine(Vector3 vector)
4752
{
4853
return $"It seems to have {SyndicateOpConsole.Instance.TcReserve} telecrystals in reserve";

0 commit comments

Comments
 (0)