Browse Source

Refactored event handler names and categories

master
Christopher 8 years ago
parent
commit
881c1259bf
  1. 6
      Assets/Fungus/Scripts/Components/SaveManager.cs
  2. 2
      Assets/Fungus/Scripts/EventHandlers/FlowchartEnabled.cs
  3. 2
      Assets/Fungus/Scripts/EventHandlers/MessageReceived.cs
  4. 14
      Assets/Fungus/Scripts/EventHandlers/SavePointLoaded.cs
  5. 0
      Assets/Fungus/Scripts/EventHandlers/SavePointLoaded.cs.meta
  6. 11
      Assets/FungusExamples/SaveGame/SceneA.unity

6
Assets/Fungus/Scripts/Components/SaveManager.cs

@ -147,12 +147,12 @@ namespace Fungus
flowchart.SetStringVariable(stringVar.key, stringVar.value); flowchart.SetStringVariable(stringVar.key, stringVar.value);
} }
// Fire any matching GameLoaded event handler with matching save key. // Fire any matching SavePointLoaded event handler with matching save key.
var eventHandlers = Object.FindObjectsOfType<GameLoaded>(); var eventHandlers = Object.FindObjectsOfType<SavePointLoaded>();
for (int i = 0; i < eventHandlers.Length; i++) for (int i = 0; i < eventHandlers.Length; i++)
{ {
var eventHandler = eventHandlers[i]; var eventHandler = eventHandlers[i];
eventHandler.OnGameLoaded(saveData.saveKey); eventHandler.OnSavePointLoaded(saveData.saveKey);
} }
// Execute any block with a Label matching the save key // Execute any block with a Label matching the save key

2
Assets/Fungus/Scripts/EventHandlers/FlowchartEnabled.cs

@ -8,7 +8,7 @@ namespace Fungus
/// <summary> /// <summary>
/// The block will execute when the Flowchart game object is enabled. /// The block will execute when the Flowchart game object is enabled.
/// </summary> /// </summary>
[EventHandlerInfo("", [EventHandlerInfo("Scene",
"Flowchart Enabled", "Flowchart Enabled",
"The block will execute when the Flowchart game object is enabled.")] "The block will execute when the Flowchart game object is enabled.")]
[AddComponentMenu("")] [AddComponentMenu("")]

2
Assets/Fungus/Scripts/EventHandlers/MessageReceived.cs

@ -8,7 +8,7 @@ namespace Fungus
/// <summary> /// <summary>
/// The block will execute when the specified message is received from a Send Message command. /// The block will execute when the specified message is received from a Send Message command.
/// </summary> /// </summary>
[EventHandlerInfo("", [EventHandlerInfo("Scene",
"Message Received", "Message Received",
"The block will execute when the specified message is received from a Send Message command.")] "The block will execute when the specified message is received from a Send Message command.")]
[AddComponentMenu("")] [AddComponentMenu("")]

14
Assets/Fungus/Scripts/EventHandlers/GameLoaded.cs → Assets/Fungus/Scripts/EventHandlers/SavePointLoaded.cs

@ -6,20 +6,20 @@ using System.Collections.Generic;
namespace Fungus namespace Fungus
{ {
[EventHandlerInfo("", [EventHandlerInfo("Scene",
"Game Loaded", "Save Point Loaded",
"Execute this block when a saved game is loaded.")] "Execute this block when a saved point is loaded.")]
public class GameLoaded : EventHandler public class SavePointLoaded : EventHandler
{ {
[Tooltip("Block will execute if the Save Key of the loaded data matches an entry in the Save Keys list.")] [Tooltip("Block will execute if the Save Key of the loaded save point matches an entry in the Save Keys list.")]
[SerializeField] protected List<string> saveKeys = new List<string>(); [SerializeField] protected List<string> saveKeys = new List<string>();
#region Public methods #region Public methods
/// <summary> /// <summary>
/// Called when a saved game is loaded. /// Called when a save point is loaded.
/// </summary> /// </summary>
public void OnGameLoaded(string saveKey) public void OnSavePointLoaded(string saveKey)
{ {
if (saveKeys.Contains(saveKey)) if (saveKeys.Contains(saveKey))
{ {

0
Assets/Fungus/Scripts/EventHandlers/GameLoaded.cs.meta → Assets/Fungus/Scripts/EventHandlers/SavePointLoaded.cs.meta

11
Assets/FungusExamples/SaveGame/SceneA.unity

@ -214,8 +214,7 @@ MonoBehaviour:
height: 909 height: 909
selectedBlocks: selectedBlocks:
- {fileID: 27697883} - {fileID: 27697883}
selectedCommands: selectedCommands: []
- {fileID: 27697875}
variables: variables:
- {fileID: 27697873} - {fileID: 27697873}
description: description:
@ -284,7 +283,7 @@ MonoBehaviour:
stringVal: stringVal:
--- !u!114 &27697875 --- !u!114 &27697875
MonoBehaviour: MonoBehaviour:
m_ObjectHideFlags: 0 m_ObjectHideFlags: 2
m_PrefabParentObject: {fileID: 0} m_PrefabParentObject: {fileID: 0}
m_PrefabInternal: {fileID: 0} m_PrefabInternal: {fileID: 0}
m_GameObject: {fileID: 27697867} m_GameObject: {fileID: 27697867}
@ -399,7 +398,7 @@ MonoBehaviour:
- {fileID: 27697878} - {fileID: 27697878}
--- !u!114 &27697881 --- !u!114 &27697881
MonoBehaviour: MonoBehaviour:
m_ObjectHideFlags: 0 m_ObjectHideFlags: 2
m_PrefabParentObject: {fileID: 0} m_PrefabParentObject: {fileID: 0}
m_PrefabInternal: {fileID: 0} m_PrefabInternal: {fileID: 0}
m_GameObject: {fileID: 27697867} m_GameObject: {fileID: 27697867}
@ -413,7 +412,7 @@ MonoBehaviour:
key: save_1 key: save_1
--- !u!114 &27697882 --- !u!114 &27697882
MonoBehaviour: MonoBehaviour:
m_ObjectHideFlags: 0 m_ObjectHideFlags: 2
m_PrefabParentObject: {fileID: 0} m_PrefabParentObject: {fileID: 0}
m_PrefabInternal: {fileID: 0} m_PrefabInternal: {fileID: 0}
m_GameObject: {fileID: 27697867} m_GameObject: {fileID: 27697867}
@ -432,7 +431,7 @@ MonoBehaviour:
' '
--- !u!114 &27697883 --- !u!114 &27697883
MonoBehaviour: MonoBehaviour:
m_ObjectHideFlags: 0 m_ObjectHideFlags: 2
m_PrefabParentObject: {fileID: 0} m_PrefabParentObject: {fileID: 0}
m_PrefabInternal: {fileID: 0} m_PrefabInternal: {fileID: 0}
m_GameObject: {fileID: 27697867} m_GameObject: {fileID: 27697867}

Loading…
Cancel
Save