public FetchablesByPrefabId(Tag prefab_id)
 {
     prefabId     = prefab_id;
     fetchables   = new KCompactedVector <Fetchable>(0);
     rotUpdaters  = new Dictionary <HandleVector <int> .Handle, Rottable.Instance>();
     finalPickups = new List <Pickup>();
 }
Ejemplo n.º 2
0
            public static void Prefix(ICollection <int> visited_cells, KCompactedVector <CavityInfo> ___cavityInfos, HandleVector <int> .Handle[] ___CellCavityID)
            {
                int maxRoomSize = TuningData <RoomProber.Tuning> .Get().maxRoomSize;

                foreach (int current in visited_cells)
                {
                    HandleVector <int> .Handle handle = ___CellCavityID [current];
                    if (handle.IsValid())
                    {
                        CavityInfo data = ___cavityInfos.GetData(handle);
                        if (0 < data.numCells && data.numCells <= maxRoomSize)
                        {
                            GameObject gameObject = Grid.Objects [current, (int)ObjectLayer.Plants];
                            if (gameObject != null)
                            {
                                KPrefabID component = gameObject.GetComponent <KPrefabID> ();
                                bool      flag2     = false;
                                foreach (KPrefabID current2 in data.buildings)
                                {
                                    if (component.InstanceID == current2.InstanceID)
                                    {
                                        flag2 = true;
                                        break;
                                    }
                                }
                                foreach (KPrefabID current3 in data.plants)
                                {
                                    if (component.InstanceID == current3.InstanceID)
                                    {
                                        flag2 = true;
                                        break;
                                    }
                                }
                                if (!flag2)
                                {
                                    if (component.GetComponent <Deconstructable> ())
                                    {
                                        data.AddBuilding(component);
                                    }
                                    else
                                    {
                                        if (component.HasTag(GameTags.Plant) && !component.HasTag("ForestTreeBranch".ToTag()))
                                        {
                                            data.AddPlants(component);
                                        }
                                    }
                                }
                            }
                        }
                    }
                }
            }
 private static void CollectSortedClearables(Navigator navigator, KCompactedVector <MarkedClearable> clearables, List <SortedClearable> sorted_clearables)
 {
     sorted_clearables.Clear();
     foreach (MarkedClearable data in clearables.GetDataList())
     {
         MarkedClearable current        = data;
         int             navigationCost = current.pickupable.GetNavigationCost(navigator, current.pickupable.cachedCell);
         if (navigationCost != -1)
         {
             sorted_clearables.Add(new SortedClearable
             {
                 pickupable     = current.pickupable,
                 masterPriority = current.prioritizable.GetMasterPriority(),
                 cost           = navigationCost
             });
         }
     }
     sorted_clearables.Sort(SortedClearable.comparer);
 }
Ejemplo n.º 4
0
        internal BackgroundRoomProber()
        {
            int n = Grid.CellCount;

            allRooms        = Game.Instance.roomProber.rooms;
            buildingChanges = new ConcurrentQueue <int>();
            cavityForCell   = new HandleVector <int> .Handle[n];
            cavityInfos     = new KCompactedVector <CavityInfo>(2048);
            // ConcurrentBag is leaky and slow: https://ayende.com/blog/156097/the-high-cost-of-concurrentbag-in-net-4-0
            destroyed           = new ConcurrentQueue <HandleVector <int> .Handle>();
            disposed            = false;
            floodFilling        = new Queue <int>();
            initialized         = false;
            pendingDestroy      = new HashSet <HandleVector <int> .Handle>();
            pendingSolidChanges = new HashSet <int>();
            roomsChanged        = new AutoResetEvent(false);
            solidChanges        = new ConcurrentQueue <int>();
            tempIDs             = new List <KPrefabID>(32);
            visitedCells        = new HashSet <int>();
            for (int i = 0; i < n; i++)
            {
                cavityForCell[i].Clear();
            }
        }
 public Cmps()
 {
     App.OnPreLoadScene = (System.Action)Delegate.Combine(App.OnPreLoadScene, new System.Action(Clear));
     items = new KCompactedVector <T>(0);
     table = new Dictionary <T, HandleVector <int> .Handle>();
 }