Example #1
0
    protected override void OnDragTool(int cell, int distFromOrigin)
    {
        GameObject gameObject = Grid.Objects[cell, 3];

        if (!((Object)gameObject == (Object)null))
        {
            ObjectLayerListItem objectLayerListItem = gameObject.GetComponent <Pickupable>().objectLayerListItem;
            while (objectLayerListItem != null)
            {
                GameObject gameObject2 = objectLayerListItem.gameObject;
                objectLayerListItem = objectLayerListItem.nextItem;
                if (!((Object)gameObject2 == (Object)null) && !((Object)gameObject2.GetComponent <MinionIdentity>() != (Object)null))
                {
                    Clearable component = gameObject2.GetComponent <Clearable>();
                    if (component.isClearable)
                    {
                        gameObject2.GetComponent <Clearable>().MarkForClear(false);
                        Prioritizable component2 = gameObject2.GetComponent <Prioritizable>();
                        if ((Object)component2 != (Object)null)
                        {
                            component2.SetMasterPriority(ToolMenu.Instance.PriorityScreen.GetLastSelectedPriority());
                        }
                    }
                }
            }
        }
    }
Example #2
0
    protected override void OnDragTool(int cell, int distFromOrigin)
    {
        PrioritySetting lastSelectedPriority = ToolMenu.Instance.PriorityScreen.GetLastSelectedPriority();
        int             num = 0;

        for (int i = 0; i < 39; i++)
        {
            GameObject gameObject = Grid.Objects[cell, i];
            if ((Object)gameObject != (Object)null)
            {
                if ((bool)gameObject.GetComponent <Pickupable>())
                {
                    ObjectLayerListItem objectLayerListItem = gameObject.GetComponent <Pickupable>().objectLayerListItem;
                    while (objectLayerListItem != null)
                    {
                        GameObject gameObject2 = objectLayerListItem.gameObject;
                        objectLayerListItem = objectLayerListItem.nextItem;
                        if (!((Object)gameObject2 == (Object)null) && !((Object)gameObject2.GetComponent <MinionIdentity>() != (Object)null) && TryPrioritizeGameObject(gameObject2, lastSelectedPriority))
                        {
                            num++;
                        }
                    }
                }
                else if (TryPrioritizeGameObject(gameObject, lastSelectedPriority))
                {
                    num++;
                }
            }
        }
        if (num > 0)
        {
            PriorityScreen.PlayPriorityConfirmSound(lastSelectedPriority);
        }
    }
Example #3
0
        private void TryMergeWithOthers()
        {
            Pickupable pickupable = GetComponent <Pickupable>();

            if (!pickupable.absorbable)
            {
                return;
            }

            Vector3 thisPosition = transform.GetPosition();

            int cell = Helpers.PosToCell(transform.position);

            pickupable.objectLayerListItem.Update(cell);
            for (ObjectLayerListItem i = pickupable.objectLayerListItem.nextItem; i != null; i = i.nextItem)
            {
                Pickupable target = i.gameObject.GetComponent <Pickupable>();
                if (target?.TryAbsorb(pickupable, false) == true)
                {
                    // Offset the position to make it look less like one of the objects are vanishing
                    target.transform.SetPosition((thisPosition + target.transform.GetPosition()) / 2);
                    break;
                }
            }
        }
Example #4
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);
				}
			}
		}
	}
 private void OnCancel(object data)
 {
     for (ObjectLayerListItem objectLayerListItem = pickupable.objectLayerListItem; objectLayerListItem != null; objectLayerListItem = objectLayerListItem.nextItem)
     {
         if ((UnityEngine.Object)objectLayerListItem.gameObject != (UnityEngine.Object)null)
         {
             objectLayerListItem.gameObject.GetComponent <Clearable>().CancelClearing();
         }
     }
 }
Example #6
0
	public void UnregisterListeners()
	{
		if (objectLayerListItem != null)
		{
			objectLayerListItem.Clear();
			objectLayerListItem = null;
		}
		GameScenePartitioner.Instance.Free(ref solidPartitionerEntry);
		GameScenePartitioner.Instance.Free(ref partitionerEntry);
		Singleton<CellChangeMonitor>.Instance.UnregisterCellChangedHandler(base.transform, OnCellChange);
	}
Example #7
0
	public void RegisterListeners()
	{
		if (!cleaningUp && !solidPartitionerEntry.IsValid())
		{
			int num = Grid.PosToCell(this);
			objectLayerListItem = new ObjectLayerListItem(base.gameObject, ObjectLayer.Pickupables, num);
			solidPartitionerEntry = GameScenePartitioner.Instance.Add("Pickupable.RegisterSolidListener", base.gameObject, num, GameScenePartitioner.Instance.solidChangedLayer, OnSolidChanged);
			partitionerEntry = GameScenePartitioner.Instance.Add("Pickupable.RegisterPickupable", this, num, GameScenePartitioner.Instance.pickupablesLayer, null);
			Singleton<CellChangeMonitor>.Instance.RegisterCellChangedHandler(base.transform, OnCellChange, "Pickupable.OnCellChange");
			Singleton<CellChangeMonitor>.Instance.MarkDirty(base.transform);
		}
	}
        protected override void OnDragTool(int cell, int distFromOrigin)
        {
            PrioritySetting selectedPriority  = ToolMenu.Instance.PriorityScreen.GetLastSelectedPriority();
            int             prioritiesChanged = 0;

            for (int index = 0; index < 40; ++index)
            {
                GameObject gameObject = Grid.Objects[cell, index];

                if (gameObject != null)
                {
                    if (gameObject.GetComponent <Pickupable>())
                    {
                        ObjectLayerListItem objectLayerListItem = gameObject.GetComponent <Pickupable>().objectLayerListItem;

                        while (objectLayerListItem != null)
                        {
                            GameObject currentObject = objectLayerListItem.gameObject;
                            objectLayerListItem = objectLayerListItem.nextItem;

                            if (currentObject != null && !(currentObject.GetComponent <MinionIdentity>() != null && TryPrioritizeGameObject(currentObject, selectedPriority)))
                            {
                                ++prioritiesChanged;
                            }
                        }
                    }

                    else if (TryPrioritizeGameObject(gameObject, selectedPriority))
                    {
                        ++prioritiesChanged;
                    }
                }
            }

            if (prioritiesChanged > 0)
            {
                PriorityScreen.PlayPriorityConfirmSound(selectedPriority);
            }
        }
Example #9
0
 public bool Refresh(int new_cell)
 {
     if (cell != new_cell)
     {
         if (cell != Grid.InvalidCell && (Object)Grid.Objects[cell, (int)layer] == (Object)this.gameObject)
         {
             GameObject value = null;
             if (nextItem != null && (Object)nextItem.gameObject != (Object)null)
             {
                 value = nextItem.gameObject;
             }
             Grid.Objects[cell, (int)layer] = value;
         }
         if (previousItem != null)
         {
             previousItem.nextItem = nextItem;
         }
         if (nextItem != null)
         {
             nextItem.previousItem = previousItem;
         }
         previousItem = null;
         nextItem     = null;
         cell         = new_cell;
         if (cell != Grid.InvalidCell)
         {
             GameObject gameObject = Grid.Objects[cell, (int)layer];
             if ((Object)gameObject != (Object)null && (Object)gameObject != (Object)this.gameObject)
             {
                 ObjectLayerListItem objectLayerListItem2 = nextItem = gameObject.GetComponent <Pickupable>().objectLayerListItem;
                 objectLayerListItem2.previousItem = this;
             }
             Grid.Objects[cell, (int)layer] = this.gameObject;
         }
         return(true);
     }
     return(false);
 }