public HandleVector <int> .Handle Add(string name, object obj, int x, int y, int width, int height, ScenePartitionerLayer layer, Action <object> event_callback)
    {
        ScenePartitionerEntry scenePartitionerEntry = new ScenePartitionerEntry(name, obj, x, y, width, height, layer, partitioner, event_callback);

        partitioner.Add(scenePartitionerEntry);
        return(scenePartitionerEntries.Allocate(scenePartitionerEntry));
    }
    private CavityInfo CreateNewCavity()
    {
        CavityInfo cavityInfo = new CavityInfo();

        cavityInfo.handle = cavityInfos.Allocate(cavityInfo);
        return(cavityInfo);
    }
 public HandleVector <int> .Handle RegisterClearable(Clearable clearable)
 {
     return(markedClearables.Allocate(new MarkedClearable
     {
         clearable = clearable,
         pickupable = clearable.GetComponent <Pickupable>(),
         prioritizable = clearable.GetComponent <Prioritizable>()
     }));
 }
 public void Add(T cmp)
 {
     HandleVector <int> .Handle value = items.Allocate(cmp);
     table[cmp] = value;
     if (this.OnAdd != null)
     {
         this.OnAdd(cmp);
     }
 }
示例#5
0
    public HandleVector <int> .Handle Add(DataType data, float last_update_time, IUpdater updater)
    {
        Entry entry = default(Entry);

        entry.data           = data;
        entry.lastUpdateTime = last_update_time;
        entry.updater        = updater;
        HandleVector <int> .Handle handle = entries.Allocate(entry);
        entries.SetData(handle, entry);
        return(handle);
    }
        public HandleVector <int> .Handle AddPickupable(Pickupable pickupable)
        {
            byte   foodQuality = 5;
            Edible component   = pickupable.GetComponent <Edible>();

            if ((Object)component != (Object)null)
            {
                foodQuality = (byte)component.GetQuality();
            }
            byte          masterPriority = 0;
            Prioritizable prioritizable  = null;

            if ((Object)pickupable.storage != (Object)null)
            {
                prioritizable = pickupable.storage.prioritizable;
                if ((Object)prioritizable != (Object)null)
                {
                    PrioritySetting masterPriority2 = prioritizable.GetMasterPriority();
                    masterPriority = (byte)masterPriority2.priority_value;
                }
            }
            Rottable.Instance sMI = pickupable.GetSMI <Rottable.Instance>();
            byte freshness        = 0;

            if (!sMI.IsNullOrStopped())
            {
                freshness = QuantizeRotValue(sMI.RotValue);
            }
            KPrefabID component2 = pickupable.GetComponent <KPrefabID>();
            TagBits   rhs        = new TagBits(ref disallowedTagMask);

            component2.AndTagBits(ref rhs);
            HandleVector <int> .Handle handle = fetchables.Allocate(new Fetchable
            {
                pickupable     = pickupable,
                foodQuality    = foodQuality,
                freshness      = freshness,
                masterPriority = masterPriority,
                tagBitsHash    = rhs.GetHashCode()
            });
            if (!sMI.IsNullOrStopped())
            {
                rotUpdaters[handle] = sMI;
            }
            return(handle);
        }
示例#7
0
    public HandleVector <int> .Handle Add(string path, Vector2 pos, Transform transform = null, bool pause_on_game_pause = true, bool enable_culling = true, bool enable_camera_scaled_position = true)
    {
        SoundDescription soundEventDescription = KFMOD.GetSoundEventDescription(path);

        Sound.Flags flags = (Sound.Flags) 0;
        if (pause_on_game_pause)
        {
            flags |= Sound.Flags.PAUSE_ON_GAME_PAUSED;
        }
        if (enable_culling)
        {
            flags |= Sound.Flags.ENABLE_CULLING;
        }
        if (enable_camera_scaled_position)
        {
            flags |= Sound.Flags.ENABLE_CAMERA_SCALED_POSITION;
        }
        KBatchedAnimController animController = null;

        if ((UnityEngine.Object)transform != (UnityEngine.Object)null)
        {
            animController = transform.GetComponent <KBatchedAnimController>();
        }
        Sound sound = default(Sound);

        sound.transform         = transform;
        sound.animController    = animController;
        sound.falloffDistanceSq = soundEventDescription.falloffDistanceSq;
        sound.path            = path;
        sound.pos             = pos;
        sound.flags           = flags;
        sound.firstParameter  = HashedString.Invalid;
        sound.secondParameter = HashedString.Invalid;
        Sound initial_data = sound;

        return(sounds.Allocate(initial_data));
    }
        /// <summary>
        /// If the cell is not already in a valid room, creates a room with this cell as the
        /// seed.
        /// </summary>
        /// <param name="cell">The starting cell.</param>
        private void CreateCavityFrom(int cell)
        {
            var visited = visitedCells;

            if (!RoomProber.CavityFloodFiller.IsWall(cell) && visited.Add(cell))
            {
                int n = 0, minX = int.MaxValue, minY = int.MaxValue, maxX = int.MinValue,
                    maxY = int.MinValue;
                bool filled;
                HandleVector <int> .Handle targetCavity;
                var queue  = floodFilling;
                var cavity = new CavityInfo();
                lock (cavityInfos) {
                    targetCavity = cavityInfos.Allocate(cavity);
                }
                do
                {
                    if (RoomProber.CavityFloodFiller.IsWall(cell))
                    {
                        // Walls and doors have no room
                        cavityForCell[cell].Clear();
                    }
                    else
                    {
                        int above = Grid.CellAbove(cell), below = Grid.CellBelow(cell),
                            left = Grid.CellLeft(cell), right = Grid.CellRight(cell);
                        Grid.CellToXY(cell, out int x, out int y);
                        cavityForCell[cell] = targetCavity;
                        n++;
                        if (x < minX)
                        {
                            minX = x;
                        }
                        if (x > maxX)
                        {
                            maxX = x;
                        }
                        if (y < minY)
                        {
                            minY = y;
                        }
                        if (y > maxY)
                        {
                            maxY = y;
                        }
                        buildingChanges.Enqueue(cell);
                        if (Grid.IsValidCell(above) && visited.Add(above))
                        {
                            queue.Enqueue(above);
                        }
                        if (Grid.IsValidCell(below) && visited.Add(below))
                        {
                            queue.Enqueue(below);
                        }
                        if (Grid.IsValidCell(left) && visited.Add(left))
                        {
                            queue.Enqueue(left);
                        }
                        if (Grid.IsValidCell(right) && visited.Add(right))
                        {
                            queue.Enqueue(right);
                        }
                    }
                    filled = queue.Count > 0;
                    if (filled)
                    {
                        cell = queue.Dequeue();
                    }
                } while (filled);
                cavity.minX     = minX;
                cavity.minY     = minY;
                cavity.maxX     = maxX;
                cavity.maxY     = maxY;
                cavity.numCells = n;
            }
        }