internal LastSelectionDetails(GameObject target) { target.TryGetComponent(out conditions); target.TryGetComponent(out identity); target.TryGetComponent(out modifiers); target.TryGetComponent(out rocketModule); target.TryGetComponent(out selectable); target.TryGetComponent(out world); if (rocketModule != null) { rocketInterface = rocketModule.CraftInterface; // Clustercraft can be pulled from the rocket-to-module interface gridEntity = rocketInterface.m_clustercraft; } else if (target.TryGetComponent(out gridEntity) && gridEntity is Clustercraft craft) { rocketInterface = craft.ModuleInterface; } else { rocketInterface = null; } fertility = target.GetSMI <FertilityMonitor.Instance>(); if (DlcManager.FeatureClusterSpaceEnabled()) { isRocket = target.TryGetComponent(out LaunchPad _) || target. TryGetComponent(out RocketProcessConditionDisplayTarget _); } else { isRocket = target.TryGetComponent(out LaunchableRocket _); } isAsteroid = gridEntity != null && gridEntity is AsteroidGridEntity; }
/// <summary> /// Gets the formatted rocket speed. /// </summary> /// <param name="rocket">The currently selected rocket.</param> /// <param name="enginePower">The rocket engine power.</param> /// <param name="burden">The total rocket burden.</param> /// <returns>The speed tool tip text. The speed title is in CACHED_BUILDER.</returns> private static string GetSpeed(CraftModuleInterface rocket, float enginePower, float burden) { var clustercraft = rocket.m_clustercraft; var text = CACHED_BUILDER; text.Clear().AppendLine(ROCKETS.SPEED.TOOLTIP).Append(Constants.TABBULLETSTRING). Append(ROCKETS.POWER_TOTAL.NAME); enginePower.ToRyuHardString(text, 0); text.AppendLine().Append(Constants.TABBULLETSTRING).Append(ROCKETS.BURDEN_TOTAL. NAME); burden.ToRyuHardString(text, 0); string tooltip = text.ToString(); text.Clear().Append(ROCKETS.SPEED.NAME); float speed = (clustercraft == null || burden == 0.0f) ? 0.0f : enginePower * clustercraft.AutoPilotMultiplier * clustercraft.PilotSkillMultiplier / burden; FormatStringPatches.GetFormattedRocketRange(text, speed, TimeSlice.PerCycle, true); return(tooltip); }
/// <summary> /// Refreshes the Spaced Out rocket module statistics. /// </summary> /// <param name="rocketStatus">The info panel to update.</param> /// <param name="rocket">The currently selected rocket.</param> private static void RefreshRocketStats(CollapsibleDetailContentPanel rocketStatus, CraftModuleInterface rocket) { RocketEngineCluster engine = null; int height = 0, maxHeight = TUNING.ROCKETRY.ROCKET_HEIGHT.MAX_MODULE_STACK_HEIGHT; var modules = rocket.clusterModules; int n = modules.Count; float oxyMass = 0.0f, fuelMass = 0.0f, fuelPerDist = 0.0f, burden = 0.0f, enginePower = 0.0f; var text = CACHED_BUILDER; // Find the engine first for (int i = 0; i < n; i++) { var module = modules[i].Get(); if (module != null && module.TryGetComponent(out engine)) { var perf = module.performanceStats; fuelPerDist = perf.FuelKilogramPerDistance; enginePower = perf.EnginePower; break; } } for (int i = 0; i < n; i++) { var module = modules[i].Get(); if (module != null) { if (engine != null) { // Some engines have built-in fuel tanks if (module.TryGetComponent(out IFuelTank fuelTank)) { fuelMass += fuelTank.Storage.GetAmountAvailable(engine.fuelTag); } // Do not exclude future combo LF/O tanks from mods ;) if (engine.requireOxidizer && module.TryGetComponent( out OxidizerTank oxyTank)) { oxyMass += oxyTank.TotalOxidizerPower; } } if (module.TryGetComponent(out Building building)) { height += building.Def.HeightInCells; } burden += module.performanceStats.Burden; } } // Range string tooltip = GetRangeLeft(engine, Mathf.Ceil(fuelMass), Mathf.Ceil(oxyMass), fuelPerDist); rocketStatus.SetLabel("RangeRemaining", text.ToString(), tooltip); // Speed tooltip = GetSpeed(rocket, enginePower, burden); rocketStatus.SetLabel("Speed", text.ToString(), tooltip); if (engine != null) { maxHeight = engine.maxHeight; } // Height string maxHeightStr = maxHeight.ToString(); tooltip = text.Clear().Append(ROCKETS.MAX_HEIGHT.TOOLTIP).Replace("{0}", engine.GetProperName()).Replace("{1}", maxHeightStr).ToString(); text.Clear().Append(ROCKETS.MAX_HEIGHT.NAME).Replace("{0}", height. ToString()).Replace("{1}", maxHeightStr); rocketStatus.SetLabel("MaxHeight", text.ToString(), tooltip); }