コード例 #1
0
        public static void Postfix(MissionState __instance, float realDt)
        {
            if (__instance.CurrentMission != null && __instance.CurrentMission.CurrentState == Mission.State.Continuing && !__instance.Paused)
            {
                MissionSpawnAgentPatch.MaxStaminaPerAgent.Keys.Except(MissionSpawnAgentPatch.AgentsToBeUpdated.Select(t => t.Item1).ToList())
                .Where(x => x.IsActive() && x.Character != null)
                .ToList().ForEach(o => AgentRecoveryTimers[o]++);

                if (!MissionSpawnAgentPatch.AgentsToBeUpdated.IsEmpty())
                {
                    Tuple <Agent, double> tuple = MissionSpawnAgentPatch.AgentsToBeUpdated.Dequeue();
                    if (tuple.Item1.IsActive())
                    {
                        ChangeWeaponSpeedsHandler(tuple.Item1, tuple.Item2);
                        //ChangeMoveSpeed(tuple.Item1, tuple.Item2);
                    }
                }

                foreach (Agent agent in AgentRecoveryTimers.Keys.ToList())
                {
                    if (AgentRecoveryTimers[agent] > 60 * StaminaProperties.Instance.SecondsBeforeStaminaRegenerates &&
                        MissionSpawnAgentPatch.GetCurrentStaminaRatio(agent) < StaminaProperties.Instance.HighStaminaRemaining)
                    {
                        if (agent.GetCurrentVelocity().Length > agent.MaximumForwardUnlimitedSpeed * StaminaProperties.Instance.MaximumMoveSpeedPercentStaminaRegenerates)
                        {
                            MissionSpawnAgentPatch.UpdateStaminaHandler(agent, StaminaProperties.Instance.StaminaRecoveredPerTickMoving, true);
                        }
                        else
                        {
                            MissionSpawnAgentPatch.UpdateStaminaHandler(agent, StaminaProperties.Instance.StaminaRecoveredPerTickResting, true);
                        }
                    }
                }
            }
        }
コード例 #2
0
        public static void Postfix(Mission __instance,
                                   Agent affectedAgent,
                                   Agent affectorAgent,
                                   int affectorWeaponKind,
                                   bool isBlocked,
                                   int damage)
        {
            MissionOnTickPatch.AgentRecoveryTimers[affectorAgent] = 0;
            MissionOnTickPatch.AgentRecoveryTimers[affectedAgent] = 0;

            if (affectorAgent.Character != null && affectorAgent.IsActive())
            {
                ItemObject itemFromWeaponKind = ItemObject.GetItemFromWeaponKind(affectorWeaponKind);
                if (itemFromWeaponKind != null && itemFromWeaponKind.PrimaryWeapon.IsConsumable)
                {
                    MissionSpawnAgentPatch.UpdateStaminaHandler(affectorAgent, StaminaProperties.Instance.StaminaCostToRangedAttack);
                }
                else
                {
                    MissionSpawnAgentPatch.UpdateStaminaHandler(affectorAgent, StaminaProperties.Instance.StaminaCostToMeleeAttack);
                }
            }

            if (affectedAgent.Character != null && affectedAgent.IsActive())
            {
                if (isBlocked)
                {
                    MissionSpawnAgentPatch.UpdateStaminaHandler(affectedAgent, damage * StaminaProperties.Instance.StaminaCostPerBlockedDamage);
                }
                else
                {
                    MissionSpawnAgentPatch.UpdateStaminaHandler(affectedAgent, damage * StaminaProperties.Instance.StaminaCostPerReceivedDamage);
                }
            }
        }
コード例 #3
0
        public static void Postfix(Agent __instance,
                                   SpawnedItemEntity spawnedItemEntity,
                                   EquipmentIndex weaponPickUpSlotIndex,
                                   bool removeWeapon)
        {
            try
            {
                AgentInitializeMissionEquipmentPatch.AgentOriginalWeaponSpeed[__instance][(int)weaponPickUpSlotIndex] = new Tuple <int, int>(spawnedItemEntity.WeaponCopy.PrimaryItem.PrimaryWeapon.SwingSpeed, spawnedItemEntity.WeaponCopy.PrimaryItem.PrimaryWeapon.ThrustSpeed);
                MissionOnTickPatch.ChangeWeaponSpeedsHandler(__instance, MissionSpawnAgentPatch.GetCurrentStaminaRatio(__instance));
            }
            catch (KeyNotFoundException)
            {
#if DEBUG
                InformationManager.DisplayMessage(new InformationMessage("Caught KeyNotFoundException in AgentOnItemPickupPatch!", new Color(1.00f, 0.38f, 0.01f), "Debug"));
#endif
            }
        }