public static void DrawLinesToNearbyBeacons(ThingDef myDef, IntVec3 myPos, Rot4 myRot, Map map, Thing thing = null)
        {
            Vector3 a = GenThing.TrueCenter(myPos, myRot, myDef.size, myDef.Altitude);

            foreach (Thing item in map.listerThings.ThingsOfDef(ThingDefOf.ShipLandingBeacon))
            {
                if ((thing == null || thing != item) && item.Faction == Faction.OfPlayer)
                {
                    CompShipLandingBeacon compShipLandingBeacon = item.TryGetComp <CompShipLandingBeacon>();
                    if (compShipLandingBeacon != null && CanLinkTo(myPos, compShipLandingBeacon) && !GenThing.CloserThingBetween(myDef, myPos, item.Position, map))
                    {
                        GenDraw.DrawLineBetween(a, item.TrueCenter(), SimpleColor.White);
                    }
                }
            }
            float minEdgeDistance = myDef.GetCompProperties <CompProperties_ShipLandingBeacon>().edgeLengthRange.min - 1f;
            float maxEdgeDistance = myDef.GetCompProperties <CompProperties_ShipLandingBeacon>().edgeLengthRange.max - 1f;

            foreach (Thing item2 in map.listerThings.ThingsInGroup(ThingRequestGroup.Blueprint))
            {
                if ((thing == null || thing != item2) && item2.def.entityDefToBuild == myDef && (myPos.x == item2.Position.x || myPos.z == item2.Position.z) && !AlignedDistanceTooShort(myPos, item2.Position, minEdgeDistance) && !AlignedDistanceTooLong(myPos, item2.Position, maxEdgeDistance) && !GenThing.CloserThingBetween(myDef, myPos, item2.Position, map))
                {
                    GenDraw.DrawLineBetween(a, item2.TrueCenter(), SimpleColor.White);
                }
            }
        }
Пример #2
0
 private bool CanLinkTo(CompShipLandingBeacon other)
 {
     if (other == this)
     {
         return(false);
     }
     return(ShipLandingBeaconUtility.CanLinkTo(parent.Position, other));
 }
Пример #3
0
        public void EstablishConnections()
        {
            if (!parent.Spawned)
            {
                return;
            }
            List <CompShipLandingBeacon> list  = new List <CompShipLandingBeacon>();
            List <CompShipLandingBeacon> list2 = new List <CompShipLandingBeacon>();
            List <Thing> list3 = parent.Map.listerThings.ThingsOfDef(ThingDefOf.ShipLandingBeacon);

            foreach (Thing item in list3)
            {
                CompShipLandingBeacon compShipLandingBeacon = item.TryGetComp <CompShipLandingBeacon>();
                if (compShipLandingBeacon != null && CanLinkTo(compShipLandingBeacon))
                {
                    if (parent.Position.x == compShipLandingBeacon.parent.Position.x)
                    {
                        list2.Add(compShipLandingBeacon);
                    }
                    else if (parent.Position.z == compShipLandingBeacon.parent.Position.z)
                    {
                        list.Add(compShipLandingBeacon);
                    }
                }
            }
            foreach (CompShipLandingBeacon h in list)
            {
                foreach (CompShipLandingBeacon v in list2)
                {
                    Thing thing = list3.FirstOrDefault((Thing x) => x.Position.x == h.parent.Position.x && x.Position.z == v.parent.Position.z);
                    if (thing != null)
                    {
                        ShipLandingArea shipLandingArea = new ShipLandingArea(CellRect.FromLimits(thing.Position, parent.Position).ContractedBy(1), parent.Map);
                        shipLandingArea.beacons = new List <CompShipLandingBeacon>
                        {
                            this,
                            thing.TryGetComp <CompShipLandingBeacon>(),
                            v,
                            h
                        };
                        TryAddArea(shipLandingArea);
                    }
                }
            }
            for (int num = landingAreas.Count - 1; num >= 0; num--)
            {
                foreach (CompShipLandingBeacon beacon in landingAreas[num].beacons)
                {
                    if (!beacon.TryAddArea(landingAreas[num]))
                    {
                        RemoveArea(landingAreas[num]);
                        break;
                    }
                }
            }
        }
 public static bool CanLinkTo(IntVec3 position, CompShipLandingBeacon other)
 {
     if (position.x == other.parent.Position.x)
     {
         return(other.parent.def.displayNumbersBetweenSameDefDistRange.Includes(Mathf.Abs(position.z - other.parent.Position.z) + 1));
     }
     if (position.z == other.parent.Position.z)
     {
         return(other.parent.def.displayNumbersBetweenSameDefDistRange.Includes(Mathf.Abs(position.x - other.parent.Position.x) + 1));
     }
     return(false);
 }
 public static List <ShipLandingArea> GetLandingZones(Map map)
 {
     tmpShipLandingAreas.Clear();
     foreach (Thing item in map.listerThings.ThingsOfDef(ThingDefOf.ShipLandingBeacon))
     {
         CompShipLandingBeacon compShipLandingBeacon = item.TryGetComp <CompShipLandingBeacon>();
         if (compShipLandingBeacon != null && item.Faction == Faction.OfPlayer)
         {
             foreach (ShipLandingArea landingArea in compShipLandingBeacon.LandingAreas)
             {
                 if (landingArea.Active && !tmpShipLandingAreas.Contains(landingArea))
                 {
                     landingArea.RecalculateBlockingThing();
                     tmpShipLandingAreas.Add(landingArea);
                 }
             }
         }
     }
     return(tmpShipLandingAreas);
 }