Created
March 24, 2016 19:32
-
-
Save aldrik/59ae7ea2cb66d6c5a824 to your computer and use it in GitHub Desktop.
PA displayCursor server mod test
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
(function() { | |
var sendCursorPosition = function(loc) { | |
var hdeck = api.holodecks[api.Holodeck.focused.id]; | |
hdeck.raycastTerrain(loc.offsetX, loc.offsetY).then(function(loc3D) { | |
if (loc3D.pos) { | |
// TODO: Include game time for chronocam support. | |
var message = JSON.stringify({ | |
"id": "displayCursor", | |
"planet": loc3D.planet, | |
"pos": loc3D.pos | |
}); | |
model.send_message("team_chat_message", {"message": message}) | |
} | |
}); | |
}; | |
$("holodeck").on("mousemove", function(event) { sendCursorPosition(event) }) | |
})(); |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
(function() { | |
var world = api.getWorldView(0); | |
var puppets = Array(100); | |
var chat_message = handlers.chat_message; | |
var player_colors; | |
playerInfoHelper.injectHandlers(handlers); | |
model.playerInfo = playerInfoHelper; | |
model.playerInfo.armyId.subscribe(function(id) { | |
player_colors = {}; | |
var armies = model.playerInfo.armies(); | |
for (var i = 0; i < armies.length; i++) { | |
var army = armies[i]; | |
if (army.id !== model.playerInfo.armyId()) { | |
// if (true) { | |
player_colors[army.name] = army.primary_color; | |
} | |
} | |
}); | |
handlers.chat_message = function(payload) { | |
if (~payload.message.indexOf('"id":"displayCursor"')) { | |
if (payload.player_name in player_colors) { | |
var data = JSON.parse(payload.message); | |
// if (puppet) { | |
// world.movePuppet(puppet.id, data); | |
// return; | |
// world.clearPuppets(); | |
// } | |
world.puppet({ | |
// model:{ | |
// "filename": "/pa/units/land/land_mine/land_mine.papa" | |
// }, | |
"fx_offsets":[{"type":"build","filename":"/pa/effects/specs/default_circle_area_target.pfx","bone":"socket_muzzle01","offset":[0,0,0],"orientation":[0,0,0]},{"type":"build","filename":"/pa/effects/specs/default_click.pfx","bone":"socket_muzzle01","offset":[0,0,0],"orientation":[0,0,0]}], | |
material: { | |
shader: 'pa_unit_ghost', | |
constants: { | |
// Color: [1,0,1,0.8], | |
Color: player_colors[payload.player_name], | |
GhostColor: [0,0,1,0.5], | |
BuildInfo: [0, 10, 0, 0] | |
} | |
}, | |
location: { | |
planet: data.planet || 0, | |
pos: data.pos, | |
orient_rel: true, | |
snap: true | |
} | |
}, true).then(function(p) { | |
// previewPuppetsIds.push(p.id); | |
// console.log(p); | |
puppets.unshift(p.id); | |
world.unPuppet(puppets.pop()); | |
}); | |
} | |
} else { | |
return chat_message.apply(handlers, arguments); | |
} | |
} | |
})(); |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment