コード例 #1
0
        public void EstablishFarcasterLink()
        {
            mapHome = this.Map;
            Messages.Message("GU_FarcasterActivated".Translate(), MessageTypeDefOf.PositiveEvent);
            FarcasterDestination worldObjectFarcaster = (FarcasterDestination)WorldObjectMaker.MakeWorldObject(DefDatabase <WorldObjectDef> .GetNamed("GU_FarcasterDestinationSigmaAlcyon", true));

            mapParent      = (MapParent)worldObjectFarcaster;
            mapParent.Tile = TileFinder.RandomStartingTile();
            mapParent.SetFaction(Faction.OfPlayer);
            worldObjectFarcaster.mapHome = mapHome;
            worldObjectFarcaster.mapGen  = DefDatabase <MapGeneratorDef> .GetNamed("GU_FarcasterMapSigmaAlcyon", true);

            Find.WorldObjects.Add(mapParent);
            myMap = new Map();

            LongEventHandler.QueueLongEvent(delegate
            {
                myMap = GetOrGenerateMapUtility.GetOrGenerateMap(mapParent.Tile, Find.World.info.initialMapSize, null);
            }, "GU_LinkingWithFarcasters", true, new Action <Exception>(GameAndMapInitExceptionHandlers.ErrorWhileGeneratingMap));
            LongEventHandler.QueueLongEvent(delegate
            {
                originalBiome        = myMap.TileInfo.biome;
                originalTile         = mapParent.Tile;
                myMap.TileInfo.biome = DefDatabase <BiomeDef> .GetNamed("GU_SigmaAlcyonIIb", true);
                mapParent.Tile       = base.Tile;

                mapFarcast = myMap;

                //Remote Farcaster portal spawning

                Building_AncientFarcaster building_AncientFarcaster = (Building_AncientFarcaster)ThingMaker.MakeThing(DefDatabase <ThingDef> .GetNamed("GU_AncientFarcasterPortal", true));
                building_AncientFarcaster.mapHome      = mapHome;
                building_AncientFarcaster.locationHome = this.Position;
                building_AncientFarcaster.SetFaction(Faction.OfPlayer);
                GenSpawn.Spawn(building_AncientFarcaster, myMap.Center, myMap);
                locationFarcast = building_AncientFarcaster.Position;

                //An auxiliary pad too

                Building_Storage building_AncientPad = (Building_Storage)ThingMaker.MakeThing(DefDatabase <ThingDef> .GetNamed("GU_AncientFarcasterPad", true));
                building_AncientPad.SetFaction(Faction.OfPlayer);
                GenSpawn.Spawn(building_AncientPad, myMap.Center - GenAdj.CardinalDirections[0] * 4, myMap);

                //Farcaster portal spawning ends here
            }, "GU_LinkingWithFarcasters", true, new Action <Exception>(GameAndMapInitExceptionHandlers.ErrorWhileGeneratingMap));
        }