feat: red and white tablecloth on the Cook's Table
The cook goes back to the cartography table with its map painted over offline (scripts/paint_cook_cloth.py from textures pulled by scripts/extract_carto.py). The three PNGs are embedded in the DLL and swapped onto copied materials by PieceLook.Retexture. The smith stays on the black marble table.
This commit is contained in:
parent
b3edb2aed1
commit
069e098cf0
8 changed files with 238 additions and 22 deletions
|
|
@ -62,6 +62,8 @@ namespace RacesOfValheim
|
|||
public const float TableSpacing = 40f;
|
||||
|
||||
private const string TableSource = "piece_blackmarble_table";
|
||||
private const string ClothTableSource = "piece_cartographytable";
|
||||
private const float ClothTableScale = 0.8f;
|
||||
|
||||
/// <summary>
|
||||
/// One skull, one wishbone, eight stone - the same price for both tables.
|
||||
|
|
@ -197,20 +199,22 @@ namespace RacesOfValheim
|
|||
private static void RegisterTable(string pieceName, string displayName, string servantPrefab,
|
||||
ButlerFamily family, string description, string iconSource)
|
||||
{
|
||||
// The black marble table: "a slab of bone and slate". It was the cartography table once,
|
||||
// whose map is baked into its own texture and could not be taken off.
|
||||
GameObject prefab = PrefabManager.Instance.CreateClonedPrefab(pieceName, TableSource);
|
||||
// The smith works at the black marble table, "a slab of bone and slate". The cook keeps the
|
||||
// cartography table, with a tablecloth painted over its map (Dress).
|
||||
bool kitchen = family == ButlerFamily.Kitchen;
|
||||
string source = kitchen ? ClothTableSource : TableSource;
|
||||
GameObject prefab = PrefabManager.Instance.CreateClonedPrefab(pieceName, source);
|
||||
if (prefab == null)
|
||||
{
|
||||
Jotunn.Logger.LogWarning($"[Butler] Could not clone {TableSource}; " +
|
||||
Jotunn.Logger.LogWarning($"[Butler] Could not clone {source}; " +
|
||||
$"the {displayName} is not registered.");
|
||||
return;
|
||||
}
|
||||
|
||||
// A blanket sweep by capability rather than a named DestroyImmediate. The cartography table
|
||||
// taught it: its MapTable is Interactable AND Hoverable, so it took the E key before our own
|
||||
// Switch ever saw it. The marble table carries nothing of the kind today, and the sweep
|
||||
// keeps a future patch from adding one behind our back.
|
||||
// The MapTable trap, and it is the reason this is a blanket sweep by capability rather than
|
||||
// a named DestroyImmediate: MapTable is Interactable AND Hoverable, so it takes the E key
|
||||
// before our own Switch ever sees it and opens the shared map instead. The marble table
|
||||
// carries nothing of the kind today, and the sweep keeps a future patch from adding one.
|
||||
foreach (MonoBehaviour behaviour in prefab.GetComponentsInChildren<MonoBehaviour>(true))
|
||||
{
|
||||
if (behaviour == null) continue;
|
||||
|
|
@ -218,6 +222,7 @@ namespace RacesOfValheim
|
|||
Object.DestroyImmediate(behaviour);
|
||||
}
|
||||
|
||||
if (kitchen) prefab.transform.localScale = Vector3.one * ClothTableScale;
|
||||
Dress(prefab, family);
|
||||
|
||||
ServantTableBehaviour table = prefab.AddComponent<ServantTableBehaviour>();
|
||||
|
|
@ -256,8 +261,8 @@ namespace RacesOfValheim
|
|||
}));
|
||||
}
|
||||
|
||||
// The look. The marble table is 2.6 m by 1.5 m; both props sit either side of its centre, the
|
||||
// trade's tool the bigger of the two. X and Z only: the height is the table's, measured.
|
||||
// The smith's look. The marble table is 2.6 m by 1.5 m; both props sit either side of its
|
||||
// centre, the anvil the bigger of the two. X and Z only: the height is the table's, measured.
|
||||
private const float MarbleTableTop = 0.82f;
|
||||
private static readonly Vector3 TradeSpot = new Vector3(-0.35f, 0f, 0f);
|
||||
private static readonly Vector3 SkullSpot = new Vector3(0.6f, 0f, 0.1f);
|
||||
|
|
@ -265,12 +270,32 @@ namespace RacesOfValheim
|
|||
private const float MealSize = 0.6f;
|
||||
private const float SkullSize = 0.45f;
|
||||
|
||||
// The cook's cartography table, in its own space BEFORE ClothTableScale (so sizes are divided by
|
||||
// it to come out the same as the smith's). The cloth covers what was the map: x -2.06 to 0.62,
|
||||
// read off the mesh. Its top is the Dvergar bank's PileHeight, on the same vanilla mesh; the
|
||||
// mesh's own height is no use here, since the writing desk stands taller than the cloth.
|
||||
private const float ClothTop = 1.05f;
|
||||
private static readonly Vector3 MealOnCloth = new Vector3(-0.75f, ClothTop, 0.2f);
|
||||
private static readonly Vector3 SkullOnCloth = new Vector3(-1.55f, ClothTop, 0.35f);
|
||||
|
||||
/// <summary>
|
||||
/// "A slab of bone and slate": the black marble table, with the trade's own work in the middle -
|
||||
/// an anvil for the smith, a meal for the cook - and a skeleton's skull beside it.
|
||||
/// The trade's own work in the middle - an anvil for the smith, a meal for the cook - and a
|
||||
/// skeleton's skull beside it. The smith's on the black marble, the cook's on a red and white
|
||||
/// cloth painted over the cartography table's map.
|
||||
/// </summary>
|
||||
private static void Dress(GameObject prefab, ButlerFamily family)
|
||||
{
|
||||
if (family == ButlerFamily.Kitchen)
|
||||
{
|
||||
LayCloth(prefab);
|
||||
float size = 1f / ClothTableScale;
|
||||
ModelBorrow.Attach(prefab.transform, "TableMeal", "MeatPlatter",
|
||||
MealOnCloth, Quaternion.identity, MealSize * size, "Butler", activeOnly: true);
|
||||
ModelBorrow.Attach(prefab.transform, "TableSkull", "TrophySkeleton",
|
||||
SkullOnCloth, Quaternion.Euler(0f, -150f, 0f), SkullSize * size, "Butler", activeOnly: true);
|
||||
return;
|
||||
}
|
||||
|
||||
// The table's own height off its own mesh, with vanilla's 0.82 m as the fallback. The mesh
|
||||
// stands on the piece's origin, so its height IS the height of the top.
|
||||
Transform model = prefab.transform.Find("new");
|
||||
|
|
@ -278,19 +303,32 @@ namespace RacesOfValheim
|
|||
if (top <= 0f) top = MarbleTableTop;
|
||||
Vector3 up = Vector3.up * top;
|
||||
|
||||
ModelBorrow.Attach(prefab.transform, "TableAnvil", "forge_ext2",
|
||||
TradeSpot + up, Quaternion.identity, AnvilSize, "Butler", activeOnly: true);
|
||||
ModelBorrow.Attach(prefab.transform, "TableSkull", "TrophySkeleton",
|
||||
SkullSpot + up, Quaternion.Euler(0f, -150f, 0f), SkullSize, "Butler", activeOnly: true);
|
||||
}
|
||||
|
||||
if (family == ButlerFamily.Forge)
|
||||
{
|
||||
ModelBorrow.Attach(prefab.transform, "TableAnvil", "forge_ext2",
|
||||
TradeSpot + up, Quaternion.identity, AnvilSize, "Butler", activeOnly: true);
|
||||
}
|
||||
else
|
||||
{
|
||||
ModelBorrow.Attach(prefab.transform, "TableMeal", "MeatPlatter",
|
||||
TradeSpot + up, Quaternion.identity, MealSize, "Butler", activeOnly: true);
|
||||
}
|
||||
/// <summary>
|
||||
/// The tablecloth: the cartography table's own textures with the map painted over in red and
|
||||
/// white squares, by scripts/paint_cook_cloth.py. The worn texture (a damaged table) has a
|
||||
/// faded, stained cloth of its own, and the normal map is smoothed there so the coastline's
|
||||
/// relief does not show through.
|
||||
/// </summary>
|
||||
private static void LayCloth(GameObject prefab)
|
||||
{
|
||||
var cloth = new System.Collections.Generic.Dictionary<string, Texture>();
|
||||
AddCloth(cloth, "Cartographer_d", "CookCloth_d.png", false);
|
||||
AddCloth(cloth, "Cartographer_worn_d", "CookCloth_worn_d.png", false);
|
||||
AddCloth(cloth, "Cartographer_n", "CookCloth_n.png", true);
|
||||
PieceLook.Retexture(prefab.transform, cloth);
|
||||
}
|
||||
|
||||
private static void AddCloth(System.Collections.Generic.Dictionary<string, Texture> cloth,
|
||||
string vanilla, string resource, bool linear)
|
||||
{
|
||||
Texture2D texture = PieceLook.LoadTexture(resource, linear);
|
||||
if (texture != null) cloth[vanilla] = texture;
|
||||
}
|
||||
|
||||
public static void EnsureKnown(Player player)
|
||||
|
|
|
|||
Loading…
Add table
Add a link
Reference in a new issue