private bool onEquipmentAddedToAvatar(InventoryModelEvents.EquipmentAddedToAvatar evt) { DCustomOutfit outfit = default(DCustomOutfit); outfit.Equipment = new DCustomEquipment[1] { evt.Data }; Model.ApplyOutfit(outfit); eventDispatcher.DispatchEvent(new InventoryPenguinAnimEvents.EquipmentEquipped(outfit.Equipment[outfit.Equipment.Length - 1].DefinitionId)); return(false); }
private IEnumerator loadRenderGameObjects(DCustomEquipment[] outfit, Color bodyColor, AvatarAnimationFrame avatarFrame, RenderRequest renderRequest) { if (avatarPrefab == null && isLoadingAvatarPrefab) { yield return(null); } if (avatarPrefab == null) { isLoadingAvatarPrefab = true; AssetRequest <GameObject> assetRequest = null; try { assetRequest = Content.LoadAsync(uiAvatarPrefabContentKey); } catch (Exception ex) { Log.LogError(this, $"Could not load UI Avatar penguin asset {uiAvatarPrefabContentKey.Key}. Message: {ex.Message}"); } if (assetRequest != null) { yield return(assetRequest); avatarPrefab = assetRequest.Asset; isLoadingAvatarPrefab = false; } } if (avatarPrefab != null) { GameObject avatarInstance = UnityEngine.Object.Instantiate(avatarPrefab); IconRenderLightingRig lightingRig = IconRenderLightingRig.Acquire(); while (!lightingRig.IsReady) { yield return(null); } DCustomOutfit avatarOutfit = default(DCustomOutfit); avatarOutfit.Equipment = outfit; AvatarModel avatarModel = avatarInstance.GetComponent <AvatarModel>(); yield return(AvatarRenderer.RenderOutfit(avatarOutfit, avatarModel.BeakColor, bodyColor, avatarModel.BellyColor, imageBuilderCameraData, avatarInstance, (ModelRenderer modelRenderer) => onProcessAnimationFrame(modelRenderer, renderRequest.Handle, avatarInstance), avatarFrame)); IconRenderLightingRig.Release(); } else { Log.LogErrorFormatted(this, "Unabe to load the UI Avatar Prefab at path {0}", uiAvatarPrefabContentKey.Key); } }
private bool onInventoryRetrieved(InventoryServiceEvents.InventoryLoaded evt) { Service.Get <EventDispatcher>().RemoveListener <InventoryServiceEvents.InventoryLoaded>(onInventoryRetrieved); DataEntityHandle localPlayerHandle = Service.Get <CPDataEntityCollection>().LocalPlayerHandle; if (!localPlayerHandle.IsNull) { inventoryData = Service.Get <CPDataEntityCollection>().AddComponent <InventoryData>(localPlayerHandle); inventoryData.Inventory = new Dictionary <long, InventoryIconModel <DCustomEquipment> >(); inventoryData.CurrentAvatarEquipment = new List <long>(); setTemplateData(); for (int i = 0; i < evt.Inventory.Count; i++) { try { DCustomEquipment data = CustomEquipmentResponseAdaptor.ConvertResponseToCustomEquipment(evt.Inventory[i]); InventoryIconModel <DCustomEquipment> value = new InventoryIconModel <DCustomEquipment>(data.Id, data, isEquipped: false, isMemberItem: true); inventoryData.Inventory.Add(data.Id, value); } catch (KeyNotFoundException) { } } if (Service.Get <CPDataEntityCollection>().TryGetComponent(localPlayerHandle, out AvatarDetailsData component) && component.Outfit != null) { DCustomOutfit currentAvatarEquipment = default(DCustomOutfit); currentAvatarEquipment.Equipment = component.Outfit; setCurrentAvatarEquipment(currentAvatarEquipment); } } else { Log.LogError(this, "Unable to find the LocalPlayerHandle."); } setDefaultScreen(); string key = SceneTransitionService.SceneArgs.ShowCatalogOnEntry.ToString(); if (Service.Get <SceneTransitionService>().HasSceneArg(key) && (bool)Service.Get <SceneTransitionService>().GetSceneArg(key)) { showCatalog(); } return(false); }
private void setupAvatarWithCurrentOutfit() { DataEntityHandle localPlayerHandle = Service.Get <CPDataEntityCollection>().LocalPlayerHandle; if (!localPlayerHandle.IsNull) { AvatarDetailsData component = Service.Get <CPDataEntityCollection>().GetComponent <AvatarDetailsData>(localPlayerHandle); if (component != null) { Model.BodyColor = component.BodyColor; DCustomOutfit outfit = default(DCustomOutfit); outfit.Equipment = component.Outfit; Model.ClearAllEquipment(); Model.ApplyOutfit(outfit); } else { Log.LogError(this, "Unable to find AvatarDetailsData on local player handle. Body color and initial outfit not set."); Model.ClearAllEquipment(); } } }