Adventure Creator  1.55b
An adventure game toolkit for Unity, by Chris Burton, ICEBOX Studios 2013-2016
AC.StateHandler Class Reference
Inheritance diagram for AC.StateHandler:

Public Member Functions

void OnAwake ()
 
void RegisterWithGameEngine ()
 
void UnregisterWithGameEngine ()
 
void AfterLoad ()
 
bool PlayGlobalOnStart ()
 Runs the ActionListAsset defined in SettingsManager's actionListOnStart when the game begins. More...
 
void CanGlobalOnStart ()
 
void GatherObjects (bool afterDelete=false)
 Re-sets the internal arrays of GameObjects used to mass-update Adventure Creator each frame. It should be called whenever a GameObject is added to or removed from the scene. More...
 
void IgnoreNavMeshCollisions ()
 
void UpdateAllMaxVolumes ()
 
GameState GetLastNonPausedState ()
 Gets the last value of gameState that wasn't GameState.Paused. More...
 
void RestoreLastNonPausedState ()
 
void LimitHotspotsToCamera (_Camera _camera)
 Goes through all Hotspots in the scene, and limits their enabed state based on a specific _Camera, if appropriate. More...
 
void StartCutscene ()
 
void EndCutscene ()
 
bool IsInScriptedCutscene ()
 Checks if the game is currently in a user-scripted cutscene. More...
 
void SetACState (bool state)
 Enables or disables Adventure Creator completely. More...
 
bool IsACEnabled ()
 
void PreScreenshotBackup ()
 
void PostScreenshotBackup ()
 
void SetCursorSystem (bool state)
 Sets the enabled state of the PlayerCursor system. More...
 
void SetInputSystem (bool state)
 Sets the enabled state of the PlayerInput system. More...
 
void SetInteractionSystem (bool state)
 Sets the enabled state of the cursor system. More...
 
bool CanInteract ()
 Checks if the interaction system is enabled. More...
 
void SetMenuSystem (bool state)
 Sets the enabled state of the PlayerMenus system. More...
 
void SetMovementSystem (bool state)
 Sets the enabled state of the PlayerMovement system. More...
 
void SetCameraSystem (bool state)
 Sets the enabled state of the MainCamera system. More...
 
void SetTriggerSystem (bool state)
 Sets the enabled state of the trigger system. More...
 
void SetPlayerSystem (bool state)
 Sets the enabled state of the Player system. More...
 
bool AreTriggersDisabled ()
 Checks if the trigger system is disabled. More...
 
MainData SaveMainData (MainData mainData)
 Updates a MainData class with its own variables that need saving. More...
 
void LoadMainData (MainData mainData)
 Updates its own variables from a MainData class. More...
 
Music GetMusicEngine ()
 Gets the Music component used to handle AudioClips played using the 'Sound: Play music' Action. More...
 

Properties

GameState gameState [get, set]
 

Detailed Description

This script stores the all-important gameState variable, which determines if the game is running normal gameplay, is in a cutscene, or is paused. It also runs the various "Update", "LateUpdate", "FixedUpdate" and "OnGUI" functions that are within Adventure Creator's main scripts - by running them all from here, performance is drastically improved.

Member Function Documentation

void AC.StateHandler.AfterLoad ( )

Called after a scene change.

bool AC.StateHandler.AreTriggersDisabled ( )

Checks if the trigger system is disabled.

Returns
True if the trigger system is disabled
void AC.StateHandler.CanGlobalOnStart ( )

Allows the ActionListAsset defined in SettingsManager's actionListOnStart to be run again.

bool AC.StateHandler.CanInteract ( )

Checks if the interaction system is enabled.

Returns
True if the interaction system is enabled
void AC.StateHandler.EndCutscene ( )

Ends a hard-coded cutscene, started by calling StartCutscene().

void AC.StateHandler.GatherObjects ( bool  afterDelete = false)

Re-sets the internal arrays of GameObjects used to mass-update Adventure Creator each frame. It should be called whenever a GameObject is added to or removed from the scene.

Parameters
afterDeleteIf False, then IgnoreNavMeshCollisions() will also be run
GameState AC.StateHandler.GetLastNonPausedState ( )

Gets the last value of gameState that wasn't GameState.Paused.

