public override void Load(ValuesDictionary valuesDictionary, IdToEntityMap idToEntityMap)
        {
            m_subsystemFurnitureBlockBehavior = base.Project.FindSubsystem <SubsystemFurnitureBlockBehavior>(throwOnError: true);
            string furnitureSetName = valuesDictionary.GetValue <string>("FurnitureSet");

            FurnitureSet = m_subsystemFurnitureBlockBehavior.FurnitureSets.FirstOrDefault((FurnitureSet f) => f.Name == furnitureSetName);
        }
Exemplo n.º 2
0
        public IEnumerable <ActiveExternalContentInfo> GetActiveExternalContent()
        {
            string downloadedContentAddress = CommunityContentManager.GetDownloadedContentAddress(ExternalContentType.World, DirectoryName);

            if (!string.IsNullOrEmpty(downloadedContentAddress))
            {
                yield return(new ActiveExternalContentInfo
                {
                    Address = downloadedContentAddress,
                    DisplayName = WorldSettings.Name,
                    Type = ExternalContentType.World
                });
            }
            if (!BlocksTexturesManager.IsBuiltIn(WorldSettings.BlocksTextureName))
            {
                downloadedContentAddress = CommunityContentManager.GetDownloadedContentAddress(ExternalContentType.BlocksTexture, WorldSettings.BlocksTextureName);
                if (!string.IsNullOrEmpty(downloadedContentAddress))
                {
                    yield return(new ActiveExternalContentInfo
                    {
                        Address = downloadedContentAddress,
                        DisplayName = BlocksTexturesManager.GetDisplayName(WorldSettings.BlocksTextureName),
                        Type = ExternalContentType.BlocksTexture
                    });
                }
            }
            SubsystemPlayers subsystemPlayers = base.Project.FindSubsystem <SubsystemPlayers>(throwOnError: true);

            foreach (PlayerData playersDatum in subsystemPlayers.PlayersData)
            {
                if (!CharacterSkinsManager.IsBuiltIn(playersDatum.CharacterSkinName))
                {
                    downloadedContentAddress = CommunityContentManager.GetDownloadedContentAddress(ExternalContentType.CharacterSkin, playersDatum.CharacterSkinName);
                    yield return(new ActiveExternalContentInfo
                    {
                        Address = downloadedContentAddress,
                        DisplayName = CharacterSkinsManager.GetDisplayName(playersDatum.CharacterSkinName),
                        Type = ExternalContentType.CharacterSkin
                    });
                }
            }
            SubsystemFurnitureBlockBehavior subsystemFurnitureBlockBehavior = base.Project.FindSubsystem <SubsystemFurnitureBlockBehavior>(throwOnError: true);

            foreach (FurnitureSet furnitureSet in subsystemFurnitureBlockBehavior.FurnitureSets)
            {
                if (furnitureSet.ImportedFrom != null)
                {
                    downloadedContentAddress = CommunityContentManager.GetDownloadedContentAddress(ExternalContentType.FurniturePack, furnitureSet.ImportedFrom);
                    yield return(new ActiveExternalContentInfo
                    {
                        Address = downloadedContentAddress,
                        DisplayName = FurniturePacksManager.GetDisplayName(furnitureSet.ImportedFrom),
                        Type = ExternalContentType.FurniturePack
                    });
                }
            }
        }
Exemplo n.º 3
0
        public void MoveFurnitureSet(int move)
        {
            FurnitureSet furnitureSet = m_furnitureSetList.SelectedItem as FurnitureSet;

            if (furnitureSet != null)
            {
                SubsystemFurnitureBlockBehavior.MoveFurnitureSet(furnitureSet, move);
                Invalidate();
            }
        }
