Skip to content

Commit

Permalink
Fixed display guy causing "Failed to find transform of type"
Browse files Browse the repository at this point in the history
  • Loading branch information
1A3Dev committed Oct 25, 2024
1 parent 58b76a5 commit 820e2cf
Show file tree
Hide file tree
Showing 2 changed files with 11 additions and 3 deletions.
12 changes: 10 additions & 2 deletions MoreCompany/Cosmetics/CosmeticApplication.cs
Original file line number Diff line number Diff line change
Expand Up @@ -10,6 +10,7 @@ public enum ParentType
Player,
DeadBody,
MaskedEnemy,
DisplayGuy,
}

public class CosmeticApplication : MonoBehaviour
Expand All @@ -30,13 +31,16 @@ public class CosmeticApplication : MonoBehaviour
public void Awake()
{
Transform spine = transform.Find("spine") ?? transform;
head = spine.Find("spine.001").Find("spine.002").Find("spine.003").Find("spine.004");
chest = spine.Find("spine.001").Find("spine.002").Find("spine.003");
lowerArmRight = spine.Find("spine.001").Find("spine.002").Find("spine.003").Find("shoulder.R").Find("arm.R_upper").Find("arm.R_lower");
head = chest.Find("spine.004");
lowerArmRight = chest.Find("shoulder.R").Find("arm.R_upper").Find("arm.R_lower");
hip = spine;
shinLeft = spine.Find("thigh.L").Find("shin.L");
shinRight = spine.Find("thigh.R").Find("shin.R");

if (parentType == ParentType.DisplayGuy)
CosmeticRegistry.UpdateCosmeticsOnDisplayGuy(false);

RefreshAllCosmeticPositions();
}

Expand Down Expand Up @@ -120,6 +124,10 @@ public void UpdateAllCosmeticVisibilities(bool isLocalPlayer = false)
{
isActive = MainClass.cosmeticsMaskedEnemy.Value;
}
else if (parentType == ParentType.DisplayGuy)
{
isActive = true;
}

foreach (var spawnedCosmetic in spawnedCosmetics)
{
Expand Down
2 changes: 1 addition & 1 deletion MoreCompany/Cosmetics/CosmeticRegistry.cs
Original file line number Diff line number Diff line change
Expand Up @@ -105,6 +105,7 @@ public static void SpawnCosmeticGUI(bool mainMenu)
.Find("ScavengerModel").Find("metarig").gameObject;

displayGuyCosmeticApplication = displayGuy.AddComponent<CosmeticApplication>();
displayGuyCosmeticApplication.parentType = ParentType.DisplayGuy;

GameObject enableCosmeticsButton = cosmeticGUIGlobalScale.Find("CosmeticsScreen").Find("EnableButton").gameObject;
GameObject disableCosmeticsButton = cosmeticGUIGlobalScale.Find("CosmeticsScreen").Find("DisableButton").gameObject;
Expand All @@ -122,7 +123,6 @@ public static void SpawnCosmeticGUI(bool mainMenu)
UpdateVisibilityCheckbox(enableCosmeticsButton, disableCosmeticsButton);

PopulateCosmetics();
UpdateCosmeticsOnDisplayGuy(false);
}

public static void PopulateCosmetics()
Expand Down

0 comments on commit 820e2cf

Please sign in to comment.