| | | 1 | | using System; |
| | | 2 | | using CounterDrone.Core.Algorithms; |
| | | 3 | | using CounterDrone.Core.Models; |
| | | 4 | | |
| | | 5 | | namespace CounterDrone.Core.Simulation |
| | | 6 | | { |
| | | 7 | | public class CloudEntity |
| | | 8 | | { |
| | 364 | 9 | | public string Id { get; } |
| | 4393 | 10 | | public ICloudDispersionModel Dispersion { get; } |
| | 25 | 11 | | public AerosolType AerosolType { get; } |
| | 0 | 12 | | public float CreatedAt { get; } |
| | 728 | 13 | | public bool IsDissipated => Dispersion.IsDissipated; |
| | | 14 | | |
| | 11 | 15 | | public CloudEntity(string id, AerosolType aerosolType, ICloudDispersionModel dispersion, float createdAt) |
| | 11 | 16 | | { |
| | 11 | 17 | | Id = id; |
| | 11 | 18 | | AerosolType = aerosolType; |
| | 11 | 19 | | Dispersion = dispersion; |
| | 11 | 20 | | CreatedAt = createdAt; |
| | 11 | 21 | | } |
| | | 22 | | |
| | | 23 | | public void Tick(float deltaTime, float windSpeed, WindDirection windDir) |
| | 364 | 24 | | { |
| | 364 | 25 | | Dispersion.Tick(deltaTime, windSpeed, windDir); |
| | 364 | 26 | | } |
| | | 27 | | |
| | | 28 | | public bool ContainsPoint(float x, float y, float z) |
| | 364 | 29 | | { |
| | 364 | 30 | | if (IsDissipated) return false; |
| | 364 | 31 | | var dx = x - Dispersion.Center.X; |
| | 364 | 32 | | var dy = y - Dispersion.Center.Y; |
| | 364 | 33 | | var dz = z - Dispersion.Center.Z; |
| | 364 | 34 | | var dist = (float)Math.Sqrt(dx * dx + dy * dy + dz * dz); |
| | 364 | 35 | | return dist <= Dispersion.EffectiveRadius; |
| | 364 | 36 | | } |
| | | 37 | | } |
| | | 38 | | } |