Exemple #1
0
    public override void Setup()
    {
        base.Setup();

        // Clear any existing data
        dropdown.ClearOptions();
        optionCategoryMap.Clear();

        foreach (ItemID id in GetItemIDs())
        {
            // Get the current option
            ItemData data = ItemRegistry.Get(id);
            TMP_Dropdown.OptionData option = new TMP_Dropdown.OptionData(data.Name.Get(itemDisplayName), data.ShopItem.Icon);

            // Add the option to the dropdown and the dictionary
            dropdown.options.Add(option);
            optionCategoryMap.Add(option, id);
        }

        // Setup the value changed callback
        dropdown.onValueChanged.AddListener(SetDropdownValue);
        // Setup the value to the first one
        if (dropdown.options.Count > 0)
        {
            SetDropdownValueWithoutNotify(0);
        }
    }
 internal void RegisterPlaceableItems(ItemRegistry r)
 {
     foreach (var fi in _dictionary.Values.Select(f => f.GetPlaceableItem()))
     {
         if (r.Get(fi.Key).IsPresent())
         {
             fi.Key = new ResourceKey(fi.Key.Namespace, fi.Key.Key + "_placeable");
         }
         r.Register(fi.Key, fi);
     }
 }
        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();
        }
        public void TargetRpc_SetSlot(NetworkConnection target, SlotDataMessage data)
        {
            var collection = UNetActionsBridge.collectionFinder.GetClientCollection(data.collectionGuid) as ICollection;

            if (collection != null)
            {
                var item = ItemRegistry.Get(data.itemInstanceGuid);
                collection.ForceSetBoxed(data.index, item, item != null ? data.amount : 0);

                logger.Log($"[Client] Set index {data.index} to item with GUID: {data.itemInstanceGuid} x {data.amount} in collection {data.collectionGuid} with netId: {bridge.netId}", bridge);
            }
            else
            {
                logger.Warning($"[Client] Collection with guid: {data.collectionGuid} not found. Can't set slot {data.index}", bridge);
            }
        }
Exemple #5
0
        public void TargetRpc_NotifyItemUsed(NetworkConnection target, ItemUsedMessage data)
        {
            var item = ItemRegistry.Get(data.itemID) as INetworkItemInstance;

            if (item != null)
            {
                item.Client_NotifyUsed(player, new ItemContext()
                {
                    useAmount   = data.amountUsed,
                    targetIndex = data.targetIndex
                });
            }
            else
            {
                logger.Warning("[Client] Server notified of used item, but item not found! :: " + data.itemID);
            }
        }
        public void TargetRpc_NotifyItemUsed(byte[] itemGuidBytes, int useAmount, int targetIndex)
        {
            Guid itemGuid = new Guid(itemGuidBytes);

            logger.Log($"[TargetRpc][ViewId: {this.photonView.ViewID}] {nameof(TargetRpc_NotifyItemUsed)}(itemGuid: {itemGuid}, useAmount: {useAmount}, targetIndex: {targetIndex})", this);

            var item = ItemRegistry.Get(itemGuid) as INetworkItemInstance;

            if (item != null)
            {
                item.Client_NotifyUsed(player, new ItemContext()
                {
                    useAmount   = useAmount,
                    targetIndex = targetIndex
                });
            }
            else
            {
                logger.Warning("[Client] Server notified of used item, but item not found! :: " + itemGuid);
            }
        }
    private void OnItemIDChanged(ItemID id)
    {
        // Set the title text to the name of the category
        ItemData data = ItemRegistry.Get(id);

        titleText.text = data.Name.Get(ItemName.Type.Science) + ": Target Specifications";

        // Destroy all notes
        foreach (ResearchSingleNoteUI note in currentNotes)
        {
            Destroy(note.gameObject);
        }
        currentNotes.Clear();

        // Create a new note for every label
        foreach (string label in CurrentNoteLabels.Labels)
        {
            ResearchSingleNoteUI clone = Instantiate(notePrefab, noteParent.transform);
            clone.Setup(id, label, scrollView);
            currentNotes.Add(clone);
        }
    }