Exemplo n.º 1
0
        public static Map GenerateMap(IntVec3 mapSize, MapParent parent, MapGeneratorDef mapGenerator, IEnumerable <GenStepWithParams> extraGenStepDefs = null, Action <Map> extraInitBeforeContentGen = null)
        {
            ProgramState programState = Current.ProgramState;

            Current.ProgramState = ProgramState.MapInitializing;
            playerStartSpotInt   = IntVec3.Invalid;
            rootsToUnfog.Clear();
            data.Clear();
            mapBeingGenerated = null;
            DeepProfiler.Start("InitNewGeneratedMap");
            Rand.PushState();
            int seed = (Rand.Seed = Gen.HashCombineInt(Find.World.info.Seed, parent.Tile));

            try
            {
                if (parent != null && parent.HasMap)
                {
                    Log.Error(string.Concat("Tried to generate a new map and set ", parent, " as its parent, but this world object already has a map. One world object can't have more than 1 map."));
                    parent = null;
                }
                DeepProfiler.Start("Set up map");
                Map map = new Map();
                map.uniqueID       = Find.UniqueIDsManager.GetNextMapID();
                map.generationTick = GenTicks.TicksGame;
                mapBeingGenerated  = map;
                map.info.Size      = mapSize;
                map.info.parent    = parent;
                map.ConstructComponents();
                DeepProfiler.End();
                Current.Game.AddMap(map);
                extraInitBeforeContentGen?.Invoke(map);
                if (mapGenerator == null)
                {
                    Log.Error("Attempted to generate map without generator; falling back on encounter map");
                    mapGenerator = MapGeneratorDefOf.Encounter;
                }
                IEnumerable <GenStepWithParams> enumerable = mapGenerator.genSteps.Select((GenStepDef x) => new GenStepWithParams(x, default(GenStepParams)));
                if (extraGenStepDefs != null)
                {
                    enumerable = enumerable.Concat(extraGenStepDefs);
                }
                map.areaManager.AddStartingAreas();
                map.weatherDecider.StartInitialWeather();
                DeepProfiler.Start("Generate contents into map");
                GenerateContentsIntoMap(enumerable, map, seed);
                DeepProfiler.End();
                Find.Scenario.PostMapGenerate(map);
                DeepProfiler.Start("Finalize map init");
                map.FinalizeInit();
                DeepProfiler.End();
                DeepProfiler.Start("MapComponent.MapGenerated()");
                MapComponentUtility.MapGenerated(map);
                DeepProfiler.End();
                parent?.PostMapGenerate();
                return(map);
            }
            finally
            {
                DeepProfiler.End();
                mapBeingGenerated    = null;
                Current.ProgramState = programState;
                Rand.PopState();
            }
        }
Exemplo n.º 2
0
 public override int GetHashCode()
 {
     return(Gen.HashCombineInt(Gen.HashCombine(0, path), renderQueue));
 }
Exemplo n.º 3
0
 public override int GetHashCode()
 {
     return(Gen.HashCombineInt(this.ID, 1538478890));
 }
Exemplo n.º 4
0
 public override int GetHashCode()
 {
     return(Gen.HashCombineInt(x, z));
 }
 public override int GetHashCode()
 {
     return(Gen.HashCombineInt(this.mat.GetHashCode(), this.alphaIndex));
 }
Exemplo n.º 6
0
        public static string Translate(this string key, params object[] args)
        {
            if (key.NullOrEmpty())
            {
                return(key);
            }
            if (LanguageDatabase.activeLanguage == null)
            {
                Log.Error("No active language! Cannot translate from key " + key + ".");
                return(key);
            }
            if (!LanguageDatabase.activeLanguage.TryGetTextFromKey(key, out TaggedString translated))
            {
                LanguageDatabase.defaultLanguage.TryGetTextFromKey(key, out translated);
                if (Prefs.DevMode)
                {
                    translated = PseudoTranslated(translated);
                }
            }
            string result = translated;

            try
            {
                result = string.Format(translated, args);
                return(result);
            }
            catch (Exception arg)
            {
                Log.ErrorOnce((string)("Exception translating '" + translated + "': ") + arg, Gen.HashCombineInt(key.GetHashCode(), 394878901));
                return(result);
            }
        }
Exemplo n.º 7
0
 public override int GetHashCode()
 {
     return(Gen.HashCombineInt(this.min, this.max));
 }
Exemplo n.º 8
0
            public override int GetHashCode()
            {
                int seed = Gen.HashCombineInt(FirstRoomID, SecondRoomID);

                return(Gen.HashCombineStruct(seed, TraverseParms));
            }
Exemplo n.º 9
0
 public static int HashOffset(this int baseInt)
 {
     return(Gen.HashCombineInt(baseInt, 169495093));
 }