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

Public Member Functions

void Initialise (bool rebuildMenus=true)
 
void _OnGUI ()
 
void Register (KickStarter kickStarter)
 
void Unregister (KickStarter kickStarter)
 
bool PlayGlobalOnStart ()
 Runs the ActionListAsset defined in SettingsManager's actionListOnStart when the game begins. More...
 
void CanGlobalOnStart ()
 
void IgnoreNavMeshCollisions ()
 
void UpdateAllMaxVolumes ()
 
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 Interaction system. More...
 
void SetDraggableSystem (bool state)
 Sets the enabled state of the Draggable system. More...
 
bool CanInteract ()
 Checks if the interaction system is enabled. More...
 
bool CanInteractWithDraggables ()
 Checks if the draggables 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...
 
bool AreCamerasDisabled ()
 Checks if the camera 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 RegisterInitialConstantIDs ()
 
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 (Container _object)
 Registers a Container, so that it can be updated More...
 
void Unregister (Container _object)
 Unregisters a Container, 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 Update ()
 
void LateUpdate ()
 
void FixedUpdate ()
 
void OnGUI ()
 
void OnAddSubScene (SubScene subScene)
 
void OnInitialiseScene ()
 
void OnEnterGameState (GameState gameState)
 
void CreateMusicEngine ()
 
void CreateAmbienceEngine ()
 
bool CanRun ()
 

Protected Attributes

Music music
 
Ambience ambience
 
bool inScriptedCutscene
 
bool inScriptedPause
 
GameState previousUpdateState = GameState.Normal
 
bool isACDisabled = false
 
bool cursorIsOff = false
 
bool inputIsOff = false
 
bool interactionIsOff = false
 
bool draggablesIsOff = false
 
bool menuIsOff = false
 
bool movementIsOff = false
 
bool cameraIsOff = false
 
bool triggerIsOff = false
 
bool playerIsOff = false
 
bool runAtLeastOnce = false
 
KickStarter activeKickStarter = null
 
HashSet< ArrowPromptarrowPrompts = new HashSet<ArrowPrompt>()
 
HashSet< DragBasedragBases = new HashSet<DragBase>()
 
HashSet< Parallax2Dparallax2Ds = new HashSet<Parallax2D>()
 
HashSet< Hotspothotspots = new HashSet<Hotspot>()
 
HashSet< Highlighthighlights = new HashSet<Highlight>()
 
HashSet< AC_Triggertriggers = new HashSet<AC_Trigger>()
 
HashSet< _Cameracameras = new HashSet<_Camera>()
 
HashSet< Soundsounds = new HashSet<Sound>()
 
HashSet< LimitVisibilitylimitVisibilitys = new HashSet<LimitVisibility>()
 
HashSet< Charcharacters = new HashSet<Char>()
 
HashSet< FollowSortingMapfollowSortingMaps = new HashSet<FollowSortingMap>()
 
HashSet< NavMeshBasenavMeshBases = new HashSet<NavMeshBase>()
 
HashSet< SortingMapsortingMaps = new HashSet<SortingMap>()
 
HashSet< BackgroundCamerabackgroundCameras = new HashSet<BackgroundCamera>()
 
HashSet< BackgroundImagebackgroundImages = new HashSet<BackgroundImage>()
 
HashSet< Containercontainers = new HashSet<Container> ()
 
ConstantIDManager constantIDManager
 
int _i = 0
 

Properties

GameState gameState [get]
 
bool EnforceCutsceneMode [get, set]
 
bool EnforcePauseMode [get, set]
 
HashSet< CharCharacters [get]
 
HashSet< SoundSounds [get]
 
HashSet< ConstantIDConstantIDs [get]
 
HashSet< HotspotHotspots [get]
 
HashSet< FollowSortingMapFollowSortingMaps [get]
 
HashSet< SortingMapSortingMaps [get]
 
HashSet< BackgroundCameraBackgroundCameras [get]
 
HashSet< BackgroundImageBackgroundImages [get]
 
HashSet< ContainerContainers [get]
 
HashSet< _CameraCameras [get]
 
ConstantIDManager ConstantIDManager [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.

◆ AreCamerasDisabled()

bool AC.StateHandler.AreCamerasDisabled ( )

Checks if the camera system is disabled.

Returns
True if the camera system is disabled

◆ 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

◆ CanInteractWithDraggables()

bool AC.StateHandler.CanInteractWithDraggables ( )

Checks if the draggables system is enabled.

Returns
True if the draggables system is enabled

◆ 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.

◆ 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

◆ IsPaused()

bool AC.StateHandler.IsPaused ( )

Checks if the game is currently paused.

Returns
True if the game is currently paused

◆ 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/18]

void AC.StateHandler.Register ( _Camera  _object)

