micromissiles-unity/Assets/Scripts/Config/SimulationConfig.cs

123 lines
3.5 KiB
C#
Raw Permalink Normal View History

using System;
2024-09-12 00:17:21 -07:00
using System.Collections.Generic;
using UnityEngine;
using Newtonsoft.Json;
using Newtonsoft.Json.Converters;
2024-09-12 00:17:21 -07:00
[Serializable]
public class SimulationConfig {
[Header("Simulation Settings")]
public float timeScale = 0.05f;
2024-09-12 00:17:21 -07:00
2024-09-24 19:59:25 -07:00
[Header("Interceptor Swarm Configurations")]
public List<SwarmConfig> interceptor_swarm_configs = new List<SwarmConfig>();
2024-09-24 19:24:50 -07:00
[Header("Threat Swarm Configurations")]
2024-09-24 19:59:25 -07:00
public List<SwarmConfig> threat_swarm_configs = new List<SwarmConfig>();
2024-09-12 00:17:21 -07:00
}
[Serializable]
2024-09-13 22:45:25 -07:00
public class DynamicConfig {
public LaunchConfig launch_config;
public SensorConfig sensor_config;
2024-09-12 00:17:21 -07:00
}
[Serializable]
2024-09-13 22:45:25 -07:00
public class SwarmConfig {
public int num_agents;
public AgentConfig agent_config;
2024-09-12 00:17:21 -07:00
}
[Serializable]
2024-09-13 22:45:25 -07:00
public class AgentConfig {
2024-09-24 19:59:25 -07:00
public InterceptorType interceptor_type;
public ThreatType threat_type;
public InitialState initial_state;
public StandardDeviation standard_deviation;
public DynamicConfig dynamic_config;
public PlottingConfig plotting_config;
public SubmunitionsConfig submunitions_config;
public static AgentConfig FromSubmunitionAgentConfig(SubmunitionAgentConfig submunitionConfig) {
return new AgentConfig {
2024-09-24 19:59:25 -07:00
interceptor_type = submunitionConfig.interceptor_type,
initial_state = submunitionConfig.initial_state,
standard_deviation = submunitionConfig.standard_deviation,
dynamic_config = submunitionConfig.dynamic_config,
plotting_config = submunitionConfig.plotting_config,
// Set other fields as needed, using default values if not present in SubmunitionAgentConfig
threat_type = ThreatType.DRONE, // Or another default value
submunitions_config = null // Or a default value if needed
};
}
2024-09-12 00:17:21 -07:00
}
[Serializable]
2024-09-13 22:45:25 -07:00
public class InitialState {
public Vector3 position;
public Vector3 rotation;
public Vector3 velocity;
2024-09-12 00:17:21 -07:00
}
[Serializable]
2024-09-13 22:45:25 -07:00
public class StandardDeviation {
public Vector3 position;
public Vector3 velocity;
2024-09-12 00:17:21 -07:00
}
[Serializable]
2024-09-13 22:45:25 -07:00
public class LaunchConfig {
public float launch_time;
2024-09-12 00:17:21 -07:00
}
[Serializable]
2024-09-13 22:45:25 -07:00
public class PlottingConfig {
public ConfigColor color;
public LineStyle linestyle;
public Marker marker;
2024-09-12 00:17:21 -07:00
}
[Serializable]
2024-09-13 22:45:25 -07:00
public class SubmunitionsConfig {
public int num_submunitions;
public LaunchConfig launch_config;
public SubmunitionAgentConfig agent_config;
2024-09-12 00:17:21 -07:00
}
[Serializable]
2024-09-13 22:45:25 -07:00
public class SubmunitionAgentConfig {
2024-09-24 19:59:25 -07:00
public InterceptorType interceptor_type;
public InitialState initial_state;
public StandardDeviation standard_deviation;
public DynamicConfig dynamic_config;
public PlottingConfig plotting_config;
2024-09-12 00:17:21 -07:00
}
[Serializable]
2024-09-13 22:45:25 -07:00
public class SensorConfig {
public SensorType type;
public float frequency;
2024-09-12 00:17:21 -07:00
}
[Serializable]
2024-09-13 22:45:25 -07:00
public class TargetConfig {
public ThreatType threat_type;
public InitialState initial_state;
public PlottingConfig plotting_config;
public string prefabName;
2024-09-12 00:17:21 -07:00
}
// Enums
[JsonConverter(typeof(StringEnumConverter))]
2024-09-24 19:59:25 -07:00
public enum InterceptorType { HYDRA_70, MICROMISSILE }
[JsonConverter(typeof(StringEnumConverter))]
2024-09-24 19:59:25 -07:00
public enum ThreatType { DRONE, ANTISHIP_MISSILE }
[JsonConverter(typeof(StringEnumConverter))]
2024-09-13 22:45:25 -07:00
public enum ConfigColor { BLUE, GREEN, RED }
[JsonConverter(typeof(StringEnumConverter))]
2024-09-13 22:45:25 -07:00
public enum LineStyle { DOTTED, SOLID }
[JsonConverter(typeof(StringEnumConverter))]
2024-09-13 22:45:25 -07:00
public enum Marker { TRIANGLE_UP, TRIANGLE_DOWN, SQUARE }
[JsonConverter(typeof(StringEnumConverter))]
2024-09-13 22:45:25 -07:00
public enum SensorType { IDEAL }