SceneModule - HueSamai/CementSource GitHub Wiki

Description and quick example

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:

CustomScene class

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.

name

 public string name { get; private set; }

Get the name of a custom scene. Get only.

constructor

public CustomScene(string name)

Create a new blank CustomScene instance, specifying the name, and configure it with the CustomSCeneManager.

InvokeOnLoad

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.

InvokeOnLoad

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.

AddObject

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.

AddObjects

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.

RemoveAllObjects

public void RemoveAllObjects()

Removes all objects which were added to a custom scene.

Load (SHOULD NOT BE USED)

public void Load()

Instantiates the CustomScene's objects and invokes all the OnLoad callbacks. Used by CustomSceneManager

⚠️ **GitHub.com Fallback** ⚠️