Exemple #1
0
 /// <summary>
 /// Fix calories calculation.
 /// </summary>
 internal static bool Prefix(FoodDiagnostic __instance,
                             ref ColonyDiagnostic.DiagnosticResult __result,
                             float ___trackerSampleCountSeconds)
 {
     __result = new ColonyDiagnostic.DiagnosticResult(ColonyDiagnostic.
                                                      DiagnosticResult.Opinion.Normal, STRINGS.UI.COLONY_DIAGNOSTICS.
                                                      GENERIC_CRITERIA_PASS);
     if (__instance.tracker.GetDataTimeLength() < 10f)
     {
         __result.opinion = ColonyDiagnostic.DiagnosticResult.Opinion.Normal;
         __result.Message = STRINGS.UI.COLONY_DIAGNOSTICS.NO_DATA;
     }
     else
     {
         var dupes = Components.LiveMinionIdentities.GetWorldItems(
             __instance.worldID);
         var requiredCaloriesPerCycle = GetRequiredFoodPerCycle(dupes);
         // show warning if food doesn't last for 3 days
         var daysReserve = 3;
         if (requiredCaloriesPerCycle * daysReserve > __instance.tracker.
             GetAverageValue(___trackerSampleCountSeconds))
         {
             var currentValue = __instance.tracker.GetCurrentValue();
             var text         = STRINGS.MISC.NOTIFICATIONS.FOODLOW.TOOLTIP;
             __result.opinion = ColonyDiagnostic.DiagnosticResult.Opinion.Concern;
             text             = text.Replace("{0}", GameUtil.GetFormattedCalories(
                                                 currentValue)).Replace("{1}", GameUtil.GetFormattedCalories(
                                                                            requiredCaloriesPerCycle));
             __result.Message = text;
         }
     }
     return(false);
 }
Exemple #2
0
        /// <summary>
        /// Applied before CheckTrapped runs.
        /// </summary>
        internal static bool Prefix(TrappedDuplicantDiagnostic __instance,
                                    ref ColonyDiagnostic.DiagnosticResult __result)
        {
            bool trapped  = false;
            int  worldID  = __instance.worldID;
            bool isRocket = ClusterManager.Instance.GetWorld(worldID).IsModuleInterior;

            // Diagnostic does nothing on rockets
            if (!isRocket)
            {
                var duplicants  = Components.LiveMinionIdentities.GetWorldItems(worldID, false);
                int n           = duplicants.Count;
                var pods        = Components.Telepads.GetWorldItems(worldID, false);
                var teleporters = Components.WarpReceivers.GetWorldItems(worldID, false);
                var beds        = Components.Sleepables.GetWorldItems(worldID, false);
                for (int i = 0; i < n && !trapped; i++)
                {
                    var duplicant = duplicants[i];
                    // The criteria used by Trapped basically requires idle Duplicants who
                    // cannot reach a friend with tasks, and cannot get to their bed or the
                    // printing pod / teleporter. Ideally this would go off even if the
                    // Duplicant is not idle, but this patch tries not to change the behavior.
                    if (IsBasicallyIdle(duplicant) && duplicant.TryGetComponent(
                            out Navigator navigator) && IsTrapped(duplicant, navigator,
                                                                  duplicants, pods, teleporters, beds))
                    {
                        __result.clickThroughTarget = new Tuple <Vector3, GameObject>(
                            duplicant.transform.position, duplicant.gameObject);
                        trapped = true;
                    }
                }
            }
            if (!trapped)
            {
                __result.clickThroughTarget = null;
            }
            __result.opinion = trapped ? ColonyDiagnostic.DiagnosticResult.Opinion.Bad :
                               ColonyDiagnostic.DiagnosticResult.Opinion.Normal;
            __result.Message = trapped ? STRINGS.UI.COLONY_DIAGNOSTICS.
                               TRAPPEDDUPLICANTDIAGNOSTIC.STUCK : STRINGS.UI.COLONY_DIAGNOSTICS.
                               TRAPPEDDUPLICANTDIAGNOSTIC.NORMAL;
            return(false);
        }