Пример #1
0
        private static void CCTestBots(ConCommandArgs args)
        {
            if (Stage.instance == null)
            {
                return;
            }

            NetworkUser user = args.sender;

            foreach (GameObject gameObject in playerbots)
            {
                CharacterMaster master      = gameObject.GetComponent <CharacterMaster>();
                AIOwnership     aiOwnership = gameObject.GetComponent <AIOwnership>();
                string          name        = master.GetBody().GetDisplayName();

                if (aiOwnership.ownerMaster)
                {
                    Debug.Log(name + "'s master: " + aiOwnership.ownerMaster.GetBody().GetUserName());
                }
                else
                {
                    Debug.Log(name + " has no master");
                }

                Debug.Log(name + "'s money: " + master.money);
            }
        }
        private CharacterMaster SummonMaster(GameObject masterObjectPrefab, Vector3 position)
        {
            if (!NetworkServer.active)
            {
                Debug.LogWarning("[Server] function 'RoR2.CharacterMaster RoR2.EquipmentSlot::SummonMaster(UnityEngine.GameObject,UnityEngine.Vector3)' called on client");
                return(null);
            }
            GameObject gameObject = UnityEngine.Object.Instantiate <GameObject>(masterObjectPrefab, position, base.transform.rotation);

            NetworkServer.Spawn(gameObject);
            CharacterMaster component = gameObject.GetComponent <CharacterMaster>();

            component.SpawnBody(component.bodyPrefab, position, base.transform.rotation);
            AIOwnership component2 = gameObject.GetComponent <AIOwnership>();

            if (component2)
            {
                CharacterBody characterBody = this.characterBody;
                if (characterBody)
                {
                    CharacterMaster master = characterBody.master;
                    if (master)
                    {
                        component2.ownerMaster = master;
                    }
                }
            }
            BaseAI component3 = gameObject.GetComponent <BaseAI>();

            if (component3)
            {
                component3.leader.gameObject = base.gameObject;
            }
            return(component);
        }
Пример #3
0
        public void OpenSummon(Interactor activator)
        {
            if (!NetworkServer.active)
            {
                Debug.LogWarning("[Server] function 'System.Void RoR2.SummonMasterBehavior::OpenSummon(RoR2.Interactor)' called on client");
                return;
            }
            GameObject gameObject = UnityEngine.Object.Instantiate <GameObject>(this.masterPrefab, base.transform.position, base.transform.rotation);

            NetworkServer.Spawn(gameObject);
            CharacterMaster component = gameObject.GetComponent <CharacterMaster>();

            component.SpawnBody(component.bodyPrefab, base.transform.position + Vector3.up * 0.8f, base.transform.rotation);
            AIOwnership component2 = gameObject.GetComponent <AIOwnership>();

            if (component2)
            {
                CharacterBody component3 = activator.GetComponent <CharacterBody>();
                if (component3)
                {
                    CharacterMaster master = component3.master;
                    if (master)
                    {
                        component2.ownerMaster = master;
                    }
                }
            }
            BaseAI component4 = gameObject.GetComponent <BaseAI>();

            if (component4)
            {
                component4.leader.gameObject = activator.gameObject;
            }
            UnityEngine.Object.Destroy(base.gameObject);
        }
Пример #4
0
        // Ghost inheritance
        public static void spookyGhosts()
        {
            if (DII.GhostInherit.Value)
            {
                On.RoR2.Util.TryToCreateGhost += (orig, targetBody, ownerBody, duration) =>
                {
                    CharacterBody characterBody = orig(targetBody, ownerBody, duration);
                    if (characterBody == null)
                    {
                        return(null);
                    }
                    CharacterMaster cm         = characterBody.master;
                    AIOwnership     component2 = cm.gameObject.GetComponent <AIOwnership>();
                    CharacterMaster master     = ownerBody.master;
                    DII.checkConfig(cm, master);

                    CustomBlacklist.customItem(cm, DII.CBItemGhosts.Value);
                    CustomBlacklist.customItemCap(cm, DII.CBItemCapGhosts.Value);
                    CustomBlacklist.customEquip(cm, DII.CBEquipGhosts.Value);
                    cm.inventory.GiveItem(RoR2Content.Items.Ghost, 1);
                    cm.inventory.ResetItem(RoR2Content.Items.HealthDecay);
                    cm.inventory.GiveItem(RoR2Content.Items.HealthDecay, duration);
                    return(characterBody);
                };
            }
        }
        public void MakeGhost(CharacterBody body, CharacterBody owner)
        {
            if (acceptNext)
            {
                body.teamComponent.teamIndex = TeamComponent.GetObjectTeam(owner.gameObject);

                if (!body.master.GetComponent <AIOwnership>())
                {
                    body.master.gameObject.AddComponent <AIOwnership>();
                }

                if (!body.master.GetComponent <MinionOwnership>())
                {
                    body.master.gameObject.AddComponent <MinionOwnership>();
                }

                AIOwnership aiOwnership = body.master.GetComponent <AIOwnership>();
                aiOwnership.ownerMaster = owner.master;


                BaseAI baseAI = body.master.GetComponent <BaseAI>();
                baseAI.leader.gameObject    = owner.gameObject;
                baseAI.leader.characterBody = owner;


                /*
                 *
                 * var skillDrivers = body.master.GetComponents<AISkillDriver>();
                 *
                 * foreach (var oldDriver in skillDrivers)
                 * {
                 * UnityEngine.Object.Destroy(oldDriver);
                 * }
                 *
                 * var droneCard = Resources.Load<CharacterSpawnCard>("SpawnCards/CharacterSpawnCards/cscBackupDrone");
                 *
                 * var skillDriversDrone = droneCard.prefab.GetComponents<AISkillDriver>();
                 *
                 * foreach(var skillDriver in skillDriversDrone)
                 * {
                 *      MoreShrines.Print("Cloning Skill: " + skillDriver.customName);
                 *      CopyComponent(skillDriver, body.master.gameObject);
                 * }
                 */

                body.inventory.GiveItem(RoR2Content.Items.Ghost);
            }

            body.inventory.GiveItem(wispItem, wispCount);
        }
