Cleans up the ExampleModule to have up-to-date examples of module init'ing, game modes, levels and basic input logic

Cleans up prototyping module to trim unneeded extra scripts and files
Adds PlayerBot model to Prototyping module
Adds metalGray material to Prototyping module
Fixes issue where logic wasn't changed for forcing AB preview images to regenerate
Removes unneeded legacy lines from editor template level
Removes unneeded extra asset import config
Disables terrain material name field from editing in terrain material editor for now to prevent bad behavior
Adds mapTo line to newly created material asset definitions to ensure shapes doing mapTo lookups can properly utilize the materials
This commit is contained in:
JeffR 2022-05-31 00:26:20 -05:00
parent e896e663d4
commit 27b20c14d7
98 changed files with 1337 additions and 1725 deletions

View file

@ -0,0 +1,120 @@
$RemapName[$RemapCount] = "Forward";
$RemapCmd[$RemapCount] = "moveforward";
$RemapActionMap[$RemapCount] = "ExampleMoveMap";
$RemapDevice[$RemapCount] = "keyboard";
$RemapDescription[$RemapCount] = "Forward Movement";
$RemapCount++;
$RemapName[$RemapCount] = "Backward";
$RemapCmd[$RemapCount] = "movebackward";
$RemapActionMap[$RemapCount] = "ExampleMoveMap";
$RemapDevice[$RemapCount] = "keyboard";
$RemapDescription[$RemapCount] = "Backward Movement";
$RemapCount++;
$RemapName[$RemapCount] = "Strafe Left";
$RemapCmd[$RemapCount] = "moveleft";
$RemapActionMap[$RemapCount] = "ExampleMoveMap";
$RemapDevice[$RemapCount] = "keyboard";
$RemapDescription[$RemapCount] = "Left Strafing Movement";
$RemapCount++;
$RemapName[$RemapCount] = "Strafe Right";
$RemapCmd[$RemapCount] = "moveright";
$RemapActionMap[$RemapCount] = "ExampleMoveMap";
$RemapDevice[$RemapCount] = "keyboard";
$RemapDescription[$RemapCount] = "Right Strafing Movement";
$RemapCount++;
$RemapName[$RemapCount] = "Ascend";
$RemapCmd[$RemapCount] = "moveup";
$RemapActionMap[$RemapCount] = "ExampleMoveMap";
$RemapDevice[$RemapCount] = "keyboard";
$RemapDescription[$RemapCount] = "Makes the camera ascend";
$RemapCount++;
$RemapName[$RemapCount] = "Descend";
$RemapCmd[$RemapCount] = "movedown";
$RemapActionMap[$RemapCount] = "ExampleMoveMap";
$RemapDevice[$RemapCount] = "keyboard";
$RemapDescription[$RemapCount] = "Makes the camera descend";
$RemapCount++;
$RemapName[$RemapCount] = "Jump";
$RemapCmd[$RemapCount] = "jump";
$RemapActionMap[$RemapCount] = "ExampleMoveMap";
$RemapDevice[$RemapCount] = "keyboard";
$RemapDescription[$RemapCount] = "Jump";
$RemapCount++;
$RemapName[$RemapCount] = "Ascend";
$RemapCmd[$RemapCount] = "moveup";
$RemapActionMap[$RemapCount] = "ExampleMoveMap";
$RemapDevice[$RemapCount] = "gamepad";
$RemapDescription[$RemapCount] = "Makes the camera ascend";
$RemapCount++;
$RemapName[$RemapCount] = "Descend";
$RemapCmd[$RemapCount] = "movedown";
$RemapActionMap[$RemapCount] = "ExampleMoveMap";
$RemapDevice[$RemapCount] = "gamepad";
$RemapDescription[$RemapCount] = "Makes the camera descend";
$RemapCount++;
$RemapName[$RemapCount] = "Jump";
$RemapCmd[$RemapCount] = "jump";
$RemapActionMap[$RemapCount] = "ExampleMoveMap";
$RemapDevice[$RemapCount] = "gamepad";
$RemapDescription[$RemapCount] = "Jump";
$RemapCount++;
if ( isObject( ExampleMoveMap ) )
ExampleMoveMap.delete();
new ActionMap(ExampleMoveMap);
ExampleMoveMap.humanReadableName = "Example Movement";
//------------------------------------------------------------------------------
// Non-remapable binds
//------------------------------------------------------------------------------
ExampleMoveMap.bind( keyboard, F2, showPlayerList );
ExampleMoveMap.bind(keyboard, "ctrl h", hideHUDs);
ExampleMoveMap.bind(keyboard, "alt p", doScreenShotHudless);
ExampleMoveMap.bindCmd(keyboard, "escape", "", "Canvas.pushDialog(PauseMenu);");
//------------------------------------------------------------------------------
// Movement Keys
//------------------------------------------------------------------------------
ExampleMoveMap.bind( keyboard, a, moveleft );
ExampleMoveMap.bind( keyboard, d, moveright );
ExampleMoveMap.bind( keyboard, left, moveleft );
ExampleMoveMap.bind( keyboard, right, moveright );
ExampleMoveMap.bind( keyboard, w, moveforward );
ExampleMoveMap.bind( keyboard, s, movebackward );
ExampleMoveMap.bind( keyboard, up, moveforward );
ExampleMoveMap.bind( keyboard, down, movebackward );
ExampleMoveMap.bind( keyboard, e, moveup );
ExampleMoveMap.bind( keyboard, c, movedown );
ExampleMoveMap.bind( keyboard, space, jump );
ExampleMoveMap.bind( mouse, xaxis, yaw );
ExampleMoveMap.bind( mouse, yaxis, pitch );
ExampleMoveMap.bind( gamepad, thumbrx, "D", "-0.23 0.23", gamepadYaw );
ExampleMoveMap.bind( gamepad, thumbry, "D", "-0.23 0.23", gamepadPitch );
ExampleMoveMap.bind( gamepad, thumblx, "D", "-0.23 0.23", gamePadMoveX );
ExampleMoveMap.bind( gamepad, thumbly, "D", "-0.23 0.23", gamePadMoveY );
ExampleMoveMap.bind( gamepad, btn_a, jump );
ExampleMoveMap.bindCmd( gamepad, btn_back, "disconnect();", "" );
//------------------------------------------------------------------------------
// Demo recording functions
//------------------------------------------------------------------------------
ExampleMoveMap.bind( keyboard, F3, startRecordingDemo );
ExampleMoveMap.bind( keyboard, F4, stopRecordingDemo );
//------------------------------------------------------------------------------
// Helper Functions
//------------------------------------------------------------------------------
GlobalActionMap.bind(keyboard, "ctrl F3", doProfile);
//------------------------------------------------------------------------------
// Misc.
//------------------------------------------------------------------------------
GlobalActionMap.bind(keyboard, "tilde", toggleConsole);
ExampleMoveMap.bindCmd(keyboard, "n", "toggleNetGraph();", "");

