Exemple #1
0
        // setup the entire interactor object and merton NPC (no gameplay)
        private void SetupInteractor(Vector3 pos)
        {
            // base gameobject
            InteractorObj = new GameObject("Horde_Interactor");
            InteractorObj.transform.position = pos;

            // fire sigil visuals
            StartCoroutine(AddItemToInteractor(8000010, Vector3.down * 0.35f, Vector3.zero, false, InteractorObj.transform));

            // setup Merton NPC
            var merton = SetupBasicNPC(pos, true);

            merton.transform.parent = InteractorObj.transform;
            // setup auto look
            merton.AddComponent <NPCLookFollow>();
            // setup character visuals
            try { SetupNpcArmor(merton, new List <int> {
                    3200030, 3200031, 3200032
                }); }
            catch { }
            // animation fix
            merton.SetActive(false);
            merton.SetActive(true);
            // make big
            merton.transform.localScale *= 1.6f;

            // setup components
            InteractionTriggerBase triggerBase = InteractorObj.AddComponent <InteractionTriggerBase>();
            InteractionActivator   activator   = InteractorObj.AddComponent <InteractionActivator>();
            //InteractionBase interactBase = InteractorObj.AddComponent(new InteractionBase { OnActivationEvent = new UnityAction(InteractorBeginEvent) });
            InteractionBase interactBase = InteractorObj.AddComponent <InteractionBase>();

            interactBase.OnActivationEvent = new UnityAction(InteractorBeginEvent);
            triggerBase.SetActivator(activator);
            At.SetValue("Begin <color=#FF0000>Merton's Challenge</color>", typeof(InteractionActivator), activator, "m_overrideBasicText");
            At.SetValue(interactBase, typeof(InteractionActivator), activator, "m_sceneBasicInteraction");
        }
        // usually called from LoadScene. Also by the Sync functions when you join a host.
        public IEnumerator SetupBonfireLocal(Vector3 position, string uid)
        {
            Debug.Log("Setting up bonfire at: " + position.ToString() + ", uid: " + uid);

            var bonfire = new GameObject("Bonfire_" + uid);

            bonfire.transform.position = position;

            var activatedCampfire = ResourcesPrefabManager.Instance.GetItemPrefab(5000101).GetComponent <Deployable>().DeployedStateItemPrefab.VisualPrefab;
            var fireVisuals       = Instantiate(activatedCampfire.gameObject);

            fireVisuals.transform.parent   = bonfire.transform;
            fireVisuals.transform.position = bonfire.transform.position;

            var swordVisuals = Instantiate(ResourcesPrefabManager.Instance.GetItemPrefab(2000151).VisualPrefab.gameObject);

            swordVisuals.transform.parent   = bonfire.transform;
            swordVisuals.transform.position = bonfire.transform.position + Vector3.up;
            swordVisuals.transform.rotation = Quaternion.Euler(0, 0, 90);

            var sigilVisuals = Instantiate(ResourcesPrefabManager.Instance.GetItemPrefab(8000010).VisualPrefab.gameObject);

            sigilVisuals.transform.parent   = bonfire.transform;
            sigilVisuals.transform.position = bonfire.transform.position;

            // interaction gameobject base
            GameObject actionHolder = new GameObject("Interaction_Holder");

            actionHolder.transform.parent   = bonfire.transform;
            actionHolder.transform.position = bonfire.transform.position;

            // setup components
            InteractionTriggerBase triggerBase  = actionHolder.AddComponent <InteractionTriggerBase>();
            InteractionActivator   activator    = actionHolder.AddComponent <InteractionActivator>();
            InteractionBase        interactBase = actionHolder.AddComponent <InteractionBase>();

            // setup the trigger base
            triggerBase.SetHolderUID(uid);
            triggerBase.GenerateColliderIfNone = true;
            triggerBase.IsLargeTrigger         = true;
            triggerBase.DetectionPriority      = -9999;
            triggerBase.SetActivator(activator);

            // setup the interaction activator
            activator.SetUID(uid);
            At.SetValue("Rest at <color=#fc4e03>Bonfire</color>", typeof(InteractionActivator), activator, "m_overrideBasicText");
            At.SetValue(interactBase, typeof(InteractionActivator), activator, "m_sceneBasicInteraction");

            // setup the event interaction base
            interactBase.OnActivationEvent = BonfireEvent;

            // =========== finalize =========== //
            bonfire.gameObject.SetActive(true);

            yield return(new WaitForSeconds(0.1f));

            //activator.Reregister();
            foreach (ParticleSystem ps in fireVisuals.GetComponentsInChildren <ParticleSystem>())
            {
                ps.Play();
                var m = ps.main;
                m.prewarm     = true;
                m.playOnAwake = true;
            }
            foreach (Light light in fireVisuals.GetComponentsInChildren <Light>())
            {
                light.gameObject.SetActive(true);
            }
            foreach (SoundPlayer sound in fireVisuals.GetComponentsInChildren <SoundPlayer>())
            {
                sound.Play(false);
            }
        }
