static void Postfix(WealthWatcher __instance)
            {
                Map map = (Map)__instance.GetType().GetField("map", BindingFlags.NonPublic | BindingFlags.Instance).GetValue(__instance);
                //float wealthBuildings = __instance.GetType().GetField("wealthBuildings", BindingFlags.NonPublic | BindingFlags.Instance).GetValue(__instance) as float;
                FieldInfo wealthItemsFI = __instance.GetType().GetField("wealthItems", BindingFlags.NonPublic | BindingFlags.Instance);
                float     wealthItems   = (float)wealthItemsFI.GetValue(__instance);

                wealthItems = TallyWealth(WorldComp.GetInfiniteStorages(map), wealthItems);
                //wealthItems = TallyWealth(WorldComp.GetNonGlobalInfiniteStorages(map), wealthItems);

                if (lastItemWealth < 1)
                {
                    lastItemWealth = wealthItems;
                }
                else if (wealthItems > lastItemWealth * 5)
                {
                    float temp = wealthItems;
                    wealthItems    = lastItemWealth;
                    lastItemWealth = temp;
                }
                else
                {
                    lastItemWealth = wealthItems;
                }

                wealthItemsFI.SetValue(__instance, wealthItems);
            }
Пример #2
0
        private static float CalculateWealthItems(WealthWatcher __instance)
        {
            //this.tmpThings.Clear();
            List <Thing> tmpThings = new List <Thing>();

            ThingOwnerUtility.GetAllThingsRecursively <Thing>(map(__instance), ThingRequest.ForGroup(ThingRequestGroup.HaulableEver), tmpThings, false, delegate(IThingHolder x)
            {
                if (x is PassingShip || x is MapComponent)
                {
                    return(false);
                }
                Pawn pawn = x as Pawn;
                return((pawn == null || pawn.Faction == Faction.OfPlayer) && (pawn == null || !pawn.IsQuestLodger()));
            }, true);
            float num = 0f;

            for (int i = 0; i < tmpThings.Count; i++)
            {
                if (tmpThings[i].SpawnedOrAnyParentSpawned && !tmpThings[i].PositionHeld.Fogged(map(__instance)))
                {
                    num += tmpThings[i].MarketValue * tmpThings[i].stackCount;
                }
            }
            //this.tmpThings.Clear();
            return(num);
        }
            static void Postfix(WealthWatcher __instance)
            {
                Map       map           = (Map)__instance.GetType().GetField("map", BindingFlags.NonPublic | BindingFlags.Instance).GetValue(__instance);
                FieldInfo wealthItemsFI = __instance.GetType().GetField("wealthItems", BindingFlags.NonPublic | BindingFlags.Instance);
                float     wealthItems   = (float)wealthItemsFI.GetValue(__instance);

                wealthItems = TallyWealth(WorldComp.GetWeaponStorages(map), wealthItems);

                wealthItemsFI.SetValue(__instance, wealthItems);
            }
Пример #4
0
        public static bool ForceRecount(WealthWatcher __instance, bool allowDuringInit = false)
        {
            if (!allowDuringInit && Current.ProgramState != ProgramState.Playing)
            {
                Log.Error("WealthWatcher recount in game mode " + Current.ProgramState, false);
                return(false);
            }
            wealthItems(__instance)      = CalculateWealthItems(__instance);
            wealthBuildings(__instance)  = 0f;
            wealthPawns(__instance)      = 0f;
            wealthFloorsOnly(__instance) = 0f;
            totalHealth(__instance) = 0;
            List <Thing> list = map(__instance).listerThings.ThingsInGroup(ThingRequestGroup.BuildingArtificial);

            for (int i = 0; i < list.Count; i++)
            {
                Thing thing = list[i];
                if (thing.Faction == Faction.OfPlayer)
                {
                    wealthBuildings(__instance) += thing.GetStatValue(StatDefOf.MarketValueIgnoreHp, true);
                    totalHealth(__instance)     += thing.HitPoints;
                }
            }
            wealthFloorsOnly(__instance) = CalculateWealthFloors(__instance);
            wealthBuildings(__instance) += wealthFloorsOnly(__instance);
            Pawn        pawn;
            List <Pawn> pawnList = map(__instance).mapPawns.PawnsInFaction(Faction.OfPlayer);

            for (int index = 0; index < pawnList.Count; index++)
            {
                try
                {
                    pawn = pawnList[index];
                } catch (ArgumentOutOfRangeException) { break; }
                if (!pawn.IsQuestLodger())
                {
                    wealthPawns(__instance) += pawn.MarketValue;
                    if (pawn.IsFreeColonist)
                    {
                        totalHealth(__instance) += Mathf.RoundToInt(pawn.health.summaryHealth.SummaryHealthPercent * 100f);
                    }
                }
            }
            lastCountTick(__instance) = (float)Find.TickManager.TicksGame;
            return(false);
        }