Пример #6
0
        static void HandleDropItem(NetworkMessage netMsg)
        {
            var dropItem = netMsg.ReadMessage <SummonClone>();
            var master   = dropItem.Player.GetComponent <CharacterBody>().master;


            CharacterBody component  = dropItem.Player.GetComponent <CharacterBody>();
            GameObject    gameObject = MasterCatalog.FindMasterPrefab("MercMonsterMaster");
            GameObject    bodyPrefab = BodyCatalog.FindBodyPrefab("MercBody");

            for (int i = 0; i < 2; i++)
            {
                if (master)
                {
                    GameObject      gameObject2 = Instantiate(gameObject, component.transform.position, component.transform.rotation);
                    CharacterMaster component2  = gameObject2.GetComponent <CharacterMaster>();
                    component2.gameObject.AddComponent <MasterSuicideOnTimer>().lifeTimer = 8f;

                    component2.teamIndex = TeamComponent.GetObjectTeam(component.gameObject);
                    AIOwnership component4 = gameObject2.GetComponent <AIOwnership>();
                    BaseAI      component5 = gameObject2.GetComponent <BaseAI>();
                    if (component4)
                    {
                        component4.ownerMaster = master;
                    }
                    if (component5)
                    {
                        component5.leader.gameObject = master.gameObject;
                    }

                    Inventory component6 = gameObject2.GetComponent <Inventory>();
                    component6.CopyItemsFrom(master.inventory);
                    component6.ResetItem(ItemIndex.BeetleGland);
                    component6.ResetItem(ItemIndex.WardOnLevel);
                    component6.ResetItem(ItemIndex.AutoCastEquipment);
                    component6.ResetItem(ItemIndex.ExtraLife);

                    NetworkServer.Spawn(gameObject2);
                    CharacterBody body = component2.SpawnBody(bodyPrefab, component.transform.position, component.transform.rotation);
                }
            }
        }
Пример #7
0
        private void UnlockingMage_onOpened(Interactor obj)
        {
            GameObject mageMasterPrefab = MasterCatalog.FindMasterPrefab("MageMonsterMaster");
            GameObject mageBodyPrefab   = mageMasterPrefab.GetComponent <CharacterMaster>().bodyPrefab;

            GameObject      mageMasterGameObject = UnityEngine.Object.Instantiate(mageMasterPrefab, gameObject.transform.position, Quaternion.identity);
            GameObject      mageBodyGameObject   = UnityEngine.Object.Instantiate(mageBodyPrefab, gameObject.transform.position, Quaternion.identity);
            CharacterMaster mageCharacterMaster  = mageBodyGameObject.GetComponent <CharacterMaster>();

            mageCharacterMaster.bodyPrefab = mageBodyGameObject;
            AIOwnership mageAIOwnership = mageBodyGameObject.GetComponent <AIOwnership>();

            CharacterMaster playerMaster = obj.gameObject.GetComponent <CharacterBody>().master;
            BaseAI          mageBaseAI   = gameObject.GetComponent <BaseAI>();

            if (mageCharacterMaster)
            {
                mageCharacterMaster.inventory.GiveItem(ItemIndex.BoostDamage, 10);
                mageCharacterMaster.inventory.GiveItem(ItemIndex.BoostHp, 10);
                GameObject bodyObject = playerMaster.GetBodyObject();
                if (bodyObject)
                {
                    Deployable component4 = mageBodyGameObject.GetComponent <Deployable>();
                    if (!component4)
                    {
                        component4 = mageBodyGameObject.AddComponent <Deployable>();
                    }
                    playerMaster.AddDeployable(component4, DeployableSlot.ParentAlly);
                }
            }
            if (mageAIOwnership)
            {
                mageAIOwnership.ownerMaster = obj.gameObject.GetComponent <CharacterBody>().master;
            }
            if (mageBaseAI)
            {
                mageBaseAI.leader.gameObject = base.gameObject;
            }

            NetworkServer.Spawn(mageBodyGameObject);
            mageCharacterMaster.SpawnBody(mageBodyGameObject, gameObject.transform.position, Quaternion.identity);
        }
