public void HandleTargetCreated() { //Debug.Log("CharacterPanel.HandleTargetCreated()"); unitController?.UnitModelController.SetInitialSavedAppearance(); CharacterEquipmentManager characterEquipmentManager = unitController.CharacterUnit.BaseCharacter.CharacterEquipmentManager; // providers need to be set or equipment won't be able to be equipped unitController.CharacterUnit.BaseCharacter.SetUnitType(playerManager.MyCharacter.UnitType, true, false, false); unitController.CharacterUnit.BaseCharacter.SetCharacterRace(playerManager.MyCharacter.CharacterRace, true, false, false); unitController.CharacterUnit.BaseCharacter.SetCharacterFaction(playerManager.MyCharacter.Faction, true, false, false); unitController.CharacterUnit.BaseCharacter.SetCharacterClass(playerManager.MyCharacter.CharacterClass, true, false, false); unitController.CharacterUnit.BaseCharacter.SetClassSpecialization(playerManager.MyCharacter.ClassSpecialization, true, false, false); unitController.CharacterUnit.BaseCharacter.CharacterStats.SetLevel(playerManager.MyCharacter.CharacterStats.Level); if (characterEquipmentManager != null) { if (playerManager.MyCharacter?.CharacterEquipmentManager != null) { //characterEquipmentManager.CurrentEquipment = playerManager.MyCharacter.CharacterEquipmentManager.CurrentEquipment; // testing new code to avoid just making a pointer to the player gear, which results in equip/unequip not working properly characterEquipmentManager.CurrentEquipment.Clear(); foreach (EquipmentSlotProfile equipmentSlotProfile in playerManager.MyCharacter.CharacterEquipmentManager.CurrentEquipment.Keys) { characterEquipmentManager.CurrentEquipment.Add(equipmentSlotProfile, playerManager.MyCharacter.CharacterEquipmentManager.CurrentEquipment[equipmentSlotProfile]); } } } else { Debug.Log("CharacterPanel.HandleTargetCreated(): could not find a characterEquipmentManager"); } }
public void EquipItemModels(CharacterEquipmentManager characterEquipmentManager, EquipmentSlotProfile equipmentSlotProfile, Equipment equipment) { //Debug.Log(unitController.gameObject.name + ".MecanimModelController.EquipItemModels()"); SpawnEquipmentObjects(equipmentSlotProfile, equipment); if (unitController?.UnitAnimator != null) { unitController.UnitAnimator.HandleEquipmentChanged(equipment, null); } }
public void EquipCharacter() { //Debug.Log("NewGamePanel.EquipCharacter()"); if (characterCreatorManager.PreviewUnitController == null) { // if this is called on the initial load then the preview panel isn't open yet //Debug.Log("NewGamePanel.EquipCharacter(): no preview unit available"); return; } /* * if (characterPreviewPanel.CharacterReady == false) { * // attempting this before the character is spawned will make it go invisible (UMA bug) * //Debug.Log("NewGameCharacterPanelController.EquipCharacter(): character not ready yet, exiting."); * return; * } */ // set character class etc first so preview works and can equip character SetCharacterProperties(); int changes = 0; CharacterEquipmentManager characterEquipmentManager = characterCreatorManager.PreviewUnitController.CharacterUnit.BaseCharacter.CharacterEquipmentManager; if (characterEquipmentManager != null) { //Debug.Log("NewGameCharacterPanelController.EquipCharacter(): found equipment manager"); // unequip equipment not in current list //characterEquipmentManager.UnequipAll(false); List <Equipment> removeList = new List <Equipment>(); foreach (Equipment equipment in characterEquipmentManager.CurrentEquipment.Values) { //Debug.Log("NewGamePanel.EquipCharacter(): checking for removal : " + (equipment == null ? "null" : equipment.DisplayName)); if (equipment != null && !newGameManager.EquipmentList.ContainsValue(equipment)) { removeList.Add(equipment); } } foreach (Equipment equipment in removeList) { //characterEquipmentManager.Unequip(equipment, false, false, false); characterEquipmentManager.Unequip(equipment, true, true, false); changes++; } // equip equipment in list but not yet equipped if (newGameManager.EquipmentList != null) { //Debug.Log("NewGameCharacterPanelController.EquipCharacter(): equipment list is not null"); foreach (Equipment equipment in newGameManager.EquipmentList.Values) { //Debug.Log("NewGameCharacterPanelController.EquipCharacter(): ask to equip: " + equipment.DisplayName); if (!characterEquipmentManager.CurrentEquipment.ContainsValue(equipment)) { characterEquipmentManager.Equip(equipment, null, false, false, false); changes++; } } } if (characterPreviewPanel.CharacterReady == true && changes > 0) { //Debug.Log("NewGamePanel.EquipCharacter(): character is ready"); characterCreatorManager.PreviewUnitController.UnitModelController.RebuildModelAppearance(); } //characterPreviewPanel.BuildModelAppearance(); } }