PowerQuest 0.20.0
Loading...
Searching...
No Matches
RoomScript Class Reference

Detailed Description

Each room you create will have its own room class and script file. These are created automatically with the name appended, eg: RoomForest.cs.

There are some additional helpful properties you can use in room scripts:

  • FirstTimeVisted property - This is true the first time the player visits the room
  • EnteredFromEditor property - This is true when testing your game, if you've pressed play in the editor from this script's room. Useful for setting up things so you can test from a particular room (eg, give the player an item they should have in that room).

Public Member Functions

void OnEnterRoom ()
 Called whenever you enter a room, before fading in. Non-blocking functions only.
Use this function to set up stuff you need to in your room, like where characters should be standing. You can also do this at the top of OnEnterRoomAfterFade.
 
IEnumerator OnEnterRoomAfterFade ()
 Blocking script called whenever you enter a room, after fade in is complete. This is where you put things that happen when you enter a room.
 
IEnumerator OnExitRoom (IRoom oldRoom, IRoom newRoom)
 Blocking script called whenever you exit a room, as it fades out.
 
IEnumerator UpdateBlocking ()
 Blocking script called every frame when no other scripts are blocking.
 
void Update ()
 Runs in the background and is called every frame. Non-blocking functions only!
 
IEnumerator OnAnyClick ()
 Blocking script called whenever the player clicks anywhere. This function is called before any other click interaction. Any blocking code here will stop another interaction from happening.
 
IEnumerator AfterAnyClick ()
 Blocking script called after a click has triggered any other interaction.
 
IEnumerator OnWalkTo (Vector2 position)
 Blocking script called whenever the player tries to walk somewhere. Even if C.Player.Moveable is set to false. Any blocking code here will interrupt them from walking. The position parameter will have the target position they were trying to walk to.
 
void OnPostRestore (int version)
 Called after restoring a game. Use this if you need to update any references based on saved data. Non-blocking functions only.
 
IEnumerator OnInteractHotspot (IHotspot hotspot)
 Blocking script called when "Interact" is used on a hotspot. The name is appended to the function, eg: OnInteractHotspotTree(...).
 
IEnumerator OnLookAtHotspot (IHotspot hotspot)
 Blocking script called when "Look At" is used on a hotspot. The name is appended to the function, eg: OnLookAtHotspotTree(...).
 
IEnumerator OnUseInvHotspot (IHotspot hotspot, IInventory item)
 Blocking script called when an item is used on a hotspot. The name is appended to the function, eg: OnUseInvHotspotTree(...). Query the passed in 'item' to see if you should perform the action. Eg: ‘if ( item == I.Key ) {...}’ or 'if ( I.Key.Active ) {...}'.
 
IEnumerator OnInteractProp (IProp prop)
 Blocking script called when "Interact" is used on a prop. The name is appended to the function, eg: OnInteractPropDoor(...).
 
IEnumerator OnLookAtProp (IProp prop)
 Blocking script called when "Look At" is used on a prop. The name is appended to the function, eg: OnLookAtPropDoor(...).
 
IEnumerator OnUseInvProp (IProp prop, IInventory item)
 Blocking script called when an item is used on a prop. The name is appended to the function, eg: OnUseInvPropDoor(...). Query the passed in 'item' to see if you should perform the action. Eg: ‘if ( item == I.Key ) {...}’ or 'if ( I.Key.Active ) {...}'.
 
IEnumerator OnInteractCharacter (ICharacter character)
 Blocking script called when "Interact" is used on a character. The name is appended to the function, eg: OnInteractCharacterBarney(...).
 
IEnumerator OnLookAtCharacter (ICharacter character)
 Blocking script called when "Look At" is used on a character. The name is appended to the function, eg: OnLookAtCharacterBarney(...).
 
IEnumerator OnUseInvCharacter (ICharacter character, IInventory item)
 Blocking script called when an item is used on a character. The name is appended to the function, eg: OnUseInvCharacterBarney(...). Query the passed in 'item' to see if you should perform the action. Eg: ‘if ( item == I.Key ) {...}’ or 'if ( I.Key.Active ) {...}'.
 
IEnumerator OnEnterRegion (IRegion region, ICharacter character)
 Blocking script called when a character enters the region. The name is appended to the function, eg: OnEnterRegionDoorway(...). Note: If region isn't set to be player only you can check if it's the player with if ( character.IsPlayer ).
 
IEnumerator OnExitRegion (IRegion region, ICharacter character)
 Blocking script called when a character exits the region. The name is appended to the function, eg: OnExitRegionDoorway(...). Note: If region isn't set to be player only you can check if it's the player with if ( character.IsPlayer ).
 
IEnumerator UnhandledInteract (IQuestClickable mouseOver)
 Called before GlobalScript.UnhandledInteract so you can override its default behaviour in a particular room.
 
IEnumerator UnhandledLookAt (IQuestClickable mouseOver)
 Called before GlobalScript.UnhandledLookAt so you can override its default behaviour in a particular room.
 
IEnumerator UnhandledUseInv (IQuestClickable mouseOver, IInventory item)
 Called before GlobalScript.UnhandledUseInv so you can override its default behaviour in a particular room.
 

Member Function Documentation

◆ OnEnterRoom()

void OnEnterRoom ( )

Called whenever you enter a room, before fading in. Non-blocking functions only.
Use this function to set up stuff you need to in your room, like where characters should be standing. You can also do this at the top of OnEnterRoomAfterFade.

