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);
        }
Exemple #2
0
 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;
 }
Exemple #4
0
 public static bool CanLinkWith(ILinearShield one, ILinearShield two)
 {
     return(one.CanLinkWith(two) && two.CanLinkWith(one) && !BlockingBetween(one, two).Any());
 }
Exemple #5
0
 public static IEnumerable <IntVec3> BlockingBetween(ILinearShield one, ILinearShield two)
 {
     return(CellsBetween(one.Position, two.Position).Where(cell => IsCellBlocked(cell, one.Map)));
 }
Exemple #6
0
 private bool LinkedWith(ILinearShield other) => _links.Any(link => link.Has(other));