public static void SpawnAmbientPlants(BiomeConfiguration biomeConfig) { var af = GameObject.Find("AmbientFlowers") != null?GameObject.Find("AmbientFlowers") : CreateParent(); var parent = af.transform; foreach (var ambientPlantConfiguration in biomeConfig.AmbientPlants) { for (int i = 0; i < ambientPlantConfiguration.Amount; i++) { var pos = new Vector3(Random.Range(0, Map.Instance.MapData.Chunks.GetLength(0) * Chunk.ChunkSize), 1000, Random.Range(0, Map.Instance.MapData.Chunks.GetLength(0) * Chunk.ChunkSize)); RaycastHit hit; Physics.Raycast(new Ray(pos, Vector3.down), out hit, float.PositiveInfinity); if (hit.collider.tag.Equals("Chunk")) { var start = hit.point; var c = Map.Instance.MapData.Chunks[(int)start.x / Chunk.ChunkSize, (int)start.y / Chunk.ChunkSize, (int)start.z / Chunk.ChunkSize]; if (c == null) { continue; } var mb = MultiblockLoader.LoadMultiblock("Plants/Ambient/" + ambientPlantConfiguration.Name, new Vector3(start.x - 0.5f, start.y, start.z - 0.5f), parent, 1); c.RegisterSmallMultiblock(mb, new Vector3((int)start.x, (int)start.y, (int)start.z) - c.Position); } } } }
void Start() { if (!active) { return; } Import(transform.GetChild(0), FileName ?? "flower.txt"); var mb = MultiblockLoader.LoadMultiblock(FileName.Split('.')[0]); mb.transform.localScale = mb.transform.localScale * 10 / FractionValue; }
private void UpdateModel() { if (Crop != null) { Object.Destroy(Crop.gameObject); } if (Stage != 0) { Crop = MultiblockLoader.LoadMultiblock(Type.GrowStages[_stage], Position + new Vector3(-0.5f, 0.5f, -0.5f), _parent, 1); } }
void Update() { if (TextFile == null || oldFileName == TextFile.name) { return; } oldFileName = TextFile.name; var path = AssetDatabase.GetAssetPath(TextFile); if (path.Contains("Imported")) { path = path.Substring(path.IndexOf("Imported", StringComparison.InvariantCulture) + "Imported/".Length); } if (path.Contains(".txt")) { path = path.Replace(".txt", ""); } var tra = MultiblockLoader.LoadMultiblock(path, Vector3.zero, transform, 1).transform; MultiblockLoader.CleanupCache(); }