public void InitWarden() { ModuleName = "5F947B8AB100C93D206D1FC3EA1FE6DD"; Script = new ScriptedObject($"warden\\{ModuleName}.vb", $"warden\\{ModuleName}.dll", InMemory: false); WardenModule = (byte[])Script.InvokeField("Main", "MD5"); ModuleKey = (byte[])Script.InvokeField("Main", "RC4"); ModuleSize = Conversions.ToInteger(Script.InvokeField("Main", "Size")); CheckIDs[0] = Conversions.ToByte(Script.InvokeField("Main", "MEM_CHECK")); CheckIDs[1] = Conversions.ToByte(Script.InvokeField("Main", "PAGE_CHECK_A")); CheckIDs[2] = Conversions.ToByte(Script.InvokeField("Main", "MPQ_CHECK")); CheckIDs[3] = Conversions.ToByte(Script.InvokeField("Main", "LUA_STR_CHECK")); CheckIDs[4] = Conversions.ToByte(Script.InvokeField("Main", "DRIVER_CHECK")); CheckIDs[5] = Conversions.ToByte(Script.InvokeField("Main", "TIMING_CHECK")); CheckIDs[6] = Conversions.ToByte(Script.InvokeField("Main", "PROC_CHECK")); CheckIDs[7] = Conversions.ToByte(Script.InvokeField("Main", "MODULE_CHECK")); ModuleData = File.ReadAllBytes("warden\\" + ModuleName + ".bin"); if (LoadModule(ModuleName, ref ModuleData, ModuleKey)) { WorldServiceLocator._WorldServer.Log.WriteLine(LogType.SUCCESS, "[WARDEN] Load of module, success [{0}]", ModuleName); } else { WorldServiceLocator._WorldServer.Log.WriteLine(LogType.CRITICAL, "[WARDEN] Failed to load module [{0}]", ModuleName); } }
// Update is called once per frame void Update() { if (Input.GetKeyDown(GameManager.SELECT_KEY)) { if (selectedObject != null) { releaseObject(); } else if (selectedObject == null && inRangeObject != null) { StartCoroutine(ToggleAnimation(true, 0)); if (inRangeObject.CompareTag(GameManager.ANIMATED_OBJECT_TAG)) { AnimatedObject anim = inRangeObject.GetComponent <AnimatedObject>(); anim.Invoke("ActivateAnimation", 0.3f); StartCoroutine(ToggleAnimation(false, 0.05f)); } else if (inRangeObject.CompareTag(GameManager.SCRIPTED_OBJECT_TAG)) { ScriptedObject scrpt = inRangeObject.GetComponent <ScriptedObject>(); scrpt.runScript(); StartCoroutine(ToggleAnimation(false, 0.1f)); } else if (inRangeObject.CompareTag(GameManager.MOVABLE_OBJECT_TAG)) { selectObject(); } } } }
public static void Init(ScriptedObject SO){ instance = (MenuEditWindow)EditorWindow.GetWindow(typeof(MenuEditWindow)); // be sure we don't blow away and edits when switching scripts... instance.myObject = SO; instance.title = "Menu Category Editor"; instance.CleanScripts(); instance.myTree = ScriptMenuTreeNode.BuildMenu(SO); }
// temporary debug variables // string eventtype = ""; // string mouseloc = ""; public static void Init(ScriptedObject role){ instance = (RoleEditorWindow)EditorWindow.GetWindow(typeof(RoleEditorWindow)); // be sure we don't blow away and edits when switching scripts... // instance.requestedScript = script; // what if we start running before saving ? we should probably warn for that too. // if (!(EditorApplication.isPlaying || EditorApplication.isPaused)) // don't load up yet, put up a confirmation dialog first. // instance.confirmChange=true; // return; // } instance.myLeftRole = role; instance.title = "Role Editor"; instance.leftHasChanged = false; instance.rightHasChanged = false; // EditorApplication.playmodeStateChanged += instance.PlaymodeCallback; }
static ScriptedObjectTest() { ConstructorArgumentValidationTestScenarios .AddScenario(() => new ConstructorArgumentValidationTestScenario <ScriptedObject> { Name = "constructor should throw ArgumentOutOfRangeException when parameter 'databaseObjectType' is ScriptableObjectType.Invalid scenario", ConstructionFunc = () => { var referenceObject = A.Dummy <ScriptedObject>(); var result = new ScriptedObject( referenceObject.Name, ScriptableObjectType.Invalid, referenceObject.DropScript, referenceObject.CreateScript); return(result); }, ExpectedExceptionType = typeof(ArgumentOutOfRangeException), ExpectedExceptionMessageContains = new[] { "scriptableObjectType", "Invalid" }, }); }
public WardenMaiev() { WardenModule = Array.Empty <byte>(); ModuleName = ""; ModuleKey = Array.Empty <byte>(); ModuleData = Array.Empty <byte>(); ModuleSize = 0; CheckIDs = new byte[8]; Script = null; delegateCache = new Dictionary <string, Delegate>(); dwModuleSize = 0; dwLibraryCount = 0; SendPacketD = null; CheckModuleD = null; ModuleLoadD = null; AllocateMemD = null; FreeMemoryD = null; SetRC4DataD = null; GetRC4DataD = null; GenerateRC4Keys = null; UnloadModule = null; PacketHandler = null; Tick = null; m_Mod = 0; m_ModMem = 0; InitPointer = 0; init = null; myFuncList = IntPtr.Zero; myFunctionList = default; pFuncList = 0; ppFuncList = 0; myWardenList = default; pWardenList = 0; m_RC4 = 0; m_PKT = Array.Empty <byte>(); }
public void HandleStatus() { /* These calls are terribly expensive, and are eating 50% of our CPU runtime TODO Find a place where they can be done once */ // get the icontag if (iconTag == null && checkCount < 100) { iconTag = GetComponentInChildren<IconTag> (); checkCount++; } // get scripted object if (SO == null && checkCount < 100) { SO = GetComponent<ScriptedObject> () as ScriptedObject; checkCount++; } /* */ if ( SO != null ) { // set busy if ( SO.GetCurrentScript() != null ) CurrentState=State.busy; else CurrentState=State.idle; // set talking Brain.AudioInfo ai = Brain.GetInstance().CurrentAudioInfo; if ( ai != null ) { if ( ai.name == Name ) { CurrentState = State.talking; // turn on tag if talking if ( iconTag != null ) iconTag.renderer.enabled = true; } } // reset iconTag to highlight status if ( iconTag != null ) { iconTag.renderer.enabled = highlight; if ( CurrentState == State.talking ) iconTag.renderer.enabled = true; } // check to see if we need updating if ( CurrentState == lastState ) return; lastState = CurrentState; // change state if ( iconTag != null ) { // set material switch (CurrentState) { case State.busy: if ( texBusy == null ) texBusy = Resources.Load<Texture2D>("GUI/npcStatus-busy"); if ( texBusy != null ) iconTag.renderer.material.mainTexture = texBusy; break; case State.talking: if ( texTalking == null ) texTalking = Resources.Load<Texture2D>("GUI/npcStatus-talking"); if ( texTalking != null ) iconTag.renderer.material.mainTexture = texTalking; // force on if talking iconTag.renderer.enabled = true; break; case State.idle: if ( texListening == null ) texListening = Resources.Load<Texture2D>("GUI/npcStatus-listening"); if ( texListening != null ) iconTag.renderer.material.mainTexture = texListening; break; } } } }
public void Awake() { if(canLookAt) lookAt = body.GetComponent<LookAtController>(); if(lookAt == null) canLookAt = false; if(breatheClip != null) { body.animation[breatheClip.name].blendMode = AnimationBlendMode.Additive; body.animation[breatheClip.name].layer = 1; } else Debug.LogWarning(gameObject.name + " starting with no breatheClip!!"); //if(postures.Count > 0 && !animInit) //InitAnimations(); // whoever gets here first can build these: if (maleClips == null){ maleClips = new Dictionary<string,AnimationClip>(); Object[] mObjs = Resources.LoadAll("Animations/Male"); // this seems pretty lame, but this is how we apparently have to instantiate these for (int i=0; i<mObjs.Length; i++){ Instantiate(mObjs[i]); maleClips.Add (mObjs[i].name, mObjs[i] as AnimationClip); } } if (femaleClips == null){ femaleClips = new Dictionary<string,AnimationClip>(); Object[] mObjs = Resources.LoadAll("Animations/Female"); // this seems pretty lame, but this is how we apparently have to instantiate these for (int i=0; i<mObjs.Length; i++){ Instantiate(mObjs[i]); femaleClips.Add (mObjs[i].name, mObjs[i] as AnimationClip); } } if (animationScriptObject == null){ Object SOB = Resources.Load("Animations/AnimationScripts"); GameObject go = Instantiate (SOB) as GameObject; if (go != null){ animationScriptObject = go.GetComponent<ScriptedObject>(); } } }
public override StringCollection Script(SmoScriptingContext context) { var textObject = ScriptedObject as ITextObject; if (textObject == null) { throw new InvalidOperationException( String.Format("ScriptedObject '{0}' cannot be scripted as alter", ScriptedObject.GetType().Name)); } StringCollection result = Script(textObject, context); return(result); }
public void ReleasedBy(InteractionScript script, ScriptedObject caller){ // Debug.LogError(name+" Released by "+script.name); if (reservedForScript == script) reservedForScript = null; // we cleared this when we started the script... if (actingInScript == script){ // if the releasing script was stacked, and will release to a higher script, we must not clear this // or it opens a window wher another waiting script could take control ScriptedObject so = caller; //GetComponent<ScriptedObject>(); if (so == null) so = GetComponent<ScriptedObject>(); if (so == null) return; if (so.scriptStack.Count <= 1){ // if the script that was running was not stacked // should we be setting this null here if we don't release ? // actingInScript = null; // now our character is free to run scripts. int checkCount = GetComponent<ScriptedObject>().scriptStack.Count; if (GetComponent<ScriptedObject>().scriptStack.Count == 0){ // or maybe 1 ? GetComponent<ScriptedObject>().ReleasedBy(script); actingInScript = null; // now our character is free to run scripts. } else { // what should this branch do ? GetComponent<ScriptedObject>().ReleasedBy(script); actingInScript = null; } } else{ ScriptedObject.QueuedScript temp = so.scriptStack.Pop (); InteractionScript callingScript = so.scriptStack.Peek ().script; so.scriptStack.Push (temp); // release any actors not needed by the calling script if (callingScript.actorObjects.Contains (this)){ actingInScript = callingScript; } else { // reenabled these two lines 11/19/15 to get queued blanket scripts to run in parallel actingInScript = null; GetComponent<ScriptedObject>().ReleasedBy(script); // this was added to fix leaving a hole when roll patient finished in exam bleeding // add me to the calling script's actors so i will be released when it is done // but maybe we shold fix exam bleeding by adding the needed characters instead // of this fix, which prevents actors from being released after sub scripts... //11/19/15 callingScript.actorObjects.Add (this); //11/19/15 actingInScript = callingScript; } } } }
public void ExecuteEvent(ScriptedObject thisCaller,string eventName){ // intended to be called from animation Events, start execution at the named line, and // run until an action flagged sequenceEnd=true; // Look for the line. fail if not found int startingIndex=-1; for (int i=0;i<scriptLines.Length;i++){ if (scriptLines[i].name == eventName){ startingIndex=i; break; } } if (startingIndex <0){ Debug.LogError("AnimationEvent using "+name+" could not find line "+eventName); return; } // caller is only used by ExecuteScript and onScriptComplete, so we might go without it... caller = thisCaller; myObject = caller.gameObject; args.Clear(); // do we need any args for events ? SetArgs (startingArgs); currentLine = startingIndex; nextLineLabel = ""; isRunning = true; readyState = readiness.executing; myOI = caller.GetComponent<ObjectInteraction>(); if (debug) Debug.Log ("Script "+name+" execution started"); if (scriptLines[currentLine] != null) scriptLines[currentLine].ForceExecute(this); else OnScriptComplete(""); }
public void OnScriptComplete(string error){ if (debug) Debug.Log ("Script "+name+" OnScriptComplete"); // we're done. Assuming no errors, see if we need to send a :COMPLETE message string triggerString = "none"; if (args.ContainsKey("trigger")) triggerString = args["trigger"]; if (triggerString.Contains(":")) { // send :COMPLETE msg to brain string completion; if (error == null || error == "") completion = ":COMPLETE"; else completion = ":"+error.ToUpper(); InteractStatusMsg msg = new InteractStatusMsg(triggerString + completion); Brain.GetInstance().PutMessage(msg); } // hasRun = true; isRunning = false; readyState = readiness.unknown; // will update on the next readiness test. currentLine = scriptLines.Length; // so don't update a line by accident ScriptedObject myCaller = caller; caller = null; // have to do this before, because OnScriptComplete could start us up again! // release character task actors foreach (ObjectInteraction actor in actorObjects){ actor.ReleasedBy(this, myCaller); } if (myCaller == null) Debug.LogWarning("Script Complete but caller was null!!"+name); else{ // added this block 6/19/14 to keep queue from hanging when scripts owned by another // object interaction are run from an objects queue if (!actorObjects.Contains(myCaller.ObjectInteraction)) myCaller.ObjectInteraction.ReleasedBy (this, myCaller); myCaller.OnScriptComplete(this,error); } roleMap.Clear(); // clear the assigned roles so they don't get reserved by accident actorObjects.Clear(); }
void AddScript(ScriptedObject so,string newName){ // create a new child game object with a default scripted action and link it in GameObject newChild = new GameObject(newName); InteractionScript newIS = newChild.AddComponent("InteractionScript") as InteractionScript; // maybe initialize some fields to meaningful defaults ? newIS.item = newName; newIS.triggerStrings = new string[1]; newIS.triggerStrings[0] = newName; newIS.triggerOnStatus = false; newIS.scriptLines = new ScriptedAction[0]; newChild.transform.parent = so.transform; if (so.scripts == null) so.scripts = new InteractionScript[0]; InteractionScript[] tmp = new InteractionScript[ so.scripts.Length]; for (int i=0; i < so.scripts.Length; i++){ tmp[i]= so.scripts[i]; } so.scripts = new InteractionScript[tmp.Length+1]; for (int i=0; i < tmp.Length; i++){ so.scripts[i] = tmp[i]; } so.scripts[tmp.Length] = newIS; EditorUtility.SetDirty(newIS); // go ahead and bring it up in the editor ScriptViewWindow.Init(newIS); }
// void Awake(){ // EditorApplication.playmodeStateChanged += PlaymodeCallback; // } void OnGUI(){ // wantsMouseMove = true; // mouseloc = Event.current.mousePosition.ToString() + dropTarget.ToString(); // handle drag/drop mouse events -------------------------------------------------------- if (Event.current.type == EventType.mouseDrag){ if (dragObject == null){ // mark where the drag started so the Repaint can check dragStart = Event.current.mousePosition; dragStart.y -= headerHeight+20; // there's some strange offset required here... } else { // dragging if ( dropTarget.Contains(Event.current.mousePosition)){ // handle highlight of drop target dropColor = Color.green; } else dropColor = Color.white; } } if (Event.current.type == EventType.mouseUp && dragObject != null){ dropColor = Color.red; if ( dropTarget.Contains(Event.current.mousePosition)){ // Perform Drop if (dropTargetRole == myLeftRole) leftHasChanged = true; else rightHasChanged = true; // see if we are rearranging within a role, or copying to a new role if (dragObject.transform.parent.gameObject == dropTargetRole.gameObject){ // rearranging. Need to know if we are moving up or down in the list, // because the dropTargetIndex changes if current index is lower. InteractionScript movingScript = dragObject.GetComponent<InteractionScript>(); int currentIndex = dropTargetRole.IndexOf(movingScript); if (currentIndex < 0){ // we should only be seeing array elements here... use Adopt drop target to reparent. return; } else { if (dropTargetIndex > 0 && currentIndex <= dropTargetIndex) dropTargetIndex --; // drop target index is never < 1 dropTargetRole.RemoveScript(movingScript); dropTargetRole.InsertScriptAt(movingScript,dropTargetIndex); } } else { // duplicate entire InteractionScript,gameObject, actions, etc...and insert into drop Role GameObject newScriptObject = Instantiate(dragObject) as GameObject; newScriptObject.name = dragObject.name; // parent to the target role newScriptObject.transform.parent = dropTargetRole.transform; // convert role references in scripted actions of the new script if possible...TODO! InteractionScript newScript = newScriptObject.GetComponent<InteractionScript>(); dropTargetRole.InsertScriptAt(newScript,dropTargetIndex); dragObject = null; dragStart = Vector2.zero; return; // does this avoid the GUI Element count error ? } dropColor = Color.yellow; // for debugging only } // un drag, no matter dragObject = null; dragStart = Vector2.zero; } // END of mouse even processing for drag and drop ------------------------------------------------------ GUILayout.Label ("DRAG and DROP Interactions between Roles. Drag roles (ScriptedObjects) to edit in from Hierarchy"); /* if (GUILayout.Button (Event.current.type.ToString()+" "+mouseloc)){ eventtype=""; mouseloc=""; dropColor = Color.white; } */ // draw the left role GUILayout.BeginArea (new Rect(0,headerHeight ,position.width*.5f,position.height)); GUILayout.BeginHorizontal (); myLeftRole = (ScriptedObject)EditorGUILayout.ObjectField("ROLE:",myLeftRole,typeof(ScriptedObject),true,GUILayout.Width(position.width*.5f-100)); if (myLeftRole != null){ if (leftHasChanged){ // SAVE BUTTON! GUI.color = Color.green; if ( GUILayout.Button("SAVE")){ SaveRole(myLeftRole); leftHasChanged = false; } GUI.color = Color.red; if ( GUILayout.Button("UNDO")){ RevertRole(myLeftRole); leftHasChanged = false; } GUI.color = Color.white; } else{ if ( GUILayout.Button("CLEAR")) myLeftRole = null; } } GUILayout.EndHorizontal(); if (myLeftRole != null){ DrawRole(myLeftRole,ref leftScrollPos,ref leftConfirmDelete,ref leftHasChanged,0,headerHeight+20); } GUILayout.EndArea(); // draw the right role GUILayout.BeginArea (new Rect(position.width*.5f,headerHeight ,position.width*.5f,position.height)); GUILayout.BeginHorizontal (); myRightRole = (ScriptedObject)EditorGUILayout.ObjectField("ROLE:",myRightRole,typeof(ScriptedObject),true,GUILayout.Width(position.width*.5f-100)); if (myRightRole != null){ if (rightHasChanged){ // SAVE BUTTON! GUI.color = Color.green; if ( GUILayout.Button("SAVE")){ SaveRole(myRightRole); rightHasChanged = false; } GUI.color = Color.red; if ( GUILayout.Button("UNDO")){ RevertRole(myRightRole); rightHasChanged = false; } GUI.color = Color.white; } else{ if ( GUILayout.Button("CLEAR")) myRightRole = null; } } GUILayout.EndHorizontal(); if (myRightRole != null){ DrawRole(myRightRole,ref rightScrollPos,ref rightConfirmDelete,ref rightHasChanged,position.width*.5f,headerHeight+20); } GUILayout.EndArea(); // show dragObject last if (dragObject == null) GUI.Button(new Rect(0,0,0,0),""); // dummy button to keep GUI element count even else{ GUI.color = Color.green; if (GUI.Button(new Rect(Event.current.mousePosition.x-20,Event.current.mousePosition.y+10,250,20),dragObject.name)){ dragObject = null; dragStart = Vector2.zero; } GUI.color = Color.green; } }
void RevertRole(ScriptedObject role){ // role.LoadFromXML(role.XMLName); // reverting from the prefab is preferred. // because LOAD disconnects... // PrefabUtility.ResetToPrefabState(role.gameObject); // this seems to work strangely like an 'undo' // PrefabUtility.ReconnectToLastPrefab(role.gameObject); PrefabUtility.RevertPrefabInstance(role.gameObject); }
void DrawRole(ScriptedObject role,ref Vector2 scrollPos,ref int confirmDelete,ref bool hasChanged, float areaOffsetX,float areaOffsetY){ Rect lastRect = new Rect(0,0,0,0); if (role == null || role.scripts == null){ GUILayout.Label("I lost my Role somewhere... sorry"); return; } GUI.color = Color.white; scrollPos = EditorGUILayout.BeginScrollView(scrollPos); for (int i=0; i< role.scripts.Length; i++){ if (confirmDelete == i){ GUILayout.Label("CONFIRM Delete? (Script will remain as orphan)"); if (GUILayout.Button("YES, ORPHAN the script.")){ role.RemoveScript(role.scripts[i]); hasChanged = true; confirmDelete = -1; return; // does this avoid the GUI count error ? } if (GUILayout.Button("Oops, no, Keep the script")){ confirmDelete = -1; } } bool expand = false; GUILayout.BeginHorizontal(); GUI.backgroundColor = Color.grey; if (GUILayout.Button (new GUIContent("X",null,"delete line"),GUILayout.ExpandWidth(false))){ confirmDelete = i; break; // we've affected the array, don't draw any more gui this frame. } if (role.scripts[i]!=null && Selection.activeObject != role.scripts[i].gameObject){ GUI.backgroundColor = Color.yellow; if (GUILayout.Button (new GUIContent(">",null,"EDIT line"),GUILayout.ExpandWidth(false))){ Selection.activeGameObject = role.scripts[i].gameObject; ScriptViewWindow.Init(role.scripts[i]); } } else { GUI.backgroundColor = Color.red; expand = true; if (GUILayout.Button (new GUIContent("V",null,"CLOSE line"),GUILayout.ExpandWidth(false))) Selection.activeGameObject = role.gameObject; } // string prefix = i<10?" ":""; GUI.color = Color.white; GUI.backgroundColor = Color.white; GUILayout.Button(role.scripts[i].name+" | "+role.scripts[i].prettyname); // DRAG SOURCE from the above button // place this right after you draw the GUI element to drag from:-------------------------------- // we pick the drag source during the Repaint pass, using the drag start that was set during the // EventMouseDrag handler when there was no Drag Object set ... if(Event.current.type == EventType.Repaint){ lastRect = GUILayoutUtility.GetLastRect(); Rect dragCheckRect = lastRect; // need to check against window coords, not area coords dragCheckRect.x += areaOffsetX; dragCheckRect.y -= scrollPos.y; if(dragObject == null && dragCheckRect.Contains(dragStart)) dragObject = role.scripts[i].gameObject; } //-----------------------------------------End Drag Source handler ------------------------------- GUI.color = Color.white; // if (GUILayout.Button (new GUIContent("?",null,"show help"),GUILayout.ExpandWidth(false))) helpTarget = myScript.scriptLines[i]; GUILayout.EndHorizontal(); // Set up a possible drop target button if we are dragging something over the item we just showed // we use GUI.Button instead of GUILayout.Button for better control of the drop target display Rect nextRect = lastRect; nextRect.y += nextRect.height/2; // move the drop target down a little to represent "insert after" if (dragObject != null && nextRect.Contains(Event.current.mousePosition)){ GUILayoutUtility.GetRect (nextRect.width,nextRect.width,nextRect.height,nextRect.height); // reserve space for the drop target GUI.color = dropColor; // set in the MouseDrag pass to debug, but we don't really need that since it's working string verb = "COPY "; if (dragObject.transform.parent.gameObject == role.gameObject) verb = "MOVE "; GUI.Button(nextRect,verb+dragObject.name+" HERE ["+dropTargetIndex+"]"); if(Event.current.type == EventType.Repaint){ dropTargetIndex = i+1; // where we would insert in the list... dropTargetRole = role; dropTarget = nextRect; dropTarget.x += areaOffsetX; dropTarget.y += areaOffsetY; // relative to the window origin, not the GUI area... } GUI.color = Color.white; } else { // dummy button to keep the count even GUILayoutUtility.GetRect (0,0,0,0); GUI.Button(new Rect(0,0,0,0),""); } } InteractionScript adoptScript = null; adoptScript = (InteractionScript)EditorGUILayout.ObjectField("Re-Adopt Child Script:",adoptScript,typeof(InteractionScript),true,GUILayout.Width(position.width*.5f-20)); if (adoptScript != null){ // be sure this is our child... if (adoptScript.transform.parent.gameObject == role.gameObject){ role.InsertScriptAt(adoptScript, role.scripts.Length); hasChanged = true; return; } } GUI.backgroundColor = Color.white; if (GUILayout.Button ("",GUILayout.ExpandWidth(false))){ //extra line so we can scroll to the bottom } EditorGUILayout.EndScrollView(); // hasChanged |= GUI.changed; // only when WE say it has. if (GUI.changed) EditorUtility.SetDirty(role); // this helps keep changes }
int AddScripts(MenuTreeNode node,ScriptedObject SO, int index){ if (node.map != null){ InteractionScript IS = BuildScriptFromInteraction(node.map); SO.scripts[index] = IS; // build the unity hierachy IS.gameObject.transform.parent = SO.gameObject.transform; index++; } else { foreach (MenuTreeNode n in node.children) index = AddScripts(n,SO,index); } return index; }
void OnWizardOtherButton(){ menuTree = MenuTreeNode.BuildMenu(XMLName); // assuming that worked, we'll build a script of character tasks for every node that is an interaction. string[] parts = XMLName.Split('/'); GameObject scriptedObjectGO = new GameObject(parts[parts.Length-1]+"Scripts"); SO = scriptedObjectGO.AddComponent<ScriptedObject>(); int numScripts = CountScripts(menuTree); SO.scripts = new InteractionScript[numScripts]; // now traverse the menutree, and as we encounter maps, build them into scripts currentScript = 0; // this is a global AddScripts(menuTree, SO, currentScript); SO.prettyname = parts[parts.Length-1]+" Scripts"; SO.XMLName = XMLName+" "+DateTime.Now.ToString(); // we really don't need this value, but it shows where we came from SO.moveToParentOnDrop = true; }
ScriptMenuTreeNode newNode; // used when building up new menus // bool valid = true; // when adding a new node, set to true when all required fields have values. // these local varaibles are for the editor GUI, letting you open one task,list or stringmap per node for editing. // string editingTaskKey = ""; // the task at this node open for edit // string editingStrmapKey = ""; // StringMap editStrmap = new StringMap(); // this persistent value lets us edit a stringmap public static ScriptMenuTreeNode BuildMenu( ScriptedObject SO ) // pass in the scripted object { ScriptMenuTreeNode returnNode = new ScriptMenuTreeNode(); returnNode.subcategories = new Dictionary<string, ScriptMenuTreeNode>(); returnNode.scripts = new List<InteractionScript>(); foreach (InteractionScript script in SO.scripts) { ScriptMenuTreeNode currentNode = returnNode; if (script.category == null || script.category.Count==0) { currentNode.scripts.Add(script); } else { foreach (string cat in script.category) { // find or build out the category tree to point to the desired category currentNode = GetNode(returnNode, cat); // add this script to that node's script list currentNode.scripts.Add(script); // it's a terminal node, an interaction } } } return returnNode; }
void SaveRole(ScriptedObject role){ role.SaveToXML(role.XMLName); // update the prefab too! GameObject vup = PrefabUtility.FindValidUploadPrefabInstanceRoot(role.gameObject); // Debug.Log (po.ToString()+pp.ToString()+pr.ToString()+rgo.ToString()+vup.ToString()); if ( vup != null){ PrefabUtility.ReplacePrefab (vup, PrefabUtility.GetPrefabParent(vup), ReplacePrefabOptions.ConnectToPrefab); // GetPrefabObject crashed unity editor... } // PrefabUtility.ReplacePrefab (role.gameObject, // PrefabUtility.GetPrefabParent(role.gameObject), // ReplacePrefabOptions.ConnectToPrefab); // GetPrefabObject crashed unity editor... }
public void Execute(ScriptedObject thisCaller,string argString="", GameObject obj=null){ caller = thisCaller; foreach (ObjectInteraction actor in actorObjects){ actor.reservedForScript = null; // incase anyone got reserved who doesn't get picked by the dispatcher } // here, we must find a character for each role, assign and reserve them Dispatcher.GetInstance().FillRoles(this); // bail if fail if (obj == null) myObject = caller.gameObject; // the scripted object by default else myObject = obj; args.Clear(); // clear the dictionary to start SetArgs (startingArgs); SetArgs(argString); currentLine = 0; nextLineLabel = ""; isRunning = true; readyState = readiness.executing; myOI = caller.GetComponent<ObjectInteraction>(); //Debug.LogWarning(name+" reserving "+myOI.name); foreach (ObjectInteraction actor in actorObjects){ actor.actingInScript = this; actor.reservedForScript = null; } foreach (ScriptedAction sa in scriptLines) sa.hasExecuted = false; // really just for debug use, would break 'executeOnlyOnce' // if there's an interaction set specified, send it to the interaction manager. if (interactionSet != null && interactionSet.Name != null && interactionSet.Name != "") InteractionMgr.GetInstance().CurrentSet = interactionSet; if (debug) Debug.Log ("Script "+name+" execution started"); // we're going to have to handle multiple current lines for roles if (scriptLines[currentLine] != null) scriptLines[currentLine].Execute(this); else OnScriptComplete(""); }
bool CheckScriptName(ScriptedObject so){ if (newScriptName == ""){ scriptNameWarning = "You must Supply a ScriptName"; return false; } if (so.scripts != null) foreach (InteractionScript script in so.scripts){ // should really check globally across all scripts. if (script.name == newScriptName){ scriptNameWarning = "ScriptName already used"; return false; } } scriptNameWarning = ""; addScriptButtonLabel = "ADD SCRIPT"; return true; }
void SaveUpdatedPrefab(ScriptedObject so){ so.SaveToXML(so.XMLName); so.SaveToPrefab(); }
// because the scripted objects thenselves are generally not created from serialized data when the game is run, // but rather instantiated from prefabs or placed in the level or asset bundle, these serialize routines // may not really matter. The individual interaction scripts/actions, however, really do have to be right!! public ScriptedObjectInfo ToInfo(ScriptedObject so){ // saves values to an info for serialization (to XML) ScriptedObjectInfo info = new ScriptedObjectInfo(); info.unityObjectName = so.name; info.moveToParentOnDrop = so.moveToParentOnDrop; // set this in each prefab, but false so constructed ones dont info.dropTargetName = so.dropTargetName; info.scripts = new InteractionScript.InteractionScriptInfo[so.scripts.Length]; for (int i = 0; i<so.scripts.Length; i++){ if (so.scripts[i] != null){ info.scripts[i] = so.scripts[i].ToInfo(so.scripts[i]); } else { Debug.Log("Scripted Boject "+so.name+"contains null script at index "+i); #if UNITY_EDITOR EditorUtility.DisplayDialog("Save Failed","Scripted Boject "+so.name+"contains null script at index "+i,"OK"); #endif } } if (so.startupScript != null) info.startupScriptName = so.startupScript.name; info.register = so.register; // instead, derive this from any contained scripts who listen to status messages info.prettyname = so.prettyname; // this was on the OI class, we shouldnt need it here info.XMLName = so.XMLName; info.XMLDirectory = so.XMLDirectory; info.assetBundleInfo = so.assetBundleInfo; info.voiceList = so.voiceList; info.voiceLists = so.voiceLists; info.vitalsBehaviors = so.vitalsBehaviors; info.scanRecords = so.scanRecords; return info; }
public CreatureInfo(int CreatureID) : this() { Id = CreatureID; WorldServiceLocator._WorldServer.CREATURESDatabase.Add(Id, this); DataTable MySQLQuery = new DataTable(); WorldServiceLocator._WorldServer.WorldDatabase.Query($"SELECT * FROM creature_template LEFT JOIN creature_template_spells ON creature_template.entry = creature_template_spells.`entry` WHERE creature_template.entry = {CreatureID};", ref MySQLQuery); if (MySQLQuery.Rows.Count == 0) { WorldServiceLocator._WorldServer.Log.WriteLine(LogType.FAILED, "CreatureID {0} not found in SQL database.", CreatureID); found_ = false; return; } found_ = true; ModelA1 = MySQLQuery.Rows[0].As <int>("modelid1"); ModelA2 = MySQLQuery.Rows[0].As <int>("Modelid2"); ModelH1 = MySQLQuery.Rows[0].As <int>("modelid3"); ModelH2 = MySQLQuery.Rows[0].As <int>("modelid4"); Name = MySQLQuery.Rows[0].As <string>("name"); try { SubName = MySQLQuery.Rows[0].As <string>("subname"); } catch (Exception projectError) { ProjectData.SetProjectError(projectError); SubName = ""; ProjectData.ClearProjectError(); } Size = MySQLQuery.Rows[0].As <float>("scale"); MinLife = MySQLQuery.Rows[0].As <int>("MinLevelHealth"); MaxLife = MySQLQuery.Rows[0].As <int>("MaxLevelHealth"); MinMana = MySQLQuery.Rows[0].As <int>("MinLevelMana"); MaxMana = MySQLQuery.Rows[0].As <int>("MaxLevelMana"); ManaType = 0; Faction = MySQLQuery.Rows[0].As <short>("factionAlliance"); Elite = MySQLQuery.Rows[0].As <byte>("rank"); Damage.Maximum = MySQLQuery.Rows[0].As <float>("MaxMeleeDmg"); RangedDamage.Maximum = MySQLQuery.Rows[0].As <float>("MaxRangedDmg"); Damage.Minimum = MySQLQuery.Rows[0].As <float>("MinMeleeDmg"); RangedDamage.Minimum = MySQLQuery.Rows[0].As <float>("MinRangedDmg"); AttackPower = MySQLQuery.Rows[0].As <int>("MeleeAttackPower"); RangedAttackPower = MySQLQuery.Rows[0].As <int>("RangedAttackPower"); WalkSpeed = MySQLQuery.Rows[0].As <float>("SpeedWalk"); RunSpeed = MySQLQuery.Rows[0].As <float>("SpeedRun"); BaseAttackTime = MySQLQuery.Rows[0].As <short>("MeleeBaseAttackTime"); BaseRangedAttackTime = MySQLQuery.Rows[0].As <short>("RangedBaseAttackTime"); cNpcFlags = MySQLQuery.Rows[0].As <int>("NpcFlags"); DynFlags = MySQLQuery.Rows[0].As <int>("DynamicFlags"); cFlags = MySQLQuery.Rows[0].As <int>("UnitFlags"); TypeFlags = MySQLQuery.Rows[0].As <uint>("CreatureTypeFlags"); CreatureType = MySQLQuery.Rows[0].As <byte>("CreatureType"); CreatureFamily = MySQLQuery.Rows[0].As <byte>("Family"); LevelMin = MySQLQuery.Rows[0].As <byte>("MinLevel"); LevelMax = MySQLQuery.Rows[0].As <byte>("MaxLevel"); TrainerType = MySQLQuery.Rows[0].As <int>("TrainerType"); TrainerSpell = MySQLQuery.Rows[0].As <int>("TrainerSpell"); Classe = MySQLQuery.Rows[0].As <byte>("TrainerClass"); Race = MySQLQuery.Rows[0].As <byte>("TrainerRace"); Leader = MySQLQuery.Rows[0].As <byte>("RacialLeader"); if (!Information.IsDBNull(RuntimeHelpers.GetObjectValue(MySQLQuery.Rows[0]["spell1"]))) { Spells[0] = MySQLQuery.Rows[0].As <int>("spell1"); } else { Spells[0] = 0; } if (!Information.IsDBNull(RuntimeHelpers.GetObjectValue(MySQLQuery.Rows[0]["spell2"]))) { Spells[1] = MySQLQuery.Rows[0].As <int>("spell2"); } else { Spells[1] = 0; } if (!Information.IsDBNull(RuntimeHelpers.GetObjectValue(MySQLQuery.Rows[0]["spell3"]))) { Spells[2] = MySQLQuery.Rows[0].As <int>("spell3"); } else { Spells[2] = 0; } if (!Information.IsDBNull(RuntimeHelpers.GetObjectValue(MySQLQuery.Rows[0]["spell4"]))) { Spells[3] = MySQLQuery.Rows[0].As <int>("spell4"); } else { Spells[3] = 0; } PetSpellDataID = MySQLQuery.Rows[0].As <int>("PetSpellDataId"); LootID = MySQLQuery.Rows[0].As <int>("LootId"); SkinLootID = MySQLQuery.Rows[0].As <int>("SkinningLootId"); PocketLootID = MySQLQuery.Rows[0].As <int>("PickpocketLootId"); MinGold = MySQLQuery.Rows[0].As <uint>("MinLootGold"); MaxGold = MySQLQuery.Rows[0].As <uint>("MaxLootGold"); Resistances[0] = MySQLQuery.Rows[0].As <int>("Armor"); Resistances[1] = MySQLQuery.Rows[0].As <int>("ResistanceHoly"); Resistances[2] = MySQLQuery.Rows[0].As <int>("ResistanceFire"); Resistances[3] = MySQLQuery.Rows[0].As <int>("ResistanceNature"); Resistances[4] = MySQLQuery.Rows[0].As <int>("ResistanceFrost"); Resistances[5] = MySQLQuery.Rows[0].As <int>("ResistanceShadow"); Resistances[6] = MySQLQuery.Rows[0].As <int>("ResistanceArcane"); EquipmentID = MySQLQuery.Rows[0].As <int>("EquipmentTemplateId"); MechanicImmune = MySQLQuery.Rows[0].As <uint>("SchoolImmuneMask"); if (File.Exists("scripts\\gossip\\" + WorldServiceLocator._Functions.FixName(Name) + ".vb")) { ScriptedObject tmpScript = new ScriptedObject("scripts\\gossip\\" + WorldServiceLocator._Functions.FixName(Name) + ".vb", "", InMemory: true); TalkScript = (TBaseTalk)tmpScript.InvokeConstructor("TalkScript"); tmpScript.Dispose(); } else if (((uint)cNpcFlags & 0x10u) != 0) { TalkScript = new WS_NPCs.TDefaultTalk(); } else if (((uint)cNpcFlags & 0x40u) != 0) { TalkScript = new WS_GuardGossip.TGuardTalk(); } else if (cNpcFlags == 0) { TalkScript = null; } else if (cNpcFlags == 1) { TalkScript = new WS_NPCs.TDefaultTalk(); } else { TalkScript = new WS_NPCs.TDefaultTalk(); } }