64 lines
1.6 KiB
C#
64 lines
1.6 KiB
C#
using System;
|
|
using System.Collections.Generic;
|
|
using Sirenix.OdinInspector;
|
|
using SLSUtilities.AllInOneAssistance;
|
|
using UnityEngine;
|
|
|
|
namespace Cielonos.MainGame.Characters.Inventory
|
|
{
|
|
public partial class ItemViewObject : General3DObject
|
|
{
|
|
public Dictionary<string, GameObject> functionalParts;
|
|
|
|
public GameObject Part(string partName)
|
|
{
|
|
if (functionalParts.TryGetValue(partName, out GameObject part))
|
|
{
|
|
return part;
|
|
}
|
|
|
|
throw new Exception($"Part {partName} not found in ItemViewObject.");
|
|
}
|
|
|
|
public void Enable()
|
|
{
|
|
gameObject.SetActive(true);
|
|
}
|
|
|
|
public void Disable()
|
|
{
|
|
gameObject.SetActive(false);
|
|
}
|
|
}
|
|
|
|
public partial class ItemViewObject
|
|
{
|
|
private bool FindAndAssignPart(string partName)
|
|
{
|
|
GameObject part = GameObject.Find(partName);
|
|
if (part != null)
|
|
{
|
|
functionalParts[partName] = part;
|
|
return true;
|
|
}
|
|
|
|
return false;
|
|
}
|
|
|
|
protected override void Reset()
|
|
{
|
|
base.Reset();
|
|
|
|
functionalParts ??= new Dictionary<string, GameObject>();
|
|
|
|
FindAndAssignPart("GrabPoint");
|
|
FindAndAssignPart("Muzzle");
|
|
FindAndAssignPart("AimingPoint");
|
|
|
|
if (!FindAndAssignPart("AudioPoint"))
|
|
{
|
|
functionalParts["AudioPoint"] = gameObject;
|
|
}
|
|
}
|
|
}
|
|
} |