1
0
mirror of https://github.com/tobspr/shapez.io.git synced 2025-06-13 13:04:03 +00:00

fix windmill shape generation - keep old fan distribution

This commit is contained in:
noctilucentgames 2020-10-26 23:16:35 +00:00
parent d4666a99b8
commit 532ac0c635

View File

@ -198,35 +198,56 @@ export class MapChunk {
weights[enumSubShape.windmill] = 0; weights[enumSubShape.windmill] = 0;
} }
if (distanceToOriginInChunks < 10) {
// Initial chunk patches always have the same shape
const subShape = this.internalGenerateRandomSubShape(rng, weights);
subShapes = [subShape, subShape, subShape, subShape];
} else if (distanceToOriginInChunks < 15) {
// Later patches can also have mixed ones
const subShapeA = this.internalGenerateRandomSubShape(rng, weights);
const subShapeB = this.internalGenerateRandomSubShape(rng, weights);
subShapes = [subShapeA, subShapeA, subShapeB, subShapeB];
} else {
// Finally there is a mix of everything
subShapes = [
this.internalGenerateRandomSubShape(rng, weights),
this.internalGenerateRandomSubShape(rng, weights),
this.internalGenerateRandomSubShape(rng, weights),
this.internalGenerateRandomSubShape(rng, weights)
];
}
// Makes sure windmills never spawn as whole // Makes sure windmills never spawn as whole
let windmillCount; let windmillCount = 0;
do { for (let i = 0; i < subShapes.length; ++i) {
windmillCount = 0; if (subShapes[i] === enumSubShape.windmill) {
if (distanceToOriginInChunks < 10) { ++windmillCount;
// Initial chunk patches always have the same shape }
weights[enumSubShape.windmill] = 0; // no whole windmills }
if (windmillCount > 1) {
weights[enumSubShape.windmill] = 0;
if (distanceToOriginInChunks < 15) {
// Turn left or right subshapes into a random type that is not windmill
const subShape = this.internalGenerateRandomSubShape(rng, weights); const subShape = this.internalGenerateRandomSubShape(rng, weights);
subShapes = [subShape, subShape, subShape, subShape]; if (rng.next() < 0.5) {
} else if (distanceToOriginInChunks < 15) { subShapes[0] = subShape;
// Later patches can also have mixed ones subShapes[1] = subShape;
const subShapeA = this.internalGenerateRandomSubShape(rng, weights); } else {
const subShapeB = this.internalGenerateRandomSubShape(rng, weights); subShapes[2] = subShape;
subShapes = [subShapeA, subShapeA, subShapeB, subShapeB]; subShapes[3] = subShape;
} else {
// Finally there is a mix of everything
subShapes = [
this.internalGenerateRandomSubShape(rng, weights),
this.internalGenerateRandomSubShape(rng, weights),
this.internalGenerateRandomSubShape(rng, weights),
this.internalGenerateRandomSubShape(rng, weights),
];
}
for (let i = 0; i < subShapes.length; ++i) {
if (subShapes[i] === enumSubShape.windmill) {
++windmillCount;
} }
} else {
// Turn subshape at 2 random positions into a random type that is not windmill
let quad1 = rng.nextIntRange(0,3);
let quad2 = rng.nextIntRange(0,2);
if (quad2 >= quad1)
{
++quad2;
}
subShapes[quad1] = this.internalGenerateRandomSubShape(rng, weights);
subShapes[quad2] = this.internalGenerateRandomSubShape(rng, weights);
} }
} while (windmillCount > 2); }
const definition = this.root.shapeDefinitionMgr.getDefinitionFromSimpleShapes(subShapes); const definition = this.root.shapeDefinitionMgr.getDefinitionFromSimpleShapes(subShapes);
this.internalGeneratePatch( this.internalGeneratePatch(