當前位置: 首頁>>代碼示例>>TypeScript>>正文


TypeScript TileHelpers.getType函數代碼示例

本文整理匯總了TypeScript中utilities/TileHelpers.getType函數的典型用法代碼示例。如果您正苦於以下問題:TypeScript getType函數的具體用法?TypeScript getType怎麽用?TypeScript getType使用的例子?那麽, 這裏精選的函數代碼示例或許可以為您提供幫助。


在下文中一共展示了getType函數的7個代碼示例,這些例子默認根據受歡迎程度排序。您可以為喜歡或者感覺有用的代碼點讚,您的評價將有助於係統推薦出更棒的TypeScript代碼示例。

示例1: update

	public update(position: IVector2, tile: ITile) {
		this.position = new Vector3(position.x, position.y, localPlayer.z);
		this.tile = tile;

		const terrainType = TerrainType[TileHelpers.getType(this.tile!)];
		if (terrainType === this.terrainType) return;

		this.terrainType = terrainType;
		this.dropdownTerrainType.refresh();
		this.setShouldLog();

		this.checkButtonTilled.toggle(terrainDescriptions[TileHelpers.getType(tile)]!.tillable === true)
			.refresh();

		return this;
	}
開發者ID:WaywardGame,項目名稱:developertools,代碼行數:16,代碼來源:Terrain.ts

示例2: changeTerrain

	@Bound
	private changeTerrain(_: any, terrain: TerrainType) {
		if (terrain === TileHelpers.getType(this.tile)) {
			return;
		}

		ActionExecutor.get(ChangeTerrain).execute(localPlayer, terrain, this.position);
		this.update(this.position, this.tile);
	}
開發者ID:WaywardGame,項目名稱:developertools,代碼行數:9,代碼來源:Terrain.ts

示例3: tuple

				.setRefreshMethod(() => ({
					defaultOption: this.tile ? TileHelpers.getType(this.tile) : TerrainType.Dirt,
					options: Enums.values(TerrainType)
						.filter(terrain => terrain)
						.map(terrain => tuple(terrain, new Translation(Dictionary.Terrain, terrain).inContext(TextContext.Title)))
						.collect(Collectors.toArray)
						.sort(([, t1], [, t2]) => Text.toString(t1).localeCompare(Text.toString(t2)))
						.values()
						.map(([id, t]) => tuple(id, (option: Button) => option.setText(t))),
				}))
開發者ID:WaywardGame,項目名稱:developertools,代碼行數:10,代碼來源:Terrain.ts

示例4: onMove

	/**
	 * Called when a player moves.
	 * @param player The player that moved.
	 * @param nextX The new `x` position of the player.
	 * @param nextY The new `y` position of the player.
	 * @param tile The tile that the player is moving to.
	 * @param direction The direction the player is moving in.
	 * 
	 * @returns `false` to cancel the movement, or `undefined` to allow the game (or other mods) to decide. 
	 * Our implementation always returns `undefined` — we just want to do some stuff when a player moves, not cancel it.
	 * 
	 * For more information on this hook, see: https://waywardgame.github.io/modules/ihookhost.html#onmove
	 */
	@HookMethod
	public onMove(player: IPlayer, nextX: number, nextY: number, tile: ITile, direction: Direction): boolean | undefined {
		const tileType = TileHelpers.getType(tile);

		// we send a message to this player with the type "stat" (orange)
		player.messages.type(MessageType.Stat)
			// we first list which message we're sending, then we list all the arguments we're giving to that message.
			// in this case, the only argument we're giving it is the name of the tile we're standing on
			.send(this.messageHelloTerrain, tileType);

		return undefined;
	}
開發者ID:WaywardGame,項目名稱:helloworld,代碼行數:25,代碼來源:helloworld.ts

示例5: function

export default function (x: number, y: number, z: number, tilled: boolean) {
	const tile = game.getTile(x, y, z);

	const tileType = TileHelpers.getType(tile);
	if (!terrainDescriptions[tileType]!.tillable) {
		return;
	}

	const tileData = game.getOrCreateTileData(x, y, z);
	if (tileData.length === 0) {
		tileData.push({
			type: tileType,
			tilled,
		});

	} else {
		tileData[0].tilled = tilled;
	}

	TileHelpers.setTilled(tile, tilled);

	world.updateTile(x, y, z, tile);
}
開發者ID:WaywardGame,項目名稱:developertools,代碼行數:23,代碼來源:SetTilled.ts

