added everything
This commit is contained in:
16
example/tutorial.base/server/camera.cs
Executable file
16
example/tutorial.base/server/camera.cs
Executable file
@ -0,0 +1,16 @@
|
||||
//-----------------------------------------------------------------------------
|
||||
// Torque Game Engine
|
||||
// Copyright (C) GarageGames.com, Inc.
|
||||
//-----------------------------------------------------------------------------
|
||||
|
||||
// Global movement speed that affects all cameras.
|
||||
$Camera::movementSpeed = 40;
|
||||
|
||||
//-----------------------------------------------------------------------------
|
||||
// Define a datablock class to use for our observer camera
|
||||
//-----------------------------------------------------------------------------
|
||||
|
||||
datablock CameraData(Observer)
|
||||
{
|
||||
mode = "Observer";
|
||||
};
|
41
example/tutorial.base/server/defaults.cs
Executable file
41
example/tutorial.base/server/defaults.cs
Executable file
@ -0,0 +1,41 @@
|
||||
//-----------------------------------------------------------------------------
|
||||
// Torque Game Engine
|
||||
// Copyright (C) GarageGames.com, Inc.
|
||||
//-----------------------------------------------------------------------------
|
||||
|
||||
// List of master servers to query, each one is tried in order
|
||||
// until one responds
|
||||
$Pref::Server::RegionMask = 2;
|
||||
$pref::Master[0] = "2:master.garagegames.com:28002";
|
||||
|
||||
// Information about the server
|
||||
$Pref::Server::Name = "Torque TTB Server";
|
||||
$Pref::Server::Info = "This is a Torque Game Engine Test Server.";
|
||||
|
||||
// The connection error message is transmitted to the client immediatly
|
||||
// on connection, if any further error occures during the connection
|
||||
// process, such as network traffic mismatch, or missing files, this error
|
||||
// message is display. This message should be replaced with information
|
||||
// usefull to the client, such as the url or ftp address of where the
|
||||
// latest version of the game can be obtained.
|
||||
$Pref::Server::ConnectionError =
|
||||
"You do not have the correct version of the Torque Game Engine or "@
|
||||
"the related art needed to connect to this server, please contact "@
|
||||
"the server operator to obtain the latest version of this game.";
|
||||
|
||||
// The network port is also defined by the client, this value
|
||||
// overrides pref::net::port for dedicated servers
|
||||
$Pref::Server::Port = 28000;
|
||||
|
||||
// If the password is set, clients must provide it in order
|
||||
// to connect to the server
|
||||
$Pref::Server::Password = "";
|
||||
|
||||
// Password for admin clients
|
||||
$Pref::Server::AdminPassword = "";
|
||||
|
||||
// Misc server settings.
|
||||
$Pref::Server::MaxPlayers = 64;
|
||||
$Pref::Server::FloodProtectionEnabled = 1;
|
||||
$Pref::Server::MaxChatLen = 120;
|
||||
|
BIN
example/tutorial.base/server/defaults.cs.dso
Executable file
BIN
example/tutorial.base/server/defaults.cs.dso
Executable file
Binary file not shown.
101
example/tutorial.base/server/editor.cs
Executable file
101
example/tutorial.base/server/editor.cs
Executable file
@ -0,0 +1,101 @@
|
||||
//-----------------------------------------------------------------------------
|
||||
// Torque Game Engine
|
||||
// Copyright (C) GarageGames.com, Inc.
|
||||
//-----------------------------------------------------------------------------
|
||||
|
||||
//-----------------------------------------------------------------------------
|
||||
// This file contains shape declarations and functions used by the mission
|
||||
// editor. The mission editor invokes datablock create methods when it
|
||||
// wants to create an object of that type.
|
||||
|
||||
//-----------------------------------------------------------------------------
|
||||
// Declare a static shape create method. This allows DTS objects to be loaded
|
||||
// using the StaticShape simulation object.
|
||||
|
||||
function StaticShapeData::create(%data)
|
||||
{
|
||||
%obj = new StaticShape() {
|
||||
dataBlock = %data;
|
||||
};
|
||||
return %obj;
|
||||
}
|
||||
|
||||
|
||||
//-----------------------------------------------------------------------------
|
||||
// Declare two marker objects used to place waypoints
|
||||
|
||||
datablock MissionMarkerData(WayPointMarker)
|
||||
{
|
||||
category = "Misc";
|
||||
shapeFile = "~/data/shapes/markers/octahedron.dts";
|
||||
};
|
||||
|
||||
datablock MissionMarkerData(SpawnSphereMarker)
|
||||
{
|
||||
category = "Misc";
|
||||
shapeFile = "~/data/shapes/markers/octahedron.dts";
|
||||
};
|
||||
|
||||
function MissionMarkerData::create(%block)
|
||||
{
|
||||
switch$(%block)
|
||||
{
|
||||
case "WayPointMarker":
|
||||
%obj = new WayPoint() {
|
||||
dataBlock = %block;
|
||||
};
|
||||
return(%obj);
|
||||
case "SpawnSphereMarker":
|
||||
%obj = new SpawnSphere() {
|
||||
datablock = %block;
|
||||
};
|
||||
return(%obj);
|
||||
}
|
||||
return(-1);
|
||||
}
|
||||
|
||||
|
||||
//-----------------------------------------------------------------------------
|
||||
// Misc. server commands used for editing
|
||||
//-----------------------------------------------------------------------------
|
||||
|
||||
function serverCmdToggleCamera(%client)
|
||||
{
|
||||
if ($Server::ServerType $= "SinglePlayer") {
|
||||
%control = %client.getControlObject();
|
||||
if (%control == %client.player) {
|
||||
%control = %client.camera;
|
||||
%control.mode = toggleCameraFly;
|
||||
}
|
||||
else {
|
||||
%control = %client.player;
|
||||
%control.mode = observerFly;
|
||||
}
|
||||
%client.setControlObject(%control);
|
||||
}
|
||||
}
|
||||
|
||||
function serverCmdDropPlayerAtCamera(%client)
|
||||
{
|
||||
if (!%client.player.isMounted())
|
||||
%client.player.setTransform(%client.camera.getTransform());
|
||||
%client.player.setVelocity("0 0 0");
|
||||
%client.setControlObject(%client.player);
|
||||
}
|
||||
|
||||
function serverCmdDropCameraAtPlayer(%client)
|
||||
{
|
||||
%client.camera.setTransform(%client.player.getEyeTransform());
|
||||
%client.camera.setVelocity("0 0 0");
|
||||
%client.setControlObject(%client.camera);
|
||||
}
|
||||
|
||||
|
||||
function dropFreakinCameraAtPlayer()
|
||||
{
|
||||
$dropcameracount++;
|
||||
%cl = ClientGroup.getObject(0);
|
||||
if (%cl.camera) dropCameraAtPlayer(1);
|
||||
else if ($dropcameracount<100) schedule(100,0,dropFreakinCameraAtPlayer);
|
||||
}
|
||||
|
123
example/tutorial.base/server/game.cs
Executable file
123
example/tutorial.base/server/game.cs
Executable file
@ -0,0 +1,123 @@
|
||||
//-----------------------------------------------------------------------------
|
||||
// Torque Game Engine
|
||||
// Copyright (C) GarageGames.com, Inc.
|
||||
//-----------------------------------------------------------------------------
|
||||
|
||||
|
||||
//-----------------------------------------------------------------------------
|
||||
// Server and mission initialization
|
||||
//-----------------------------------------------------------------------------
|
||||
|
||||
function onServerCreated()
|
||||
{
|
||||
// This function is called when a server is constructed.
|
||||
|
||||
// Master server information for multiplayer games
|
||||
$Server::GameType = "Torque TTB";
|
||||
$Server::MissionType = "None";
|
||||
|
||||
// Load up all datablocks, objects etc.
|
||||
exec("./camera.cs");
|
||||
exec("./editor.cs");
|
||||
exec("./player.cs");
|
||||
exec("./logoitem.cs");
|
||||
|
||||
exec("common/server/lightingSystem.cs");
|
||||
}
|
||||
|
||||
function onServerDestroyed()
|
||||
{
|
||||
// This function is called as part of a server shutdown.
|
||||
}
|
||||
|
||||
|
||||
//-----------------------------------------------------------------------------
|
||||
|
||||
function onMissionLoaded()
|
||||
{
|
||||
// Called by loadMission() once the mission is finished loading.
|
||||
}
|
||||
|
||||
function onMissionEnded()
|
||||
{
|
||||
// Called by endMission(), right before the mission is destroyed
|
||||
}
|
||||
|
||||
|
||||
//-----------------------------------------------------------------------------
|
||||
// Dealing with client connections
|
||||
// These methods are extensions to the GameConnection class. Extending
|
||||
// GameConnection make is easier to deal with some of this functionality,
|
||||
// but these could also be implemented as stand-alone functions.
|
||||
//-----------------------------------------------------------------------------
|
||||
|
||||
//-----------------------------------------------------------------------------
|
||||
|
||||
function GameConnection::onClientEnterGame(%this)
|
||||
{
|
||||
// Every client get's a camera object.
|
||||
%this.camera = new Camera() {
|
||||
dataBlock = Observer;
|
||||
};
|
||||
MissionCleanup.add( %this.camera );
|
||||
%this.camera.scopeToClient(%this);
|
||||
|
||||
// Create a player object.
|
||||
%spawnPoint = pickSpawnPoint();
|
||||
%this.createPlayer(%spawnPoint);
|
||||
}
|
||||
|
||||
function GameConnection::onClientLeaveGame(%this)
|
||||
{
|
||||
if (isObject(%this.camera))
|
||||
%this.camera.delete();
|
||||
if (isObject(%this.player))
|
||||
%this.player.delete();
|
||||
}
|
||||
|
||||
|
||||
//-----------------------------------------------------------------------------
|
||||
|
||||
function GameConnection::createPlayer(%this, %spawnPoint)
|
||||
{
|
||||
if (%this.player > 0) {
|
||||
// The client should not have a player currently
|
||||
// assigned. Assigning a new one could result in
|
||||
// a player ghost.
|
||||
error( "Attempting to create an angus ghost!" );
|
||||
}
|
||||
|
||||
// Create the player object
|
||||
%player = new Player() {
|
||||
dataBlock = PlayerBody;
|
||||
client = %this;
|
||||
};
|
||||
MissionCleanup.add(%player);
|
||||
|
||||
// Player setup...
|
||||
%player.setTransform(%spawnPoint);
|
||||
%player.setShapeName(%this.name);
|
||||
|
||||
// Update the camera to start with the player
|
||||
%this.camera.setTransform(%player.getEyeTransform());
|
||||
|
||||
// Give the client control of the player
|
||||
%this.player = %player;
|
||||
%this.setControlObject(%player);
|
||||
}
|
||||
|
||||
|
||||
//-----------------------------------------------------------------------------
|
||||
|
||||
function pickSpawnPoint()
|
||||
{
|
||||
// Pick the first object in drop point group and use it's
|
||||
// location as a spawn point.
|
||||
%group = nameToID("MissionGroup/PlayerDropPoints");
|
||||
if (%group != -1 && %group.getCount() != 0)
|
||||
return %group.getObject(0).getTransform();
|
||||
|
||||
// If no object was found, return a point near the center of the world
|
||||
error("Missing spawn point object and/or mission group " @ %groupName);
|
||||
return "0 0 300 1 0 0 0";
|
||||
}
|
BIN
example/tutorial.base/server/game.cs.dso
Executable file
BIN
example/tutorial.base/server/game.cs.dso
Executable file
Binary file not shown.
10
example/tutorial.base/server/logoitem.cs
Executable file
10
example/tutorial.base/server/logoitem.cs
Executable file
@ -0,0 +1,10 @@
|
||||
//-----------------------------------------------------------------------------
|
||||
// Torque Game Engine
|
||||
// Copyright (C) GarageGames.com, Inc.
|
||||
//-----------------------------------------------------------------------------
|
||||
|
||||
datablock StaticShapeData(TorqueLogoItem)
|
||||
{
|
||||
category = "Items";
|
||||
shapeFile = "~/data/shapes/3dtorquelogo/torque_logo.dts";
|
||||
};
|
49
example/tutorial.base/server/player.cs
Executable file
49
example/tutorial.base/server/player.cs
Executable file
@ -0,0 +1,49 @@
|
||||
//-----------------------------------------------------------------------------
|
||||
// Torque Game Engine
|
||||
// Copyright (C) GarageGames.com, Inc.
|
||||
//-----------------------------------------------------------------------------
|
||||
|
||||
// Load dts shapes and merge animations
|
||||
datablock TSShapeConstructor(PlayerDts)
|
||||
{
|
||||
baseShape = "~/data/shapes/player/player.dts";
|
||||
sequence0 = "~/data/shapes/player/player_root.dsq root";
|
||||
sequence1 = "~/data/shapes/player/player_forward.dsq run";
|
||||
sequence2 = "~/data/shapes/player/player_back.dsq back";
|
||||
sequence3 = "~/data/shapes/player/player_side.dsq side";
|
||||
sequence4 = "~/data/shapes/player/player_fall.dsq fall";
|
||||
sequence5 = "~/data/shapes/player/player_land.dsq land";
|
||||
sequence6 = "~/data/shapes/player/player_jump.dsq jump";
|
||||
sequence7 = "~/data/shapes/player/player_standjump.dsq standjump";
|
||||
sequence8 = "~/data/shapes/player/player_lookde.dsq look";
|
||||
sequence9 = "~/data/shapes/player/player_head.dsq head";
|
||||
sequence10 = "~/data/shapes/player/player_headside.dsq headside";
|
||||
sequence11 = "~/data/shapes/player/player_celwave.dsq celwave";
|
||||
};
|
||||
|
||||
datablock PlayerData(PlayerBody)
|
||||
{
|
||||
renderFirstPerson = false;
|
||||
shapeFile = "~/data/shapes/player/player.dts";
|
||||
};
|
||||
|
||||
|
||||
//----------------------------------------------------------------------------
|
||||
// PlayerBody Datablock methods
|
||||
//----------------------------------------------------------------------------
|
||||
|
||||
function PlayerBody::onAdd(%this,%obj)
|
||||
{
|
||||
// Called when the PlayerData datablock is first 'read' by the engine (executable)
|
||||
}
|
||||
|
||||
function PlayerBody::onRemove(%this, %obj)
|
||||
{
|
||||
if (%obj.client.player == %obj)
|
||||
%obj.client.player = 0;
|
||||
}
|
||||
|
||||
function PlayerBody::onNewDataBlock(%this,%obj)
|
||||
{
|
||||
// Called when this PlayerData datablock is assigned to an object
|
||||
}
|
Reference in New Issue
Block a user