Registers a _Camera, so that it can be updated

Parameters
_objectThe _Camera to register

◆ Register() [2/18]

void AC.StateHandler.Register ( AC_Trigger  _object)

Registers a AC_Trigger, so that it can be updated

Parameters
_objectThe AC_Trigger to register

◆ Register() [3/18]

void AC.StateHandler.Register ( ArrowPrompt  _object)

Registers an ArrowPrompt, so that it can be updated

Parameters
_objectThe ArrowPrompt to register

◆ Register() [4/18]

void AC.StateHandler.Register ( BackgroundCamera  _object)

Registers a BackgroundCamera, so that it can be updated

Parameters
_objectThe BackgroundCamera to register

◆ Register() [5/18]

void AC.StateHandler.Register ( BackgroundImage  _object)

Registers a BackgroundImage, so that it can be updated

Parameters
_objectThe BackgroundImage to register

◆ Register() [6/18]

void AC.StateHandler.Register ( Char  _object)

Registers a Char, so that it can be updated

Parameters
_objectThe Char to register

◆ Register() [7/18]

void AC.StateHandler.Register ( ConstantID  _object)

Registers a ConstantID, so that it can be updated

Parameters
_objectThe ConstantID to register

◆ Register() [8/18]

void AC.StateHandler.Register ( Container  _object)

Registers a Container, so that it can be updated

Parameters
_objectThe Container to register

◆ Register() [9/18]

void AC.StateHandler.Register ( DragBase  _object)

Registers a DragBase, so that it can be updated

Parameters
_objectThe DragBase to register

◆ Register() [10/18]

void AC.StateHandler.Register ( FollowSortingMap  _object)

Registers a FollowSortingMap, so that it can be updated

Parameters
_objectThe FollowSortingMap to register

◆ Register() [11/18]

void AC.StateHandler.Register ( Highlight  _object)

Registers a Highlight, so that it can be updated

Parameters
_objectThe Highlight to register

◆ Register() [12/18]

void AC.StateHandler.Register ( Hotspot  _object)

Registers a Hotspot, so that it can be updated

Parameters
_objectThe Hotspot to register

◆ Register() [13/18]

void AC.StateHandler.Register ( KickStarter  kickStarter)

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.

◆ Register() [14/18]

void AC.StateHandler.Register ( LimitVisibility  _object)

Registers a LimitVisibility, so that it can be updated

Parameters
_objectThe LimitVisibility to register

◆ Register() [15/18]

void AC.StateHandler.Register ( NavMeshBase  _object)

Registers a NavMeshBase, so that it can be updated

Parameters
_objectThe NavMeshBase to register

◆ Register() [16/18]

void AC.StateHandler.Register ( Parallax2D  _object)

Registers a Parallax2D, so that it can be updated

Parameters
_objectThe Parallax2D to register

◆ Register() [17/18]

void AC.StateHandler.Register ( SortingMap  _object)

Registers a SortingMap, so that it can be updated

Parameters
_objectThe SortingMap to register

◆ Register() [18/18]

void AC.StateHandler.Register ( Sound  _object)

Registers a Sound, so that it can be updated

Parameters
_objectThe Sound to register

◆ RegisterInitialConstantIDs()

void AC.StateHandler.RegisterInitialConstantIDs ( )

Creates an initial record of all ConstantID components in the Hierarchy. More may be added through OnEnable / Start functions, but this way those that are initially present are ensured to be included in initialisation processes

◆ 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

◆ SetDraggableSystem()

void AC.StateHandler.SetDraggableSystem ( bool  state)

Sets the enabled state of the Draggable system.

Parameters
stateIf True, the Draggable 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 Interaction system.

Parameters
stateIf True, the Interaction 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

◆ Unregister() [1/18]

void AC.StateHandler.Unregister ( _Camera  _object)

Unregisters a _Camera, so that it is no longer updated

Parameters
_objectThe _Camera to unregister

◆ Unregister() [2/18]

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() [3/18]

void AC.StateHandler.Unregister ( ArrowPrompt  _object)

Unregisters an ArrowPrompt, so that it is no longer updated

Parameters
_objectThe ArrowPrompt to unregister

◆ Unregister() [4/18]

void AC.StateHandler.Unregister ( BackgroundCamera  _object)

Unregisters a BackgroundCamera, so that it is no longer updated

Parameters
_objectThe BackgroundCamera to unregister

◆ Unregister() [5/18]

void AC.StateHandler.Unregister ( BackgroundImage  _object)

Unregisters a BackgroundImage, so that it is no longer updated

Parameters
_objectThe BackgroundImage to unregister

◆ Unregister() [6/18]

void AC.StateHandler.Unregister ( Char  _object)

Unregisters a Char, so that it is no longer updated

