SceneModule - HueSamai/CementSource GitHub Wiki
The SceneModule allows you to load a game object as if it was a Gang Beasts map. In the current version it is very limited.
Here is a basic example:
using CementTools.Modules.SceneModule;
// methods go in a CementMod
void CreateCustomScene()
{
// this is just loading an asset bundle and has nothing to do with the SceneModule. Check see also
AssetBundle exampleBundle = AssetBundle.LoadFromFile(Path.Combine(modDirectoryPath, "example"));
GameObject sceneObject = exampleBundle.LoadAsset<GameObject>();
// when we construct a new CustomScene, it gets automatically configured with the CustomSceneManager
new CustomScene("Example Map")
.AddObject(sceneObject)
.InvokeOnLoad(OnLoad)
CustomSceneManager.LoadScene("Example Map");
}
void OnLoad()
{
// do map loaded logic here
Cement.Log("Map loaded!");
}
See also:
Class that stores scene data for custom scenes/maps. Allows you to add custom objects to the scene and perform custom logic when the scene is loaded. CustomScene instances are used by the CustomSceneManager to load scene data.
public string name { get; private set; }
Get the name of a custom scene. Get only.
public CustomScene(string name)
Create a new blank CustomScene instance, specifying the name, and configure it with the CustomSCeneManager.
public CustomScene InvokeOnLoad(Action action)
Add a callback for when the CustomScene gets loaded. Returns the CustomScene so that another method can be called after.
public CustomScene InvokeOnLoad(IEnumerable<Action> action)
Add multiple callbacks for when a CustomScene gets loaded. Returns the CustomScene so that another method can be called after.
public CustomScene AddObject(GameObject gameObject)
Add an object that will get instantiated when the CustomScene gets loaded. Returns the CustomScene so that another method can be called after.
public CustomScene AddObjects(IEnumberable<GameObject> gameObjects)
Add multiple objects at a time that will each get instantiated when the CustomScene gets loaded. Returns the CustomScene so that another method can be called after.
public void RemoveAllObjects()
Removes all objects which were added to a custom scene.
public void Load()
Instantiates the CustomScene's objects and invokes all the OnLoad callbacks. Used by CustomSceneManager