示例6: onPlayerDeath

	@HookMethod
	public onPlayerDeath(player: IPlayer): boolean | undefined {
		// Drop items
		itemManager.placeItemsAroundLocation(player.inventory, player.x, player.y, player.z);

		// Randomize skills a bit
		const skills = Enums.values(SkillType);
		for (const skillType of skills) {
			let newSkill = Math2.roundNumber(Random.float() * 9 - 5 + localPlayer.getSkillCore(skillType), 1);
			if (newSkill > 100) {
				newSkill = 100;

			} else if (newSkill < 0) {
				newSkill = 0;
			}

			localPlayer.setSkillCore(skillType, newSkill);
		}

		// Randomize stats a bit
		const health = player.getStat(Stat.Health);
		const stamina = player.getStat(Stat.Stamina);
		const hunger = player.getStat(Stat.Hunger);
		const thirst = player.getStat(Stat.Thirst);

		player.setStatMax(Stat.Health, health.max + Math.floor(Random.float() * 4 - 2));
		player.setStatMax(Stat.Stamina, stamina.max + Math.floor(Random.float() * 4 - 2));
		player.setStatMax(Stat.Hunger, hunger.max + Math.floor(Random.float() * 4 - 2));
		player.setStatMax(Stat.Thirst, thirst.max + Math.floor(Random.float() * 4 - 2));

		// Reset stats
		health.changeTimer = health.nextChangeTimer;
		stamina.changeTimer = stamina.nextChangeTimer;
		hunger.changeTimer = hunger.nextChangeTimer;
		thirst.changeTimer = thirst.nextChangeTimer;

		player.setStat(health, health.max);
		player.setStat(stamina, stamina.max);
		player.setStat(hunger, hunger.max);
		player.setStat(thirst, thirst.max);

		player.setStatus(StatusType.Bleeding, false, StatusEffectChangeReason.Passed);
		player.setStatus(StatusType.Burned, false, StatusEffectChangeReason.Passed);
		player.setStatus(StatusType.Poisoned, false, StatusEffectChangeReason.Passed);

		player.equipped = {};
		player.isMoving = false;
		player.isMovingClientside = false;
		player.movementComplete = false;
		player.movementCompleteZ = undefined;
		player.movementProgress = 1;
		player.raft = undefined;
		player.restData = undefined;
		player.swimming = false;
		player.stopNextMovement = false;

		// Random character
		player.customization = {
			hairStyle: HairStyle[Enums.getRandom(HairStyle)] as keyof typeof HairStyle,
			hairColor: HairColor[Enums.getRandom(HairColor)] as keyof typeof HairColor,
			skinColor: SkinColor[Enums.getRandom(SkinColor)] as keyof typeof SkinColor
		};

		// Random spawn
		let xTry: number;
		let yTry: number;
		while (true) {
			xTry = Math.floor(Random.float() * 400 + 50);
			yTry = Math.floor(Random.float() * 400 + 50);
			if (TileHelpers.isOpenTile({ x: xTry, y: yTry, z: WorldZ.Overworld }, game.getTile(xTry, yTry, WorldZ.Overworld))) {
				player.x = xTry;
				player.y = yTry;
				player.fromX = xTry;
				player.fromY = yTry;
				break;
			}
		}

		// Always make the player go to overworld
		player.z = WorldZ.Overworld;

		// Effects and messages
		player.messages.type(MessageType.Stat)
			.send(this.reincarnateMessage);

		player.updateTablesAndWeight();
		player.updateStatsAndAttributes();

		player.tick();

		player.addDelay(Delay.LongPause);

		// Start swimming if spawning in water
		const spawnedTile = game.getTile(player.x, player.y, player.z);
		const tileType = TileHelpers.getType(spawnedTile);
		if (Terrains[tileType].water) {
			player.swimming = true;
		}

		game.updateView(RenderSource.Mod, true);
//.........這裏部分代碼省略.........
開發者ID:WaywardGame,項目名稱:reincarnate,代碼行數:101,代碼來源:reincarnate.ts

示例7: getTabTranslation

	@Bound
	public getTabTranslation() {
		return this.tile && translation(DebugToolsTranslation.InspectTerrain)
			.get(new Translation(Dictionary.Terrain, TileHelpers.getType(this.tile)).inContext(TextContext.Title));
	}
開發者ID:WaywardGame,項目名稱:developertools,代碼行數:5,代碼來源:Terrain.ts


注:本文中的utilities/TileHelpers.getType函數示例由純淨天空整理自Github/MSDocs等開源代碼及文檔管理平台,相關代碼片段篩選自各路編程大神貢獻的開源項目,源碼版權歸原作者所有,傳播和使用請參考對應項目的License;未經允許,請勿轉載。