Ejemplo n.º 1
0
        static public void maybeAddCharacter(UnitEntityView original)
        {
            var character = original.GetComponent <Character>();

            if (character == null)
            {
                character = original.gameObject.AddComponent <Character>();
                //BlueprintRoot.Instance.CharGen.FemaleDoll
                var drow = ResourcesLibrary.TryGetResource <UnitEntityView>("a65d9da806faa8f4ca078dfe942bf458", true);
                CloneMonobehaviour(drow.GetComponentInChildren <Character>(), character);
                character.BakedCharacter = CreateBakedCharacter(original.gameObject);
            }
        }
Ejemplo n.º 2
0
        static void ShowDollRoom(UnitEntityData unit, bool pregenMode = true)
        {
            if (unit == null)
            {
                throw new Exception("ShowDollRoom received null unit");
            }
            var dollRoom = Game.Instance.UI.Common.DollRoom;

            if (dollRoom != null)
            {
                CharGenDollRoom component = Game.Instance.UI.Common.DollRoom.GetComponent <CharGenDollRoom>();
                if (component)
                {
                    component.CreateDolls();
                }
                else
                {
                    Main.Error("CharGenDollRoom is null");
                }
                dollRoom.SetUnit(unit);
                if (pregenMode)
                {
                    BlueprintUnit  blueprint      = unit.Blueprint;
                    UnitEntityView unitEntityView = blueprint.Prefab.Load(false);
                    if (unitEntityView != null)
                    {
                        Character characterComponent = unitEntityView.GetComponent <Character>();
                        Character character          = dollRoom.CreateAvatar(characterComponent, blueprint.name);
                        character.AnimationManager.IsInCombat = false;
                        dollRoom.SetAvatar(character);
                    }
                    else
                    {
                        Main.Error("ShowDollRoom.unitEntityView is null");
                    }
                }
                //dollRoom.Show(true);
                if (dollRoom.Unit == null)
                {
                    Main.Error("Failed to set DollRoom.Unit");
                }
                if (dollRoom.GetAvatar() == null)
                {
                    Main.Error("Failed to set DollRoom.Avatar");
                }
            }
            else
            {
                Main.Error("Game.Instance.UI.Common.DollRoom is null");
            }
        }
Ejemplo n.º 3
0
        static public void TryReplaceView(UnitDescriptor Owner, UnitViewLink Prefab)
        {
            if (!Owner.Unit.View)
            {
                return;
            }
            UnitEntityView unitEntityView = Prefab.Load(true);

            if (unitEntityView == null)
            {
                return;
            }
            foreach (Buff buff in Owner.Buffs)
            {
                buff.ClearParticleEffect();
            }
            UnitEntityView oldView = Owner.Unit.View;
            UnitEntityView newView = UnityEngine.Object.Instantiate(unitEntityView).GetComponent <UnitEntityView>();

            newView.UniqueId = Owner.Unit.UniqueId;
            newView.transform.SetParent(oldView.transform.parent, false);
            newView.transform.position = oldView.transform.position;
            newView.transform.rotation = oldView.transform.rotation;
            newView.DisableSizeScaling = false;
            newView.Blueprint          = Owner.Blueprint;
            var character = newView.GetComponent <Character>();

            if (character == null)
            {
                character = newView.gameObject.AddComponent <Character>();
                character.AnimatorPrefab = BlueprintRoot.Instance.CharGen.FemaleDoll.AnimatorPrefab;
                character.BakedCharacter = CreateBakedCharacter(newView.gameObject);
                //BlueprintRoot.Instance.CharGen.FemaleDoll

                /*var drow = ResourcesLibrary.TryGetResource<UnitEntityView>("a65d9da806faa8f4ca078dfe942bf458", true);
                 * CloneMonobehaviour(drow.GetComponentInChildren<Character>(), character);
                 * character.BakedCharacter = CreateBakedCharacter(newView.gameObject);*/
            }
            Owner.Unit.AttachToViewOnLoad(newView);
            Owner.Unit.Commands.InterruptAll((UnitCommand cmd) => !(cmd is UnitMoveTo));
            var selectionManager = Game.Instance.UI.SelectionManager;

            if (selectionManager != null)
            {
                selectionManager.ForceCreateMarks();
            }
            UnityEngine.Object.Destroy(oldView.gameObject);
        }