Пример #5
0
        public static bool ResetStaticData(WealthWatcher __instance)
        {
            int num = -1;
            List <TerrainDef> allDefsListForReading = DefDatabase <TerrainDef> .AllDefsListForReading;

            for (int i = 0; i < allDefsListForReading.Count; i++)
            {
                num = Mathf.Max(num, allDefsListForReading[i].index);
            }

            float[] newCachedTerrainMarketValue = new float[num + 1];
            for (int j = 0; j < allDefsListForReading.Count; j++)
            {
                newCachedTerrainMarketValue[allDefsListForReading[j].index] = allDefsListForReading[j].GetStatValueAbstract(StatDefOf.MarketValue);
            }
            cachedTerrainMarketValue = newCachedTerrainMarketValue;
            return(false);
        }
Пример #6
0
            public static bool WealthPawns(WealthWatcher __instance, Map ___map, ref float __result, float ___lastCountTick)
            {
                float result = 0;

                foreach (var map in ZUtils.ZTracker.GetAllMaps(___map.Tile))
                {
                    if ((float)Find.TickManager.TicksGame - ___lastCountTick > 5000f)
                    {
                        map.wealthWatcher.ForceRecount();
                    }
                    var value = map.wealthWatcher.wealthPawns;
                    result += value;
                    //ZLogger.Message("Analyzing wealthPawns: " + map + " - value: " + value);
                }
                //ZLogger.Message("New result: " + result);
                __result = result;
                return(false);
            }
Пример #7
0
            public static bool WealthFloorsOnly(WealthWatcher __instance, Map ___map, ref float __result, float ___lastCountTick)
            {
                float result = 0;

                //Log.Message("Old result: " + Traverse.Create(__instance).Field("wealthFloorsOnly").GetValue<float>());
                foreach (var map in ZUtils.ZTracker.GetAllMaps(___map.Tile))
                {
                    if ((float)Find.TickManager.TicksGame - ___lastCountTick > 5000f)
                    {
                        map.wealthWatcher.ForceRecount();
                    }
                    var value = Traverse.Create(map.wealthWatcher).Field("wealthFloorsOnly").GetValue <float>();
                    result += value;
                    //Log.Message("Analyzing wealthFloorsOnly: " + map + " - value: " + value);
                }
                //Log.Message("New result: " + result);
                __result = result;
                return(false);
            }
Пример #8
0
        private static float CalculateWealthFloors(WealthWatcher __instance)
        {
            TerrainDef[] topGrid = map(__instance).terrainGrid.topGrid;
            bool[]       fogGrid = map(__instance).fogGrid.fogGrid;
            IntVec3      size    = map(__instance).Size;
            float        num     = 0f;
            int          i       = 0;
            int          num2    = size.x * size.z;

            while (i < num2)
            {
                if (!fogGrid[i])
                {
                    num += cachedTerrainMarketValue[topGrid[i].index];
                }
                i++;
            }
            return(num);
        }