Exemplo n.º 4
0
 public void ExportFurnitureSet()
 {
     try
     {
         FurnitureDesign[] designs     = SubsystemFurnitureBlockBehavior.GetFurnitureSetDesigns(ComponentFurnitureInventory.FurnitureSet).ToArray();
         string            displayName = FurniturePacksManager.GetDisplayName(FurniturePacksManager.CreateFurniturePack(ComponentFurnitureInventory.FurnitureSet.Name, designs));
         DialogsManager.ShowDialog(m_componentPlayer.GuiWidget, new MessageDialog(LanguageControl.Get(fName, 21), string.Format(LanguageControl.Get(fName, 22), displayName), LanguageControl.Get("Usual", "ok"), null, null));
     }
     catch (Exception ex)
     {
         DialogsManager.ShowDialog(m_componentPlayer.GuiWidget, new MessageDialog(LanguageControl.Get(fName, 23), ex.Message, LanguageControl.Get("Usual", "ok"), null, null));
     }
 }
Exemplo n.º 5
0
        public void DeleteFurnitureSet()
        {
            FurnitureSet furnitureSet = m_furnitureSetList.SelectedItem as FurnitureSet;

            if (furnitureSet != null)
            {
                int num = SubsystemFurnitureBlockBehavior.FurnitureSets.IndexOf(furnitureSet);
                SubsystemFurnitureBlockBehavior.DeleteFurnitureSet(furnitureSet);
                SubsystemFurnitureBlockBehavior.GarbageCollectDesigns();
                ComponentFurnitureInventory.FurnitureSet = ((num > 0) ? SubsystemFurnitureBlockBehavior.FurnitureSets[num - 1] : null);
                Invalidate();
            }
        }
Exemplo n.º 6
0
        public void NewFurnitureSet()
        {
            ComponentPlayer componentPlayer = ComponentFurnitureInventory.Entity.FindComponent <ComponentPlayer>(throwOnError: true);

            base.Input.EnterText(componentPlayer.GuiWidget, LanguageControl.Get(fName, 15), LanguageControl.Get(fName, 16), 20, delegate(string s)
            {
                if (s != null)
                {
                    FurnitureSet furnitureSet = SubsystemFurnitureBlockBehavior.NewFurnitureSet(s, null);
                    ComponentFurnitureInventory.FurnitureSet = furnitureSet;
                    Populate();
                    m_furnitureSetList.ScrollToItem(furnitureSet);
                }
            });
        }
        public static string CreateFurniturePack(string name, ICollection <FurnitureDesign> designs)
        {
            MemoryStream memoryStream = new MemoryStream();

            using (ZipArchive zipArchive = ZipArchive.Create(memoryStream, keepStreamOpen: true))
            {
                ValuesDictionary valuesDictionary = new ValuesDictionary();
                SubsystemFurnitureBlockBehavior.SaveFurnitureDesigns(valuesDictionary, designs);
                XElement xElement = new XElement("FurnitureDesigns");
                valuesDictionary.Save(xElement);
                MemoryStream memoryStream2 = new MemoryStream();
                xElement.Save((Stream)memoryStream2);
                memoryStream2.Position = 0L;
                zipArchive.AddStream("FurnitureDesigns.xml", memoryStream2);
            }
            memoryStream.Position = 0L;
            return(ImportFurniturePack(name, memoryStream));
        }
 public static List <FurnitureDesign> LoadFurniturePack(SubsystemTerrain subsystemTerrain, Stream stream)
 {
     using (ZipArchive zipArchive = ZipArchive.Open(stream, keepStreamOpen: true))
     {
         List <ZipArchiveEntry> list = zipArchive.ReadCentralDir();
         if (list.Count != 1 || list[0].FilenameInZip != "FurnitureDesigns.xml")
         {
             throw new InvalidOperationException("Invalid furniture pack.");
         }
         MemoryStream memoryStream = new MemoryStream();
         zipArchive.ExtractFile(list[0], memoryStream);
         memoryStream.Position = 0L;
         XElement         overridesNode    = XElement.Load((Stream)memoryStream);
         ValuesDictionary valuesDictionary = new ValuesDictionary();
         valuesDictionary.ApplyOverrides(overridesNode);
         return(SubsystemFurnitureBlockBehavior.LoadFurnitureDesigns(subsystemTerrain, valuesDictionary));
     }
 }
Exemplo n.º 9
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;
        }
Exemplo n.º 10
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
                });
            }
        }
