public Material Apply(CelestialBody cb, MaterialManager mat, Shader shader, bool updateOrigin, bool subPQS) { KSPLog.print("Applying PQS Material Manager!"); material = new Material(shader); if (mat != null) { mat.ApplyMaterialProperties(material); } this.updateOrigin = updateOrigin; this.subPQS = subPQS; PQS pqs = null; body = cb; if (cb != null && cb.pqsController != null) { pqs = cb.pqsController; } else { KSPLog.print("No PQS!"); } if (pqs != null) { this.sphere = pqs; this.transform.parent = pqs.transform; this.requirements = PQS.ModiferRequirements.Default; this.modEnabled = true; this.order += 10; this.transform.localPosition = Vector3.zero; this.transform.localRotation = Quaternion.identity; this.transform.localScale = Vector3.one; } if (this.sphere != null && this.sphere.quads != null) { foreach (PQ pq in this.sphere.quads) { ApplyToQuadMaterials(pq); } } if (subPQS && this.sphere != null && this.sphere.ChildSpheres != null && this.sphere.ChildSpheres.Length > 0) { GameObject go = new GameObject(); MaterialPQS ChildPQS = go.AddComponent <MaterialPQS>(); ChildPQS.updateOrigin = false; ChildPQS.subPQS = false; ChildPQS.isOcean = true; pqs = this.sphere.ChildSpheres[0]; if (pqs != null) { ChildPQS.sphere = pqs; ChildPQS.transform.parent = pqs.transform; ChildPQS.requirements = PQS.ModiferRequirements.Default; ChildPQS.modEnabled = true; ChildPQS.order += 10; ChildPQS.transform.localPosition = Vector3.zero; ChildPQS.transform.localRotation = Quaternion.identity; ChildPQS.transform.localScale = Vector3.one; ChildPQS.material = material; } if (ChildPQS.sphere != null && ChildPQS.sphere.quads != null) { foreach (PQ pq in this.sphere.quads) { ApplyToQuadMaterials(pq); } } } GameEvents.OnPQSCityLoaded.Add(PQSLoaded); return(material); }
public Material Apply(CelestialBody cb, MaterialManager mat, Shader shader, bool updateOrigin, bool subPQS) { KSPLog.print("Applying PQS Material Manager!"); material = new Material( shader); if (mat != null) { mat.ApplyMaterialProperties(material); } this.updateOrigin = updateOrigin; this.subPQS = subPQS; PQS pqs = null; body = cb; if (cb != null && cb.pqsController != null) { pqs = cb.pqsController; } else { KSPLog.print("No PQS!"); } if (pqs != null) { this.sphere = pqs; this.transform.parent = pqs.transform; this.requirements = PQS.ModiferRequirements.Default; this.modEnabled = true; this.order += 10; this.transform.localPosition = Vector3.zero; this.transform.localRotation = Quaternion.identity; this.transform.localScale = Vector3.one; } if (this.sphere != null && this.sphere.quads != null) foreach (PQ pq in this.sphere.quads) { ApplyToQuadMaterials(pq); } if(subPQS && this.sphere != null && this.sphere.ChildSpheres != null && this.sphere.ChildSpheres.Length > 0) { GameObject go = new GameObject(); MaterialPQS ChildPQS = go.AddComponent<MaterialPQS>(); ChildPQS.updateOrigin = false; ChildPQS.subPQS = false; ChildPQS.isOcean = true; pqs = this.sphere.ChildSpheres[0]; if (pqs != null) { ChildPQS.sphere = pqs; ChildPQS.transform.parent = pqs.transform; ChildPQS.requirements = PQS.ModiferRequirements.Default; ChildPQS.modEnabled = true; ChildPQS.order += 10; ChildPQS.transform.localPosition = Vector3.zero; ChildPQS.transform.localRotation = Quaternion.identity; ChildPQS.transform.localScale = Vector3.one; ChildPQS.material = material; } if (ChildPQS.sphere != null && ChildPQS.sphere.quads != null) foreach (PQ pq in this.sphere.quads) { ApplyToQuadMaterials(pq); } } GameEvents.OnPQSCityLoaded.Add(PQSLoaded); return material; }