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; }
protected override void OnForcedCleanUp() { instance = null; partitioner.FreeResources(); partitioner = null; solidChangedLayer = null; liquidChangedLayer = null; digDestroyedLayer = null; fogOfWarChangedLayer = null; decorProviderLayer = null; attackableEntitiesLayer = null; fetchChoreLayer = null; pickupablesLayer = null; pickupablesChangedLayer = null; gasConduitsLayer = null; liquidConduitsLayer = null; solidConduitsLayer = null; noisePolluterLayer = null; validNavCellChangedLayer = null; dirtyNavCellUpdateLayer = null; trapsLayer = null; floorSwitchActivatorLayer = null; floorSwitchActivatorChangedLayer = null; objectLayers = null; }
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; }
protected override void OnPrefabInit() { Debug.Assert((UnityEngine.Object)instance == (UnityEngine.Object)null); instance = this; partitioner = new ScenePartitioner(16, 64, Grid.WidthInCells, Grid.HeightInCells); solidChangedLayer = partitioner.CreateMask("SolidChanged"); liquidChangedLayer = partitioner.CreateMask("LiquidChanged"); digDestroyedLayer = partitioner.CreateMask("DigDestroyed"); fogOfWarChangedLayer = partitioner.CreateMask("FogOfWarChanged"); decorProviderLayer = partitioner.CreateMask("DecorProviders"); attackableEntitiesLayer = partitioner.CreateMask("FactionedEntities"); fetchChoreLayer = partitioner.CreateMask("FetchChores"); pickupablesLayer = partitioner.CreateMask("Pickupables"); pickupablesChangedLayer = partitioner.CreateMask("PickupablesChanged"); gasConduitsLayer = partitioner.CreateMask("GasConduit"); liquidConduitsLayer = partitioner.CreateMask("LiquidConduit"); solidConduitsLayer = partitioner.CreateMask("SolidConduit"); noisePolluterLayer = partitioner.CreateMask("NoisePolluters"); validNavCellChangedLayer = partitioner.CreateMask("validNavCellChangedLayer"); dirtyNavCellUpdateLayer = partitioner.CreateMask("dirtyNavCellUpdateLayer"); trapsLayer = partitioner.CreateMask("trapsLayer"); floorSwitchActivatorLayer = partitioner.CreateMask("FloorSwitchActivatorLayer"); floorSwitchActivatorChangedLayer = partitioner.CreateMask("FloorSwitchActivatorChangedLayer"); collisionLayer = partitioner.CreateMask("Collision"); lure = partitioner.CreateMask("Lure"); plants = partitioner.CreateMask("Plants"); industrialBuildings = partitioner.CreateMask("IndustrialBuildings"); completeBuildings = partitioner.CreateMask("CompleteBuildings"); prioritizableObjects = partitioner.CreateMask("PrioritizableObjects"); objectLayers = new ScenePartitionerLayer[39]; for (int i = 0; i < 39; i++) { ObjectLayer objectLayer = (ObjectLayer)i; objectLayers[i] = partitioner.CreateMask(new HashedString(objectLayer.ToString())); } }