コード例 #1
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);
        }
コード例 #2
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();
 }
コード例 #3
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);
 }
コード例 #4
0
ファイル: IO.cs プロジェクト: HampsterEater/FusionGameEngine
 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);
 }
コード例 #5
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))));
 }
コード例 #6
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);
 }
コード例 #7
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);
 }
コード例 #8
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);
 }
コード例 #9
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);
 }
コード例 #10
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))));
 }
コード例 #11
0
 public void SetChannelVolume(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 SetChannelVolume with an invalid object.", LogAlertLevel.Error);
         return;
     }
     sound.Volume = thread.GetFloatParameter(1);
 }
コード例 #12
0
 public void ResumeChannel(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 ResumeChannel with an invalid object.", LogAlertLevel.Error);
         return;
     }
     sound.Paused = false;
 }
コード例 #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()));
 }
コード例 #14
0
 public void EntityCollisionBoxHeight(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 EntityCollisionBoxHeight with an invalid object.", LogAlertLevel.Error);
         return;
     }
     thread.SetReturnValue(entity.CollisionRectangle.Height);
 }
コード例 #15
0
ファイル: IO.cs プロジェクト: HampsterEater/FusionGameEngine
 public void StreamWriteA(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 StreamWrite with an invalid object.", LogAlertLevel.Error);
         return;
     }
     stream.Writer.Write(thread.GetBooleanParameter(1));
 }
コード例 #16
0
 public void EntityRenderZ(ScriptThread thread)
 {
     EntityNode entity = ((NativeObject)thread.GetObjectParameter(0)).Object as EntityNode;
     CameraNode camera = ((NativeObject)thread.GetObjectParameter(1)).Object as CameraNode;
     if (entity == null || camera == null)
     {
         DebugLogger.WriteLog((thread.Process.Url != null && thread.Process.Url != "" ? thread.Process.Url : "A script") + " called EntityRenderZ with an invalid object.", LogAlertLevel.Error);
         return;
     }
     Transformation transformation = entity.CalculateTransformation(camera);
     thread.SetReturnValue(transformation.Z);
 }
コード例 #17
0
 public void EntityHitTestB(ScriptThread thread)
 {
     EntityNode entitya = ((NativeObject)thread.GetObjectParameter(0)).Object as EntityNode;
     if (entitya == null)
     {
         DebugLogger.WriteLog((thread.Process.Url != null && thread.Process.Url != "" ? thread.Process.Url : "A script") + " called EntityHitTest with an invalid object.", LogAlertLevel.Error);
         return;
     }
     CollisionRectangle rect = new CollisionRectangle(new Transformation(thread.GetIntegerParameter(1), thread.GetIntegerParameter(2), 0, 0, 0, 0, 1, 1, 1), thread.GetIntegerParameter(3), thread.GetIntegerParameter(4));
     rect.Layers = entitya.CollisionPolygon.Layers;
     thread.SetReturnValue(entitya.CollisionPolygon.HitTest(rect));
 }
コード例 #18
0
 public void EntityHitTestA(ScriptThread thread)
 {
     EntityNode entitya = ((NativeObject)thread.GetObjectParameter(0)).Object as EntityNode;
     EntityNode entityb = ((NativeObject)thread.GetObjectParameter(1)).Object as EntityNode;
     if (entitya == null || entityb == null)
     {
         DebugLogger.WriteLog((thread.Process.Url != null && thread.Process.Url != "" ? thread.Process.Url : "A script") + " called EntityHitTest with an invalid object.", LogAlertLevel.Error);
         return;
     }
     thread.SetReturnValue(entitya.CollisionPolygon.HitTest(entityb.CollisionPolygon));
 }
コード例 #19
0
 public void EntityCollisionLayer(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 EntityCollisionLayers with an invalid object.", LogAlertLevel.Error);
         return;
     }
     if (entity.CollisionPolygon == null) return;
     int arrayIndex = thread.AllocateArray(DataType.Int, entity.CollisionPolygon.Layers.Length);
     for (int i = 0; i < entity.CollisionPolygon.Layers.Length; i++)
         thread.SetArrayElement(arrayIndex, i, entity.CollisionPolygon.Layers[i]);
     thread.SetReturnValueArray(arrayIndex);
 }
