Added the new coilhead behaviour to the knight Added treasure room puzzle for bedroom Changed many LogInfo into LogDebug Removed jank animator override stuff (no offense) Changed how treasure rooms lock their doors to work in multiplayer Removed basement scripts
69 lines
1.8 KiB
C#
69 lines
1.8 KiB
C#
using System;
|
|
using System.Collections.Generic;
|
|
using System.Linq;
|
|
using System.Text;
|
|
using System.Threading.Tasks;
|
|
using UnityEngine;
|
|
using DunGen;
|
|
|
|
namespace ScarletMansion {
|
|
|
|
public class KnightSpawnManager : MonoBehaviour, IDungeonCompleteReceiver {
|
|
|
|
public static KnightSpawnManager Instance { get; private set; }
|
|
|
|
public List<KnightSpawnPoint> spawnPoints;
|
|
public List<KnightSpawnPoint> unusedSpawnPoints;
|
|
|
|
public int lastKnightSeenPlayer = -1;
|
|
public bool disableNextKnightSpecialSpawn;
|
|
|
|
void Awake(){
|
|
Instance = this;
|
|
}
|
|
|
|
public void OnDungeonComplete(Dungeon dungeon) {
|
|
var points = dungeon.GetComponentsInChildren<KnightSpawnPoint>();
|
|
spawnPoints = points.ToList();
|
|
for(var i = 0; i < spawnPoints.Count; ++i){
|
|
spawnPoints[i].index = i;
|
|
}
|
|
|
|
unusedSpawnPoints = points.ToList();
|
|
Plugin.logger.LogDebug($"Found {spawnPoints.Count} spawn points for the knight");
|
|
}
|
|
|
|
public int GetSpawnPointIndex(){
|
|
if (disableNextKnightSpecialSpawn) {
|
|
disableNextKnightSpecialSpawn = true;
|
|
return -1;
|
|
}
|
|
|
|
if (unusedSpawnPoints.Count == 0) return -1;
|
|
|
|
// cause it would be funny
|
|
if (lastKnightSeenPlayer >= 0){
|
|
var tempitem = spawnPoints[lastKnightSeenPlayer];
|
|
if (tempitem.gameObject.activeInHierarchy){
|
|
Plugin.logger.LogDebug($"Using the last knight {tempitem.index} that saw a player");
|
|
unusedSpawnPoints.Remove(tempitem);
|
|
lastKnightSeenPlayer = -1;
|
|
return tempitem.index;
|
|
}
|
|
|
|
}
|
|
|
|
var index = UnityEngine.Random.Range(0, unusedSpawnPoints.Count);
|
|
var item = unusedSpawnPoints[index];
|
|
unusedSpawnPoints.RemoveAt(index);
|
|
|
|
return item.index;
|
|
}
|
|
|
|
public Transform GetSpawnPointTransform(int index){
|
|
return spawnPoints[index].transform;
|
|
}
|
|
|
|
|
|
}
|
|
}
|