private void OnGUI()
        {
            _source  = (Source)EditorGUILayout.EnumPopup("Source", _source);
            itemGuid = EditorGUILayout.TextField("Item GUID", itemGuid);

            _scrollPosition = GUILayout.BeginScrollView(_scrollPosition, false, true);

            if (string.IsNullOrEmpty(itemGuid))
            {
                if (_source == Source.Server)
                {
                    var items = ServerItemRegistry.GetAll();
                    foreach (var item in items)
                    {
                        DrawItemInfo(item);
                    }
                }
                else if (_source == Source.Client)
                {
                    var items = ItemRegistry.GetAll();
                    foreach (var item in items)
                    {
                        DrawItemInfo(item);
                    }
                }
            }
            else
            {
                System.Guid guid;
                if (System.Guid.TryParse(itemGuid, out guid))
                {
                    if (_source == Source.Server)
                    {
                        var item = ServerItemRegistry.Get(guid);
                        DrawItemInfo(item);
                    }
                    else if (_source == Source.Client)
                    {
                        var col = ItemRegistry.Get(guid);
                        DrawItemInfo(col);
                    }
                }
                else
                {
                    EditorGUILayout.LabelField("guid is not a valid parsable GUID value");
                }
            }

            EditorGUILayout.EndScrollView();
        }
Exemplo n.º 2
0
        public void Server_CleanDanglingItemReferences()
        {
            var all = ServerItemRegistry.GetAll();

            foreach (var item in all)
            {
                var entry = item as ICollectionSlotEntry;
                if (entry != null && entry.collectionEntry != null)
                {
                    if (entry.collectionEntry.amount == 0)
                    {
                        // Item is depleted, yet still exists and has a reference to a collection (itemGuid could be filled by other item now).
                        ServerItemRegistry.UnRegister(item.ID);
                        ItemRegistry.UnRegister(item.ID);
                        logger.Log($"[Server] Cleaned dangling item {item.ID} from item registry", this);
                    }
                }
            }
        }