コード例 #1
0
        public void RespawnCharacter(CharacterMaster characterMaster)
        {
            if (!NetworkServer.active)
            {
                Debug.LogWarning("[Server] function 'System.Void RoR2.Stage::RespawnCharacter(RoR2.CharacterMaster)' called on client");
                return;
            }
            if (!characterMaster)
            {
                return;
            }
            Transform  playerSpawnTransform = this.GetPlayerSpawnTransform();
            Vector3    vector     = Vector3.zero;
            Quaternion quaternion = Quaternion.identity;

            if (playerSpawnTransform)
            {
                vector     = playerSpawnTransform.position;
                quaternion = playerSpawnTransform.rotation;
            }
            characterMaster.Respawn(vector, quaternion);
            if (characterMaster.GetComponent <PlayerCharacterMasterController>())
            {
                this.spawnedAnyPlayer = true;
            }
            if (this.usePod)
            {
                Run.instance.HandlePlayerFirstEntryAnimation(characterMaster.GetBody(), vector, quaternion);
            }
        }
コード例 #2
0
        // Token: 0x06001C20 RID: 7200 RVA: 0x00083300 File Offset: 0x00081500
        public static CharacterBody TryToCreateGhost(CharacterBody targetBody, CharacterBody ownerBody, int duration)
        {
            if (!targetBody || !NetworkServer.active)
            {
                return(null);
            }
            if (TeamComponent.GetTeamMembers(ownerBody.teamComponent.teamIndex).Count >= 40)
            {
                return(null);
            }
            int num = BodyCatalog.FindBodyIndex(targetBody.gameObject);

            if (num < 0)
            {
                return(null);
            }
            GameObject bodyPrefab = BodyCatalog.GetBodyPrefab(num);

            if (!bodyPrefab)
            {
                return(null);
            }
            CharacterMaster characterMaster = MasterCatalog.allAiMasters.FirstOrDefault((CharacterMaster master) => master.bodyPrefab == bodyPrefab);

            if (!characterMaster)
            {
                return(null);
            }
            GameObject      gameObject = UnityEngine.Object.Instantiate <GameObject>(characterMaster.gameObject);
            CharacterMaster component  = gameObject.GetComponent <CharacterMaster>();

            component.teamIndex = ownerBody.teamComponent.teamIndex;
            component.GetComponent <BaseAI>().leader.gameObject = ownerBody.gameObject;
            Inventory inventory = targetBody.inventory;

            if (inventory)
            {
                component.inventory.CopyItemsFrom(inventory);
                component.inventory.CopyEquipmentFrom(inventory);
            }
            component.inventory.GiveItem(ItemIndex.Ghost, 1);
            component.inventory.GiveItem(ItemIndex.HealthDecay, duration);
            component.inventory.GiveItem(ItemIndex.BoostDamage, 30);
            NetworkServer.Spawn(gameObject);
            CharacterBody characterBody = component.Respawn(targetBody.footPosition, targetBody.transform.rotation);

            if (characterBody)
            {
                foreach (EntityStateMachine entityStateMachine in characterBody.GetComponents <EntityStateMachine>())
                {
                    entityStateMachine.initialStateType = entityStateMachine.mainStateType;
                }
            }
            return(characterBody);
        }
コード例 #3
0
        // 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);
        }