/// <summary> /// Отрисовка предмета в инвентаре /// </summary> /// <param name="item">Рисуемый предмет</param> /// <param name="offsetX">Смещение (позиция) инвентаря по x</param> /// <param name="offsetY">Смещение (позиция) инвентаря по y</param> /// <param name="fixWebPosition">при fixWebPosition=true предмет рисуется "в сетке"</param> /// <param name="drawIcon">при drawIcon=false, предмет рисуется без иконки</param> public void DrawItem(ItemSlot item, float offsetX, float offsetY, bool fixWebPosition = true, bool drawIcon = true) { Rect cellRectangle; if (fixWebPosition) { cellRectangle = new Rect(offsetX + CellSettings.cellPaddingX + (item.position.X - 1) * CellSettings.cellWidth+shadowSize, offsetY + CellSettings.cellPaddingY + (item.position.Y - 1) * CellSettings.cellHeight+shadowSize, CellSettings.cellWidth, CellSettings.cellHeight); } else { cellRectangle = new Rect(offsetX+shadowSize, offsetY+shadowSize, CellSettings.cellWidth, CellSettings.cellHeight); } string description = item.item.getCount()>1? item.item.getCount().ToString()+CLang.getInstance().get(Dictionary.K_COUNT) : ""; GUI.Box(cellRectangle, description, labelShadow); cellRectangle.x-=shadowSize; cellRectangle.y-=shadowSize; if (drawIcon) labelStyle.normal.background = item.item.resource.icon; GUI.color = new Color(1f,1f,1f,1f); GUI.Box(cellRectangle, description, labelStyle); }
/// <summary> /// Base deserialization constructor. /// </summary> /// <param name="src"></param> internal Item(MarketGroup group, SerializableItem src) : this(src.ID, src.Name) { m_marketGroup = group; m_icon = src.Icon; m_race = src.Race; m_slot = src.Slot; m_family = src.Family; m_description = src.Description; m_metaLevel = src.MetaLevel; m_metaGroup = src.MetaGroup; m_reprocessing = new FastList<Material>(0); m_properties = new PropertiesCollection(src.Properties); // Skills prerequisites m_prerequisites = new FastList<StaticSkillLevel>((src.Prereqs != null ? src.Prereqs.Length : 0)); if (src.Prereqs == null) return; foreach (var prereq in src.Prereqs) { m_prerequisites.Add(new StaticSkillLevel(prereq.ID, prereq.Level)); } }
/// <summary> /// Raycasts from the mouse /// returns true if something was hit /// /// uses out to return relevant menu scripts /// /// </summary> /// <param name="hitInfo"></param> /// <param name="items"></param> /// <param name="itemSlots"></param> /// <returns></returns> public bool Raycast(out RaycastHit[] hitInfo, out Item[] items, out ItemSlot[] itemSlots) { items = new Item[0]; itemSlots = new ItemSlot[0]; hitInfo = Physics.RaycastAll (m_MainCamera.ScreenPointToRay (Input.mousePosition), RAYCAST_DISTANCE, m_RaycastMask.value); Debug.DrawLine (m_MainCamera.ScreenPointToRay(Input.mousePosition).origin, m_MainCamera.ScreenPointToRay(Input.mousePosition).origin + (m_MainCamera.ScreenPointToRay(Input.mousePosition).direction * RAYCAST_DISTANCE), Color.black, 1.0f); if(hitInfo.Length > 0) {//hit at least one menu thing List<Item> itemsFound = new List<Item>(); List<ItemSlot> itemSlotsFound = new List<ItemSlot>(); for(int i = 0; i < hitInfo.Length; i++) { Item item = hitInfo[i].collider.gameObject.GetComponent<Item>(); if (item != null) itemsFound.Add(item); ItemSlot itemSlot = hitInfo[i].collider.gameObject.GetComponent<ItemSlot>(); if (itemSlot != null) itemSlotsFound.Add(itemSlot); } items = itemsFound.ToArray(); itemSlots = itemSlotsFound.ToArray(); return true; } return false; }
public CraftingGrid(GameWorld GameWorld, Vector2 Position) { this.Position = Position; RecipePartIdMatching = new int[5, 5]; for (int y = 0; y < 5; y++) { for (int x = 0; x < 5; x++) { RecipeSlots[x, y] = new ItemSlot(GameWorld); RecipeSlots[x, y].Visible = true; Vector2 UpperLeftPos = Position + new Vector2(x * 34, y * 34); RecipeSlots[x, y].Position = new Rectangle((int)UpperLeftPos.X, (int)UpperLeftPos.Y, 32, 32); RecipeSlots[x, y].OnStackModified += UpdateGrid; RecipePartIdMatching[x, y] = -1; } } OutputSlot = new ItemSlot(GameWorld); OutputSlot.Visible = true; OutputSlot.State = ItemSlot.SlotState.InputLocked; OutputSlot.Position = new Rectangle((int)Position.X + 5 * 32 + 10, (int)Position.Y + 2 * 32, 32, 32); OutputSlot.OnStackModified += ItemCrafted; }
public static void SwapItemsNoReAdding(ItemSlot slot1, ItemSlot slot2) { Item tempItem = slot1.getItem(); slot1.m_Item = slot2.getItem(); slot2.m_Item = tempItem; slot1.getItem().OnMount(slot1); slot2.getItem().OnMount(slot2); }
public void Clear() { if(_tempRightClick != null) { NGUITools.Destroy(_tempRightClick); _tempRightClick = null; } _itemSlot = null; }
public void DrawCellsItem(float offsetX, float offsetY, ItemSlot item, Texture2D image) { Rect cellRect = new Rect(); cellRect.x = offsetX + (item.getPosition().X - 1) * CellSettings.cellWidth + CellSettings.cellPaddingX; cellRect.y = offsetY + (item.getPosition().Y - 1) * CellSettings.cellHeight + CellSettings.cellPaddingY; cellRect.width = CellSettings.cellWidth * item.item.getSize().getWidth(); cellRect.height = CellSettings.cellHeight * item.item.getSize().getHeight(); GUI.DrawTextureWithTexCoords(cellRect, image, textCoords); }
public void Swap (ItemSlot other) { if (!CanSwap (other)) return; var swapper = other.currentItem; other.currentItem = currentItem; currentItem = swapper; RestoreItem (); other.RestoreItem (); }
public EquipmentItem SetItem(ItemSlot slot, EquipmentItem item) { if (!(item is EquipmentItem)) return null; var eqItem = item as EquipmentItem; if (eqItem.RequiredSpecialisation != Specialisation.NONE && eqItem.RequiredSpecialisation != this.Specialisation) return null; EquipmentItem oldItem = null; if (Items.ContainsKey(slot)) oldItem = Items[slot]; Items[slot] = eqItem; return oldItem; }
/// <summary> /// C'tor /// </summary> /// <param name="_slotsData">Data about slot: slot key && available item types for the slot</param> /// <param name="onEquipmentUpdate"></param> public UnitInventory(Dictionary<EUnitEqupmentSlot, EItemType[]> _slotsData, ArrayRO<ItemSlot> _initialItems, Action<EUnitEqupmentSlot, EItemKey, EItemKey> onEquipmentUpdate) { _slotsConfig = _slotsData; _equipment = new ItemSlot[_slotsConfig.Count]; int i = 0; foreach(KeyValuePair<EUnitEqupmentSlot, EItemType[]> kvp in _slotsConfig) { _equipment[i] = new ItemSlot(kvp.Key, EItemKey.None); i++; } for (i = 0; i < _initialItems.Length; i++) { Equip(_initialItems[i].SlotName, _initialItems[i].ItemKey); } _onEquipmentUpdate = onEquipmentUpdate; }
public void Show(ItemSlot itemSlot) { Vector3 pos = Input.mousePosition; pos.x = Mathf.Clamp01(pos.x / Screen.width); pos.y = Mathf.Clamp01(pos.y / Screen.height); if(_tempRightClick == null) { _itemSlot = itemSlot; _tempRightClick = NGUITools.AddChild(this.gameObject.transform.parent.gameObject, RightClickPrefab); _tempRightClick.transform.position = _camera.ViewportToWorldPoint(pos); RightClickMaker m = _tempRightClick.GetComponent<RightClickMaker>(); m.Make(_itemSlot); } }
public Item(ItemTemplate template, double attack = 0, double magicAttack = 0, double accuracy = 0, double criticalRate = 0, double defense = 0, double magicDefense = 0, double strength = 0, double intelligence = 0, double dexterity = 0, double hp = 0) { this.Template = template; this.Name = template.Name; this.Level = template.Level; this.Slot = template.Slot; this.Attack = attack; this.MagicAttack = magicAttack; this.Accuracy = accuracy; this.CriticalRate = criticalRate; this.Defense = defense; this.MagicDefense = magicDefense; this.Strength = strength; this.Intelligence = intelligence; this.Dexterity = dexterity; this.HP = hp; }
public Item(string name, int level, ItemSlot slot, double attack = 0, double magicAttack = 0, double accuracy = 0, double criticalRate = 0, double defense = 0, double magicDefense = 0, double strength = 0, double intelligence = 0, double dexterity = 0, double hp = 0) { this.Template = null; this.Name = name; this.Level = level; this.Slot = slot; this.Attack = attack; this.MagicAttack = magicAttack; this.Accuracy = accuracy; this.CriticalRate = criticalRate; this.Defense = defense; this.MagicDefense = magicDefense; this.Strength = strength; this.Intelligence = intelligence; this.Dexterity = dexterity; this.HP = hp; }
// Update is called once per frame void Update () { if (this.targetList.Count != 0) { //제일 가까운놈을 찾아라.... //일단 첫번째 놈.... this.target = null; float miniumDistance = Mathf.Infinity; for (int i = 0 ; i < this.targetList.Count; i++) { this.targetList[i].TargetOff(); //거리 float nowDistance = (targetList[i].transform.position - this.transform.position).sqrMagnitude; //최초로 들어왔다면... if (this.target == null) { target = targetList[i]; miniumDistance = nowDistance; } //기존에 저장된 놈보다 작다면 갱신 else if (nowDistance < miniumDistance) { target = targetList[i]; miniumDistance = nowDistance; } } //타겟으로 잡힌 놈만 PlayOn this.target.TargetOn(); } else { this.target = null; } }
void Update () { UpdateHovered (); if (Input.GetButtonDown ("Swap")) { if (hovered != null && swapsThisNight.Count >= maxSwapPerNight) GiveWarning ("You have already used all of your swaps for this night."); else { if (initial != null) initial.OnStopHover (); initial = hovered; if (initial != null) { initial.OnSelectInitial (selectedColor); soundMgr.PlaySound (soundSrc, initialSelectSound); } } } if (Input.GetButtonUp ("Swap")) { if (initial != null && hovered != null && initial != hovered) { if (HasSwapBeenDoneThisNight (initial, hovered)) { GiveWarning ("You have already swapped those two items this night."); initial.OnStopHover (); soundMgr.PlaySound (soundSrc, failSound); } else { initial.Swap (hovered); swapsThisNight.Add (new KeyValuePair<string, string> (initial.currentItem.name, hovered.currentItem.name)); swapCounter.text = "Swap done: " + swapsThisNight.Count + " / " + maxSwapPerNight; hovered.OnHover (hoverColor); initial.OnStopHover (); initial = null; soundMgr.PlaySound (soundSrc, swapSound); } } else if (initial != null) { initial.OnStopHover (); if (initial == GetHoveredSlot ()) { hovered = initial; hovered.OnHover (hoverColor); } initial = null; soundMgr.PlaySound (soundSrc, failSound); } } }
private void SetItemInSlot(Item value, ItemSlot slot) { if (!CanEquip(value, slot)) return; var old = Equip.FirstOrDefault(i => i.Slot == slot); if (old != null) { Equip.Remove(old); old.Slot = ItemSlot.Unequipable; } if (value != null) { value.Slot = slot; Equip.Add(value); } OnPropertyChanged(slot.ToString()); RefreshItemAttributes(); }
// Reader public static object JsonDeserializer(Jboy.JsonReader reader) { if(reader.TryReadNull()) return null; var itemSlot = new ItemSlot(); reader.ReadObjectStart(); // ID reader.ReadPropertyName("item"); itemSlot.item = Jboy.Json.ReadObject<Item>(reader); // Count reader.ReadPropertyName("count"); itemSlot.count = (ulong)reader.ReadNumber(); reader.ReadObjectEnd(); return itemSlot; }
void SetEquipStatus(ItemSlot itemSlot) { var type = itemSlot.GetType(); if(type == typeof(StorageSlot)) { EquipButton.SetActive(true); UnequipButton.SetActive(false); } else if(type == typeof(EquipmentSlot)) { EquipButton.SetActive(false); UnequipButton.SetActive(true); } else { EquipButton.SetActive(false); UnequipButton.SetActive(true); } }
public void Make(ItemSlot itemSlot) { Item item = itemSlot.item; SetStackable(item); switch(item.Type) { case ItemType.Armor: SetArmorButtons(itemSlot); break; case ItemType.Consumable: SetConsumable(itemSlot); break; case ItemType.Enhancer: SetEnhancer(itemSlot); break; case ItemType.Generator: SetGenerator(itemSlot); break; case ItemType.LaserWeapon: SetLaserWeapon(itemSlot); break; case ItemType.LegacyWeapon: SetLegacyWeapon(itemSlot); break; case ItemType.MagneticWeapon: SetMagneticWeapon(itemSlot); break; case ItemType.Melee: SetMelee(itemSlot); break; case ItemType.Misc: SetMisc(itemSlot); break; case ItemType.Quest: SetQuest(itemSlot); break; } }
public bool IsSettingHammer(ItemSlot slot) => slot.Itemstack.Collectible.FirstCodePart() == "settinghammer";
public override WeightedSlot GetBestSuitedSlot(ItemSlot sourceSlot, List <ItemSlot> skipSlots = null) { return(new WeightedSlot()); }
public override bool OnHeldInteractCancel(float secondsUsed, ItemSlot slot, EntityAgent byEntity, BlockSelection blockSel, EntitySelection entitySel, EnumItemUseCancelReason cancelReason) { return(true); }
private void HandleOnShowContextMenu(ItemSlot slot) { GD.Print("EquipmentSlotsManager - HandleOnShowContextMenu"); OnShowContextMenu?.Invoke(slot); }
public bool IsSlotObscured(NamedSlot namedSlot) { return(obscuredSlots.HasFlag(ItemSlot.GetFlaggedSlot(namedSlot))); }
internal void OnUseOver(IPlayer byPlayer, Vec3i voxelPos, BlockSelection blockSel) { if (voxelPos == null) { return; } // Send a custom network packet for server side, because // serverside blockselection index is inaccurate if (api.Side == EnumAppSide.Client) { SendUseOverPacket(byPlayer, voxelPos); } ItemSlot slot = byPlayer.InventoryManager.ActiveHotbarSlot; if (slot.Itemstack == null || !CanWorkCurrent) { return; } int toolMode = slot.Itemstack.Collectible.GetToolMode(slot, byPlayer, blockSel); float yaw = GameMath.Mod(byPlayer.Entity.Pos.Yaw, 2 * GameMath.PI); BlockFacing towardsFace = BlockFacing.HorizontalFromAngle(yaw); float temp = workItemStack.Collectible.GetTemperature(api.World, workItemStack); if (Voxels[voxelPos.X, voxelPos.Y, voxelPos.Z]) { if (temp > 800) { bigMetalSparks.minPos = pos.ToVec3d().AddCopy(voxelPos.X / 16f, voxelPos.Y / 16f + 0.0625f, voxelPos.Z / 16f); bigMetalSparks.glowLevel = (byte)GameMath.Clamp((int)(temp - 770) / 3, 32, 128); byPlayer.Entity.World.SpawnParticles(bigMetalSparks, byPlayer); smallMetalSparks.minPos = pos.ToVec3d().AddCopy(voxelPos.X / 16f, voxelPos.Y / 16f + 0.0625f, voxelPos.Z / 16f); smallMetalSparks.glowLevel = (byte)GameMath.Clamp((int)(temp - 770) / 3, 32, 128); smallMetalSparks.model = EnumParticleModel.Quad; smallMetalSparks.lifeLength = 0.03f; smallMetalSparks.minVelocity = new Vec3f(-1f, 1f, -1f); smallMetalSparks.addVelocity = new Vec3f(2f, 2f, 2f); smallMetalSparks.minQuantity = 4; smallMetalSparks.addQuantity = 6; smallMetalSparks.minSize = 0.1f; smallMetalSparks.maxSize = 0.1f; smallMetalSparks.SizeEvolve = new EvolvingNatFloat(EnumTransformFunction.LINEAR, -0.1f); byPlayer.Entity.World.SpawnParticles(smallMetalSparks, byPlayer); } switch (toolMode) { case 0: OnHit(voxelPos); break; case 1: OnUpset(voxelPos, BlockFacing.NORTH.FaceWhenRotatedBy(0, yaw - GameMath.PIHALF, 0)); break; case 2: OnUpset(voxelPos, BlockFacing.EAST.FaceWhenRotatedBy(0, yaw - GameMath.PIHALF, 0)); break; case 3: OnUpset(voxelPos, BlockFacing.SOUTH.FaceWhenRotatedBy(0, yaw - GameMath.PIHALF, 0)); break; case 4: OnUpset(voxelPos, BlockFacing.WEST.FaceWhenRotatedBy(0, yaw - GameMath.PIHALF, 0)); break; case 5: OnSplit(voxelPos); break; } RegenMeshAndSelectionBoxes(); api.World.BlockAccessor.MarkBlockDirty(pos); api.World.BlockAccessor.MarkBlockEntityDirty(pos); slot.Itemstack.Collectible.DamageItem(api.World, byPlayer.Entity, slot); if (!HasAnyVoxel()) { AvailableVoxels = 0; workItemStack = null; return; } } CheckIfFinished(byPlayer); MarkDirty(); }
public void Unlink() { itemSlot.UnlinkUISlot(); itemSlot = null; UpdateSlot(); }
private void OnDestroy() { //free the slots ItemSlot.Free(this); }
public void OnDespawnClient(ClientDespawnInfo info) { //free the slots ItemSlot.Free(this); }
public ItemSlot GetIndexedItemSlot(int slotIndex) { return(ItemSlot.GetIndexed(this, slotIndex)); }
public ItemSlot GetNamedItemSlot(NamedSlot named) { return(ItemSlot.GetNamed(this, named)); }
/// <summary> /// /// </summary> /// <param name="named"></param> /// <returns>the item slot from this storage, null if this item storage doesn't have this slot</returns> public ItemSlot GetItemSlot(SlotIdentifier named) { return(ItemSlot.Get(this, named)); }
internal void OnUseOver(IPlayer byPlayer, Vec3i voxelPos, BlockSelection blockSel) { if (voxelPos == null) { return; } if (SelectedRecipe == null) { ditchWorkItemStack(); return; } // Send a custom network packet for server side, because // serverside blockselection index is inaccurate if (Api.Side == EnumAppSide.Client) { SendUseOverPacket(byPlayer, voxelPos); } ItemSlot slot = byPlayer.InventoryManager.ActiveHotbarSlot; if (slot.Itemstack == null || !CanWorkCurrent) { return; } int toolMode = slot.Itemstack.Collectible.GetToolMode(slot, byPlayer, blockSel); float yaw = GameMath.Mod(byPlayer.Entity.Pos.Yaw, 2 * GameMath.PI); EnumVoxelMaterial voxelMat = (EnumVoxelMaterial)Voxels[voxelPos.X, voxelPos.Y, voxelPos.Z]; if (voxelMat != EnumVoxelMaterial.Empty) { spawnParticles(voxelPos, voxelMat, byPlayer); switch (toolMode) { case 0: OnHit(voxelPos); break; case 1: OnUpset(voxelPos, BlockFacing.NORTH.FaceWhenRotatedBy(0, yaw - GameMath.PIHALF, 0)); break; case 2: OnUpset(voxelPos, BlockFacing.EAST.FaceWhenRotatedBy(0, yaw - GameMath.PIHALF, 0)); break; case 3: OnUpset(voxelPos, BlockFacing.SOUTH.FaceWhenRotatedBy(0, yaw - GameMath.PIHALF, 0)); break; case 4: OnUpset(voxelPos, BlockFacing.WEST.FaceWhenRotatedBy(0, yaw - GameMath.PIHALF, 0)); break; case 5: OnSplit(voxelPos); break; } RegenMeshAndSelectionBoxes(); Api.World.BlockAccessor.MarkBlockDirty(Pos); Api.World.BlockAccessor.MarkBlockEntityDirty(Pos); slot.Itemstack.Collectible.DamageItem(Api.World, byPlayer.Entity, slot); if (!HasAnyMetalVoxel()) { workItemStack = null; return; } } CheckIfFinished(byPlayer); MarkDirty(); }
private bool TryPut(IWorldAccessor world, IPlayer byPlayer, BlockSelection blockSel) { ItemSlot slot = byPlayer.InventoryManager.ActiveHotbarSlot; if (slot.Itemstack == null) { return(false); } ItemStack stack = slot.Itemstack; IAnvilWorkable workableobj = stack.Collectible as IAnvilWorkable; if (workableobj == null) { return(false); } int requiredTier = workableobj.GetRequiredAnvilTier(stack); if (requiredTier > OwnMetalTier) { if (world.Side == EnumAppSide.Client) { (Api as ICoreClientAPI).TriggerIngameError(this, "toolowtier", Lang.Get("Working this metal needs a tier {0} anvil", requiredTier)); } return(false); } ItemStack newWorkItemStack = workableobj.TryPlaceOn(stack, this); if (newWorkItemStack != null) { if (workItemStack == null) { workItemStack = newWorkItemStack; rotation = workItemStack.Attributes.GetInt("rotation"); } else if (workItemStack.Collectible is ItemWorkItem wi && wi.isBlisterSteel) { return(false); } if (SelectedRecipeId < 0) { var list = workableobj.GetMatchingRecipes(stack); if (list.Count == 1) { SelectedRecipeId = list[0].RecipeId; } else { if (world.Side == EnumAppSide.Client) { OpenDialog(stack); } } } returnOnCancelStack = slot.TakeOut(1); slot.MarkDirty(); if (Api.Side == EnumAppSide.Server) { // Let the server decide the shape, then send the stuff to client, and then show the correct voxels // instead of the voxels flicker thing when both sides do it (due to voxel placement randomness in iron bloom and blister steel) RegenMeshAndSelectionBoxes(); } CheckIfFinished(byPlayer); MarkDirty(); return(true); } return(false); }
/// <summary> /// Transfers an item from an item slot to the body part's internal storage, usually another body part /// </summary> /// <param name="ItemSlot">Item Slot to transfer from</param> public virtual void AddBodyPartSlot(ItemSlot ItemSlot) { Storage.ServerTryTransferFrom(ItemSlot); }
private bool TryPut(IWorldAccessor world, IPlayer byPlayer, BlockSelection blockSel) { ItemSlot slot = byPlayer.InventoryManager.ActiveHotbarSlot; if (slot.Itemstack == null) { return(false); } ItemStack stack = slot.Itemstack; string metalType = stack.Collectible.LastCodePart(); bool viableTier = metalsByCode.ContainsKey(metalType) && metalsByCode[metalType].Tier <= OwnMetalTier + 1; bool viableBaseMaterial = stack.Collectible is ItemIngot && CanWork(stack) && viableTier; // Place ingot if (viableBaseMaterial && (workItemStack == null || workItemStack.Collectible.LastCodePart().Equals(stack.Collectible.LastCodePart()))) { if (workItemStack == null) { if (world is IClientWorldAccessor) { OpenDialog(stack); } CreateInitialWorkItem(); workItemStack = new ItemStack(api.World.GetItem(new AssetLocation("workitem-" + stack.Collectible.LastCodePart()))); workItemStack.Collectible.SetTemperature(api.World, workItemStack, stack.Collectible.GetTemperature(api.World, stack)); baseMaterial = new ItemStack(api.World.GetItem(new AssetLocation("ingot-" + stack.Collectible.LastCodePart()))); List <SmithingRecipe> recipes = api.World.SmithingRecipes .Where(r => r.Ingredient.SatisfiesAsIngredient(baseMaterial)) .OrderBy(r => r.Output.ResolvedItemstack.Collectible.Code) .ToList() ; selectedRecipeId = recipes[0].RecipeId; } AvailableVoxels += 32; stack.StackSize--; if (stack.StackSize <= 0) { slot.Itemstack = null; } slot.MarkDirty(); RegenMeshAndSelectionBoxes(); MarkDirty(); return(true); } // Place workitem bool viableWorkItem = stack.Collectible.FirstCodePart().Equals("workitem") && viableTier; if (viableWorkItem) { try { deserializeVoxels(slot.Itemstack.Attributes.GetBytes("voxels")); AvailableVoxels = slot.Itemstack.Attributes.GetInt("availableVoxels"); selectedRecipeId = slot.Itemstack.Attributes.GetInt("selectedRecipeId"); workItemStack = stack.Clone(); slot.Itemstack = null; slot.MarkDirty(); } catch (Exception) { } if (selectedRecipeId < 0 && world is IClientWorldAccessor) { OpenDialog(stack); } RegenMeshAndSelectionBoxes(); CheckIfFinished(byPlayer); MarkDirty(); return(true); } return(false); }
void Update() { Player player = Player.localPlayer; if (player != null) { panel.SetActive(true); // instantiate/destroy enough slots UIUtils.BalancePrefabs(slotPrefab.gameObject, player.skillbar.slots.Length, content); // refresh all for (int i = 0; i < player.skillbar.slots.Length; ++i) { SkillbarEntry entry = player.skillbar.slots[i]; UISkillbarSlot slot = content.GetChild(i).GetComponent <UISkillbarSlot>(); slot.dragAndDropable.name = i.ToString(); // drag and drop index // hotkey overlay (without 'Alpha' etc.) string pretty = entry.hotKey.ToString().Replace("Alpha", ""); slot.hotkeyText.text = pretty; // skill, inventory item or equipment item? int skillIndex = player.skills.GetSkillIndexByName(entry.reference); int inventoryIndex = player.inventory.GetItemIndexByName(entry.reference); int equipmentIndex = player.equipment.GetItemIndexByName(entry.reference); if (skillIndex != -1) { Skill skill = player.skills.skills[skillIndex]; bool canCast = player.skills.CastCheckSelf(skill); // if movement does NOT support navigation then we need to // check distance too. otherwise distance doesn't matter // because we can navigate anywhere. if (!player.movement.CanNavigate()) { canCast &= player.skills.CastCheckDistance(skill, out Vector3 _); } // hotkey pressed and not typing in any input right now? if (Input.GetKeyDown(entry.hotKey) && !UIUtils.AnyInputActive() && canCast) // checks mana, cooldowns, etc.) { { // try use the skill or walk closer if needed ((PlayerSkills)player.skills).TryUse(skillIndex); } // refresh skill slot slot.button.interactable = canCast; // check mana, cooldowns, etc. slot.button.onClick.SetListener(() => { // try use the skill or walk closer if needed ((PlayerSkills)player.skills).TryUse(skillIndex); }); // only build tooltip while it's actually shown. this // avoids MASSIVE amounts of StringBuilder allocations. slot.tooltip.enabled = true; if (slot.tooltip.IsVisible()) { slot.tooltip.text = skill.ToolTip(); } slot.dragAndDropable.dragable = true; slot.image.color = Color.white; slot.image.sprite = skill.image; float cooldown = skill.CooldownRemaining(); slot.cooldownOverlay.SetActive(cooldown > 0); slot.cooldownText.text = cooldown.ToString("F0"); slot.cooldownCircle.fillAmount = skill.cooldown > 0 ? cooldown / skill.cooldown : 0; slot.amountOverlay.SetActive(false); } else if (inventoryIndex != -1) { ItemSlot itemSlot = player.inventory.slots[inventoryIndex]; // hotkey pressed and not typing in any input right now? if (Input.GetKeyDown(entry.hotKey) && !UIUtils.AnyInputActive()) { player.inventory.CmdUseItem(inventoryIndex); } // refresh inventory slot slot.button.onClick.SetListener(() => { player.inventory.CmdUseItem(inventoryIndex); }); // only build tooltip while it's actually shown. this // avoids MASSIVE amounts of StringBuilder allocations. slot.tooltip.enabled = true; if (slot.tooltip.IsVisible()) { slot.tooltip.text = itemSlot.ToolTip(); } slot.dragAndDropable.dragable = true; // use durability colors? if (itemSlot.item.maxDurability > 0) { if (itemSlot.item.durability == 0) { slot.image.color = brokenDurabilityColor; } else if (itemSlot.item.DurabilityPercent() < lowDurabilityThreshold) { slot.image.color = lowDurabilityColor; } else { slot.image.color = Color.white; } } else { slot.image.color = Color.white; // reset for no-durability items } slot.image.sprite = itemSlot.item.image; slot.cooldownOverlay.SetActive(false); // cooldown if usable item if (itemSlot.item.data is UsableItem usable) { float cooldown = player.GetItemCooldown(usable.cooldownCategory); slot.cooldownCircle.fillAmount = usable.cooldown > 0 ? cooldown / usable.cooldown : 0; } else { slot.cooldownCircle.fillAmount = 0; } slot.amountOverlay.SetActive(itemSlot.amount > 1); slot.amountText.text = itemSlot.amount.ToString(); } else if (equipmentIndex != -1) { ItemSlot itemSlot = player.equipment.slots[equipmentIndex]; // refresh equipment slot slot.button.onClick.RemoveAllListeners(); // only build tooltip while it's actually shown. this // avoids MASSIVE amounts of StringBuilder allocations. slot.tooltip.enabled = true; if (slot.tooltip.IsVisible()) { slot.tooltip.text = itemSlot.ToolTip(); } slot.dragAndDropable.dragable = true; // use durability colors? if (itemSlot.item.maxDurability > 0) { if (itemSlot.item.durability == 0) { slot.image.color = brokenDurabilityColor; } else if (itemSlot.item.DurabilityPercent() < lowDurabilityThreshold) { slot.image.color = lowDurabilityColor; } else { slot.image.color = Color.white; } } else { slot.image.color = Color.white; // reset for no-durability items } slot.image.sprite = itemSlot.item.image; slot.cooldownOverlay.SetActive(false); // cooldown if usable item if (itemSlot.item.data is UsableItem usable) { float cooldown = player.GetItemCooldown(usable.cooldownCategory); slot.cooldownCircle.fillAmount = usable.cooldown > 0 ? cooldown / usable.cooldown : 0; } else { slot.cooldownCircle.fillAmount = 0; } slot.amountOverlay.SetActive(itemSlot.amount > 1); slot.amountText.text = itemSlot.amount.ToString(); } else { // clear the outdated reference // (need to assign directly because it's a struct) player.skillbar.slots[i].reference = ""; // refresh empty slot slot.button.onClick.RemoveAllListeners(); slot.tooltip.enabled = false; slot.dragAndDropable.dragable = false; slot.image.color = Color.clear; slot.image.sprite = null; slot.cooldownOverlay.SetActive(false); slot.cooldownCircle.fillAmount = 0; slot.amountOverlay.SetActive(false); } } } else { panel.SetActive(false); } }
public override float GetSuitability(ItemSlot sourceSlot, ItemSlot targetSlot, bool isMerge) { return(base.GetSuitability(sourceSlot, targetSlot, isMerge)); }
public void SetupPanel(ItemSlot go) { UpdateFriendTxt(go); }
private void EndDrag(ItemSlot itemSlot) { dragItemSlot = null; draggableItem.enabled = false; }
public byte GetUpgradesBySlot(ItemSlot slot) { Equip eqp; if (EquippedItems.TryGetValue(slot, out eqp)) { return eqp.Upgrades; } else return 0; }
public byte GetUpgradesBySlot(ItemSlot pType) { //double check if found Item equip = this.Inventory.EquippedItems.Find(d => d.Slot == (sbyte)pType && d.IsEquipped); if (equip == null) { return 0; } else { return equip.UpgradeStats.Upgrades; } }
public CritterSmthMoveItemEventArgs(Critter cr, Critter from_cr, Item item, ItemSlot from_slot) : base(cr, item, from_slot) { this.From = from_cr; }
public static void DrawColoredItemSlot(SpriteBatch spriteBatch, ref Item item, Vector2 position, Texture2D backTexture, Color slotColor, Color lightColor = default) { spriteBatch.Draw(backTexture, position, null, slotColor, 0f, default(Vector2), Main.inventoryScale, SpriteEffects.None, 0f); ItemSlot.Draw(spriteBatch, ref item, ItemSlot.Context.ChatItem, position, lightColor); }
public void RunAnimation(Door door, ItemSlot trigger) { RunAnimation(); }
public override void OnInteract(EntityAgent byEntity, ItemSlot slot, Vec3d hitPosition, EnumInteractMode mode) { if (mode != EnumInteractMode.Interact || !(byEntity is EntityPlayer)) { base.OnInteract(byEntity, slot, hitPosition, mode); return; } if (!Alive) { return; } EntityPlayer entityplr = byEntity as EntityPlayer; IPlayer player = World.PlayerByUid(entityplr.PlayerUID); tradingWith = entityplr; if (World.Side == EnumAppSide.Client) { ICoreClientAPI capi = (ICoreClientAPI)Api; if (tradingWith.Pos.SquareDistanceTo(this.Pos) <= 5 && dlg?.IsOpened() != true) { // Will break all kinds of things if we allow multiple concurrent of these dialogs if (capi.Gui.OpenedGuis.FirstOrDefault(dlg => dlg is GuiDialogTrader && dlg.IsOpened()) == null) { capi.Network.SendEntityPacket(this.EntityId, 1001); player.InventoryManager.OpenInventory(Inventory); dlg = new GuiDialogTrader(Inventory, this, World.Api as ICoreClientAPI); dlg.TryOpen(); } else { capi.TriggerIngameError(this, "onlyonedialog", Lang.Get("Can only trade with one trader at a time")); } } else { // Ensure inventory promptly closed server-side if the client didn't open the GUI capi.Network.SendPacketClient(capi.World.Player.InventoryManager.CloseInventory(Inventory)); } talkUtil.Talk(EnumTalkType.Meet); } if (World.Side == EnumAppSide.Server) { // Make the trader walk towards the player AiTaskManager tmgr = GetBehavior <EntityBehaviorTaskAI>().TaskManager; tmgr.StopTask(typeof(AiTaskWander)); AiTaskGotoEntity task = new AiTaskGotoEntity(this, entityplr); if (task.TargetReached()) { tmgr.ExecuteTask(new AiTaskLookAtEntity(this, entityplr), 1); } else { tmgr.ExecuteTask(task, 1); } AnimManager.StartAnimation(new AnimationMetaData() { Animation = "welcome", Code = "welcome", Weight = 10, EaseOutSpeed = 10000, EaseInSpeed = 10000 }); AnimManager.StopAnimation("idle"); } }
/// <summary> /// Creates an ItemBase that sets <see cref="ItemClass"/> and <see cref="Tags"/> on /// a best effort basis. They might not be set correctly. /// <para/> /// Only <see cref="Name"/>, <see cref="ItemClass"/> and <see cref="Tags"/> may be called on /// ItemBases created via this constructor. It is not meant to produce bases that can exist independent /// of the <see cref="Item"/> they are created for. /// </summary> /// <param name="itemImageService"></param> /// <param name="itemSlot">The slot the parent <see cref="Item"/> is slotted into. /// <see cref="ItemSlot.Unequipable"/> if is not equipped.</param> /// <param name="typeLine">The TypeLine property of the parent <see cref="Item"/>.</param> /// <param name="weaponClass">A string representing the weapon class of the parent <see cref="Item"/>. /// Can be null or empty if that item is not a weapon. The weapon class generally is a property without value.</param> /// <param name="frameType">The frame type of the item.</param> public ItemBase(ItemImageService itemImageService, ItemSlot itemSlot, string typeLine, string weaponClass, FrameType frameType) { // These don't matter as we won't create new items from this base. Level = 0; RequiredStrength = 0; RequiredDexterity = 0; RequiredIntelligence = 0; DropDisabled = false; InventoryHeight = 0; InventoryWidth = 0; MetadataId = ""; ImplicitMods = new List <IMod>(); _properties = new List <string>(); CanHaveQuality = false; Name = typeLine; ItemClass = ItemSlotToClass(itemSlot); if (ItemClass == ItemClass.ActiveSkillGem) { ItemClass = ItemClassEx.ItemClassForGem(typeLine); } if (ItemClass == ItemClass.Unknown) { if (frameType == FrameType.Gem) { ItemClass = ItemClassEx.ItemClassForGem(typeLine); } else if (frameType == FrameType.Currency || frameType == FrameType.DivinationCard || frameType == FrameType.QuestItem || frameType == FrameType.Prophecy) { ItemClass = ItemClass.Unknown; } else if (typeLine.Contains("Quiver")) { ItemClass = ItemClass.Quiver; } else if (typeLine.Contains("Shield") || typeLine.Contains("Buckler")) { ItemClass = ItemClass.Shield; } else if (typeLine.Contains("Amulet") || typeLine.Contains("Talisman")) { ItemClass = ItemClass.Amulet; } else if (typeLine.Contains("Ring")) { ItemClass = ItemClass.Ring; } else if (typeLine.Contains("Belt")) { ItemClass = ItemClass.Belt; } else if (!string.IsNullOrWhiteSpace(weaponClass)) { // This will not catch ThrustingOneHandSword and Sceptre, // but the distinction between those and OneHandSword and OneHandMace only matters for mod crafting var itemClassStr = weaponClass.Replace("Handed", "Hand") .Replace(" ", "").Trim(); ItemClass type; if (Enum.TryParse(itemClassStr, true, out type)) { ItemClass = type; } } } // This might miss some tags, but those are only important for mod crafting, // which will not happen with this item. Tags = ItemClass.ToTags(); Image = new ItemImage(itemImageService, ItemClass); }
public ushort GetEquippedBySlot(ItemSlot slot) { Equip eqp; if (EquippedItems.TryGetValue(slot, out eqp)) { return eqp.ItemID; } else return ushort.MaxValue; }
private static int SlotIndex(ItemSlot slot) { switch (slot) { case ItemSlot.Head: case ItemSlot.Chest: case ItemSlot.Legs: case ItemSlot.TwoHand: return 0; case ItemSlot.Shoulders: case ItemSlot.Hands: case ItemSlot.Waist: case ItemSlot.Feet: return 1; case ItemSlot.Wrist: case ItemSlot.Neck: case ItemSlot.Back: case ItemSlot.Finger: case ItemSlot.OffHand: default: return 2; case ItemSlot.MainHand: case ItemSlot.OneHand: return 3; case ItemSlot.Ranged: return 4; } }
public ushort GetEquippedBySlot(ItemSlot pType) { //double check if found Item equip = this.Inventory.EquippedItems.Find(d => d.Slot == (sbyte)pType && d.IsEquipped); if (equip == null) { return 0xffff; } else { return (ushort)equip.ID; } }
private void UpdateGraphEquipped(string subgraph) { SetGraphControl(ComparisonGraph); CGL_Legend.LegendItems = Calculations.SubPointNameColors; ComparisonGraph.LegendItems = Calculations.SubPointNameColors; ComparisonGraph.Mode = ComparisonGraph.DisplayMode.Subpoints; List<ComparisonCalculationBase> itemCalculations = new List<ComparisonCalculationBase>(); if (subgraph == "Gear" || subgraph == "All") { CharacterSlot[] slots = new CharacterSlot[] { CharacterSlot.Back, CharacterSlot.Chest, CharacterSlot.Feet, CharacterSlot.Finger1, CharacterSlot.Finger2, CharacterSlot.Hands, CharacterSlot.Head, CharacterSlot.Legs, CharacterSlot.MainHand, CharacterSlot.Neck, CharacterSlot.OffHand, /*CharacterSlot.Projectile, CharacterSlot.ProjectileBag,*/ CharacterSlot.Ranged, CharacterSlot.Shoulders, CharacterSlot.Trinket1, CharacterSlot.Trinket2, CharacterSlot.Waist, CharacterSlot.Wrist }; foreach (CharacterSlot slot in slots) { ItemInstance item = Character[slot]; if (item != null) { itemCalculations.Add(Calculations.GetItemCalculations(item, Character, slot)); } } } if (subgraph == "Enchants" || subgraph == "All") { ItemSlot[] slots = new ItemSlot[] { ItemSlot.Back, ItemSlot.Chest, ItemSlot.Feet, ItemSlot.Finger, ItemSlot.Hands, ItemSlot.Head, ItemSlot.Legs, ItemSlot.MainHand, ItemSlot.OffHand, ItemSlot.Ranged, ItemSlot.Shoulders, ItemSlot.Waist, ItemSlot.Wrist }; foreach (ItemSlot slot in slots) foreach (ComparisonCalculationBase calc in Calculations.GetEnchantCalculations(slot, Character, Calculations.GetCharacterCalculations(Character), true)) itemCalculations.Add(calc); } if (subgraph == "Tinkerings" || subgraph == "All") { ItemSlot[] slots = new ItemSlot[] { ItemSlot.Back, ItemSlot.Hands, ItemSlot.Waist, }; foreach (ItemSlot slot in slots) foreach (ComparisonCalculationBase calc in Calculations.GetTinkeringCalculations(slot, Character, Calculations.GetCharacterCalculations(Character), true)) itemCalculations.Add(calc); } if (subgraph == "Buffs" || subgraph == "All") { itemCalculations.AddRange(Calculations.GetBuffCalculations(Character, Calculations.GetCharacterCalculations(Character), ConvertBuffSelector("Current"))); ComparisonGraph.DisplayCalcs(itemCalculations.ToArray()); } // Now Push the results to the screen ComparisonGraph.DisplayCalcs(_itemCalculations = itemCalculations.ToArray()); }
public CritterMoveItemEventArgs(Critter cr, Item item, ItemSlot from_slot) : base(cr) { this.Item = item; this.FromSlot = from_slot; }
public override string GetHeldTpUseAnimation(ItemSlot activeHotbarSlot, Entity byEntity) { return(null); }
// called by engine void RaiseSmthMoveItem(Critter from_cr, Item item, ItemSlot from_slot) { if (SmthMoveItem != null) SmthMoveItem(this, new CritterSmthMoveItemEventArgs(this, from_cr, item, from_slot)); }
public static void Sort(Item[] inv, params int[] ignoreSlots) { SetupSortingPriorities(); List <int> list = new List <int>(); for (int i = 0; i < inv.Length; i++) { if (!ignoreSlots.Contains(i)) { Item item = inv[i]; if (item != null && item.stack != 0 && item.type != 0 && !item.favorited) { list.Add(i); } } } for (int j = 0; j < list.Count; j++) { Item item2 = inv[list[j]]; if (item2.stack < item2.maxStack) { int num = item2.maxStack - item2.stack; for (int k = j; k < list.Count; k++) { if (j != k) { Item item3 = inv[list[k]]; if (item2.IsTheSameAs(item3) && item3.stack != item3.maxStack) { int num2 = item3.stack; if (num < num2) { num2 = num; } item2.stack += num2; item3.stack -= num2; num -= num2; if (item3.stack == 0) { inv[list[k]] = new Item(); list.Remove(list[k]); j--; k--; break; } if (num == 0) { break; } } } } } } List <int> list2 = new List <int>(list); for (int l = 0; l < inv.Length; l++) { if (!ignoreSlots.Contains(l) && !list2.Contains(l)) { Item item4 = inv[l]; if (item4 == null || item4.stack == 0 || item4.type == 0) { list2.Add(l); } } } list2.Sort(); List <int> list3 = new List <int>(); List <int> list4 = new List <int>(); foreach (ItemSortingLayer itemSortingLayer in _layerList) { List <int> list5 = itemSortingLayer.SortingMethod(itemSortingLayer, inv, list); if (list5.Count > 0) { list4.Add(list5.Count); } list3.AddRange(list5); } list3.AddRange(list); List <Item> list6 = new List <Item>(); foreach (int num3 in list3) { list6.Add(inv[num3]); inv[num3] = new Item(); } float num4 = 1f / (float)list4.Count; float num5 = num4 / 2f; for (int m = 0; m < list6.Count; m++) { int num6 = list2[0]; ItemSlot.SetGlow(num6, num5, Main.player[Main.myPlayer].chest != -1); List <int> list7 = list4; int num7 = list7[0]; list7[0] = num7 - 1; if (list4[0] == 0) { list4.RemoveAt(0); num5 += num4; } inv[num6] = list6[m]; list2.Remove(num6); } }
private void HandleEquipItem(GameSession session, PacketReader packet) { long itemUid = packet.ReadLong(); string equipSlotStr = packet.ReadUnicodeString(); if (!Enum.TryParse(equipSlotStr, out ItemSlot equipSlot)) { Logger.Warning("Unknown equip slot: " + equipSlotStr); return; } // Remove the item from the users inventory InventoryController.Remove(session, itemUid, out Item item); // Get correct equipped inventory Dictionary <ItemSlot, Item> equippedInventory = session.Player.GetEquippedInventory(item.InventoryTab); if (equippedInventory == null) { Logger.Warning("equippedInventory was null: " + item.InventoryTab); return; } // Move previously equipped item back to inventory if (equippedInventory.Remove(equipSlot, out Item prevItem)) { prevItem.Slot = item.Slot; InventoryController.Add(session, prevItem, false); session.FieldManager.BroadcastPacket(EquipmentPacket.UnequipItem(session.FieldPlayer, prevItem)); } // Handle unequipping pants when equipping dresses // Handle unequipping off-hand when equipping two-handed weapons if (item.IsDress || item.IsTwoHand) { if (equippedInventory.Remove(item.IsDress ? ItemSlot.PA : ItemSlot.LH, out Item prevItem2)) { prevItem2.Slot = -1; if (prevItem == null) { prevItem2.Slot = item.Slot; } InventoryController.Add(session, prevItem2, false); session.FieldManager.BroadcastPacket(EquipmentPacket.UnequipItem(session.FieldPlayer, prevItem2)); } } // Handle unequipping dresses when equipping pants // Handle unequipping two-handed main-hands when equipping off-hand weapons if (item.ItemSlot == ItemSlot.PA || item.ItemSlot == ItemSlot.LH) { ItemSlot prevItemSlot = item.ItemSlot == ItemSlot.PA ? ItemSlot.CL : ItemSlot.RH; if (equippedInventory.ContainsKey(prevItemSlot)) { if (equippedInventory[prevItemSlot] != null && equippedInventory[prevItemSlot].IsDress) { if (equippedInventory.Remove(prevItemSlot, out Item prevItem2)) { prevItem2.Slot = item.Slot; InventoryController.Add(session, prevItem2, false); session.FieldManager.BroadcastPacket(EquipmentPacket.UnequipItem(session.FieldPlayer, prevItem2)); } } } } // Equip new item equippedInventory[equipSlot] = item; session.FieldManager.BroadcastPacket(EquipmentPacket.EquipItem(session.FieldPlayer, item, equipSlot)); if (item.InventoryTab == InventoryTab.Gear) { // TODO - Increase stats based on the item stats itself session.Player.Stats.IncreaseMax(PlayerStatId.CritRate, 12); session.Player.Stats.IncreaseMax(PlayerStatId.MinAtk, 15); session.Player.Stats.IncreaseMax(PlayerStatId.MaxAtk, 17); session.Player.Stats.IncreaseMax(PlayerStatId.MagAtk, 15); session.Send(StatPacket.SetStats(session.FieldPlayer)); } }
public override void DamageItem(IWorldAccessor world, Entity byEntity, ItemSlot itemslot, int amount = 1) { ModularItemHelper.DamageTool(world, byEntity, itemslot, amount); }
public CommandSet AddCommandSet(string name, int capacity, bool autoFire, E_CommandConsume consumeType, CommandSet pipe) { CommandSet ret = null; if (consumeType == E_CommandConsume.ItemSlot) { ret = new ItemSlot(name, pipe); } else if (consumeType == E_CommandConsume.None) { ret = new ConsumableCommandSet(capacity, autoFire, false, pipe); } else if (consumeType == E_CommandConsume.Skill) { ret = new SkillSlot(pipe); } if (ret != null) { commandQueue.Add(name, ret); } return ret; }
public override float OnGettingBroken(IPlayer player, BlockSelection blockSel, ItemSlot itemslot, float remainingResistance, float dt, int counter) { IWorldAccessor world = player?.Entity?.World; if (world == null) { world = api.World; } BEMPMultiblock be = world.BlockAccessor.GetBlockEntity(blockSel.Position) as BEMPMultiblock; if (be == null || be.Principal == null) { return(1f); //never break } Block principalBlock = world.BlockAccessor.GetBlock(be.Principal); if (api.Side == EnumAppSide.Client) { //Vintagestory.Client.SystemMouseInWorldInteractions mouse; //mouse.loadOrCreateBlockDamage(bs, principalBlock); //mouse.curBlockDmg.LastBreakEllapsedMs = game.ElapsedMilliseconds; } BlockSelection bs = blockSel.Clone(); bs.Position = be.Principal; return(principalBlock.OnGettingBroken(player, bs, itemslot, remainingResistance, dt, counter)); }
private void UpdateGraphAvailable(string subgraph) { SetGraphControl(ComparisonGraph); CGL_Legend.LegendItems = Calculations.SubPointNameColors; ComparisonGraph.LegendItems = Calculations.SubPointNameColors; ComparisonGraph.Mode = ComparisonGraph.DisplayMode.Subpoints; List<ComparisonCalculationBase> itemCalculations = new List<ComparisonCalculationBase>(); List<ItemInstance> availableGear = new List<ItemInstance>(); List<Item> availableEnchants = new List<Item>(); List<Item> availableTinkerings = new List<Item>(); foreach (string availableItem in Character.AvailableItems) { ItemInstance ii = null; if ((ii = new ItemInstance(availableItem)) != null) { if (ii.Id > 0 && (subgraph == "Gear" || subgraph == "All")) { availableGear.Add(ii); } else if (ii.Id < -1000000 && (subgraph == "Tinkerings" || subgraph == "All")) { ii.Id *= -1; int slot = int.Parse(ii.Id.ToString().Substring(0, 2)); if (slot > (int)ItemSlot.Ranged) slot /= 10; ii.Id -= slot * (int)AvailableItemIDModifiers.Tinkerings; Tinkering temp = Tinkering.FindTinkering(ii.Id, (ItemSlot)slot, Character); Item tink = new Item(string.Format("{0} ({1})", temp.Name, (ItemSlot)slot), ItemQuality.Temp, ItemType.None, -1 * (temp.Id + ((int)AvailableItemIDModifiers.Tinkerings * (int)temp.Slot)), null, ItemSlot.None, null, false, temp.Stats, null, ItemSlot.None, ItemSlot.None, ItemSlot.None, 0, 0, ItemDamageType.Physical, 0, null); availableTinkerings.Add(tink); } else if (ii.Id < 0 && (subgraph == "Enchants" || subgraph == "All")) { ii.Id *= -1; int slot = int.Parse(ii.Id.ToString().Substring(0, 2)); if (slot > (int)ItemSlot.Ranged) slot /= 10; ii.Id -= slot * (int)AvailableItemIDModifiers.Enchants; Enchant temp = Enchant.FindEnchant(ii.Id, (ItemSlot)slot, Character); Item ench = new Item(string.Format("{0} ({1})", temp.Name, (ItemSlot)slot), ItemQuality.Temp, ItemType.None, -1 * (temp.Id + ((int)AvailableItemIDModifiers.Enchants * (int)temp.Slot)), null, ItemSlot.None, null, false, temp.Stats, null, ItemSlot.None, ItemSlot.None, ItemSlot.None, 0, 0, ItemDamageType.Physical, 0, null); availableEnchants.Add(ench); } } } if (subgraph == "Gear" || subgraph == "All") { CharacterSlot[] slots = new CharacterSlot[] { CharacterSlot.Back, CharacterSlot.Chest, CharacterSlot.Feet, CharacterSlot.Finger1, CharacterSlot.Finger2, CharacterSlot.Hands, CharacterSlot.Head, CharacterSlot.Legs, CharacterSlot.MainHand, CharacterSlot.Neck, CharacterSlot.OffHand, /*CharacterSlot.Projectile, CharacterSlot.ProjectileBag,*/ CharacterSlot.Ranged, CharacterSlot.Shoulders, CharacterSlot.Trinket1, CharacterSlot.Trinket2, CharacterSlot.Waist, CharacterSlot.Wrist }; foreach (ItemInstance item in availableGear) { if (item != null) { itemCalculations.Add(Calculations.GetItemCalculations(item, Character, Character.GetCharacterSlotByItemSlot(item.Slot))); ItemSlot islot = item.Slot; CharacterSlot PriSlot = Character.GetCharacterSlotByItemSlot(islot), AltSlot; if (islot == ItemSlot.Finger ) { AltSlot = CharacterSlot.Finger2; } else if (islot == ItemSlot.Trinket) { AltSlot = CharacterSlot.Trinket2; } else if (islot == ItemSlot.TwoHand) { AltSlot = CharacterSlot.OffHand; } else if (islot == ItemSlot.OneHand) { AltSlot = CharacterSlot.OffHand; } else { AltSlot = PriSlot; } if ( Character[PriSlot] != null && Character[PriSlot].Id == item.Id) { itemCalculations[itemCalculations.Count - 1].PartEquipped = true; } else if (AltSlot != PriSlot && Character[AltSlot] != null && Character[AltSlot].Id == item.Id) { itemCalculations[itemCalculations.Count - 1].PartEquipped = true; } } } } if (subgraph == "Enchants" || subgraph == "All") { ItemSlot[] slots = new ItemSlot[] { ItemSlot.Back, ItemSlot.Chest, ItemSlot.Feet, ItemSlot.Finger, ItemSlot.Hands, ItemSlot.Head, ItemSlot.Legs, ItemSlot.MainHand, ItemSlot.OffHand, ItemSlot.Ranged, ItemSlot.Shoulders, ItemSlot.Waist, ItemSlot.Wrist }; foreach (ItemSlot slot in slots) { foreach (ComparisonCalculationBase calc in Calculations.GetEnchantCalculations(slot, Character, Calculations.GetCharacterCalculations(Character), false, true)) { foreach(Item item in availableEnchants) { if (calc.Item.Id == item.Id) { itemCalculations.Add(calc); break; } } } } } if (subgraph == "Tinkerings" || subgraph == "All") { ItemSlot[] slots = new ItemSlot[] { ItemSlot.Back, ItemSlot.Hands, ItemSlot.Waist, }; foreach (ItemSlot slot in slots) { foreach (ComparisonCalculationBase calc in Calculations.GetTinkeringCalculations(slot, Character, Calculations.GetCharacterCalculations(Character), false, true)) { foreach (Item item in availableTinkerings) { if (calc.Item.Id == item.Id) { itemCalculations.Add(calc); break; } } } } } // Now Push the results to the screen ComparisonGraph.DisplayCalcs(_itemCalculations = itemCalculations.ToArray()); }
public override WorldInteraction[] GetHeldInteractionHelp(ItemSlot inSlot) { return(interactions.Append(base.GetHeldInteractionHelp(inSlot))); }