70 lines
1.8 KiB
C#
70 lines
1.8 KiB
C#
using System;
|
|
using System.Collections.Generic;
|
|
using System.Linq;
|
|
using System.Text;
|
|
using System.Threading.Tasks;
|
|
using DunGen;
|
|
using UnityEngine;
|
|
using ScarletMansion.GamePatch.Managers;
|
|
|
|
namespace ScarletMansion.DunGenPatch.Doorways {
|
|
public class DoorwayCleanup : MonoBehaviour, IDungeonCompleteReceiver {
|
|
|
|
[Header("Doorway References")]
|
|
public Doorway doorway;
|
|
public List<GameObject> connectors;
|
|
public List<GameObject> blockers;
|
|
public GameObject doorwayGameObject;
|
|
|
|
[Header("Cleanup References")]
|
|
public DCleanBase[] cleanupList;
|
|
|
|
[Header("Overrides")]
|
|
public bool overrideConnector;
|
|
public bool overrideNoDoorway;
|
|
|
|
[ContextMenu("Populate")]
|
|
public void Populate(){
|
|
cleanupList = GetComponents<DCleanBase>();
|
|
}
|
|
|
|
void Reset(){
|
|
doorway = GetComponent<Doorway>();
|
|
}
|
|
|
|
public void OnDungeonComplete(Dungeon dungeon) {
|
|
DoorwayManager.Instance.AddDoorwayCleanup(this);
|
|
}
|
|
|
|
public void Cleanup(){
|
|
// start up like in original
|
|
SwitchConnectorBlocker(doorway.ConnectedDoorway != null);
|
|
|
|
foreach(var c in cleanupList)
|
|
c.Cleanup();
|
|
|
|
if (overrideNoDoorway) SwitchDoorwayGameObject(false);
|
|
|
|
// clean up like in original
|
|
foreach(var c in connectors){
|
|
if (!c.activeSelf) UnityEngine.Object.DestroyImmediate(c, false);
|
|
}
|
|
|
|
foreach(var b in blockers){
|
|
if (!b.activeSelf) UnityEngine.Object.DestroyImmediate(b, false);
|
|
}
|
|
}
|
|
|
|
public void SwitchConnectorBlocker(bool isConnector){
|
|
if (overrideConnector) isConnector = true;
|
|
foreach(var c in connectors) c.SetActive(isConnector);
|
|
foreach(var b in blockers) b.SetActive(!isConnector);
|
|
}
|
|
|
|
public void SwitchDoorwayGameObject(bool isActive){
|
|
doorwayGameObject.SetActive(isActive);
|
|
}
|
|
|
|
}
|
|
}
|