private void updateControlPlayerBlockProperties(BlockProperties properties, IBlock block = null) { controlPlayer.buildingMaterial = properties; controlPlayer.buildTile = properties.getID(); controlPlayer.buildingVariations = properties.getVariations(); controlPlayer.buildingVariationIndex = ModUtils.getVariationIndex(block); if (block != null && (tempBlockDataTextureVariant = block.getMeta<BlockDataTextureVariant>()) != null) { controlPlayer.buildingPillarless = tempBlockDataTextureVariant.checkVariant(TextureVariant.Pillar); controlPlayer.buildingTrimless = tempBlockDataTextureVariant.checkVariant(TextureVariant.Trimless); } else { controlPlayer.buildingPillarless = false; controlPlayer.buildingTrimless = false; } }
public override void OnUpdate() { if (isScrollOverride && !isScrolling) { isScrollOverride = false; } if (Time.timeSinceLevelLoad > 12f && doApplyPreferences) { doApplyPreferences = false; foreach (ALivingEntity entity in worldManager.PlayerFaction.units) { applyPlayerPreferences(entity); } } if (doSaveGame || doSaveBackup) { doSaveGame = false; if (Time.timeSinceLevelLoad > 12f) { worldManager.SaveGame(); if (doSaveBackup) { doSaveBackup = false; if (!modSettings.isAutoBackupsEnabled) { GameSaveService.SaveGameInfo saveGameInfo = gameSaveService.getSaveGameInfoFromSettlementName(worldManager.settlementName); gameSaveService.createBackup(saveGameInfo); log("Backup saved for: " + saveGameInfo.Name); } } } else log("Unable to save. Press play until save button is visible then try again."); } if (modSettings.isCreativeEnabled) { if (doCreateBlocks || doReplaceBlocks) { selectedBlockType = controlPlayer.buildingMaterial; if (selectedBlockType.getVariations() != null) { selectedBlockData = selectedBlockType.getVariations()[controlPlayer.buildingVariationIndex][0]; } else { BlockDataTextureVariant textureData = new BlockDataTextureVariant(TextureVariant.None); textureData.setVariant(TextureVariant.Pillar, controlPlayer.buildingPillarless); textureData.setVariant(TextureVariant.Trimless, controlPlayer.buildingTrimless); selectedBlockData = textureData; } } if (doBuildStructures) { doBuildStructures = false; controlPlayer.structures.Where(s => !s.isBuilt).ToList() .ForEach(s => buildingService.buildStructure(ref s, worldManager.PlayerFaction)); } else if (doReplaceBlocks) { doReplaceBlocks = false; buildingService.replaceBlocksInSelection(selectedBlockType, selectedBlockData); } else if (doSmoothTerrain) { doSmoothTerrain = false; buildingService.smoothBlocksInSelection(); } else if (doCreateBlocks) { doCreateBlocks = false; buildingService.buildBlocksInSelection(selectedBlockType, selectedBlockData); } else if (doRemoveBlocks) { doRemoveBlocks = false; buildingService.removeBlocksInSelection(); } else if (doRemoveTrees) { doRemoveTrees = false; buildingService.removeSelectedTrees(); buildingService.removeSelectedShrubs(); } else if (doRemoveAllTrees) { doRemoveAllTrees = false; buildingService.removeAllTreeItems(); controlPlayer.CancelDesigning(true); } else if (doPlaceHuman) { doPlaceHuman = false; if (isMouseInWorld(out mouseWorldPosition)) { unitService.addHuman(selectedUnitType, mouseWorldPosition, autoAccept: true); } } else if (doPlaceEnemy) { doPlaceEnemy = false; if (isMouseInWorld(out mouseWorldPosition)) { unitService.addEnemy(selectedEnemyType, mouseWorldPosition); } } else if (doPlaceAnimal) { doPlaceAnimal = false; if (isMouseInWorld(out mouseWorldPosition)) { unitService.addAnimal(selectedAnimalType, mouseWorldPosition); } } else if (doRemoveEntity) { doRemoveEntity = false; if (UnitService.isFriendly(selectedEntity) && playerFactionUnitCount <= 1) { log("Unable to remove player unit. There must be at least one unit in the player faction."); return; } selectedEntity.Destroy(); } else if (doSetPlayerUnitSettings) { doSetPlayerUnitSettings = false; if (isPlayableUnitSelected) { PlayerUnitSettings.setPlayerUnitSettings(playerUnitTraitSettings, selectedUnit, UnitTrait.List); } } else if (isPlayableUnitSelected) { PlayerUnitSettings.updatePlayerUnitSettings(ref playerUnitTraitSettings, selectedUnit, UnitTrait.List); } } }