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); } } }
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); } } } } }