Exemplo n.º 11
0
 public override void Update()
 {
     if (m_populateNeeded)
     {
         Populate();
         m_populateNeeded = false;
     }
     if (ComponentFurnitureInventory.PageIndex != m_assignedPage)
     {
         AssignInventorySlots();
     }
     m_creativeInventoryWidget.PageUpButton.IsEnabled   = (ComponentFurnitureInventory.PageIndex > 0);
     m_creativeInventoryWidget.PageDownButton.IsEnabled = (ComponentFurnitureInventory.PageIndex < m_pagesCount - 1);
     m_creativeInventoryWidget.PageLabel.Text           = ((m_pagesCount > 0) ? $"{ComponentFurnitureInventory.PageIndex + 1}/{m_pagesCount}" : string.Empty);
     m_moreButton.IsEnabled = (ComponentFurnitureInventory.FurnitureSet != null);
     if (base.Input.Scroll.HasValue && HitTestGlobal(base.Input.Scroll.Value.XY).IsChildWidgetOf(m_inventoryGrid))
     {
         ComponentFurnitureInventory.PageIndex -= (int)base.Input.Scroll.Value.Z;
     }
     if (m_creativeInventoryWidget.PageUpButton.IsClicked)
     {
         int num = --ComponentFurnitureInventory.PageIndex;
     }
     if (m_creativeInventoryWidget.PageDownButton.IsClicked)
     {
         int num = ++ComponentFurnitureInventory.PageIndex;
     }
     ComponentFurnitureInventory.PageIndex = ((m_pagesCount > 0) ? MathUtils.Clamp(ComponentFurnitureInventory.PageIndex, 0, m_pagesCount - 1) : 0);
     if (m_addButton.IsClicked)
     {
         List <Tuple <string, Action> > list = new List <Tuple <string, Action> >();
         list.Add(new Tuple <string, Action>(LanguageControl.Get(fName, 6), delegate
         {
             if (SubsystemFurnitureBlockBehavior.FurnitureSets.Count < 32)
             {
                 NewFurnitureSet();
             }
             else
             {
                 DialogsManager.ShowDialog(m_componentPlayer.GuiWidget, new MessageDialog(LanguageControl.Get(fName, 24), LanguageControl.Get(fName, 25), LanguageControl.Get("Usual", "ok"), null, null));
             }
         }));
         list.Add(new Tuple <string, Action>(LanguageControl.Get(fName, 7), delegate
         {
             ImportFurnitureSet(SubsystemTerrain);
         }));
         DialogsManager.ShowDialog(m_componentPlayer.GuiWidget, new ListSelectionDialog(LanguageControl.Get(fName, 8), list, 64f, (object t) => ((Tuple <string, Action>) t).Item1, delegate(object t)
         {
             ((Tuple <string, Action>)t).Item2();
         }));
     }
     if (m_moreButton.IsClicked && ComponentFurnitureInventory.FurnitureSet != null)
     {
         List <Tuple <string, Action> > list2 = new List <Tuple <string, Action> >();
         list2.Add(new Tuple <string, Action>(LanguageControl.Get(fName, 9), delegate
         {
             RenameFurnitureSet();
         }));
         list2.Add(new Tuple <string, Action>(LanguageControl.Get(fName, 28), delegate
         {
             if (SubsystemFurnitureBlockBehavior.GetFurnitureSetDesigns(ComponentFurnitureInventory.FurnitureSet).Count() > 0)
             {
                 DialogsManager.ShowDialog(m_componentPlayer.GuiWidget, new MessageDialog(LanguageControl.Get("Usual", "warning"), LanguageControl.Get(fName, 26), LanguageControl.Get(fName, 27), LanguageControl.Get(fName, 28), delegate(MessageDialogButton b)
                 {
                     if (b == MessageDialogButton.Button1)
                     {
                         DeleteFurnitureSet();
                     }
                 }));
             }
             else
             {
                 DeleteFurnitureSet();
             }
         }));
         list2.Add(new Tuple <string, Action>(LanguageControl.Get(fName, 11), delegate
         {
             MoveFurnitureSet(-1);
         }));
         list2.Add(new Tuple <string, Action>(LanguageControl.Get(fName, 12), delegate
         {
             MoveFurnitureSet(1);
         }));
         list2.Add(new Tuple <string, Action>(LanguageControl.Get(fName, 13), delegate
         {
             ExportFurnitureSet();
         }));
         DialogsManager.ShowDialog(m_componentPlayer.GuiWidget, new ListSelectionDialog(LanguageControl.Get(fName, 14), list2, 64f, (object t) => ((Tuple <string, Action>) t).Item1, delegate(object t)
         {
             ((Tuple <string, Action>)t).Item2();
         }));
     }
 }
