Skip to content
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
85 changes: 8 additions & 77 deletions UnityProject/Assets/Prefabs/UI/Panel_Hud_Bottom.prefab

Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.

Original file line number Diff line number Diff line change
@@ -1,8 +1,5 @@
using System;
using System.Collections;
using System.Collections.Generic;
using System.Linq;
using HealthV2;
using Items.Implants.Organs;
using UnityEngine;

Expand All @@ -15,18 +12,56 @@ public class UI_SlotManager : MonoBehaviour

public GameObject Pockets;
public GameObject SuitStorage;

public GameObject Hands;

public GameObject BeltPDABackpack;

public GameObject Clothing;


public GameObject SlotPrefab;

public HandsController HandsController;

private static readonly Dictionary<NamedSlot, int> NamedSlotOrder = new Dictionary<NamedSlot, int>
{
{ NamedSlot.head, 0 },
{ NamedSlot.ear, 1 },
{ NamedSlot.eyes, 2 },
{ NamedSlot.mask, 3 },
{ NamedSlot.neck, 4 },
{ NamedSlot.uniform, 5 },
{ NamedSlot.outerwear, 6 },
{ NamedSlot.hands, 7 },
{ NamedSlot.belt, 8 },
{ NamedSlot.feet, 9 },
{ NamedSlot.leftHand, 10 },
{ NamedSlot.rightHand, 11 },
{ NamedSlot.back, 12 },
{ NamedSlot.id, 13 },
{ NamedSlot.handcuffs, 14 },
{ NamedSlot.suitStorage, 15 },
{ NamedSlot.storage01, 16 },
{ NamedSlot.storage02, 17 },
{ NamedSlot.storage03, 18 },
{ NamedSlot.storage04, 19 },
{ NamedSlot.storage05, 20 },
{ NamedSlot.storage06, 21 },
{ NamedSlot.storage07, 22 },
{ NamedSlot.storage08, 23 },
{ NamedSlot.storage09, 24 },
{ NamedSlot.storage10, 25 },
{ NamedSlot.storage11, 26 },
{ NamedSlot.storage12, 27 },
{ NamedSlot.storage13, 28 },
{ NamedSlot.storage14, 29 },
{ NamedSlot.storage15, 30 },
{ NamedSlot.storage16, 31 },
{ NamedSlot.storage17, 32 },
{ NamedSlot.storage18, 33 },
{ NamedSlot.storage19, 34 },
{ NamedSlot.storage20, 35 },
{ NamedSlot.ghostStorage01, 36 },
{ NamedSlot.ghostStorage02, 37 },
{ NamedSlot.ghostStorage03, 38 },
{ NamedSlot.none, int.MaxValue }
}; // (Max): Hacky workaround to how the NamedSlots enum cannot be re-ordered.


//Instance ID of class that implements it
public List<Tuple<int, BodyPartUISlots.StorageCharacteristics>> ContainSlots = new List<Tuple<int, BodyPartUISlots.StorageCharacteristics>>();
Expand Down Expand Up @@ -59,71 +94,74 @@ public void UpdateUI()
{
if (PlayerManager.LocalPlayerScript.OrNull()?.DynamicItemStorage != null)
{
var DynamicItemStorage = PlayerManager.LocalPlayerScript.DynamicItemStorage;
var Newstored = DynamicItemStorage.ClientSlotCharacteristic;
List<Tuple<IDynamicItemSlotS, BodyPartUISlots.StorageCharacteristics>> Inadd = new List<Tuple<IDynamicItemSlotS, BodyPartUISlots.StorageCharacteristics>>();
List<Tuple<int, BodyPartUISlots.StorageCharacteristics>> Inremove = new List<Tuple<int, BodyPartUISlots.StorageCharacteristics>>();

foreach (var slot in Newstored)
SyncUISlots();
}
else
{
foreach (var contained in ContainSlots)
{
if (slot.Value.NotPresentOnUI) continue;

bool NotPresent = true;
foreach (var Oldslot in ContainSlots)
{
if (Oldslot.Item1 == slot.Value.RelatedIDynamicItemSlotS.InterfaceGetInstanceID && Oldslot.Item2 == slot.Value)
{
NotPresent = false;
}
}
RemoveSpecifyedUISlot(contained.Item1, contained.Item2);
}
ContainSlots.Clear();
}
SortSlots(Clothing.transform);
}