Пример #9
0
 public void ConstructComponents()
 {
     this.spawnedThings      = new ThingOwner <Thing>(this);
     this.cellIndices        = new CellIndices(this);
     this.listerThings       = new ListerThings(ListerThingsUse.Global);
     this.listerBuildings    = new ListerBuildings();
     this.mapPawns           = new MapPawns(this);
     this.dynamicDrawManager = new DynamicDrawManager(this);
     this.mapDrawer          = new MapDrawer(this);
     this.tooltipGiverList   = new TooltipGiverList();
     this.pawnDestinationReservationManager = new PawnDestinationReservationManager();
     this.reservationManager = new ReservationManager(this);
     this.physicalInteractionReservationManager = new PhysicalInteractionReservationManager();
     this.designationManager             = new DesignationManager(this);
     this.lordManager                    = new LordManager(this);
     this.debugDrawer                    = new DebugCellDrawer();
     this.passingShipManager             = new PassingShipManager(this);
     this.haulDestinationManager         = new HaulDestinationManager(this);
     this.gameConditionManager           = new GameConditionManager(this);
     this.weatherManager                 = new WeatherManager(this);
     this.zoneManager                    = new ZoneManager(this);
     this.resourceCounter                = new ResourceCounter(this);
     this.mapTemperature                 = new MapTemperature(this);
     this.temperatureCache               = new TemperatureCache(this);
     this.areaManager                    = new AreaManager(this);
     this.attackTargetsCache             = new AttackTargetsCache(this);
     this.attackTargetReservationManager = new AttackTargetReservationManager(this);
     this.lordsStarter                   = new VoluntarilyJoinableLordsStarter(this);
     this.thingGrid                  = new ThingGrid(this);
     this.coverGrid                  = new CoverGrid(this);
     this.edificeGrid                = new EdificeGrid(this);
     this.blueprintGrid              = new BlueprintGrid(this);
     this.fogGrid                    = new FogGrid(this);
     this.glowGrid                   = new GlowGrid(this);
     this.regionGrid                 = new RegionGrid(this);
     this.terrainGrid                = new TerrainGrid(this);
     this.pathGrid                   = new PathGrid(this);
     this.roofGrid                   = new RoofGrid(this);
     this.fertilityGrid              = new FertilityGrid(this);
     this.snowGrid                   = new SnowGrid(this);
     this.deepResourceGrid           = new DeepResourceGrid(this);
     this.exitMapGrid                = new ExitMapGrid(this);
     this.linkGrid                   = new LinkGrid(this);
     this.glowFlooder                = new GlowFlooder(this);
     this.powerNetManager            = new PowerNetManager(this);
     this.powerNetGrid               = new PowerNetGrid(this);
     this.regionMaker                = new RegionMaker(this);
     this.pathFinder                 = new PathFinder(this);
     this.pawnPathPool               = new PawnPathPool(this);
     this.regionAndRoomUpdater       = new RegionAndRoomUpdater(this);
     this.regionLinkDatabase         = new RegionLinkDatabase();
     this.moteCounter                = new MoteCounter();
     this.gatherSpotLister           = new GatherSpotLister();
     this.windManager                = new WindManager(this);
     this.listerBuildingsRepairable  = new ListerBuildingsRepairable();
     this.listerHaulables            = new ListerHaulables(this);
     this.listerMergeables           = new ListerMergeables(this);
     this.listerFilthInHomeArea      = new ListerFilthInHomeArea(this);
     this.reachability               = new Reachability(this);
     this.itemAvailability           = new ItemAvailability(this);
     this.autoBuildRoofAreaSetter    = new AutoBuildRoofAreaSetter(this);
     this.roofCollapseBufferResolver = new RoofCollapseBufferResolver(this);
     this.roofCollapseBuffer         = new RoofCollapseBuffer();
     this.wildAnimalSpawner          = new WildAnimalSpawner(this);
     this.wildPlantSpawner           = new WildPlantSpawner(this);
     this.steadyEnvironmentEffects   = new SteadyEnvironmentEffects(this);
     this.skyManager                 = new SkyManager(this);
     this.overlayDrawer              = new OverlayDrawer();
     this.floodFiller                = new FloodFiller(this);
     this.weatherDecider             = new WeatherDecider(this);
     this.fireWatcher                = new FireWatcher(this);
     this.dangerWatcher              = new DangerWatcher(this);
     this.damageWatcher              = new DamageWatcher();
     this.strengthWatcher            = new StrengthWatcher(this);
     this.wealthWatcher              = new WealthWatcher(this);
     this.regionDirtyer              = new RegionDirtyer(this);
     this.cellsInRandomOrder         = new MapCellsInRandomOrder(this);
     this.rememberedCameraPos        = new RememberedCameraPos(this);
     this.mineStrikeManager          = new MineStrikeManager();
     this.storyState                 = new StoryState(this);
     this.retainedCaravanData        = new RetainedCaravanData(this);
     this.components.Clear();
     this.FillComponents();
 }
