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

Public Member Functions

void OnAwake ()
 
void _OnGUI ()
 
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)
 This method is now deprecrated and is not necessary.
 
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...
 
bool IsInCutscene ()
 Checks if the game is currently in a cutscene, scripted or otherwise. More...
 
bool IsPaused ()
 Checks if the game is currently paused. More...
 
bool IsInGameplay ()
 Checks if the game is currently in regular gameplay. More...
 
void SetACState (bool state)
 Enables or disables Adventure Creator completely. More...
 
bool IsACEnabled ()
 Checks if AC is currently enabled. More...
 
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 PlayerInteraction 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...
 
Ambience GetAmbienceEngine ()
 Gets the Ambience component used to handle AudioClips played using the 'Sound: Play ambience' Action. More...
 
void Register (ArrowPrompt _object)
 Registers an ArrowPrompt, so that it can be updated More...
 
void Unregister (ArrowPrompt _object)
 Unregisters an ArrowPrompt, so that it is no longer updated More...
 
void Register (DragBase _object)
 Registers a DragBase, so that it can be updated More...
 
void Unregister (DragBase _object)
 Unregisters a DragBase, so that it is no longer updated More...
 
void Register (Parallax2D _object)
 Registers a Parallax2D, so that it can be updated More...
 
void Unregister (Parallax2D _object)
 Unregisters a Parallax2D, so that it is no longer updated More...
 
void Register (Hotspot _object)
 Registers a Hotspot, so that it can be updated More...
 
void Unregister (Hotspot _object)
 Unregisters a Hotspot, so that it is no longer updated More...
 
void Register (Highlight _object)
 Registers a Highlight, so that it can be updated More...
 
void Unregister (Highlight _object)
 Unregisters a Highlight, so that it is no longer updated More...
 
void Register (AC_Trigger _object)
 Registers a AC_Trigger, so that it can be updated More...
 
void Unregister (AC_Trigger _object)
 Unregisters a AC_Trigger, so that it is no longer updated More...
 
void Register (_Camera _object)
 Registers a _Camera, so that it can be updated More...
 
void Unregister (_Camera _object)
 Unregisters a _Camera, so that it is no longer updated More...
 
void Register (Sound _object)
 Registers a Sound, so that it can be updated More...
 
void Unregister (Sound _object)
 Unregisters a Sound, so that it is no longer updated More...
 
void Register (LimitVisibility _object)
 Registers a LimitVisibility, so that it can be updated More...
 
void Unregister (LimitVisibility _object)
 Unregisters a LimitVisibility, so that it is no longer updated More...
 
void Register (Char _object)
 Registers a Char, so that it can be updated More...
 
void Unregister (Char _object)
 Unregisters a Char, so that it is no longer updated More...
 
void Register (FollowSortingMap _object)
 Registers a FollowSortingMap, so that it can be updated More...
 
void Unregister (FollowSortingMap _object)
 Unregisters a FollowSortingMap, so that it is no longer updated More...
 
void Register (NavMeshBase _object)
 Registers a NavMeshBase, so that it can be updated More...
 
void Unregister (NavMeshBase _object)
 Unregisters a NavMeshBase, so that it is no longer updated More...
 
void Register (SortingMap _object)
 Registers a SortingMap, so that it can be updated More...
 
void Unregister (SortingMap _object)
 Unregisters a SortingMap, so that it is no longer updated More...
 
void Register (BackgroundCamera _object)
 Registers a BackgroundCamera, so that it can be updated More...
 
void Unregister (BackgroundCamera _object)
 Unregisters a BackgroundCamera, so that it is no longer updated More...
 
void Register (BackgroundImage _object)
 Registers a BackgroundImage, so that it can be updated More...
 
void Unregister (BackgroundImage _object)
 Unregisters a BackgroundImage, so that it is no longer updated More...
 
void Register (ConstantID _object)
 Registers a ConstantID, so that it can be updated More...
 
void Unregister (ConstantID _object)
 Unregisters a ConstantID, so that it is no longer updated More...
 

Protected Member Functions

void Start ()
 
void Update ()
 
void LateUpdate ()
 
void FixedUpdate ()
 
void InitPersistentEngine ()
 
bool HasGameStateChanged ()
 
void CreateMusicEngine ()
 
void CreateAmbienceEngine ()
 
CreateSoundtrackEngine< T > (string resourceName)
 

Protected Attributes

GameState _gameState = GameState.Normal
 
Music music
 
Ambience ambience
 
bool inScriptedCutscene
 
GameState previousUpdateState = GameState.Normal
 
GameState lastNonPausedState = GameState.Normal
 
bool isACDisabled = false
 
