Skip to content
This repository has been archived by the owner on Dec 24, 2020. It is now read-only.

Commit

Permalink
Refactored the Events system, turning logging into #defines to improv…
Browse files Browse the repository at this point in the history
…e performance; fixed a few runtime bugs regarding deconstruction of the registration objects for Actions/Events.
  • Loading branch information
Azurelol committed May 10, 2018
1 parent 5d67d38 commit d799a1d
Show file tree
Hide file tree
Showing 10 changed files with 25 additions and 36 deletions.
Original file line number Diff line number Diff line change
Expand Up @@ -1209,8 +1209,8 @@ Transform:
m_PrefabParentObject: {fileID: 0}
m_PrefabInternal: {fileID: 0}
m_GameObject: {fileID: 770947306}
m_LocalRotation: {x: 0, y: 0, z: 0, w: 1}
m_LocalPosition: {x: 0, y: 0, z: 0}
m_LocalRotation: {x: 0.3826835, y: 0, z: 0, w: 0.92387956}
m_LocalPosition: {x: -8, y: 15, z: -48}
m_LocalScale: {x: 1, y: 1, z: 1}
m_Children: []
m_Father: {fileID: 0}
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -133,10 +133,10 @@ static void ModifyEvents()
{
//GUILayout.Label("Events", HeaderStyle);
GUILayout.Label("Tracing", EditorStyles.boldLabel);
Events.logging.Connect = EditorGUILayout.Toggle("Connect", Events.logging.Connect);
Events.logging.Dispatch = EditorGUILayout.Toggle("Dispatch", Events.logging.Dispatch);
Events.logging.Construction = EditorGUILayout.Toggle("Construction", Events.logging.Construction);
Events.logging.Register = EditorGUILayout.Toggle("Register", Events.logging.Register);
Events.logging.connect = EditorGUILayout.Toggle("Connect", Events.logging.connect);
Events.logging.dispatch = EditorGUILayout.Toggle("Dispatch", Events.logging.dispatch);
Events.logging.construction = EditorGUILayout.Toggle("Construction", Events.logging.construction);
Events.logging.register = EditorGUILayout.Toggle("Register", Events.logging.register);
}

static void ModifyTrace()
Expand Down Expand Up @@ -170,10 +170,10 @@ public static void Save()
//Trace.Script("GameObject color = " + Trace.GameObjectColor.ToHex());
EditorPrefs.SetString("Stratus_Trace_TimestampColor", Trace.timeStampColor.ToHex());
// Events
EditorPrefs.SetBool("Stratus_Events_Connect", Events.logging.Connect);
EditorPrefs.SetBool("Stratus_Events_Dispatch", Events.logging.Dispatch);
EditorPrefs.SetBool("Stratus_Events_Construction", Events.logging.Construction);
EditorPrefs.SetBool("Stratus_Events_Register", Events.logging.Register);
EditorPrefs.SetBool("Stratus_Events_Connect", Events.logging.connect);
EditorPrefs.SetBool("Stratus_Events_Dispatch", Events.logging.dispatch);
EditorPrefs.SetBool("Stratus_Events_Construction", Events.logging.construction);
EditorPrefs.SetBool("Stratus_Events_Register", Events.logging.register);
}

/// <summary>
Expand All @@ -190,10 +190,10 @@ public static void Load()
Trace.gameObjectColor = Utilities.Graphical.HexToColor(EditorPrefs.GetString("Stratus_Trace_GameObjectColor", Color.blue.ToHex()));
Trace.timeStampColor = Utilities.Graphical.HexToColor(EditorPrefs.GetString("Stratus_Trace_TimestampColor", Color.green.ToHex()));
// Events
Events.logging.Connect = EditorPrefs.GetBool("Stratus_Events_Connect", false);
Events.logging.Dispatch = EditorPrefs.GetBool("Stratus_Events_Dispatch", false);
Events.logging.Construction = EditorPrefs.GetBool("Stratus_Events_Construction", false);
Events.logging.Register = EditorPrefs.GetBool("Stratus_Events_Register", false);
Events.logging.connect = EditorPrefs.GetBool("Stratus_Events_Connect", false);
Events.logging.dispatch = EditorPrefs.GetBool("Stratus_Events_Dispatch", false);
Events.logging.construction = EditorPrefs.GetBool("Stratus_Events_Construction", false);
Events.logging.register = EditorPrefs.GetBool("Stratus_Events_Register", false);
}


