public void FillSlots()
 {
     m_subsystemFurnitureBlockBehavior.GarbageCollectDesigns();
     m_slots.Clear();
     for (int i = 0; i < maxDesign; i++)
     {
         FurnitureDesign design = m_subsystemFurnitureBlockBehavior.GetDesign(i);
         if (design != null)
         {
             int num = (from f in design.ListChain()
                        select f.Index).Min();
             if (design.Index == num)
             {
                 int data = FurnitureBlock.SetDesignIndex(0, i, design.ShadowStrengthFactor, design.IsLightEmitter);
                 int item = Terrain.MakeBlockValue(227, 0, data);
                 m_slots.Add(item);
             }
         }
     }
 }
Exemple #2
0
        public void AssignInventorySlots()
        {
            List <int> list = new List <int>();

            for (int i = 0; i < ComponentFurnitureInventory.SlotsCount; i++)
            {
                int slotValue = ComponentFurnitureInventory.GetSlotValue(i);
                int slotCount = ComponentFurnitureInventory.GetSlotCount(i);
                if (slotValue != 0 && slotCount > 0 && Terrain.ExtractContents(slotValue) == 227)
                {
                    int             designIndex = FurnitureBlock.GetDesignIndex(Terrain.ExtractData(slotValue));
                    FurnitureDesign design      = SubsystemFurnitureBlockBehavior.GetDesign(designIndex);
                    if (design != null && design.FurnitureSet == ComponentFurnitureInventory.FurnitureSet)
                    {
                        list.Add(i);
                    }
                }
            }
            List <InventorySlotWidget> list2 = new List <InventorySlotWidget>((from w in m_inventoryGrid.Children
                                                                               select w as InventorySlotWidget into w
                                                                               where w != null
                                                                               select w).Cast <InventorySlotWidget>());
            int num = ComponentFurnitureInventory.PageIndex * list2.Count;

            for (int j = 0; j < list2.Count; j++)
            {
                if (num < list.Count)
                {
                    list2[j].AssignInventorySlot(ComponentFurnitureInventory, list[num]);
                }
                else
                {
                    list2[j].AssignInventorySlot(null, 0);
                }
                num++;
            }
            m_pagesCount   = (list.Count + list2.Count - 1) / list2.Count;
            m_assignedPage = ComponentFurnitureInventory.PageIndex;
        }
