MK5LPGJ3HSEHGWOZFPY6QMFVMHWRXQZ6PUQEXFWNOBAK4SUQT56AC
KREAAF4L5GTC6F55ZKEGBZ43DASWW4JBAYLR3GKI53VQY4FLJELQC
EMED7UWAGESRTWJJWVXRL27O4XMBGZDDAU4LNVF3MQAYKFKRDNXQC
AAKN4XJLZ2GARZMUFYX3CJZKYHTRRZDYNTFRLMY7VPAY7K6W4N3QC
YJ3YEICSBUHMDVJB6W3ZOOVWLTAXRDCIKOGNN6HRP6N3HWQTDGVAC
T6RGFAV3VFISSGKMFKK544MGGXCURAO4ARG22R5O75UBUKPHFM5AC
ZHOSSPNKGFIKSFPDXCGLMSYMMX2J433VU2BUUWBKUH7TOLQUBSPQC
// determine which nodes we want to throw out -
let allNodes: Vector2[] = [];
// determine which nodes we want to throw out - also keep 4way rotational symmetry
let droppedNodes: HashSet<Vector2> = new HashSet();
allNodes.push(new Vector2(i, j))
if (i === 0 && j === 0) {
continue;
}
if (squirrel3(this.id + i * Chunk.CHUNK_DIM + j) / INTMAX32 < Chunk.DROP_NODES_CHANCE / 4) {
droppedNodes.put(new Vector2(i, j));
droppedNodes.put(new Vector2(j, -i));
droppedNodes.put(new Vector2(-i, -j));
droppedNodes.put(new Vector2(-j, i));
}
// drop some of them...?
for (let i = 0; i < allNodes.length; i++) {
if (squirrel3(this.id + i) / INTMAX32 < 0.9 || allNodes[i].x == 0 && allNodes[i].y == 0) {
this.nodes.push(allNodes[i]);
for (let i = -Chunk.CHUNK_HALF_DIM; i <= Chunk.CHUNK_HALF_DIM; i++) {
for (let j = -Chunk.CHUNK_HALF_DIM; j <= Chunk.CHUNK_HALF_DIM; j++) {
let loc = new Vector2(i, j);
if (!droppedNodes.get(loc)) {
this.nodes.push(new Vector2(i, j));
}
import * as Pixi from "pixi.js";
import { Vector2 } from "../lib/util/geometry/vector2";
import { squirrel3 } from "../lib/util/random";
import { Chunk, RenderedChunk } from "./Chunk";
export class ZLevel {
private id: number;
public z: number;
public chunks: Chunk[] = []
constructor(seed: number, zIndex: number) {
this.z = zIndex;
this.id = squirrel3(seed + this.z);
// pregenerate stuff
for (let i = -3; i <= 3; i++) {
for (let j = -3; j <= 3; j++) {
this.chunks.push(new Chunk(this.id, new Vector2(i, j)));
}
}
}
}
export class RenderedZLevel {
public zLevel!: ZLevel;
public container: Pixi.Container;
constructor(zLevel: ZLevel, onNodeFocus: Function) {
this.zLevel = zLevel;
this.container = new Pixi.Container();
// this.actionStage.addChild(chunksContainer);
// this.container.x = this.app.screen.width/2;
// this.container.y = this.app.screen.height/2;
// this.onResize.push(() => {
// chunksContainer.x = this.app.screen.width/2;
// chunksContainer.y = this.app.screen.height/2;
// })
for (let chunk of this.zLevel.chunks) {
this.container.addChild(
new RenderedChunk(chunk, onNodeFocus).container
)
}
}
}