Exemplo n.º 12
0
 public void ImportFurnitureSet(SubsystemTerrain subsystemTerrain)
 {
     FurniturePacksManager.UpdateFurniturePacksList();
     if (FurniturePacksManager.FurniturePackNames.Count() == 0)
     {
         DialogsManager.ShowDialog(m_componentPlayer.GuiWidget, new MessageDialog(LanguageControl.Get(fName, 18), LanguageControl.Get(fName, 19), LanguageControl.Get("Usual", "ok"), null, null));
     }
     else
     {
         DialogsManager.ShowDialog(m_componentPlayer.GuiWidget, new ListSelectionDialog(LanguageControl.Get(fName, 20), FurniturePacksManager.FurniturePackNames, 64f, (object s) => FurniturePacksManager.GetDisplayName((string)s), delegate(object s)
         {
             try
             {
                 int num     = 0;
                 int num2    = 0;
                 string text = (string)s;
                 List <List <FurnitureDesign> > list = FurnitureDesign.ListChains(FurniturePacksManager.LoadFurniturePack(subsystemTerrain, text));
                 List <FurnitureDesign> list2        = new List <FurnitureDesign>();
                 SubsystemFurnitureBlockBehavior.GarbageCollectDesigns();
                 foreach (List <FurnitureDesign> item in list)
                 {
                     FurnitureDesign furnitureDesign = SubsystemFurnitureBlockBehavior.TryAddDesignChain(item[0], garbageCollectIfNeeded: false);
                     if (furnitureDesign == item[0])
                     {
                         list2.Add(furnitureDesign);
                     }
                     else if (furnitureDesign == null)
                     {
                         num2++;
                     }
                     else
                     {
                         num++;
                     }
                 }
                 if (list2.Count > 0)
                 {
                     FurnitureSet furnitureSet = SubsystemFurnitureBlockBehavior.NewFurnitureSet(FurniturePacksManager.GetDisplayName(text), text);
                     foreach (FurnitureDesign item2 in list2)
                     {
                         SubsystemFurnitureBlockBehavior.AddToFurnitureSet(item2, furnitureSet);
                     }
                     ComponentFurnitureInventory.FurnitureSet = furnitureSet;
                 }
                 Invalidate();
                 string text2 = string.Format(LanguageControl.Get(fName, 1), list2.Count);
                 if (num > 0)
                 {
                     text2 += string.Format(LanguageControl.Get(fName, 2), num);
                 }
                 if (num2 > 0)
                 {
                     text2 += string.Format(LanguageControl.Get(fName, 3), num2, 65535);
                 }
                 DialogsManager.ShowDialog(m_componentPlayer.GuiWidget, new MessageDialog(LanguageControl.Get(fName, 4), text2.Trim(), LanguageControl.Get("Usual", "ok"), null, null));
             }
             catch (Exception ex)
             {
                 DialogsManager.ShowDialog(m_componentPlayer.GuiWidget, new MessageDialog(LanguageControl.Get(fName, 5), ex.Message, LanguageControl.Get("Usual", "ok"), null, null));
             }
         }));
     }
 }
 public override void Load(ValuesDictionary valuesDictionary)
 {
     base.Load(valuesDictionary);
     m_subsystemFurnitureBlockBehavior = base.Project.FindSubsystem <SubsystemFurnitureBlockBehavior>(throwOnError: true);
 }
Exemplo n.º 14
0
        public static FurnitureDesign GetDesign(SubsystemFurnitureBlockBehavior subsystemFurnitureBlockBehavior, int value)
        {
            int designIndex = GetDesignIndex(Terrain.ExtractData(value));

            return(subsystemFurnitureBlockBehavior.GetDesign(designIndex));
        }