Skip to content

Commit

Permalink
Start work on new Components architecture
Browse files Browse the repository at this point in the history
  • Loading branch information
nasser committed Nov 23, 2015
1 parent d5f4b9b commit 083c7d3
Show file tree
Hide file tree
Showing 133 changed files with 1,839 additions and 0 deletions.
Binary file added Clojure-icon.png
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
55 changes: 55 additions & 0 deletions Clojure-icon.png.meta

Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.

9 changes: 9 additions & 0 deletions Components.meta

Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.

43 changes: 43 additions & 0 deletions Components/ArcadiaComponent.cs
Original file line number Diff line number Diff line change
@@ -0,0 +1,43 @@
using UnityEngine;
using clojure.lang;

public class ArcadiaBehaviour : MonoBehaviour, ISerializationCallbackReceiver
{
private IFn _fn;
public IFn fn
{
get { return _fn; }
set
{
_fn = value;
serializedVar = null;
OnBeforeSerialize();
}
}

[SerializeField]
public string serializedVar;

// if fn is a var, store in serializedVar
public void OnBeforeSerialize()
{
Var v = fn as Var;
if(v != null)
{
serializedVar = v.Namespace.Name + "/" + v.Symbol.Name;
}
}

// if serializedVar not null, set fn to var
public void OnAfterDeserialize()
{
if(serializedVar != "")
{
Symbol sym = Symbol.intern(serializedVar);
string libName = sym.Namespace.Replace(".", "/").Replace("-", "_");
Debug.Log("Loading " + libName);
RT.load(libName);
fn = Var.intern(Symbol.intern(sym.Namespace), Symbol.intern(sym.Name));
}
}
}
12 changes: 12 additions & 0 deletions Components/ArcadiaComponent.cs.meta

Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.

20 changes: 20 additions & 0 deletions Components/ArcadiaState.cs
Original file line number Diff line number Diff line change
@@ -0,0 +1,20 @@
using UnityEngine;
using System.Collections;
using clojure.lang;

public class ArcadiaState : MonoBehaviour, ISerializationCallbackReceiver
{
[TextArea(3,10)]
public string edn;
public object state;

public void OnBeforeSerialize()
{
edn = (string)((IFn)RT.var("clojure.core", "pr-str")).invoke(state);
}

public void OnAfterDeserialize()
{
state = (object)((IFn)RT.var("clojure.edn", "read-string")).invoke(edn);
}
}
12 changes: 12 additions & 0 deletions Components/ArcadiaState.cs.meta

Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.

11 changes: 11 additions & 0 deletions Components/AwakeHook.cs
Original file line number Diff line number Diff line change
@@ -0,0 +1,11 @@
using UnityEngine;
using clojure.lang;

public class AwakeHook : ArcadiaBehaviour
{
void Awake()
{
if(fn != null)
fn.invoke(gameObject);
}
}
12 changes: 12 additions & 0 deletions Components/AwakeHook.cs.meta

Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.

11 changes: 11 additions & 0 deletions Components/FixedUpdateHook.cs
Original file line number Diff line number Diff line change
@@ -0,0 +1,11 @@
using UnityEngine;
using clojure.lang;

public class FixedUpdateHook : ArcadiaBehaviour
{
void FixedUpdate()
{
if(fn != null)
fn.invoke(gameObject);
}
}
12 changes: 12 additions & 0 deletions Components/FixedUpdateHook.cs.meta

Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.

11 changes: 11 additions & 0 deletions Components/LateUpdateHook.cs
Original file line number Diff line number Diff line change
@@ -0,0 +1,11 @@
using UnityEngine;
using clojure.lang;

public class LateUpdateHook : ArcadiaBehaviour
{
void LateUpdate()
{
if(fn != null)
fn.invoke(gameObject);
}
}
12 changes: 12 additions & 0 deletions Components/LateUpdateHook.cs.meta

Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.

11 changes: 11 additions & 0 deletions Components/OnAnimatorIKHook.cs
Original file line number Diff line number Diff line change
@@ -0,0 +1,11 @@
using UnityEngine;
using clojure.lang;

public class OnAnimatorIKHook : ArcadiaBehaviour
{
void OnAnimatorIK(System.Int32 G__18667)
{
if(fn != null)
fn.invoke(gameObject, G__18667);
}
}
12 changes: 12 additions & 0 deletions Components/OnAnimatorIKHook.cs.meta

Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.

11 changes: 11 additions & 0 deletions Components/OnAnimatorMoveHook.cs
Original file line number Diff line number Diff line change
@@ -0,0 +1,11 @@
using UnityEngine;
using clojure.lang;

public class OnAnimatorMoveHook : ArcadiaBehaviour
{
void OnAnimatorMove()
{
if(fn != null)
fn.invoke(gameObject);
}
}
12 changes: 12 additions & 0 deletions Components/OnAnimatorMoveHook.cs.meta

Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.

11 changes: 11 additions & 0 deletions Components/OnApplicationFocusHook.cs
Original file line number Diff line number Diff line change
@@ -0,0 +1,11 @@
using UnityEngine;
using clojure.lang;

public class OnApplicationFocusHook : ArcadiaBehaviour
{
void OnApplicationFocus(System.Boolean G__18674)
{
if(fn != null)
fn.invoke(gameObject, G__18674);
}
}
12 changes: 12 additions & 0 deletions Components/OnApplicationFocusHook.cs.meta

Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.

11 changes: 11 additions & 0 deletions Components/OnApplicationPauseHook.cs
Original file line number Diff line number Diff line change
@@ -0,0 +1,11 @@
using UnityEngine;
using clojure.lang;

public class OnApplicationPauseHook : ArcadiaBehaviour
{
void OnApplicationPause(System.Boolean G__18647)
{
if(fn != null)
fn.invoke(gameObject, G__18647);
}
}
12 changes: 12 additions & 0 deletions Components/OnApplicationPauseHook.cs.meta

Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.

11 changes: 11 additions & 0 deletions Components/OnApplicationQuitHook.cs
Original file line number Diff line number Diff line change
@@ -0,0 +1,11 @@
using UnityEngine;
using clojure.lang;

public class OnApplicationQuitHook : ArcadiaBehaviour
{
void OnApplicationQuit()
{
if(fn != null)
fn.invoke(gameObject);
}
}
12 changes: 12 additions & 0 deletions Components/OnApplicationQuitHook.cs.meta

Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.

11 changes: 11 additions & 0 deletions Components/OnAudioFilterReadHook.cs
Original file line number Diff line number Diff line change
@@ -0,0 +1,11 @@
using UnityEngine;
using clojure.lang;

public class OnAudioFilterReadHook : ArcadiaBehaviour
{
void OnAudioFilterRead(System.Single[] G__18675, System.Int32 G__18676)
{
if(fn != null)
fn.invoke(gameObject, G__18675, G__18676);
}
}
12 changes: 12 additions & 0 deletions Components/OnAudioFilterReadHook.cs.meta

Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.

Loading

0 comments on commit 083c7d3

Please sign in to comment.