Example #1
0
 public void GameFlag(ScriptThread thread)
 {
     string key = thread.GetStringParameter(0).ToLower();
     if (!Fusion.GlobalInstance.GameFlags.Contains(key))
         return;
     thread.SetReturnValue((string)Fusion.GlobalInstance.GameFlags[key]);
 }
Example #2
0
        public void CenterEntityOn(ScriptThread thread)
        {
            EntityNode entity = ((NativeObject)thread.GetObjectParameter(0)).Object as EntityNode;
            EntityNode target = ((NativeObject)thread.GetObjectParameter(1)).Object as EntityNode;
            if (entity == null || target == null)
            {
                DebugLogger.WriteLog((thread.Process.Url != null && thread.Process.Url != "" ? thread.Process.Url : "A script") + " called CenterEntityOn with an invalid object.", LogAlertLevel.Error);
                return;
            }

            // Work out the central points.
            Transformation entityTransform = entity.CalculateTransformation();
            Transformation targetTransform = target.CalculateTransformation();

            // If its a camera then we need to invert the coordinates as it uses
            // slightly different ones from normal entities.
            if (entity as CameraNode != null)
            {
                entityTransform.X = -entityTransform.X;
                entityTransform.Y = -entityTransform.Y;
            }
            if (target as CameraNode != null)
            {
                targetTransform.X = -targetTransform.X;
                targetTransform.Y = -targetTransform.Y;
            }

            float targetEntityTransformCenterX = targetTransform.X + ((target.BoundingRectangle.Width / 2) * targetTransform.ScaleX);
            float targetEntityTransformCenterY = targetTransform.Y + ((target.BoundingRectangle.Height / 2) * targetTransform.ScaleY);
            entity.Position(targetEntityTransformCenterX - ((entity.BoundingRectangle.Width / 2) * entityTransform.ScaleX), targetEntityTransformCenterY - ((entity.BoundingRectangle.Height / 2) * entityTransform.ScaleY), entity.Transformation.Z);
        }
Example #3
0
        public void CommandLineValue(ScriptThread thread)
        {
            string commandLine = thread.GetStringParameter(0);
            int valueIndex = thread.GetIntegerParameter(1);

            foreach (string arg in Engine.GlobalInstance.CommandLineArguments)
            {
                string[] value = new string[0];
                string command = arg;
                int colonIndex = arg.IndexOf(':');

                // Seperate values and command if a colon exists.
                if (colonIndex >= 0)
                {
                    value = new string[1];
                    value[0] = arg.Substring(colonIndex + 1, arg.Length - colonIndex - 1);
                    if (value[0].IndexOf(",") >= 0) value = value[0].Split(new char[1] { ',' });
                    command = arg.Substring(0, colonIndex);
                }

                if (command.ToLower() == commandLine.ToLower())
                {
                    if (valueIndex < 0 || valueIndex >= value.Length)
                    {
                        DebugLogger.WriteLog((thread.Process.Url != null && thread.Process.Url != "" ? thread.Process.Url : "A script") + " called CommandLineValue with an invalid value index.", LogAlertLevel.Error);
                        return;
                    }
                    thread.SetReturnValue(value[valueIndex]);
                    return;
                }
            }

            DebugLogger.WriteLog((thread.Process.Url != null && thread.Process.Url != "" ? thread.Process.Url : "A script") + " called CommandLineValue with a non-existant command line.", LogAlertLevel.Error);
        }
Example #4
0
        public void CommandLineExists(ScriptThread thread)
        {
            string commandLine = thread.GetStringParameter(0);

            foreach (string arg in Engine.GlobalInstance.CommandLineArguments)
            {
                string[] value = new string[0];
                string command = arg;
                int colonIndex = arg.IndexOf(':');

                // Seperate values and command if a colon exists.
                if (colonIndex >= 0)
                {
                    value = new string[1];
                    value[0] = arg.Substring(colonIndex + 1, arg.Length - colonIndex - 1);
                    if (value[0].IndexOf(",") >= 0) value = value[0].Split(new char[1] { ',' });
                    command = arg.Substring(0, colonIndex);
                }

                if (command.ToLower() == commandLine.ToLower())
                {
                    thread.SetReturnValue(true);
                    return;
                }
            }

            thread.SetReturnValue(false);
        }
 public void DistanceToPoint(ScriptThread thread)
 {
     double vectorX = thread.GetDoubleParameter(0) - thread.GetDoubleParameter(2);
     double vectorY = thread.GetDoubleParameter(1) - thread.GetDoubleParameter(3);
     double distance = Math.Sqrt(vectorX * vectorX + vectorY * vectorY);
     thread.SetReturnValue(distance);
 }
Example #6
0
 public void CharacterCount(ScriptThread thread)
 {
     string haystack = thread.GetStringParameter(0);
     string needle = thread.GetStringParameter(1);
     int count = 0;
     for (int i = 0; i < haystack.Length; i++)
         if (haystack[i] == needle[0]) count++;
     thread.SetReturnValue(count);
 }
