warvulture
This commit is contained in:
parent
3095198539
commit
1d66b00374
29 changed files with 7236 additions and 4 deletions
|
|
@ -40,6 +40,33 @@ namespace RacesOfValheim
|
|||
public static GameObject Attach(Transform parent, string holderName, string sourcePrefab,
|
||||
Vector3 localPosition, Quaternion localRotation, float targetSize,
|
||||
string label)
|
||||
{
|
||||
GameObject source = Jotunn.Managers.PrefabManager.Cache.GetPrefab<GameObject>(sourcePrefab);
|
||||
if (source == null)
|
||||
{
|
||||
Jotunn.Logger.LogWarning($"[{label}] No '{sourcePrefab}' to borrow a model from; nothing was attached.");
|
||||
|
||||
GameObject empty = new GameObject(holderName);
|
||||
empty.transform.SetParent(parent, false);
|
||||
empty.transform.localPosition = localPosition;
|
||||
return empty;
|
||||
}
|
||||
|
||||
return Attach(parent, holderName, source, localPosition, localRotation, targetSize, label);
|
||||
}
|
||||
|
||||
/// <summary>
|
||||
/// The same, for a source that has already been found by hand.
|
||||
///
|
||||
/// Not every borrowable model is a top-level prefab. The Seeker's wing, for one, is a
|
||||
/// child of the creature's death effect rather than a prefab of its own, so no name lookup
|
||||
/// can reach it and the caller has to walk to it first. Everything past the lookup - the
|
||||
/// inactive holder, the component strip, the measure-and-ground - is identical, which is
|
||||
/// exactly why this is an overload and not a second copy.
|
||||
/// </summary>
|
||||
public static GameObject Attach(Transform parent, string holderName, GameObject source,
|
||||
Vector3 localPosition, Quaternion localRotation, float targetSize,
|
||||
string label)
|
||||
{
|
||||
GameObject holder = new GameObject(holderName);
|
||||
holder.transform.SetParent(parent, false);
|
||||
|
|
@ -48,14 +75,14 @@ namespace RacesOfValheim
|
|||
// BEFORE the Instantiate below. This single line is the whole point of the class.
|
||||
holder.SetActive(false);
|
||||
|
||||
GameObject source = Jotunn.Managers.PrefabManager.Cache.GetPrefab<GameObject>(sourcePrefab);
|
||||
if (source == null)
|
||||
{
|
||||
Jotunn.Logger.LogWarning($"[{label}] No '{sourcePrefab}' to borrow a model from; nothing was attached.");
|
||||
Jotunn.Logger.LogWarning($"[{label}] No source model handed to '{holderName}'; nothing was attached.");
|
||||
holder.SetActive(true);
|
||||
return holder;
|
||||
}
|
||||
|
||||
string sourcePrefab = source.name;
|
||||
GameObject copy = Object.Instantiate(source, holder.transform);
|
||||
copy.name = "model";
|
||||
copy.transform.localPosition = Vector3.zero;
|
||||
|
|
|
|||
Loading…
Add table
Add a link
Reference in a new issue