Exemple #3
0
        public GameMenuDialog(ComponentPlayer componentPlayer)
        {
            XElement node = ContentManager.Get <XElement>("Dialogs/GameMenuDialog");

            LoadContents(this, node);
            m_statsPanel             = Children.Find <StackPanelWidget>("StatsPanel");
            m_componentPlayer        = componentPlayer;
            m_adventureRestartExists = WorldsManager.SnapshotExists(GameManager.WorldInfo.DirectoryName, "AdventureRestart");
            if (!m_increaseDetailDialogShown && PerformanceManager.LongTermAverageFrameTime.HasValue && PerformanceManager.LongTermAverageFrameTime.Value * 1000f < 25f && (SettingsManager.VisibilityRange <= 64 || SettingsManager.ResolutionMode == ResolutionMode.Low))
            {
                m_increaseDetailDialogShown = true;
                DialogsManager.ShowDialog(base.ParentWidget, new MessageDialog(LanguageControl.Get(fName, 1), LanguageControl.Get(fName, 2), LanguageControl.Get("Usual", "ok"), null, null));
                AnalyticsManager.LogEvent("[GameMenuScreen] IncreaseDetailDialog Shown");
            }
            if (!m_decreaseDetailDialogShown && PerformanceManager.LongTermAverageFrameTime.HasValue && PerformanceManager.LongTermAverageFrameTime.Value * 1000f > 50f && (SettingsManager.VisibilityRange >= 64 || SettingsManager.ResolutionMode == ResolutionMode.High))
            {
                m_decreaseDetailDialogShown = true;
                DialogsManager.ShowDialog(base.ParentWidget, new MessageDialog(LanguageControl.Get(fName, 3), LanguageControl.Get(fName, 4), LanguageControl.Get("Usual", "ok"), null, null));
                AnalyticsManager.LogEvent("[GameMenuScreen] DecreaseDetailDialog Shown");
            }
            m_statsPanel.Children.Clear();
            Project           project           = componentPlayer.Project;
            PlayerData        playerData        = componentPlayer.PlayerData;
            PlayerStats       playerStats       = componentPlayer.PlayerStats;
            SubsystemGameInfo subsystemGameInfo = project.FindSubsystem <SubsystemGameInfo>(throwOnError: true);
            SubsystemFurnitureBlockBehavior subsystemFurnitureBlockBehavior = project.FindSubsystem <SubsystemFurnitureBlockBehavior>(throwOnError: true);
            BitmapFont       font             = ContentManager.Get <BitmapFont>("Fonts/Pericles");
            BitmapFont       font2            = ContentManager.Get <BitmapFont>("Fonts/Pericles");
            Color            white            = Color.White;
            StackPanelWidget stackPanelWidget = new StackPanelWidget
            {
                Direction           = LayoutDirection.Vertical,
                HorizontalAlignment = WidgetAlignment.Center
            };

            m_statsPanel.Children.Add(stackPanelWidget);
            stackPanelWidget.Children.Add(new LabelWidget
            {
                Text = LanguageControl.Get(fName, 5),
                Font = font,
                HorizontalAlignment = WidgetAlignment.Center,
                Margin = new Vector2(0f, 10f),
                Color  = white
            });
            AddStat(stackPanelWidget, LanguageControl.Get(fName, 6), LanguageControl.Get("GameMode", subsystemGameInfo.WorldSettings.GameMode.ToString()) + ", " + LanguageControl.Get("EnvironmentBehaviorMode", subsystemGameInfo.WorldSettings.EnvironmentBehaviorMode.ToString()));
            AddStat(stackPanelWidget, LanguageControl.Get(fName, 7), StringsManager.GetString("TerrainGenerationMode." + subsystemGameInfo.WorldSettings.TerrainGenerationMode.ToString() + ".Name"));
            string seed = subsystemGameInfo.WorldSettings.Seed;

            AddStat(stackPanelWidget, LanguageControl.Get(fName, 8), (!string.IsNullOrEmpty(seed)) ? seed : LanguageControl.Get(fName, 9));
            AddStat(stackPanelWidget, LanguageControl.Get(fName, 10), WorldOptionsScreen.FormatOffset(subsystemGameInfo.WorldSettings.SeaLevelOffset));
            AddStat(stackPanelWidget, LanguageControl.Get(fName, 11), WorldOptionsScreen.FormatOffset(subsystemGameInfo.WorldSettings.TemperatureOffset));
            AddStat(stackPanelWidget, LanguageControl.Get(fName, 12), WorldOptionsScreen.FormatOffset(subsystemGameInfo.WorldSettings.HumidityOffset));
            AddStat(stackPanelWidget, LanguageControl.Get(fName, 13), subsystemGameInfo.WorldSettings.BiomeSize.ToString() + "x");
            int num = 0;

            for (int i = 0; i < ComponentFurnitureInventory.maxDesign; i++)
            {
                if (subsystemFurnitureBlockBehavior.GetDesign(i) != null)
                {
                    num++;
                }
            }
            AddStat(stackPanelWidget, LanguageControl.Get(fName, 14), $"{num}/{ComponentFurnitureInventory.maxDesign}");
            AddStat(stackPanelWidget, LanguageControl.Get(fName, 15), string.IsNullOrEmpty(subsystemGameInfo.WorldSettings.OriginalSerializationVersion) ? LanguageControl.Get(fName, 16) : subsystemGameInfo.WorldSettings.OriginalSerializationVersion);
            stackPanelWidget.Children.Add(new LabelWidget
            {
                Text = LanguageControl.Get(fName, 17),
                Font = font,
                HorizontalAlignment = WidgetAlignment.Center,
                Margin = new Vector2(0f, 10f),
                Color  = white
            });
            AddStat(stackPanelWidget, LanguageControl.Get(fName, 18), playerData.Name);
            AddStat(stackPanelWidget, LanguageControl.Get(fName, 19), playerData.PlayerClass.ToString());
            string value = (playerData.FirstSpawnTime >= 0.0) ? (((subsystemGameInfo.TotalElapsedGameTime - playerData.FirstSpawnTime) / 1200.0).ToString("N1") + LanguageControl.Get(fName, 20)) : LanguageControl.Get(fName, 21);

            AddStat(stackPanelWidget, LanguageControl.Get(fName, 22), value);
            string value2 = (playerData.LastSpawnTime >= 0.0) ? (((subsystemGameInfo.TotalElapsedGameTime - playerData.LastSpawnTime) / 1200.0).ToString("N1") + LanguageControl.Get(fName, 23)) : LanguageControl.Get(fName, 24);

            AddStat(stackPanelWidget, LanguageControl.Get(fName, 25), value2);
            AddStat(stackPanelWidget, LanguageControl.Get(fName, 26), MathUtils.Max(playerData.SpawnsCount - 1, 0).ToString("N0") + LanguageControl.Get(fName, 27));
            AddStat(stackPanelWidget, LanguageControl.Get(fName, 28), string.Format(LanguageControl.Get(fName, 29), ((int)MathUtils.Floor(playerStats.HighestLevel)).ToString("N0")));
            if (componentPlayer != null)
            {
                Vector3 position = componentPlayer.ComponentBody.Position;
                if (subsystemGameInfo.WorldSettings.GameMode == GameMode.Creative)
                {
                    AddStat(stackPanelWidget, LanguageControl.Get(fName, 30), string.Format(LanguageControl.Get(fName, 31), $"{position.X:0}", $"{position.Z:0}", $"{position.Y:0}"));
                }
                else
                {
                    AddStat(stackPanelWidget, LanguageControl.Get(fName, 30), string.Format(LanguageControl.Get(fName, 32), LanguageControl.Get("GameMode", subsystemGameInfo.WorldSettings.GameMode.ToString())));
                }
            }
            if (string.CompareOrdinal(subsystemGameInfo.WorldSettings.OriginalSerializationVersion, "1.29") > 0)
            {
                stackPanelWidget.Children.Add(new LabelWidget
                {
                    Text = LanguageControl.Get(fName, 33),
                    Font = font,
                    HorizontalAlignment = WidgetAlignment.Center,
                    Margin = new Vector2(0f, 10f),
                    Color  = white
                });
                AddStat(stackPanelWidget, LanguageControl.Get(fName, 34), playerStats.PlayerKills.ToString("N0"));
                AddStat(stackPanelWidget, LanguageControl.Get(fName, 35), playerStats.LandCreatureKills.ToString("N0"));
                AddStat(stackPanelWidget, LanguageControl.Get(fName, 36), playerStats.WaterCreatureKills.ToString("N0"));
                AddStat(stackPanelWidget, LanguageControl.Get(fName, 37), playerStats.AirCreatureKills.ToString("N0"));
                AddStat(stackPanelWidget, LanguageControl.Get(fName, 38), playerStats.MeleeAttacks.ToString("N0"));
                AddStat(stackPanelWidget, LanguageControl.Get(fName, 39), playerStats.MeleeHits.ToString("N0"), $"({((playerStats.MeleeHits == 0L) ? 0.0 : ((double)playerStats.MeleeHits / (double)playerStats.MeleeAttacks * 100.0)):0}%)");
                AddStat(stackPanelWidget, LanguageControl.Get(fName, 40), playerStats.RangedAttacks.ToString("N0"));
                AddStat(stackPanelWidget, LanguageControl.Get(fName, 41), playerStats.RangedHits.ToString("N0"), $"({((playerStats.RangedHits == 0L) ? 0.0 : ((double)playerStats.RangedHits / (double)playerStats.RangedAttacks * 100.0)):0}%)");
                AddStat(stackPanelWidget, LanguageControl.Get(fName, 42), playerStats.HitsReceived.ToString("N0"));
                stackPanelWidget.Children.Add(new LabelWidget
                {
                    Text = LanguageControl.Get(fName, 43),
                    Font = font,
                    HorizontalAlignment = WidgetAlignment.Center,
                    Margin = new Vector2(0f, 10f),
                    Color  = white
                });
                AddStat(stackPanelWidget, LanguageControl.Get(fName, 44), playerStats.BlocksDug.ToString("N0"));
                AddStat(stackPanelWidget, LanguageControl.Get(fName, 45), playerStats.BlocksPlaced.ToString("N0"));
                AddStat(stackPanelWidget, LanguageControl.Get(fName, 46), playerStats.BlocksInteracted.ToString("N0"));
                AddStat(stackPanelWidget, LanguageControl.Get(fName, 47), playerStats.ItemsCrafted.ToString("N0"));
                AddStat(stackPanelWidget, LanguageControl.Get(fName, 48), playerStats.FurnitureItemsMade.ToString("N0"));
                stackPanelWidget.Children.Add(new LabelWidget
                {
                    Text = LanguageControl.Get(fName, 49),
                    Font = font,
                    HorizontalAlignment = WidgetAlignment.Center,
                    Margin = new Vector2(0f, 10f),
                    Color  = white
                });
                AddStat(stackPanelWidget, LanguageControl.Get(fName, 50), FormatDistance(playerStats.DistanceTravelled));
                AddStat(stackPanelWidget, LanguageControl.Get(fName, 51), FormatDistance(playerStats.DistanceWalked), $"({((playerStats.DistanceTravelled > 0.0) ? (playerStats.DistanceWalked / playerStats.DistanceTravelled * 100.0) : 0.0):0.0}%)");
                AddStat(stackPanelWidget, LanguageControl.Get(fName, 52), FormatDistance(playerStats.DistanceFallen), $"({((playerStats.DistanceTravelled > 0.0) ? (playerStats.DistanceFallen / playerStats.DistanceTravelled * 100.0) : 0.0):0.0}%)");
                AddStat(stackPanelWidget, LanguageControl.Get(fName, 53), FormatDistance(playerStats.DistanceClimbed), $"({((playerStats.DistanceTravelled > 0.0) ? (playerStats.DistanceClimbed / playerStats.DistanceTravelled * 100.0) : 0.0):0.0}%)");
                AddStat(stackPanelWidget, LanguageControl.Get(fName, 54), FormatDistance(playerStats.DistanceFlown), $"({((playerStats.DistanceTravelled > 0.0) ? (playerStats.DistanceFlown / playerStats.DistanceTravelled * 100.0) : 0.0):0.0}%)");
                AddStat(stackPanelWidget, LanguageControl.Get(fName, 55), FormatDistance(playerStats.DistanceSwam), $"({((playerStats.DistanceTravelled > 0.0) ? (playerStats.DistanceSwam / playerStats.DistanceTravelled * 100.0) : 0.0):0.0}%)");
                AddStat(stackPanelWidget, LanguageControl.Get(fName, 56), FormatDistance(playerStats.DistanceRidden), $"({((playerStats.DistanceTravelled > 0.0) ? (playerStats.DistanceRidden / playerStats.DistanceTravelled * 100.0) : 0.0):0.0}%)");
                AddStat(stackPanelWidget, LanguageControl.Get(fName, 57), FormatDistance(playerStats.LowestAltitude));
                AddStat(stackPanelWidget, LanguageControl.Get(fName, 58), FormatDistance(playerStats.HighestAltitude));
                AddStat(stackPanelWidget, LanguageControl.Get(fName, 59), playerStats.DeepestDive.ToString("N1") + "m");
                AddStat(stackPanelWidget, LanguageControl.Get(fName, 60), playerStats.Jumps.ToString("N0"));
                stackPanelWidget.Children.Add(new LabelWidget
                {
                    Text = LanguageControl.Get(fName, 61),
                    Font = font,
                    HorizontalAlignment = WidgetAlignment.Center,
                    Margin = new Vector2(0f, 10f),
                    Color  = white
                });
                AddStat(stackPanelWidget, LanguageControl.Get(fName, 62), (playerStats.TotalHealthLost * 100.0).ToString("N0") + "%");
                AddStat(stackPanelWidget, LanguageControl.Get(fName, 63), playerStats.FoodItemsEaten.ToString("N0") + LanguageControl.Get(fName, 64));
                AddStat(stackPanelWidget, LanguageControl.Get(fName, 65), playerStats.TimesWentToSleep.ToString("N0") + LanguageControl.Get(fName, 66));
                AddStat(stackPanelWidget, LanguageControl.Get(fName, 67), (playerStats.TimeSlept / 1200.0).ToString("N1") + LanguageControl.Get(fName, 68));
                AddStat(stackPanelWidget, LanguageControl.Get(fName, 69), playerStats.TimesWasSick.ToString("N0") + LanguageControl.Get(fName, 66));
                AddStat(stackPanelWidget, LanguageControl.Get(fName, 70), playerStats.TimesPuked.ToString("N0") + LanguageControl.Get(fName, 66));
                AddStat(stackPanelWidget, LanguageControl.Get(fName, 71), playerStats.TimesHadFlu.ToString("N0") + LanguageControl.Get(fName, 66));
                stackPanelWidget.Children.Add(new LabelWidget
                {
                    Text = LanguageControl.Get(fName, 72),
                    Font = font,
                    HorizontalAlignment = WidgetAlignment.Center,
                    Margin = new Vector2(0f, 10f),
                    Color  = white
                });
                AddStat(stackPanelWidget, LanguageControl.Get(fName, 73), playerStats.StruckByLightning.ToString("N0") + LanguageControl.Get(fName, 66));
                GameMode easiestModeUsed = playerStats.EasiestModeUsed;
                AddStat(stackPanelWidget, LanguageControl.Get(fName, 74), LanguageControl.Get("GameMode", easiestModeUsed.ToString()));
                if (playerStats.DeathRecords.Count > 0)
                {
                    stackPanelWidget.Children.Add(new LabelWidget
                    {
                        Text = LanguageControl.Get(fName, 75),
                        Font = font,
                        HorizontalAlignment = WidgetAlignment.Center,
                        Margin = new Vector2(0f, 10f),
                        Color  = white
                    });
                    foreach (PlayerStats.DeathRecord deathRecord in playerStats.DeathRecords)
                    {
                        float  num2 = (float)MathUtils.Remainder(deathRecord.Day, 1.0);
                        string arg  = (!(num2 < 0.2f) && !(num2 >= 0.8f)) ? ((!(num2 >= 0.7f)) ? ((!(num2 >= 0.5f)) ? LanguageControl.Get(fName, 76) : LanguageControl.Get(fName, 77)) : LanguageControl.Get(fName, 78)) : LanguageControl.Get(fName, 79);
                        AddStat(stackPanelWidget, string.Format(LanguageControl.Get(fName, 80), MathUtils.Floor(deathRecord.Day) + 1.0, arg), "", deathRecord.Cause);
                    }
                }
            }
            else
            {
                stackPanelWidget.Children.Add(new LabelWidget
                {
                    Text                = LanguageControl.Get(fName, 81),
                    WordWrap            = true,
                    Font                = font2,
                    HorizontalAlignment = WidgetAlignment.Center,
                    TextAnchor          = TextAnchor.HorizontalCenter,
                    Margin              = new Vector2(20f, 10f),
                    Color               = white
                });
            }
        }
Exemple #4
0
        public static FurnitureDesign GetDesign(SubsystemFurnitureBlockBehavior subsystemFurnitureBlockBehavior, int value)
        {
            int designIndex = GetDesignIndex(Terrain.ExtractData(value));

            return(subsystemFurnitureBlockBehavior.GetDesign(designIndex));
        }