private void BuildFireCone() { _fireCone = null; var pawn = Main.GetSelectedPawn(); if (pawn == null) { return; } if (!HasValidWeapon(pawn)) { return; } var targetCell = UI.MouseCell(); var pawnCell = pawn.Position; if (pawnCell.DistanceTo(targetCell) > GetEquippedWeaponRange(pawn)) { return; } var fireProperties = new FireProperties(pawn, targetCell); _fireCone = FireCalculations.GetFireCone(fireProperties); }
private HashSet <int> GetOrCreatedCachedFireConeFor(FireProperties fireProperties) { var originIndex = fireProperties.OriginIndex; var targetIndex = fireProperties.TargetIndex; if (_cachedFireCones.TryGetValue(originIndex, out var cachedFireConesFromOrigin)) { if (cachedFireConesFromOrigin.TryGetValue(targetIndex, out var cachedFireCone)) { if (!cachedFireCone.IsExpired()) { cachedFireCone.Prolong(); return(cachedFireCone.FireCone); } } } // No cached firecone, create one var newFireCone = new CachedFireCone(FireCalculations.GetFireCone(fireProperties)); if (!_cachedFireCones.ContainsKey(originIndex)) { _cachedFireCones.Add(originIndex, new Dictionary <int, CachedFireCone>()); } _cachedFireCones[originIndex][targetIndex] = newFireCone; return(newFireCone.FireCone); }