-
Notifications
You must be signed in to change notification settings - Fork 0
Cyclops References
Indigocoder1 edited this page Oct 23, 2024
·
5 revisions
Sub Library has a system for referencing objects on the Cyclops called the CyclopsReferenceHandler
. It provides a reference to the Cyclops prefab after a coroutine setup.
You can access it directly via CyclopsReferenceHandler.CyclopsReference
, or by using the interface ICyclopsReferencer
. The latter must be called manually during prefab setup, either using a foreach loop or by using InterfaceCallerHandler.InvokeCyclopsReferencers()
and passing in your prefab root.
Example prefab setup code (Without using Interface Handler):
GameObject model = Main_Plugin.AssetBundle.LoadAsset<GameObject>("ChameleonSub");
model.SetActive(false);
GameObject chameleon = GameObject.Instantiate(model);
yield return new WaitUntil(() => MaterialUtils.IsReady);
//Apply shaders first so you don't mess with the instantiated stuff
MaterialUtils.ApplySNShaders(chameleon, shininess: 1f);
yield return CyclopsReferenceManager.EnsureCyclopsReference();
foreach (ICyclopsReferencer referencer in chameleon.GetComponentsInChildren<ICyclopsReferencer>())
{
referencer.OnCyclopsReferenceFinished(CyclopsReferenceManager.CyclopsReference);
}
prefabOut.Set(chameleon);
Example interface implementation:
internal class ChameleonFXAssigner : MonoBehaviour, ICyclopsReferencer
{
public VFXController controller;
public Vector3 interiorExplosionScale = Vector3.one;
public Vector3 exteriorExplosionScale = Vector3.one;
public void OnCyclopsReferenceFinished(GameObject cyclops)
{
VFXController cyclopsController = cyclops.transform.Find("FX/CyclopsExplosionFX").GetComponent<VFXController>();
controller.emitters[0].fx = cyclopsController.emitters[0].fx;
controller.emitters[1].fx = cyclopsController.emitters[1].fx;
controller.emitters[0].fx.transform.localScale = interiorExplosionScale;
controller.emitters[1].fx.transform.localScale = exteriorExplosionScale;
}
}
Code examples taken from the Chameleon repo.
While this doesn't use the Sub Library, it has its own system using the same concepts which can be applied here