public static GameObject CreateDaggerfallBlockGameObject(string blockName, Transform parent) { if (string.IsNullOrEmpty(blockName)) { return(null); } blockName = blockName.ToUpper(); GameObject go = null; if (blockName.EndsWith(".RMB")) { go = RMBLayout.CreateGameObject(blockName); } else if (blockName.EndsWith(".RDB")) { go = RDBLayout.CreateGameObject(blockName, false); } else { return(null); } if (parent) { go.transform.parent = parent; } return(go); }
/// <summary> /// Layout RMB block gamne object from name only. /// This will be missing information like building data and should only be used standalone. /// </summary> public static GameObject CreateRMBBlockGameObject( string blockName, int layoutX, int layoutY, bool addGroundPlane = true, DaggerfallRMBBlock cloneFrom = null, DaggerfallBillboardBatch natureBillboardBatch = null, DaggerfallBillboardBatch lightsBillboardBatch = null, DaggerfallBillboardBatch animalsBillboardBatch = null, TextureAtlasBuilder miscBillboardAtlas = null, DaggerfallBillboardBatch miscBillboardBatch = null, ClimateNatureSets climateNature = ClimateNatureSets.TemperateWoodland, ClimateSeason climateSeason = ClimateSeason.Summer) { // Get block data from name DFBlock blockData; if (!RMBLayout.GetBlockData(blockName, out blockData)) { return(null); } // Create base object from block data GameObject go = CreateRMBBlockGameObject( blockData, layoutX, layoutY, addGroundPlane, cloneFrom, natureBillboardBatch, lightsBillboardBatch, animalsBillboardBatch, miscBillboardAtlas, miscBillboardBatch, climateNature, climateSeason); return(go); }
/// <summary> /// Layout a complete RMB block game object. /// Can be used standalone or as part of a city build. /// </summary> public static GameObject CreateRMBBlockGameObject( string blockName, bool addGroundPlane = true, DaggerfallRMBBlock cloneFrom = null, DaggerfallBillboardBatch natureBillboardBatch = null, DaggerfallBillboardBatch lightsBillboardBatch = null, DaggerfallBillboardBatch animalsBillboardBatch = null, TextureAtlasBuilder miscBillboardAtlas = null, DaggerfallBillboardBatch miscBillboardBatch = null, ClimateNatureSets climateNature = ClimateNatureSets.TemperateWoodland, ClimateSeason climateSeason = ClimateSeason.Summer) { // Get DaggerfallUnity DaggerfallUnity dfUnity = DaggerfallUnity.Instance; if (!dfUnity.IsReady) { return(null); } // Create base object DFBlock blockData; GameObject go = RMBLayout.CreateBaseGameObject(blockName, out blockData, cloneFrom); // Create flats node GameObject flatsNode = new GameObject("Flats"); flatsNode.transform.parent = go.transform; // Create lights node GameObject lightsNode = new GameObject("Lights"); lightsNode.transform.parent = go.transform; // If billboard batching is enabled but user has not specified // a batch, then make our own auto batch for this block bool autoLightsBatch = false; bool autoNatureBatch = false; bool autoAnimalsBatch = false; if (dfUnity.Option_BatchBillboards) { if (natureBillboardBatch == null) { autoNatureBatch = true; int natureArchive = ClimateSwaps.GetNatureArchive(climateNature, climateSeason); natureBillboardBatch = GameObjectHelper.CreateBillboardBatchGameObject(natureArchive, flatsNode.transform); } if (lightsBillboardBatch == null) { autoLightsBatch = true; lightsBillboardBatch = GameObjectHelper.CreateBillboardBatchGameObject(TextureReader.LightsTextureArchive, flatsNode.transform); } if (animalsBillboardBatch == null) { autoAnimalsBatch = true; animalsBillboardBatch = GameObjectHelper.CreateBillboardBatchGameObject(TextureReader.AnimalsTextureArchive, flatsNode.transform); } } // Layout light billboards and gameobjects RMBLayout.AddLights(ref blockData, flatsNode.transform, lightsNode.transform, lightsBillboardBatch); // Layout nature billboards RMBLayout.AddNatureFlats(ref blockData, flatsNode.transform, natureBillboardBatch, climateNature, climateSeason); // Layout all other flats RMBLayout.AddMiscBlockFlats(ref blockData, flatsNode.transform, animalsBillboardBatch, miscBillboardAtlas, miscBillboardBatch); // Add ground plane if (addGroundPlane) { RMBLayout.AddGroundPlane(ref blockData, go.transform); } // Apply auto batches if (autoNatureBatch) { natureBillboardBatch.Apply(); } if (autoLightsBatch) { lightsBillboardBatch.Apply(); } if (autoAnimalsBatch) { animalsBillboardBatch.Apply(); } return(go); }