Changeset View
Standalone View
binaries/data/mods/public/maps/random/rmgen/Terrain.js
Context not available. | |||||
* @file A Terrain is a class that modifies an arbitrary property of a given tile. | * @file A Terrain is a class that modifies an arbitrary property of a given tile. | ||||
*/ | */ | ||||
const LOW = 0; | |||||
lyv: Probably the wrong place. But I could not find a better file. | |||||
StanUnsubmitted Not Done Inline ActionsMight be better as g_TexturePriorityHigh/Low ? Stan: Might be better as g_TexturePriorityHigh/Low ?
Might also deserve a comment. | |||||
elexisUnsubmitted Not Done Inline ActionsWhy is it 0 and 1 here but u16 when passing it to the engine? elexis: Why is it 0 and 1 here but u16 when passing it to the engine?
If cpp counterpart supports u16… | |||||
lyvAuthorUnsubmitted Done Inline ActionsThis is for the function parameter. lyv: This is for the function parameter. | |||||
elexisUnsubmitted Not Done Inline ActionsBut (same question)? elexis: But (same question)? | |||||
lyvAuthorUnsubmitted Not Done Inline ActionsWell, I could just use the string "HIGH" and "LOW" lyv: Well, I could just use the string "HIGH" and "LOW" | |||||
elexisUnsubmitted Not Done Inline ActionsWhy not simply no constants and having each texture define a number if it wants to use priorities (0 otherwise)? elexis: Why not simply no constants and having each texture define a number if it wants to use… | |||||
lyvAuthorUnsubmitted Not Done Inline ActionsIf one wants to have a texture submissive around other tiles who also are submissive to some tiles, then the user would have to keep track of each of the tile's priorities and select a number which is less than the priority of those tiles. Which could quickly go out of hand when working with multiple tiles close by having different priorities. lyv: If one wants to have a texture submissive around other tiles who also are submissive to some… | |||||
elexisUnsubmitted Not Done Inline ActionsThe only time I noticed this was in #4816. Maybe it could be used at the shoreline or when drawing paths to ensure that the intended border texture is visible. If we want the priority system, it seems the easiest / most streamlined and most versatile way to mirror the engine as closely as possible. (I still didn't check what the C++ code actually does.) elexis: The only time I noticed this was in #4816. Maybe it could be used at the shoreline or when… | |||||
lyvAuthorUnsubmitted Not Done Inline ActionsWhat if you want the tile to the right to be rendered on top and the tile next to that and so on. It could go up pretty high technically speaking. But logically speaking, it won't probably go higher than 3 as you mentioned. I guess what @FeXoR suggested might work too. Calculating actual values when exporting. lyv: What if you want the tile to the right to be rendered on top and the tile next to that and so… | |||||
elexisUnsubmitted Not Done Inline ActionsIt can also be 4+ by wanting to paint the path-texture always on top, the shore always on top of ground, the cliff texture always on top of the ground, the X always on top of the Z? elexis: It can also be 4+ by wanting to paint the path-texture always on top, the shore always on top… | |||||
FeXoRUnsubmitted Not Done Inline Actionssmiley said: "then the user would have to keep track of each of the tile's priorities" (Is it really needed to give "terrains" (texture+entity/actor pairs) priorities? I really think that should be a property of the "terrain only" objects so the same "texture+priority" can be used in multiple "terrain"s.) FeXoR: smiley said: "then the user would have to keep track of each of the tile's priorities"
That's… | |||||
lyvAuthorUnsubmitted Not Done Inline ActionsI am not sure how that would work. Each tile should have a priority. Not each texture. One could paint "red" in high position at one place and as low on another. I suppose this array should be storing tile coords or something. Which would be way less memory efficent and slower. Int16Array is faster than an Array of Uint16Arrays. lyv: I am not sure how that would work. Each tile should have a priority. Not each texture. One… | |||||
FeXoRUnsubmitted Not Done Inline ActionsIn a texturePriorityList IDs could be stored I'm not in general opposed to a cell object but if we add it it should be extendable from within a map script (and I think that's not going to work without headaches?). Otherwise I'm for one map for each cell property (like it's now). But in case of texture priority we only need the property at map export so no need to add and update such a map during map generation. FeXoR: In a texturePriorityList IDs could be stored
In the IDToName array texture strings are stored… | |||||
elexisUnsubmitted Not Done Inline ActionsSetting the priority as an argument of texture / Terrain creation sounds easy to handle for new maps and probably sufficient to gain the benefit at places where textures overlap? The alternative would be to pass the priority to the TerrainPainter, but then it seems easy to run into the confusion troubles you mentioned earlier? elexis: Setting the priority as an argument of texture / Terrain creation sounds easy to handle for new… | |||||
elexisUnsubmitted Not Done Inline ActionsCurrently: const tDirt = "medit_dirt_b"; const tDirt2 = "medit_rocks_grass"; const tDirt3 = "medit_rocks_shrubs"; What I think FeXoR means: const tDirt = "medit_dirt_b"; const tDirt2 = "medit_rocks_grass"; const tDirt3 = "medit_rocks_shrubs"; const tPriorities = [ tDirt, tDirt2, tDirt3 ]; But wouldn't this leave the header cleaner? const tDirt = new Terrain("medit_dirt_b", 0); const tDirt2 = new Terrain("medit_rocks_grass", 1); const tDirt3 = new Terrain("medit_rocks_shrubs", 2); (Just that it would come at the cost of possibly having to update all maps.) elexis: Currently:
```
const tDirt = "medit_dirt_b";
const tDirt2 = "medit_rocks_grass";
const tDirt3 =… | |||||
const HIGH = 1; | |||||
/** | /** | ||||
* SimpleTerrain paints the given texture on the terrain. | * SimpleTerrain paints the given texture on the terrain. | ||||
* | * | ||||
Context not available. | |||||
* Optionally it places an entity on the affected tiles and | * Optionally it places an entity on the affected tiles and | ||||
Not Done Inline ActionsInstead of High and Low being strings might want to use an enum with freeze. Maybe you'll get some perf https://stackoverflow.com/questions/287903/what-is-the-preferred-syntax-for-defining-enums-in-javascript Stan: Instead of High and Low being strings might want to use an enum with freeze. Maybe you'll get… | |||||
Done Inline ActionsPersonally, I dont like the complexity-use ratio of that. But agree for replacing string with a number. lyv: Personally, I dont like the complexity-use ratio of that. But agree for replacing string with a… | |||||
Not Done Inline ActionsSure. Also if someday we have different blends will be easier to implement :) Stan: Sure. Also if someday we have different blends will be easier to implement :) | |||||
* replaces prior entities added by SimpleTerrain on the same tile. | * replaces prior entities added by SimpleTerrain on the same tile. | ||||
*/ | */ | ||||
function SimpleTerrain(texture, templateName = undefined) | function SimpleTerrain(texture, templateName = undefined, priority = HIGH) | ||||
{ | { | ||||
if (texture === undefined) | if (texture === undefined) | ||||
throw new Error("SimpleTerrain: texture not defined"); | throw new Error("SimpleTerrain: texture not defined"); | ||||
Context not available. | |||||
this.texture = texture; | this.texture = texture; | ||||
this.templateName = templateName; | this.templateName = templateName; | ||||
this.priority = priority; | |||||
} | } | ||||
SimpleTerrain.prototype.place = function(position) | SimpleTerrain.prototype.place = function(position) | ||||
Context not available. | |||||
if (this.templateName && g_Map.validTilePassable(position)) | if (this.templateName && g_Map.validTilePassable(position)) | ||||
g_Map.setTerrainEntity(this.templateName, 0, Vector2D.add(position, new Vector2D(0.5, 0.5)), randomAngle()); | g_Map.setTerrainEntity(this.templateName, 0, Vector2D.add(position, new Vector2D(0.5, 0.5)), randomAngle()); | ||||
g_Map.setTexture(position, this.texture); | g_Map.setTexture(position, this.texture, this.priority); | ||||
}; | }; | ||||
/** | /** | ||||
Context not available. |
Probably the wrong place. But I could not find a better file.