Beispiel #1
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);
        }
Beispiel #2
0
        public void CommandLineValueCount(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(value.Length);
                    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);
        }
Beispiel #3
0
        public void ExtractBlue(ScriptThread thread)
        {
            int r = 0, g = 0, b = 0, a = 0;

            ColorMethods.SplitColor(ColorFormats.A8R8G8B8, thread.GetIntegerParameter(0), out r, out g, out b, out a);
            thread.SetReturnValue(b);
        }
Beispiel #4
0
        public void BFCodeLength(ScriptThread thread)
        {
            string bfCode        = thread.GetStringParameter(0);
            int    currentLength = 0;

            if (bfCode == "" || bfCode == null)
            {
                return;
            }

            for (int currentPosition = 0; currentPosition < bfCode.Length; currentPosition++)
            {
                char currentCharacter = bfCode[currentPosition];
                if (currentCharacter == '[')
                {
                    // Skip to closing tag.
                    currentPosition = bfCode.IndexOf(']', currentPosition);
                    if (currentPosition == -1)
                    {
                        continue;
                    }
                }
                else
                {
                    currentLength++;
                }
            }

            thread.SetReturnValue(currentLength);
        }
        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);
        }
 public void ConnectToServer(ScriptThread thread)
 {
     Networking.NetworkManager.ServerIP = thread.GetStringParameter(0);
     if (thread.GetIntegerParameter(1) != -1)
     {
         Networking.NetworkManager.Port = thread.GetIntegerParameter(1);
     }
     thread.SetReturnValue(Networking.NetworkManager.Start());
 }
Beispiel #7
0
        public void NodeAtPoint(ScriptThread thread)
        {
            CollisionPolygon polygon = CollisionManager.PolygonAtPoint((int)thread.GetFloatParameter(0), (int)thread.GetFloatParameter(1));

            if (polygon == null || polygon.MetaData == null)
            {
                return;
            }
            thread.SetReturnValue(new SceneNodeScriptObject(polygon.MetaData as SceneNode));
        }
Beispiel #8
0
 public void IsProcessFinished(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 IsProcessFinished with an invalid object.", LogAlertLevel.Error);
         return;
     }
     thread.SetReturnValue(process.IsFinished);
 }
Beispiel #9
0
 public void CreateChannelFadeProcess(ScriptThread thread)
 {
     Audio.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 CreateChannelFadeProcess with an invalid object.", LogAlertLevel.Error);
         return;
     }
     thread.SetReturnValue(new ProcessScriptObject(new ChannelFadeProcess(sound, thread.GetFloatParameter(1), thread.GetFloatParameter(2), thread.GetIntegerParameter(3))));
 }
Beispiel #10
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]);
        }
Beispiel #11
0
        public void ImageOriginY(ScriptThread thread)
        {
            Image image = ((NativeObject)thread.GetObjectParameter(0)).Object as Image;

            if (image == null)
            {
                DebugLogger.WriteLog((thread.Process.Url != null && thread.Process.Url != "" ? thread.Process.Url : "A script") + " called ImageOriginY with an invalid object.", LogAlertLevel.Error);
                return;
            }
            thread.SetReturnValue(image.Origin.Y);
        }
Beispiel #12
0
        public void PacketID(ScriptThread thread)
        {
            NetworkPacket packet = ((NativeObject)thread.GetObjectParameter(0)).Object as NetworkPacket;

            if (packet == null)
            {
                DebugLogger.WriteLog((thread.Process.Url != null && thread.Process.Url != "" ? thread.Process.Url : "A script") + " called PacketID with an invalid object.", LogAlertLevel.Error);
                return;
            }
            thread.SetReturnValue(packet.ID);
        }
Beispiel #13
0
        public void PlaySound(ScriptThread thread)
        {
            Sound sound = ((NativeObject)thread.GetObjectParameter(0)).Object as Sound;

            if (sound == null)
            {
                DebugLogger.WriteLog((thread.Process.Url != null && thread.Process.Url != "" ? thread.Process.Url : "A script") + " called PlaySound with an invalid object.", LogAlertLevel.Error);
                return;
            }
            thread.SetReturnValue(new ChannelScriptObject(sound.Play()));
        }
Beispiel #14
0
        public void ChannelOuterRadius(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 ChannelOuterRadius with an invalid object.", LogAlertLevel.Error);
                return;
            }
            thread.SetReturnValue(sound.OuterRadius);
        }
Beispiel #15
0
        public void UniqueEntityFlag(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 UniqueEntityFlag with an invalid object.", LogAlertLevel.Error);
                return;
            }
            thread.SetReturnValue(("quest:maps:[" + Fusion.GlobalInstance.Map.URL + "]:Entity" + entity.UniqueID).ToLower());
        }
Beispiel #16
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))));
        }
Beispiel #17
0
        public void CreateDestroyProcess(ScriptThread thread)
        {
            SceneNode entity = ((NativeObject)thread.GetObjectParameter(0)).Object as SceneNode;

            if (entity == null)
            {
                DebugLogger.WriteLog((thread.Process.Url != null && thread.Process.Url != "" ? thread.Process.Url : "A script") + " called CreateDestroyProcess with an invalid object.", LogAlertLevel.Error);
                return;
            }
            thread.SetReturnValue(new ProcessScriptObject(new EntityDestroyProcess(entity)));
        }
Beispiel #18
0
        public void CreateBoundryProcessA(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 CreateBoundryProcess with an invalid object.", LogAlertLevel.Error);
                return;
            }
            thread.SetReturnValue(new ProcessScriptObject(new EntityBoundryProcess(entity, new RectangleF(thread.GetFloatParameter(1), thread.GetFloatParameter(2), thread.GetFloatParameter(3), thread.GetFloatParameter(4)))));
        }
