Esempio n. 1
0
        public static void LandShip(Map map, Thing ship)
        {
            Thing    blockingThing;
            IntVec3  center = IntVec3.Invalid;
            CompShip comp   = ship.TryGetComp <CompShip>();

            Area_LandingZone lz = map.areaManager.LandingZone();

            if (lz != null && !lz.TryFindShipLandingArea(ship.def.size, out center, out blockingThing) && blockingThing != null)
            {
                Messages.Message("TraderShipsLandingZoneBlocked".Translate("TraderShipsBlockedBy".Translate(blockingThing)), blockingThing, MessageTypeDefOf.NeutralEvent, true);
            }

            if (!center.IsValid && ThingDefOf.ShipLandingBeacon != null && !DropCellFinder.TryFindShipLandingArea(map, out center, out blockingThing) && blockingThing != null)
            {
                Messages.Message("TraderShipsLandingZoneBlocked".Translate("TraderShipsBlockedBy".Translate(blockingThing)), blockingThing, MessageTypeDefOf.NeutralEvent, true);
            }

            if (!center.IsValid)
            {
                FindCloseLandingSpot(out center, comp.tradeShip.Faction, map, ship.def.size);
            }

            GenPlace.TryPlaceThing(SkyfallerMaker.MakeSkyfaller(comp.Props.landAnimation, ship), center, map, ThingPlaceMode.Near);
        }
Esempio n. 2
0
        public static void SpawnTraderShip()
        {
            List <DebugMenuOption> list = new List <DebugMenuOption>();

            list.Add(new DebugMenuOption("Incoming", DebugMenuOptionMode.Tool, delegate()
            {
                Thing thing   = ThingMaker.MakeThing(Globals.TraderShipsShip, null);
                CompShip comp = thing.TryGetComp <CompShip>();
                comp.GenerateInternalTradeShip(Find.CurrentMap);

                GenPlace.TryPlaceThing(SkyfallerMaker.MakeSkyfaller(comp.Props.landAnimation, thing), UI.MouseCell(), Find.CurrentMap, ThingPlaceMode.Near, null, null, default(Rot4));
            }));

            list.Add(new DebugMenuOption("Stationary", DebugMenuOptionMode.Tool, delegate()
            {
                Thing thing = ThingMaker.MakeThing(Globals.TraderShipsShip, null);
                thing.TryGetComp <CompShip>().GenerateInternalTradeShip(Find.CurrentMap);

                GenPlace.TryPlaceThing(thing, UI.MouseCell(), Find.CurrentMap, ThingPlaceMode.Near, null, null, default(Rot4));
            }));


            list.Add(new DebugMenuOption("Crash", DebugMenuOptionMode.Tool, delegate()
            {
                Thing ship    = ThingMaker.MakeThing(Globals.TraderShipsShip, null);
                CompShip comp = ship.TryGetComp <CompShip>();
                comp.GenerateInternalTradeShip(Find.CurrentMap);
                comp.mustCrash = true;
                GenPlace.TryPlaceThing(SkyfallerMaker.MakeSkyfaller(Globals.TraderShipsShipCrashing, ship), UI.MouseCell(), Find.CurrentMap, ThingPlaceMode.Near);
            }));

            List <DebugMenuOption> options = list;

            Find.WindowStack.Add(new Dialog_DebugOptionListLister(options));
        }
        protected override bool TryExecuteWorker(IncidentParms parms)
        {
            Map     map  = (Map)parms.target;
            Thing   ship = ThingMaker.MakeThing(Globals.TraderShipsShip, null);
            IntVec3 spot = RandomSpot(map);

            CompShip comp = ship.TryGetComp <CompShip>();

            comp.GenerateInternalTradeShip(map);
            comp.mustCrash = true;
            GenPlace.TryPlaceThing(SkyfallerMaker.MakeSkyfaller(Globals.TraderShipsShipCrashing, ship), spot, map, ThingPlaceMode.Near);
            return(true);
        }
Esempio n. 4
0
        public static Thing MakeTraderShip(Map map)
        {
            Thing         ship          = ThingMaker.MakeThing(Globals.TraderShipsShip, null);
            TraderKindDef traderKindDef = (from x in DefDatabase <TraderKindDef> .AllDefs where CanSpawn(map, x) select x).RandomElementByWeightWithFallback((TraderKindDef traderDef) => traderDef.CalculatedCommonality);

            if (traderKindDef == null)
            {
                throw new InvalidOperationException();
            }

            CompShip comp = ship.TryGetComp <CompShip>();

            comp.GenerateInternalTradeShip(map, traderKindDef);
            return(ship);
        }
Esempio n. 5
0
        protected override void Impact()
        {
            IntVec3  position = Position;
            Map      map      = Map;
            CompShip comp     = Ship;

            base.Impact();

            if (map == null || comp == null)
            {
                return;
            }
            if (comp.mustCrash)
            {
                comp.Crash();
            }
        }
Esempio n. 6
0
        public override void DrawAt(Vector3 drawLoc, bool flip = false)
        {
            float pos = Traverse.Create(this).Property <float>("TimeInAnimation").Value;

            CompShip comp = Ship;

            if (comp == null)
            {
                return;
            }

            float num = 0f;

            if (def.skyfaller.rotateGraphicTowardsDirection)
            {
                num = angle;
            }
            if (def.skyfaller.angleCurve != null)
            {
                angle = def.skyfaller.angleCurve.Evaluate(pos);
            }
            if (def.skyfaller.rotationCurve != null)
            {
                num += def.skyfaller.rotationCurve.Evaluate(pos);
            }
            if (def.skyfaller.xPositionCurve != null)
            {
                drawLoc.x += def.skyfaller.xPositionCurve.Evaluate(pos);
            }
            if (def.skyfaller.zPositionCurve != null)
            {
                drawLoc.z += def.skyfaller.zPositionCurve.Evaluate(pos);
            }

            comp.Sprite.Draw(drawLoc, num);

            if (ShadowMaterial != null)
            {
                drawLoc.z = GenThing.TrueCenter(this).z;

                DrawDropSpotShadow(drawLoc, Rotation, ShadowMaterial, def.skyfaller.shadowSize, ticksToImpact);
            }
        }
        protected override IEnumerable <Toil> MakeNewToils()
        {
            CompShip comp = Trader.TryGetComp <CompShip>();

            this.FailOnDespawnedOrNull(TargetIndex.A);
            yield return(Toils_Goto.GotoThing(TargetIndex.A, PathEndMode.InteractionCell).FailOn(() => comp == null || !comp.tradeShip.CanTradeNow));

            Toil trade = new Toil();

            trade.initAction = delegate()
            {
                Pawn actor = trade.actor;
                if (comp.tradeShip.CanTradeNow)
                {
                    Find.WindowStack.Add(new Dialog_Trade(actor, comp.tradeShip, false));
                }
            };
            yield return(trade);

            yield break;
        }