private void Master_onBodyStart(CharacterBody obj)
        {
            GenericSkill[] skills = obj.GetComponents <GenericSkill>();
            if (skills[skills.Count() - 1].skillDef.skillName == "VT_SCAVSTASHHEALING_MISC")
            {
                obj.inventory.GiveItem(ItemIndex.Tooth, 3);
                obj.inventory.GiveItem(ItemIndex.HealOnCrit, 1);
            }
            if (skills[skills.Count() - 1].skillDef.skillName == "VT_SCAVSTASHMOVEMENT_MISC")
            {
                obj.inventory.GiveItem(ItemIndex.SprintBonus, 3);
                obj.inventory.GiveItem(ItemIndex.SprintOutOfCombat, 1);
            }
            if (skills[skills.Count() - 1].skillDef.skillName == "VT_SCAVSTASHATTACKSPEED_MISC")
            {
                obj.inventory.GiveItem(ItemIndex.Syringe, 3);
                obj.inventory.GiveItem(ItemIndex.EnergizedOnEquipmentUse, 1);
            }
            if (skills[skills.Count() - 1].skillDef.skillName == "VT_SCAVSTASHLUNAR_MISC")
            {
                obj.inventory.GiveItem(ItemIndex.LunarPrimaryReplacement, 2);
                obj.inventory.GiveItem(ItemIndex.LunarTrinket, 1);
                obj.inventory.SetEquipmentIndex(EquipmentIndex.CrippleWard);
            }

            obj.master.onBodyStart -= Master_onBodyStart;
        }
예제 #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
        private void FindStateMachine()
        {
            CharacterBody body = LocalUserManager.GetFirstLocalUser().cachedBody;

            if (body)
            {
                stateMachines             = body.GetComponents <EntityStateMachine>().ToList();
                foundStateMachine         = true;
                RoR2Application.onUpdate -= FindStateMachine;
            }
        }
        private void Awake()
        {
            body     = MotionControls.currentBody;
            animator = GetComponent <Animator>();

            if (!body || !animator)
            {
                enabled = false;
                return;
            }

            bodyStateMachines = body.GetComponents <EntityStateMachine>();
        }
예제 #5
0
 // Checks if the duration value exists.
 private double SprintDelayTime(CharacterBody targetBody) {
     float duration = 0.0f;
     EntityStateMachine[] stateMachines;
     stateMachines = targetBody.GetComponents<EntityStateMachine>();
     foreach (EntityStateMachine machine in stateMachines) {
         var currentState = machine.state;
         if (currentState == null) { return duration; }
         if (stateAnimationDelayList.Contains(currentState.ToString())) {
             try { duration = currentState.GetFieldValue<float>("duration"); } catch { }
             //var stateField = currentState.GetType().GetFieldCached("duration");
             //if (stateField != null) duration = (float)stateField.GetValue(currentState);
             return duration;
         }
     }
     return duration;
 }
        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);
            }
        }
        public void ModifySpawnedMasters(GameObject targetGameObject)
        {
            if (!NetworkServer.active)
            {
                Debug.LogWarning("[Server] function 'System.Void RoR2.ArenaMissionController::ModifySpawnedMasters(UnityEngine.GameObject)' called on client");
                return;
            }
            CharacterMaster component = targetGameObject.GetComponent <CharacterMaster>();
            CharacterBody   body      = component.GetBody();

            if (body)
            {
                foreach (EntityStateMachine entityStateMachine in body.GetComponents <EntityStateMachine>())
                {
                    entityStateMachine.initialStateType = entityStateMachine.mainStateType;
                }
            }
            component.inventory.AddItemsFrom(this.inventory);
        }
예제 #8
0
        // Checks if an EntityState blocks sprinting
        private bool ShouldSprintBeDisabledOnThisBody(CharacterBody targetBody) {
            EntityStateMachine[] stateMachines;
            stateMachines = targetBody.GetComponents<EntityStateMachine>();
            bool isSprintBlocked = false;
            foreach (EntityStateMachine machine in stateMachines) {
                var currentState = machine.state;
                if (currentState == null) { return false; }
#if DEBUGGY
                if (!knownEntityStates.Contains(currentState.ToString())) {
                    knownEntityStates.Add(currentState.ToString());
                    Debug.LogError("List of Known EntityStates;");
                    foreach (var item in knownEntityStates) {
                        Debug.Log(item);
                    }
                }
#endif
                if (stateSprintDisableList.Contains(currentState.ToString())) { isSprintBlocked = true; }
            }
            return isSprintBlocked;
        }
예제 #9
0
        private bool TeleportAlliesToFirstAvailablePlayer(Vector3?forcePosition = null)
        {
            if (allies.Count == 0)
            {
                return(true);
            }

            CharacterBody body = null;

            foreach (var masterController in PlayerCharacterMasterController.instances)
            {
                if (masterController.master.GetBody())
                {
                    body = masterController.master.GetBody();
                    break;
                }
            }

            if (!body)
            {
                return(false);
            }

            bool teleportedAtLeastOneAlly = false;

            foreach (var ally in allies)
            {
                CharacterBody allyBody = ally.GetBody();
                if (!allyBody)
                {
                    continue;
                }
                Vector3?position = forcePosition;
                if (!forcePosition.HasValue)
                {
                    position = FindSafeTeleportDestination(body.footPosition, allyBody, RoR2Application.rng);
                }
                if (position.HasValue)
                {
                    TeleportHelper.TeleportBody(allyBody, position.Value);

                    allyBody.AddTimedBuff(RoR2Content.Buffs.Immune, 3f);
                    foreach (EntityStateMachine entityStateMachine in allyBody.GetComponents <EntityStateMachine>())
                    {
                        entityStateMachine.initialStateType = entityStateMachine.mainStateType;
                    }

                    GameObject respawnEffect = Resources.Load <GameObject>("Prefabs/Effects/HippoRezEffect");
                    if (respawnEffect)
                    {
                        Transform bodyTransform = getTransform(allyBody);
                        EffectManager.SpawnEffect(respawnEffect, new EffectData
                        {
                            origin   = position.Value,
                            rotation = bodyTransform.rotation,
                            scale    = allyBody.bestFitRadius * 2f
                        }, true);
                    }
                    if (ally.GetBodyObject())
                    {
                        Util.PlaySound("Play_item_proc_extraLife", ally.GetBodyObject());
                    }

                    teleportedAtLeastOneAlly = true;
                }
            }

            return(teleportedAtLeastOneAlly);
        }