Пример #8
0
        // A hacky method. Don't ask questions.
        private static void SpawnPlayerbotAsSummon(CharacterMaster owner, SurvivorIndex survivorIndex)
        {
            SurvivorDef def = SurvivorCatalog.GetSurvivorDef(survivorIndex);

            if (def == null)
            {
                return;
            }

            GameObject bodyPrefab = def.bodyPrefab;

            if (bodyPrefab == null)
            {
                return;
            }

            // Get card
            SpawnCard card = (SpawnCard)Resources.Load("SpawnCards/CharacterSpawnCards/cscBeetleGuardAlly");

            // Spawn request
            DirectorSpawnRequest spawnRequest = new DirectorSpawnRequest(card, new DirectorPlacementRule
            {
                placementMode = DirectorPlacementRule.PlacementMode.Approximate,
                minDistance   = 3f,
                maxDistance   = 40f,
                spawnOnTarget = owner.GetBody().transform
            }, RoR2Application.rng);

            spawnRequest.ignoreTeamMemberLimit = true;
            spawnRequest.teamIndexOverride     = new TeamIndex?(TeamIndex.Player);
            //spawnRequest.summonerBodyObject = owner.GetBody().gameObject;

            // Spawn
            GameObject gameObject = DirectorCore.instance.TrySpawnObject(spawnRequest);

            if (gameObject)
            {
                CharacterMaster master      = gameObject.GetComponent <CharacterMaster>();
                AIOwnership     aiOwnership = gameObject.AddComponent <AIOwnership>() as AIOwnership;
                BaseAI          ai          = gameObject.GetComponent <BaseAI>();

                if (master)
                {
                    master.name       = "PlayerBot";
                    master.bodyPrefab = bodyPrefab;
                    SetRandomSkin(master, bodyPrefab);

                    master.Respawn(master.GetBody().transform.position, master.GetBody().transform.rotation);
                    master.teamIndex = TeamIndex.Player;

                    master.GiveMoney(owner.money);
                    master.inventory.CopyItemsFrom(owner.inventory);
                    master.inventory.GiveItem(ItemIndex.DrizzlePlayerHelper, 1);

                    // Allow the bots to spawn in the next stage
                    master.destroyOnBodyDeath = false;
                    master.gameObject.AddComponent <SetDontDestroyOnLoad>();
                }
                if (aiOwnership)
                {
                    aiOwnership.ownerMaster = owner;
                }
                if (ai)
                {
                    ai.name = "PlayerBot";
                    ai.leader.gameObject = owner.GetBody().gameObject;

                    ai.fullVision        = true;
                    ai.aimVectorDampTime = .01f;
                    ai.aimVectorMaxSpeed = 180f;
                }

                InjectSkillDrivers(gameObject, ai, survivorIndex);

                if (AutoPurchaseItems.Value)
                {
                    // Add item manager
                    ItemManager itemManager = gameObject.AddComponent <ItemManager>() as ItemManager;
                }

                // Add to playerbot list
                playerbots.Add(gameObject);
            }
        }
Пример #9
0
        private static void SpawnPlayerbotAsPlayer(CharacterMaster owner, SurvivorIndex survivorIndex)
        {
            SurvivorDef def = SurvivorCatalog.GetSurvivorDef(survivorIndex);

            if (def == null)
            {
                return;
            }

            GameObject bodyPrefab = def.bodyPrefab;

            if (bodyPrefab == null)
            {
                return;
            }

            // Card
            PlayerBotSpawnCard card = ScriptableObject.CreateInstance <PlayerBotSpawnCard>();

            card.hullSize        = HullClassification.Human;
            card.nodeGraphType   = MapNodeGroup.GraphType.Ground;
            card.occupyPosition  = false;
            card.sendOverNetwork = true;
            card.forbiddenFlags  = NodeFlags.NoCharacterSpawn;
            card.prefab          = Resources.Load <GameObject>("prefabs/charactermasters/CommandoMaster");
            card.playerbotName   = bodyPrefab.GetComponent <CharacterBody>().GetDisplayName();
            card.bodyPrefab      = bodyPrefab;

            // Spawn
            DirectorSpawnRequest spawnRequest = new DirectorSpawnRequest(card, new DirectorPlacementRule
            {
                placementMode = DirectorPlacementRule.PlacementMode.Approximate,
                minDistance   = 3f,
                maxDistance   = 40f,
                spawnOnTarget = owner.GetBody().transform
            }, RoR2Application.rng);

            spawnRequest.ignoreTeamMemberLimit = true;
            //spawnRequest.summonerBodyObject = owner.GetBody().gameObject;
            spawnRequest.teamIndexOverride = new TeamIndex?(TeamIndex.Player);

            GameObject gameObject = DirectorCore.instance.TrySpawnObject(spawnRequest);

            if (gameObject)
            {
                // Add components
                EntityStateMachine stateMachine = gameObject.AddComponent <PlayerBotStateMachine>() as EntityStateMachine;
                BaseAI             ai           = gameObject.AddComponent <PlayerBotBaseAI>() as BaseAI;
                AIOwnership        aiOwnership  = gameObject.AddComponent <AIOwnership>() as AIOwnership;
                aiOwnership.ownerMaster = owner;

                CharacterMaster master = gameObject.GetComponent <CharacterMaster>();
                PlayerCharacterMasterController playerMaster = gameObject.GetComponent <PlayerCharacterMasterController>();

                // Random skin
                SetRandomSkin(master, bodyPrefab);

                // Set commponent values
                master.SetFieldValue("aiComponents", gameObject.GetComponents <BaseAI>());
                master.GiveMoney(owner.money);
                master.inventory.CopyItemsFrom(owner.inventory);
                master.inventory.GiveItem(ItemIndex.DrizzlePlayerHelper, 1);
                master.destroyOnBodyDeath = false; // Allow the bots to spawn in the next stage

                playerMaster.name = master.GetBody().GetDisplayName();

                // Add custom skills
                InjectSkillDrivers(gameObject, ai, survivorIndex);

                if (AutoPurchaseItems.Value)
                {
                    // Add item manager
                    ItemManager itemManager = gameObject.AddComponent <ItemManager>() as ItemManager;
                }

                // Add to playerbot list
                playerbots.Add(gameObject);

                // Cleanup
                Destroy(card);
            }
        }
