85 lines
2.7 KiB
C#
85 lines
2.7 KiB
C#
using System;
|
|
using System.Collections.Generic;
|
|
using System.Linq;
|
|
using System.Text;
|
|
using System.Threading.Tasks;
|
|
using UnityEngine;
|
|
using ScarletMansion.GamePatch.Components;
|
|
using ScarletMansion.Configs;
|
|
|
|
namespace ScarletMansion.GamePatch.FixValues {
|
|
public class FixFireExit : FixBaseClass<SpawnSyncedObject> {
|
|
|
|
public bool vanillaSetup;
|
|
|
|
[Header("Targets")]
|
|
public GameObject sdmGameObject;
|
|
public GameObject vanillaGameObject;
|
|
public List<GameObject> vanillaGameObjectGlobalPropTargets;
|
|
|
|
[Header("SDM Fire Exit")]
|
|
public GameObject sdmRenderGameObject;
|
|
public ScarletFireExit sdmFireExit;
|
|
|
|
[Header("Vanilla References")]
|
|
public SpawnSyncedObject vanillaSpawnSyncedObject;
|
|
public GameObject vanillaLightGameObject;
|
|
public GameObject vanillaCube001GameObject;
|
|
public GameObject vanillaCube002GameObject;
|
|
|
|
public bool EnableVanillaFireExit => !ConfigMain.Instance.useSDMFireExitsValue && vanillaSetup;
|
|
|
|
public void Awake(){
|
|
if (EnableVanillaFireExit){
|
|
sdmGameObject.SetActive(false);
|
|
sdmRenderGameObject.SetActive(false);
|
|
vanillaGameObject.SetActive(true);
|
|
}
|
|
}
|
|
|
|
public void OnDisable(){
|
|
foreach(var t in vanillaGameObjectGlobalPropTargets)
|
|
t.SetActive(false);
|
|
}
|
|
|
|
public void OnEnable(){
|
|
foreach(var t in vanillaGameObjectGlobalPropTargets)
|
|
t.SetActive(true);
|
|
}
|
|
|
|
public void Setup(GameObject blocker){
|
|
try {
|
|
vanillaSpawnSyncedObject.spawnPrefab = blocker.GetComponentInChildren<SpawnSyncedObject>().spawnPrefab;
|
|
CopyMeshAndRenderers("Light", vanillaLightGameObject);
|
|
CopyMeshAndRenderers("Cube.001", vanillaCube001GameObject);
|
|
CopyMeshAndRenderers("Cube.002", vanillaCube002GameObject);
|
|
|
|
void CopyMeshAndRenderers(string sourceName, GameObject target){
|
|
var source = Utility.FindChildRecurvisely(blocker.transform, sourceName);
|
|
target.GetComponent<MeshFilter>().sharedMesh = source.GetComponent<MeshFilter>().sharedMesh;
|
|
target.GetComponent<MeshRenderer>().sharedMaterials = source.GetComponent<MeshRenderer>().sharedMaterials;
|
|
}
|
|
|
|
vanillaSetup = true;
|
|
//Plugin.logger.LogInfo("Vanilla fire exit set up");
|
|
} catch (Exception e){
|
|
Plugin.logger.LogDebug("Failed to setup vanilla fire exit. The 'Use SDM Fire Exits' config will be ignored");
|
|
Plugin.logger.LogError(e.ToString());
|
|
|
|
vanillaSetup = false;
|
|
}
|
|
}
|
|
|
|
public void ForcefullyEnableDoorway(){
|
|
gameObject.SetActive(true);
|
|
sdmGameObject.SetActive(false);
|
|
sdmRenderGameObject.SetActive(false);
|
|
vanillaGameObject.SetActive(false);
|
|
}
|
|
|
|
public void ForcefullyEnableSDMRender(){
|
|
sdmRenderGameObject.SetActive(true);
|
|
}
|
|
|
|
}
|
|
}
|