View file

@ -0,0 +1,324 @@
function escapeFromGame()
{
disconnect();
}
function showPlayerList(%val)
{
if (%val)
PlayerListGui.toggle();
}
function hideHUDs(%val)
{
if (%val)
HudlessPlayGui.toggle();
}
function doScreenShotHudless(%val)
{
if(%val)
{
canvas.setContent(HudlessPlayGui);
//doScreenshot(%val);
schedule(10, 0, "doScreenShot", %val);
}
else
{
%playGUIName = ProjectSettings.value("UI/playGUIName");
Canvas.setContent(%playGUIName);
}
}
$movementSpeed = 1; // m/s
function setSpeed(%speed)
{
if(%speed)
$movementSpeed = %speed;
}
function moveleft(%val)
{
$mvLeftAction = %val * $movementSpeed;
}
function moveright(%val)
{
$mvRightAction = %val * $movementSpeed;
}
function moveforward(%val)
{
$mvForwardAction = %val * $movementSpeed;
}
function movebackward(%val)
{
$mvBackwardAction = %val * $movementSpeed;
}
function moveup(%val)
{
%object = ServerConnection.getControlObject();
if(%object.isInNamespaceHierarchy("Camera"))
$mvUpAction = %val * $movementSpeed;
}
function movedown(%val)
{
%object = ServerConnection.getControlObject();
if(%object.isInNamespaceHierarchy("Camera"))
$mvDownAction = %val * $movementSpeed;
}
function turnLeft( %val )
{
$mvYawRightSpeed = %val ? $Pref::Input::KeyboardTurnSpeed : 0;
}
function turnRight( %val )
{
$mvYawLeftSpeed = %val ? $Pref::Input::KeyboardTurnSpeed : 0;
}
function panUp( %val )
{
$mvPitchDownSpeed = %val ? $Pref::Input::KeyboardTurnSpeed : 0;
}
function panDown( %val )
{
$mvPitchUpSpeed = %val ? $Pref::Input::KeyboardTurnSpeed : 0;
}
function getMouseAdjustAmount(%val)
{
// based on a default camera FOV of 90'
return(%val * ($cameraFov / 90) * 0.01) * $pref::Input::LinkMouseSensitivity;
}
function getGamepadAdjustAmount(%val)
{
// based on a default camera FOV of 90'
return(%val * ($cameraFov / 90) * 0.01) * 10.0;
}
function yaw(%val)
{
%yawAdj = getMouseAdjustAmount(%val);
if(ServerConnection.isControlObjectRotDampedCamera())
{
// Clamp and scale
%yawAdj = mClamp(%yawAdj, -m2Pi()+0.01, m2Pi()-0.01);
%yawAdj *= 0.5;
}
$mvYaw += %yawAdj;
}
function pitch(%val)
{
%pitchAdj = getMouseAdjustAmount(%val);
if(ServerConnection.isControlObjectRotDampedCamera())
{
// Clamp and scale
%pitchAdj = mClamp(%pitchAdj, -m2Pi()+0.01, m2Pi()-0.01);
%pitchAdj *= 0.5;
}
$mvPitch += %pitchAdj;
}
function jump(%val)
{
$mvTriggerCount2++;
}
function gamePadMoveX( %val )
{
if(%val > 0)
{
$mvRightAction = %val * $movementSpeed;
$mvLeftAction = 0;
}
else
{
$mvRightAction = 0;
$mvLeftAction = -%val * $movementSpeed;
}
}
function gamePadMoveY( %val )
{
if(%val > 0)
{
$mvForwardAction = %val * $movementSpeed;
$mvBackwardAction = 0;
}
else
{
$mvForwardAction = 0;
$mvBackwardAction = -%val * $movementSpeed;
}
}
function gamepadYaw(%val)
{
%yawAdj = getGamepadAdjustAmount(%val);
if(ServerConnection.isControlObjectRotDampedCamera())
{
// Clamp and scale
%yawAdj = mClamp(%yawAdj, -m2Pi()+0.01, m2Pi()-0.01);
%yawAdj *= 0.5;
}
if(%yawAdj > 0)
{
$mvYawLeftSpeed = %yawAdj;
$mvYawRightSpeed = 0;
}
else
{
$mvYawLeftSpeed = 0;
$mvYawRightSpeed = -%yawAdj;
}
}
function gamepadPitch(%val)
{
%pitchAdj = getGamepadAdjustAmount(%val);
if(ServerConnection.isControlObjectRotDampedCamera())
{
// Clamp and scale
%pitchAdj = mClamp(%pitchAdj, -m2Pi()+0.01, m2Pi()-0.01);
%pitchAdj *= 0.5;
}
if(%pitchAdj > 0)
{
$mvPitchDownSpeed = %pitchAdj;
$mvPitchUpSpeed = 0;
}
else
{
$mvPitchDownSpeed = 0;
$mvPitchUpSpeed = -%pitchAdj;
}
}
function toggleZoomFOV()
{
$Player::CurrentFOV = $Player::CurrentFOV / 2;
if($Player::CurrentFOV < 5)
resetCurrentFOV();
if(ServerConnection.zoomed)
setFOV($Player::CurrentFOV);
else
{
setFov(ServerConnection.getControlCameraDefaultFov());
}
}
function resetCurrentFOV()
{
$Player::CurrentFOV = ServerConnection.getControlCameraDefaultFov() / 2;
}
function turnOffZoom()
{
ServerConnection.zoomed = false;
setFov(ServerConnection.getControlCameraDefaultFov());
Reticle.setVisible(true);
zoomReticle.setVisible(false);
// Rather than just disable the DOF effect, we want to set it to the level's
// preset values.
//DOFPostEffect.disable();
ppOptionsUpdateDOFSettings();
}
function setZoomFOV(%val)
{
if(%val)
toggleZoomFOV();
}
function toggleZoom(%val)
{
if (%val)
{
ServerConnection.zoomed = true;
setFov($Player::CurrentFOV);
Reticle.setVisible(false);
zoomReticle.setVisible(true);
DOFPostEffect.setAutoFocus( true );
DOFPostEffect.setFocusParams( 0.5, 0.5, 50, 500, -5, 5 );
DOFPostEffect.enable();
}
else
{
turnOffZoom();
}
}
function mouseButtonZoom(%val)
{
toggleZoom(%val);
}
function startRecordingDemo( %val )
{
if ( %val )
startDemoRecord();
}
function stopRecordingDemo( %val )
{
if ( %val )
stopDemoRecord();
}
//------------------------------------------------------------------------------
// Debugging Functions
//------------------------------------------------------------------------------
function showMetrics(%val)
{
if(%val)
{
if(!Canvas.isMember(FrameOverlayGui))
metrics("fps gfx shadow sfx terrain groundcover forest net");
else
metrics("");
}
}
GlobalActionMap.bind(keyboard, "ctrl F2", showMetrics);
//------------------------------------------------------------------------------
//
// Start profiler by pressing ctrl f3
// ctrl f3 - starts profile that will dump to console and file
//
function doProfile(%val)
{
if (%val)
{
// key down -- start profile
echo("Starting profile session...");
profilerReset();
profilerEnable(true);
}
else
{
// key up -- finish off profile
echo("Ending profile session...");
profilerDumpToFile("profilerDumpToFile" @ getSimTime() @ ".txt");
profilerEnable(false);
}
}