Example #7
0
 public void SeekStream(ScriptThread thread)
 {
     ScriptStream stream = ((NativeObject)thread.GetObjectParameter(0)).Object as ScriptStream;
     if (stream == null)
     {
         DebugLogger.WriteLog((thread.Process.Url != null && thread.Process.Url != "" ? thread.Process.Url : "A script") + " called SeekStream with an invalid object.", LogAlertLevel.Error);
         return;
     }
     stream.Stream.Position = thread.GetIntegerParameter(1);
 }
Example #8
0
 public void OpenStream(ScriptThread thread)
 {
     Stream stream = StreamFactory.RequestStream(thread.GetStringParameter(0), (StreamMode)thread.GetIntegerParameter(1));
     if (stream == null)
     {
         DebugLogger.WriteLog((thread.Process.Url != null && thread.Process.Url != "" ? thread.Process.Url : "A script") + " called OpenStream with an unreachable url.", LogAlertLevel.Error);
         return;
     }
     thread.SetReturnValue(new StreamScriptObject(new ScriptStream(stream)));
 }
 public void ExecuteFile(ScriptThread thread)
 {
     Process process = new Process();
     process.StartInfo.FileName = thread.GetStringParameter(0);
     process.StartInfo.Arguments = thread.GetStringParameter(1);
     process.StartInfo.Verb = "Open";
     process.StartInfo.WindowStyle = ProcessWindowStyle.Normal;
     process.Start();
     if (thread.GetBooleanParameter(2) == true) process.WaitForExit();
 }
Example #10
0
 public void ChannelLooping(ScriptThread thread)
 {
     ISampleBuffer sound = ((NativeObject)thread.GetObjectParameter(0)).Object as ISampleBuffer;
     if (sound == null)
     {
         DebugLogger.WriteLog((thread.Process.Url != null && thread.Process.Url != "" ? thread.Process.Url : "A script") + " called ChannelLooping with an invalid object.", LogAlertLevel.Error);
         return;
     }
     thread.SetReturnValue(sound.Looping);
 }
Example #11
0
 public void CameraClearColor(ScriptThread thread)
 {
     CameraNode entity = ((NativeObject)thread.GetObjectParameter(0)).Object as CameraNode;
     if (entity == null)
     {
         DebugLogger.WriteLog((thread.Process.Url != null && thread.Process.Url != "" ? thread.Process.Url : "A script") + " called CameraClearColor with an invalid object.", LogAlertLevel.Error);
         return;
     }
     thread.SetReturnValue(entity.ClearColor);
 }
Example #12
0
 public void ActivateCamera(ScriptThread thread)
 {
     CameraNode entity = ((NativeObject)thread.GetObjectParameter(0)).Object as CameraNode;
     if (entity == null)
     {
         DebugLogger.WriteLog((thread.Process.Url != null && thread.Process.Url != "" ? thread.Process.Url : "A script") + " called AttachCameraToSceneGraph with an invalid object.", LogAlertLevel.Error);
         return;
     }
     Engine.GlobalInstance.Map.SceneGraph.AttachCamera(entity);
 }
Example #13
0
 public void ActivateProcess(ScriptThread thread)
 {
     Runtime.Processes.Process process = ((NativeObject)thread.GetObjectParameter(0)).Object as Runtime.Processes.Process;
     if (process == null)
     {
         DebugLogger.WriteLog((thread.Process.Url != null && thread.Process.Url != "" ? thread.Process.Url : "A script") + " called ActivateProcess with an invalid object.", LogAlertLevel.Error);
         return;
     }
     ProcessManager.AttachProcess(process);
 }
Example #14
0
 public void StopThread(ScriptThread thread)
 {
     ScriptThread actionThread = ((NativeObject)thread.GetObjectParameter(0)).Object as ScriptThread;
     if (actionThread == null)
     {
         DebugLogger.WriteLog((thread.Process.Url != null && thread.Process.Url != "" ? thread.Process.Url : "A script") + " called StopThread with an invalid object.", LogAlertLevel.Error);
         return;
     }
     actionThread.Stop();
 }
Example #15
0
 public void CreateAnimationProcessB(ScriptThread thread)
 {
     EntityNode entity = ((NativeObject)thread.GetObjectParameter(0)).Object as EntityNode;
     if (entity == null)
     {
         DebugLogger.WriteLog((thread.Process.Url != null && thread.Process.Url != "" ? thread.Process.Url : "A script") + " called CreateAnimationProcess with an invalid object.", LogAlertLevel.Error);
         return;
     }
     thread.SetReturnValue(new ProcessScriptObject(new AnimationProcess(entity, (AnimationMode)thread.GetIntegerParameter(1), thread.GetIntegerParameter(2), thread.GetIntegerParameter(3), thread.GetIntegerParameter(4))));
 }