Пример #10
0
        public void Awake()
        {
            var addRule     = typeof(RuleCatalog).GetMethod("AddRule", BindingFlags.Static | BindingFlags.NonPublic, null, new Type[] { typeof(RuleDef) }, null);
            var addCategory = typeof(RuleCatalog).GetMethod("AddCategory", BindingFlags.Static | BindingFlags.NonPublic, null, new Type[] { typeof(string), typeof(Color), typeof(string), typeof(Func <bool>) }, null);

            addCategory.Invoke(null, new object[] { "Ally Editor", new Color(94 / 255, 82 / 255, 30 / 255, byte.MaxValue), "", new Func <bool>(() => false) });

            RuleDef allySpawnType = new RuleDef("FloodWarning.allySpawnType", "Guaranteed");


            RuleChoiceDef myRule = allySpawnType.AddChoice("0", 0, false);

            myRule.spritePath       = "Textures/MiscIcons/texRuleBonusStartingMoney";
            myRule.tooltipNameToken = "Vanilla";
            myRule.tooltipBodyToken = "Allies do not spawn with any extra items";
            RuleChoiceDef myRule2 = allySpawnType.AddChoice("0", 1, false);

            myRule2.spritePath       = "Textures/MiscIcons/texRuleBonusStartingMoney";
            myRule2.tooltipNameToken = "Item Ratio";
            myRule2.tooltipBodyToken = "Allies will gain extra items based on how many their owner has (Ratio editable below)";
            allySpawnType.MakeNewestChoiceDefault();
            RuleChoiceDef myRule3 = allySpawnType.AddChoice("0", 2, false);

            myRule3.spritePath       = "Textures/MiscIcons/texRuleBonusStartingMoney";
            myRule3.tooltipNameToken = "Direct Copy";
            myRule3.tooltipBodyToken = "Allies will have a direct copy of their owner's items, not including equipment";
            RuleChoiceDef myRule4 = allySpawnType.AddChoice("0", 2, false);

            myRule4.spritePath       = "Textures/MiscIcons/texRuleBonusStartingMoney";
            myRule4.tooltipNameToken = "Direct Copy+";
            myRule4.tooltipBodyToken = "Allies will have a direct copy of their owner's items, Including equipment";

            addRule.Invoke(null, new object[] { allySpawnType });

            RuleDef allyItemRatio = new RuleDef("FloodWarning.allyItemRatio", "Guaranteed");

            for (float o = 0; o <= 20; o++)
            {
                float         myNum   = o / 10;
                RuleChoiceDef myRule5 = allyItemRatio.AddChoice("0", myNum, false);
                myRule5.spritePath       = "Textures/MiscIcons/texRuleBonusStartingMoney";
                myRule5.tooltipNameToken = "" + myNum * 10 + " to 10";
                myRule5.tooltipBodyToken = "Allies will spawn with " + myNum + "x the items their owner has";
                if (myNum == 0.4f)
                {
                    allyItemRatio.MakeNewestChoiceDefault();
                }
            }
            addRule.Invoke(null, new object[] { allyItemRatio });

            On.RoR2.SummonMasterBehavior.OpenSummon += (orig, self, activator) =>
            {
                GameObject      gameObject = UnityEngine.Object.Instantiate <GameObject>(self.masterPrefab, self.transform.position, self.transform.rotation);
                CharacterBody   component  = activator.GetComponent <CharacterBody>();
                CharacterMaster master     = component.master;
                CharacterMaster component2 = gameObject.GetComponent <CharacterMaster>();
                component2.teamIndex = TeamComponent.GetObjectTeam(component.gameObject);
                Inventory component3 = gameObject.GetComponent <Inventory>();
                giveItems(component3, master.inventory, (int)(Run.instance.ruleBook.GetRuleChoice(RuleCatalog.FindRuleDef("FloodWarning.allySpawnType")).extraData));
                NetworkServer.Spawn(gameObject);
                component2.SpawnBody(component2.bodyPrefab, self.transform.position + Vector3.up * 0.8f, self.transform.rotation);
                AIOwnership component4 = gameObject.GetComponent <AIOwnership>();
                if (component4 && component && master)
                {
                    component4.ownerMaster = master;
                }
                BaseAI component5 = gameObject.GetComponent <BaseAI>();
                if (component5)
                {
                    component5.leader.gameObject = activator.gameObject;
                }
                UnityEngine.Object.Destroy(self.gameObject);
            };

            On.RoR2.EquipmentSlot.SummonMaster += (orig, self, masterObjectPrefab, position) =>
            {
                GameObject      gameObject = UnityEngine.Object.Instantiate <GameObject>(masterObjectPrefab, position, self.transform.rotation);
                CharacterBody   component  = self.GetComponent <CharacterBody>();
                CharacterMaster master     = component.master;
                CharacterMaster component2 = gameObject.GetComponent <CharacterMaster>();
                component2.teamIndex = TeamComponent.GetObjectTeam(component.gameObject);
                Inventory component3 = gameObject.GetComponent <Inventory>();
                giveItems(component3, master.inventory, (int)(Run.instance.ruleBook.GetRuleChoice(RuleCatalog.FindRuleDef("FloodWarning.allySpawnType")).extraData));
                NetworkServer.Spawn(gameObject);
                component2.SpawnBody(component2.bodyPrefab, position, self.transform.rotation);
                AIOwnership component4 = gameObject.GetComponent <AIOwnership>();
                if (component4 && component && master)
                {
                    component4.ownerMaster = master;
                }
                BaseAI component5 = gameObject.GetComponent <BaseAI>();
                if (component5)
                {
                    component5.leader.gameObject = self.gameObject;
                }
                return(component2);
            };

            //    On.RoR2.CharacterBody.UpdateBeetleGuardAllies += (orig, self) =>
            //    {
            //        if (NetworkServer.active)
            //        {
            //            int num = self.inventory ? self.inventory.GetItemCount(ItemIndex.BeetleGland) : 0;
            //            if (num > 0 && self.master.GetDeployableCount(DeployableSlot.BeetleGuardAlly) < num)
            //            {
            //                self.SetFieldValue("guardResummonCooldown", self.GetFieldValue<float>("guardResummonCooldown") - Time.fixedDeltaTime);

            //                if (self.GetFieldValue<float>("guardResummonCooldown") <= 0f)
            //                {
            //                    self.SetFieldValue("guardResummonCooldown", 30f);
            //                    GameObject gameObject = DirectorCore.instance.TrySpawnObject((SpawnCard)Resources.Load("SpawnCards/CharacterSpawnCards/cscBeetleGuardAlly"), new DirectorPlacementRule
            //                    {
            //                        placementMode = DirectorPlacementRule.PlacementMode.Approximate,
            //                        minDistance = 3f,
            //                        maxDistance = 40f,
            //                        spawnOnTarget = self.transform
            //                    }, RoR2Application.rng);
            //                    if (gameObject)
            //                    {
            //                        CharacterMaster component = gameObject.GetComponent<CharacterMaster>();

            //                        Inventory inventory = gameObject.GetComponent<Inventory>();

            //                        inventory.CopyItemsFrom(self.inventory);
            //                        giveItems(inventory, self.inventory, (int)(Run.instance.ruleBook.GetRuleChoice(RuleCatalog.FindRuleDef("FloodWarning.allySpawnType")).extraData));

            //                        AIOwnership component2 = gameObject.GetComponent<AIOwnership>();
            //                        BaseAI component3 = gameObject.GetComponent<BaseAI>();
            //                        if (component)
            //                        {
            //                            component.teamIndex = TeamComponent.GetObjectTeam(self.gameObject);
            //                            component.inventory.GiveItem(ItemIndex.BoostDamage, 30);
            //                            component.inventory.GiveItem(ItemIndex.BoostHp, 10);
            //                            GameObject bodyObject = component.GetBodyObject();
            //                            if (bodyObject)
            //                            {
            //                                Deployable component4 = bodyObject.GetComponent<Deployable>();
            //                                self.master.AddDeployable(component4, DeployableSlot.BeetleGuardAlly);
            //                            }
            //                        }
            //                        if (component2)
            //                        {
            //                            component2.ownerMaster = self.master;
            //                        }
            //                        if (component3)
            //                        {
            //                            component3.leader.gameObject = self.gameObject;
            //                        }
            //                    }
            //                }
            //            }
            //        }

            //    };
        }
