public override void OnStart(PartModule.StartState state) { if (state == StartState.Editor) { return; } part.force_activate(); reprocessor = new FuelReprocessor(part); if (part.airlock != null && part.airlock.transform != null) { if (part.airlock.transform.gameObject != null) { Destroy(part.airlock.transform.gameObject); } } anim = part.FindModelAnimators(animName).FirstOrDefault(); if (anim != null) { anim[animName].layer = 1; if (IsEnabled) { anim.Blend(animName, 2, 0); } else { play_down = false; anim[animName].speed = -1f; anim[animName].normalizedTime = 0f; anim.Blend(animName, 0, 1); } } }
public override void OnStart(PartModule.StartState state) { if (state == StartState.Editor) { return; } reprocessor = new FuelReprocessor(part); anti_factory = new AntimatterFactory(part); ConfigNode config = PluginHelper.getPluginSaveFile(); part.force_activate(); anim = part.FindModelAnimators(animName1).FirstOrDefault(); anim2 = part.FindModelAnimators(animName2).FirstOrDefault(); if (anim != null && anim2 != null) { anim[animName1].layer = 1; anim2[animName2].layer = 1; if (IsEnabled) { //anim [animName1].normalizedTime = 1f; //anim2 [animName2].normalizedTime = 1f; //anim [animName1].speed = -1f; //anim2 [animName2].speed = -1f; anim.Blend(animName1, 1, 0); anim2.Blend(animName2, 1, 0); } else { //anim [animName1].normalizedTime = 0f; //anim2 [animName2].normalizedTime = 0f; //anim [animName1].speed = 1f; //anim2 [animName2].speed = 1f; //anim.Blend (animName1, 0, 0); //anim2.Blend (animName2, 0, 0); play_down = false; } //anim.Play (); //anim2.Play (); } if (IsEnabled && last_active_time != 0) { float global_rate_multipliers = 1; crew_capacity_ratio = ((float)part.protoModuleCrew.Count) / ((float)part.CrewCapacity); global_rate_multipliers = global_rate_multipliers * crew_capacity_ratio; if (active_mode == 0) // Science persistence { double now = Planetarium.GetUniversalTime(); double time_diff = now - last_active_time; float altitude_multiplier = (float)(vessel.altitude / (vessel.mainBody.Radius)); altitude_multiplier = Math.Max(altitude_multiplier, 1); float stupidity = 0; foreach (ProtoCrewMember proto_crew_member in part.protoModuleCrew) { stupidity += proto_crew_member.stupidity; } stupidity = 1.5f - stupidity / 2.0f; double science_to_add = GameConstants.baseScienceRate * time_diff / 86400 * electrical_power_ratio * stupidity * global_rate_multipliers * PluginHelper.getScienceMultiplier(vessel.mainBody.flightGlobalsIndex, vessel.LandedOrSplashed) / ((float)Math.Sqrt(altitude_multiplier)); //part.RequestResource ("Science", -science_to_add); science_awaiting_addition = science_to_add; } else if (active_mode == 2) // Antimatter persistence { double now = Planetarium.GetUniversalTime(); double time_diff = now - last_active_time; List <PartResource> partresources = new List <PartResource>(); part.GetConnectedResources(PartResourceLibrary.Instance.GetDefinition("Antimatter").id, partresources); float currentAntimatter_missing = 0; foreach (PartResource partresource in partresources) { currentAntimatter_missing += (float)(partresource.maxAmount - partresource.amount); } float total_electrical_power_provided = (float)(electrical_power_ratio * (GameConstants.baseAMFPowerConsumption + GameConstants.basePowerConsumption) * 1E6); double antimatter_mass = total_electrical_power_provided / GameConstants.warpspeed / GameConstants.warpspeed * 1E6 / 20000.0; float antimatter_peristence_to_add = (float)-Math.Min(currentAntimatter_missing, antimatter_mass * time_diff); part.RequestResource("Antimatter", antimatter_peristence_to_add); } } }
public override void OnStart(PartModule.StartState state) { if (state == StartState.Editor) { return; } reprocessor = new FuelReprocessor(part); anti_factory = new AntimatterFactory(part); ConfigNode config = PluginHelper.getPluginSaveFile(); part.force_activate(); anim = part.FindModelAnimators(animName1).FirstOrDefault(); anim2 = part.FindModelAnimators(animName2).FirstOrDefault(); if (anim != null && anim2 != null) { anim[animName1].layer = 1; anim2[animName2].layer = 1; if (IsEnabled) { //anim [animName1].normalizedTime = 1f; //anim2 [animName2].normalizedTime = 1f; //anim [animName1].speed = -1f; //anim2 [animName2].speed = -1f; anim.Blend(animName1, 1, 0); anim2.Blend(animName2, 1, 0); } else { //anim [animName1].normalizedTime = 0f; //anim2 [animName2].normalizedTime = 0f; //anim [animName1].speed = 1f; //anim2 [animName2].speed = 1f; //anim.Blend (animName1, 0, 0); //anim2.Blend (animName2, 0, 0); play_down = false; } //anim.Play (); //anim2.Play (); } if (IsEnabled && last_active_time != 0) { float global_rate_multipliers = 1; crew_capacity_ratio = ((float)part.protoModuleCrew.Count) / ((float)part.CrewCapacity); global_rate_multipliers = global_rate_multipliers * crew_capacity_ratio; if (active_mode == 0) { // Science persistence double now = Planetarium.GetUniversalTime(); double time_diff = now - last_active_time; float altitude_multiplier = (float)(vessel.altitude / (vessel.mainBody.Radius)); altitude_multiplier = Math.Max(altitude_multiplier, 1); float stupidity = 0; foreach (ProtoCrewMember proto_crew_member in part.protoModuleCrew) { stupidity += proto_crew_member.stupidity; } stupidity = 1.5f - stupidity / 2.0f; double science_to_add = GameConstants.baseScienceRate * time_diff / 86400 * electrical_power_ratio * stupidity * global_rate_multipliers * PluginHelper.getScienceMultiplier(vessel.mainBody.flightGlobalsIndex, vessel.LandedOrSplashed) / ((float)Math.Sqrt(altitude_multiplier)); //part.RequestResource ("Science", -science_to_add); science_awaiting_addition = science_to_add; } else if (active_mode == 2) { // Antimatter persistence double now = Planetarium.GetUniversalTime(); double time_diff = now - last_active_time; List<PartResource> partresources = new List<PartResource>(); part.GetConnectedResources(PartResourceLibrary.Instance.GetDefinition("Antimatter").id, PartResourceLibrary.Instance.GetDefinition("Antimatter").resourceFlowMode, partresources); float currentAntimatter_missing = 0; foreach (PartResource partresource in partresources) { currentAntimatter_missing += (float)(partresource.maxAmount - partresource.amount); } float total_electrical_power_provided = (float)(electrical_power_ratio * (GameConstants.baseAMFPowerConsumption + GameConstants.basePowerConsumption) * 1E6); double antimatter_mass = total_electrical_power_provided / GameConstants.warpspeed / GameConstants.warpspeed * 1E6 / 20000.0; float antimatter_peristence_to_add = (float)-Math.Min(currentAntimatter_missing, antimatter_mass * time_diff); part.RequestResource("Antimatter", antimatter_peristence_to_add); } } }