public static pulseUnit getPulseUnit(String name, float energy, float mass) { if (pulseUnits.ContainsKey(name)) { return(pulseUnits[name]); } pulseUnit ret = new pulseUnit(name, energy, mass); pulseUnits.Add(name, ret); Debug.Log(">>> Added " + name + " With mass of " + mass + " and energy of " + energy); ret.getImpulse(); Debug.Log(">>> " + name + " has impulse of " + ret.getImpulse()); return(ret); }
protected void detonatePulse() { if (fuelSupply == null) { return; } totalVesselMass = 0f; foreach (Part current in this.vessel.parts) { totalVesselMass += current.mass; } currentUnit = fuelSupply.getUnit(false); if (currentUnit != null) { float neededCharge = currentUnit.getEnergy() / (activationRatio * efficiency); float rechargeAmount = -currentUnit.getEnergy() / efficiency; float charge = getECInBank(); Debug.Log(charge + ":" + neededCharge); if (charge < neededCharge) { Debug.Log(charge + " " + neededCharge + " " + (charge - neededCharge)); return; } fuelSupply.getUnit(true); consumeCharge(neededCharge); RequestResource("ElectricCharge", rechargeAmount); // add velocity this.vessel.ChangeWorldVelocity(base.transform.up * (this.currentUnit.getImpulse() / totalVesselMass)); base.rigidbody.AddRelativeForce(new Vector3(0f, (this.currentUnit.getImpulse() / totalVesselMass), 0f), ForceMode.Force); if (this.Modules.Contains("HeatTransfer")) { this.temperature += currentUnit.getEnergy() / 50000; } // FX: make explosion sound this.explosionGroup.Power = 10; this.explosionGroup.Burst(); base.gameObject.audio.pitch = 1f; base.gameObject.audio.PlayOneShot(this.explosionGroup.sfx); //TODO replace this with a jet of plasma Vector3d groundZero = new Vector3d(base.transform.FindChild("model").localPosition.x, base.transform.FindChild("model").localPosition.y, base.transform.FindChild("model").localPosition.z); groundZero = base.transform.FindChild("model").TransformPoint(groundZero); FXMonger.Explode(this, groundZero, 10); } }