Changeset View
Changeset View
Standalone View
Standalone View
binaries/data/mods/public/maps/random/rmgen2/setup.js
Show First 20 Lines • Show All 72 Lines • ▼ Show 20 Lines | "randomGroup": { | ||||
"groupedDistance": fractionToTiles(randFloat(0.08, 0.1)), | "groupedDistance": fractionToTiles(randFloat(0.08, 0.1)), | ||||
"walls": true | "walls": true | ||||
}, | }, | ||||
"stronghold": { | "stronghold": { | ||||
"getPosition": (distance, groupedDistance, startAngle) => placeStronghold(getTeamsArray(), distance, groupedDistance, startAngle), | "getPosition": (distance, groupedDistance, startAngle) => placeStronghold(getTeamsArray(), distance, groupedDistance, startAngle), | ||||
"distance": fractionToTiles(randFloat(0.2, 0.35)), | "distance": fractionToTiles(randFloat(0.2, 0.35)), | ||||
"groupedDistance": fractionToTiles(randFloat(0.08, 0.1)), | "groupedDistance": fractionToTiles(randFloat(0.08, 0.1)), | ||||
"walls": false | "walls": false | ||||
}, | |||||
"besideAllies": { | |||||
"getPosition": (distance, groupedDistance, startAngle) => playerPlacementMultiArcs(sortAllPlayers(), distance, startAngle), | |||||
"distance": fractionToTiles(randFloat(0.3, 0.35)), | |||||
"groupedDistance": null, // The gap between allies is computed within the function | |||||
lyv: The distance is better suited for here. For consistency and general separation of concerns. And… | |||||
"walls": false | |||||
} | } | ||||
}; | }; | ||||
/** | /** | ||||
* Adds an array of elements to the map. | * Adds an array of elements to the map. | ||||
*/ | */ | ||||
function addElements(elements) | function addElements(elements) | ||||
{ | { | ||||
▲ Show 20 Lines • Show All 50 Lines • ▼ Show 20 Lines | |||||
/** | /** | ||||
* Choose starting locations for all players. | * Choose starting locations for all players. | ||||
* | * | ||||
* @param {string} type - "radial", "line", "stronghold", "randomGroup" | * @param {string} type - "radial", "line", "stronghold", "randomGroup" | ||||
* @param {number} distance - radial distance from the center of the map | * @param {number} distance - radial distance from the center of the map | ||||
* @param {number} groupedDistance - space between players within a team | * @param {number} groupedDistance - space between players within a team | ||||
* @param {number} startAngle - determined by the map that might want to place something between players | * @param {number} startAngle - determined by the map that might want to place something between players | ||||
* @param {function} createBaseFunc - function to create a base for a single player (optional). | |||||
* @returns {Array|undefined} - If successful, each element is an object that contains id, angle, x, z for each player | * @returns {Array|undefined} - If successful, each element is an object that contains id, angle, x, z for each player | ||||
*/ | */ | ||||
function createBasesByPattern(type, distance, groupedDistance, startAngle) | function createBasesByPattern(type, distance, groupedDistance, startAngle, createBasesFunc = createBases) | ||||
Not Done Inline ActionsThis is an unneeded indirection I am not a fan of, Bring your own placement logic is just going to cause tons of almost duplicated functions. Giving too much flexibility in these APIs is not necessary because there are only a limited number of viable choices. This callback would just be a proxy to the rmgen base placement function. Another option is to not use rmgen2 base placement function if the desired base placement is actually rmgen anyway. And instead just use the player position calculation function instead, which should fit in nicely with rmgen base placement. lyv: This is an unneeded indirection I am not a fan of, Bring your own placement logic is just going… | |||||
{ | { | ||||
return createBases(...g_PlayerbaseTypes[type].getPosition(distance, groupedDistance, startAngle), g_PlayerbaseTypes[type].walls); | return createBasesFunc(...g_PlayerbaseTypes[type].getPosition(distance, groupedDistance, startAngle), g_PlayerbaseTypes[type].walls); | ||||
} | } | ||||
function createBases(playerIDs, playerPosition, walls) | function createBases(playerIDs, playerPosition, walls) | ||||
{ | { | ||||
g_Map.log("Creating bases"); | g_Map.log("Creating bases"); | ||||
for (let i = 0; i < getNumPlayers(); ++i) | for (let i = 0; i < getNumPlayers(); ++i) | ||||
createBase(playerIDs[i], playerPosition[i], walls); | createBase(playerIDs[i], playerPosition[i], walls); | ||||
▲ Show 20 Lines • Show All 175 Lines • Show Last 20 Lines |
Wildfire Games · Phabricator
The distance is better suited for here. For consistency and general separation of concerns. And the multiarc function should respect the provided distance.
I am assuming it's because the arc function is using angles to define separation.