Adds some example components, game objects and the tools and scripts to utilize them.

This commit is contained in:
Areloch 2016-05-15 16:24:47 -05:00
parent 7bf49f0670
commit 6fe0b1789d
32 changed files with 1812 additions and 0 deletions

View file

@ -0,0 +1,7 @@
<ComponentAsset
AssetName="AnimationComponentAsset"
componentName=""
componentClass="AnimationComponent"
friendlyName="Animation"
componentType="Animation"
description="Allows a mesh component to be animated."/>

View file

@ -0,0 +1,7 @@
<ComponentAsset
AssetName="CameraOrbiterComponentAsset"
componentName=""
componentClass="CameraOrbiterComponent"
friendlyName="Camera Orbiter"
componentType="Game"
description="Acts as a boon arm for a camera component."/>

View file

@ -0,0 +1,7 @@
<ComponentAsset
AssetName="CollisionComponentAsset"
componentName=""
componentClass="CollisionComponent"
friendlyName="Collision"
componentType="Collision"
description="Enables an entity to collide with things."/>

View file

@ -0,0 +1,7 @@
<ComponentAsset
AssetName="CameraComponentAsset"
componentName=""
componentClass="CameraComponent"
friendlyName="Camera"
componentType="Game"
description="Allows the component owner to operate as a camera."/>

View file

@ -0,0 +1,198 @@
//-----------------------------------------------------------------------------
// 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.
//-----------------------------------------------------------------------------
function CameraComponent::onAdd(%this)
{
Parent::onBehaviorAdd(%this);
%this.addComponentField(clientOwner, "The client that views this camera", "int", "1", "");
%test = %this.clientOwner;
%barf = ClientGroup.getCount();
%clientID = %this.getClientID();
if(%clientID && !isObject(%clientID.camera))
{
%this.scopeToClient(%clientID);
%this.setDirty();
%clientID.setCameraObject(%this.owner);
%clientID.setControlCameraFov(%this.FOV);
%clientID.camera = %this.owner;
}
%res = $pref::Video::mode;
%derp = 0;
}
function CameraComponent::onRemove(%this)
{
%clientID = %this.getClientID();
if(%clientID)
%clientID.clearCameraObject();
}
function CameraComponent::onInspectorUpdate(%this)
{
//if(%this.clientOwner)
//%this.clientOwner.setCameraObject(%this.owner);
}
function CameraComponent::getClientID(%this)
{
return ClientGroup.getObject(%this.clientOwner-1);
}
function CameraComponent::isClientCamera(%this, %client)
{
%clientID = ClientGroup.getObject(%this.clientOwner-1);
if(%client.getID() == %clientID)
return true;
else
return false;
}
function CameraComponent::onClientConnect(%this, %client)
{
//if(%this.isClientCamera(%client) && !isObject(%client.camera))
//{
%this.scopeToClient(%client);
%this.setDirty();
%client.setCameraObject(%this.owner);
%client.setControlCameraFov(%this.FOV);
%client.camera = %this.owner;
//}
//else
//{
// echo("CONNECTED CLIENT IS NOT CAMERA OWNER!");
//}
}
function CameraComponent::onClientDisconnect(%this, %client)
{
Parent::onClientDisconnect(%this, %client);
if(isClientCamera(%client)){
%this.clearScopeToClient(%client);
%client.clearCameraObject();
}
}
//move to the editor later
GlobalActionMap.bind("keyboard", "alt c", "toggleEditorCam");
function switchCamera(%client, %newCamEntity)
{
if(!isObject(%client) || !isObject(%newCamEntity))
return error("SwitchCamera: No client or target camera!");
%cam = %newCamEntity.getComponent(CameraComponent);
if(!isObject(%cam))
return error("SwitchCamera: Target camera doesn't have a camera behavior!");
//TODO: Cleanup clientOwner for previous camera!
if(%cam.clientOwner == 0 || %cam.clientOwner $= "")
%cam.clientOwner = 0;
%cam.scopeToClient(%client);
%cam.setDirty();
%client.setCameraObject(%newCamEntity);
%client.setControlCameraFov(%cam.FOV);
%client.camera = %newCamEntity;
}
function buildEditorCamera()
{
if(isObject("EditorCamera"))
return EditorCamera;
%camObj = SGOManager.spawn("SpectatorObject", false);
%camObj.name = "EditorCamera";
%client = ClientGroup.getObject(0);
%camObj.getComponent(SpectatorControls).setupControls(%client);
MissionCleanup.add(%camObj);
return %camObj;
}
//TODO: Move this somewhere else!
function toggleEditorCam(%val)
{
if(!%val)
return;
%client = ClientGroup.getObject(0);
if(!isObject(%client.camera))
return error("ToggleEditorCam: no existing camera!");
%editorCam = buildEditorCamera();
//if this is our first switch, just go to the editor camera
if(%client.lastCam $= "" || %client.camera.getId() != %editorCam.getId())
{
if(%client.lastCam $= "")
{
//set up the position
%editorCam.position = %client.camera.position;
%editorCam.rotation = %client.camera.rotation;
}
%client.lastCam = %client.camera;
%client.lastController = %client.getControlObject();
switchCamera(%client, %editorCam);
switchControlObject(%client, %editorCam);
}
else
{
switchCamera(%client, %client.lastCam);
switchControlObject(%client, %client.lastController);
%client.lastCam = %editorCam;
%client.lastController = %editorCam;
}
}
function serverCmdSetClientAspectRatio(%client, %width, %height)
{
echo("Client: " @ %client SPC "changing screen res to: " @ %width SPC %height);
%client.screenExtent = %width SPC %height;
%cam = %client.getCameraObject();
if(!isObject(%cam))
return;
%cameraComp = %cam.getComponent(CameraComponent);
%cameraComp.ScreenAspect = %width SPC %height;
}

View file

@ -0,0 +1,7 @@
<ComponentAsset
AssetName="ControlObjectComponentAsset"
componentName="ControlObjectComponent"
componentClass="Component"
friendlyName="Control Object"
componentType="Game"
description="Allows the component owner to be controlled by a client."/>

View file

@ -0,0 +1,91 @@
//-----------------------------------------------------------------------------
// 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.
//-----------------------------------------------------------------------------
//registerComponent("ControlObjectComponent", "Component", "Control Object", "Game", false, "Allows the behavior owner to operate as a camera.");
function ControlObjectComponent::onAdd(%this)
{
Parent::onBehaviorAdd(%this);
%this.addComponentField(clientOwner, "The shape to use for rendering", "int", "1", "");
%clientID = %this.getClientID();
if(%clientID && !isObject(%clientID.getControlObject()))
%clientID.setControlObject(%this.owner);
}
function ControlObjectComponent::onRemove(%this)
{
%clientID = %this.getClientID();
if(%clientID)
%clientID.setControlObject(0);
}
function ControlObjectComponent::onClientConnect(%this, %client)
{
if(%this.isControlClient(%client) && !isObject(%client.getControlObject()))
%client.setControlObject(%this.owner);
}
function ControlObjectComponent::onClientDisconnect(%this, %client)
{
if(%this.isControlClient(%client))
%client.setControlObject(0);
}
function ControlObjectComponent::getClientID(%this)
{
return ClientGroup.getObject(%this.clientOwner-1);
}
function ControlObjectComponent::isControlClient(%this, %client)
{
%clientID = ClientGroup.getObject(%this.clientOwner-1);
if(%client.getID() == %clientID)
return true;
else
return false;
}
function ControlObjectComponent::onInspectorUpdate(%this, %field)
{
%clientID = %this.getClientID();
if(%clientID && !isObject(%clientID.getControlObject()))
%clientID.setControlObject(%this.owner);
}
function switchControlObject(%client, %newControlEntity)
{
if(!isObject(%client) || !isObject(%newControlEntity))
return error("SwitchControlObject: No client or target controller!");
%control = %newControlEntity.getComponent(ControlObjectComponent);
if(!isObject(%control))
return error("SwitchControlObject: Target controller has no conrol object behavior!");
%client.setControlObject(%newControlEntity);
}

View file

@ -0,0 +1,7 @@
<ComponentAsset
AssetName="ItemRotationComponentAsset"
componentName="ItemRotationComponent"
componentClass="Component"
friendlyName="Item Rotation"
componentType="Game"
description="Rotates the entity around an axis, like an item pickup."/>

View file