Пример #10
0
        /// <summary>
        /// Только для своих объетков
        /// </summary>
        public static WorldObjectEntry GetWorldObjectEntry(WorldObject worldObject)
        {
            var worldObjectEntry = new WorldObjectEntry();

            worldObjectEntry.Type       = worldObject is Caravan ? WorldObjectEntryType.Caravan : WorldObjectEntryType.Base;
            worldObjectEntry.Tile       = worldObject.Tile;
            worldObjectEntry.Name       = worldObject.LabelCap;
            worldObjectEntry.LoginOwner = SessionClientController.My.Login;
            worldObjectEntry.FreeWeight = 999999;

            //определяем цену и вес
            var caravan = worldObject as Caravan;

            if (caravan != null)
            {
                var transferables = CalculateTransferables(caravan);

                List <ThingCount> stackParts = new List <ThingCount>();
                for (int i = 0; i < transferables.Count; i++)
                {
                    TransferableUtility.TransferNoSplit(transferables[i].things, transferables[i].MaxCount /*CountToTransfer*/, delegate(Thing originalThing, int toTake)
                    {
                        stackParts.Add(new ThingCount(originalThing, toTake));
                    }, false, false);
                }
                worldObjectEntry.FreeWeight = CollectionsMassCalculator.Capacity(stackParts)
                                              - CollectionsMassCalculator.MassUsage(stackParts, IgnorePawnsInventoryMode.Ignore, false, false);

                worldObjectEntry.MarketValue     = 0f;
                worldObjectEntry.MarketValuePawn = 0f;
                for (int i = 0; i < stackParts.Count; i++)
                {
                    int count = stackParts[i].Count;

                    if (count > 0)
                    {
                        Thing thing = stackParts[i].Thing;
                        if (thing is Pawn)
                        {
                            worldObjectEntry.MarketValuePawn += thing.MarketValue
                                                                + WealthWatcher.GetEquipmentApparelAndInventoryWealth(thing as Pawn);
                        }
                        else
                        {
                            worldObjectEntry.MarketValue += thing.MarketValue * (float)count;
                        }
                    }
                }
            }
            else if (worldObject is Settlement)
            {
                var map = (worldObject as Settlement).Map;
                if (map != null)
                {
                    worldObjectEntry.MarketValue = map.wealthWatcher.WealthTotal;

                    worldObjectEntry.MarketValuePawn = 0;
                    foreach (Pawn current in map.mapPawns.FreeColonists)
                    {
                        worldObjectEntry.MarketValuePawn += current.MarketValue;
                    }
                    //Loger.Log("Map things "+ worldObjectEntry.MarketValue + " pawns " + worldObjectEntry.MarketValuePawn);
                }
            }

            WorldObjectEntry storeWO;

            if (MyWorldObjectEntry.TryGetValue(worldObject.ID, out storeWO))
            {
                //если серверу приходит объект без данного ServerId, значит это наш новый объект (кроме первого запроса, т.к. не было ещё загрузки)
                worldObjectEntry.ServerId = storeWO.ServerId;
            }

            return(worldObjectEntry);
        }
