public void RPC_ShowUI() { var vendor = VendorRegistry.itemVendors.Get(vendorGuid) as PUN2Vendor <IItemInstance>; if (vendor == null) { new UnityLogger("[Vendor] ").Error($"Couldn't find vendor for guid: '{vendorGuid}'", this); } var vendors = FindObjectsOfType <ItemVendorUI>(); foreach (var vendorUI in vendors) { if (vendorUI.collectionName == _vendorCollectionName) { vendorUI.vendor = vendor; vendorUI.collection = vendor?.vendorCollection; vendorUI.window.Show(); _currentVendorUI = vendorUI; return; } } new UnityLogger("[Vendor] ").Warning("Couldn't find VendorUI that repaints collection " + vendor?.vendorCollectionName, this); }
public void OnTriggerUsed(Character character, TriggerEventData data) { var vendor = VendorRegistry.itemVendors.Get(_vendorGuid.guid) as UnityVendor <IItemInstance>; if (vendor != null) { var vendors = FindObjectsOfType <ItemVendorUI>(); foreach (var vendorUI in vendors) { if (vendorUI.collectionName == vendor.vendorCollectionName) { vendorUI.vendor = vendor; vendorUI.collection = vendor.vendorCollection; vendorUI.window.Show(); _activeUI = vendorUI; return; } } new UnityLogger("[Vendor] ").Warning("Couldn't find VendorUI that repaints collection for vendor: " + vendor.vendorCollectionName); return; } new UnityLogger("[Vendor] ").Warning("Couldn't find VendorUI that repaints for vendor: " + _vendorGuid); }
// [ServerCallback] public void OnTriggerUsed(Character character, TriggerEventData data) { if (isServer) { var vendor = ServerVendorRegistry.itemVendors.Get(vendorGuid) as UNetVendor <IItemInstance>; var bridge = character.GetComponent <UNetActionsBridge>(); if (character is Player && bridge != null && vendor != null) { // Register collection on client bridge.Server_AddVendorItemCollectionToClient(new AddCollectionMessage() { collectionGuid = vendor.vendorCollectionGuid, collectionName = vendor.vendorCollectionName, owner = _identity, slotCount = 10, }); // Give the client read permission to the vendor's items. // TODO: Consider putting this in a single call with registration (add collection call) bridge.Server_SetCollectionPermissionOnServerAndClient(new SetCollectionPermissionMessage() { collectionGuid = vendor.vendorCollectionGuid, permission = ReadWritePermission.Read }); bridge.Server_SetItemVendorCollectionContentsOnClient(vendor.vendorGuid, vendor.vendorCollectionGuid, vendor.vendorCollection); } } if (isClient && character == PlayerManager.currentPlayer) { var vendor = VendorRegistry.itemVendors.Get(vendorGuid) as UNetVendor <IItemInstance>; var vendors = FindObjectsOfType <ItemVendorUI>(); foreach (var vendorUI in vendors) { if (vendorUI.collectionName == _vendorCollectionName) { vendorUI.vendor = vendor; vendorUI.collection = vendor?.vendorCollection; vendorUI.window.Show(); _currentVendorUI = vendorUI; return; } } new UnityLogger("[Vendor] ").Warning("Couldn't find VendorUI that repaints collection " + vendor?.vendorCollectionName); } }