private bool startMenuOverlay() { if (!Misc.Parse(SettingsManager.GetValue("ShowInMenu"), true)) { return(false); } var objects = GameObject.FindSceneObjectsOfType(typeof(GameObject)); if (objects.Any(o => o.name == "LoadingBuffer")) { return(false); } var kerbin = objects.OfType <GameObject>().Where(b => b.name == "Kerbin").LastOrDefault(); if (kerbin == null) { Debug.LogWarning("[Kethane] Couldn't find Kerbin!"); return(false); } gameObject.layer = kerbin.layer; gameObject.transform.parent = kerbin.transform; gameObject.transform.localPosition = Vector3.zero; gameObject.transform.localRotation = Quaternion.identity; gameObject.transform.localScale = Vector3.one * 1020; gameObject.renderer.enabled = true; var random = new System.Random(); var colors = new Color32[mesh.vertexCount]; foreach (var cell in grid) { var rand = random.Next(100); Color32 color; if (rand < 16) { color = rand < 4 ? new Color32(21, 176, 26, 255) : colorEmpty; foreach (var neighbor in cell.Neighbors) { if (random.Next(2) < 1) { setCellColor(neighbor, color, colors); } } } else { color = colorUnknown; } setCellColor(cell, color, colors); } mesh.colors32 = colors; return(true); }
private void load(ConfigNode node) { MinRadius = Misc.Parse(node.GetValue("MinRadius"), MinRadius); MaxRadius = Misc.Parse(node.GetValue("MaxRadius"), MaxRadius); MinQuantity = Misc.Parse(node.GetValue("MinQuantity"), MinQuantity); MaxQuantity = Misc.Parse(node.GetValue("MaxQuantity"), MaxQuantity); MinVertices = Misc.Parse(node.GetValue("MinVertices"), MinVertices); MaxVertices = Misc.Parse(node.GetValue("MaxVertices"), MaxVertices); RadiusVariance = Misc.Parse(node.GetValue("RadiusVariance"), RadiusVariance); DepositCount = Misc.Parse(node.GetValue("DepositCount"), DepositCount); NumberOfTries = Misc.Parse(node.GetValue("NumberOfTries"), NumberOfTries); }
public ResourceDefinition(ConfigNode node) { Resource = node.GetValue("Resource"); SeedModifier = Misc.Parse(node.GetValue("SeedModifier"), Resource.GetHashCode()); ColorFull = ColorEmpty = Color.white; load(node); foreach (var bodyNode in node.GetNodes("Body")) { var body = (ResourceDefinition)this.MemberwiseClone(); body.Resource = Resource; body.load(bodyNode); bodies[bodyNode.GetValue("name")] = body; } }
private static IEnumerable <ResourceRate> loadRates(ConfigNode config) { if (config == null) { yield break; } foreach (var entry in config.values.Cast <ConfigNode.Value>()) { var name = entry.name; bool optional = name.EndsWith("*"); if (optional) { name = name.Substring(0, name.Length - 1); } var rate = Misc.Parse(entry.value, 0.0); if (PartResourceLibrary.Instance.resourceDefinitions.Any(d => d.name == name) && rate > 0) { yield return(new ResourceRate(name, rate, optional)); } } }
private void load(ConfigNode node) { MinRadius = Misc.Parse(node.GetValue("MinRadius"), MinRadius); MaxRadius = Misc.Parse(node.GetValue("MaxRadius"), MaxRadius); MinQuantity = Misc.Parse(node.GetValue("MinQuantity"), MinQuantity); MaxQuantity = Misc.Parse(node.GetValue("MaxQuantity"), MaxQuantity); MinVertices = Misc.Parse(node.GetValue("MinVertices"), MinVertices); MaxVertices = Misc.Parse(node.GetValue("MaxVertices"), MaxVertices); RadiusVariance = Misc.Parse(node.GetValue("RadiusVariance"), RadiusVariance); DepositCount = Misc.Parse(node.GetValue("DepositCount"), DepositCount); NumberOfTries = Misc.Parse(node.GetValue("NumberOfTries"), NumberOfTries); var colorFull = node.GetValue("ColorFull"); if (colorFull != null) { ColorFull = ConfigNode.ParseColor(colorFull); } var colorEmpty = node.GetValue("ColorEmpty"); if (colorEmpty != null) { ColorEmpty = ConfigNode.ParseColor(colorEmpty); } }
public BodyDeposits(GeneratorConfiguration resource, ConfigNode node) { if (node == null) { node = new ConfigNode(); } this.deposits = new List <Deposit>(); this.seed = Misc.Parse(node.GetValue("Seed"), seedGenerator.Next()); var random = new System.Random(seed); for (int i = 0; i < resource.DepositCount; i++) { float R = random.Range(resource.MinRadius, resource.MaxRadius); for (int j = 0; j < resource.NumberOfTries; j++) { Vector2 Pos = new Vector2(random.Range(R, 360 - R), random.Range(R, 180 - R)); var deposit = Deposit.Generate(Pos, R, random, resource); if (!deposits.Any(d => d.Shape.Vertices.Any(v => deposit.Shape.PointInPolygon(new Vector2(v.x, v.y)))) && !deposit.Shape.Vertices.Any(v => deposits.Any(d => d.Shape.PointInPolygon(new Vector2(v.x, v.y))))) { deposits.Add(deposit); break; } } } var depositValues = node.GetValues("Deposit"); for (int i = 0; i < Math.Min(deposits.Count, depositValues.Length); i++) { deposits[i].Quantity = Misc.Parse(depositValues[i], deposits[i].InitialQuantity); } MaxQuantity = resource.MaxQuantity; }
private void loadBodyDeposits(ConfigNode config, string resourceName) { if (!PlanetDeposits.ContainsKey(resourceName)) { return; } foreach (var body in PlanetDeposits[resourceName]) { var deposits = body.Value; var bodyNode = config.GetNodes("Body").Where(b => b.GetValue("Name") == body.Key).SingleOrDefault(); if (bodyNode == null) { continue; } var scanMask = bodyNode.GetValue("ScanMask"); if (scanMask != null) { try { Scans[resourceName][body.Key] = new GeodesicGrid.Cell.Set(5, Convert.FromBase64String(scanMask.Replace('.', '/').Replace('%', '='))); } catch (FormatException e) { Debug.LogError(String.Format("[Kethane] Failed to parse {0}/{1} scan string, resetting ({2})", body.Key, resourceName, e.Message)); } } var depositNodes = bodyNode.GetNodes("Deposit"); for (int i = 0; i < Math.Min(deposits.Count, depositNodes.Length); i++) { deposits[i].Quantity = Misc.Parse(depositNodes[i].GetValue("Quantity"), deposits[i].InitialQuantity); } } }
public void Setup() { if (part.partInfo == null) { return; } if (obj != null) { return; } var node = GameDatabase.Instance.GetConfigs("PART").Single(c => part.partInfo.name == c.name.Replace('_', '.')).config.GetNodes("MODULE").Where(n => n.GetValue("name") == moduleName).Single(n => n.GetValue("Label") == Label); var shaderName = node.GetValue("ShaderName"); var textureName = node.GetValue("TextureName"); obj = GameObject.CreatePrimitive(PrimitiveType.Sphere); obj.collider.enabled = false; obj.renderer.material.color = new Color(0, 0, 0, 0); obj.renderer.material.shader = Shader.Find("Transparent/Diffuse"); obj.transform.parent = part.transform; obj.transform.localRotation = Quaternion.identity; animator = (ParticleAnimator)obj.AddComponent <ParticleAnimator>(); emitter = (ParticleEmitter)obj.AddComponent("MeshParticleEmitter"); renderer = (ParticleRenderer)obj.AddComponent <ParticleRenderer>(); var material = new Material(Shader.Find(shaderName)); material.mainTexture = GameDatabase.Instance.GetTexture(textureName, false); material.color = Color.white; renderer.materials = new Material[] { material }; animator.colorAnimation = new Color[5]; if (Misc.Parse(node.GetValue("Collision"), false)) { obj.AddComponent("WorldParticleCollider"); } AngularVelocity = Misc.Parse(node.GetValue("AngularVelocity"), 0f); CameraVelocityScale = Misc.Parse(node.GetValue("CameraVelocityScale"), 0f); ColorAnimation1 = ConfigNode.ParseColor(node.GetValue("ColorAnimation1")); ColorAnimation2 = ConfigNode.ParseColor(node.GetValue("ColorAnimation2")); ColorAnimation3 = ConfigNode.ParseColor(node.GetValue("ColorAnimation3")); ColorAnimation4 = ConfigNode.ParseColor(node.GetValue("ColorAnimation4")); ColorAnimation5 = ConfigNode.ParseColor(node.GetValue("ColorAnimation5")); Damping = Misc.Parse(node.GetValue("Damping"), 1f); Emit = Misc.Parse(node.GetValue("Emit"), true); EmitterVelocityScale = Misc.Parse(node.GetValue("EmitterVelocityScale"), 1f); Force = Misc.Parse(node.GetValue("Force"), Vector3.zero); LengthScale = Misc.Parse(node.GetValue("LengthScale"), 1f); LocalRotationAxis = Misc.Parse(node.GetValue("LocalRotationAxis"), Vector3.zero); LocalVelocity = Misc.Parse(node.GetValue("LocalVelocity"), Vector3.zero); MaxEmission = Misc.Parse(node.GetValue("MaxEmission"), 0f); MaxEnergy = Misc.Parse(node.GetValue("MaxEnergy"), 0f); MaxParticleSize = Misc.Parse(node.GetValue("MaxParticleSize"), 0f); MaxSize = Misc.Parse(node.GetValue("MaxSize"), 0f); MinEmission = Misc.Parse(node.GetValue("MinEmission"), 0f); MinEnergy = Misc.Parse(node.GetValue("MinEnergy"), 0f); MinSize = Misc.Parse(node.GetValue("MinSize"), 0f); RandomAngularVelocity = Misc.Parse(node.GetValue("RandomAngularVelocity"), 0f); RandomForce = Misc.Parse(node.GetValue("RandomForce"), Vector3.zero); RandomRotation = Misc.Parse(node.GetValue("RandomRotation"), false); RandomVelocity = Misc.Parse(node.GetValue("RandomVelocity"), Vector3.zero); RenderMode = Misc.Parse(node.GetValue("RenderMode"), ParticleRenderMode.Billboard); SizeGrow = Misc.Parse(node.GetValue("SizeGrow"), 0f); UseWorldSpace = Misc.Parse(node.GetValue("UseWorldSpace"), false); VelocityScale = Misc.Parse(node.GetValue("VelocityScale"), 0f); WorldRotationAxis = Misc.Parse(node.GetValue("WorldRotationAxis"), Vector3.zero); WorldVelocity = Misc.Parse(node.GetValue("WorldVelocity"), Vector3.zero); EmitterPosition = Misc.Parse(node.GetValue("EmitterPosition"), Vector3.zero); EmitterScale = Misc.Parse(node.GetValue("EmitterScale"), Vector3.zero); }
static MapOverlay() { controlWindowPos.x = Misc.Parse(SettingsManager.GetValue("WindowLeft"), 200f); controlWindowPos.y = Misc.Parse(SettingsManager.GetValue("WindowTop"), 200f); }
private static IEnumerable <ResourceRate> loadRates(ConfigNode config) { return((config ?? new ConfigNode()).values.Cast <ConfigNode.Value>().Where(v => PartResourceLibrary.Instance.resourceDefinitions.Any(d => d.name == v.name)).Select(v => new ResourceRate(v.name, Misc.Parse(v.value, 0.0))).Where(r => r.Rate > 0)); }