private void UpdateItem(ContainerItem item, int index) { Item aitem = item.Item; WObject itemRenderer = InventoryItemsRenders[index]; Model mod = null; Label amount = null; if (itemRenderer == null) { } else { mod = itemRenderer.GetModule <Model>(); amount = InventoryItemsAmount[index]; } itemRenderer.LocalRotation = aitem.InventoryRotation; itemRenderer.LocalScale = aitem.InventoryScale; if (aitem.Identifier == "winecrash:air") { mod.Renderer.Mesh = null; amount.Text = ""; } else { mod.Renderer.Mesh = aitem.Model; amount.Text = item.Amount > 1 ? item.Amount.ToString() : ""; } amount.WObject.Rotation = Quaternion.Identity; }
private void UpdateHotbarSelected(ContainerItem item, int index) { WObject wobj = PlayerEntity.PlayerHandWobject; Material material = ItemCache.AtlasMaterial; Mesh mesh = null; Item aitem; if (item == null) { aitem = ItemCache.Get <Item>("winecrash:air"); } else { aitem = item.Item; } if (aitem.Identifier == "winecrash:air") { material = Player.LocalPlayer.Entity.SkinMaterial; mesh = PlayerEntity.PlayerRightArmMesh; } else { mesh = aitem.Model; ItemDisplayName(aitem); } wobj.LocalPosition = aitem.HandPosition; wobj.LocalRotation = aitem.HandRotation; wobj.LocalScale = aitem.HandScale; MeshRenderer mr = wobj.GetModule <MeshRenderer>(); mr.Material = material; mr.Mesh = mesh; Image img = HotbarSelector.GetModule <Image>(); Vector2D min = new Vector2D(-0.0055D, 0.01D); Vector2D max = new Vector2D(0.1265, 1.0725D); double magicNumber = 0.989D; min.X += (index / 9D) * magicNumber; max.X += (index / 9D) * magicNumber; img.MinAnchor = min; img.MaxAnchor = max; }
private void UpdateHotbarItem(ContainerItem item, int index) { Item aitem = item.Item; WObject itemRenderer = HotbarItemsRenders[index]; Model mod = null; Label amount = null; if (itemRenderer == null) { itemRenderer = HotbarItemsRenders[index] = CreateItemRenderer(Hotbar, out mod, out amount); itemRenderer.Name += " (Hotbar)"; mod.Depth = 1000; amount.Depth = 1000; HotbarItemsAmount[index] = amount; } else { mod = itemRenderer.GetModule <Model>(); amount = HotbarItemsAmount[index]; } itemRenderer.LocalRotation = aitem.InventoryRotation; itemRenderer.LocalScale = aitem.InventoryScale; if (aitem.Identifier == "winecrash:air") { mod.Renderer.Mesh = null; amount.Text = ""; } else { mod.Renderer.Mesh = aitem.Model; amount.Text = item.Amount > 1 ? item.Amount.ToString() : ""; } mod.MinAnchor = _ItemHotbarAnchors[index][0]; mod.MaxAnchor = _ItemHotbarAnchors[index][1]; amount.WObject.Rotation = Quaternion.Identity; if (index == Player.LocalPlayer.HotbarSelectedIndex) { UpdateHotbarSelected(item, index); } }