warvulture
This commit is contained in:
parent
d79f78e9f0
commit
8580d65a56
4 changed files with 90 additions and 7 deletions
|
|
@ -1,4 +1,6 @@
|
|||
using System.Collections.Generic;
|
||||
using HarmonyLib;
|
||||
using Jotunn.Configs;
|
||||
using Jotunn.Entities;
|
||||
using Jotunn.Managers;
|
||||
using UnityEngine;
|
||||
|
|
@ -36,6 +38,12 @@ namespace RacesOfValheim
|
|||
private const string TrophyPrefab = "TrophyVolture";
|
||||
private const string Label = "WarVulture";
|
||||
|
||||
/// <summary>The three materials. Ids, not display names: the ingot is BlackMetal (the SCRAP
|
||||
/// is the ore), and the raw lox meat is LoxMeat, with CookedLoxMeat being the other one.</summary>
|
||||
private const string GreydwarfEye = "GreydwarfEye";
|
||||
private const string BlackMetalIngot = "BlackMetal";
|
||||
private const string RawLoxMeat = "LoxMeat";
|
||||
|
||||
public static void Register()
|
||||
{
|
||||
GameObject prefab = PrefabManager.Instance.CreateClonedPrefab(PrefabName, SourcePrefab);
|
||||
|
|
@ -73,9 +81,24 @@ namespace RacesOfValheim
|
|||
// is not. Getting that wrong once put a live Ashlands predator in the player's world.
|
||||
WarVultureVisual.BuildTemplate();
|
||||
|
||||
// No recipe, on purpose and for now: the item is spawned from the console
|
||||
// ("spawn WarVulture") while the flight is being proven. A recipe costs nothing to add
|
||||
// later and would only be materials invented before anyone knows what this is worth.
|
||||
// The forge, and not the workbench, for the same reason Trol's Hammer sits on a
|
||||
// workbench: the station is picked by the material that is hardest to have. Eyes and
|
||||
// meat are picked up off the ground; a black metal ingot means a blast furnace already
|
||||
// exists, and the forge is where that metal is worked.
|
||||
ItemManager.Instance.AddRecipe(new CustomRecipe(new RecipeConfig
|
||||
{
|
||||
Item = PrefabName,
|
||||
Amount = 1,
|
||||
CraftingStation = CraftingStations.Forge,
|
||||
MinStationLevel = 1,
|
||||
Requirements = new[]
|
||||
{
|
||||
new RequirementConfig(GreydwarfEye, 10, 0, true),
|
||||
new RequirementConfig(BlackMetalIngot, 2, 0, true),
|
||||
new RequirementConfig(RawLoxMeat, 2, 0, true),
|
||||
},
|
||||
}));
|
||||
|
||||
Jotunn.Logger.LogInfo($"[{Label}] {DisplayName} registered: no eitr, no health, no stamina, no skeleton.");
|
||||
}
|
||||
|
||||
|
|
@ -251,6 +274,35 @@ namespace RacesOfValheim
|
|||
}
|
||||
}
|
||||
|
||||
/// <summary>
|
||||
/// Who gets to see the recipe: the same list the bird itself answers to
|
||||
/// (WarVultureConfig.AllowedRaces, "Furling,Dvergar" out of the box), read through the same
|
||||
/// helper, so the crafting menu and the summon can never disagree. A race that could craft the
|
||||
/// item but not call the bird would just be selling someone ten greydwarf eyes' worth of stick.
|
||||
///
|
||||
/// Player.GetAvailableRecipes is the single funnel the crafting list is built from, and it is
|
||||
/// public and takes the list by ref - so a Postfix that removes one entry is the whole gate.
|
||||
/// The recipe is still REGISTERED for everybody, which is deliberate: it stays in ObjectDB, so
|
||||
/// a character who changes race sees it appear or vanish with no world edit and no re-register.
|
||||
///
|
||||
/// Filtering here rather than at the craft click also means the refusal never has to be
|
||||
/// explained - an item that was never in the list cannot be clicked.
|
||||
/// </summary>
|
||||
[HarmonyPatch(typeof(Player), nameof(Player.GetAvailableRecipes))]
|
||||
public static class WarVultureRecipeRacePatch
|
||||
{
|
||||
private static void Postfix(Player __instance, ref List<Recipe> available)
|
||||
{
|
||||
if (__instance == null || available == null) return;
|
||||
if (WarVultureConfig.RaceAllowed(WarVultureConfig.RaceOf(__instance))) return;
|
||||
|
||||
available.RemoveAll(recipe =>
|
||||
recipe != null &&
|
||||
recipe.m_item != null &&
|
||||
Utils.GetPrefabName(recipe.m_item.gameObject) == WarVultureItem.PrefabName);
|
||||
}
|
||||
}
|
||||
|
||||
/// <summary>
|
||||
/// The click. Attack.OnAttackTrigger is used rather than Attack.Start because it takes NO
|
||||
/// parameters - its signature cannot drift - and it fires when the animation reaches its
|
||||
|
|
|
|||
Loading…
Add table
Add a link
Reference in a new issue