Esempio n. 1
0
 // try and setup our character, if we hit an error we set it to false
 //TODO: Find a way to stop it from checking whilst in main menu/lobby menu
 private static void GetCharacter()
 {
     try
     {
         LocalNetworkUser = null;
         foreach (NetworkUser readOnlyInstance in NetworkUser.readOnlyInstancesList)
         {
             //localplayer == you!
             if (readOnlyInstance.isLocalPlayer)
             {
                 LocalNetworkUser = readOnlyInstance;
                 LocalPlayer      = LocalNetworkUser.master;
                 LocalPlayerInv   = LocalPlayer.GetComponent <Inventory>();
                 LocalHealth      = LocalPlayer.GetBody().GetComponent <HealthComponent>();
                 LocalSkills      = LocalPlayer.GetBody().GetComponent <SkillLocator>();
                 if (LocalHealth.alive)
                 {
                     _CharacterCollected = true;
                 }
                 else
                 {
                     _CharacterCollected = false;
                 }
             }
         }
     }
     catch (Exception e)
     {
         _CharacterCollected = false;
     }
 }
Esempio n. 2
0
 private void PoisonEliteChanges(On.RoR2.GlobalEventManager.orig_OnHitEnemy orig, RoR2.GlobalEventManager self, RoR2.DamageInfo damageInfo, GameObject victim)
 {
     if (damageInfo.attacker)
     {
         RoR2.CharacterBody component     = damageInfo.attacker.GetComponent <RoR2.CharacterBody>();
         RoR2.CharacterBody characterBody = victim ? victim.GetComponent <RoR2.CharacterBody>() : null;
         if (component)
         {
             RoR2.CharacterMaster master = component.master;
             if (master)
             {
                 if ((component.HasBuff(Resources.Load <BuffDef>("buffdefs/AffixPoison")) ? 1 : 0) > 0 && characterBody)
                 {
                     int   itemCount = master.inventory.GetItemCount(AspectsToItems.AspectsToItems.NewDefsList.Find(x => x.name == "AffixPoison").itemIndex);
                     float amount    = damageInfo.damage * (0.05f + 0.05f * itemCount);
                     if (itemCount == 0)
                     {
                         amount = damageInfo.damage * .1f;
                     }
                     component.healthComponent.Heal(amount, damageInfo.procChainMask, true);
                 }
             }
         }
     }
     orig(self, damageInfo, victim);
 }
Esempio n. 3
0
        private void addItems(ItemTier item, int amount, RoR2.CharacterMaster localUser, System.Random rnd, int min, int max)
        {
            int amountOfItems;

            if (min > max)
            {
                max = min;
            }

            if (min <= 0)
            {
                amountOfItems = rnd.Next(1, max + 1);
            }
            else
            {
                amountOfItems = rnd.Next(min, max + 1);
            }

            int       itemsToGive = amount / amountOfItems;
            int       remainder   = amount % amountOfItems;
            ItemIndex itemRolled;

            itemRolled = this.getRandomItem(item, localUser, rnd);
            localUser.inventory.GiveItem(itemRolled, itemsToGive + remainder);

            for (int i = 0; i < amountOfItems - 1; i++)
            {
                itemRolled = this.getRandomItem(item, localUser, rnd);
                localUser.inventory.GiveItem(itemRolled, itemsToGive);
            }
        }
 public RoR2.CharacterMaster GetCurrentPlayer()
 {
     if (this.currentPlayer == null)
     {
         this.currentPlayer = RoR2.PlayerCharacterMasterController.instances[0].master;
     }
     return(this.currentPlayer);
 }
        IEnumerator ShowItemPickerCoroutine(float waitForSeconds)
        {
            if (waitForSeconds > 0)
            {
                yield return(new WaitForSeconds(waitForSeconds));
            }

            RoR2.CharacterMaster master = GetCurrentPlayer();
            ShowItemPicker(GetAvailablePickups(), GetCurrentPlayer());
        }
