| 123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475 |
- //-----------------------------------------------------------------------------
- // Copyright (c) 2012 GarageGames, LLC
- //
- // Permission is hereby granted, free of charge, to any person obtaining a copy
- // of this software and associated documentation files (the "Software"), to
- // deal in the Software without restriction, including without limitation the
- // rights to use, copy, modify, merge, publish, distribute, sublicense, and/or
- // sell copies of the Software, and to permit persons to whom the Software is
- // furnished to do so, subject to the following conditions:
- //
- // The above copyright notice and this permission notice shall be included in
- // all copies or substantial portions of the Software.
- //
- // THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
- // IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
- // FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE
- // AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER
- // LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING
- // FROM, OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS
- // IN THE SOFTWARE.
- //-----------------------------------------------------------------------------
- // Global movement speed that affects all cameras. This should be moved
- // into the camera datablock.
- $Camera::movementSpeed = 40;
- function Observer::onTrigger(%this,%obj,%trigger,%state)
- {
- // state = 0 means that a trigger key was released
- if (%state == 0)
- return;
- // Default player triggers: 0=fire 1=altFire 2=jump
- %client = %obj.getControllingClient();
- switch$ (%obj.mode)
- {
- case "Observer":
- // Do something interesting.
- case "Corpse":
- // Fade out the corpse
- if (isObject(%obj.orbitObj))
- {
- cancelAll(%obj.orbitObj);
- %obj.orbitObj.schedule(0, "startFade", 1000, 0, true);
- %obj.orbitObj.schedule(1000, "delete");
- }
- // Viewing dead corpse, so we probably want to respawn.
- game.preparePlayer(%client);
- // Set the camera back into observer mode, since in
- // debug mode we like to switch to it.
- %this.setMode(%obj,"Observer");
- }
- }
- function Observer::setMode(%this,%obj,%mode,%arg1,%arg2,%arg3)
- {
- switch$ (%mode)
- {
- case "Observer":
- // Let the player fly around
- %obj.setFlyMode();
- case "Corpse":
- // Lock the camera down in orbit around the corpse,
- // which should be arg1
- %transform = %arg1.getTransform();
- %obj.setOrbitMode(%arg1, %transform, 0.5, 4.5, 4.5);
- %obj.orbitObj = %arg1;
- }
- %obj.mode = %mode;
- }
|