if (NotPresent)
{
Inadd.Add(new Tuple<IDynamicItemSlotS, BodyPartUISlots.StorageCharacteristics>(slot.Value.RelatedIDynamicItemSlotS, slot.Value));
}
private void SyncUISlots()
{
var dynamicItemStorage = PlayerManager.LocalPlayerScript.DynamicItemStorage;
var newstored = dynamicItemStorage.ClientSlotCharacteristic;
List<Tuple<IDynamicItemSlotS, BodyPartUISlots.StorageCharacteristics>> Inadd = new List<Tuple<IDynamicItemSlotS, BodyPartUISlots.StorageCharacteristics>>();
List<Tuple<int, BodyPartUISlots.StorageCharacteristics>> Inremove = new List<Tuple<int, BodyPartUISlots.StorageCharacteristics>>();

}
foreach (var slot in newstored)
{
if (slot.Value.NotPresentOnUI) continue;

foreach (var OLDslot in ContainSlots)
bool NotPresent = true;
foreach (var Oldslot in ContainSlots)
{
bool NotPresent = true;
foreach (var Newslot in Newstored)
if (Oldslot.Item1 == slot.Value.RelatedIDynamicItemSlotS.InterfaceGetInstanceID && Oldslot.Item2 == slot.Value)
{
if (OLDslot.Item1 == Newslot.Value.RelatedIDynamicItemSlotS.InterfaceGetInstanceID && OLDslot.Item2 == Newslot.Value)
{
NotPresent = false;
}
}

if (NotPresent)
{
Inremove.Add(OLDslot);
NotPresent = false;
}
}

foreach (var removeing in Inremove)
if (NotPresent)
{
RemoveSpecifyedUISlot(removeing.Item1, removeing.Item2);
ContainSlots.Remove(removeing);
Inadd.Add(new Tuple<IDynamicItemSlotS, BodyPartUISlots.StorageCharacteristics>(slot.Value.RelatedIDynamicItemSlotS, slot.Value));
}
}

foreach (var OLDslot in ContainSlots)
{
bool NotPresent = true;
foreach (var Newslot in newstored)
{
if (OLDslot.Item1 == Newslot.Value.RelatedIDynamicItemSlotS.InterfaceGetInstanceID && OLDslot.Item2 == Newslot.Value)
{
NotPresent = false;
}
}

foreach (var Adding in Inadd)
if (NotPresent)
{
AddIndividual(Adding.Item1, Adding.Item2);
ContainSlots.Add(new Tuple<int, BodyPartUISlots.StorageCharacteristics>(Adding.Item1.InterfaceGetInstanceID,Adding.Item2 ));
Inremove.Add(OLDslot);
}
}
else

foreach (var removeing in Inremove)
{
RemoveSpecifyedUISlot(removeing.Item1, removeing.Item2);
ContainSlots.Remove(removeing);

foreach (var contained in ContainSlots)
{
RemoveSpecifyedUISlot(contained.Item1, contained.Item2);
}
ContainSlots.Clear();
}

foreach (var Adding in Inadd)
{
AddIndividual(Adding.Item1, Adding.Item2);
ContainSlots.Add(new Tuple<int, BodyPartUISlots.StorageCharacteristics>(Adding.Item1.InterfaceGetInstanceID,Adding.Item2 ));
}
}

public void RemoveSpecifyedUISlot(int bodyPartUISlots,
Expand Down Expand Up @@ -191,17 +229,31 @@ public void AddIndividual(IDynamicItemSlotS bodyPartUISlots,
break;
}

// if (ClientContents.ContainsKey(storageCharacteristicse.SlotArea) == false) ClientContents[storageCharacteristicse.SlotArea] = new List<UI_DynamicItemSlot>();
// ClientContents[storageCharacteristicse.SlotArea].Add(NewSlot);
gameobjt.transform.localScale = Vector3.one;
if (BodyPartToSlot.ContainsKey(bodyPartUISlots.InterfaceGetInstanceID) == false)
BodyPartToSlot[bodyPartUISlots.InterfaceGetInstanceID] = new List<GameObject>();
BodyPartToSlot[bodyPartUISlots.InterfaceGetInstanceID].Add(gameobjt);

OpenSlots.Add(NewSlot);
}
}

private void SortSlots(Transform parentTransform)
{
if (parentTransform == null) return;
var slots = parentTransform.GetComponentsInChildren<UI_DynamicItemSlot>();
Array.Sort(slots, (slot1, slot2) =>
{
int order1 = NamedSlotOrder.ContainsKey(slot1.NamedSlot) ? -NamedSlotOrder[slot1.NamedSlot] : int.MaxValue;
int order2 = NamedSlotOrder.ContainsKey(slot2.NamedSlot) ? -NamedSlotOrder[slot2.NamedSlot] : int.MaxValue;
return order1.CompareTo(order2);
});

for (int i = 0; i < slots.Length; i++)
{
slots[i].transform.parent.SetSiblingIndex(i);
}
}

public enum SlotArea
{
Pockets,
Expand Down