106 lines
2.5 KiB
C#
106 lines
2.5 KiB
C#
|
using RoR2.Networking;
|
||
|
using UnityEngine;
|
||
|
using UnityEngine.Networking;
|
||
|
|
||
|
namespace RoR2;
|
||
|
|
||
|
[RequireComponent(typeof(PurchaseInteraction))]
|
||
|
public class ShrineBossBehavior : ShrineBehavior
|
||
|
{
|
||
|
public int maxPurchaseCount;
|
||
|
|
||
|
public float costMultiplierPerPurchase;
|
||
|
|
||
|
public Transform symbolTransform;
|
||
|
|
||
|
private PurchaseInteraction purchaseInteraction;
|
||
|
|
||
|
private int purchaseCount;
|
||
|
|
||
|
private float refreshTimer;
|
||
|
|
||
|
private const float refreshDuration = 2f;
|
||
|
|
||
|
private bool waitingForRefresh;
|
||
|
|
||
|
public override int GetNetworkChannel()
|
||
|
{
|
||
|
return QosChannelIndex.defaultReliable.intVal;
|
||
|
}
|
||
|
|
||
|
private void Start()
|
||
|
{
|
||
|
purchaseInteraction = GetComponent<PurchaseInteraction>();
|
||
|
}
|
||
|
|
||
|
public void FixedUpdate()
|
||
|
{
|
||
|
if (waitingForRefresh)
|
||
|
{
|
||
|
refreshTimer -= Time.fixedDeltaTime;
|
||
|
if (refreshTimer <= 0f && purchaseCount < maxPurchaseCount)
|
||
|
{
|
||
|
purchaseInteraction.SetAvailable(newAvailable: true);
|
||
|
purchaseInteraction.Networkcost = (int)((float)purchaseInteraction.cost * costMultiplierPerPurchase);
|
||
|
waitingForRefresh = false;
|
||
|
}
|
||
|
}
|
||
|
}
|
||
|
|
||
|
[Server]
|
||
|
public void AddShrineStack(Interactor interactor)
|
||
|
{
|
||
|
if (!NetworkServer.active)
|
||
|
{
|
||
|
Debug.LogWarning("[Server] function 'System.Void RoR2.ShrineBossBehavior::AddShrineStack(RoR2.Interactor)' called on client");
|
||
|
return;
|
||
|
}
|
||
|
waitingForRefresh = true;
|
||
|
if ((bool)TeleporterInteraction.instance)
|
||
|
{
|
||
|
TeleporterInteraction.instance.AddShrineStack();
|
||
|
}
|
||
|
CharacterBody component = interactor.GetComponent<CharacterBody>();
|
||
|
Chat.SendBroadcastChat(new Chat.SubjectFormatChatMessage
|
||
|
{
|
||
|
subjectAsCharacterBody = component,
|
||
|
baseToken = "SHRINE_BOSS_USE_MESSAGE"
|
||
|
});
|
||
|
EffectManager.SpawnEffect(LegacyResourcesAPI.Load<GameObject>("Prefabs/Effects/ShrineUseEffect"), new EffectData
|
||
|
{
|
||
|
origin = base.transform.position,
|
||
|
rotation = Quaternion.identity,
|
||
|
scale = 1f,
|
||
|
color = new Color(0.7372549f, 77f / 85f, 0.94509804f)
|
||
|
}, transmit: true);
|
||
|
purchaseCount++;
|
||
|
refreshTimer = 2f;
|
||
|
if (purchaseCount >= maxPurchaseCount)
|
||
|
{
|
||
|
symbolTransform.gameObject.SetActive(value: false);
|
||
|
CallRpcSetPingable(value: false);
|
||
|
}
|
||
|
}
|
||
|
|
||
|
private void UNetVersion()
|
||
|
{
|
||
|
}
|
||
|
|
||
|
public override bool OnSerialize(NetworkWriter writer, bool forceAll)
|
||
|
{
|
||
|
bool flag = base.OnSerialize(writer, forceAll);
|
||
|
bool flag2 = default(bool);
|
||
|
return flag2 || flag;
|
||
|
}
|
||
|
|
||
|
public override void OnDeserialize(NetworkReader reader, bool initialState)
|
||
|
{
|
||
|
base.OnDeserialize(reader, initialState);
|
||
|
}
|
||
|
|
||
|
public override void PreStartClient()
|
||
|
{
|
||
|
base.PreStartClient();
|
||
|
}
|
||
|
}
|