Пример #11
0
        public override void OnEnter()
        {
            base.OnEnter();
            Ray aimRay = base.GetAimRay();

            this.duration = this.baseDuration / this.attackSpeedStat;
            if (this.effectPrefab)
            {
                EffectManager.SimpleMuzzleFlash(this.effectPrefab, base.gameObject, muzzleLeft, false);
                EffectManager.SimpleMuzzleFlash(this.effectPrefab, base.gameObject, muzzleRight, false);
            }
            base.PlayAnimation("Gesture", "FireCannons", "FireCannons.playbackRate", this.duration);
            if (base.isAuthority && base.modelLocator && base.modelLocator.modelTransform)
            {
                if (base.modelLocator.modelTransform.GetComponent <ChildLocator>())
                {
                    ChildLocator childLocator = base.modelLocator.modelTransform.GetComponent <ChildLocator>();
                    //literally compiler names but who will look at this code anyways?
                    int       muzzleLeftShildIndex  = childLocator.FindChildIndex(muzzleLeft);
                    int       muzzleRightChildIndex = childLocator.FindChildIndex(muzzleRight);
                    Transform muzzleLeftTransform   = childLocator.FindChild(muzzleLeftShildIndex);
                    Transform muzzleRightTransform  = childLocator.FindChild(muzzleRightChildIndex);
                    if (muzzleLeftTransform)
                    {
                        CharacterMaster characterMaster;
                        characterMaster = new MasterSummon
                        {
                            masterPrefab          = MasterCatalog.FindMasterPrefab("WispMaster"),
                            position              = muzzleLeftTransform.position,
                            rotation              = muzzleLeftTransform.rotation,
                            summonerBodyObject    = null,
                            ignoreTeamMemberLimit = true,
                            teamIndexOverride     = TeamIndex.Monster
                        }.Perform();


                        AIOwnership component4 = characterMaster.gameObject.GetComponent <AIOwnership>();
                        BaseAI      component5 = characterMaster.gameObject.GetComponent <BaseAI>();

                        if (component4 && characterBody.master)
                        {
                            component4.ownerMaster = base.characterBody.master;
                        }
                        if (component5 && characterBody.master.gameObject)
                        {
                            component5.leader.gameObject = base.characterBody.master.gameObject;
                            component5.isHealer          = false;
                            component5.fullVision        = true;
                        }
                    }
                    if (muzzleRightTransform)
                    {
                        CharacterMaster characterMaster;
                        characterMaster = new MasterSummon
                        {
                            masterPrefab          = MasterCatalog.FindMasterPrefab("WispMaster"),
                            position              = muzzleRightTransform.position,
                            rotation              = muzzleRightTransform.rotation,
                            summonerBodyObject    = null,
                            ignoreTeamMemberLimit = true,
                            teamIndexOverride     = TeamIndex.Monster
                        }.Perform();


                        AIOwnership component4 = characterMaster.gameObject.GetComponent <AIOwnership>();
                        BaseAI      component5 = characterMaster.gameObject.GetComponent <BaseAI>();

                        if (component4 && characterBody.master)
                        {
                            component4.ownerMaster = base.characterBody.master;
                        }
                        if (component5 && characterBody.master.gameObject)
                        {
                            component5.leader.gameObject = base.characterBody.master.gameObject;
                            component5.isHealer          = false;
                            component5.fullVision        = true;
                        }
                    }
                }
            }
        }