Ejemplo n.º 4
0
        static public void TryReplaceView(UnitDescriptor Owner, UnitViewLink Prefab, bool use_master_view)
        {
            if (!Owner.Unit.View)
            {
                return;
            }
            UnitEntityView unitEntityView = null;

            if (!use_master_view)
            {
                unitEntityView = Prefab.Load(true);
            }
            else
            {//copy view from master
                var master = Owner.Unit.Descriptor.Master.Value;
                unitEntityView = master?.Descriptor.Doll.CreateUnitView(false);
                //Main.logger.Log("View: " + (unitEntityView != null).ToString());
                if (master != null)
                {
                    if (master?.UISettings.PortraitBlueprint != null)
                    {
                        Owner.Unit.Descriptor.UISettings.SetPortrait(master.UISettings.PortraitBlueprint);
                    }
                    else
                    {
                        Owner.Unit.Descriptor.UISettings.SetPortrait(master.UISettings.Portrait);
                    }
                    Owner.Unit.Descriptor.CustomPrefabGuid        = master.Descriptor.CustomPrefabGuid;
                    Owner.Unit.Descriptor.Doll                    = master.Descriptor.Doll;
                    Owner.Unit.Descriptor.ForcceUseClassEquipment = true;
                    Owner.Unit.Descriptor.CustomGender            = master.Descriptor.Gender;
                    Owner.Unit.Descriptor.CustomAsks              = master.Descriptor.Asks;
                }
            }
            if (unitEntityView == null)
            {
                return;
            }
            foreach (Buff buff in Owner.Buffs)
            {
                buff.ClearParticleEffect();
            }
            UnitEntityView oldView = Owner.Unit.View;
            UnitEntityView newView = null;

            if (!use_master_view)
            {
                newView          = UnityEngine.Object.Instantiate(unitEntityView).GetComponent <UnitEntityView>();
                newView.UniqueId = Owner.Unit.UniqueId;
            }
            else
            {
                newView = unitEntityView;
                //newView = UnityEngine.Object.Instantiate(unitEntityView).GetComponent<UnitEntityView>();
                newView.UniqueId = Owner.Unit.UniqueId;
                //newView = unitEntityView;
            }
            newView.transform.SetParent(oldView.transform.parent, false);
            newView.transform.position = oldView.transform.position;
            newView.transform.rotation = oldView.transform.rotation;
            newView.DisableSizeScaling = false;
            newView.Blueprint          = Owner.Blueprint;
            if (!use_master_view)
            {
                var character = newView.GetComponent <Character>();
                if (character == null)
                {
                    character = newView.gameObject.AddComponent <Character>();
                    character.AnimatorPrefab = BlueprintRoot.Instance.CharGen.FemaleDoll.AnimatorPrefab;
                    character.BakedCharacter = CreateBakedCharacter(newView.gameObject);
                    //BlueprintRoot.Instance.CharGen.FemaleDoll

                    /*var drow = ResourcesLibrary.TryGetResource<UnitEntityView>("a65d9da806faa8f4ca078dfe942bf458", true);
                     * CloneMonobehaviour(drow.GetComponentInChildren<Character>(), character);
                     * character.BakedCharacter = CreateBakedCharacter(newView.gameObject);*/
                }
            }
            Owner.Unit.AttachToViewOnLoad(newView);
            Owner.Unit.Commands.InterruptAll((UnitCommand cmd) => !(cmd is UnitMoveTo));
            var selectionManager = Game.Instance.UI.SelectionManager;

            if (selectionManager != null)
            {
                selectionManager.ForceCreateMarks();
            }

            if (use_master_view)
            {
                var master = Owner.Unit.Descriptor.Master.Value;
                int?clothesPrimaryIndex   = master.Descriptor.Doll?.ClothesPrimaryIndex;
                int primaryRampIndex      = !clothesPrimaryIndex.HasValue ? -1 : clothesPrimaryIndex.Value;
                int?clothesSecondaryIndex = master.Descriptor.Doll?.ClothesSecondaryIndex;
                int secondaryRampIndex    = !clothesSecondaryIndex.HasValue ? -1 : clothesSecondaryIndex.Value;
                var equipment_class       = CallOfTheWild.Helpers.GetField <BlueprintCharacterClass>(master.View, "m_EquipmentClass");
                foreach (EquipmentEntity loadClothe in equipment_class.LoadClothes(master.Descriptor.Gender, master.Descriptor.Progression.Race))
                {
                    unitEntityView.CharacterAvatar.AddEquipmentEntity(loadClothe, false);
                    if (primaryRampIndex >= 0)
                    {
                        unitEntityView.CharacterAvatar.SetPrimaryRampIndex(loadClothe, primaryRampIndex, false);
                    }
                    if (secondaryRampIndex >= 0)
                    {
                        unitEntityView.CharacterAvatar.SetSecondaryRampIndex(loadClothe, secondaryRampIndex, false);
                    }
                }
                //unitEntityView.UpdateClassEquipment();
            }
            UnityEngine.Object.Destroy(oldView.gameObject);
        }