feat: Alfar chests get bodies of their own
Players mistook a plain Wood chest for the Eldividarkista, so neither Alfar chest looks like a buildable vanilla chest any more. Eldividarkista: the Mistlands dvergr crate stretched to 1.6 x 0.8 m, blackened iron with a bronze frame and an iron grate on the front. The grate glows and throws sparks only while the chest holds wood the drones may burn. Inngangskista: the dvergr town loot chest, navy steel with silver trim. A cyan line in the lid shines while it holds anything but the sigil. Both have new hammer icons, and their hover names say their role (input, fuel) in English, Italian and Russian. If a borrowed vanilla model is missing, the chest falls back to the old tinted wood chest. scripts/paint_*_chest.py repaint the textures and render previews and icons offline with scripts/render_obj.py.
This commit is contained in:
parent
16cacde532
commit
b661fa6516
15 changed files with 634 additions and 10 deletions
|
|
@ -61,12 +61,15 @@ namespace RacesOfValheim
|
|||
public static void Register()
|
||||
{
|
||||
RegisterOne(EntryName, "$rov_piece_alfar_inngangskista_name", "$rov_piece_alfar_inngangskista_desc",
|
||||
new Color(0.62f, 0.80f, 1f, 1f));
|
||||
"$rov_hover_alfar_inngangskista", new Color(0.62f, 0.80f, 1f, 1f),
|
||||
AlfarInputChest.Build, "AlfarInputChest_icon.png");
|
||||
RegisterOne(WoodName, "$rov_piece_alfar_eldividarkista_name", "$rov_piece_alfar_eldividarkista_desc",
|
||||
new Color(0.85f, 0.62f, 0.36f, 1f));
|
||||
"$rov_hover_alfar_eldividarkista", new Color(0.85f, 0.62f, 0.36f, 1f),
|
||||
AlfarFireChest.Build, "AlfarFireChest_icon.png");
|
||||
}
|
||||
|
||||
private static void RegisterOne(string pieceName, string display, string description, Color tint)
|
||||
private static void RegisterOne(string pieceName, string display, string description, string hoverName, Color tint,
|
||||
System.Func<GameObject, bool> build, string iconResource)
|
||||
{
|
||||
GameObject source = PrefabManager.Cache.GetPrefab<GameObject>("piece_chest_wood");
|
||||
if (source == null)
|
||||
|
|
@ -91,15 +94,19 @@ namespace RacesOfValheim
|
|||
}
|
||||
requirements.Add(new RequirementConfig("GreydwarfEye", AlfarNexusConfig.ChestEyes.Value, 0, true));
|
||||
|
||||
// The hover and the chest window say what the chest is for, not only its name.
|
||||
Container container = prefab.GetComponent<Container>();
|
||||
if (container != null) container.m_name = display;
|
||||
if (container != null) container.m_name = hoverName;
|
||||
|
||||
Piece piece = prefab.GetComponent<Piece>();
|
||||
if (piece == null) { Jotunn.Logger.LogWarning("[Alfar] The chest has no Piece: " + pieceName); return; }
|
||||
piece.m_name = display;
|
||||
piece.m_description = description;
|
||||
|
||||
AlfarConstructs.Tint(prefab, tint);
|
||||
// Each chest has a body of its own; the tint stays as the fallback if it cannot be built.
|
||||
Sprite icon = piece.m_icon;
|
||||
if (!build(prefab)) AlfarConstructs.Tint(prefab, tint);
|
||||
else icon = IconFrom(iconResource) ?? icon;
|
||||
|
||||
PieceManager.Instance.AddPiece(new CustomPiece(prefab, fixReference: false, new PieceConfig
|
||||
{
|
||||
|
|
@ -107,7 +114,7 @@ namespace RacesOfValheim
|
|||
Description = description,
|
||||
PieceTable = PieceTables.Hammer,
|
||||
Category = PieceCategories.Crafting,
|
||||
Icon = piece.m_icon,
|
||||
Icon = icon,
|
||||
Requirements = requirements.ToArray(),
|
||||
}));
|
||||
|
||||
|
|
@ -130,5 +137,12 @@ namespace RacesOfValheim
|
|||
|
||||
AlfarPieces.Extra.Add(pieceName);
|
||||
}
|
||||
|
||||
private static Sprite IconFrom(string resource)
|
||||
{
|
||||
Texture2D texture = PieceLook.LoadTexture(resource);
|
||||
if (texture == null) return null;
|
||||
return Sprite.Create(texture, new Rect(0f, 0f, texture.width, texture.height), new Vector2(0.5f, 0.5f));
|
||||
}
|
||||
}
|
||||
}
|
||||
|
|
|
|||
Loading…
Add table
Add a link
Reference in a new issue