bool cursorIsOff = false
 
bool inputIsOff = false
 
bool interactionIsOff = false
 
bool menuIsOff = false
 
bool movementIsOff = false
 
bool cameraIsOff = false
 
bool triggerIsOff = false
 
bool playerIsOff = false
 
bool runAtLeastOnce = false
 
bool hasGameEngine = false
 
List< ArrowPromptarrowPrompts = new List<ArrowPrompt>()
 
List< DragBasedragBases = new List<DragBase>()
 
List< Parallax2Dparallax2Ds = new List<Parallax2D>()
 
List< Hotspothotspots = new List<Hotspot>()
 
List< Highlighthighlights = new List<Highlight>()
 
List< AC_Triggertriggers = new List<AC_Trigger>()
 
List< _Cameracameras = new List<_Camera>()
 
List< Soundsounds = new List<Sound>()
 
List< LimitVisibilitylimitVisibilitys = new List<LimitVisibility>()
 
List< Charcharacters = new List<Char>()
 
List< FollowSortingMapfollowSortingMaps = new List<FollowSortingMap>()
 
List< NavMeshBasenavMeshBases = new List<NavMeshBase>()
 
List< SortingMapsortingMaps = new List<SortingMap>()
 
List< BackgroundCamerabackgroundCameras = new List<BackgroundCamera>()
 
List< BackgroundImagebackgroundImages = new List<BackgroundImage>()
 
List< ConstantIDconstantIDs = new List<ConstantID>()
 
int _i = 0
 

Properties

GameState gameState [get, set]
 
bool UnpausedLastFrame [get]
 
List< CharCharacters [get]
 
List< FollowSortingMapFollowSortingMaps [get]
 
List< SortingMapSortingMaps [get]
 
List< BackgroundCameraBackgroundCameras [get]
 
List< BackgroundImageBackgroundImages [get]
 
List< ConstantIDConstantIDs [get]
 
bool MovementIsOff [get]
 

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

◆ _OnGUI()

void AC.StateHandler._OnGUI ( )

Runs all of AC's OnGUI code. This is called automatically from within StateHandler, unless 'ACIgnoreOnGUI' is listed in Unity's Scripting Define Symbols box in the Player settings.

◆ AfterLoad()

void AC.StateHandler.AfterLoad ( )

Called after a scene change.

◆ AreTriggersDisabled()

bool AC.StateHandler.AreTriggersDisabled ( )

Checks if the trigger system is disabled.

Returns
True if the trigger system is disabled

◆ CanGlobalOnStart()

void AC.StateHandler.CanGlobalOnStart ( )

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

◆ CanInteract()

bool AC.StateHandler.CanInteract ( )

Checks if the interaction system is enabled.

Returns
True if the interaction system is enabled

◆ EndCutscene()

void AC.StateHandler.EndCutscene ( )

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

◆ GetAmbienceEngine()

Ambience AC.StateHandler.GetAmbienceEngine ( )

Gets the Ambience component used to handle AudioClips played using the 'Sound: Play ambience' Action.

Returns
The Ambience component used to handle AudioClips played using the 'Sound: Play ambience' Action.

◆ GetLastNonPausedState()

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

◆ GetMusicEngine()

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.

◆ IgnoreNavMeshCollisions()

void AC.StateHandler.IgnoreNavMeshCollisions ( )

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

◆ IsACEnabled()

bool AC.StateHandler.IsACEnabled ( )

Checks if AC is currently enabled.

Returns
Trye if AC is currently enabled.
Returns

◆ IsInCutscene()

bool AC.StateHandler.IsInCutscene ( )

Checks if the game is currently in a cutscene, scripted or otherwise.

Returns
True if the game is currently in a cutscene

◆ IsInGameplay()

bool AC.StateHandler.IsInGameplay ( )

Checks if the game is currently in regular gameplay.

Returns
True if the game is currently in regular gameplay

◆ IsInScriptedCutscene()

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

◆ IsPaused()

bool AC.StateHandler.IsPaused ( )

Checks if the game is currently paused.

Returns
True if the game is currently paused

◆ LimitHotspotsToCamera()

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

◆ LoadMainData()

void AC.StateHandler.LoadMainData ( MainData  mainData)

Updates its own variables from a MainData class.

Parameters
mainDataThe MainData class to load from

◆ PlayGlobalOnStart()

bool AC.StateHandler.PlayGlobalOnStart ( )

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

Returns
True if an ActionListAsset was run

◆ Register() [1/16]

void AC.StateHandler.Register ( ArrowPrompt  _object)

Registers an ArrowPrompt, so that it can be updated

Parameters
_objectThe ArrowPrompt to register