Exemple #3
0
        public GameObject GenerateSimpleNPC(Vector3 position)
        {
            var panel = Resources.FindObjectsOfTypeAll <CharacterCreationPanel>()[0];

            // OR var panel = CharacterManager.Instance.GetFirstLocalCharacter().CharacterUI.MainMenu.CurrentCharacterCreationPanel;

            /*GameObject prefab = AccessTools.Field(typeof(CharacterCreationPanel), "CharacterCreationPrefab").GetValue(panel) as GameObject;
             *
             * if (prefab && prefab.transform.Find("HumanSNPC") is Transform npc)
             * {
             *  Transform npc2 = Instantiate(npc);
             *
             *  // move npc to player
             *  npc2.position = position;
             *  return npc2.gameObject;
             * }*/
            try
            {
                //AccessTools.Method(typeof(CharacterCreationPanel), "InitHumanSNPC").Invoke(panel, null);
                //panel.OnRandomize();
                GameObject prefab = AccessTools.Field(typeof(CharacterCreationPanel), "CharacterCreationPrefab").GetValue(panel) as GameObject;
                if (prefab && prefab.transform.Find("HumanSNPC") is Transform npc)
                {
                    //npc.position = position;
                    //SNPC testNC = npc.GetOrAddComponent<SNPC>();

                    // _SNPC/CharactersToDesactivate/_Immobile
                    GameObject gameObject = GameObject.Find("_SNPC");
                    if (gameObject != null)
                    {
                        //OLogger.Log("_SNPC", "ffffffff", "wip");
                        Transform t1 = gameObject.transform.Find("CharactersToDesactivate");
                        if (t1 != null)
                        {
                            //OLogger.Log("CharactersToDesactivate", "ffffffff", "wip");
                            Transform t2 = t1.transform.Find("_Immobile");
                            if (t2 != null)
                            {
                                //OLogger.Log("_Immobile", "ffffffff", "wip");
                                //testNC = t2.GetOrAddComponent<SNPC>();
                                Transform npc2 = Instantiate(npc);
                                npc2.transform.parent = t2;
                                npc2.name             = "HumanSNPC_lasyan3";
                                npc2.position         = position;

                                #region BasicInteraction

                                /*GameObject gameObject2 = new GameObject("Interaction_Holder");
                                 * gameObject2.transform.parent = npc2.transform;
                                 * gameObject2.transform.position = position;
                                 * InteractionTriggerBase interactionTriggerBase = gameObject2.AddComponent<InteractionTriggerBase>();
                                 * InteractionActivator interactionActivator = gameObject2.AddComponent<InteractionActivator>();
                                 * InteractionBase interaction = gameObject2.AddComponent<InteractionBase>();
                                 * interactionTriggerBase.GenerateColliderIfNone = true;
                                 * interactionTriggerBase.IsLargeTrigger = true;
                                 * interactionTriggerBase.DetectionPriority = -9999;
                                 * interactionTriggerBase.SetActivator(interactionActivator);
                                 * AccessTools.Field(typeof(InteractionActivator), "m_overrideBasicText").SetValue(interactionActivator, "Rest at <color=#fc4e03>Bonfire</color>");
                                 * AccessTools.Field(typeof(InteractionActivator), "m_sceneBasicInteraction").SetValue(interactionActivator, interaction);
                                 * interaction.OnActivationEvent = testEvent;//*/
                                #endregion

                                #region NPCInteraction
                                // InteractionTriggerBase   --> _SNPC/CharactersToDesactivate/_UNPC/Elinarasaved/UNPC_EllinaraA/Dialogue_EllinaraA/InteractionAccessPoint_pO7WB - InteractionTriggerBase
                                // InteractionActivator     --> _SNPC/CharactersToDesactivate/_UNPC/Elinarasaved/UNPC_EllinaraA/Dialogue_EllinaraA/NPC/InteractionActivatorSettings - Component
                                // NPCInteraction           --> _SNPC/CharactersToDesactivate/_UNPC/Elinarasaved/UNPC_EllinaraA/Dialogue_EllinaraA/NPC/InteractionActivatorSettings - Component
                                GameObject gameObject2 = new GameObject("Interaction_Holder");
                                gameObject2.transform.parent   = npc2.transform;
                                gameObject2.transform.position = position;

                                Transform InteractionAccessPoint = FindPath("_SNPC", "CharactersToDesactivate/_UNPC/Elinarasaved/UNPC_EllinaraA/Dialogue_EllinaraA/InteractionAccessPoint_pO7WB");
                                InteractionTriggerBase interactionTriggerBase = InteractionAccessPoint.GetComponent <InteractionTriggerBase>(); // gameObject2.AddComponent<InteractionTriggerBase>();
                                interactionTriggerBase.transform.parent = gameObject2.transform;
                                Transform            InteractionActivatorSettings = FindPath("_SNPC", "CharactersToDesactivate/_UNPC/Elinarasaved/UNPC_EllinaraA/Dialogue_EllinaraA/NPC/InteractionActivatorSettings");
                                InteractionActivator interactionActivator         = InteractionActivatorSettings.GetComponent <InteractionActivator>(); // gameObject2.AddComponent<InteractionActivator>();
                                interactionActivator.transform.parent = gameObject2.transform;
                                NPCInteraction interaction = InteractionActivatorSettings.GetComponent <NPCInteraction>();                              // gameObject2.AddComponent<NPCInteraction>();
                                interaction.transform.parent = gameObject2.transform;
                                // DialogueActor
                                // m_dialogueTree --> NPCDialogue.DialogueTree
                                // m_character --> DialogueActor.gameObject.GetComponent<Character>()
                                // m_dialogueActorLocalize --> DialogueActor.GetComponent<DialogueActorLocalize>()
                                interactionTriggerBase.GenerateColliderIfNone = true;
                                interactionTriggerBase.IsLargeTrigger         = true;
                                interactionTriggerBase.DetectionPriority      = -9999;
                                interactionTriggerBase.SetActivator(interactionActivator);
                                AccessTools.Field(typeof(InteractionActivator), "m_overrideBasicText").SetValue(interactionActivator, "Rest at <color=#fc4e03>Bonfire</color>");
                                AccessTools.Field(typeof(InteractionActivator), "m_sceneBasicInteraction").SetValue(interactionActivator, interaction);
                                interaction.OnActivationEvent = testEvent;//*/
                                #endregion
                                OLogger.Log("DONE");
                            }
                        }
                    }

                    //OLogger.Log($"SNPC={testNC.UID}");
                    //AccessTools.Method(typeof(SNPC), "Start").Invoke(testNC, null);
                    //CharacterVisuals cv = AccessTools.Field(typeof(SNPC), "m_visuals").GetValue(testNC) as CharacterVisuals;
                    //OLogger.Log($"visuals={cv == null}");
                    //testNC.transform.position = position;

                    //testNC.StartTalking(panel.pl

                    /*OLogger.Log($"CharacterVisuals");
                     * CharacterVisuals cv = AccessTools.Field(typeof(CharacterCreationPanel), "m_characterVisuals").GetValue(panel) as CharacterVisuals;
                     * OLogger.Log($"testSN");
                     * SNPC testSN = new SNPC();
                     * OLogger.Log($"m_visuals");
                     * AccessTools.Field(typeof(SNPC), "m_visuals").SetValue(testSN, cv);
                     * OLogger.Log($"Generate");
                     * //testSN.SetUID(UID.Generate());
                     * Transform npc2 = Instantiate(npc);
                     * //OLogger.Log($"transform={testSN.transform}");
                     * npc2.transform.position = position;*/

                    return(npc.gameObject);
                }
            }
            catch (Exception ex)
            {
                OLogger.Error(ex.Message);
            }
            return(null);
        }