Пример #12
0
        private static void SpawnPlayerbotAsSummon(CharacterMaster owner, SurvivorIndex survivorIndex)
        {
            SurvivorDef def = SurvivorCatalog.GetSurvivorDef(survivorIndex);

            if (def == null)
            {
                return;
            }

            GameObject bodyPrefab = def.bodyPrefab;

            if (bodyPrefab == null)
            {
                return;
            }

            // Card
            PlayerBotSpawnCard card = ScriptableObject.CreateInstance <PlayerBotSpawnCard>();

            card.hullSize        = HullClassification.Human;
            card.nodeGraphType   = MapNodeGroup.GraphType.Ground;
            card.occupyPosition  = false;
            card.sendOverNetwork = true;
            card.forbiddenFlags  = NodeFlags.NoCharacterSpawn;
            card.prefab          = Resources.Load <GameObject>("prefabs/charactermasters/CommandoMonsterMaster");
            card.playerbotName   = bodyPrefab.GetComponent <CharacterBody>().GetDisplayName();
            card.bodyPrefab      = bodyPrefab;

            // Spawn request
            DirectorSpawnRequest spawnRequest = new DirectorSpawnRequest(card, new DirectorPlacementRule
            {
                placementMode = DirectorPlacementRule.PlacementMode.Approximate,
                minDistance   = 3f,
                maxDistance   = 40f,
                spawnOnTarget = owner.GetBody().transform
            }, RoR2Application.rng);

            spawnRequest.ignoreTeamMemberLimit = true;
            spawnRequest.teamIndexOverride     = new TeamIndex?(TeamIndex.Player);
            //spawnRequest.summonerBodyObject = owner.GetBody().gameObject;

            // Spawn
            GameObject gameObject = DirectorCore.instance.TrySpawnObject(spawnRequest);

            if (gameObject)
            {
                CharacterMaster master      = gameObject.GetComponent <CharacterMaster>();
                BaseAI          ai          = gameObject.GetComponent <BaseAI>();
                AIOwnership     aiOwnership = gameObject.AddComponent <AIOwnership>() as AIOwnership;
                aiOwnership.ownerMaster = owner;

                if (master)
                {
                    master.name = "PlayerBot";
                    SetRandomSkin(master, bodyPrefab);

                    master.teamIndex = TeamIndex.Player;

                    GiveStartingItems(owner, master);

                    // Allow the bots to spawn in the next stage
                    master.destroyOnBodyDeath = false;
                    master.gameObject.AddComponent <SetDontDestroyOnLoad>();
                }
                if (ai)
                {
                    ai.name = "PlayerBot";
                    ai.leader.gameObject = owner.GetBody().gameObject;

                    ai.neverRetaliateFriendlies = true;
                    ai.fullVision        = true;
                    ai.aimVectorDampTime = .01f;
                    ai.aimVectorMaxSpeed = 180f;
                }

                InjectSkillDrivers(gameObject, ai, survivorIndex);

                if (AutoPurchaseItems.Value)
                {
                    // Add item manager
                    ItemManager itemManager = gameObject.AddComponent <ItemManager>() as ItemManager;
                }

                // Add to playerbot list
                playerbots.Add(gameObject);
            }
        }