Returns
The last value of gameState that wasn't GameState.Paused
Music AC.StateHandler.GetMusicEngine ( )

Gets the Music component used to handle AudioClips played using the 'Sound: Play music' Action.

Returns
The Music component used to handle AudioClips played using the 'Sound: Play music' Action.
void AC.StateHandler.IgnoreNavMeshCollisions ( )

Calls Physics.IgnoreCollision on all appropriate Collider combinations (Unity 5 only).

bool AC.StateHandler.IsInScriptedCutscene ( )

Checks if the game is currently in a user-scripted cutscene.

Returns
True if the game is currently in a user-scripted cutscene
void AC.StateHandler.LimitHotspotsToCamera ( _Camera  _camera)

Goes through all Hotspots in the scene, and limits their enabed state based on a specific _Camera, if appropriate.

Parameters
_cameraThe _Camera to attempt to limit all Hotspots to
void AC.StateHandler.LoadMainData ( MainData  mainData)

Updates its own variables from a MainData class.

Parameters
mainDataThe MainData class to load from
bool AC.StateHandler.PlayGlobalOnStart ( )

Runs the ActionListAsset defined in SettingsManager's actionListOnStart when the game begins.

Returns
True if an ActionListAsset was run
void AC.StateHandler.PostScreenshotBackup ( )

Restores the menu and cursor systems to their former states, after taking a screenshot.

void AC.StateHandler.PreScreenshotBackup ( )

Backs up the state of the menu and cursor systems, and disables them, before taking a screenshot.

void AC.StateHandler.RegisterWithGameEngine ( )

Alerts the StateHandler that a Game Engine prefab is present in the scene. This is called from KickStarter when the game begins - the StateHandler will not run until this is done.

void AC.StateHandler.RestoreLastNonPausedState ( )

Restores the gameState to its former state after un-pausing the game.

MainData AC.StateHandler.SaveMainData ( MainData  mainData)

Updates a MainData class with its own variables that need saving.

Parameters
mainDataThe original MainData class
Returns
The updated MainData class
void AC.StateHandler.SetACState ( bool  state)

Enables or disables Adventure Creator completely.

Parameters
stateIf True, then Adventure Creator will be enabled. If False, then Adventure Creator will be disabled.
void AC.StateHandler.SetCameraSystem ( bool  state)

Sets the enabled state of the MainCamera system.

Parameters
stateIf True, the MainCamera system will be enabled
void AC.StateHandler.SetCursorSystem ( bool  state)

Sets the enabled state of the PlayerCursor system.

Parameters
stateIf True, the PlayerCursor system will be enabled
void AC.StateHandler.SetInputSystem ( bool  state)

Sets the enabled state of the PlayerInput system.

Parameters
stateIf True, the PlayerInput system will be enabled
void AC.StateHandler.SetInteractionSystem ( bool  state)

Sets the enabled state of the cursor system.

Parameters
stateIf True, the cursor system will be enabled
void AC.StateHandler.SetMenuSystem ( bool  state)

Sets the enabled state of the PlayerMenus system.

Parameters
stateIf True, the PlayerMenus system will be enabled
void AC.StateHandler.SetMovementSystem ( bool  state)

Sets the enabled state of the PlayerMovement system.

Parameters
stateIf True, the PlayerMovement system will be enabled
void AC.StateHandler.SetPlayerSystem ( bool  state)

Sets the enabled state of the Player system.

Parameters
stateIf True, the Player system will be enabled
void AC.StateHandler.SetTriggerSystem ( bool  state)

Sets the enabled state of the trigger system.

Parameters
stateIf True, the trigger system will be enabled
void AC.StateHandler.StartCutscene ( )

Begins a hard-coded cutscene. Gameplay will resume once EndCutscene() is called.

void AC.StateHandler.UnregisterWithGameEngine ( )

Alerts the StateHandler that a Game Engine prefab is no longer present in the scene. This is called from KickStarter's OnDestroy function.

void AC.StateHandler.UpdateAllMaxVolumes ( )

Sets the maximum volume of all Sound objects in the scene.

Property Documentation

GameState AC.StateHandler.gameState
getset

The current state of the game (Normal, Cutscene, Paused, DialogOptions)