Esempio n. 1
0
 /// <summary>
 /// Applied after BeginMission runs.
 /// </summary>
 internal static void Postfix(SpaceDestination destination)
 {
     if (destination != null)
     {
         AchievementStateComponent.OnVisit(destination.id);
     }
 }
Esempio n. 2
0
 /// <summary>
 /// Applied after OnSpawn runs.
 /// </summary>
 internal static void Postfix(PrimaryElement ___primaryElement)
 {
     if (___primaryElement != null)
     {
         AchievementStateComponent.UpdateMaxKelvin(___primaryElement.Temperature);
     }
 }
Esempio n. 3
0
            /// <summary>
            /// Applied after ApplyRandomTrait runs.
            /// </summary>
            internal static void Postfix()
            {
#if DEBUG
                PUtil.LogDebug("Neural Vacillator used");
#endif
                AchievementStateComponent.OnGeneShuffleComplete();
            }
Esempio n. 4
0
            /// <summary>
            /// Applied after DoDamage runs.
            /// </summary>
            internal static void Postfix(BuildingHP __instance, object data)
            {
                Wire wire;
                WireUtilityNetworkLink bridge;

                if (__instance != null && data is BuildingHP.DamageSourceInfo source &&
                    (source.source == STRINGS.BUILDINGS.DAMAGESOURCES.CIRCUIT_OVERLOADED ||
                     source.takeDamageEffect == SpawnFXHashes.BuildingSpark))
                {
                    var obj = __instance.gameObject;
#if DEBUG
                    PUtil.LogDebug("Wire overloaded: " + obj.name);
#endif
                    if ((wire = obj.GetComponentSafe <Wire>()) != null)
                    {
                        // Wire is overloading
                        AchievementStateComponent.OnOverload(wire.GetMaxWattageRating());
                    }
                    else if ((bridge = obj.GetComponentSafe <WireUtilityNetworkLink>()) != null)
                    {
                        // Wire bridge is overloading
                        AchievementStateComponent.OnOverload(bridge.GetMaxWattageRating());
                    }
                }
            }
Esempio n. 5
0
            /// <summary>
            /// Applied after CompleteMission runs.
            /// </summary>
            internal static void Postfix(Spacecraft __instance)
            {
                var instance = SpacecraftManager.instance;
                SpaceDestination destination;

                if ((destination = instance.GetSpacecraftDestination(__instance.id)) != null)
                {
                    AchievementStateComponent.OnVisit(destination.id);
                }
            }
Esempio n. 6
0
            /// <summary>
            /// Applied after Kill runs.
            /// </summary>
            internal static void Postfix(DeathMonitor.Instance __instance, Death death)
            {
#if DEBUG
                PUtil.LogDebug("Duplicant died: " + death?.Id);
#endif
                if (__instance.IsDuplicant)
                {
                    AchievementStateComponent.OnDeath(death);
                }
            }
Esempio n. 7
0
 /// <summary>
 /// Checks to see if the object that just got melted is a POI object.
 ///
 /// Destroys the object before returning.
 /// </summary>
 /// <param name="obj">The object that just melted, before the melt actually completes.</param>
 private static void CheckAndDestroy(GameObject obj)
 {
     if (obj != null)
     {
         if (Achievements.POI_PROPS.Contains(obj.PrefabID().Name))
         {
             AchievementStateComponent.Trigger(AchievementStrings.WATCHTHEWORLDBURN.ID);
         }
         Util.KDestroyGameObject(obj);
     }
 }
Esempio n. 8
0
            /// <summary>
            /// Applied after Discover runs.
            /// </summary>
            internal static void Postfix(Tag tag)
            {
                var neutronium = ElementLoader.FindElementByHash(SimHashes.Unobtanium);

                if (neutronium != null && tag.Equals(neutronium.tag))
                {
                    // I See What You Did There
                    AchievementStateComponent.Trigger(AchievementStrings.ISEEWHATYOUDIDTHERE.
                                                      ID);
                }
            }
Esempio n. 9
0
            /// <summary>
            /// Applied after OnStartWork runs.
            /// </summary>
            internal static void Postfix(Clinic __instance, Worker worker)
            {
                var building = __instance.gameObject.GetComponentSafe <Building>();
                var hp       = Db.Get().Amounts.HitPoints.Lookup(worker);

#if DEBUG
                if (hp != null)
                {
                    PUtil.LogDebug("Reached clinic with {0:F2} left".F(hp.value));
                }
#endif
                if (building != null && building.Def.PrefabID == MedicalCotConfig.ID && hp !=
                    null && hp.value <= AchievementStrings.SAVINGMEEP.THRESHOLD)
                {
                    AchievementStateComponent.Trigger(AchievementStrings.SAVINGMEEP.ID);
                }
            }
Esempio n. 10
0
            /// <summary>
            /// Applied after OnButcherComplete runs.
            /// </summary>
            internal static void Postfix(Butcherable __instance)
            {
                var  obj     = __instance.gameObject;
                bool natural = false;

                if (obj != null)
                {
                    var smi = obj.GetSMI <AgeMonitor.Instance>();
                    if (smi != null)
                    {
                        natural = smi.CyclesUntilDeath < (1.0f / Constants.SECONDS_PER_CYCLE);
                    }
#if DEBUG
                    PUtil.LogDebug("Critter died: " + (natural ? "old age" : "prematurely"));
#endif
                    if (!natural)
                    {
                        AchievementStateComponent.OnCritterKilled();
                    }
                }
            }
Esempio n. 11
0
        /// <summary>
        /// Checks the remaining breath of the Duplicant when they reach oxygen.
        /// </summary>
        /// <param name="smi">The state machine instance controlling breath recovery.</param>
        private static void CheckBreath(RecoverBreathChore.StatesInstance smi)
        {
            var dupe = smi.sm.recoverer.Get(smi);

            if (dupe != null)
            {
                // How long until that dupe would have suffocated?
                var instance  = Db.Get().Amounts.Breath.Lookup(dupe);
                var breathSMI = dupe.GetSMI <SuffocationMonitor.Instance>();
                if (instance != null && breathSMI != null)
                {
                    float delta = instance.GetDelta();
#if DEBUG
                    PUtil.LogDebug("Reached air with {0:F2} left".F(instance.value));
#endif
                    if (delta != 0.0f && instance.value / Mathf.Abs(delta) <
                        AchievementStrings.FINALBREATH.THRESHOLD)
                    {
                        AchievementStateComponent.Trigger(AchievementStrings.FINALBREATH.
                                                          ID);
                    }
                }
            }
        }
Esempio n. 12
0
 /// <summary>
 /// Destroys the singleton instance of this component.
 /// </summary>
 internal static void DestroyInstance()
 {
     Instance = null;
 }
Esempio n. 13
0
 /// <summary>
 /// Applied after OnSetTemperature runs.
 /// </summary>
 internal static void Postfix(float temperature)
 {
     AchievementStateComponent.UpdateMaxKelvin(temperature);
 }
Esempio n. 14
0
 internal static void Cleanup()
 {
     AchievementStateComponent.DestroyInstance();
 }
 /// <summary>
 /// Applied after DestroyInstances runs.
 /// </summary>
 internal static void Postfix()
 {
     AchievementStateComponent.DestroyInstance();
 }
Esempio n. 16
0
 protected override void OnPrefabInit()
 {
     base.OnPrefabInit();
     Instance = this;
 }