Expand Down
15 changes: 5 additions & 10 deletions StratusFramework/Assets/Stratus/Core/Source/Events/Events.cs
Original file line number Diff line number Diff line change
Expand Up @@ -17,12 +17,9 @@ @date 5/25/2016
namespace Stratus
{
// By type
//using DelegatePair = Tuple<bool, >
using DelegateTypeList = List<Delegate>;
using DelegateMap = Dictionary<string, List<Delegate>>;
using DispatchMap = Dictionary<GameObject, Dictionary<string, List<Delegate>>>;
//using DelegateConnectMap = Dictionary<>
//using

/// <summary>
/// The class which manages the overlying Stratus event system.
Expand All @@ -32,10 +29,10 @@ public class Events : Singleton<Events>
{
public class LoggingSetup
{
public bool Construction = false;
public bool Register = false;
public bool Connect = true;
public bool Dispatch = false;
public bool construction = false;
public bool register = false;
public bool connect = true;
public bool dispatch = false;
}

//------------------------------------------------------------------------/
Expand Down Expand Up @@ -68,8 +65,6 @@ public class LoggingSetup
/// </summary>
protected override void OnAwake()
{
//DontDestroyOnLoad(this);
//gameObjectDelegateMap = new DelegateMap();
}

/// <summary>
Expand Down Expand Up @@ -510,7 +505,7 @@ public static void Disconnect(GameObject obj)
// Remove this GameObject from the event dispatch map
if (Events.get.dispatchMap.ContainsKey(obj))
{
if (logging.Register)
if (logging.register)
Trace.Script(obj.name + " has been disconnected from the event system");
Events.get.dispatchMap.Remove(obj);
}
Expand Down
14 changes: 4 additions & 10 deletions StratusFramework/Assets/Stratus/Core/Source/Scenes/Scene.cs
Original file line number Diff line number Diff line change
Expand Up @@ -25,6 +25,9 @@ namespace Stratus
[Singleton("Stratus Scene Events", true, true)]
public class Scene : Singleton<Scene>
{
//----------------------------------------------------------------------------------/
// Declarations
//----------------------------------------------------------------------------------/
public abstract class StatusEvent : Stratus.Event { public string name; }
public class ChangedEvent : StatusEvent { }
public class LoadedEvent : StatusEvent { }
Expand Down Expand Up @@ -79,16 +82,7 @@ public static SceneField[] activeScenes
/// <summary>
/// The current progress into loading the next scene, on a (0,1) range
/// </summary>
public static float loadingProgress
{
get; private set;
//get
//{
// if (get.loadingOperation == null)
// return 0.0f;
// return get.loadingOperation.progress;
//}
}
public static float loadingProgress { get; private set; }

/// <summary>
/// A provided callback for when the scene has changed. Add your methods here to be
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -54,7 +54,7 @@ public class AnalyticsCollector : StratusBehaviour
[SerializeField]
public Analysis.Attribute attribute;

private bool debug;
private bool debug = false;
//------------------------------------------------------------------------/
// Properties
//------------------------------------------------------------------------/
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -8,7 +8,7 @@ namespace Stratus.Analytics
[LayoutViewDisplayAttribute("Stratus Analytics", 225f, 200f, StratusGUI.Anchor.BottomLeft, StratusGUI.Dimensions.Absolute)]
public class AnalyticsSceneViewDisplay : SingletonSceneViewDisplay<AnalyticsEngine>
{
AnimationCurve curve = new AnimationCurve();
//AnimationCurve curve = new AnimationCurve();

protected override void OnGUI(Rect position)
{
Expand Down
Binary file not shown.
Binary file not shown.
Binary file not shown.
Binary file not shown.

0 comments on commit d799a1d

Please sign in to comment.