@ -0,0 +1,49 @@
//-----------------------------------------------------------------------------
// 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.
//-----------------------------------------------------------------------------
//registerComponent("ItemRotationComponent", "Component", "Item Rotation", "Game", false, "Rotates the entity around the z axis, like an item pickup.");
function ItemRotationComponent::onAdd(%this)
{
%this.addComponentField(rotationsPerMinute, "Number of rotations per minute", "float", "5", "");
%this.addComponentField(forward, "Rotate forward or backwards", "bool", "1", "");
%this.addComponentField(horizontal, "Rotate horizontal or verticle, true for horizontal", "bool", "1", "");
}
function ItemRotateBehavior::Update(%this)
{
%tickRate = 0.032;
//Rotations per second is calculated based on a standard update tick being 32ms. So we scale by the tick speed, then add that to our rotation to
//get a nice rotation speed.
if(%this.horizontal)
{
if(%this.forward)
%this.owner.rotation.z += ( ( 360 * %this.rotationsPerMinute ) / 60 ) * %tickRate;
else
%this.owner.rotation.z -= ( ( 360 * %this.rotationsPerMinute ) / 60 ) * %tickRate;
}
else
{
%this.owner.rotation.x += ( ( 360 * %this.rotationsPerMinute ) / 60 ) * %tickRate;
}
}

View file

@ -0,0 +1,7 @@
<ComponentAsset
AssetName="PlayerSpawnerComponentAsset"
componentName="PlayerSpawner"
componentClass="Component"
friendlyName="Player Spawner"
componentType="Game"
description="When a client connects, it spawns a player object for them and attaches them to it."/>

View file

@ -0,0 +1,70 @@
//-----------------------------------------------------------------------------
// 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.
//-----------------------------------------------------------------------------
//registerComponent("PlayerSpawner", "Component",
// "Player Spawner", "Game", false, "When a client connects, it spawns a player object for them and attaches them to it");
function PlayerSpawner::onAdd(%this)
{
%this.clientCount = 1;
%this.friendlyName = "Player Spawner";
%this.componentType = "Spawner";
%this.addComponentField("GameObjectName", "The name of the game object we spawn for the players", string, "PlayerObject");
}
function PlayerSpawner::onClientConnect(%this, %client)
{
%playerObj = SGOManager.spawn(%this.GameObjectName);
if(!isObject(%playerObj))
return;
%playerObj.position = %this.owner.position;
MissionCleanup.add(%playerObj);
for(%b = 0; %b < %playerObj.getComponentCount(); %b++)
{
%comp = %playerObj.getComponentByIndex(%b);
if(%comp.isMethod("onClientConnect"))
%comp.onClientConnect(%client);
}
switchControlObject(%client, %playerObj);
switchCamera(%client, %playerObj);
//%playerObj.getComponent(FPSControls).setupControls(%client);
%this.clientCount++;
}
function PlayerSpawner::onClientDisConnect(%this, %client)
{
}
function PlayerSpawner::getClientID(%this)
{
return ClientGroup.getObject(%this.clientOwner-1);
}

View file

@ -0,0 +1,7 @@
<ComponentAsset
AssetName="FPSControlsComponentAsset"
componentName="FPSControls"
componentClass="Component"
friendlyName="FPS Controls"
componentType="Input"
description="First Person Shooter-type controls."/>

View file

