Redid vent code to work better and like work in general. Knight animation now pauses for a second. Knights no longer trigger the default scarlet vent animation. Revenants now spawn at a vent if no knights exist.
68 lines
2 KiB
C#
68 lines
2 KiB
C#
using System;
|
|
using System.Collections;
|
|
using System.Collections.Generic;
|
|
using System.Linq;
|
|
using System.Text;
|
|
using System.Threading.Tasks;
|
|
using UnityEngine;
|
|
using UnityEngine.Events;
|
|
|
|
namespace ScarletMansion {
|
|
|
|
public class KnightSpawnPoint : MonoBehaviour {
|
|
|
|
//[System.Serializable]
|
|
//public class OnRemoveUnityEvent {
|
|
// public UnityEvent onSelected;
|
|
// public UnityEvent onStop;
|
|
//}
|
|
|
|
//public OnRemoveUnityEvent onRemoveNormalUnityEvent;
|
|
//public OnRemoveUnityEvent onRemoveGhostUnityEvent;
|
|
|
|
public int index;
|
|
public GameObject renderGameObject;
|
|
|
|
public void Start(){
|
|
if (GameNetworkManager.Instance.isHostingGame)
|
|
StartCoroutine(GetNearbyPlayers());
|
|
}
|
|
|
|
public const float minTime = 4f;
|
|
public const float maxTime = 8f;
|
|
public const float minSqrDistance = 6f * 6f;
|
|
|
|
public IEnumerator GetNearbyPlayers(){
|
|
while(true){
|
|
var randomWait = UnityEngine.Random.Range(minTime, maxTime);
|
|
yield return new WaitForSeconds(randomWait);
|
|
|
|
var sround = StartOfRound.Instance;
|
|
var players = sround.allPlayerScripts;
|
|
var playerCount = sround.connectedPlayersAmount + 1;
|
|
for(var i = 0; i < playerCount; ++i){
|
|
var player = players[i];
|
|
if (!player.isPlayerControlled && player.isPlayerDead) continue;
|
|
|
|
// could i do a raycast?
|
|
// i mean i could but most knights are in visable locations in every room
|
|
// plus its a big pain on GOD
|
|
var dist = Vector3.SqrMagnitude(transform.position - player.transform.position);
|
|
if (dist <= minSqrDistance) {
|
|
KnightSpawnManager.Instance.lastKnightSeenPlayer = index;
|
|
Plugin.logger.LogDebug($"Knight {index} has noticed player {player.playerUsername}");
|
|
}
|
|
}
|
|
}
|
|
}
|
|
|
|
public void OnStop(){
|
|
renderGameObject.SetActive(false);
|
|
StopAllCoroutines();
|
|
|
|
//GetUnityEvent(isNormal).onStop.Invoke();
|
|
}
|
|
|
|
}
|
|
|
|
}
|