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

War Ops, reinforcements, and Syndicate Uplink tweaks. Bounty #6148 #6167

Merged
merged 23 commits into from
Mar 23, 2021
Merged
Show file tree
Hide file tree
Changes from 1 commit
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

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

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

This file was deleted.

7 changes: 4 additions & 3 deletions UnityProject/Assets/Scripts/Items/PDA/PDALogic.cs
Original file line number Diff line number Diff line change
Expand Up @@ -60,7 +60,7 @@ public class PDALogic : NetworkBehaviour, ICheckedInteractable<HandApply>, IChec
public bool IsNukeOps => isNukeOps;

[SerializeField]
private ItemTrait trait;
private ItemTrait telecrystalTrait;

[SerializeField, BoxGroup("Uplink")]
private bool debugUplink = false;
Expand Down Expand Up @@ -308,7 +308,7 @@ private bool WillInsert(GameObject item, NetworkSide side)
return true;
}

if (Validations.HasItemTrait(item, trait))
if (Validations.HasItemTrait(item, telecrystalTrait))
{
return true;
}
Expand Down Expand Up @@ -338,7 +338,7 @@ private void ServerInsertItem(GameObject item, ItemSlot fromSlot, GameObject pla

Inventory.ServerTransfer(fromSlot, CartridgeSlot);
}
else if (Validations.HasItemTrait(item, trait))
else if (Validations.HasItemTrait(item, telecrystalTrait))
{
if (IsUplinkLocked == false)
{
Expand All @@ -364,6 +364,7 @@ private void ServerInsertItem(GameObject item, ItemSlot fromSlot, GameObject pla
/// </summary>
/// <param name="informPlayer">The player that will be informed the code to the PDA uplink</param>
/// <param name="tcCount">The amount of telecrystals to add to the uplink.</param>
/// <param name="isNukie">Determines if the uplink can purchase nukeop exclusive items</param>
public void InstallUplink(ConnectedPlayer informPlayer, int tcCount, bool isNukie)
AutumnNova marked this conversation as resolved.
Show resolved Hide resolved
{
UplinkTC = tcCount; // Add; if uplink installed again (e.g. via admin tools (player request more TC)).
Expand Down
143 changes: 70 additions & 73 deletions UnityProject/Assets/Scripts/Objects/Consoles/SyndicateOpConsole.cs
Original file line number Diff line number Diff line change
Expand Up @@ -5,108 +5,105 @@
using System;
using System.Collections.Generic;

public class SyndicateOpConsole : MonoBehaviour
namespace SyndicateOps
{
public class SyndicateOpConsole : MonoBehaviour
{
[NonSerialized] public static SyndicateOpConsole Instance;

[NonSerialized] public int TcReserve;

public static SyndicateOpConsole Instance;

public int TcReserve;

public int TcIncrement = 14;
public int TcIncrement => timer / 60;

private bool warDeclared = false;
private bool rewardGiven = false;
private int timer = 1200;
private bool warDeclared = false;
private bool rewardGiven = false;
[SerializeField] private int timer = 1200;

private int timerIncrement = 60;
private int tcToGive = 280;
[SerializeField] private int tcToGive = 280;

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

public int Timer => timer;
public int Timer => timer;

private void Awake()
{
if ( Instance == null )
{
Instance = this;
}
else
private void Awake()
{
Destroy(gameObject);
if ( Instance == null )
{
Instance = this;
}
else
{
Destroy(gameObject);
}
}
}


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

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


public void AnnounceWar(string DeclerationMessage)
{
if (warDeclared == false)
public void AnnounceWar(string declarationMessage)
{
warDeclared = true;
if (warDeclared == false)
{
warDeclared = true;

GameManager.Instance.CentComm.ChangeAlertLevel(CentComm.AlertLevel.Red, true);
CentComm.MakeAnnouncement(ChatTemplates.PriorityAnnouncement,
$"Attention all crew! An open message from the syndicate has been picked up on local radiowaves! Message Reads:\n" +
$"{DeclerationMessage}" ,CentComm.UpdateSound.Alert);
GameManager.Instance.CentComm.ChangeAlertLevel(CentComm.AlertLevel.Red, true);
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.CurrentAntags;
var antagPlayers = AntagManager.Instance.CurrentAntags;

foreach (var antag in antagplayers )
{
if (antag.Antagonist.AntagJobType == JobType.SYNDICATE)
foreach (var antag in antagPlayers )
{
Operatives.Add(antag);
if (antag.Antagonist.AntagJobType == JobType.SYNDICATE)
{
Operatives.Add(antag);
}
}
}
}
}

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

if (timerIncrement > 0 || timer > 0)
{
timerIncrement--;
timer--;
}
else
{
timerIncrement = 60;
RewardTelecrystals();
}
}
public void RewardTelecrystals()
{
if (tcToGive <= TcIncrement) rewardGiven = true;
if (tcToGive >= TcIncrement)
public void ServerUpdateTimer()
{
if (warDeclared == false || rewardGiven) return;

TcReserve += TcIncrement;
tcToGive -= TcIncrement;
if (timer > 0)
{
timer--;
}

if (timer % 60 == 0)
{
RewardTelecrystals();
}
}
if (tcToGive < TcIncrement)
public void RewardTelecrystals()
{
TcReserve += tcToGive;
tcToGive = 0;
if (tcToGive <= TcIncrement) rewardGiven = true;
AutumnNova marked this conversation as resolved.
Show resolved Hide resolved
if (tcToGive >= TcIncrement)
{

TcReserve += TcIncrement;
tcToGive -= TcIncrement;
}
if (tcToGive < TcIncrement)
{
TcReserve += tcToGive;
tcToGive = 0;
}
}
}
}
}
Original file line number Diff line number Diff line change
@@ -1,38 +1,40 @@
using UnityEngine;
using Items.PDA;

class SyndicateTelecrystalStation : MonoBehaviour, ICheckedInteractable<HandApply>, IExaminable
namespace SyndicateOps
{
public bool WillInteract(HandApply interaction, NetworkSide side)
class SyndicateTelecrystalStation : MonoBehaviour, ICheckedInteractable<HandApply>, IExaminable
{
if (DefaultWillInteract.Default(interaction, side)) return true;
return false;
}

public void ServerPerformInteraction(HandApply interaction)
{
if (SyndicateOpConsole.Instance.TcReserve > 0) WithdrawTeleCrystals(interaction);
}
public bool WillInteract(HandApply interaction, NetworkSide side)
{
if (DefaultWillInteract.Default(interaction, side)) return true;
return false;
}

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

public void WithdrawTeleCrystals(HandApply interaction)
{
int tc = Mathf.FloorToInt(SyndicateOpConsole.Instance.Operatives.Count / SyndicateOpConsole.Instance.TcIncrement);
pdaComp.UplinkTC += tc;
SyndicateOpConsole.Instance.TcReserve -= tc;
if (interaction.UsedObject == null)
{
Chat.AddExamineMsgFromServer(interaction.Performer, $"It seems to have {SyndicateOpConsole.Instance.TcReserve} telecrystals in reserve");
return;
}
PDALogic pdaComp = interaction.UsedObject.GetComponent<PDALogic>();
if (pdaComp != null && pdaComp.IsUplinkLocked == false)
{
int tc = Mathf.FloorToInt(SyndicateOpConsole.Instance.Operatives.Count / SyndicateOpConsole.Instance.TcIncrement);
pdaComp.UplinkTC += tc;
SyndicateOpConsole.Instance.TcReserve -= tc;
}
}
}

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