private void OnDragState(bool start) { if (start) { if (!this.dragging && !this.startedNoItem) { UICamera.Cursor.DropNotification = DropNotificationFlags.DragLand | DropNotificationFlags.AltLand | DropNotificationFlags.RegularHover | DropNotificationFlags.DragLandOutside; this.lastLanding = null; this.dragging = true; RPOS.Item_CellDragBegin(this); UICamera.Cursor.CurrentButton.ClickNotification = UICamera.ClickNotification.BasedOnDelta; } } else if (this.dragging) { this.dragging = false; if (!this.lastLanding) { RPOS.Item_CellReset(); } else { this.dragging = false; RPOS.Item_CellDragEnd(this, this.lastLanding); UICamera.Cursor.Buttons.LeftValue.ClickNotification = UICamera.ClickNotification.None; } } }
public bool SetHeldItem(RPOSInventoryCell cell) { Vector3 vector3; IInventoryItem inventoryItem; if (!cell) { inventoryItem = null; } else { inventoryItem = cell.slotItem; } if (!this.SetHeldItem(inventoryItem)) { return(false); } try { if (NGUITools.GetCentroid(cell, out vector3)) { Vector2 screenPoint = UICamera.FindCameraForLayer(cell.gameObject.layer).cachedCamera.WorldToScreenPoint(vector3); this.offsetPoint = screenPoint - UICamera.lastMousePosition; } } catch { this.offsetPoint = Vector3.zero; } return(true); }
public void SetInventory(Inventory newInv, bool spawnNewCells) { this.displayInventory = newInv; if (spawnNewCells && this.SpawnCells) { this.generatedCells = true; for (int i = 0; i < (int)this._inventoryCells.Length; i++) { UnityEngine.Object.Destroy(this._inventoryCells[i].gameObject); this._inventoryCells[i] = null; } this.NumCellsVertical = Mathf.CeilToInt((float)newInv.slotCount / 3f); this.CreateCellsOnGameObject(newInv, base.gameObject); } int num = 0; RPOSInventoryCell[] rPOSInventoryCellArray = this._inventoryCells; for (int j = 0; j < (int)rPOSInventoryCellArray.Length; j++) { RPOSInventoryCell cellIndexStart = rPOSInventoryCellArray[j]; cellIndexStart._displayInventory = newInv; cellIndexStart._mySlot = (byte)(this.CellIndexStart + num); newInv.MarkSlotDirty((int)cellIndexStart._mySlot); num++; } }
private void OnAltLand(GameObject landing) { RPOSInventoryCell component = landing.GetComponent <RPOSInventoryCell>(); if (component != null) { RPOS.ItemCellAltClicked(component); } }
protected virtual void CreateCellsOnGameObject(Inventory inven, GameObject parent) { int numCells; int end; Inventory.Slot.Range range; if (!inven) { numCells = this.GetNumCells(); end = 2147483647; } else { inven.GetSlotsOfKind(Inventory.Slot.Kind.Default, out range); numCells = range.Count; end = range.End; } Array.Resize <RPOSInventoryCell>(ref this._inventoryCells, numCells); Vector3 component = this.CellPrefab.GetComponent <RPOSInventoryCell>()._background.transform.localScale; float single = component.x; Vector3 vector3 = this.CellPrefab.GetComponent <RPOSInventoryCell>()._background.transform.localScale; float single1 = vector3.y; for (int i = 0; i < this.NumCellsVertical; i++) { for (int j = 0; j < this.NumCellsHorizontal; j++) { byte cellIndexStart = (byte)(this.CellIndexStart + RPOSInvCellManager.GetIndex2D(j, i, this.NumCellsHorizontal)); if (cellIndexStart >= end) { return; } GameObject gameObject = NGUITools.AddChild(parent, this.CellPrefab); RPOSInventoryCell str = gameObject.GetComponent <RPOSInventoryCell>(); str._mySlot = cellIndexStart; str._displayInventory = inven; if (this.NumberedCells) { int index2D = RPOSInvCellManager.GetIndex2D(j, i, this.NumCellsHorizontal) + 1; str._numberLabel.text = index2D.ToString(); } gameObject.transform.localPosition = new Vector3((float)this.CellOffsetX + ((float)j * single + (float)(j * this.CellSpacing)), -((float)this.CellOffsetY + ((float)i * single1 + (float)(i * this.CellSpacing))), -2f); this._inventoryCells[RPOS.GetIndex2D(j, i, this.NumCellsHorizontal)] = gameObject.GetComponent <RPOSInventoryCell>(); } } if (this.CenterFromCells) { if (this.NumCellsHorizontal > 1) { base.transform.localPosition = new Vector3((float)(this.CellOffsetX + this.NumCellsHorizontal * this.CellSize + (this.NumCellsHorizontal - 1) * this.CellSpacing) * -0.5f, (float)this.CellSize, 0f); } else if (this.NumCellsVertical > 1) { base.transform.localPosition = new Vector3((float)(-this.CellSize), (float)(this.CellOffsetY + this.NumCellsVertical * this.CellSize) * 0.5f, 0f); } } }
protected virtual void CreateCellsOnGameObject(Inventory inven, GameObject parent) { int count; int end; if (inven != null) { Inventory.Slot.Range range; inven.GetSlotsOfKind(Inventory.Slot.Kind.Default, out range); count = range.Count; end = range.End; } else { count = this.GetNumCells(); end = 0x7fffffff; } Array.Resize <RPOSInventoryCell>(ref this._inventoryCells, count); float x = this.CellPrefab.GetComponent <RPOSInventoryCell>()._background.transform.localScale.x; float y = this.CellPrefab.GetComponent <RPOSInventoryCell>()._background.transform.localScale.y; for (int i = 0; i < this.NumCellsVertical; i++) { for (int j = 0; j < this.NumCellsHorizontal; j++) { byte num7 = (byte)(this.CellIndexStart + GetIndex2D(j, i, this.NumCellsHorizontal)); if (num7 >= end) { return; } GameObject obj2 = NGUITools.AddChild(parent, this.CellPrefab); RPOSInventoryCell component = obj2.GetComponent <RPOSInventoryCell>(); component._mySlot = num7; component._displayInventory = inven; if (this.NumberedCells) { component._numberLabel.text = (GetIndex2D(j, i, this.NumCellsHorizontal) + 1).ToString(); } obj2.transform.localPosition = new Vector3(this.CellOffsetX + ((j * x) + (j * this.CellSpacing)), -(this.CellOffsetY + ((i * y) + (i * this.CellSpacing))), -2f); this._inventoryCells[RPOS.GetIndex2D(j, i, this.NumCellsHorizontal)] = obj2.GetComponent <RPOSInventoryCell>(); } } if (this.CenterFromCells) { if (this.NumCellsHorizontal > 1) { base.transform.localPosition = new Vector3((this.CellOffsetX + ((this.NumCellsHorizontal * this.CellSize) + ((this.NumCellsHorizontal - 1) * this.CellSpacing))) * -0.5f, (float)this.CellSize, 0f); } else if (this.NumCellsVertical > 1) { base.transform.localPosition = new Vector3((float)-this.CellSize, (this.CellOffsetY + (this.NumCellsVertical * this.CellSize)) * 0.5f, 0f); } } }
private void SetCellsLocked(bool isLocked) { RPOSInvCellManager componentInChildren = base.GetComponentInChildren <RPOSInvCellManager>(); for (int i = 0; i < componentInChildren._inventoryCells.Length; i++) { RPOSInventoryCell cell = componentInChildren._inventoryCells[i]; if (cell != null) { cell.SetItemLocked(isLocked); } } }
public void ClearHeldItem(RPOSInventoryCell fadeToCell) { Vector3 vector3; if (this.hasItem) { this.fadingOut = true; this.ClearHeldItem(); try { if (NGUITools.GetCentroid(fadeToCell, out vector3)) { this.FadeOutToPoint(vector3); } return; } catch { } this.Opaque(); } }
public bool SetHeldItem(RPOSInventoryCell cell) { if (!this.SetHeldItem((cell == null) ? null : cell.slotItem)) { return(false); } try { Vector3 vector; if (NGUITools.GetCentroid(cell, out vector)) { Vector2 vector2 = UICamera.FindCameraForLayer(cell.gameObject.layer).cachedCamera.WorldToScreenPoint(vector); this.offsetPoint = (Vector3)(vector2 - UICamera.lastMousePosition); } } catch { this.offsetPoint = Vector3.zero; } return(true); }
public void ClearHeldItem(RPOSInventoryCell fadeToCell) { Vector3 vector3; if (this.hasItem) { this.fadingOut = true; this.ClearHeldItem(); try { if (NGUITools.GetCentroid(fadeToCell, out vector3)) { this.FadeOutToPoint(vector3); } return; } catch { } this.Opaque(); } }
private void OnLand(GameObject landing) { this.lastLanding = landing.GetComponent <RPOSInventoryCell>(); }
public bool SetHeldItem(RPOSInventoryCell cell) { Vector3 vector3; IInventoryItem inventoryItem; if (!cell) { inventoryItem = null; } else { inventoryItem = cell.slotItem; } if (!this.SetHeldItem(inventoryItem)) { return false; } try { if (NGUITools.GetCentroid(cell, out vector3)) { Vector2 screenPoint = UICamera.FindCameraForLayer(cell.gameObject.layer).cachedCamera.WorldToScreenPoint(vector3); this.offsetPoint = screenPoint - UICamera.lastMousePosition; } } catch { this.offsetPoint = Vector3.zero; } return true; }
private void OnLand(GameObject landing) { this.lastLanding = landing.GetComponent<RPOSInventoryCell>(); }
private void OnDragState(bool start) { if (start) { if (!this.dragging && !this.startedNoItem) { UICamera.Cursor.DropNotification = DropNotificationFlags.DragLand | DropNotificationFlags.AltLand | DropNotificationFlags.RegularHover | DropNotificationFlags.DragLandOutside; this.lastLanding = null; this.dragging = true; RPOS.Item_CellDragBegin(this); UICamera.Cursor.CurrentButton.ClickNotification = UICamera.ClickNotification.BasedOnDelta; } } else if (this.dragging) { this.dragging = false; if (!this.lastLanding) { RPOS.Item_CellReset(); } else { this.dragging = false; RPOS.Item_CellDragEnd(this, this.lastLanding); UICamera.Cursor.Buttons.LeftValue.ClickNotification = UICamera.ClickNotification.None; } } }