private void OnPickupablesChanged(object data)
    {
        float num  = 0f;
        int   cell = Grid.CellAbove(this.NaturalBuildingCell());

        ListPool <ScenePartitionerEntry, LogicMassSensor> .PooledList pooledList = ListPool <ScenePartitionerEntry, LogicMassSensor> .Allocate();

        GameScenePartitioner instance = GameScenePartitioner.Instance;
        Vector2I             vector2I = Grid.CellToXY(cell);
        int      x         = vector2I.x;
        Vector2I vector2I2 = Grid.CellToXY(cell);

        instance.GatherEntries(x, vector2I2.y, 1, 1, GameScenePartitioner.Instance.pickupablesLayer, pooledList);
        for (int i = 0; i < pooledList.Count; i++)
        {
            Pickupable pickupable = pooledList[i].obj as Pickupable;
            if (!((Object)pickupable == (Object)null) && !pickupable.wasAbsorbed)
            {
                KPrefabID component = pickupable.GetComponent <KPrefabID>();
                if (!component.HasTag(GameTags.Creature) || component.HasTag(GameTags.Creatures.Walker) || component.HasTag(GameTags.Creatures.Hoverer) || pickupable.HasTag(GameTags.Creatures.Flopping))
                {
                    num += pickupable.PrimaryElement.Mass;
                }
            }
        }
        pooledList.Recycle();
        massPickupables = num;
    }
Example #2
0
        public void PollForReactables(Navigator.ActiveTransition transition)
        {
            if (!IsReacting())
            {
                if (justReacted)
                {
                    justReacted = false;
                }
                else
                {
                    lastReactable = null;
                }
                for (int num = oneshotReactables.Count - 1; num >= 0; num--)
                {
                    Reactable reactable = oneshotReactables[num];
                    if (reactable.IsExpired())
                    {
                        reactable.Cleanup();
                    }
                }
                int cell = Grid.PosToCell(base.smi.gameObject);
                ListPool <ScenePartitionerEntry, ReactionMonitor> .PooledList pooledList = ListPool <ScenePartitionerEntry, ReactionMonitor> .Allocate();

                GameScenePartitioner instance = GameScenePartitioner.Instance;
                Vector2I             vector2I = Grid.CellToXY(cell);
                int      x         = vector2I.x;
                Vector2I vector2I2 = Grid.CellToXY(cell);
                instance.GatherEntries(x, vector2I2.y, 1, 1, GameScenePartitioner.Instance.objectLayers[0], pooledList);
                for (int i = 0; i < pooledList.Count; i++)
                {
                    Reactable reactable2 = pooledList[i].obj as Reactable;
                    if (reactable2 != null && reactable2 != lastReactable && (!lastReactTimes.ContainsKey(reactable2.id) || !(GameClock.Instance.GetTime() - lastReactTimes[reactable2.id] < reactable2.minReactorTime)) && reactable2.CanBegin(base.gameObject, transition))
                    {
                        justReacted   = true;
                        lastReactable = reactable2;
                        lastReactTimes[reactable2.id] = GameClock.Instance.GetTime();
                        base.sm.reactable.Set(reactable2, base.smi);
                        base.smi.GoTo(base.sm.reacting);
                        break;
                    }
                }
                pooledList.Recycle();
            }
        }
    private void OnActivatorsChanged(object data)
    {
        float num  = 0f;
        int   cell = Grid.CellAbove(this.NaturalBuildingCell());

        ListPool <ScenePartitionerEntry, LogicMassSensor> .PooledList pooledList = ListPool <ScenePartitionerEntry, LogicMassSensor> .Allocate();

        GameScenePartitioner instance = GameScenePartitioner.Instance;
        Vector2I             vector2I = Grid.CellToXY(cell);
        int      x         = vector2I.x;
        Vector2I vector2I2 = Grid.CellToXY(cell);

        instance.GatherEntries(x, vector2I2.y, 1, 1, GameScenePartitioner.Instance.floorSwitchActivatorLayer, pooledList);
        for (int i = 0; i < pooledList.Count; i++)
        {
            FloorSwitchActivator floorSwitchActivator = pooledList[i].obj as FloorSwitchActivator;
            if (!((Object)floorSwitchActivator == (Object)null))
            {
                num += floorSwitchActivator.PrimaryElement.Mass;
            }
        }
        pooledList.Recycle();
        massActivators = num;
    }