コード例 #1
0
        public static void MeditationTick_PostFix(JobDriver_Meditate __instance)
        {
            var pawn = Traverse.Create(__instance).Field("pawn").GetValue <Pawn>();

            if (ModsConfig.RoyaltyActive && DefDatabase <MeditationFocusDef> .GetNamed("Morbid").CanPawnUse(pawn))
            {
                int num = GenRadial.NumCellsInRadius(MeditationUtility.FocusObjectSearchRadius);
                for (int i = 0; i < num; i++)
                {
                    IntVec3 c = pawn.Position + GenRadial.RadialPattern[i];
                    if (c.InBounds(pawn.Map))
                    {
                        Plant plant = c.GetPlant(pawn.Map);
                        if (plant != null && plant.def == ThingDef.Named("Cults_PlantTreeNightmare"))
                        {
                            CompSpawnSubplant compSpawnSubplant = plant.TryGetComp <CompSpawnSubplant>();
                            if (compSpawnSubplant != null)
                            {
                                compSpawnSubplant.AddProgress(JobDriver_Meditate.AnimaTreeSubplantProgressPerTick, false);
                            }
                        }
                    }
                }
            }
        }
コード例 #2
0
 public static bool TryGrowSubplants(CompSpawnSubplant __instance)
 {
     while (__instance.progressToNextSubplant >= 1f)
     {
         bool grow = false;
         lock (__instance) //threadsafe subrtract for float
         {
             if (__instance.progressToNextSubplant >= 1f)
             {
                 __instance.progressToNextSubplant -= 1f;
                 grow = true;
             }
         }
         if (grow)
         {
             __instance.DoGrowSubplant();
         }
     }
     return(false);
 }
コード例 #3
0
        public static bool AddProgress(CompSpawnSubplant __instance, float progress, bool ignoreMultiplier = false)
#endif
        {
            if (!ModLister.RoyaltyInstalled)
            {
                Log.ErrorOnce("Subplant spawners are a Royalty-specific game system. If you want to use this code please check ModLister.RoyaltyInstalled before calling it. See rules on the Ludeon forum for more info.", 43254);
            }
            else
            {
                if (!ignoreMultiplier)
                {
                    progress *= __instance.ProgressMultiplier;
                }
                lock (__instance) //threadsafe add for float
                {
                    __instance.progressToNextSubplant += progress;
                }

                Interlocked.Increment(ref __instance.meditationTicksToday); //used threadsafe increment
                __instance.TryGrowSubplants();
            }

            return(false);
        }
コード例 #4
0
 public static bool AddProgress_NewTmp(CompSpawnSubplant __instance, float progress, bool ignoreMultiplier = false)