コード例 #20
0
ファイル: IO.cs プロジェクト: HampsterEater/FusionGameEngine
 public void StreamLength(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 StreamLength with an invalid object.", LogAlertLevel.Error);
         return;
     }
     thread.SetReturnValue(stream.Stream.Length);
 }
コード例 #21
0
ファイル: IO.cs プロジェクト: HampsterEater/FusionGameEngine
 public void StreamPeekString(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 StreamPeekString with an invalid object.", LogAlertLevel.Error);
         return;
     }
     long position = stream.Stream.Position;
     string value = stream.Reader.ReadString();
     stream.Stream.Position = position;
     thread.SetReturnValue(value);
 }
コード例 #22
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());
 }
コード例 #23
0
 public void EntityZ(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 EntityZ with an invalid object.", LogAlertLevel.Error);
         return;
     }
     thread.SetReturnValue(entity.Transformation.Z);
 }
コード例 #24
0
 public void EntityChildren(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 EntityChildren with an invalid object.", LogAlertLevel.Error);
         return;
     }
     if (entity.Children.Count > 0)
     {
         int memoryIndex = thread.AllocateArray(DataType.Object, entity.Children.Count);
         for (int i = 0; i < entity.Children.Count; i++)
         {
             thread.SetArrayElement(memoryIndex, i, new SceneNodeScriptObject((SceneNode)entity.Children[i]));
         }
         thread.SetReturnValueArray(memoryIndex);
     }
 }
コード例 #25
0
 public void SetPostProcessingShader(ScriptThread thread)
 {
     Shader shader = ((NativeObject)thread.GetObjectParameter(0)).Object as Shader;
     if (shader == null)
     {
         DebugLogger.WriteLog((thread.Process.Url != null && thread.Process.Url != "" ? thread.Process.Url : "A script") + " called SetPostProcessingShader with an invalid object.", LogAlertLevel.Error);
         return;
     }
     Fusion.GlobalInstance.Window.PostProcessingShader = shader;
 }
コード例 #26
0
        public void MoveEntityTowardsPoint(ScriptThread thread)
        {
            EntityNode entity = ((NativeObject)thread.GetObjectParameter(0)).Object as EntityNode;
            float x = thread.GetFloatParameter(1);
            float y = thread.GetFloatParameter(2);
            float speed = thread.GetFloatParameter(3);
            if (entity == null)
            {
                DebugLogger.WriteLog((thread.Process.Url != null && thread.Process.Url != "" ? thread.Process.Url : "A script") + " called MoveEntityTowardsPoint with an invalid object.", LogAlertLevel.Error);
                return;
            }

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

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

            // Are we at the correct place? If so why bother with the below code :P.
            if (entityTransform.X == x && entityTransform.Y == y)
                return;

            float entityTransformCenterX = entityTransform.X + ((entity.BoundingRectangle.Width / 2) * entityTransform.ScaleX);
            float entityTransformCenterY = entityTransform.Y + ((entity.BoundingRectangle.Height / 2) * entityTransform.ScaleY);
            float vectorX = entityTransformCenterX - x;
            float vectorY = entityTransformCenterY - y;
            float distance = (float)Math.Sqrt(vectorX * vectorX + vectorY * vectorY);
            vectorX /= distance;
            vectorY /= distance;

            if (float.IsNaN(vectorX * speed) || float.IsNaN(vectorY * speed)) return;

            // Work out vector towards entity.
            entity.Move(-(vectorX * speed),-(vectorY * speed), 0.0f);
        }
コード例 #27
0
 public void SetPacketID(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 SetPacketID with an invalid object.", LogAlertLevel.Error);
         return;
     }
     packet.ID = thread.GetIntegerParameter(0);
 }
コード例 #28
0
 public void RotateEntity(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 RotateEntity with an invalid object.", LogAlertLevel.Error);
         return;
     }
     entity.Rotate(thread.GetFloatParameter(1), thread.GetFloatParameter(2), thread.GetFloatParameter(3));
 }