◆ Register() [2/16]

void AC.StateHandler.Register ( DragBase  _object)

Registers a DragBase, so that it can be updated

Parameters
_objectThe DragBase to register

◆ Register() [3/16]

void AC.StateHandler.Register ( Parallax2D  _object)

Registers a Parallax2D, so that it can be updated

Parameters
_objectThe Parallax2D to register

◆ Register() [4/16]

void AC.StateHandler.Register ( Hotspot  _object)

Registers a Hotspot, so that it can be updated

Parameters
_objectThe Hotspot to register

◆ Register() [5/16]

void AC.StateHandler.Register ( Highlight  _object)

Registers a Highlight, so that it can be updated

Parameters
_objectThe Highlight to register

◆ Register() [6/16]

void AC.StateHandler.Register ( AC_Trigger  _object)

Registers a AC_Trigger, so that it can be updated

Parameters
_objectThe AC_Trigger to register

◆ Register() [7/16]

void AC.StateHandler.Register ( _Camera  _object)

Registers a _Camera, so that it can be updated

Parameters
_objectThe _Camera to register

◆ Register() [8/16]

void AC.StateHandler.Register ( Sound  _object)

Registers a Sound, so that it can be updated

Parameters
_objectThe Sound to register

◆ Register() [9/16]

void AC.StateHandler.Register ( LimitVisibility  _object)

Registers a LimitVisibility, so that it can be updated

Parameters
_objectThe LimitVisibility to register

◆ Register() [10/16]

void AC.StateHandler.Register ( Char  _object)

Registers a Char, so that it can be updated

Parameters
_objectThe Char to register

◆ Register() [11/16]

void AC.StateHandler.Register ( FollowSortingMap  _object)

Registers a FollowSortingMap, so that it can be updated

Parameters
_objectThe FollowSortingMap to register

◆ Register() [12/16]

void AC.StateHandler.Register ( NavMeshBase  _object)

Registers a NavMeshBase, so that it can be updated

Parameters
_objectThe NavMeshBase to register

◆ Register() [13/16]

void AC.StateHandler.Register ( SortingMap  _object)

Registers a SortingMap, so that it can be updated

Parameters
_objectThe SortingMap to register

◆ Register() [14/16]

void AC.StateHandler.Register ( BackgroundCamera  _object)

Registers a BackgroundCamera, so that it can be updated

Parameters
_objectThe BackgroundCamera to register

◆ Register() [15/16]

void AC.StateHandler.Register ( BackgroundImage  _object)

Registers a BackgroundImage, so that it can be updated

Parameters
_objectThe BackgroundImage to register

◆ Register() [16/16]

void AC.StateHandler.Register ( ConstantID  _object)

Registers a ConstantID, so that it can be updated

Parameters
_objectThe ConstantID to register

◆ RegisterWithGameEngine()

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.

◆ RestoreLastNonPausedState()

void AC.StateHandler.RestoreLastNonPausedState ( )

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

◆ SaveMainData()

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

◆ SetACState()

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.

◆ SetCameraSystem()

void AC.StateHandler.SetCameraSystem ( bool  state)

Sets the enabled state of the MainCamera system.

Parameters
stateIf True, the MainCamera system will be enabled

◆ SetCursorSystem()

void AC.StateHandler.SetCursorSystem ( bool  state)

Sets the enabled state of the PlayerCursor system.

Parameters
stateIf True, the PlayerCursor system will be enabled

◆ SetInputSystem()

void AC.StateHandler.SetInputSystem ( bool  state)

Sets the enabled state of the PlayerInput system.

Parameters
stateIf True, the PlayerInput system will be enabled

◆ SetInteractionSystem()

void AC.StateHandler.SetInteractionSystem ( bool  state)

Sets the enabled state of the PlayerInteraction system.

Parameters
stateIf True, the PlayerInteraction system will be enabled

◆ SetMenuSystem()

void AC.StateHandler.SetMenuSystem ( bool  state)

Sets the enabled state of the PlayerMenus system.

Parameters
stateIf True, the PlayerMenus system will be enabled

◆ SetMovementSystem()

void AC.StateHandler.SetMovementSystem ( bool  state)

Sets the enabled state of the PlayerMovement system.

Parameters
stateIf True, the PlayerMovement system will be enabled

◆ SetPlayerSystem()

void AC.StateHandler.SetPlayerSystem ( bool  state)

Sets the enabled state of the Player system.

Parameters
stateIf True, the Player system will be enabled

◆ SetTriggerSystem()

void AC.StateHandler.SetTriggerSystem ( bool  state)

Sets the enabled state of the trigger system.

Parameters
stateIf True, the trigger system will be enabled

