Exemple #1
0
 public override void Tick()
 {
     base.Tick();
     if (vehicle.CompVehicleLauncher.launchProtocol.FinishedLanding(this))
     {
         delayLandingTicks--;
         if (delayLandingTicks <= 0 && Position.InBounds(Map))
         {
             Position = skyfallerLoc.ToIntVec3();
             FinalizeLanding();
         }
     }
     if (Find.TickManager.TicksGame % NotificationSquishInterval == 0)
     {
         foreach (IntVec3 cell in vehicle.PawnOccupiedCells(Position, Rotation))
         {
             GenVehicleTracks.NotifyNearbyPawnsOfDangerousPosition(Map, cell);
         }
     }
 }
Exemple #2
0
        public void TakeStep()
        {
            drawTracks.Clear();
            foreach (VehicleTrack track in Props.tracks)
            {
                IntVec2 rotationalSign = new IntVec2(1, 1);

                if (ParentVehicle.Rotation == Rot4.South)
                {
                    rotationalSign.z = -1;
                }
                else if (ParentVehicle.Rotation == Rot4.West)
                {
                    rotationalSign.x = -1;
                }
                else if (ParentVehicle.Rotation == Rot4.East)
                {
                    rotationalSign.z = -1;
                }

                IntVec2 start = track.trackPoint.First;
                IntVec2 end   = track.trackPoint.Second;
                start.z -= 1;
                end.z   -= 1;

                int     xFirst  = rotationalSign.x * (ParentVehicle.Rotation.IsHorizontal ? start.z : start.x);
                int     zFirst  = rotationalSign.z * (ParentVehicle.Rotation.IsHorizontal ? start.x : start.z);
                IntVec3 first   = new IntVec3(ParentVehicle.Position.x - xFirst, ParentVehicle.Position.y, ParentVehicle.Position.z - zFirst);
                int     xSecond = rotationalSign.x * (ParentVehicle.Rotation.IsHorizontal ? end.z : end.x);
                int     zSecond = rotationalSign.z * (ParentVehicle.Rotation.IsHorizontal ? end.x : end.z);
                IntVec3 second  = new IntVec3(ParentVehicle.Position.x - xSecond, ParentVehicle.Position.y, ParentVehicle.Position.z - zSecond);

                drawTracks.Add(new Pair <IntVec3, IntVec3>(first, second));

                foreach (IntVec3 cell in CellRect.FromLimits(first, second).Cells)
                {
                    if (!cell.InBounds(ParentVehicle.Map))
                    {
                        continue;
                    }

                    List <Thing> things = ParentVehicle.Map.thingGrid.ThingsListAtFast(cell);
                    for (int i = things.Count - 1; i >= 0; i--)
                    {
                        Thing thing = things[i];
                        if (thing == ParentVehicle)
                        {
                            continue;
                        }
                        if (track.destroyableCategories.Contains(thing.def.category))
                        {
                            try
                            {
                                if (thing.def.category == ThingCategory.Pawn)
                                {
                                    thing.TakeDamage(new DamageInfo(DamageDefOf.Crush, 200));
                                }
                                else
                                {
                                    thing.Destroy();
                                }
                            }
                            catch
                            {
                                //do nothing right now
                            }
                        }
                    }
                }

                foreach (IntVec3 cell in WarningRect().Cells)
                {
                    if (!cell.InBounds(ParentVehicle.Map))
                    {
                        continue;
                    }
                    if (ParentVehicle.Map.thingGrid.ThingsListAtFast(cell).Any(t => t is Pawn))
                    {
                        GenVehicleTracks.NotifyNearbyPawnsPathOfVehicleTrack(ParentVehicle);
                    }
                }
            }
        }