void Init(){ m_Left = null; m_Right = null; m_Parent = null; m_Data = ""; m_dwDataHash = 0; m_bNot = false; }
public static BinaryExpressionNode BuildTree(string szStringToEvaluate){ string sParser = szStringToEvaluate; if(szStringToEvaluate != null) { BinaryExpressionNode pNode = new BinaryExpressionNode(sParser); // start a tree from the first token if (sParser.IndexOf(" ") >= 0){ sParser = sParser.Substring(sParser.IndexOf(" ")); pNode.BuildOnToNode(sParser); // and build onto it. } return pNode.GetRoot(); //Returns the root } return null; }
public BinaryExpressionNode(BinaryExpressionNode rhs) : base(rhs) { Optr = rhs.Optr; LeftNode = rhs.LeftNode == null ? null : ProtoCore.Utils.NodeUtils.Clone(rhs.LeftNode); RightNode = rhs.RightNode == null ? null : ProtoCore.Utils.NodeUtils.Clone(rhs.RightNode); }
public virtual Value evaluate(Context cx, BinaryExpressionNode node) { output("<BinaryExpressionNode position=\"" + node.pos() + "\">"); indent_Renamed_Field++; if (node.lhs != null) { node.lhs.evaluate(cx, this); } if (node.rhs != null) { node.rhs.evaluate(cx, this); } indent_Renamed_Field--; output("</BinaryExpressionNode>"); return null; }
public void Execute(InteractionScript callingScript){ //Debug.Log ("XXX"+Time.time+" "+name+type); if ((breakpoint || callingScript.singleStepping) && callingScript.debug){ // place a breakpoint here and set breakpoint=true to trap on execute of a particular line of script Debug.Log ("Hit Execute Breakpoint for "+name+" of "+callingScript.name); InteractionScript.atBreakpoint = callingScript; callingScript.waitingForDebugger = true; Debug.Break (); WaitForDebugger (callingScript); Debug.Log ("Ran Right Past the Call"); } executedBy = callingScript; /* moved to Calling script to handle Role mapping * if (objectToAffect == null){ // default, or we could try looking up the name again... if (objectName != ""){ objectToAffect = GameObject.Find(executedBy.ResolveArgs(objectName).Replace ("\"","")); // we have a problem with two names here, one used by unity, one by the if (objectToAffect == null){ objectToAffect = ObjectManager.GetInstance().GetGameObject(objectName); } } else objectToAffect = executedBy.myObject; } */ if (executedBy != null) objectToAffect = executedBy.FindObjectToAffect(this); if (type != actionType.putMessage && objectToAffect != null) // don't need a taskCharacter to send a message... taskChar = objectToAffect.GetComponent<TaskCharacter>(); if (!forceExecute){ if (taskChar != null && taskChar.executingScript != null && taskChar.executingScript != this){ // this character is already busy, so wait until the current line completes StartCoroutine (ExecuteWhenIdle(callingScript)); return; } if (taskChar != null){ taskChar.executingScript = this; if (taskChar.actingInScript != null && taskChar.actingInScript != executedBy){// && CanCompleteImmediately()){ // don't add me, I'll be done before you know it... } else { taskChar.actingInScript = executedBy; // this could get cleared by this character doing an executeScript. // since we set it, be sure we're in the list of actor objects so we'll be released if (!executedBy.actorObjects.Contains(taskChar as ObjectInteraction)) executedBy.actorObjects.Add (taskChar as ObjectInteraction); } } } forceExecute = false; #if DEBUG_SCRIPTING Debug.Log ("ScriptedAction execute "+name); #endif if (breakpoint && callingScript.debug){ // place a breakpoint here and set breakpoint=true to trap on execute of a particular line of script Debug.Log ("Hit Execute Breakpoint for "+name+" of "+callingScript.name); } if (hasExecuted && executeOnlyOnce){ error = "already executed"; OnComplete(); } characterTaskPending = false; waitingForUpdate = false; // a single update call will complete us waitingForDialog = false; taskReady = false; waitingForNav = false; waitingForCondition = false; ignoreTimeout = false; waitingForAnim = false; runIndependentUpdates = false; trackCameraLookat = false; postureChangeStartTime = 0; executedBy = callingScript; error = ""; this.enabled = true; // need updates until we are through // Temporary hack to add any InteractMessage map to the character to avoid an error if (objectToAffect != null && type == actionType.putMessage && gameMsgForm.msgType == GameMsgForm.eMsgType.interactMsg){ // we are going to add this interaction to the objects AllMaps so it doesn't get an error ObjectInteraction OI = objectToAffect.GetComponent<ObjectInteraction>(); if (OI != null) OI.AddToAllMaps(gameMsgForm.map.GetMap()); } if (preAttributes != "") SetAttributes(objectToAffect,preAttributes); // can't do this here, need to do it when we use the values, and don't overwrite the original ones! // stringParam = SubstituteArgsAndAttributes(stringParam); // update parameter strings with current #args, $attrs // stringParam2 = SubstituteArgsAndAttributes(stringParam2); // stringParam3 = SubstituteArgsAndAttributes(stringParam3); // stringParam4 = SubstituteArgsAndAttributes(stringParam4); // attachmentOverride = SubstituteArgsAndAttributes(attachmentOverride); if (type == actionType.enableInteraction){ if (objectName == "Dispatcher"){ // this will cause all interaction tags except the space delimited list to be rejected // until an interaction on the list is hit, which then re-enables all interactions. // (needed so scripts can use tags to trigger things when running) // an empty list will allow all interactions again. Dispatcher td = FindObjectOfType<Dispatcher>(); if (td != null){ td.LimitInteractions( stringParam, negate, loop ); } OnComplete(); Cleanup (); } else { // look for an ObjectInteraction component on ObjectToAffect if (objectToAffect != null){ if (objectToAffect.GetComponent<ObjectInteraction>() != null){ ObjectInteraction OI = objectToAffect.GetComponent<ObjectInteraction>(); OI.Enabled = !negate; if (ease || texture2D!= null){ //hackfully abuse the 'ease' boolean to force clear the icon texture if (ease) OI.iconTexture = null; else if (texture2D!= null) OI.iconTexture = texture2D; } } else // adding handling of nav mesh obstacle here... if (objectToAffect.GetComponent<NavMeshObstacle>() != null){ NavMeshObstacle NMO = objectToAffect.GetComponent<NavMeshObstacle>(); NMO.enabled = !negate; } OnComplete(); Cleanup (); } else { error = "no objectInteraction to enable"; OnComplete(); Cleanup (); } } } if (type == actionType.playAnimation){ if (objectToAffect != null){ taskChar = objectToAffect.GetComponent<TaskCharacter>(); if (taskChar != null){ taskChar.Animate(stringParam); // figure out if we should wait... we could wait for the characterAnimState if (waitForCompletion){ waitingForAnim = true; animEndTime = -1; // failsafe for hung waiting for anim to end... AnimationState ast = taskChar.GetComponent<AnimationManager>().body.animation[stringParam]; if (ast != null && ast.clip != null) animEndTime = Time.time + ast.clip.length + 0.05f;; } else OnComplete (); } else { // handle ?speed= ?time= ?wieght= string[] p = stringParam.Split ('?'); string animationName = p[0]; float animSpeed = 1; // for overrideing defaults float animWeight = 1; float animTime = 0; int start=1; // process speed= weight= time= possibly mixing transform... while (start < p.Length){ if (p.Length > start && p[start].ToLower().Contains("speed=")){ string[] q = p[start].Split('='); float.TryParse(q[1],out animSpeed); } if (p.Length > start && p[start].ToLower().Contains("weight=")){ string[] q = p[start].Split('='); float.TryParse(q[1],out animWeight); } if (p.Length > start && p[start].ToLower().Contains("time=")){ string[] q = p[start].Split('='); float.TryParse(q[1],out animTime); } start++; } if (objectToAffect.animation != null){ if (animTime == 0) objectToAffect.animation.Rewind(animationName); if (animTime > 0) objectToAffect.animation[animationName].time = animTime; objectToAffect.animation[animationName].speed = animSpeed; objectToAffect.animation[animationName].weight = animWeight; objectToAffect.animation.clip = objectToAffect.animation[animationName].clip; objectToAffect.animation.Play(); if (waitForCompletion) waitingForAnim = true; else OnComplete (); } } } else { error = "no object to play animation on"; OnComplete(); Cleanup (); } } if (type == actionType.playAudio){ // object to affect should have an audio source AudioSource src = null; if (objectToAffect != null) src = objectToAffect.GetComponent<AudioSource>(); if (src == null) src = objectToAffect.AddComponent<AudioSource>() as AudioSource; if (src != null){ float timeToWait = fadeLength; if (audioClip == null){ // find the audio clip, looking thru the sound map for this character? if (stringParam != ""){ VoiceMap vm = VoiceMgr.GetInstance().Find(objectToAffect.name, stringParam); if (vm != null){ vm.Clip = SoundMgr.GetInstance().GetClip(vm.Audio); if (vm.Clip != null) timeToWait += vm.Clip.length; VoiceMgr.GetInstance().Play (objectToAffect.name, stringParam); if (stringParam2 != "" && taskChar != null && vm.Clip != null) taskChar.LookAt(stringParam2, Time.time + vm.Clip.length); } else{ audioClip = SoundMgr.GetInstance().Get(stringParam); } } } if (audioClip != null){ // will still be null if we sent this to the voice manager src.clip = audioClip; src.Play(); timeToWait += audioClip.length; if (stringParam2 != "" && taskChar != null) taskChar.LookAt(stringParam2, Time.time + audioClip.length); } if (waitForCompletion) StartCoroutine(CompleteAfterDelay (timeToWait)); else { OnComplete(); Cleanup (); } } else { error = "no audiosource for playAudio"; OnComplete(); } } if (type == actionType.putMessage){ // hack to avoid 'I'm too busy messages... if (taskChar != null) taskChar.executingScript = null; StartCoroutine(SendMessageAfterDelay(fadeLength)); } if (type == actionType.move){ // // lets handle the camera move first: if (moveTo == null){ // translate the name, if presesnt if (moveToName != "" && GameObject.Find(moveToName)!= null ){ moveTo = GameObject.Find(moveToName).transform; } } CameraLERP cameraLERP = objectToAffect.GetComponent<CameraLERP>(); if (cameraLERP != null){ // strangely in Unity, we're not allowed to create new Transforms, so we have to make a dummy if (moveTo != null){ if (offset == Vector3.zero){ // assume this is a return to the spline // reset the camera rail controller so we go to the starting position... // CameraRailCoordinator crc = FindObjectOfType<CameraRailCoordinator>(); // if (crc != null) // crc.Reset(); // cameraLERP.MoveTo(moveTo, fadeLength,true,false, 0); trackCameraLookat = true; if (!waitForCompletion) runIndependentUpdates = true; StartCoroutine( EndTrackCameraLookat(fadeLength)); if (!waitForCompletion) OnComplete (); return; } else { dummyGO = new GameObject("dummyGO"); dummyGO.transform.position = moveTo.position + offset.x*dummyGO.transform.forward + offset.y*dummyGO.transform.up + offset.z*dummyGO.transform.right; dummyGO.transform.LookAt(moveTo); cameraLERP.MoveTo(dummyGO.transform, fadeLength,true,true, 0); } } else { if (fadeLength <= 0) cameraLERP.Return(); // snap back else { GameObject dummyGO = new GameObject("dummyGO"); dummyGO.transform.position = cameraLERP.oldWorldPos; dummyGO.transform.rotation = cameraLERP.oldWorldRot; cameraLERP.MoveTo(dummyGO.transform, fadeLength,true,false, 0); } } //Destroy (dummyGO); destroy this later on Completed if (waitForCompletion && fadeLength > 0) StartCoroutine(CompleteAfterDelay (fadeLength)); else { OnComplete(); //Cleanup (); } } else { // if the moveTo NAME is a valid Node Name, we can use the TaskCharacter to move there taskChar = objectToAffect.GetComponent<TaskCharacter>(); if (taskChar != null){ // bool bResult = taskChar.IsInPosition (moveTo.name); // this should start off the nav // lets see if we have something with a NavMeshAgentWrapper... // navWrapper = objectToAffect.GetComponent<NavMeshAgentWrapper>(); // if (navWrapper != null){ // lets ignore the offset for now... // navWrapper.MoveToGameObject(moveTo.gameObject,2.0f); if (waitForCompletion){ navStartTime = Time.realtimeSinceStartup; // we may want to time out waitingForNav = true; return; } else{ runIndependentUpdates = true; pingTaskCharacter = true; OnComplete(); } // } } else { error = "move only implemented for camera, no cameraLERP found"; OnComplete(); } } } if (type == actionType.fade){ // if (objectToAffect == null){ Debug.LogWarning("Null object "+objectName+" for fade by "+name); OnComplete(); Cleanup(); return; } // if the thing is a the GUIManager then fade it GUIManager gm = objectToAffect.GetComponent<GUIManager>(); // test it if (gm != null) { gm.SetFadeCurtain(desiredColor.a, fadeLength); OnComplete(); Cleanup (); return; } // we need to have an object with a renderer. if (objectToAffect != null && objectToAffect.renderer != null){ // if string param has something, look for a resource by that name that is a mesh or material to swap in Material newMaterial = null; // Mesh newMesh = null; if (stringParam != ""){ newMaterial = Resources.Load(stringParam) as Material; // newMesh = Resources.Load(stringParam) as Mesh; } // fade can be an instant change, or take some time. // desired color should override desired alpha if (stringParam=="current"){ // should check new material and use it's color if provided desiredColor = objectToAffect.renderer.material.color; desiredColor.a = desiredAlpha; } desiredColor.a = desiredAlpha; if (fadeLength > 0){ // get components // if the thing has a color changer, lets make use of that. ColorChanger cc = objectToAffect.GetComponent<ColorChanger>(); if (cc != null){ cc.ChangeColor(desiredColor, fadeLength); } else { // fadeBeginTime = Time.time; // fadeBeginColor = objectToAffect.renderer.material.color; if (desiredAlpha > 0){ objectToAffect.renderer.enabled = true; // temporarily just jam the final result until the fade interpolate is in place objectToAffect.renderer.material.color = desiredColor; } // if the final alpha is zero, then set the alpha, and turn off the renderer else { objectToAffect.renderer.enabled = false; objectToAffect.renderer.material.color = desiredColor; } } } else { // instant fade if (newMaterial != null) renderer.material = newMaterial; // if final alpha is > 0, turn the renderer on and set the alpha if (desiredAlpha > 0){ objectToAffect.renderer.enabled = true; objectToAffect.renderer.material.color = desiredColor; } // if the final alpha is zero, then set the alpha, and turn off the renderer else { objectToAffect.renderer.enabled = false; objectToAffect.renderer.material.color = desiredColor; } } } else { // missing object or renderer error = "Fade has no object with renderer specified"; } OnComplete(); Cleanup (); } if (type == actionType.ifThenElse){ // BaseObject bob = null; if (objectToAffect != null && objectToAffect.GetComponent<BaseObject>() != null) bob = objectToAffect.GetComponent<BaseObject>(); if (bob != null){ // build a binaryExpressionNode out of the string for our testEntity and evaluate. // perform any arg substitutions string newString = executedBy.ResolveArgs(stringParam); BinaryExpressionNode condition = BinaryExpressionNode.BuildTree(newString); if (condition.Evaluate(bob)) executedBy.nextLineLabel = ""; // just go on to the next statement else executedBy.nextLineLabel = "else"; // this will find either the next 'else' block or the next 'endIfThenElse' block } else { error = "no baseObject for ifThenElse to test"; } // executedBy.nestingDepth += 1; OnComplete(); Cleanup (); } if (type == actionType.executeScript){ // our execution will be stacked and we will pend until this script completes if (scriptToExecute == null && stringParam2 != null && stringParam2 != ""){ // First, look for a script on the character running this interaction if (taskChar != null){ ScriptedObject tcso = taskChar.GetComponent<ScriptedObject>(); if (tcso!=null){ foreach (InteractionScript tcis in tcso.scripts){ if (tcis.name == stringParam2){ scriptToExecute = tcis; break; } } } } if (scriptToExecute == null){ // try finding the named game object and look for an interaction script there GameObject isGO = GameObject.Find(stringParam2); if (isGO != null) scriptToExecute = isGO.GetComponent<InteractionScript>(); } } if (scriptToExecute == null){ Debug.LogError("scriptedAction could not find script to execute at "+name+executedBy.name); OnComplete (); Cleanup (); } if (waitForCompletion){ // run this as a subroutine, continuing when it's done //build a string with our script's args and add to stringParam args... if (taskChar != null) taskChar.executingScript = null; // need to clear this for the next scrip executedBy.ExecuteScript(scriptToExecute, executedBy.ResolveArgs(stringParam)+" trigger="+name, objectToAffect, ease); // yield until we get an update. which will complete us. we HAVE to wait, no multi threading support yet. waitingForUpdate = true; } else { // don't wait for completion, so we will JUMP and not return to this line if (taskChar != null) taskChar.executingScript = null; // need to clear this for the next scrip executedBy.QueueScript(scriptToExecute, executedBy.ResolveArgs(stringParam)+" trigger="+name, objectToAffect, ease); // yield until we get an update. which will complete us. we HAVE to wait, no multi threading support yet. executedBy.nextLineLabel = "abort"; // terminate this script error="abort"; OnComplete(); Cleanup (); } } if (type == actionType.queueScript){ // no script and loop set means flush all scripts from the queue if (scriptToExecute == null && loop && (stringParam2 == null || stringParam2 == "")){ // remove all scripts that are not currently on the stack from the queue executedBy.caller.FlushScriptQueue(); OnComplete(); Cleanup (); return; } if (scriptToExecute == null && stringParam2 != null && stringParam2 != ""){ // try finding the named game object and look for an interaction script there GameObject isGO = GameObject.Find(stringParam2); if (isGO != null) scriptToExecute = isGO.GetComponent<InteractionScript>(); } if (scriptToExecute != null) executedBy.QueueScript(scriptToExecute, executedBy.ResolveArgs(stringParam)+" trigger="+name, objectToAffect, ease); else Debug.LogError("FAILED TO FIND script named \""+stringParam2+"\""); OnComplete(); Cleanup (); return; } if (type == actionType.wait){ // we ignore wait for completion on this one... // set the HoldPosition flag if requested if (loop){ NavMeshAgentWrapper w = objectToAffect.GetComponent<NavMeshAgentWrapper>(); if (w != null) w.HoldPosition(true); // if there is no condition, holdPosition will stick till the next character task } // specifying wait 0 and delay = #delay lets you pass a delay into the script. if (fadeLength==0 && stringParam.ToLower().Contains("delay=")){ string delayString = SubstituteArgsAndAttributes(stringParam); if (!float.TryParse(delayString.Replace("delay=",""),out fadeLength)){ Debug.LogWarning("bad delay time in scripted action "+ name + stringParam); OnComplete(); Cleanup (); } else { StartCoroutine(CompleteAfterDelay (fadeLength)); return; } } // let's see about waiting for a TAG:NAME if (stringParam.Contains(":") && !stringParam.Contains ("=")){ // this could be better at excluding other things that contain ":" // assume this thing is a tag, and post a listener //GUIManager.GetInstance().AddInteractCallback(null,myInteractCallback); Brain.GetInstance().AddCallback(myInteractCallback); // fadelength should be a timeout here if > 0 if (fadeLength > 0) StartCoroutine(CompleteAfterDelay (fadeLength)); } else { if (stringParam == "" || stringParam == null){ StartCoroutine(CompleteAfterDelay (fadeLength)); } else { waitingForCondition = true; conditionNode = BinaryExpressionNode.BuildTree(stringParam); if (fadeLength > 0) StartCoroutine(CompleteAfterDelay (fadeLength)); // this starts a timeout } } } if (type == actionType.characterTask){ // taskChar = objectToAffect.GetComponent<TaskCharacter>(); nmaWrapper = objectToAffect.GetComponent<NavMeshAgentWrapper>(); if (taskChar != null){ taskChar.Init(); // clears flags taskChar.executingScript = this; // restore this flag // overload 'ease' for random pathnode/animation if (moveToName.ToLower()=="random"){ ease=true; moveToName = SceneNode.GetRandomUnlockedNode().name; // this could return a null, BOOM! } else { ease=false; } StartCoroutine(CharacterTaskAfterDelay(fadeLength)); if (!waitForCompletion){ runIndependentUpdates = true; OnComplete (); } } } if (type == actionType.attach){ // TaskCharacter tc = objectToAffect.GetComponent<TaskCharacter>(); if (negate){ // this is a detach, which leaves the object loose at the top level of the hierarchy. if (tc != null){ tc.Detach(SubstituteArgsAndAttributes(attachmentOverride)); } } else { // this is an attach, and it's usually better to attach to a new parent than to just detach. bool attachingToTcBone = true; if (tc != null){ // if there's an attachment override, and you can find the object and a bone, // then place the object at the bone plus offset location string substituted = attachmentOverride; if (attachmentOverride != "" && attachmentOverride.Contains(" ")){ string[]p = attachmentOverride.Split (' '); GameObject targetObject = GameObject.Find (SubstituteArgsAndAttributes(p[0]).Replace ("\"","")); Transform parentBone = tc.GetComponent<AnimationManager>().GetBone(p[1].Replace ("\"","")); attachingToTcBone = (parentBone != null); if (targetObject == null){ Debug.LogError(executedBy.name+": "+name+" Script Attachment found no target object in "+attachmentOverride); OnComplete(); Cleanup (); return; } if (!attachingToTcBone){ // name is not a bone, see if there's a game object by this name GameObject parentObject = GameObject.Find (SubstituteArgsAndAttributes(p[1]).Replace ("\"","")); if (parentObject != null) parentBone = parentObject.transform; tc.Detach(targetObject.name); // remove this from the attached Objects list... } substituted = targetObject.name+" "+p[1].Replace ("\"",""); if (offset != new Vector3(-1,-1,-1)){ if (targetObject != null && parentBone != null){ // if there's a delay, then we can do the lerp in a co-routine if (fadeLength > 0){ StartCoroutine (AttachAfterDelay(targetObject,parentBone,tc,substituted,attachingToTcBone)); return; // don't cleanup or complete until after delayed lerp } else { targetObject.transform.position = parentBone.TransformPoint(offset);//position+offset; targetObject.transform.rotation = parentBone.rotation*Quaternion.Euler(orientation); if (!attachingToTcBone) targetObject.transform.parent = parentBone; } } } else { // performing attach using current position if (!attachingToTcBone) targetObject.transform.parent = parentBone; } } if (attachingToTcBone) tc.Attach(substituted); } } OnComplete(); Cleanup (); } if (type == actionType.spawn){ GameObject newObject = Instantiate(Resources.Load(stringParam), objectToAffect.transform.position, objectToAffect.transform.rotation) as GameObject; newObject.name = SubstituteArgsAndAttributes(stringParam2); if (stringParam3 != ""){ GameObject newParent = GameObject.Find (stringParam3); if (newParent != null){ newObject.transform.parent = newParent.transform; newObject.transform.localPosition = offset; } } executedBy.args["spawnedname"]=newObject.name; OnComplete(); Cleanup (); } if (type == actionType.destroy){ Destroy(objectToAffect); OnComplete(); Cleanup (); } if (type == actionType.unityMessage){ // if (objectToAffect != null) objectToAffect.SendMessage(stringParam,stringParam2); OnComplete(); Cleanup (); } if (type == actionType.lockPosition){ if (negate){ NavMeshAgentWrapper w = objectToAffect.GetComponent<NavMeshAgentWrapper>(); if (w != null) w.LockPosition(false); ScriptedObject so = objectToAffect.GetComponent<ScriptedObject>(); if (so != null) so.executePriorityLock = -1; } else { NavMeshAgentWrapper w = objectToAffect.GetComponent<NavMeshAgentWrapper>(); if (w != null) w.LockPosition(true); if (stringParam != ""){ int lockPriority; if (int.TryParse(stringParam,out lockPriority)){ ScriptedObject so = objectToAffect.GetComponent<ScriptedObject>(); if (so != null) so.executePriorityLock = lockPriority; } } // test unlocking any nodes we have locked, so they are not blocking. // this is specifically for BVM, but might be good overall. SceneNode.UnlockLocation(objectToAffect.transform.position,0.5f); // radius is completely arbitrary 0.44f is probably a good value. } OnComplete(); Cleanup (); } if (type == actionType.goToLine){ // executedBy.nextLineLabel = stringParam; // untested, and very scary OnComplete(); Cleanup (); } if (type == actionType.setIKTarget){ // TaskCharacter tc = objectToAffect.GetComponent<TaskCharacter>(); if (tc != null){ IKArmController ctlr = tc.IKArmRight; if (stringParam.ToLower().Contains ("left")) ctlr = tc.IKArmLeft; if ((moveToName == null) || moveToName == ""){ // we are clearing the target ctlr.target = null; } else { GameObject targetGo = GameObject.Find(moveToName); if (targetGo != null){ ctlr.target = targetGo.transform; HandPoser poser = targetGo.GetComponent<HandPoser>(); if (poser != null) poser.Setup(ctlr.hand); } } ctlr.blendTime = fadeLength; ctlr.offset = offset; ctlr.orientation = Quaternion.Euler(orientation); if (stringParam2 == null || stringParam2 == "") stringParam2 = "0"; float releaseTime = 0; float.TryParse(stringParam2, out releaseTime); ctlr.releaseTime = releaseTime; } OnComplete(); // we'll worry about wait for completion later TODO Cleanup (); } }
void BuildOnToNode(string szString) { // throws away the first token, so call this with the string that built the node you are on ? string sParser = szString; if(sParser != null) { BinaryExpressionNode pInsertSpot = this; while(sParser != null) // we throw away the first token { if (sParser.IndexOf (" ") >= 0) sParser = sParser.Substring(sParser.IndexOf (" ")); else sParser = null; if(sParser != null) { while(sParser[0] == ' ') { if (sParser.Length == 1) return; sParser = sParser.Substring(1);//Skip the ' ' } //New Node BinaryExpressionNode pNewNode = new BinaryExpressionNode(sParser); if(pNewNode.IsOpenParenthesis()) { pNewNode.SetParent(pInsertSpot, pInsertSpot.m_Left == null); //Choose a free spot pInsertSpot = pNewNode; //And change the target continue; } else if(pInsertSpot.IsOpenParenthesis()) { pInsertSpot.m_bNot = pNewNode.m_bNot; //Parenthesese should never exist in the tree after building pInsertSpot.m_dwDataHash = pNewNode.m_dwDataHash; //So, we copy the data over the Parenthesis pInsertSpot.m_Data = pNewNode.m_Data; //pNewNode->Release(); continue; } if(pNewNode.IsCloseParenthesis()) { if(pInsertSpot != null && pInsertSpot.m_Parent != null) pInsertSpot = pInsertSpot.m_Parent; //pop back up a level } else if(pNewNode.IsOperator()) { if(pInsertSpot.m_Parent != null) //If we have a parent we have to make sure to inform the parent { //that we are being adopted pNewNode.SetParent(pInsertSpot.m_Parent, pInsertSpot.m_Parent.m_Left == pInsertSpot); } pNewNode.SetLeft(pInsertSpot); //First thing will always go left pInsertSpot = pNewNode; } else { pInsertSpot.SetRight(pNewNode); //Always goes right } } } } }
void SetParent(BinaryExpressionNode pParent, bool bLeft) { //Safe goodness, nothing to see here if(bLeft) pParent.SetLeft(this); else pParent.SetRight(this); }
void SetRight(BinaryExpressionNode pRight) { m_Right = pRight; if(pRight != null) { pRight.m_Parent = this; } }
void SetLeft(BinaryExpressionNode pLeft) { //Relying on garbage collection to clean up old references... m_Left = pLeft; if(pLeft != null) { pLeft.m_Parent = this; } }
private static void ParseUserCodeCore(Core core, string expression, out List <AssociativeNode> astNodes, out List <AssociativeNode> commentNodes) { astNodes = new List <AssociativeNode>(); core.ResetForPrecompilation(); core.IsParsingCodeBlockNode = true; core.ParsingMode = ParseMode.AllowNonAssignment; ParseResult parseResult = ParserUtils.ParseWithCore(expression, core); commentNodes = ParserUtils.GetAstNodes(parseResult.CommentBlockNode); var nodes = ParserUtils.GetAstNodes(parseResult.CodeBlockNode); Validity.Assert(nodes != null); int index = 0; int typedIdentIndex = 0; foreach (var node in nodes) { var n = node as AssociativeNode; Validity.Assert(n != null); // Append the temporaries only if it is not a function def or class decl bool isFunctionOrClassDef = n is FunctionDefinitionNode || n is ClassDeclNode; if (n is ImportNode) { core.BuildStatus.LogSemanticError(Resources.ImportStatementNotSupported); } else if (isFunctionOrClassDef) { // Add node as it is astNodes.Add(node); } else { // Handle temporary naming for temporary Binary exp. nodes and non-assignment nodes var ben = node as BinaryExpressionNode; if (ben != null && ben.Optr == Operator.assign) { var lNode = ben.LeftNode as IdentifierNode; if (lNode != null && lNode.Value == Constants.kTempProcLeftVar) { string name = Constants.kTempVarForNonAssignment + index; var newNode = new BinaryExpressionNode(new IdentifierNode(name), ben.RightNode); astNodes.Add(newNode); index++; } else { // Add node as it is astNodes.Add(node); index++; } } else { if (node is TypedIdentifierNode) { // e.g. a : int = %tTypedIdent_<Index>; var ident = new IdentifierNode(Constants.kTempVarForTypedIdentifier + typedIdentIndex); NodeUtils.CopyNodeLocation(ident, node); var typedNode = new BinaryExpressionNode(node as TypedIdentifierNode, ident, Operator.assign); NodeUtils.CopyNodeLocation(typedNode, node); astNodes.Add(typedNode); typedIdentIndex++; } else { string name = Constants.kTempVarForNonAssignment + index; var newNode = new BinaryExpressionNode(new IdentifierNode(name), n); astNodes.Add(newNode); index++; } } } } }