Esempio n. 1
0
        // credit to bananasss00 for this function
        public static bool TryGetKanbanSettings(this IntVec3 cell, Map map, out KanbanSettings ks, out SlotGroup slotGroup)
        {
            ks        = new KanbanSettings();
            slotGroup = null;

            if (map == null)
            {
                return(false);
            }

            slotGroup = cell.GetSlotGroup(map);
            if (slotGroup?.Settings == null)
            {
                return(false);
            }

            // grab latest configs for this stockpile from our state manager
            ks = State.Get(slotGroup.Settings.owner.ToString());

            // skip all this stuff now if stockpile is not configured to use at least one feature
            if (ks.srt == 100 && ks.ssl == 0)
            {
                return(false);
            }

            return(true);
        }
Esempio n. 2
0
 //[SyncWorker(shouldConstruct = false)]
 public static void SyncKanbanSettings(SyncWorker sync, ref KanbanSettings ks)
 {
     sync.Bind(ref ks.srt);
     sync.Bind(ref ks.ssl);
     //if (sync.isWriting) {
     //    sync.Write(ks);
     //} else {
     //    ks = sync.Read<KanbanSettings>();
     //}
 }
Esempio n. 3
0
        //public void CopyFrom(StorageSettings other)
        public static void CopyFrom(StorageSettings __instance, StorageSettings other)
        {
            var st = new StackTrace();

            if (st.FrameCount > 3 && st.GetFrame(2).GetMethod() == Building_Storage_PostMake)
            {
                return; // prevent copy settings when called from Building_Storage:PostMake, new storage
            }
            KSLog.Message("[KanbanStockpile] CopyFrom()");
            string         label = other?.owner?.ToString() ?? "___clipboard";
            KanbanSettings ks    = State.Get(label);

            label = __instance?.owner?.ToString() ?? "___clipboard";
            State.Set(label, ks);
        }
Esempio n. 4
0
        public static void Postfix(StorageSettings __instance)
        {
            // The clipboard StorageSettings has no owner, so assume a null is the clipboard...
            string label = __instance?.owner?.ToString() ?? "___clipboard";

            KSLog.Message("[KanbanStockpile] ExposeData() with owner name: " + label);
            KanbanSettings ks = State.Get(label);

            if (Scribe.mode == LoadSaveMode.Saving)
            {
                // this mode implicitly takes the value currently in srt and saves it out
                Scribe_Values.Look(ref ks.srt, "stackRefillThreshold", 100, true);
                Scribe_Values.Look(ref ks.ssl, "similarStackLimit", 0, true);
            }
            else if (Scribe.mode == LoadSaveMode.LoadingVars)
            {
                // this mode implicitly loads some other value into this instance of srt
                Scribe_Values.Look(ref ks.srt, "stackRefillThreshold", 100, false);
                Scribe_Values.Look(ref ks.ssl, "similarStackLimit", 0, false);
                State.Set(label, ks);
            }
        }
Esempio n. 5
0
 //[SyncMethod]
 public static void Set(string label, KanbanSettings ks)
 {
     db[label] = ks;
 }
Esempio n. 6
0
 //[SyncWorker(shouldConstruct = false)]
 public static void SyncKanbanSettings(SyncWorker sync, ref KanbanSettings ks)
 {
     sync.Bind(ref ks.srt);
     sync.Bind(ref ks.ssl);
 }