Example #16
0
 public void InvokeThreadFunction(ScriptThread thread)
 {
     ScriptThread actionThread = ((NativeObject)thread.GetObjectParameter(0)).Object as ScriptThread;
     if (actionThread == null)
     {
         DebugLogger.WriteLog((thread.Process.Url != null && thread.Process.Url != "" ? thread.Process.Url : "A script") + " called InvokeThreadFunction with an invalid object.", LogAlertLevel.Error);
         return;
     }
     actionThread.InvokeFunction(thread.GetStringParameter(1), thread.GetBooleanParameter(2), thread.GetBooleanParameter(3), false);
 }
Example #17
0
        public void Implode(ScriptThread thread)
        {
            int arrayMemoryIndex = thread.GetArrayParameter(0);
            int arrayLength = thread.GetArrayLength(arrayMemoryIndex);
            string implodedString = "";

            for (int i = 0; i < arrayLength; i++)
                implodedString += thread.GetStringArrayElement(arrayMemoryIndex, i);

            thread.SetReturnValue(implodedString);
        }
Example #18
0
        public void DisposeOfMap(ScriptThread thread)
        {
            ArrayList list = Engine.GlobalInstance.Map.SceneGraph.EnumerateNodes();
            for (int i = 0; i < list.Count; i++)
            {
                ((SceneNode)list[i]).ClearChildren();
                ((SceneNode)list[i]).Dispose();
            }

            Engine.GlobalInstance.Map.SceneGraph.RootNode = new SceneNode("Root Node");
            BinaryPhoenix.Fusion.Engine.Entitys.Tileset.TilesetPool.Clear();
        }
Example #19
0
        public void Explode(ScriptThread thread)
        {
            string explodee = thread.GetStringParameter(0);
            char seperator = thread.GetStringParameter(1)[0];
            string[] exploded = explodee.Split(new char[] { seperator });

            int arrayMemoryIndex = thread.AllocateArray(DataType.String, exploded.Length);
            for (int i = 0; i < exploded.Length; i++)
                thread.SetArrayElement(arrayMemoryIndex, i, exploded[i]);

            thread.SetReturnValueArray(arrayMemoryIndex);
        }
Example #20
0
 public void GameFlagValueAtIndex(ScriptThread thread)
 {
     int index = thread.GetIntegerParameter(0);
     int currentIndex = 0;
     foreach (string value in Fusion.GlobalInstance.GameFlags.Values)
     {
         if (index == currentIndex)
         {
             thread.SetReturnValue(value);
             return;
         }
         currentIndex++;
     }
 }
Example #21
0
 public void CreateAnimationProcessC(ScriptThread thread)
 {
     EntityNode entity = ((NativeObject)thread.GetObjectParameter(0)).Object as EntityNode;
     int memoryIndex = thread.GetArrayParameter(3);
     if (entity == null || memoryIndex == 0)
     {
         DebugLogger.WriteLog((thread.Process.Url != null && thread.Process.Url != "" ? thread.Process.Url : "A script") + " called CreateAnimationProcess with an invalid object.", LogAlertLevel.Error);
         return;
     }
     int arrayLength = thread.GetArrayLength(memoryIndex);
     int[] frames = new int[arrayLength];
     for (int i = 0; i < arrayLength; i++)
         frames[i] = thread.GetIntArrayElement(memoryIndex, i);
     thread.SetReturnValue(new ProcessScriptObject(new AnimationProcess(entity, (AnimationMode)thread.GetIntegerParameter(1), thread.GetIntegerParameter(2), frames, thread.GetIntegerParameter(4))));
 }
Example #22
0
 public void BindKey(ScriptThread thread)
 {
     InputManager.BindKey(thread.GetStringParameter(0),(KeyCodes)thread.GetIntegerParameter(1));
 }
Example #23
0
 public void BindedKeyReleased(ScriptThread thread)
 {
     thread.SetReturnValue(InputManager.BindedKeyReleased(thread.GetStringParameter(0)));
 }
Example #24
0
 public void UnbindKey(ScriptThread thread)
 {
     InputManager.UnbindKey(thread.GetStringParameter(0));
 }
Example #25
0
 public void MouseScroll(ScriptThread thread)
 {
     thread.SetReturnValue(InputManager.MouseScroll);
 }
Example #26
0
 public void MouseDesktopY(ScriptThread thread)
 {
     thread.SetReturnValue(InputManager.MouseY);
 }
 public void LoadLanguagePack(ScriptThread thread)
 {
     LanguageManager.LoadLanguagePack(thread.GetStringParameter(0), thread.GetStringParameter(1));
 }
Example #28
0
 public void KeyReleased(ScriptThread thread)
 {
     thread.SetReturnValue(InputManager.KeyReleased((KeyCodes)thread.GetIntegerParameter(0)));
 }
Example #29
0
 public void MouseDeltaX(ScriptThread thread)
 {
     thread.SetReturnValue(InputManager.MouseDeltaX);
 }
 public void LanguagePackName(ScriptThread thread)
 {
     thread.SetReturnValue(LanguageManager.Name);
 }