void mainGameThread() { IList rulesAndEffects=_GameData[_effects] as IList; Conditional stack=new Conditional(); stack[_Game]=_GameData; List<Conditional> wrappedEffects=wrapGameEffects(); stack[_effects]=wrappedEffects; stack[_target]=null; stack[_rootl]=_GameData; string curName=""; Debug.Log(string.Format("effects : {0}",wrappedEffects.Count)); try { while(runThread) { int ii=0; while(ii<rulesAndEffects.Count) { object obj =rulesAndEffects[ii]; ii++; Conditional eff=obj as Conditional; curName=eff["__name"] as string; if(!eff.hasTag(EXECUTE_PREFIX)&&!eff.hasTag(EXECUTE_POSTFIX)) { Condition cnd=eff[_condition] as Condition; //Debug.Log(cnd); //Monitor.Enter(gameLock); if(cnd.isFulfilled(stack,stack[_Game] as Conditional)) { //Debug.Log(cnd); lock(gameLock) { Operation op=new Operation(Operation.Commands.NEW); Conditional nstack=op.createStack(stack, eff); int oneff=rulesAndEffects.Count; op.executeList(eff[_commands], nstack); if(rulesAndEffects.Count!=oneff) { stack[_effects]=wrapGameEffects(); Debug.Log("added trules"); } if(nstack.hasTag(TAG_ABORT)) { Debug.Log("GameObject Overlapped"); return;//gameover? I guess } } } //Monitor.Exit(gameLock); } } } } catch (System.Exception ex) { Debug.Log(ex); Debug.Log(curName); // I WILL LOG THE EXCEPTION object "EX" here ! but ex.StackTrace is truncated! } }
public object this [string name] { //let us add the dot notation... get { string [] ln=name.Split('.'); if(ln.Length==1) { object ret=null; if(ln[0]==_conditional_self) return this; if(_values.TryGetValue(ln[0], out ret)) { IList ab=accessBindings(name); double dret=0; if(ab!=null&&ab.Count>0&&tryGetDouble(ret,out dret)) { bool changed=false; foreach(object o in ab) { Conditional accessBound=o as Conditional; if(accessBound==null) { #if THING Debug.Log(string.Format("Invalid access bound list element {0}",o)); #endif return ret; } if(accessBound.hasTag("IN_BINDING")) continue; Condition cnd=accessBound[_condition] as Condition; if(cnd==null) { #if THING Debug.Log(string.Format("No condition ffound in access bound element {0}",accessBound)); #endif continue; } accessBound.setTag("IN_BINDING"); if(cnd.isFulfilled(this,this[_upcond] as Conditional)) { Conditional nstack=new Conditional(false); nstack[_parentl]=this; nstack[_upcond]=this; nstack[_effects]=new List<Conditional>(); nstack[_rootl]=_values[_rootl]; nstack["_bound"]=dret; Operation e=new Operation(Operation.Commands.NEW); e.executeList(accessBound[_commands],nstack); dret=(double)nstack["_bound"]; //Debug.Log("bound"); changed=true; } accessBound.removeTag("IN_BINDING"); } if(changed) return dret; } return ret; } else return null; } else { object ret=null; if(_values.TryGetValue(ln[0], out ret)) { Conditional nxt=ret as Conditional; if(nxt!=null) return nxt[name.Substring(ln[0].Length+1)];//hopefully... else { Debug.Log(string.Format("invalid name chain: {0}",name)); return null; } } else return null; } } set { string [] ln=name.Split('.'); if(ln.Length==1) { _values[name]=value; } else { object ret=null; if(_values.TryGetValue(ln[0], out ret)) { Conditional nxt=ret as Conditional; nxt[name.Substring(ln[0].Length+1)]=value;//hopefully... } } } }