Secure your code as it's written. Use Snyk Code to scan source code in minutes - no build needed - and fix issues immediately.
constructor(game: Game, simulation: BrowserSimulation) {
super(game, simulation);
// Generate a context group that will render the user's inventory for this simulation.
this._contextGroup = new InventoryContextGroup3D(
this,
this.simulation.helper.userBot,
'player',
this.decoratorFactory
);
const calc = this.simulation.helper.createContext();
let gridScale = calculateGridScale(calc, null);
this.grid3D = new PlayerGrid3D(gridScale).showGrid(false);
this.grid3D.useAuxCoordinates = true;
this.add(this.grid3D);
}
private _setupGrid(calc: BotCalculationContext) {
if (this.grid3D) {
this.remove(this.grid3D);
}
let gridScale = calculateGridScale(
calc,
this._contextGroup ? this._contextGroup.bot : null
);
this.grid3D = new PlayerGrid3D(gridScale).showGrid(false);
this.grid3D.useAuxCoordinates = true;
}
fileUpdated(calc: FileCalculationContext): void {
const gridScale = calculateGridScale(
calc,
this.file3D.contextGroup ? this.file3D.contextGroup.file : null
);
const scale = calculateScale(calc, this.file3D.file, gridScale);
this.file3D.display.scale.set(scale.x, scale.y, scale.z);
}
bots.forEach(bot => {
if (isUserBot(bot.bot)) {
return;
}
let localPosition = calculateGridTileLocalCenter(
calculateBotValue(calc, bot.bot, bot.context + 'X'),
calculateBotValue(calc, bot.bot, bot.context + 'Y'),
calculateBotValue(calc, bot.bot, bot.context + 'Z'),
calculateGridScale(calc, bot.contextGroup.bot)
);
let axial: Axial = realPosToGridPos(
new Vector2(localPosition.x, localPosition.z),
scale
);
const hexgrid = this.hexGrid.addAt(axial);
hexgrid.height =
centerHeight || defaultHeight || DEFAULT_WORKSPACE_HEIGHT;
});
botUpdated(calc: BotCalculationContext): void {
const userContext = this.bot3D.context;
if (userContext) {
const scale = calculateGridScale(calc, this.bot3D.contextGroup.bot);
const currentGridPos = getBotPosition(
calc,
this.bot3D.bot,
this.bot3D.context
);
const currentHeight = calculateVerticalHeight(
calc,
this.bot3D.bot,
this.bot3D.context,
scale
);
this._nextPos = calculateObjectPositionInGrid(
calc,
this.bot3D,
scale
);