@ -0,0 +1,249 @@
//-----------------------------------------------------------------------------
// 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.
//-----------------------------------------------------------------------------
//registerComponent("FPSControls", "Component", "FPS Controls", "Input", false, "First Person Shooter-type controls");
function FPSControls::onAdd(%this)
{
Parent::onBehaviorAdd(%this);
//
%this.beginGroup("Keys");
%this.addComponentField(forwardKey, "Key to bind to vertical thrust", keybind, "keyboard w");
%this.addComponentField(backKey, "Key to bind to vertical thrust", keybind, "keyboard s");
%this.addComponentField(leftKey, "Key to bind to horizontal thrust", keybind, "keyboard a");
%this.addComponentField(rightKey, "Key to bind to horizontal thrust", keybind, "keyboard d");
%this.addComponentField(jump, "Key to bind to horizontal thrust", keybind, "keyboard space");
%this.endGroup();
%this.beginGroup("Mouse");
%this.addComponentField(pitchAxis, "Key to bind to horizontal thrust", keybind, "mouse yaxis");
%this.addComponentField(yawAxis, "Key to bind to horizontal thrust", keybind, "mouse xaxis");
%this.endGroup();
%this.addComponentField(moveSpeed, "Horizontal thrust force", float, 300.0);
%this.addComponentField(jumpStrength, "Vertical thrust force", float, 3.0);
//
%control = %this.owner.getComponent( ControlObjectComponent );
if(!%control)
return echo("SPECTATOR CONTROLS: No Control Object behavior!");
//%this.Physics = %this.owner.getComponent( PlayerPhysicsComponent );
//%this.Animation = %this.owner.getComponent( AnimationComponent );
//%this.Camera = %this.owner.getComponent( MountedCameraComponent );
//%this.Animation.playThread(0, "look");
%this.setupControls(%control.getClientID());
}
function FPSControls::onRemove(%this)
{
Parent::onBehaviorRemove(%this);
commandToClient(%control.clientOwnerID, 'removeInput', %this.forwardKey);
commandToClient(%control.clientOwnerID, 'removeInput', %this.backKey);
commandToClient(%control.clientOwnerID, 'removeInput', %this.leftKey);
commandToClient(%control.clientOwnerID, 'removeInput', %this.rightKey);
commandToClient(%control.clientOwnerID, 'removeInput', %this.pitchAxis);
commandToClient(%control.clientOwnerID, 'removeInput', %this.yawAxis);
}
function FPSControls::onBehaviorFieldUpdate(%this, %field)
{
%controller = %this.owner.getBehavior( ControlObjectBehavior );
commandToClient(%controller.clientOwnerID, 'updateInput', %this.getFieldValue(%field), %field);
}
function FPSControls::onClientConnect(%this, %client)
{
%this.setupControls(%client);
}
function FPSControls::setupControls(%this, %client)
{
%control = %this.owner.getComponent( ControlObjectComponent );
if(!%control.isControlClient(%client))
{
echo("FPS CONTROLS: Client Did Not Match");
return;
}
%inputCommand = "FPSControls";
%test = %this.forwardKey;
/*SetInput(%client, %this.forwardKey.x, %this.forwardKey.y, %inputCommand@"_forwardKey");
SetInput(%client, %this.backKey.x, %this.backKey.y, %inputCommand@"_backKey");
SetInput(%client, %this.leftKey.x, %this.leftKey.y, %inputCommand@"_leftKey");
SetInput(%client, %this.rightKey.x, %this.rightKey.y, %inputCommand@"_rightKey");
SetInput(%client, %this.jump.x, %this.jump.y, %inputCommand@"_jump");
SetInput(%client, %this.pitchAxis.x, %this.pitchAxis.y, %inputCommand@"_pitchAxis");
SetInput(%client, %this.yawAxis.x, %this.yawAxis.y, %inputCommand@"_yawAxis");*/
SetInput(%client, "keyboard", "w", %inputCommand@"_forwardKey");
SetInput(%client, "keyboard", "s", %inputCommand@"_backKey");
SetInput(%client, "keyboard", "a", %inputCommand@"_leftKey");
SetInput(%client, "keyboard", "d", %inputCommand@"_rightKey");
SetInput(%client, "keyboard", "space", %inputCommand@"_jump");
SetInput(%client, "mouse", "yaxis", %inputCommand@"_pitchAxis");
SetInput(%client, "mouse", "xaxis", %inputCommand@"_yawAxis");
SetInput(%client, "keyboard", "f", %inputCommand@"_flashlight");
}
function FPSControls::onMoveTrigger(%this, %triggerID)
{
//check if our jump trigger was pressed!
if(%triggerID == 2)
{
%this.owner.applyImpulse("0 0 0", "0 0 " @ %this.jumpStrength);
}
}
function FPSControls::Update(%this)
{
return;
%moveVector = %this.owner.getMoveVector();
%moveRotation = %this.owner.getMoveRotation();
%this.Physics.moveVector = "0 0 0";
if(%moveVector.x != 0)
{
%fv = VectorNormalize(%this.owner.getRightVector());
%forMove = VectorScale(%fv, (%moveVector.x));// * (%this.moveSpeed * 0.032)));
//%this.Physics.velocity = VectorAdd(%this.Physics.velocity, %forMove);
%this.Physics.moveVector = VectorAdd(%this.Physics.moveVector, %forMove);
//if(%forMove > 0)
// %this.Animation.playThread(1, "run");
}
/*else
{
%fv = VectorNormalize(%this.owner.getRightVector());
%forMove = VectorScale(%fv, (%moveVector.x * (%this.moveSpeed * 0.032)));
if(%forMove <= 0)
%this.Animation.stopThread(1);
}*/
if(%moveVector.y != 0)
{
%fv = VectorNormalize(%this.owner.getForwardVector());
%forMove = VectorScale(%fv, (%moveVector.y));// * (%this.moveSpeed * 0.032)));
//%this.Physics.velocity = VectorAdd(%this.Physics.velocity, %forMove);
%this.Physics.moveVector = VectorAdd(%this.Physics.moveVector, %forMove);
//if(VectorLen(%this.Physics.velocity) < 2)
// %this.Physics.velocity = VectorAdd(%this.Physics.velocity, %forMove);
}
/*if(%moveVector.z)
{
%fv = VectorNormalize(%this.owner.getUpVector());
%forMove = VectorScale(%fv, (%moveVector.z * (%this.moveSpeed * 0.032)));
%this.Physics.velocity = VectorAdd(%this.Physics.velocity, %forMove);
}*/
if(%moveRotation.x != 0)
{
%look = mRadToDeg(%moveRotation.x) / 180;
//%this.Animation.setThreadPos(0, %look);
%this.owner.getComponent( MountedCameraComponent ).rotationOffset.x += mRadToDeg(%moveRotation.x);
//%this.Camera.rotationOffset.x += mRadToDeg(%moveRotation.x);
}
// %this.owner.rotation.x += mRadToDeg(%moveRotation.x);
if(%moveRotation.z != 0)
{
%zrot = mRadToDeg(%moveRotation.z);
%this.owner.getComponent( MountedCameraComponent ).rotationOffset.z += %zrot;
//%this.owner.rotation.z += %zrot;
}
}
//
function FPSControls_forwardKey(%val)
{
$mvForwardAction = %val;
}
function FPSControls_backKey(%val)
{
$mvBackwardAction = %val;
}
function FPSControls_leftKey(%val)
{
$mvLeftAction = %val;
}
function FPSControls_rightKey(%val)
{
$mvRightAction = %val;
}
function FPSControls_yawAxis(%val)
{
$mvYaw += getMouseAdjustAmount(%val);
}
function FPSControls_pitchAxis(%val)
{
$mvPitch += getMouseAdjustAmount(%val);
}
function FPSControls_jump(%val)
{
$mvTriggerCount2++;
}
function FPSControls_flashLight(%val)
{
$mvTriggerCount3++;
}