Esempio n. 6
0
 private void IceEliteChanges(On.RoR2.HealthComponent.orig_TakeDamage orig, RoR2.HealthComponent self, RoR2.DamageInfo damageInfo)
 {
     RoR2.CharacterBody characterBody = null;
     if (damageInfo.attacker)
     {
         characterBody = damageInfo.attacker.GetComponent <RoR2.CharacterBody>();
     }
     if (damageInfo.damage > 0)
     {
         if (characterBody)
         {
             RoR2.CharacterMaster master = characterBody.master;
             if (master && master.inventory)
             {
                 if (damageInfo.procCoefficient > 0f)
                 {
                     if (characterBody.GetBuffCount(Resources.Load <BuffDef>("buffdefs/AffixWhite")) > 0)
                     {
                         self.body.AddTimedBuff(FreezingBlood.buffIndex, 2f * damageInfo.procCoefficient);
                         if (self.body.GetBuffCount(FreezingBlood.buffIndex) >= 10)
                         {
                             self.body.ClearTimedBuffs(FreezingBlood.buffIndex);
                             RoR2.CharacterBody component     = damageInfo.attacker.GetComponent <RoR2.CharacterBody>();
                             RoR2.ProcChainMask procChainMask = damageInfo.procChainMask;
                             int     AffixWhiteStack          = master.inventory.GetItemCount(AspectsToItems.AspectsToItems.NewDefsList.Find(x => x.name == "AffixWhite").itemIndex);
                             Vector3 position          = damageInfo.position;
                             float   damageCoefficient = 10f + 10f * AffixWhiteStack;
                             if (AffixWhiteStack == 0)
                             {
                                 damageCoefficient = 20f;
                             }
                             float           damage2     = RoR2.Util.OnHitProcDamage(component.damage, component.damage, damageCoefficient);
                             RoR2.DamageInfo damageInfo2 = new RoR2.DamageInfo
                             {
                                 damage           = damage2,
                                 damageColorIndex = DamageColorIndex.Item,
                                 damageType       = DamageType.Generic,
                                 attacker         = damageInfo.attacker,
                                 crit             = damageInfo.crit,
                                 force            = Vector3.zero,
                                 inflictor        = null,
                                 position         = position,
                                 procChainMask    = procChainMask,
                                 procCoefficient  = 1f
                             };
                             RoR2.EffectManager.SimpleImpactEffect(Resources.Load <GameObject>("Prefabs/Effects/ImpactEffects/IceCullExplosion"), position, Vector3.up, true);
                             self.TakeDamage(damageInfo2);
                         }
                     }
                 }
             }
         }
     }
     orig(self, damageInfo);
 }