コード例 #29
0
        public void ClosestSideOfEntity(ScriptThread thread)
        {
            EntityNode aEntity = ((NativeObject)thread.GetObjectParameter(0)).Object as EntityNode;
            EntityNode bEntity = ((NativeObject)thread.GetObjectParameter(1)).Object as EntityNode;
            if (aEntity == null || bEntity == null)
            {
                DebugLogger.WriteLog((thread.Process.Url != null && thread.Process.Url != "" ? thread.Process.Url : "A script") + " called ClosestSideOfEntity with an invalid object.", LogAlertLevel.Error);
                return;
            }

            float bWidth = bEntity.Width * bEntity.Transformation.ScaleX, bHeight = bEntity.Height * bEntity.Transformation.ScaleY;
            float bCenterX = bEntity.Transformation.X + (bWidth / 2.0f), bCenterY = bEntity.Transformation.Y + (bHeight / 2.0f);
            float aWidth = aEntity.Width * aEntity.Transformation.ScaleX, aHeight = aEntity.Height * aEntity.Transformation.ScaleY;
            float aCenterX = aEntity.Transformation.X + (aWidth / 2.0f), aCenterY = aEntity.Transformation.Y + (aHeight / 2.0f);
            float bVertexX = 0, bVertexY = 0;
            float aVertexX = 0, aVertexY = 0;

            if (aCenterX > bCenterX)
                if (aCenterY > bCenterY)
                {
                    // Were in the bottom-right corner of the rectangle.
                    bVertexX = bEntity.Transformation.X + bWidth;
                    bVertexY = bEntity.Transformation.Y + bHeight;
                    aVertexX = aEntity.Transformation.X;
                    aVertexY = aEntity.Transformation.Y;

                    float xDifference = aVertexX - bVertexX;
                    float yDifference = aVertexY - bVertexY;
                    if (Math.Abs(xDifference) > Math.Abs(yDifference))
                        thread.SetReturnValue(4);
                    else
                        thread.SetReturnValue(2);
                }
                else
                {
                    // Were in the top-right corner of the rectangle.
                    bVertexX = bEntity.Transformation.X + bWidth;
                    bVertexY = bEntity.Transformation.Y;
                    aVertexX = aEntity.Transformation.X;
                    aVertexY = aEntity.Transformation.Y + aHeight;

                    float xDifference = aVertexX - bVertexX;
                    float yDifference = aVertexY - bVertexY;
                    if (Math.Abs(xDifference) > Math.Abs(yDifference))
                        thread.SetReturnValue(3);
                    else
                        thread.SetReturnValue(2);
                }
            else
                if (aCenterY > bCenterY)
                {
                    // Were in the bottom-left corner of the rectangle.
                    bVertexX = bEntity.Transformation.X;
                    bVertexY = bEntity.Transformation.Y + bHeight;
                    aVertexX = aEntity.Transformation.X + aWidth;
                    aVertexY = aEntity.Transformation.Y;

                    float xDifference = aVertexX - bVertexX;
                    float yDifference = aVertexY - bVertexY;
                    if (Math.Abs(xDifference) > Math.Abs(yDifference))
                        thread.SetReturnValue(4);
                    else
                        thread.SetReturnValue(1);
                }
                else
                {
                    // Were in the top-left corner of the rectangle.
                    bVertexX = bEntity.Transformation.X;
                    bVertexY = bEntity.Transformation.Y;
                    aVertexX = aEntity.Transformation.X + aWidth;
                    aVertexY = aEntity.Transformation.Y + aHeight;

                    float xDifference = aVertexX - bVertexX;
                    float yDifference = aVertexY - bVertexY;
                    if (Math.Abs(xDifference) > Math.Abs(yDifference))
                        thread.SetReturnValue(3);
                    else
                        thread.SetReturnValue(1);
                }
        }
コード例 #30
0
 public void DestroyEntity(ScriptThread thread)
 {
     RuntimeObject obj = thread.GetObjectParameter(0);
     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 DestroyEntity with an invalid object.", LogAlertLevel.Error);
         return;
     }
     entity.Dispose();
 }