Ejemplo n.º 1
0
        private static void DoHysteresisBlock(Rect rect, StorageSettings settings)
        {
            StorageSettings_Hysteresis storageSettings_Hysteresis = StorageSettings_Mapping.Get(settings) ?? new StorageSettings_Hysteresis();

            storageSettings_Hysteresis.FillPercent = Widgets.HorizontalSlider(rect.LeftPart(0.8f), storageSettings_Hysteresis.FillPercent, 0f, 100f, false, "Refill cells less than");
            Widgets.Label(rect.RightPart(0.2f), storageSettings_Hysteresis.FillPercent.ToString("N0") + "%");

            StorageSettings_Mapping.Set(settings, storageSettings_Hysteresis);
        }
        public static void CopyFrom(StorageSettings __instance, StorageSettings other)
        {
            StorageSettings_Hysteresis storageSettings_Hysteresis = StorageSettings_Mapping.Get(other);
            bool flag = storageSettings_Hysteresis != null;

            if (flag)
            {
                StorageSettings_Mapping.Set(__instance, storageSettings_Hysteresis);
            }
        }
Ejemplo n.º 3
0
        public static void ExposeData(StorageSettings __instance)
        {
            StorageSettings_Hysteresis storageSettings_Hysteresis = StorageSettings_Mapping.Get(__instance);

            Scribe_Deep.Look <StorageSettings_Hysteresis>(ref storageSettings_Hysteresis, "hysteresis", new object[0]);
            bool flag = storageSettings_Hysteresis != null;

            if (flag)
            {
                StorageSettings_Mapping.Set(__instance, storageSettings_Hysteresis);
            }
        }
Ejemplo n.º 4
0
        public static void FilledEnough(ref bool __result, IntVec3 c, Map map, Thing thing)
        {
            // if base implementation waves of, then don't need to care


            if (__result)
            {
                float num  = 100f;
                bool  flag = c.GetSlotGroup(map) != null && c.GetSlotGroup(map).Settings != null;
                if (flag)
                {
                    num = StorageSettings_Mapping.Get(c.GetSlotGroup(map).Settings).FillPercent;
                }


                /*
                 * foreach (Thing thisthing in map.thingGrid.ThingsListAt(c))
                 * {
                 *  if (SatisfiedStorageMod.DeepStorageCOMP)
                 *  {
                 *      //it might be a deep storage so lets check if it has
                 *
                 *      var th = thisthing as ThingWithComps;
                 *      if (th == null) continue;
                 *      foreach (ThingComp cc in th.AllComps)
                 *      {
                 *
                 *          if (cc == null) continue;
                 *          if (cc.GetType() == SatisfiedStorageMod._comptype)
                 *          {
                 *              //it is a deep storage so
                 *
                 *              object[] parameters = new object[] { thing, c, map, null };
                 *              object result1 = SatisfiedStorageMod.methodcapacityat.Invoke(cc, parameters);
                 *              current = (int)parameters[3];
                 *
                 *
                 *              //we found the type now lets ask him if he wants us
                 *              object result2 = SatisfiedStorageMod.methodcapacitytostorethingat.Invoke(cc, new object[] { thing, map, c });
                 *              totalcapacity = (int)result2;
                 *              Log.Message("status : " + current.ToString() + "//" + totalcapacity.ToString());
                 *
                 *              //ITS A DEEP STORAGE SO LETS GET THE RESULT AND LEAVE
                 *              if(current > totalcapacity * (num / 100f))
                 *              {
                 *                  __result = false;
                 *              }
                 *
                 *               // IT IS NOT POSSIBLE TO HAVE DEEP STORAGE AND A STORAGE ZONE ON TOP OF EACH OTHER SO NO NEED TO CHECK MORE
                 *              return;
                 *          }
                 *      }
                 *  }
                 *
                 *
                 *
                 * }
                 */



                __result &= !map.thingGrid.ThingsListAt(c).Any(t => t.def.EverStorable(false) && t.stackCount >= thing.def.stackLimit * (num / 100f));
            }
        }
        public static void NoStorageBlockersInPost(ref bool __result, IntVec3 c, Map map, Thing thing)
        {
            //FALSE IF ITS TOO FULL
            //TRUE IF THERE IS EMPTY SPACE

            //we dont make empty space so if its full then we dont care
            if (__result)
            {
                float     num       = 100f;
                SlotGroup slotGroup = c.GetSlotGroup(map);

                bool flag = slotGroup != null && slotGroup.Settings != null;
                if (flag)
                {
                    num = StorageSettings_Mapping.Get(slotGroup.Settings).FillPercent;
                }

                //LWM.DeepStorage
                if (checkIHoldMultipleThings)
                {
                    foreach (Thing thisthing in map.thingGrid.ThingsListAt(c))
                    {
                        ThingWithComps th = thisthing as ThingWithComps;
                        if (th == null)
                        {
                            continue;
                        }
                        var allComps = th.AllComps;

                        if (allComps != null)
                        {
                            foreach (var comp in allComps)
                            {
                                if (comp is IHoldMultipleThings.IHoldMultipleThings)
                                {
                                    int capacity = 0;
                                    IHoldMultipleThings.IHoldMultipleThings thiscomp = (IHoldMultipleThings.IHoldMultipleThings)comp;

                                    thiscomp.CapacityAt(thing, c, map, out capacity);
                                    // if total capacity is larger than the stackLimit (full stack available)
                                    //    Allow hauling (other choices are valid)
                                    // if (capacity > thing.def.stackLimit) return true;
                                    // only haul if count is below threshold
                                    //   which is equivalent to availability being above threshold:
                                    //            Log.Message("capacity = " + capacity);
                                    //            Log.Message("thing.def.stackLimit = " +thing.def.stackLimit);
                                    float var = (100f * (float)capacity / thing.def.stackLimit);

                                    //100 - num is necessary because capacity gives empty space not full space
                                    __result = var > (100 - num);
                                    //      if (__result == false){
                                    //          Log.Message("ITS TOO FULL stop yey");
                                    //      }
                                    return;
                                }
                            }
                        }
                    }
                }

                // mod check:
                __result &= !map.thingGrid.ThingsListAt(c).Any(t => t.def.EverStorable(false) && t.stackCount >= thing.def.stackLimit * (num / 100f));
            }
        }