예제 #1
0
        public void ServerCmdCycleCameraFlyType(coGameConnection client)
        {
            coCamera camera = client["camera"];

            if (camera.getMode() != Camera__CameraMotionMode.FlyMode)
            {
                return;
            }
            if (camera["newtonMode"].AsBool() == false)
            {
                camera["newtonMode"]     = true.AsString();
                camera["newtonRotation"] = false.AsString();
                camera.setVelocity(new Point3F("0 0 0"));
            }
            else if (camera["newtonRotation"].AsBool() == false)
            {
                camera["newtonMode"]     = true.AsString();
                camera["newtonRotation"] = true.AsString();
                camera.setAngularVelocity(new Point3F("0 0 0"));
            }
            else
            {
                camera["newtonMode"]     = false.AsString();
                camera["newtonRotation"] = false.AsString();
            }
            client.setControlObject(camera);
            console.Call("clientCmdSyncEditorGui");
        }
예제 #2
0
        public void ObserverObserverOnTrigger(coCameraData cameradata, coCamera camera, string trigger, bool state)
        {
            // state = 0 means that a trigger key was released
            if (state == false)
            {
                return;
            }

            // Default player triggers: 0=fire 1=altFire 2=jump
            coGameConnection client = camera.getControllingClient();
            string           mode   = camera["mode"];

            switch (mode)
            {
            case "Observer":
                // Do something interesting.
                break;

            case "Corpse":
                //Here is a winner... if you send the prepare too soon, it will crash out the client.  The GameConnectionOnControlObjectChange needs
                //time to run, and since it's still processing the first change (Switch to camera) this second change (Camera->player) will crash
                //out the client.
                //ServerCmdSetEditorCameraStandard(client);
                //ServerCmdDropCameraAtPlayer(client);
                camera.setFlyMode();
                client.setControlObject(camera);
                GameConnectiOnPreparePlayer(client);
                break;
            }
        }
예제 #3
0
        public void ServerCmdEditorCameraAutoFit(coGameConnection client, float radius)
        {
            coCamera camera = client["camera"];

            camera.autoFitRadius(radius);
            client.setControlObject(camera);
            console.Call("clientCmdSyncEditorGui");
        }
예제 #4
0
        public void ServerCmdSetEditorFlyCamera(coGameConnection client)
        {
            coCamera camera = client["camera"];

            camera.setFlyMode();
            client.setControlObject(camera);
            console.Call("clientCmdSyncEditorGui");
        }
예제 #5
0
        public void CameraSetMode(coCamera camera, string mode, string arg1 = "", string arg2 = "", string arg3 = "")
        {
            coSimDataBlock t = camera.getDataBlock();

            System.Console.WriteLine(t.getName());
            console.Call_Classname(camera.getDataBlock().AsString(), "setMode", new string[] { camera, mode, arg1, arg2, arg3 });
            // Punt this one over to our datablock
        }
예제 #6
0
        public void ServerCmdSetEditorCameraStandard(coGameConnection client)
        {
            coCamera camera = client["camera"];

            camera.setFlyMode();
            camera["newtonMode"]     = true.AsString();
            camera["newtonRotation"] = false.AsString();
            client.setControlObject(camera);
            console.Call("clientCmdSyncEditorGui");
        }
예제 #7
0
        public void ServerCmdSetEditorCameraNewtonDamped(coGameConnection client)
        {
            coCamera camera = client["camera"];

            camera.setFlyMode();
            camera["newtonMode"]     = true.AsString();
            camera["newtonRotation"] = true.AsString();
            camera.setVelocity(new Point3F("0 0 0"));
            client.setControlObject(camera);
            console.Call("clientCmdSyncEditorGui");
        }
예제 #8
0
        public void ServerCmdEditorOrbitCameraSelectChange(coGameConnection client, int size, Point3F center)
        {
            coCamera camera = client["camera"];

            if (size > 0)
            {
                camera.setValidEditOrbitPoint(true);
                camera.setEditOrbitPoint(center);
            }
            else
            {
                camera.setValidEditOrbitPoint(false);
            }
        }
예제 #9
0
        public void ObserverObserverSetMode(coCamera camera, string mode, coSceneObject arg1, string arg2, string arg3)
        {
            switch (mode)
            {
            case "Observer":
                camera.setFlyMode();
                break;

            case "Corpse":
                camera.setOrbitMode(arg1, arg1.getTransform(), (float)0.5, (float)4.5, (float)4.5, false, new Point3F(), false);
                camera["orbitObj"] = arg1;
                break;
            }
            camera["mode"] = mode;
        }
예제 #10
0
        public void GameConnectionSpawnCamera(coGameConnection client, string spawnPoint)
        {
            coCamera camera = client["camera"];

            //string camera = console.GetVarString(thisobj + ".camera");

            // Set the control object to the default camera
            if (!camera.isObject())
            {
                camera           = Util._spawnObject(Game__DefaultCameraClass, Game__DefaultCameraDataBlock);
                client["camera"] = camera;
            }

            // If we have a camera then set up some properties
            if (!camera.isObject())
            {
                return;
            }

            ((coSimSet)"MissionCleanup").pushToBack(camera);

            camera.scopeToClient(client);

            client.setControlObject(camera);

            if (spawnPoint == "")
            {
                return;
            }

            // Attempt to treat %spawnPoint as an object


            if (Util.getWordCount(spawnPoint) == 1 && console.isObject(spawnPoint))
            {
                camera.setTransform(((coMarker)spawnPoint).getTransform());
            }
            else
            {
                camera.setTransform(new TransformF(spawnPoint));
            }
        }
