-
Notifications
You must be signed in to change notification settings - Fork 13
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
Feature/cleanup #37
Merged
Merged
Feature/cleanup #37
Changes from all commits
Commits
Show all changes
7 commits
Select commit
Hold shift + click to select a range
a993e8a
Cleanup of the previous structure
kefniark 06d1113
Add Mage folder
kefniark 7c247bf
Add Tomes folder
kefniark 7519ab8
Add Network folder (http/jsonrpc)
kefniark c7a3a21
Add the remaining folders (Utils, Event, Editor)
kefniark 0eae49e
Remove warning, improve singletons and few other fixes
kefniark 04e635a
small fix
kefniark File filter
Filter by extension
Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,6 @@ | ||
using System.Runtime.InteropServices; | ||
|
||
// Setting ComVisible to false makes the types in this assembly not visible | ||
// to COM components. If you need to access a type in this assembly from | ||
// COM, set the ComVisible attribute to true on that type. | ||
[assembly: ComVisible(false)] |
This file was deleted.
Oops, something went wrong.
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,9 @@ | ||
namespace Wizcorp.MageSDK.Editor | ||
{ | ||
public enum EditorPlayModeState | ||
{ | ||
Stopped, | ||
Playing, | ||
Paused | ||
} | ||
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,75 @@ | ||
#if UNITY_EDITOR | ||
|
||
using UnityEditor; | ||
|
||
namespace Wizcorp.MageSDK.Editor | ||
{ | ||
[InitializeOnLoad] | ||
public static class UnityEditorPlayMode | ||
{ | ||
public delegate void EditorModeChanged(EditorPlayModeState newState); | ||
|
||
private static EditorPlayModeState currentState = EditorPlayModeState.Stopped; | ||
public static EditorModeChanged OnEditorModeChanged; | ||
|
||
static UnityEditorPlayMode() | ||
{ | ||
EditorApplication.playmodeStateChanged += OnUnityPlayModeChanged; | ||
if (EditorApplication.isPaused) | ||
{ | ||
currentState = EditorPlayModeState.Paused; | ||
} | ||
} | ||
|
||
private static void OnUnityPlayModeChanged() | ||
{ | ||
var newState = EditorPlayModeState.Stopped; | ||
switch (currentState) | ||
{ | ||
case EditorPlayModeState.Stopped: | ||
if (EditorApplication.isPlayingOrWillChangePlaymode) | ||
{ | ||
newState = EditorPlayModeState.Playing; | ||
} | ||
else | ||
{ | ||
newState = EditorPlayModeState.Paused; | ||
} | ||
break; | ||
case EditorPlayModeState.Playing: | ||
if (EditorApplication.isPaused) | ||
{ | ||
newState = EditorPlayModeState.Paused; | ||
} | ||
else if (EditorApplication.isPlaying) | ||
{ | ||
newState = EditorPlayModeState.Playing; | ||
} | ||
else | ||
{ | ||
newState = EditorPlayModeState.Stopped; | ||
} | ||
break; | ||
case EditorPlayModeState.Paused: | ||
if (EditorApplication.isPlayingOrWillChangePlaymode && !EditorApplication.isPaused) | ||
{ | ||
newState = EditorPlayModeState.Playing; | ||
} | ||
else if (EditorApplication.isPlayingOrWillChangePlaymode && EditorApplication.isPaused) | ||
{ | ||
newState = EditorPlayModeState.Paused; | ||
} | ||
break; | ||
} | ||
|
||
if (OnEditorModeChanged != null) | ||
{ | ||
OnEditorModeChanged.Invoke(newState); | ||
} | ||
|
||
currentState = newState; | ||
} | ||
} | ||
} | ||
|
||
#endif |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,71 @@ | ||
using System; | ||
using System.Collections.Generic; | ||
using System.ComponentModel; | ||
|
||
namespace Wizcorp.MageSDK.Event | ||
{ | ||
public class EventEmitter<T> | ||
{ | ||
private EventHandlerList eventsList = new EventHandlerList(); | ||
|
||
// | ||
private Dictionary<string, object> eventTags = new Dictionary<string, object>(); | ||
|
||
// | ||
public void On(string eventTag, Action<object, T> handler) | ||
{ | ||
if (!eventTags.ContainsKey(eventTag)) | ||
{ | ||
eventTags.Add(eventTag, new object()); | ||
} | ||
|
||
eventsList.AddHandler(eventTags[eventTag], handler); | ||
} | ||
|
||
// | ||
public void Once(string eventTag, Action<object, T> handler) | ||
{ | ||
Action<object, T> handlerWrapper = null; | ||
handlerWrapper = (obj, arguments) => { | ||
eventsList.RemoveHandler(eventTags[eventTag], handlerWrapper); | ||
handler(obj, arguments); | ||
}; | ||
|
||
On(eventTag, handlerWrapper); | ||
} | ||
|
||
// | ||
public void Emit(string eventTag, object sender, T arguments) | ||
{ | ||
if (!eventTags.ContainsKey(eventTag)) | ||
{ | ||
return; | ||
} | ||
|
||
var execEventList = (Action<object, T>)eventsList[eventTags[eventTag]]; | ||
execEventList(sender, arguments); | ||
} | ||
|
||
public void Emit(string eventTag, T arguments) | ||
{ | ||
Emit(eventTag, null, arguments); | ||
} | ||
|
||
// | ||
public void Off(string eventTag, Action<object, T> handler) | ||
{ | ||
eventsList.RemoveHandler(eventTags[eventTag], handler); | ||
} | ||
|
||
// | ||
public void RemoveAllListeners() | ||
{ | ||
// Destroy all event handlers | ||
eventsList.Dispose(); | ||
eventsList = new EventHandlerList(); | ||
|
||
// Destroy all event tags | ||
eventTags = new Dictionary<string, object>(); | ||
} | ||
} | ||
} |
This file was deleted.
Oops, something went wrong.
Oops, something went wrong.
Add this suggestion to a batch that can be applied as a single commit.
This suggestion is invalid because no changes were made to the code.
Suggestions cannot be applied while the pull request is closed.
Suggestions cannot be applied while viewing a subset of changes.
Only one suggestion per line can be applied in a batch.
Add this suggestion to a batch that can be applied as a single commit.
Applying suggestions on deleted lines is not supported.
You must change the existing code in this line in order to create a valid suggestion.
Outdated suggestions cannot be applied.
This suggestion has been applied or marked resolved.
Suggestions cannot be applied from pending reviews.
Suggestions cannot be applied on multi-line comments.
Suggestions cannot be applied while the pull request is queued to merge.
Suggestion cannot be applied right now. Please check back later.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Would be nice for some docs on this