private void AskForApply() { var player = Mission.Current.MainAgent; if (Imgui.Button("UPDATE AI")) { foreach (var agent in Mission.Current.AllAgents) { if (agent == null || agent == player) { continue; } var component = agent?.GetComponent <AgentAIStateFlagComponent>(); if (component != null) { component.IsPaused = everyonePassive; } var agentDrivenProperties = (AgentDrivenProperties)agent.GetType() .GetProperty("AgentDrivenProperties", BindingFlags.NonPublic | BindingFlags.Instance) ?.GetValue(agent); foreach (DrivenProperty drivenProperty in (DrivenProperty[])Enum.GetValues(typeof(DrivenProperty))) { if (drivenProperty < DrivenProperty.MountManeuver && drivenProperty > DrivenProperty.None) { float val = StatsToSet.GetStat(drivenProperty); agentDrivenProperties?.SetStat(drivenProperty, val); } agent.UpdateAgentProperties(); } } } }
private void ResetStats() { var player = Mission.Current.MainAgent; foreach (var agent in Mission.Current.AllAgents) { if (agent == null || agent == player) { continue; } var component = agent?.GetComponent <AgentAIStateFlagComponent>(); if (component != null) { component.IsPaused = everyonePassive; } var agentDrivenProperties = (AgentDrivenProperties)agent.GetType() .GetProperty("AgentDrivenProperties", BindingFlags.NonPublic | BindingFlags.Instance) ?.GetValue(agent); foreach (DrivenProperty drivenProperty in (DrivenProperty[])Enum.GetValues(typeof(DrivenProperty))) { if (drivenProperty >= DrivenProperty.MountManeuver || drivenProperty <= DrivenProperty.None) { continue; } var val = StatsBackup.GetStat(drivenProperty); agentDrivenProperties?.SetStat(drivenProperty, val); } agent.UpdateAgentProperties(); } }