public ShieldLinearWantLinkUiComponent(ILinearShield self, ILinearShield other, Action <bool> fieldRenderOverride, Action buttonAction) { Self = self; Other = other; FieldRenderOverride = fieldRenderOverride; ButtonAction = buttonAction; var distance = self.Position.DistanceTo(other.Position); PowerNeeded = LinearShieldUtility.CellProtectionFactorCost(distance) * distance; Efficiency = LinearShieldUtility.CalculateFieldEfficiency(distance, self.EfficientRange, other.EfficientRange); }
public static TargetingParameters LinearLink(ILinearShield source) => new TargetingParameters { canTargetLocations = false, canTargetSelf = false, canTargetPawns = false, canTargetFires = false, canTargetBuildings = true, canTargetItems = false, validator = targetInfo => { var shield = LinearShieldUtility.Find(targetInfo.Thing); if (shield != null && source.CanLinkWith(shield)) { // TODO add efficiency LinearShieldUtility.DrawFieldBetween(source.Position, shield.Position, shield.Map, Color.grey); return(true); } return(false); } };
public ShieldLinearLinkUiComponent(LinearShieldLink link, ILinearShield self) { Link = link; Self = self; }
public static bool CanLinkWith(ILinearShield one, ILinearShield two) { return(one.CanLinkWith(two) && two.CanLinkWith(one) && !BlockingBetween(one, two).Any()); }
public static IEnumerable <IntVec3> BlockingBetween(ILinearShield one, ILinearShield two) { return(CellsBetween(one.Position, two.Position).Where(cell => IsCellBlocked(cell, one.Map))); }
private bool LinkedWith(ILinearShield other) => _links.Any(link => link.Has(other));