View file

@ -0,0 +1,82 @@
//-----------------------------------------------------------------------------
// 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.
//-----------------------------------------------------------------------------
function SetInput(%client, %device, %key, %command, %bindMap, %behav)
{
commandToClient(%client, 'SetInput', %device, %key, %command, %bindMap, %behav);
}
function RemoveInput(%client, %device, %key, %command, %bindMap)
{
commandToClient(%client, 'removeInput', %device, %key, %command, %bindMap);
}
function clientCmdSetInput(%device, %key, %command, %bindMap, %behav)
{
//if we're requesting a custom bind map, set that up
if(%bindMap $= "")
%bindMap = moveMap;
if (!isObject(%bindMap)){
new ActionMap(moveMap);
moveMap.push();
}
//get our local
//%localID = ServerConnection.resolveGhostID(%behav);
//%tmpl = %localID.getTemplate();
//%tmpl.insantiateNamespace(%tmpl.getName());
//first, check if we have an existing command
%oldBind = %bindMap.getBinding(%command);
if(%oldBind !$= "")
%bindMap.unbind(getField(%oldBind, 0), getField(%oldBind, 1));
//now, set the requested bind
%bindMap.bind(%device, %key, %command);
}
function clientCmdRemoveSpecCtrlInput(%device, %key, %bindMap)
{
//if we're requesting a custom bind map, set that up
if(%bindMap $= "")
%bindMap = moveMap;
if (!isObject(%bindMap))
return;
%bindMap.unbind(%device, %key);
}
function clientCmdSetupClientBehavior(%bhvrGstID)
{
%localID = ServerConnection.resolveGhostID(%bhvrGstID);
%tmpl = %localID.getTemplate();
%tmpl.insantiateNamespace(%tmpl.getName());
}
function getMouseAdjustAmount(%val)
{
// based on a default camera FOV of 90'
return(%val * ($cameraFov / 90) * 0.01) * $pref::Input::LinkMouseSensitivity;
}

View file

@ -0,0 +1,7 @@
<ComponentAsset
AssetName="MeshComponentAsset"
componentName=""
componentClass="MeshComponent"
friendlyName="Mesh"
componentType="Render"
description="Enables an entity to render a shape."/>

View file

@ -0,0 +1,7 @@
<ComponentAsset
AssetName="PlayerControllerComponentAsset"
componentName=""
componentClass="PlayerControllerComponent"
friendlyName="Player Controller"
componentType="Game"
description="Enables an entity to move like a player object."/>

View file

@ -0,0 +1,7 @@
<ComponentAsset
AssetName="StateMachineComponentAsset"
componentName=""
componentClass="StateMachineComponent"
friendlyName="State Machine"
componentType="Game"
description="Enables a state machine on the entity."/>