Esempio n. 7
0
 // Token: 0x060015B7 RID: 5559 RVA: 0x0005C7B4 File Offset: 0x0005A9B4
 public unsafe override void OnServerBossAdded(BossGroup bossGroup, CharacterMaster characterMaster)
 {
     base.OnServerBossAdded(bossGroup, characterMaster);
     if (this.stageClearCount >= 1)
     {
         if (characterMaster.inventory.GetEquipmentIndex() == EquipmentIndex.None)
         {
             characterMaster.inventory.SetEquipmentIndex(*this.bossAffixRng.NextElementUniform <EquipmentIndex>(WeeklyRun.affixes));
         }
         characterMaster.inventory.GiveItem(ItemIndex.BoostHp, 5);
         characterMaster.inventory.GiveItem(ItemIndex.BoostDamage, 1);
     }
 }
        // Token: 0x0600069A RID: 1690 RVA: 0x0001AFE4 File Offset: 0x000191E4
        private void RememberBoss(CharacterMaster master)
        {
            if (!master)
            {
                return;
            }
            int num = this.FindBossMemoryIndex(master.netId);

            if (num == -1)
            {
                num = this.AddBossMemory(master);
            }
            ref BossGroup.BossMemory ptr = ref this.bossMemories[num];
Esempio n. 9
0
 // Token: 0x0600177F RID: 6015 RVA: 0x0006F4C0 File Offset: 0x0006D6C0
 public override void OnServerBossAdded(BossGroup bossGroup, CharacterMaster characterMaster)
 {
     base.OnServerBossAdded(bossGroup, characterMaster);
     if (this.stageClearCount >= 1)
     {
         if (characterMaster.inventory.GetEquipmentIndex() == EquipmentIndex.None)
         {
             characterMaster.inventory.SetEquipmentIndex(WeeklyRun.affixes[this.bossAffixRng.RangeInt(0, WeeklyRun.affixes.Length)]);
         }
         characterMaster.inventory.GiveItem(ItemIndex.BoostHp, 5);
         characterMaster.inventory.GiveItem(ItemIndex.BoostDamage, 1);
     }
 }
Esempio n. 10
0
 // Token: 0x06001B1E RID: 6942 RVA: 0x0007F2FC File Offset: 0x0007D4FC
 private void SetCurrentMaster(CharacterMaster newMaster)
 {
     if (this.currentMaster != null)
     {
         this.currentMaster.onBodyDeath.RemoveListener(new UnityAction(this.OnBodyDeath));
         this.currentMaster.onBodyStart -= this.OnBodyStart;
     }
     this.currentMaster = newMaster;
     if (this.currentMaster != null)
     {
         this.currentMaster.onBodyDeath.AddListener(new UnityAction(this.OnBodyDeath));
         this.currentMaster.onBodyStart += this.OnBodyStart;
     }
 }
Esempio n. 11
0
        // Token: 0x06000522 RID: 1314 RVA: 0x00014908 File Offset: 0x00012B08
        public DamageReport(DamageInfo damageInfo, HealthComponent victim, float damageDealt)
        {
            this.damageInfo = damageInfo;
            this.victim     = victim;
            this.victimBody = (victim ? victim.body : null);
            CharacterBody characterBody = this.victimBody;

            this.victimBodyIndex = ((characterBody != null) ? characterBody.bodyIndex : -1);
            CharacterBody characterBody2 = this.victimBody;

            this.victimTeamIndex = ((characterBody2 != null) ? characterBody2.teamComponent.teamIndex : TeamIndex.None);
            CharacterBody characterBody3 = this.victimBody;

            this.victimMaster = ((characterBody3 != null) ? characterBody3.master : null);
            CharacterBody characterBody4 = this.victimBody;

            this.victimIsElite = (characterBody4 != null && characterBody4.isElite);
            CharacterBody characterBody5 = this.victimBody;

            this.victimIsBoss = (characterBody5 != null && characterBody5.isBoss);
            this.attacker     = damageInfo.attacker;
            this.attackerBody = (this.attacker ? this.attacker.GetComponent <CharacterBody>() : null);
            CharacterBody characterBody6 = this.attackerBody;

            this.attackerBodyIndex = ((characterBody6 != null) ? characterBody6.bodyIndex : -1);
            CharacterBody characterBody7 = this.attackerBody;

            this.attackerTeamIndex = ((characterBody7 != null) ? characterBody7.teamComponent.teamIndex : TeamIndex.None);
            CharacterBody characterBody8 = this.attackerBody;

            this.attackerMaster = ((characterBody8 != null) ? characterBody8.master : null);
            CharacterMaster characterMaster = this.attackerMaster;

            this.attackerOwnerMaster = ((characterMaster != null) ? characterMaster.minionOwnership.ownerMaster : null);
            CharacterMaster characterMaster2 = this.attackerOwnerMaster;
            int?            num;

            if (characterMaster2 == null)
            {
                num = null;
            }
            else
            {
                CharacterBody body = characterMaster2.GetBody();
                num = ((body != null) ? new int?(body.bodyIndex) : null);
            }
            this.attackerOwnerBodyIndex = (num ?? -1);
            this.dotType     = damageInfo.dotIndex;
            this.damageDealt = damageDealt;
        }
        // Token: 0x06000691 RID: 1681 RVA: 0x0001AD08 File Offset: 0x00018F08
        private void OnMemberDeathServer(CharacterMaster memberMaster, DamageReport damageReport)
        {
            GameObject   bodyObject   = memberMaster.GetBodyObject();
            DeathRewards deathRewards = (bodyObject != null) ? bodyObject.GetComponent <DeathRewards>() : null;

            if (deathRewards)
            {
                PickupIndex pickupIndex = (PickupIndex)deathRewards.bossPickup;
                if (pickupIndex != PickupIndex.none)
                {
                    this.bossDrops.Add(pickupIndex);
                }
            }
        }
Esempio n. 13
0
        private void RemoveMember(CharacterMaster memberMaster)
        {
            if (!NetworkServer.active)
            {
                Debug.LogWarning("[Server] function 'System.Void RoR2.BossGroup::RemoveMember(RoR2.CharacterMaster)' called on client");
                return;
            }
            int num = this.membersList.IndexOf(memberMaster);

            if (num != -1)
            {
                this.RemoveMemberAt(num);
            }
        }
        // Token: 0x06000F4E RID: 3918 RVA: 0x0004B9AC File Offset: 0x00049BAC
        private void Start()
        {
            this.childLocator = base.GetComponent <ChildLocator>();
            this.body         = base.GetComponent <CharacterModel>().body;
            CharacterMaster master = this.body.master;

            this.bodyInventory = ((master != null) ? master.inventory : null);
            this.animator      = base.GetComponent <Animator>();
            if (this.enableFootstepDust)
            {
                this.footstepDustInstanceTransform      = UnityEngine.Object.Instantiate <GameObject>(this.footstepDustPrefab, base.transform).transform;
                this.footstepDustInstanceParticleSystem = this.footstepDustInstanceTransform.GetComponent <ParticleSystem>();
                this.footstepDustInstanceShakeEmitter   = this.footstepDustInstanceTransform.GetComponent <ShakeEmitter>();
            }
        }
Esempio n. 15
0
 // Token: 0x06000E2B RID: 3627 RVA: 0x00045C7C File Offset: 0x00043E7C
 private void FixedUpdate()
 {
     this.burstTimer -= Time.fixedDeltaTime;
     if (this.burstTimer <= 0f)
     {
         bool flag = false;
         ReadOnlyCollection <PlayerCharacterMasterController> instances = PlayerCharacterMasterController.instances;
         for (int i = 0; i < instances.Count; i++)
         {
             GameObject      gameObject = instances[i].gameObject;
             CharacterMaster component  = gameObject.GetComponent <CharacterMaster>();
             uint            num;
             if (!this.burstSizes.TryGetValue(gameObject, out num))
             {
                 num = (uint)Mathf.CeilToInt(component.money / (float)this.burstCount);
                 this.burstSizes[gameObject] = num;
             }
             if (num > component.money)
             {
                 num = component.money;
             }
             component.money -= num;
             GameObject bodyObject = component.GetBodyObject();
             ulong      num2       = (ulong)(num / 2f / (float)instances.Count);
             if (num > 0u)
             {
                 flag = true;
             }
             if (bodyObject)
             {
                 ExperienceManager.instance.AwardExperience(base.transform.position, bodyObject.GetComponent <CharacterBody>(), num2);
             }
             else
             {
                 TeamManager.instance.GiveTeamExperience(component.teamIndex, num2);
             }
         }
         if (flag)
         {
             this.burstTimer = this.burstInterval;
             return;
         }
         if (this.burstTimer < -2.5f)
         {
             UnityEngine.Object.Destroy(this);
         }
     }
 }
        public void AddShrineStack(Interactor interactor)
        {
            if (!NetworkServer.active)
            {
                Debug.LogWarning("[Server] function 'System.Void RoR2.ShrineCombatBehavior::AddShrineStack(RoR2.Interactor)' called on client");
                return;
            }
            new List <CharacterBody>();
            this.waitingForRefresh = true;
            if (this.combatDirector)
            {
                this.combatDirector.enabled        = true;
                this.combatDirector.monsterCredit += this.monsterCredit;
                this.combatDirector.OverrideCurrentMonsterCard(this.chosenDirectorCard);
                this.combatDirector.monsterSpawnTimer = 0f;
            }
            CharacterMaster component = this.chosenDirectorCard.spawnCard.prefab.GetComponent <CharacterMaster>();

            if (component)
            {
                CharacterBody component2 = component.bodyPrefab.GetComponent <CharacterBody>();
                if (component2)
                {
                    Chat.SendBroadcastChat(new Chat.SubjectFormatChatMessage
                    {
                        subjectAsCharacterBody = interactor.GetComponent <CharacterBody>(),
                        baseToken   = "SHRINE_COMBAT_USE_MESSAGE",
                        paramTokens = new string[]
                        {
                            component2.baseNameToken
                        }
                    });
                }
            }
            EffectManager.SpawnEffect(Resources.Load <GameObject>("Prefabs/Effects/ShrineUseEffect"), new EffectData
            {
                origin   = base.transform.position,
                rotation = Quaternion.identity,
                scale    = 1f,
                color    = this.shrineEffectColor
            }, true);
            this.purchaseCount++;
            this.refreshTimer = 2f;
            if (this.purchaseCount >= this.maxPurchaseCount)
            {
                this.symbolTransform.gameObject.SetActive(false);
            }
        }
Esempio n. 17
0
        private void OnCharacterDeathCallback(DamageReport damageReport)
        {
            if (!NetworkServer.active)
            {
                Debug.LogWarning("[Server] function 'System.Void RoR2.CombatSquad::OnCharacterDeathCallback(RoR2.DamageReport)' called on client");
                return;
            }
            DamageInfo    damageInfo = damageReport.damageInfo;
            CharacterBody component  = damageReport.victim.gameObject.GetComponent <CharacterBody>();

            if (!component)
            {
                return;
            }
            CharacterMaster master = component.master;

            if (!master)
            {
                return;
            }
            GameObject gameObject = master.gameObject;
            int        num        = this.membersList.IndexOf(master);

            if (num >= 0)
            {
                Action <CharacterMaster, DamageReport> action = this.onMemberDeathServer;
                if (action != null)
                {
                    action(master, damageReport);
                }
                this.RemoveMemberAt(num);
                if (!this.defeatedServer && this.membersList.Count == 0)
                {
                    this.defeatedServer = true;
                    Action action2 = this.onDefeatedServer;
                    if (action2 != null)
                    {
                        action2();
                    }
                    UnityEvent unityEvent = this.onDefeatedServerLogicEvent;
                    if (unityEvent == null)
                    {
                        return;
                    }
                    unityEvent.Invoke();
                }
            }
        }
Esempio n. 18
0
        private ItemIndex getRandomItem(ItemTier tier, RoR2.CharacterMaster localUser, System.Random rnd)
        {
            ItemIndex result = ItemIndex.None;

            switch (tier)
            {
            case ItemTier.Tier1:
            {
                List <ItemIndex> tier1ItemList = RoR2.ItemCatalog.tier1ItemList;
                int tierCount = tier1ItemList.Count;
                int rndCount  = rnd.Next(0, tierCount);
                result = tier1ItemList[rndCount];
                Debug.Log(rndCount + " : Tier 1 " + result);
                break;
            }

            case ItemTier.Tier2:
            {
                List <ItemIndex> tier2ItemList = RoR2.ItemCatalog.tier2ItemList;
                int tierCount = tier2ItemList.Count;
                int rndCount  = rnd.Next(0, tierCount);
                result = tier2ItemList[rndCount];
                Debug.Log(rndCount + " : Tier 2 " + result);
                break;
            }

            case ItemTier.Tier3:
            {
                List <ItemIndex> tier3ItemList = RoR2.ItemCatalog.tier3ItemList;
                int tierCount = tier3ItemList.Count;
                int rndCount  = rnd.Next(0, tierCount);
                result = tier3ItemList[rndCount];
                Debug.Log(rndCount + " : Tier 3 " + result);
                break;
            }

            case ItemTier.Lunar:
            {
                List <ItemIndex> lunarItemList = RoR2.ItemCatalog.lunarItemList;
                int tierCount = lunarItemList.Count;
                int rndCount  = rnd.Next(0, tierCount);
                result = lunarItemList[rndCount];
                Debug.Log(rndCount + " : Tier Lunar " + result);
                break;
            }
            }
            return(result);
        }
Esempio n. 19
0
 private void OnEquipmentSpentOnPurchase(PurchaseInteraction purchaseInteraction, Interactor interactor, EquipmentIndex equipmentIndex)
 {
     if (!NetworkServer.active)
     {
         Debug.LogWarning("[Server] function 'System.Void RoR2.SummonMasterBehavior::OnEquipmentSpentOnPurchase(RoR2.PurchaseInteraction,RoR2.Interactor,RoR2.EquipmentIndex)' called on client");
         return;
     }
     if (purchaseInteraction == base.GetComponent <PurchaseInteraction>())
     {
         CharacterMaster characterMaster = this.OpenSummonReturnMaster(interactor);
         if (characterMaster)
         {
             characterMaster.inventory.SetEquipmentIndex(equipmentIndex);
         }
     }
 }
Esempio n. 20
0
 // Token: 0x06001517 RID: 5399 RVA: 0x0005A198 File Offset: 0x00058398
 public virtual void SetFromMaster(CharacterMaster master)
 {
     if (master)
     {
         PlayerCharacterMasterController component = master.GetComponent <PlayerCharacterMasterController>();
         if (component)
         {
             NetworkUser networkUser = component.networkUser;
             this.SetFromSteamId(networkUser.id.value);
             return;
         }
     }
     this.userSteamId = 0UL;
     this.sourceType  = SocialUserIcon.SourceType.None;
     this.Refresh();
 }
Esempio n. 21
0
 public void OnMemberDestroyed(OnDestroyCallback onDestroyCallback)
 {
     if (!NetworkServer.active)
     {
         Debug.LogWarning("[Server] function 'System.Void RoR2.BossGroup::OnMemberDestroyed(RoR2.OnDestroyCallback)' called on client");
         return;
     }
     if (onDestroyCallback)
     {
         GameObject      gameObject      = onDestroyCallback.gameObject;
         CharacterMaster characterMaster = gameObject ? gameObject.GetComponent <CharacterMaster>() : null;
         if (characterMaster)
         {
             this.membersList.Remove(characterMaster);
         }
     }
 }
Esempio n. 22
0
        private System.Collections.IEnumerator GlobalEventManager_CreateLevelUpEffect(On.RoR2.GlobalEventManager.orig_CreateLevelUpEffect orig, RoR2.GlobalEventManager self, float delay, GameObject levelUpEffect, RoR2.EffectData effectData)
        {
            yield return(new WaitForSeconds(delay));

            orig.Invoke(self, delay, levelUpEffect, effectData);

            foreach (RoR2.PlayerCharacterMasterController playerCharacterMasterController in RoR2.PlayerCharacterMasterController.instances)
            {
                bool isClient = playerCharacterMasterController.master.isClient;
                if (isClient)
                {
                    string        displayName = playerCharacterMasterController.GetDisplayName();
                    System.Random rnd         = new System.Random();

                    RoR2.CharacterMaster localUser  = playerCharacterMasterController.master;
                    RoR2.CharacterBody   playerBody = localUser.GetBody();
                    int playerLevel = (int)playerBody.level;

                    if (currentLevel < playerLevel)
                    {
                        ItemTier itemTier1           = ItemTier.Tier1;
                        int      amountOfItemsInTier = this.getAmountOfItemsInTier(itemTier1, playerCharacterMasterController.master);
                        this.removeAllItemsInTier(itemTier1, playerCharacterMasterController.master);
                        this.addItems(itemTier1, amountOfItemsInTier, playerCharacterMasterController.master, rnd, tier1Min.Value, tier1Max.Value);

                        ItemTier itemTier2 = ItemTier.Tier2;
                        amountOfItemsInTier = this.getAmountOfItemsInTier(itemTier2, playerCharacterMasterController.master);
                        this.removeAllItemsInTier(itemTier2, playerCharacterMasterController.master);
                        this.addItems(itemTier2, amountOfItemsInTier, playerCharacterMasterController.master, rnd, tier2Min.Value, tier2Max.Value);

                        ItemTier itemTier3 = ItemTier.Tier3;
                        amountOfItemsInTier = this.getAmountOfItemsInTier(itemTier3, playerCharacterMasterController.master);
                        this.removeAllItemsInTier(itemTier3, playerCharacterMasterController.master);
                        this.addItems(itemTier3, amountOfItemsInTier, playerCharacterMasterController.master, rnd, tier3Min.Value, tier3Max.Value);

                        ItemTier itemTierLunar = ItemTier.Lunar;
                        amountOfItemsInTier = this.getAmountOfItemsInTier(itemTierLunar, playerCharacterMasterController.master);
                        this.removeAllItemsInTier(itemTierLunar, playerCharacterMasterController.master);
                        this.addItems(itemTierLunar, amountOfItemsInTier, playerCharacterMasterController.master, rnd, tierLunarMin.Value, tierLunarMax.Value);
                        currentLevel = playerLevel;
                    }
                }
            }

            yield break;
        }
Esempio n. 23
0
 // Token: 0x060015D5 RID: 5589 RVA: 0x0006897C File Offset: 0x00066B7C
 private void Start()
 {
     this.sceneDef = SceneCatalog.GetSceneDefForCurrentScene();
     if (NetworkServer.active)
     {
         this.NetworkstartRunTime = Run.instance.fixedTime;
         this.stageSpawnPosition  = this.SampleNodeGraphForSpawnPosition();
         ReadOnlyCollection <CharacterMaster> readOnlyInstancesList = CharacterMaster.readOnlyInstancesList;
         Transform playerSpawnTransform = this.GetPlayerSpawnTransform();
         for (int i = 0; i < readOnlyInstancesList.Count; i++)
         {
             CharacterMaster characterMaster = readOnlyInstancesList[i];
             if (characterMaster && !characterMaster.GetComponent <PlayerCharacterMasterController>() && !characterMaster.GetBodyObject() && characterMaster.gameObject.scene.buildIndex == -1)
             {
                 Vector3    vector   = Vector3.zero;
                 Quaternion rotation = Quaternion.identity;
                 if (playerSpawnTransform)
                 {
                     vector   = playerSpawnTransform.position;
                     rotation = playerSpawnTransform.rotation;
                     BaseAI        component  = readOnlyInstancesList[i].GetComponent <BaseAI>();
                     CharacterBody component2 = readOnlyInstancesList[i].bodyPrefab.GetComponent <CharacterBody>();
                     if (component && component2)
                     {
                         NodeGraph nodeGraph = component.GetNodeGraph();
                         if (nodeGraph)
                         {
                             List <NodeGraph.NodeIndex> list = nodeGraph.FindNodesInRange(vector, 10f, 100f, (HullMask)(1 << (int)component2.hullClassification));
                             if ((float)list.Count > 0f)
                             {
                                 nodeGraph.GetNodePosition(list[UnityEngine.Random.Range(0, list.Count)], out vector);
                             }
                         }
                     }
                 }
                 readOnlyInstancesList[i].Respawn(vector, rotation);
             }
         }
         this.BeginServer();
     }
     if (NetworkClient.active)
     {
         this.RespawnLocalPlayers();
     }
 }
        public void ModifySpawnedMasters(GameObject targetGameObject)
        {
            if (!NetworkServer.active)
            {
                Debug.LogWarning("[Server] function 'System.Void RoR2.ArenaMissionController::ModifySpawnedMasters(UnityEngine.GameObject)' called on client");
                return;
            }
            ArenaMissionController.< > c__DisplayClass62_0 CS$ < > 8__locals1 = new ArenaMissionController.< > c__DisplayClass62_0();
            CharacterMaster component = targetGameObject.GetComponent <CharacterMaster>();

            CS$ < > 8__locals1.ai = component.GetComponent <BaseAI>();
            if (CS$ < > 8__locals1.ai)
            {
                CS$ < > 8__locals1.ai.onBodyDiscovered += CS$ < > 8__locals1.< ModifySpawnedMasters > g__OnBodyDiscovered | 0;
            }
            CharacterBody body = component.GetBody();

            if (body)
            {
                foreach (EntityStateMachine entityStateMachine in body.GetComponents <EntityStateMachine>())
                {
                    entityStateMachine.initialStateType = entityStateMachine.mainStateType;
                }
            }
            for (int j = 0; j < this.syncActivePickups.Count; j++)
            {
                int       count     = 0;
                ItemIndex itemIndex = PickupCatalog.GetPickupDef(new PickupIndex(this.syncActivePickups[j])).itemIndex;
                switch (ItemCatalog.GetItemDef(itemIndex).tier)
                {
                case ItemTier.Tier1:
                    count = this.stackCountPerTier1;
                    break;

                case ItemTier.Tier2:
                    count = this.stackCountPerTier2;
                    break;

                case ItemTier.Tier3:
                    count = this.stackCountPerTier3;
                    break;
                }
                component.inventory.GiveItem(itemIndex, count);
            }
        }
Esempio n. 25
0
 private static void Init()
 {
     GlobalEventManager.onCharacterDeathGlobal += delegate(DamageReport damageReport)
     {
         CharacterMaster victimMaster = damageReport.victimMaster;
         if (victimMaster)
         {
             victimMaster.killerBodyIndex = BodyCatalog.FindBodyIndex(damageReport.damageInfo.attacker);
         }
     };
     Stage.onServerStageBegin += delegate(Stage stage)
     {
         foreach (CharacterMaster characterMaster in CharacterMaster.instancesList)
         {
             characterMaster.preventRespawnUntilNextStageServer = false;
         }
     };
 }
Esempio n. 26
0
        // Token: 0x06000955 RID: 2389 RVA: 0x00028B38 File Offset: 0x00026D38
        private void RemoveMemberAt(int memberIndex)
        {
            CharacterMaster obj = this.membersList[memberIndex];

            this.membersList.RemoveAt(memberIndex);
            if (this.onDestroyCallbacksServer != null)
            {
                this.onDestroyCallbacksServer.RemoveAt(memberIndex);
            }
            base.SetDirtyBit(1U);
            Action <CharacterMaster> action = this.onMemberLost;

            if (action == null)
            {
                return;
            }
            action(obj);
        }
 // Token: 0x06000ECC RID: 3788 RVA: 0x00048C74 File Offset: 0x00046E74
 private void Start()
 {
     this.projectileStick      = base.GetComponent <ProjectileStickOnImpact>();
     this.projectileController = base.GetComponent <ProjectileController>();
     this.projectileDamage     = base.GetComponent <ProjectileDamage>();
     base.GetComponent <Rigidbody>().AddTorque(UnityEngine.Random.insideUnitSphere * 90f);
     if (NetworkServer.active && this.projectileController.owner)
     {
         CharacterBody component = this.projectileController.owner.GetComponent <CharacterBody>();
         if (component)
         {
             CharacterMaster master = component.master;
             if (master)
             {
                 master.AddDeployable(base.GetComponent <Deployable>(), DeployableSlot.EngiMine);
             }
         }
     }
 }
        private void AddMonsterType()
        {
            if (!NetworkServer.active)
            {
                Debug.LogWarning("[Server] function 'System.Void RoR2.ArenaMissionController::AddMonsterType()' called on client");
                return;
            }
            if (this.availableMonsterCards.Count == 0)
            {
                Debug.Log("Out of monster types! Aborting.");
                return;
            }
            int          num   = this.availableMonsterCards.EvaluteToChoiceIndex(this.rng.nextNormalizedFloat);
            DirectorCard value = this.availableMonsterCards.choices[num].value;

            this.activeMonsterCards.Add(value);
            SyncList <int>  syncList  = this.syncActiveMonsterBodies;
            CharacterMaster component = value.spawnCard.prefab.GetComponent <CharacterMaster>();
            int?            num2;

            if (component == null)
            {
                num2 = null;
            }
            else
            {
                CharacterBody component2 = component.bodyPrefab.GetComponent <CharacterBody>();
                num2 = ((component2 != null) ? new int?(component2.bodyIndex) : null);
            }
            syncList.Add(num2 ?? -1);
            this.availableMonsterCards.RemoveChoice(num);
            CharacterBody component3 = value.spawnCard.prefab.GetComponent <CharacterMaster>().bodyPrefab.GetComponent <CharacterBody>();

            Chat.SendBroadcastChat(new Chat.SubjectFormatChatMessage
            {
                baseToken   = "ARENA_ADD_MONSTER",
                paramTokens = new string[]
                {
                    component3.baseNameToken
                }
            });
        }
Esempio n. 29
0
        private void GrantLunarCoin(CharacterBody body, uint count)
        {
            if (!NetworkServer.active)
            {
                Debug.LogWarning("[Server] function 'System.Void RoR2.GenericPickupController::GrantLunarCoin(RoR2.CharacterBody,System.UInt32)' called on client");
                return;
            }
            CharacterMaster master      = body.master;
            NetworkUser     networkUser = Util.LookUpBodyNetworkUser(body);

            if (networkUser)
            {
                if (master)
                {
                    GenericPickupController.SendPickupMessage(master, this.pickupIndex);
                }
                networkUser.AwardLunarCoins(count);
                UnityEngine.Object.Destroy(base.gameObject);
            }
        }
 private static void Init()
 {
     GlobalEventManager.onCharacterDeathGlobal += delegate(DamageReport damageReport)
     {
         CharacterMaster characterMaster = damageReport.attackerMaster;
         if (characterMaster)
         {
             if (characterMaster.minionOwnership.ownerMaster)
             {
                 characterMaster = characterMaster.minionOwnership.ownerMaster;
             }
             PlayerCharacterMasterController component = characterMaster.GetComponent <PlayerCharacterMasterController>();
             if (component && Util.CheckRoll(1f * component.lunarCoinChanceMultiplier, 0f, null))
             {
                 PickupDropletController.CreatePickupDroplet(PickupIndex.Find("LunarCoin.Coin0"), damageReport.victim.transform.position, Vector3.up * 10f);
                 component.lunarCoinChanceMultiplier *= 0.5f;
             }
         }
     };
 }