Пример #13
0
        private static GameObject CreateDecoyMaster()
        {
            GameObject master = PrefabsCore.CreatePrefab("SniperDecoyMaster", true);

            NetworkIdentity netId = master.AddOrGetComponent <NetworkIdentity>();

            CharacterMaster charMaster = master.AddOrGetComponent <CharacterMaster>();

            charMaster.masterIndex        = new MasterCatalog.MasterIndex(-1);
            charMaster.bodyPrefab         = GetDecoyPrefab();
            charMaster.spawnOnStart       = false;
            charMaster.teamIndex          = TeamIndex.Player;
            charMaster.destroyOnBodyDeath = true;
            charMaster.isBoss             = false;
            charMaster.preventGameOver    = true;


            _ = master.AddOrGetComponent <Inventory>();


            BaseAI ai = master.AddOrGetComponent <BaseAI>();

            ai.fullVision = true;
            ai.neverRetaliateFriendlies = true;
            //ai.minDistanceFromEnemy = 0;
            ai.enemyAttentionDuration = 0;
            //ai.navigationType = BaseAI.NavigationType.Nodegraph;
            ai.desiredSpawnNodeGraphType = RoR2.Navigation.MapNodeGroup.GraphType.Ground;
            EntityStateMachine esm = ai.stateMachine = master.AddOrGetComponent <EntityStateMachine>();

            ai.isHealer          = false;
            ai.enemyAttention    = 0f;
            ai.aimVectorDampTime = 0f;
            ai.aimVectorMaxSpeed = 0f;
            //ai.desiredAimDirection = Vector3.up;
            //ai.drawAIPath = false;
            ai.selectedSkilldriverName = null;
            ai.debugEnemyHurtBox       = null;
            ai.currentEnemy            = null;
            ai.leader       = null;
            ai.customTarget = null;

            esm.customName       = "AI";
            esm.initialStateType = SkillsCore.StateType <BlankAI>();
            esm.mainStateType    = SkillsCore.StateType <BlankAI>();

            AISkillDriver driver = master.AddOrGetComponent <AISkillDriver>();

            driver.customName                        = "Sit there and look pretty";
            driver.skillSlot                         = SkillSlot.None;
            driver.requiredSkill                     = null;
            driver.requireSkillReady                 = false;
            driver.requireEquipmentReady             = false;
            driver.moveTargetType                    = AISkillDriver.TargetType.CurrentEnemy;
            driver.minUserHealthFraction             = Single.NegativeInfinity;
            driver.maxUserHealthFraction             = Single.PositiveInfinity;
            driver.minTargetHealthFraction           = Single.NegativeInfinity;
            driver.maxTargetHealthFraction           = Single.PositiveInfinity;
            driver.minDistance                       = Single.NegativeInfinity;
            driver.maxDistance                       = Single.PositiveInfinity;
            driver.selectionRequiresTargetLoS        = false;
            driver.activationRequiresTargetLoS       = false;
            driver.activationRequiresAimConfirmation = false;
            driver.movementType                      = AISkillDriver.MovementType.Stop;
            driver.moveInputScale                    = 0f;
            driver.aimType                   = AISkillDriver.AimType.None;
            driver.ignoreNodeGraph           = true;
            driver.driverUpdateTimerOverride = 1f;
            driver.resetCurrentEnemyOnNextDriverSelection = false;
            driver.noRepeat            = false;
            driver.shouldSprint        = true;
            driver.shouldFireEquipment = false;
            driver.shouldTapButton     = false;


            _ = master.AddOrGetComponent <MinionOwnership>();


            AIOwnership aiOwnership = master.AddOrGetComponent <AIOwnership>();

            aiOwnership.ownerMaster = null;


            foreach (IRuntimePrefabComponent comp in master.GetComponents <IRuntimePrefabComponent>())
            {
                comp.InitializePrefab();
            }


            MastersCore.Add(master);

            return(master);
        }