◆ OnEnterRoomAfterFade()

IEnumerator OnEnterRoomAfterFade ( )

Blocking script called whenever you enter a room, after fade in is complete. This is where you put things that happen when you enter a room.

Here there's a few extra helpful properties you can use here- Use if (FirstTimeVisited) {...} for things to that happen the first time the player visits. Use if (EnteredFromEditor) {...} when you only want things to happen.

◆ OnExitRoom()

IEnumerator OnExitRoom ( IRoom oldRoom,
IRoom newRoom )

Blocking script called whenever you exit a room, as it fades out.

◆ UpdateBlocking()

IEnumerator UpdateBlocking ( )

Blocking script called every frame when no other scripts are blocking.

◆ Update()

void Update ( )

Runs in the background and is called every frame. Non-blocking functions only!

◆ OnAnyClick()

IEnumerator OnAnyClick ( )

Blocking script called whenever the player clicks anywhere. This function is called before any other click interaction. Any blocking code here will stop another interaction from happening.

See also
AfterAnyClick

◆ AfterAnyClick()

IEnumerator AfterAnyClick ( )

Blocking script called after a click has triggered any other interaction.

See also
OnAnyClick

◆ OnWalkTo()

IEnumerator OnWalkTo ( Vector2 position)

Blocking script called whenever the player tries to walk somewhere. Even if C.Player.Moveable is set to false. Any blocking code here will interrupt them from walking. The position parameter will have the target position they were trying to walk to.

Eg.

if ( I.HeavyItem.Owned )
    Dave: I can't move I'm encumbered!
Barney: I'm not though, I'll go there instead!
C.Barney.WalkTo(position);

◆ OnPostRestore()

void OnPostRestore ( int version)

Called after restoring a game. Use this if you need to update any references based on saved data. Non-blocking functions only.

◆ OnInteractHotspot()

IEnumerator OnInteractHotspot ( IHotspot hotspot)

Blocking script called when "Interact" is used on a hotspot. The name is appended to the function, eg: OnInteractHotspotTree(...).

◆ OnLookAtHotspot()

IEnumerator OnLookAtHotspot ( IHotspot hotspot)

Blocking script called when "Look At" is used on a hotspot. The name is appended to the function, eg: OnLookAtHotspotTree(...).

◆ OnUseInvHotspot()

IEnumerator OnUseInvHotspot ( IHotspot hotspot,
IInventory item )

Blocking script called when an item is used on a hotspot. The name is appended to the function, eg: OnUseInvHotspotTree(...). Query the passed in 'item' to see if you should perform the action. Eg: ‘if ( item == I.Key ) {...}’ or 'if ( I.Key.Active ) {...}'.

◆ OnInteractProp()

IEnumerator OnInteractProp ( IProp prop)

Blocking script called when "Interact" is used on a prop. The name is appended to the function, eg: OnInteractPropDoor(...).

◆ OnLookAtProp()

IEnumerator OnLookAtProp ( IProp prop)

Blocking script called when "Look At" is used on a prop. The name is appended to the function, eg: OnLookAtPropDoor(...).

◆ OnUseInvProp()

IEnumerator OnUseInvProp ( IProp prop,
IInventory item )

Blocking script called when an item is used on a prop. The name is appended to the function, eg: OnUseInvPropDoor(...). Query the passed in 'item' to see if you should perform the action. Eg: ‘if ( item == I.Key ) {...}’ or 'if ( I.Key.Active ) {...}'.

◆ OnInteractCharacter()

IEnumerator OnInteractCharacter ( ICharacter character)

Blocking script called when "Interact" is used on a character. The name is appended to the function, eg: OnInteractCharacterBarney(...).

◆ OnLookAtCharacter()

IEnumerator OnLookAtCharacter ( ICharacter character)

Blocking script called when "Look At" is used on a character. The name is appended to the function, eg: OnLookAtCharacterBarney(...).

◆ OnUseInvCharacter()

IEnumerator OnUseInvCharacter ( ICharacter character,
IInventory item )

Blocking script called when an item is used on a character. The name is appended to the function, eg: OnUseInvCharacterBarney(...). Query the passed in 'item' to see if you should perform the action. Eg: ‘if ( item == I.Key ) {...}’ or 'if ( I.Key.Active ) {...}'.

◆ OnEnterRegion()

IEnumerator OnEnterRegion ( IRegion region,
ICharacter character )

Blocking script called when a character enters the region. The name is appended to the function, eg: OnEnterRegionDoorway(...). Note: If region isn't set to be player only you can check if it's the player with if ( character.IsPlayer ).

◆ OnExitRegion()

IEnumerator OnExitRegion ( IRegion region,
ICharacter character )

Blocking script called when a character exits the region. The name is appended to the function, eg: OnExitRegionDoorway(...). Note: If region isn't set to be player only you can check if it's the player with if ( character.IsPlayer ).

◆ UnhandledInteract()

IEnumerator UnhandledInteract ( IQuestClickable mouseOver)

Called before GlobalScript.UnhandledInteract so you can override its default behaviour in a particular room.

◆ UnhandledLookAt()

IEnumerator UnhandledLookAt ( IQuestClickable mouseOver)

Called before GlobalScript.UnhandledLookAt so you can override its default behaviour in a particular room.

◆ UnhandledUseInv()

IEnumerator UnhandledUseInv ( IQuestClickable mouseOver,
IInventory item )

Called before GlobalScript.UnhandledUseInv so you can override its default behaviour in a particular room.