mirror of
https://github.com/tym1116/BH3.git
synced 2025-12-16 16:34:41 +01:00
116 lines
2.1 KiB
C#
116 lines
2.1 KiB
C#
using System.Collections.Generic;
|
|
using CinemaDirector.Helpers;
|
|
using UnityEngine;
|
|
|
|
namespace CinemaDirector
|
|
{
|
|
[CutsceneItem("Utility", "Mass Disabler", new CutsceneItemGenre[] { CutsceneItemGenre.GlobalItem })]
|
|
public class MassDisabler : CinemaGlobalAction, IRevertable
|
|
{
|
|
public List<GameObject> GameObjects = new List<GameObject>();
|
|
|
|
public List<string> Tags = new List<string>();
|
|
|
|
private List<GameObject> tagsCache = new List<GameObject>();
|
|
|
|
[SerializeField]
|
|
private RevertMode editorRevertMode;
|
|
|
|
[SerializeField]
|
|
private RevertMode runtimeRevertMode;
|
|
|
|
public RevertMode EditorRevertMode
|
|
{
|
|
get
|
|
{
|
|
return editorRevertMode;
|
|
}
|
|
set
|
|
{
|
|
editorRevertMode = value;
|
|
}
|
|
}
|
|
|
|
public RevertMode RuntimeRevertMode
|
|
{
|
|
get
|
|
{
|
|
return runtimeRevertMode;
|
|
}
|
|
set
|
|
{
|
|
runtimeRevertMode = value;
|
|
}
|
|
}
|
|
|
|
public RevertInfo[] CacheState()
|
|
{
|
|
List<GameObject> list = new List<GameObject>();
|
|
foreach (string tag in Tags)
|
|
{
|
|
GameObject[] array = GameObject.FindGameObjectsWithTag(tag);
|
|
GameObject[] array2 = array;
|
|
foreach (GameObject gameObject in array2)
|
|
{
|
|
if (gameObject != null)
|
|
{
|
|
list.Add(gameObject);
|
|
}
|
|
}
|
|
}
|
|
list.AddRange(GameObjects);
|
|
List<RevertInfo> list2 = new List<RevertInfo>();
|
|
foreach (GameObject item in list)
|
|
{
|
|
if (item != null)
|
|
{
|
|
list2.Add(new RevertInfo(this, item, "SetActive", item.activeInHierarchy));
|
|
}
|
|
}
|
|
return list2.ToArray();
|
|
}
|
|
|
|
public override void Trigger()
|
|
{
|
|
tagsCache.Clear();
|
|
foreach (string tag in Tags)
|
|
{
|
|
GameObject[] array = GameObject.FindGameObjectsWithTag(tag);
|
|
GameObject[] array2 = array;
|
|
foreach (GameObject item in array2)
|
|
{
|
|
tagsCache.Add(item);
|
|
}
|
|
}
|
|
setActive(false);
|
|
}
|
|
|
|
public override void End()
|
|
{
|
|
setActive(true);
|
|
}
|
|
|
|
public override void ReverseTrigger()
|
|
{
|
|
End();
|
|
}
|
|
|
|
public override void ReverseEnd()
|
|
{
|
|
Trigger();
|
|
}
|
|
|
|
private void setActive(bool enabled)
|
|
{
|
|
foreach (GameObject gameObject in GameObjects)
|
|
{
|
|
gameObject.SetActive(enabled);
|
|
}
|
|
foreach (GameObject item in tagsCache)
|
|
{
|
|
item.SetActive(enabled);
|
|
}
|
|
}
|
|
}
|
|
}
|