예제 #11
0
        public void DOFPostEffectautoFocus(coPostEffect thisobj)
        {
            try
            {
                coGameConnection serverconnection = "ServerConnection";
                coCamera         camera           = serverconnection.getCameraObject();

                uint mask = (uint)(WinterLeaf.Enums.SceneObjectTypesAsUint.StaticObjectType | WinterLeaf.Enums.SceneObjectTypesAsUint.TerrainObjectType);


                //string control = GameConnection.getCameraObject("ServerConnection"); //console.Call("ServerConnection", "getCameraObject");

                Point3F fvec  = camera.getEyeVector();
                Point3F start = camera.getEyePoint();

                //Point3F fvec = ShapeBase.getEyeVector(control); // console.Call(control, "getEyeVector");
                //Point3F start = ShapeBase.getEyePoint(control); // console.Call(control, "getEyePoint");

                Point3F end = Util.VectorAdd(start, Util.VectorScale(fvec, fGlobal["$Param::FarDist"]));

                string result = Util.containerRayCast(start, end, mask, camera, true);

                string hitPos  = Util.getWords(result, 1, 3);
                string focDist = sGlobal["$Param::FarDist"];
                if (hitPos != "")
                {
                    focDist = Util.VectorDist(new Point3F(hitPos), start).AsString();
                }

                thisobj["focalDist"] = focDist;
            }
            catch (Exception)
            {
                //Do nothing, this only gets hit when it can't find the serverconnection or the camera.
            }
        }
예제 #12
0
        public void GameConnectionOnDeath(coGameConnection client, coPlayer sourceobject, coGameConnection sourceclient, string damagetype, string damloc)
        {
            if (client.isObject())
            {
                if (client["ownedTurrets"] == "")
                {
                    client["ownedTurrets"] = new Torque_Class_Helper("SimSet").Create().AsString();
                }

                coSimSet simSet = client["ownedTurrets"];

                for (uint i = 0; i < simSet.getCount(); i++)
                {
                    ((coSimObject)simSet.getObject(i)).schedule("10", "delete");
                }
            }


            // clear the weaponHUD

            GameConnectionRefreshWeaponHud(client, 0, "", "", "", 0);

            coPlayer player = client["player"];

            // Clear out the name on the corpse
            player.setShapeName("");

            // Update the numerical Health HUD

            //PlayerUpdateHealth(player);


            // Switch the client over to the death cam and unhook the player object.
            coCamera camera = client["camera"];

            if (camera.isObject() && player.isObject())
            {
                camera.call("setMode", "Corpse", player, "", "");
                client.setControlObject(camera);
            }
            else
            {
                console.print("------------>Failed to Switch the client over to the death cam.");
            }

            client["player"] = "0";

            // Display damage appropriate kill message
            string sendMsgFunction = "sendMsgClientKilled_" + damagetype;

            if (!console.isFunction(sendMsgFunction))
            {
                sendMsgFunction = "sendMsgClientKilled_Default";
            }

            console.Call(sendMsgFunction, new string[] { "MsgClientKilled", client, sourceclient, damloc });
            // Dole out points and check for win
            if ((damagetype == "Suicide") || (sourceclient == client))
            {
                IncDeaths(client, "1", "1");
                IncScore(client, "-1", "0");
            }
            else
            {
                IncDeaths(client, "1", "0");
                IncScore(sourceclient, "1", "1");
                IncKills(sourceclient, "1", "0");
            }
        }
예제 #13
0
        public void PlayerSetDamageDirection(coPlayer player, coPlayer sourceObject, TransformF damagePos)
        {
            if (sourceObject.isObject())
            {
                damagePos = console.isField(sourceObject, "initialPosition") ? new TransformF(sourceObject["initialPosition"]) : sourceObject.getTransform();
            }


            TransformF dp  = damagePos;
            Point3F    wbc = player.getWorldBoxCenter();

            TransformF damagevec = dp - new TransformF(wbc);

            damagevec = damagevec.normalizeSafe();

            coGameConnection client = player["client"];

            if (!client.isObject())
            {
                return;
            }


            coCamera cameraobject = client.getCameraObject();

            TransformF inverseTransform = cameraobject.getInverseTransform();

            damagevec = math.MatrixMulVector(inverseTransform, damagevec.MPosition);

            float[]  components = new float[6];
            string[] directions = new string[6];
            directions[0] = "Left";
            directions[1] = "Right";
            directions[2] = "Bottom";
            directions[3] = "Front";
            directions[4] = "Bottom";
            directions[5] = "Top";

            components[0] = -damagevec.MPosition.x;
            components[1] = damagevec.MPosition.x;
            components[2] = -damagevec.MPosition.y;
            components[3] = damagevec.MPosition.y;
            components[4] = -damagevec.MPosition.z;
            components[5] = damagevec.MPosition.z;
            string damagedirection = string.Empty;
            float  max             = 0;

            for (int i = 0; i < 6; i++)
            {
                if (components[i] <= max)
                {
                    continue;
                }
                damagedirection = directions[i];
                max             = components[i];
            }

            if (console.isObject(client))
            {
                console.commandToClient(client, console.addTaggedString("setDamageDirection"), new[] { damagedirection });
            }
        }
예제 #14
0
 public void CameraOnAdd(coCamera camera, string obj)
 {
     CameraSetMode(camera, camera["mode"]);
 }