Example #1
0
	private void OnCellChange()
	{
		Vector3 position = base.transform.GetPosition();
		int num = Grid.PosToCell(position);
		if (!Grid.IsValidCell(num))
		{
			Vector2 vector = new Vector2(-0.1f * (float)Grid.WidthInCells, 1.1f * (float)Grid.WidthInCells);
			Vector2 vector2 = new Vector2(-0.1f * (float)Grid.HeightInCells, 1.1f * (float)Grid.HeightInCells);
			if (position.x < vector.x || vector.y < position.x || position.y < vector2.x || vector2.y < position.y)
			{
				this.DeleteObject();
			}
		}
		else
		{
			ReleaseEntombedVisualizerAndAddFaller(true);
			if (!HandleSolidCell(num))
			{
				objectLayerListItem.Update(num);
				bool flag = false;
				if (absorbable && !KPrefabID.HasTag(GameTags.Stored))
				{
					int num2 = Grid.CellBelow(num);
					if (Grid.IsValidCell(num2) && Grid.Solid[num2])
					{
						ObjectLayerListItem nextItem = objectLayerListItem.nextItem;
						while (nextItem != null)
						{
							GameObject gameObject = nextItem.gameObject;
							nextItem = nextItem.nextItem;
							Pickupable component = gameObject.GetComponent<Pickupable>();
							if ((UnityEngine.Object)component != (UnityEngine.Object)null)
							{
								flag = component.TryAbsorb(this, false, false);
								if (flag)
								{
									break;
								}
							}
						}
					}
				}
				GameScenePartitioner.Instance.UpdatePosition(solidPartitionerEntry, num);
				GameScenePartitioner.Instance.UpdatePosition(partitionerEntry, num);
				int cachedCell = this.cachedCell;
				UpdateCachedCell(num);
				if (!flag)
				{
					NotifyChanged(num);
				}
				if (Grid.IsValidCell(cachedCell) && num != cachedCell)
				{
					NotifyChanged(cachedCell);
				}
			}
		}
	}