Parameters
_objectThe Char to unregister

◆ Unregister() [7/18]

void AC.StateHandler.Unregister ( ConstantID  _object)

Unregisters a ConstantID, so that it is no longer updated

Parameters
_objectThe ConstantID to unregister

◆ Unregister() [8/18]

void AC.StateHandler.Unregister ( Container  _object)

Unregisters a Container, so that it is no longer updated

Parameters
_objectThe Container to unregister

◆ Unregister() [9/18]

void AC.StateHandler.Unregister ( DragBase  _object)

Unregisters a DragBase, so that it is no longer updated

Parameters
_objectThe DragBase to unregister

◆ Unregister() [10/18]

void AC.StateHandler.Unregister ( FollowSortingMap  _object)

Unregisters a FollowSortingMap, so that it is no longer updated

Parameters
_objectThe FollowSortingMap to unregister

◆ Unregister() [11/18]

void AC.StateHandler.Unregister ( Highlight  _object)

Unregisters a Highlight, so that it is no longer updated

Parameters
_objectThe Highlight to unregister

◆ Unregister() [12/18]

void AC.StateHandler.Unregister ( Hotspot  _object)

Unregisters a Hotspot, so that it is no longer updated

Parameters
_objectThe Hotspot to unregister

◆ Unregister() [13/18]

void AC.StateHandler.Unregister ( KickStarter  kickStarter)

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

◆ Unregister() [14/18]

void AC.StateHandler.Unregister ( LimitVisibility  _object)

Unregisters a LimitVisibility, so that it is no longer updated

Parameters
_objectThe LimitVisibility to unregister

◆ Unregister() [15/18]

void AC.StateHandler.Unregister ( NavMeshBase  _object)

Unregisters a NavMeshBase, so that it is no longer updated

Parameters
_objectThe NavMeshBase to unregister

◆ Unregister() [16/18]

void AC.StateHandler.Unregister ( Parallax2D  _object)

Unregisters a Parallax2D, so that it is no longer updated

Parameters
_objectThe Parallax2D to unregister

◆ Unregister() [17/18]

void AC.StateHandler.Unregister ( SortingMap  _object)

Unregisters a SortingMap, so that it is no longer updated

Parameters
_objectThe SortingMap to unregister

◆ Unregister() [18/18]

void AC.StateHandler.Unregister ( Sound  _object)

Unregisters a Sound, so that it is no longer updated

Parameters
_objectThe Sound to unregister

◆ UpdateAllMaxVolumes()

void AC.StateHandler.UpdateAllMaxVolumes ( )

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

Property Documentation

◆ BackgroundCameras

HashSet<BackgroundCamera> AC.StateHandler.BackgroundCameras
get

A HashSet of all BackgroundCamera components found in the scene

◆ BackgroundImages

HashSet<BackgroundImage> AC.StateHandler.BackgroundImages
get

A HashSet of all BackgroundImage components found in the scene

◆ Cameras

HashSet<_Camera> AC.StateHandler.Cameras
get

A HashSet of all _Camera components found in the scene

◆ Characters

HashSet<Char> AC.StateHandler.Characters
get

A HashSet of all Char components found in the scene

◆ ConstantIDManager

ConstantIDManager AC.StateHandler.ConstantIDManager
get

The ConstantIDManager used to record all ConstantID components in the Hierarchy

◆ ConstantIDs

HashSet<ConstantID> AC.StateHandler.ConstantIDs
get

A HashSet of all ConstantID components found in the scene

◆ Containers

HashSet<Container> AC.StateHandler.Containers
get

A HashSet of all Container components found in the scene

◆ EnforceCutsceneMode

bool AC.StateHandler.EnforceCutsceneMode
getset

Sets the state of enforced cutscene mode. This is used to block gameplay etc through custom scripting, as opposed to ActionLists

◆ EnforcePauseMode

bool AC.StateHandler.EnforcePauseMode
getset

Sets the state of enforced pause mode. This is used to pause the game without requiring a pausing menu to be enabled

◆ FollowSortingMaps

HashSet<FollowSortingMap> AC.StateHandler.FollowSortingMaps
get

A HashSet of all FollowSortingMap components found in the scene

◆ gameState

GameState AC.StateHandler.gameState
get

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

◆ Hotspots

HashSet<Hotspot> AC.StateHandler.Hotspots
get

A HashSet of all Hotspot components found in the scene

◆ MovementIsOff

bool AC.StateHandler.MovementIsOff
get

True if the Movement system has been disabled

◆ SortingMaps

HashSet<SortingMap> AC.StateHandler.SortingMaps
get

A HashSet of all SortingMap components found in the scene

◆ Sounds

HashSet<Sound> AC.StateHandler.Sounds
get

A HashSet of all Sound components found in the scene