Ejemplo n.º 1
0
        public void OnLoadingColony(Colony colony, JSONNode data)
        {
            if (data.TryGetAs <JSONNode>(nameof(CrateLocations), out var crateJson))
            {
                if (!CrateLocations.ContainsKey(colony))
                {
                    CrateLocations.Add(colony, new Dictionary <Vector3Int, CrateInventory>());
                }

                foreach (var loc in crateJson.LoopObject())
                {
                    CrateLocations[colony][Vector3Int.Parse(loc.Key)] = new CrateInventory(loc.Value, colony);
                }
            }

            if (data.TryGetAs <JSONNode>(nameof(ItemCrateLocations), out var icl))
            {
                if (!ItemCrateLocations.ContainsKey(colony))
                {
                    ItemCrateLocations.Add(colony, new Dictionary <ushort, List <Vector3Int> >());
                }

                foreach (var kvp in icl.LoopObject())
                {
                    List <Vector3Int> locs = new List <Vector3Int>();

                    foreach (var l in kvp.Value.LoopArray())
                    {
                        locs.Add((Vector3Int)l);
                    }

                    ItemCrateLocations[colony][Convert.ToUInt16(kvp.Key)] = locs;
                }
            }
        }
Ejemplo n.º 2
0
        public void AfterWorldLoad()
        {
            _worldLoaded = true;

            foreach (var colony in ServerManager.ColonyTracker.ColoniesByID.Values)
            {
                if (!CrateLocations.ContainsKey(colony))
                {
                    CrateLocations.Add(colony, new Dictionary <Vector3Int, CrateInventory>());
                }

                if (!ItemCrateLocations.ContainsKey(colony))
                {
                    ItemCrateLocations.Add(colony, new Dictionary <ushort, List <Vector3Int> >());
                }

                RecalcMax(colony);
            }
        }
Ejemplo n.º 3
0
        public void AfterWorldLoad()
        {
            _worldLoaded = true;

            if (ServerManager.BlockEntityCallbacks.TryGetAutoLoadedInstance <CivCrateTracker>(out var crateTracker))
            {
                CrateTracker = crateTracker;
            }

            foreach (var colony in ServerManager.ColonyTracker.ColoniesByID.Values.Where(c => c != null))
            {
                if (!CrateLocations.ContainsKey(colony))
                {
                    CrateLocations.Add(colony, new Dictionary <Vector3Int, CrateInventory>());
                }

                if (!ItemCrateLocations.ContainsKey(colony))
                {
                    ItemCrateLocations.Add(colony, new Dictionary <ushort, List <Vector3Int> >());
                }

                RecalcStockpileMaxSize(colony);
            }
        }