Пример #14
0
        private static void SpawnPlayerbotAsPlayer(CharacterMaster owner, SurvivorIndex survivorIndex)
        {
            SurvivorDef def = SurvivorCatalog.GetSurvivorDef(survivorIndex);

            if (def == null)
            {
                return;
            }
            else if (!def.CheckRequiredExpansionEnabled())
            {
                Debug.Log("You do not have the proper expansion enabled.");
                return;
            }

            GameObject bodyPrefab = def.bodyPrefab;

            if (bodyPrefab == null)
            {
                return;
            }

            // Card
            PlayerBotSpawnCard card = ScriptableObject.CreateInstance <PlayerBotSpawnCard>();

            card.hullSize        = HullClassification.Human;
            card.nodeGraphType   = MapNodeGroup.GraphType.Ground;
            card.occupyPosition  = false;
            card.sendOverNetwork = true;
            card.forbiddenFlags  = NodeFlags.NoCharacterSpawn;
            card.prefab          = LegacyResourcesAPI.Load <GameObject>("Prefabs/CharacterMasters/CommandoMaster");
            //card.bodyPrefab = bodyPrefab;

            // Spawn
            DirectorSpawnRequest spawnRequest = new DirectorSpawnRequest(card, new DirectorPlacementRule
            {
                placementMode = DirectorPlacementRule.PlacementMode.Approximate,
                minDistance   = 3f,
                maxDistance   = 40f,
                spawnOnTarget = owner.GetBody().transform
            }, RoR2Application.rng);

            spawnRequest.ignoreTeamMemberLimit = true;
            spawnRequest.teamIndexOverride     = new TeamIndex?(TeamIndex.Player);

            spawnRequest.onSpawnedServer = result =>
            {
                GameObject gameObject = result.spawnedInstance;

                if (gameObject)
                {
                    // Add components
                    EntityStateMachine stateMachine = gameObject.AddComponent <PlayerBotStateMachine>() as EntityStateMachine;
                    BaseAI             ai           = gameObject.AddComponent <PlayerBotBaseAI>() as BaseAI;
                    AIOwnership        aiOwnership  = gameObject.AddComponent <AIOwnership>() as AIOwnership;
                    aiOwnership.ownerMaster = owner;

                    CharacterMaster master = gameObject.GetComponent <CharacterMaster>();
                    PlayerCharacterMasterController playerMaster = gameObject.GetComponent <PlayerCharacterMasterController>();
                    playerMaster.name = "PlayerBot";

                    // Required to bypass entitlements
                    master.bodyPrefab = bodyPrefab;
                    master.Respawn(master.transform.position, master.transform.rotation);

                    // Random skin
                    SetRandomSkin(master, bodyPrefab);

                    // Set commponent values
                    master.SetFieldValue("aiComponents", gameObject.GetComponents <BaseAI>());
                    master.destroyOnBodyDeath = false; // Allow the bots to spawn in the next stage

                    // Starting items
                    GiveStartingItems(owner, master);

                    // Add custom skills
                    InjectSkillDrivers(gameObject, ai, survivorIndex);

                    if (AutoPurchaseItems.Value)
                    {
                        // Add item manager
                        ItemManager itemManager = gameObject.AddComponent <ItemManager>() as ItemManager;
                    }

                    // Add to playerbot list
                    playerbots.Add(gameObject);
                }
            };

            DirectorCore.instance.TrySpawnObject(spawnRequest);

            // Cleanup
            Destroy(card);
        }
        // Token: 0x060017BB RID: 6075 RVA: 0x00066F64 File Offset: 0x00065164
        public CharacterMaster Perform()
        {
            TeamIndex teamIndex;

            if (this.teamIndexOverride != null)
            {
                teamIndex = this.teamIndexOverride.Value;
            }
            else
            {
                if (!this.summonerBodyObject)
                {
                    Debug.LogErrorFormat("Cannot spawn master {0}: No team specified.", new object[]
                    {
                        this.masterPrefab
                    });
                    return(null);
                }
                teamIndex = TeamComponent.GetObjectTeam(this.summonerBodyObject);
            }
            if (!this.ignoreTeamMemberLimit)
            {
                TeamDef teamDef = TeamCatalog.GetTeamDef(teamIndex);
                if (teamDef == null)
                {
                    Debug.LogErrorFormat("Attempting to spawn master {0} on TeamIndex.None. Is this intentional?", new object[]
                    {
                        this.masterPrefab
                    });
                    return(null);
                }
                if (teamDef != null && teamDef.softCharacterLimit <= TeamComponent.GetTeamMembers(teamIndex).Count)
                {
                    return(null);
                }
            }
            CharacterBody   characterBody   = null;
            CharacterMaster characterMaster = null;

            if (this.summonerBodyObject)
            {
                characterBody = this.summonerBodyObject.GetComponent <CharacterBody>();
            }
            if (characterBody)
            {
                characterMaster = characterBody.master;
            }
            GameObject      gameObject = UnityEngine.Object.Instantiate <GameObject>(this.masterPrefab, this.position, this.rotation);
            CharacterMaster component  = gameObject.GetComponent <CharacterMaster>();

            component.teamIndex = teamIndex;
            if (this.loadout != null)
            {
                component.SetLoadoutServer(this.loadout);
            }
            CharacterMaster characterMaster2 = characterMaster;

            if (characterMaster2 && characterMaster2.minionOwnership.ownerMaster)
            {
                characterMaster2 = characterMaster2.minionOwnership.ownerMaster;
            }
            component.minionOwnership.SetOwner(characterMaster2);
            if (this.summonerBodyObject)
            {
                AIOwnership component2 = gameObject.GetComponent <AIOwnership>();
                if (component2)
                {
                    if (characterMaster)
                    {
                        component2.ownerMaster = characterMaster;
                    }
                    CharacterBody component3 = this.summonerBodyObject.GetComponent <CharacterBody>();
                    if (component3)
                    {
                        CharacterMaster master = component3.master;
                        if (master)
                        {
                            component2.ownerMaster = master;
                        }
                    }
                }
                BaseAI component4 = gameObject.GetComponent <BaseAI>();
                if (component4)
                {
                    component4.leader.gameObject = this.summonerBodyObject;
                }
            }
            Action <CharacterMaster> action = this.preSpawnSetupCallback;

            if (action != null)
            {
                action(component);
            }
            NetworkServer.Spawn(gameObject);
            component.Respawn(this.position, this.rotation, false);
            return(component);
        }