Integrate inventory interface with inventory backend
This commit is contained in:
parent
a43b53112d
commit
9acd9f638f
@ -1671,14 +1671,14 @@ Transform:
|
|||||||
m_PrefabParentObject: {fileID: 0}
|
m_PrefabParentObject: {fileID: 0}
|
||||||
m_PrefabInternal: {fileID: 100100000}
|
m_PrefabInternal: {fileID: 100100000}
|
||||||
m_GameObject: {fileID: 1101618282831644}
|
m_GameObject: {fileID: 1101618282831644}
|
||||||
m_LocalRotation: {x: -0, y: -0, z: -0, w: 1}
|
m_LocalRotation: {x: 0, y: 0.7071068, z: 0, w: 0.7071068}
|
||||||
m_LocalPosition: {x: -0.02, y: 0.6244, z: 0.5199004}
|
m_LocalPosition: {x: -0.02, y: 0.6244, z: 0}
|
||||||
m_LocalScale: {x: 0.14000012, y: 0.14, z: 0.14000012}
|
m_LocalScale: {x: 0.14000012, y: 0.14, z: 0.14000012}
|
||||||
m_Children:
|
m_Children:
|
||||||
- {fileID: 4871279644634608}
|
- {fileID: 4871279644634608}
|
||||||
m_Father: {fileID: 4236387573765288}
|
m_Father: {fileID: 4236387573765288}
|
||||||
m_RootOrder: 10
|
m_RootOrder: 10
|
||||||
m_LocalEulerAnglesHint: {x: 0, y: 0, z: 0}
|
m_LocalEulerAnglesHint: {x: 0, y: 90, z: 0}
|
||||||
--- !u!4 &4345907313541278
|
--- !u!4 &4345907313541278
|
||||||
Transform:
|
Transform:
|
||||||
m_ObjectHideFlags: 1
|
m_ObjectHideFlags: 1
|
||||||
@ -2262,13 +2262,13 @@ Transform:
|
|||||||
m_PrefabParentObject: {fileID: 0}
|
m_PrefabParentObject: {fileID: 0}
|
||||||
m_PrefabInternal: {fileID: 100100000}
|
m_PrefabInternal: {fileID: 100100000}
|
||||||
m_GameObject: {fileID: 1733941371029502}
|
m_GameObject: {fileID: 1733941371029502}
|
||||||
m_LocalRotation: {x: -0.5, y: 0.5, z: 0.5, w: 0.5}
|
m_LocalRotation: {x: -0.7071068, y: 0, z: 0, w: 0.7071068}
|
||||||
m_LocalPosition: {x: -0, y: 0, z: 0}
|
m_LocalPosition: {x: 0.02, y: 0, z: 0}
|
||||||
m_LocalScale: {x: 1, y: 1, z: 1}
|
m_LocalScale: {x: 0.8, y: 0.8, z: 0.8}
|
||||||
m_Children: []
|
m_Children: []
|
||||||
m_Father: {fileID: 4334285771407092}
|
m_Father: {fileID: 4334285771407092}
|
||||||
m_RootOrder: 0
|
m_RootOrder: 0
|
||||||
m_LocalEulerAnglesHint: {x: -90.00001, y: 90, z: 0}
|
m_LocalEulerAnglesHint: {x: -90.00001, y: 0, z: 0}
|
||||||
--- !u!4 &4883048021777868
|
--- !u!4 &4883048021777868
|
||||||
Transform:
|
Transform:
|
||||||
m_ObjectHideFlags: 1
|
m_ObjectHideFlags: 1
|
||||||
@ -4646,6 +4646,7 @@ MonoBehaviour:
|
|||||||
m_Script: {fileID: 11500000, guid: bb0d2e67bf4cd4c6b97d2572ce00fc41, type: 3}
|
m_Script: {fileID: 11500000, guid: bb0d2e67bf4cd4c6b97d2572ce00fc41, type: 3}
|
||||||
m_Name:
|
m_Name:
|
||||||
m_EditorClassIdentifier:
|
m_EditorClassIdentifier:
|
||||||
|
Inventory: {fileID: 114702404122310282}
|
||||||
Camera: {fileID: 20678872378488080}
|
Camera: {fileID: 20678872378488080}
|
||||||
Hologram: {fileID: 114633016952828368}
|
Hologram: {fileID: 114633016952828368}
|
||||||
ItemPreviewMesh: {fileID: 33585471952367662}
|
ItemPreviewMesh: {fileID: 33585471952367662}
|
||||||
|
@ -2259,70 +2259,6 @@ Prefab:
|
|||||||
propertyPath: m_RootOrder
|
propertyPath: m_RootOrder
|
||||||
value: 0
|
value: 0
|
||||||
objectReference: {fileID: 0}
|
objectReference: {fileID: 0}
|
||||||
- target: {fileID: 4334285771407092, guid: e8761b9491a974d1780e60dafbd372a2, type: 2}
|
|
||||||
propertyPath: m_LocalPosition.x
|
|
||||||
value: -0.02
|
|
||||||
objectReference: {fileID: 0}
|
|
||||||
- target: {fileID: 4871279644634608, guid: e8761b9491a974d1780e60dafbd372a2, type: 2}
|
|
||||||
propertyPath: m_LocalPosition.x
|
|
||||||
value: 0.02
|
|
||||||
objectReference: {fileID: 0}
|
|
||||||
- target: {fileID: 4871279644634608, guid: e8761b9491a974d1780e60dafbd372a2, type: 2}
|
|
||||||
propertyPath: m_LocalRotation.x
|
|
||||||
value: -0.7071068
|
|
||||||
objectReference: {fileID: 0}
|
|
||||||
- target: {fileID: 4871279644634608, guid: e8761b9491a974d1780e60dafbd372a2, type: 2}
|
|
||||||
propertyPath: m_LocalRotation.y
|
|
||||||
value: 0
|
|
||||||
objectReference: {fileID: 0}
|
|
||||||
- target: {fileID: 4871279644634608, guid: e8761b9491a974d1780e60dafbd372a2, type: 2}
|
|
||||||
propertyPath: m_LocalRotation.z
|
|
||||||
value: 0
|
|
||||||
objectReference: {fileID: 0}
|
|
||||||
- target: {fileID: 4871279644634608, guid: e8761b9491a974d1780e60dafbd372a2, type: 2}
|
|
||||||
propertyPath: m_LocalRotation.w
|
|
||||||
value: 0.7071068
|
|
||||||
objectReference: {fileID: 0}
|
|
||||||
- target: {fileID: 4871279644634608, guid: e8761b9491a974d1780e60dafbd372a2, type: 2}
|
|
||||||
propertyPath: m_LocalEulerAnglesHint.y
|
|
||||||
value: 0
|
|
||||||
objectReference: {fileID: 0}
|
|
||||||
- target: {fileID: 4871279644634608, guid: e8761b9491a974d1780e60dafbd372a2, type: 2}
|
|
||||||
propertyPath: m_LocalScale.x
|
|
||||||
value: 0.8
|
|
||||||
objectReference: {fileID: 0}
|
|
||||||
- target: {fileID: 4871279644634608, guid: e8761b9491a974d1780e60dafbd372a2, type: 2}
|
|
||||||
propertyPath: m_LocalScale.y
|
|
||||||
value: 0.8
|
|
||||||
objectReference: {fileID: 0}
|
|
||||||
- target: {fileID: 4871279644634608, guid: e8761b9491a974d1780e60dafbd372a2, type: 2}
|
|
||||||
propertyPath: m_LocalScale.z
|
|
||||||
value: 0.8
|
|
||||||
objectReference: {fileID: 0}
|
|
||||||
- target: {fileID: 4334285771407092, guid: e8761b9491a974d1780e60dafbd372a2, type: 2}
|
|
||||||
propertyPath: m_LocalRotation.x
|
|
||||||
value: 0
|
|
||||||
objectReference: {fileID: 0}
|
|
||||||
- target: {fileID: 4334285771407092, guid: e8761b9491a974d1780e60dafbd372a2, type: 2}
|
|
||||||
propertyPath: m_LocalRotation.y
|
|
||||||
value: 0.7071068
|
|
||||||
objectReference: {fileID: 0}
|
|
||||||
- target: {fileID: 4334285771407092, guid: e8761b9491a974d1780e60dafbd372a2, type: 2}
|
|
||||||
propertyPath: m_LocalRotation.z
|
|
||||||
value: 0
|
|
||||||
objectReference: {fileID: 0}
|
|
||||||
- target: {fileID: 4334285771407092, guid: e8761b9491a974d1780e60dafbd372a2, type: 2}
|
|
||||||
propertyPath: m_LocalRotation.w
|
|
||||||
value: 0.7071068
|
|
||||||
objectReference: {fileID: 0}
|
|
||||||
- target: {fileID: 4334285771407092, guid: e8761b9491a974d1780e60dafbd372a2, type: 2}
|
|
||||||
propertyPath: m_LocalEulerAnglesHint.y
|
|
||||||
value: 90
|
|
||||||
objectReference: {fileID: 0}
|
|
||||||
- target: {fileID: 4334285771407092, guid: e8761b9491a974d1780e60dafbd372a2, type: 2}
|
|
||||||
propertyPath: m_LocalPosition.z
|
|
||||||
value: 0
|
|
||||||
objectReference: {fileID: 0}
|
|
||||||
m_RemovedComponents: []
|
m_RemovedComponents: []
|
||||||
m_ParentPrefab: {fileID: 100100000, guid: e8761b9491a974d1780e60dafbd372a2, type: 2}
|
m_ParentPrefab: {fileID: 100100000, guid: e8761b9491a974d1780e60dafbd372a2, type: 2}
|
||||||
m_IsPrefabParent: 0
|
m_IsPrefabParent: 0
|
||||||
|
@ -3,6 +3,8 @@ using System.Collections.Generic;
|
|||||||
using UnityEngine;
|
using UnityEngine;
|
||||||
using Cyber.Util;
|
using Cyber.Util;
|
||||||
using Cyber.Console;
|
using Cyber.Console;
|
||||||
|
using Cyber.Entities.SyncBases;
|
||||||
|
using Cyber.Items;
|
||||||
|
|
||||||
namespace Cyber.Controls {
|
namespace Cyber.Controls {
|
||||||
|
|
||||||
@ -11,6 +13,11 @@ namespace Cyber.Controls {
|
|||||||
/// </summary>
|
/// </summary>
|
||||||
public class InventoryInterface : MonoBehaviour {
|
public class InventoryInterface : MonoBehaviour {
|
||||||
|
|
||||||
|
/// <summary>
|
||||||
|
/// The inventory of the player, will be displayed here.
|
||||||
|
/// </summary>
|
||||||
|
public Inventory Inventory;
|
||||||
|
|
||||||
/// <summary>
|
/// <summary>
|
||||||
/// The camera that is displaying this inventory interface.
|
/// The camera that is displaying this inventory interface.
|
||||||
/// </summary>
|
/// </summary>
|
||||||
@ -173,8 +180,16 @@ namespace Cyber.Controls {
|
|||||||
if (ItemGridSelectedIndex < 0) {
|
if (ItemGridSelectedIndex < 0) {
|
||||||
SetPreviewMesh(null);
|
SetPreviewMesh(null);
|
||||||
}
|
}
|
||||||
for (int i = 0; i < ItemGridDimensions.x * ItemGridDimensions.y; i++) {
|
for (int y = 0; y < ItemGridDimensions.y; y++) {
|
||||||
ItemGridCellMeshes[i].mesh = MeshDB.Meshes[i % MeshDB.Meshes.Length];
|
for (int x = 0; x < ItemGridDimensions.x; x++) {
|
||||||
|
int i = x + y * (int) ItemGridDimensions.x;
|
||||||
|
Item Item = Inventory.Drive.Interface.GetItemAt(x, y);
|
||||||
|
Mesh Mesh = null;
|
||||||
|
if (Item != null) {
|
||||||
|
Mesh = MeshDB.Meshes[Item.ModelID];
|
||||||
|
}
|
||||||
|
ItemGridCellMeshes[i].mesh = Mesh;
|
||||||
|
|
||||||
float Scale = 0.08f;
|
float Scale = 0.08f;
|
||||||
bool Spinning = false;
|
bool Spinning = false;
|
||||||
if (focused == i || ItemGridSelectedIndex == i) {
|
if (focused == i || ItemGridSelectedIndex == i) {
|
||||||
@ -205,6 +220,7 @@ namespace Cyber.Controls {
|
|||||||
FixMeshScaling(ItemGridCellMeshes[i], Scale);
|
FixMeshScaling(ItemGridCellMeshes[i], Scale);
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
}
|
||||||
|
|
||||||
private void SetPreviewMesh(Mesh mesh) {
|
private void SetPreviewMesh(Mesh mesh) {
|
||||||
ItemPreviewSpinner.Spinning = mesh != null;
|
ItemPreviewSpinner.Spinning = mesh != null;
|
||||||
@ -216,7 +232,11 @@ namespace Cyber.Controls {
|
|||||||
}
|
}
|
||||||
|
|
||||||
private void FixMeshScaling(MeshFilter toFix, float scale) {
|
private void FixMeshScaling(MeshFilter toFix, float scale) {
|
||||||
float HighestExtent = 0f;
|
if (toFix.mesh == null) {
|
||||||
|
return;
|
||||||
|
}
|
||||||
|
|
||||||
|
float HighestExtent = 0.1f;
|
||||||
float Height = toFix.mesh.bounds.extents.y * 2f;
|
float Height = toFix.mesh.bounds.extents.y * 2f;
|
||||||
float Width = Mathf.Sqrt(Mathf.Pow(toFix.mesh.bounds.extents.x * 2f, 2) +
|
float Width = Mathf.Sqrt(Mathf.Pow(toFix.mesh.bounds.extents.x * 2f, 2) +
|
||||||
Mathf.Pow(toFix.mesh.bounds.extents.y * 2f, 2));
|
Mathf.Pow(toFix.mesh.bounds.extents.y * 2f, 2));
|
||||||
|
@ -76,7 +76,7 @@ namespace Cyber.Items {
|
|||||||
/// <param name="idx">The index of the desired item</param>
|
/// <param name="idx">The index of the desired item</param>
|
||||||
/// <returns>The item or null if nothing was found.</returns>
|
/// <returns>The item or null if nothing was found.</returns>
|
||||||
public Item GetItem(int idx) {
|
public Item GetItem(int idx) {
|
||||||
if (idx < 0 || idx > Items.Count) {
|
if (idx < 0 || idx >= Items.Count) {
|
||||||
return null;
|
return null;
|
||||||
}
|
}
|
||||||
return Items[idx];
|
return Items[idx];
|
||||||
|
Loading…
Reference in New Issue
Block a user