public override string GetDisplayName(SubsystemTerrain subsystemTerrain, int value) { int data = Terrain.ExtractData(value); int color = GetColor(data); return(LanguageControl.Get("LedBlock", color) + LanguageControl.GetBlock(string.Format("{0}:{1}", GetType().Name, data.ToString()), "DisplayName")); }
public override string GetDescription(int value) { int data = Terrain.ExtractData(value); ClothingData clothingData = GetClothingData(data); string desc = LanguageControl.GetBlock(string.Format("{0}:{1}", GetType().Name, data), "Description"); if (string.IsNullOrEmpty(desc)) { desc = clothingData.Description; } return(desc); }
public virtual string GetDescription(int value) { int data = Terrain.ExtractData(value); string bn = string.Format("{0}:{1}", GetType().Name, data); string nm = LanguageControl.GetBlock(bn, "Description"); if (string.IsNullOrEmpty(nm)) { return(DefaultDescription); } else { return(nm); } }
public virtual string GetDisplayName(SubsystemTerrain subsystemTerrain, int value) { int data = Terrain.ExtractData(value); string bn = string.Format("{0}:{1}", GetType().Name, data); string nm = LanguageControl.GetBlock(bn, "DisplayName"); if (string.IsNullOrEmpty(nm)) { return(DefaultDisplayName); } else { return(nm); } }
public override string GetDisplayName(SubsystemTerrain subsystemTerrain, int value) { int data = Terrain.ExtractData(value); ClothingData clothingData = GetClothingData(data); int clothingColor = GetClothingColor(data); string displayName = LanguageControl.GetBlock(string.Format("{0}:{1}", GetType().Name, data), "DisplayName"); if (string.IsNullOrEmpty(displayName)) { displayName = clothingData.DisplayName; } if (clothingColor != 0) { return(SubsystemPalette.GetName(subsystemTerrain, clothingColor, displayName)); } return(displayName); }
public override void Initialize() { if (Initialize1 != null) { Initialize1(); return; } int num = 0; Dictionary <int, ClothingData> dictionary = new Dictionary <int, ClothingData>(); IEnumerator <XElement> enumerator = ModsManager.CombineXml(ContentManager.Get <XElement>("Clothes"), ModsManager.GetEntries(".clo"), "Index", "Clothes").Elements().GetEnumerator(); while (enumerator.MoveNext()) { XElement item = enumerator.Current; string newDescription = LanguageControl.GetBlock(string.Format("{0}:{1}", GetType().Name, Index), "Description"); string newDisplayName = LanguageControl.GetBlock(string.Format("{0}:{1}", GetType().Name, Index), "DisplayName"); if (item.Attribute("DisplayName") != null && item.Attribute("Description") != null) { newDisplayName = XmlUtils.GetAttributeValue <string>(item, "DisplayName"); newDescription = XmlUtils.GetAttributeValue <string>(item, "Description"); } ClothingData clothingData = new ClothingData { Index = XmlUtils.GetAttributeValue <int>(item, "Index"), DisplayIndex = num++, DisplayName = newDisplayName, Slot = XmlUtils.GetAttributeValue <ClothingSlot>(item, "Slot"), ArmorProtection = XmlUtils.GetAttributeValue <float>(item, "ArmorProtection"), Sturdiness = XmlUtils.GetAttributeValue <float>(item, "Sturdiness"), Insulation = XmlUtils.GetAttributeValue <float>(item, "Insulation"), MovementSpeedFactor = XmlUtils.GetAttributeValue <float>(item, "MovementSpeedFactor"), SteedMovementSpeedFactor = XmlUtils.GetAttributeValue <float>(item, "SteedMovementSpeedFactor"), DensityModifier = XmlUtils.GetAttributeValue <float>(item, "DensityModifier"), IsOuter = XmlUtils.GetAttributeValue <bool>(item, "IsOuter"), CanBeDyed = XmlUtils.GetAttributeValue <bool>(item, "CanBeDyed"), Layer = XmlUtils.GetAttributeValue <int>(item, "Layer"), PlayerLevelRequired = XmlUtils.GetAttributeValue <int>(item, "PlayerLevelRequired"), Texture = ContentManager.Get <Texture2D>(XmlUtils.GetAttributeValue <string>(item, "TextureName")), ImpactSoundsFolder = XmlUtils.GetAttributeValue <string>(item, "ImpactSoundsFolder"), Description = newDescription }; dictionary.Add(clothingData.Index, clothingData); } m_clothingData = new ClothingData[dictionary.Count]; for (int i = 0; i < dictionary.Count; i++) { m_clothingData[i] = dictionary[i]; } Model playerModel = CharacterSkinsManager.GetPlayerModel(PlayerClass.Male); Matrix[] array = new Matrix[playerModel.Bones.Count]; playerModel.CopyAbsoluteBoneTransformsTo(array); int index = playerModel.FindBone("Hand1").Index; int index2 = playerModel.FindBone("Hand2").Index; array[index] = Matrix.CreateRotationY(0.1f) * array[index]; array[index2] = Matrix.CreateRotationY(-0.1f) * array[index2]; m_innerMesh = new BlockMesh(); foreach (ModelMesh mesh in playerModel.Meshes) { Matrix matrix = array[mesh.ParentBone.Index]; foreach (ModelMeshPart meshPart in mesh.MeshParts) { Color color = Color.White * 0.8f; color.A = byte.MaxValue; m_innerMesh.AppendModelMeshPart(meshPart, matrix, makeEmissive: false, flipWindingOrder: false, doubleSided: false, flipNormals: false, Color.White); m_innerMesh.AppendModelMeshPart(meshPart, matrix, makeEmissive: false, flipWindingOrder: true, doubleSided: false, flipNormals: true, color); } } Model outerClothingModel = CharacterSkinsManager.GetOuterClothingModel(PlayerClass.Male); Matrix[] array2 = new Matrix[outerClothingModel.Bones.Count]; outerClothingModel.CopyAbsoluteBoneTransformsTo(array2); int index3 = outerClothingModel.FindBone("Leg1").Index; int index4 = outerClothingModel.FindBone("Leg2").Index; array2[index3] = Matrix.CreateTranslation(-0.02f, 0f, 0f) * array2[index3]; array2[index4] = Matrix.CreateTranslation(0.02f, 0f, 0f) * array2[index4]; m_outerMesh = new BlockMesh(); foreach (ModelMesh mesh2 in outerClothingModel.Meshes) { Matrix matrix2 = array2[mesh2.ParentBone.Index]; foreach (ModelMeshPart meshPart2 in mesh2.MeshParts) { Color color2 = Color.White * 0.8f; color2.A = byte.MaxValue; m_outerMesh.AppendModelMeshPart(meshPart2, matrix2, makeEmissive: false, flipWindingOrder: false, doubleSided: false, flipNormals: false, Color.White); m_outerMesh.AppendModelMeshPart(meshPart2, matrix2, makeEmissive: false, flipWindingOrder: true, doubleSided: false, flipNormals: true, color2); } } base.Initialize(); }
public static void Initialize() { if (Initialize1 != null) { Initialize1(); return; } XElement source1 = ContentManager.Get <XElement>("CraftingRecipes"); ModsManager.CombineXml(source1, ModsManager.GetEntries(".cr"), "Description", "Result", "Recipes"); IEnumerable <XElement> source2 = source1.Descendants("Recipe"); foreach (XElement item in source2) { CraftingRecipe craftingRecipe = new CraftingRecipe(); string attributeValue = XmlUtils.GetAttributeValue <string>(item, "Result"); string desc = LanguageControl.GetBlock(attributeValue, "CRDescription"); if (item.Attribute("Description") != null) { desc = XmlUtils.GetAttributeValue <string>(item, "Description"); } craftingRecipe.ResultValue = DecodeResult(attributeValue); craftingRecipe.ResultCount = XmlUtils.GetAttributeValue <int>(item, "ResultCount"); string attributeValue2 = XmlUtils.GetAttributeValue(item, "Remains", string.Empty); if (!string.IsNullOrEmpty(attributeValue2)) { craftingRecipe.RemainsValue = DecodeResult(attributeValue2); craftingRecipe.RemainsCount = XmlUtils.GetAttributeValue <int>(item, "RemainsCount"); } craftingRecipe.RequiredHeatLevel = XmlUtils.GetAttributeValue <float>(item, "RequiredHeatLevel"); craftingRecipe.RequiredPlayerLevel = XmlUtils.GetAttributeValue(item, "RequiredPlayerLevel", 1f); craftingRecipe.Description = desc; craftingRecipe.Message = XmlUtils.GetAttributeValue <string>(item, "Message", null); if (craftingRecipe.ResultCount > BlocksManager.Blocks[Terrain.ExtractContents(craftingRecipe.ResultValue)].MaxStacking) { throw new InvalidOperationException($"In recipe for \"{attributeValue}\" ResultCount is larger than max stacking of result block."); } if (craftingRecipe.RemainsValue != 0 && craftingRecipe.RemainsCount > BlocksManager.Blocks[Terrain.ExtractContents(craftingRecipe.RemainsValue)].MaxStacking) { throw new InvalidOperationException($"In Recipe for \"{attributeValue2}\" RemainsCount is larger than max stacking of remains block."); } Dictionary <char, string> dictionary = new Dictionary <char, string>(); foreach (XAttribute item2 in from a in item.Attributes() where a.Name.LocalName.Length == 1 && char.IsLower(a.Name.LocalName[0]) select a) { DecodeIngredient(item2.Value, out string craftingId, out int?data); if (BlocksManager.FindBlocksByCraftingId(craftingId).Length == 0) { throw new InvalidOperationException($"Block with craftingId \"{item2.Value}\" not found."); } if (data.HasValue && (data.Value < 0 || data.Value > 262143)) { throw new InvalidOperationException($"Data in recipe ingredient \"{item2.Value}\" must be between 0 and 0x3FFFF."); } dictionary.Add(item2.Name.LocalName[0], item2.Value); } string[] array = item.Value.Trim().Split(new string[] { "\n" }, StringSplitOptions.None); for (int i = 0; i < array.Length; i++) { int num = array[i].IndexOf('"'); int num2 = array[i].LastIndexOf('"'); if (num < 0 || num2 < 0 || num2 <= num) { throw new InvalidOperationException("Invalid recipe line."); } string text = array[i].Substring(num + 1, num2 - num - 1); for (int j = 0; j < text.Length; j++) { char c = text[j]; if (char.IsLower(c)) { string text2 = dictionary[c]; craftingRecipe.Ingredients[j + i * 3] = text2; } } } m_recipes.Add(craftingRecipe); } Block[] blocks = BlocksManager.Blocks; foreach (Block block in blocks) { m_recipes.AddRange(block.GetProceduralCraftingRecipes()); } m_recipes.Sort(delegate(CraftingRecipe r1, CraftingRecipe r2) { int y = r1.Ingredients.Count((string s) => !string.IsNullOrEmpty(s)); int x = r2.Ingredients.Count((string s) => !string.IsNullOrEmpty(s)); return(Comparer <int> .Default.Compare(x, y)); }); }
public override string GetDisplayName(SubsystemTerrain subsystemTerrain, int value) { int data = Terrain.ExtractData(value); return(LanguageControl.GetBlock(fName + ":" + data, "DisplayName")); }