Beispiel #19
0
        public void StreamReadDouble(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 StreamReadDouble with an invalid object.", LogAlertLevel.Error);
                return;
            }
            thread.SetReturnValue(stream.Reader.ReadDouble());
        }
Beispiel #20
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)));
        }
Beispiel #21
0
        public void CreatePathFollowProcess(ScriptThread thread)
        {
            PathMarkerNode node1 = ((NativeObject)thread.GetObjectParameter(0)).Object as PathMarkerNode;
            EntityNode     node2 = ((NativeObject)thread.GetObjectParameter(1)).Object as EntityNode;

            if (node1 == null || node2 == null)
            {
                DebugLogger.WriteLog((thread.Process.Url != null && thread.Process.Url != "" ? thread.Process.Url : "A script") + " called CreatePathFollowProcess with an invalid object.", LogAlertLevel.Error);
                return;
            }
            thread.SetReturnValue(new ProcessScriptObject(new PathFollowProcess(node1, node2)));
        }
Beispiel #22
0
        public void CreateMoveToProcessB(ScriptThread thread)
        {
            EntityNode entity     = ((NativeObject)thread.GetObjectParameter(0)).Object as EntityNode;
            EntityNode moveEntity = ((NativeObject)thread.GetObjectParameter(3)).Object as EntityNode;

            if (entity == null || moveEntity == null)
            {
                DebugLogger.WriteLog((thread.Process.Url != null && thread.Process.Url != "" ? thread.Process.Url : "A script") + " called CreateMoveToProcess with an invalid object.", LogAlertLevel.Error);
                return;
            }
            thread.SetReturnValue(new ProcessScriptObject(new EntityMoveToProcess(entity, moveEntity.Transformation.X + ((moveEntity.BoundingRectangle.Width / 2.0f) * moveEntity.Transformation.ScaleX), moveEntity.Transformation.Y + ((moveEntity.BoundingRectangle.Height / 2.0f) * moveEntity.Transformation.ScaleY), new StartFinishF(thread.GetFloatParameter(1), thread.GetFloatParameter(2)))));
        }
Beispiel #23
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);
        }
Beispiel #24
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++;
            }
        }
Beispiel #25
0
        public void StreamPeekLong(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 StreamPeekLong with an invalid object.", LogAlertLevel.Error);
                return;
            }
            long position = stream.Stream.Position;
            long value    = stream.Reader.ReadInt64();

            stream.Stream.Position = position;
            thread.SetReturnValue(value);
        }
Beispiel #26
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);
        }
Beispiel #27
0
        public void EngineVariable(ScriptThread thread)
        {
            string value = "";

            switch (thread.GetStringParameter(0).ToLower())
            {
            case "audiopath": value = Engine.GlobalInstance.AudioPath; break;

            case "basepath": value = Engine.GlobalInstance.BasePath; break;

            case "buildpath": value = Engine.GlobalInstance.BuildPath; break;

            case "configpath": value = Engine.GlobalInstance.ConfigPath; break;

            case "enginepath": value = Engine.GlobalInstance.EnginePath; break;

            case "fontpath": value = Engine.GlobalInstance.FontPath; break;

            case "gamename": value = Engine.GlobalInstance.GameName; break;

            case "gamepath": value = Engine.GlobalInstance.GamePath; break;

            case "graphicpath": value = Engine.GlobalInstance.GraphicPath; break;

            case "languagepath": value = Engine.GlobalInstance.LanguagePath; break;

            case "mappath": value = Engine.GlobalInstance.MapPath; break;

            case "mediapath": value = Engine.GlobalInstance.MediaPath; break;

            case "objectpath": value = Engine.GlobalInstance.ObjectPath; break;

            case "pluginpath": value = Engine.GlobalInstance.PluginPath; break;

            case "savepath": value = Engine.GlobalInstance.SavePath; break;

            case "scriptlibrarypath": value = Engine.GlobalInstance.ScriptLibraryPath; break;

            case "scriptpath": value = Engine.GlobalInstance.ScriptPath; break;

            case "tilesetpath": value = Engine.GlobalInstance.TilesetPath; break;

            case "effectpath": value = Engine.GlobalInstance.EffectPath; break;

            case "shaderpath": value = Engine.GlobalInstance.ShaderPath; break;
            }
            thread.SetReturnValue(value);
        }
Beispiel #28
0
        public void CreateAnimationProcessD(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)));
        }
Beispiel #29
0
        public void BFCodeSubString(ScriptThread thread)
        {
            string bfCode        = thread.GetStringParameter(0);
            int    start         = thread.GetIntegerParameter(1);
            int    length        = thread.GetIntegerParameter(2);
            string finished      = "";
            int    currentLength = 0;

            if (bfCode == "" || bfCode == null)
            {
                return;
            }

            for (int currentPosition = 0; currentPosition < bfCode.Length; currentPosition++)
            {
                char currentCharacter = bfCode[currentPosition];
                if (currentCharacter == '[')
                {
                    // Skip to closing tag.
                    int newPosition = bfCode.IndexOf(']', currentPosition);
                    if (newPosition == -1)
                    {
                        continue;
                    }

                    finished       += bfCode.Substring(currentPosition, (newPosition - currentPosition) + 1);
                    currentPosition = newPosition;
                }
                else if (currentPosition >= start)
                {
                    finished += currentCharacter;
                    currentLength++;
                }
                if (currentLength >= length)
                {
                    break;
                }
            }
            thread.SetReturnValue(finished);
        }
Beispiel #30
0
 public void CreateDelayProcess(ScriptThread thread)
 {
     thread.SetReturnValue(new ProcessScriptObject(new DelayProcess(thread.GetIntegerParameter(0))));
 }