Skip to content

Commit

Permalink
Mild refactoring for HookStateSystem
Browse files Browse the repository at this point in the history
  • Loading branch information
timsgardner committed Dec 28, 2017
1 parent 092af87 commit 5fe2600
Showing 1 changed file with 13 additions and 17 deletions.
30 changes: 13 additions & 17 deletions Helpers/HookStateSystem.cs
Original file line number Diff line number Diff line change
Expand Up @@ -20,14 +20,21 @@ public static object FullLookup (object obj, object key)
{
ArcadiaState arcs;

if (obj is GameObject) {
arcs = (ArcadiaState)((GameObject)obj).GetComponent(typeof(ArcadiaState));
} else if (obj is Component) {
arcs = (ArcadiaState)((Component)obj).GetComponent(typeof(ArcadiaState));
var gobj = obj as GameObject;
if (gobj != null) {
arcs = gobj.GetComponent<ArcadiaState>();
} else {
return null;
var cmpt = obj as Component;
if (cmpt != null) {
arcs = cmpt.GetComponent<ArcadiaState>();
} else {
return null;
}
}

if (arcs == null)
return null;

var jm = arcs.state;
Arcadia.JumpMap.KeyVal kv;
if (jm.dict.TryGetValue(key, out kv)) {
Expand All @@ -38,18 +45,7 @@ public static object FullLookup (object obj, object key)

public static object Lookup (object gobj, object key)
{

//if (arcadiaState != null && gobj == arcadiaState.gameObject) {
// if (pamv != null) {
// return pamv.ValueAtKey(key);
// }
// return arcadiaState.state.ValueAtKey(key);
//}
//return FullLookup(gobj, key)

// fully inlined lookup:

if (hasState && ReferenceEquals(gobj, arcadiaState.gameObject)) {
if (hasState && gobj == arcadiaState.gameObject) {
var kvs = pamv.kvs;
for (int i = 0; i < kvs.Length; i++) {
var kv = kvs[i];
Expand Down

0 comments on commit 5fe2600

Please sign in to comment.