Пример #11
0
 private static void DoPlayLoad()
 {
     GraphicDatabase.Clear();
     DeepProfiler.Start("Load all active mods.");
     try
     {
         LoadedModManager.LoadAllActiveMods();
     }
     finally
     {
         DeepProfiler.End();
     }
     DeepProfiler.Start("Load language metadata.");
     try
     {
         LanguageDatabase.LoadAllMetadata();
     }
     finally
     {
         DeepProfiler.End();
     }
     LongEventHandler.SetCurrentEventText("LoadingDefs".Translate());
     DeepProfiler.Start("Copy all Defs from mods to global databases.");
     try
     {
         foreach (Type item in typeof(Def).AllSubclasses())
         {
             GenGeneric.InvokeStaticMethodOnGenericType(typeof(DefDatabase <>), item, "AddAllInMods");
         }
     }
     finally
     {
         DeepProfiler.End();
     }
     DeepProfiler.Start("Resolve cross-references between non-implied Defs.");
     try
     {
         DirectXmlCrossRefLoader.ResolveAllWantedCrossReferences(FailMode.Silent);
     }
     finally
     {
         DeepProfiler.End();
     }
     DeepProfiler.Start("Rebind defs (early).");
     try
     {
         DefOfHelper.RebindAllDefOfs(earlyTryMode: true);
     }
     finally
     {
         DeepProfiler.End();
     }
     DeepProfiler.Start("Inject selected language data into game data (early pass).");
     try
     {
         LanguageDatabase.activeLanguage.InjectIntoData_BeforeImpliedDefs();
     }
     finally
     {
         DeepProfiler.End();
     }
     DeepProfiler.Start("Generate implied Defs (pre-resolve).");
     try
     {
         DefGenerator.GenerateImpliedDefs_PreResolve();
     }
     finally
     {
         DeepProfiler.End();
     }
     DeepProfiler.Start("Resolve cross-references between Defs made by the implied defs.");
     try
     {
         DirectXmlCrossRefLoader.ResolveAllWantedCrossReferences(FailMode.LogErrors);
     }
     finally
     {
         DeepProfiler.End();
     }
     DeepProfiler.Start("Rebind DefOfs (final).");
     try
     {
         DefOfHelper.RebindAllDefOfs(earlyTryMode: false);
     }
     finally
     {
         DeepProfiler.End();
     }
     DeepProfiler.Start("Other def binding, resetting and global operations (pre-resolve).");
     try
     {
         PlayerKnowledgeDatabase.ReloadAndRebind();
         LessonAutoActivator.Reset();
         CostListCalculator.Reset();
         Pawn.ResetStaticData();
         PawnApparelGenerator.Reset();
         RestUtility.Reset();
         ThoughtUtility.Reset();
         PawnWeaponGenerator.Reset();
         ThinkTreeKeyAssigner.Reset();
         ThingCategoryNodeDatabase.FinalizeInit();
         TrainableUtility.Reset();
         HaulAIUtility.Reset();
         GenConstruct.Reset();
         MedicalCareUtility.Reset();
         InspectPaneUtility.Reset();
         GraphicDatabaseHeadRecords.Reset();
         DateReadout.Reset();
         ResearchProjectDef.GenerateNonOverlappingCoordinates();
         BaseGen.Reset();
         ResourceCounter.ResetDefs();
         ApparelProperties.ResetStaticData();
         WildPlantSpawner.ResetStaticData();
         PawnGenerator.Reset();
         TunnelHiveSpawner.ResetStaticData();
         Hive.ResetStaticData();
         ExpectationsUtility.Reset();
         WealthWatcher.ResetStaticData();
         SkillUI.Reset();
         WorkGiver_FillFermentingBarrel.ResetStaticData();
         WorkGiver_DoBill.ResetStaticData();
         WorkGiver_InteractAnimal.ResetStaticData();
         WorkGiver_Warden_DoExecution.ResetStaticData();
         WorkGiver_GrowerSow.ResetStaticData();
         WorkGiver_Miner.ResetStaticData();
         WorkGiver_FixBrokenDownBuilding.ResetStaticData();
         WorkGiver_ConstructDeliverResources.ResetStaticData();
     }
     finally
     {
         DeepProfiler.End();
     }
     DeepProfiler.Start("Resolve references.");
     try
     {
         foreach (Type item2 in typeof(Def).AllSubclasses())
         {
             if (item2 != typeof(ThingDef))
             {
                 GenGeneric.InvokeStaticMethodOnGenericType(typeof(DefDatabase <>), item2, "ResolveAllReferences", true);
             }
         }
         DefDatabase <ThingDef> .ResolveAllReferences();
     }
     finally
     {
         DeepProfiler.End();
     }
     DeepProfiler.Start("Generate implied Defs (post-resolve).");
     try
     {
         DefGenerator.GenerateImpliedDefs_PostResolve();
     }
     finally
     {
         DeepProfiler.End();
     }
     DeepProfiler.Start("Other def binding, resetting and global operations (post-resolve).");
     try
     {
         BuildingProperties.FinalizeInit();
         ThingSetMakerUtility.Reset();
     }
     finally
     {
         DeepProfiler.End();
     }
     if (Prefs.DevMode)
     {
         DeepProfiler.Start("Error check all defs.");
         try
         {
             foreach (Type item3 in typeof(Def).AllSubclasses())
             {
                 GenGeneric.InvokeStaticMethodOnGenericType(typeof(DefDatabase <>), item3, "ErrorCheckAllDefs");
             }
         }
         finally
         {
             DeepProfiler.End();
         }
     }
     LongEventHandler.SetCurrentEventText("Initializing".Translate());
     DeepProfiler.Start("Load keyboard preferences.");
     try
     {
         KeyPrefs.Init();
     }
     finally
     {
         DeepProfiler.End();
     }
     DeepProfiler.Start("Short hash giving.");
     try
     {
         ShortHashGiver.GiveAllShortHashes();
     }
     finally
     {
         DeepProfiler.End();
     }
     LongEventHandler.ExecuteWhenFinished(delegate
     {
         DeepProfiler.Start("Load backstories.");
         try
         {
             BackstoryDatabase.ReloadAllBackstories();
         }
         finally
         {
             DeepProfiler.End();
         }
     });
     LongEventHandler.ExecuteWhenFinished(delegate
     {
         DeepProfiler.Start("Inject selected language data into game data.");
         try
         {
             LanguageDatabase.activeLanguage.InjectIntoData_AfterImpliedDefs();
             GenLabel.ClearCache();
         }
         finally
         {
             DeepProfiler.End();
         }
     });
     LongEventHandler.ExecuteWhenFinished(delegate
     {
         StaticConstructorOnStartupUtility.CallAll();
         if (Prefs.DevMode)
         {
             StaticConstructorOnStartupUtility.ReportProbablyMissingAttributes();
         }
     });
 }
