Skip to content

Commit

Permalink
Fixes warops withdraw machine (unitystation#7116)
Browse files Browse the repository at this point in the history
* 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.
  • Loading branch information
Aranclanos authored and corp-0 committed Jul 24, 2021
1 parent f542fea commit e50a9de
Show file tree
Hide file tree
Showing 4 changed files with 47 additions and 68 deletions.

Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.

13 changes: 9 additions & 4 deletions UnityProject/Assets/Scripts/Items/PDA/PDALogic.cs
Original file line number Diff line number Diff line change
Expand Up @@ -354,14 +354,19 @@ private void ServerInsertItem(GameObject item, ItemSlot fromSlot, GameObject pla
$"After a moment it disappears, your Telecrystal counter ticks up a second later";

Chat.AddExamineMsgFromServer(player, uplinkMessage);
if (PDAGui)
{
PDAGui.uplinkPage.UpdateTCCounter();
}
UpdateTCCountGui();
}
}
}

public void UpdateTCCountGui()
{
if (PDAGui)
{
PDAGui.uplinkPage.UpdateTCCounter();
}
}

#endregion Interaction

#region Uplink-Init
Expand Down
62 changes: 9 additions & 53 deletions UnityProject/Assets/Scripts/Objects/Consoles/SyndicateOpConsole.cs
Original file line number Diff line number Diff line change
Expand Up @@ -16,13 +16,11 @@ public class SyndicateOpConsole : MonoBehaviour
public int TcIncrement = 14;

private bool warDeclared = false;
private bool rewardGiven = false;

[SerializeField] private int timer = 1200;

[SerializeField] private int tcToGive = 280;

[NonSerialized] public List<SpawnedAntag> Operatives = new List<SpawnedAntag>();

public int Timer => timer;

private void Awake()
Expand All @@ -37,20 +35,9 @@ private void Awake()
}
}

private void OnEnable()
{
if (CustomNetworkManager.IsServer)
{
UpdateManager.Add(ServerUpdateTimer, 1f);
}
}

private void OnDisable()
{
if (CustomNetworkManager.IsServer)
{
UpdateManager.Remove(CallbackType.PERIODIC_UPDATE, ServerUpdateTimer);
}
UpdateManager.Remove(CallbackType.PERIODIC_UPDATE, RewardTelecrystals);
}

public void AnnounceWar(string declarationMessage)
Expand All @@ -60,54 +47,23 @@ public void AnnounceWar(string declarationMessage)
warDeclared = true;

GameManager.Instance.CentComm.ChangeAlertLevel(CentComm.AlertLevel.Red, true);
CentComm.MakeAnnouncement(ChatTemplates.PriorityAnnouncement,
CentComm.MakeAnnouncement(ChatTemplates.PriorityAnnouncement,
$"Attention all crew! An open message from the syndicate has been picked up on local radiowaves! Message Reads:\n" +
$"{declarationMessage}" ,CentComm.UpdateSound.Alert);

var antagPlayers = AntagManager.Instance.ActiveAntags;

foreach (var antag in antagPlayers )
{
if (antag.Antagonist.AntagJobType == JobType.SYNDICATE)
{
Operatives.Add(antag);
}
}
UpdateManager.Add(RewardTelecrystals, 60);
}
}

public void ServerUpdateTimer()
{
if (warDeclared == false || rewardGiven) return;

if (timer > 0)
{
timer--;
}

if (timer % 60 == 0)
{
RewardTelecrystals();
}
}
public void RewardTelecrystals()
{
if (tcToGive <= TcIncrement)
var amount = Mathf.Min(TcIncrement, tcToGive);
TcReserve += amount;
tcToGive -= amount;
if (tcToGive == 0)
{
rewardGiven = true;
}

if (tcToGive >= TcIncrement)
{
TcReserve += TcIncrement;
tcToGive -= TcIncrement;
UpdateManager.Remove(CallbackType.PERIODIC_UPDATE, RewardTelecrystals);
}

if (tcToGive < TcIncrement)
{
TcReserve += tcToGive;
tcToGive = 0;
}
}
}
}
Original file line number Diff line number Diff line change
Expand Up @@ -6,6 +6,7 @@ namespace SyndicateOps
{
class SyndicateTelecrystalStation : MonoBehaviour, ICheckedInteractable<HandApply>, IExaminable
{
private static int TransferAmount = 5;
public bool WillInteract(HandApply interaction, NetworkSide side)
{
if (DefaultWillInteract.Default(interaction, side)) return true;
Expand All @@ -19,30 +20,34 @@ public void ServerPerformInteraction(HandApply interaction)

public void WithdrawTeleCrystals(HandApply interaction)
{
if (SyndicateOpConsole.Instance.TcReserve == 0)
{
Chat.AddExamineMsgFromServer(interaction.Performer, $"There are no telecrystals in reserve");
return;
}
if (interaction.UsedObject == null)
{
Chat.AddExamineMsgFromServer(interaction.Performer, $"It seems to have {SyndicateOpConsole.Instance.TcReserve} telecrystals in reserve");
Chat.AddExamineMsgFromServer(interaction.Performer, $"There are {SyndicateOpConsole.Instance.TcReserve} telecrystals in reserve");
return;
}
PDALogic pdaComp = interaction.UsedObject.GetComponent<PDALogic>();
if (pdaComp != null)
{
if (pdaComp.IsUplinkLocked == false)
{

int tc = Mathf.FloorToInt(SyndicateOpConsole.Instance.Operatives.Count / SyndicateOpConsole.Instance.TcIncrement);
//this is to prevent tc being unobtainable when the value above is bigger then the amount of tc left within the reserves
tc = Math.Min(tc, SyndicateOpConsole.Instance.TcReserve);
pdaComp.UplinkTC += tc;
SyndicateOpConsole.Instance.TcReserve -= tc;
var amount = Math.Min(TransferAmount, SyndicateOpConsole.Instance.TcReserve);
pdaComp.UplinkTC += amount;
pdaComp.UpdateTCCountGui();
SyndicateOpConsole.Instance.TcReserve -= amount;
Chat.AddExamineMsgFromServer(interaction.Performer, $"You successfully transfer {amount} telecrystals into the {interaction.TargetObject.ExpensiveName()}");
}
else
{
Chat.AddExamineMsgFromServer(interaction.Performer, $"Your {interaction.TargetObject.ExpensiveName()} must be unlocked to transfer TC!");
}
}
}

public string Examine(Vector3 vector)
{
return $"It seems to have {SyndicateOpConsole.Instance.TcReserve} telecrystals in reserve";
Expand Down

0 comments on commit e50a9de

Please sign in to comment.