1
0
forked from 0ad/0ad
0ad/binaries/data/mods/public/simulation/helpers/Commands.js
Ykkrosh 7c2e9027c2 # Rewrite of the game's simulation system
Giant merge from
http://svn.wildfiregames.com/hg-source/file/5fb522019d5e
Infrastructure is largely complete, gameplay is largely missing
Disabled by default; use command-line flag "-sim2"
(Second attempt at commit...)

This was SVN commit r7259.
2010-01-09 19:20:14 +00:00

31 lines
656 B
JavaScript

function ProcessCommand(player, cmd)
{
// print("command: " + player + " " + uneval(cmd) + "\n");
switch (cmd.type)
{
case "spin":
for each (var ent in cmd.entities)
{
var pos = Engine.QueryInterface(ent, IID_Position);
if (! pos)
continue;
pos.SetYRotation(pos.GetRotation().y + 1);
}
break;
case "walk":
for each (var ent in cmd.entities)
{
var motion = Engine.QueryInterface(ent, IID_UnitMotion);
if (! motion)
continue;
motion.MoveToPoint(cmd.x, cmd.z);
}
break;
default:
print("Ignoring unrecognised command type '" + cmd.type + "'\n");
}
}
Engine.RegisterGlobal("ProcessCommand", ProcessCommand);