◆ StartCutscene()

void AC.StateHandler.StartCutscene ( )

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

◆ Unregister() [1/16]

void AC.StateHandler.Unregister ( ArrowPrompt  _object)

Unregisters an ArrowPrompt, so that it is no longer updated

Parameters
_objectThe ArrowPrompt to unregister

◆ Unregister() [2/16]

void AC.StateHandler.Unregister ( DragBase  _object)

Unregisters a DragBase, so that it is no longer updated

Parameters
_objectThe DragBase to unregister

◆ Unregister() [3/16]

void AC.StateHandler.Unregister ( Parallax2D  _object)

Unregisters a Parallax2D, so that it is no longer updated

Parameters
_objectThe Parallax2D to unregister

◆ Unregister() [4/16]

void AC.StateHandler.Unregister ( Hotspot  _object)

Unregisters a Hotspot, so that it is no longer updated

Parameters
_objectThe Hotspot to unregister

◆ Unregister() [5/16]

void AC.StateHandler.Unregister ( Highlight  _object)

Unregisters a Highlight, so that it is no longer updated

Parameters
_objectThe Highlight to unregister

◆ Unregister() [6/16]

void AC.StateHandler.Unregister ( AC_Trigger  _object)

Unregisters a AC_Trigger, so that it is no longer updated

Parameters
_objectThe AC_Trigger to unregister

◆ Unregister() [7/16]

void AC.StateHandler.Unregister ( _Camera  _object)

Unregisters a _Camera, so that it is no longer updated

Parameters
_objectThe _Camera to unregister

◆ Unregister() [8/16]

void AC.StateHandler.Unregister ( Sound  _object)

Unregisters a Sound, so that it is no longer updated

Parameters
_objectThe Sound to unregister

◆ Unregister() [9/16]

void AC.StateHandler.Unregister ( LimitVisibility  _object)

Unregisters a LimitVisibility, so that it is no longer updated

Parameters
_objectThe LimitVisibility to unregister

◆ Unregister() [10/16]

void AC.StateHandler.Unregister ( Char  _object)

Unregisters a Char, so that it is no longer updated

Parameters
_objectThe Char to unregister

◆ Unregister() [11/16]

void AC.StateHandler.Unregister ( FollowSortingMap  _object)

Unregisters a FollowSortingMap, so that it is no longer updated

Parameters
_objectThe FollowSortingMap to unregister

◆ Unregister() [12/16]

void AC.StateHandler.Unregister ( NavMeshBase  _object)

Unregisters a NavMeshBase, so that it is no longer updated

Parameters
_objectThe NavMeshBase to unregister

◆ Unregister() [13/16]

void AC.StateHandler.Unregister ( SortingMap  _object)

Unregisters a SortingMap, so that it is no longer updated

Parameters
_objectThe SortingMap to unregister

◆ Unregister() [14/16]

void AC.StateHandler.Unregister ( BackgroundCamera  _object)

Unregisters a BackgroundCamera, so that it is no longer updated

Parameters
_objectThe BackgroundCamera to unregister

◆ Unregister() [15/16]

void AC.StateHandler.Unregister ( BackgroundImage  _object)

Unregisters a BackgroundImage, so that it is no longer updated

Parameters
_objectThe BackgroundImage to unregister

◆ Unregister() [16/16]

void AC.StateHandler.Unregister ( ConstantID  _object)

Unregisters a ConstantID, so that it is no longer updated

Parameters
_objectThe ConstantID to unregister

◆ UnregisterWithGameEngine()

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.

◆ UpdateAllMaxVolumes()

void AC.StateHandler.UpdateAllMaxVolumes ( )

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

Property Documentation

◆ BackgroundCameras

List<BackgroundCamera> AC.StateHandler.BackgroundCameras
get

A List of all BackgroundCamera components found in the scene

◆ BackgroundImages

List<BackgroundImage> AC.StateHandler.BackgroundImages
get

A List of all BackgroundImage components found in the scene

◆ Characters

List<Char> AC.StateHandler.Characters
get

A List of all Char components found in the scene

◆ ConstantIDs

List<ConstantID> AC.StateHandler.ConstantIDs
get

A List of all ConstantID components found in the scene

◆ FollowSortingMaps

List<FollowSortingMap> AC.StateHandler.FollowSortingMaps
get

A List of all FollowSortingMap components found in the scene

◆ gameState

GameState AC.StateHandler.gameState
getset

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

◆ MovementIsOff

bool AC.StateHandler.MovementIsOff
get

True if the Movement system has been disabled

◆ SortingMaps

List<SortingMap> AC.StateHandler.SortingMaps
get

A List of all SortingMap components found in the scene