Пример #12
0
        /// <summary>
        /// Только для своих объетков
        /// </summary>
        public static WorldObjectEntry GetWorldObjectEntry(WorldObject worldObject
                                                           , PlayerGameProgress gameProgress
                                                           , Dictionary <Map, List <Pawn> > cacheColonists)
        {
            var worldObjectEntry = new WorldObjectEntry();

            worldObjectEntry.Type       = worldObject is Caravan ? WorldObjectEntryType.Caravan : WorldObjectEntryType.Base;
            worldObjectEntry.Tile       = worldObject.Tile;
            worldObjectEntry.Name       = worldObject.LabelCap;
            worldObjectEntry.LoginOwner = SessionClientController.My.Login;
            worldObjectEntry.FreeWeight = 999999;

            //определяем цену и вес
            var caravan = worldObject as Caravan;

            if (caravan != null)
            {
                //Loger.Log("Client TestBagSD 002");
                var transferables = CalculateTransferables(caravan);
                //Loger.Log("Client TestBagSD 003");

                List <ThingCount> stackParts = new List <ThingCount>();
                for (int i = 0; i < transferables.Count; i++)
                {
                    TransferableUtility.TransferNoSplit(transferables[i].things, transferables[i].MaxCount /*CountToTransfer*/, delegate(Thing originalThing, int toTake)
                    {
                        stackParts.Add(new ThingCount(originalThing, toTake));
                    }, false, false);
                }
                //Loger.Log("Client TestBagSD 004");
                worldObjectEntry.FreeWeight = CollectionsMassCalculator.Capacity(stackParts)
                                              - CollectionsMassCalculator.MassUsage(stackParts, IgnorePawnsInventoryMode.Ignore, false, false);
                //Loger.Log("Client TestBagSD 005");

                worldObjectEntry.MarketValue     = 0f;
                worldObjectEntry.MarketValuePawn = 0f;
                for (int i = 0; i < stackParts.Count; i++)
                {
                    int count = stackParts[i].Count;

                    if (count > 0)
                    {
                        Thing thing = stackParts[i].Thing;
                        if (thing is Pawn)
                        {
                            worldObjectEntry.MarketValuePawn += thing.MarketValue
                                                                + WealthWatcher.GetEquipmentApparelAndInventoryWealth(thing as Pawn);
                            GameProgressAdd(gameProgress, thing as Pawn);
                        }
                        else
                        {
                            worldObjectEntry.MarketValue += thing.MarketValue * (float)count;
                        }
                    }
                }
                //Loger.Log("Client TestBagSD 006");
            }
            else if (worldObject is Settlement)
            {
                //Loger.Log("Client TestBagSD 007");
                var map = (worldObject as Settlement).Map;
                if (map != null)
                {
                    //Loger.Log("Client TestBagSD 008");
                    try
                    {
                        DateTime lastForceRecount;
                        if (!LastForceRecount.TryGetValue(map.uniqueID, out lastForceRecount))
                        {
                            LastForceRecount.Add(map.uniqueID, DateTime.UtcNow.AddSeconds(new Random(map.uniqueID * 7).Next(0, 10)));
                        }
                        else if ((DateTime.UtcNow - lastForceRecount).TotalSeconds > 30)
                        {
                            LastForceRecount[map.uniqueID] = DateTime.UtcNow;
                            ModBaseData.RunMainThread(() =>
                            {
                                map.wealthWatcher.ForceRecount();
                            });
                        }
                        worldObjectEntry.MarketValue = map.wealthWatcher.WealthTotal;
                    }
                    catch
                    {
                        Thread.Sleep(100);
                        try
                        {
                            worldObjectEntry.MarketValue = map.wealthWatcher.WealthTotal;
                        }
                        catch
                        {
                        }
                    }

                    worldObjectEntry.MarketValuePawn = 0;

                    //Loger.Log("Client TestBagSD 015");
                    List <Pawn> ps;
                    if (!cacheColonists.TryGetValue(map, out ps))
                    {
                        var mapPawnsA = new Pawn[map.mapPawns.AllPawnsSpawned.Count];
                        map.mapPawns.AllPawnsSpawned.CopyTo(mapPawnsA);

                        ps = mapPawnsA.Where(p => p.Faction == Faction.OfPlayer && p.RaceProps.Humanlike).ToList();
                        cacheColonists[map] = ps;
                    }

                    //Loger.Log("Client TestBagSD 016");
                    foreach (Pawn current in ps)
                    {
                        worldObjectEntry.MarketValuePawn += current.MarketValue;

                        GameProgressAdd(gameProgress, current);
                    }
                    //Loger.Log("Client TestBagSD 017");
                    //Loger.Log("Map things "+ worldObjectEntry.MarketValue + " pawns " + worldObjectEntry.MarketValuePawn);
                }
            }
            //Loger.Log("Client TestBagSD 018");

            WorldObjectEntry storeWO;

            if (WorldObjectEntrys.TryGetValue(worldObject.ID, out storeWO))
            {
                //если серверу приходит объект без данного ServerId, значит это наш новый объект (кроме первого запроса, т.к. не было ещё загрузки)
                worldObjectEntry.ServerId = storeWO.ServerId;
            }
            //Loger.Log("Client TestBagSD 019");

            return(worldObjectEntry);
        }