| | 1 | | using System; |
| | 2 | | using UnityEngine; |
| | 3 | |
|
| | 4 | | namespace AvatarSystem |
| | 5 | | { |
| | 6 | | [Serializable] |
| | 7 | | public struct AvatarAnchorPoint |
| | 8 | | { |
| | 9 | | public string AnchorName; |
| | 10 | | public Transform Bone; |
| | 11 | | } |
| | 12 | |
|
| | 13 | | [Serializable] |
| | 14 | | public class BaseAvatarReferences : MonoBehaviour, IBaseAvatarReferences |
| | 15 | | { |
| | 16 | | [Header("References")] |
| | 17 | | public SkinnedMeshRenderer skinnedMeshRenderer; |
| | 18 | | public Transform armatureContainer; |
| | 19 | | public GameObject particlesContainer; |
| | 20 | | public AvatarAnchorPoint[] anchors; |
| | 21 | |
|
| | 22 | | [Header("Ghost Settings")] |
| | 23 | | [ColorUsage(true, true)] public Color ghostMinColor; |
| | 24 | | [ColorUsage(true, true)] public Color ghostMaxColor; |
| 3 | 25 | | public float fadeGhostSpeed = 2f; |
| 3 | 26 | | public float revealSpeed = 2f; |
| | 27 | |
|
| 4 | 28 | | public SkinnedMeshRenderer SkinnedMeshRenderer => skinnedMeshRenderer; |
| | 29 | |
|
| | 30 | | private (string AnchorName, Transform Bone)[] anchorsCache; |
| 0 | 31 | | public (string AnchorName, Transform Bone)[] Anchors => anchorsCache ??= CacheAnchors(); |
| | 32 | |
|
| 0 | 33 | | public Transform ArmatureContainer => armatureContainer; |
| 0 | 34 | | public GameObject ParticlesContainer => particlesContainer; |
| 2 | 35 | | public Color GhostMinColor => ghostMinColor; |
| 2 | 36 | | public Color GhostMaxColor => ghostMaxColor; |
| 0 | 37 | | public float FadeGhostSpeed => fadeGhostSpeed; |
| 0 | 38 | | public float RevealSpeed => revealSpeed; |
| | 39 | |
|
| | 40 | | private (string AnchorName, Transform Bone)[] CacheAnchors() |
| | 41 | | { |
| 0 | 42 | | var cachedAnchors = new (string, Transform)[anchors.Length]; |
| | 43 | |
|
| 0 | 44 | | for (var i = 0; i < anchors.Length; i++) |
| | 45 | | { |
| 0 | 46 | | AvatarAnchorPoint anchorPoint = anchors[i]; |
| 0 | 47 | | cachedAnchors[i] = (anchorPoint.AnchorName, anchorPoint.Bone); |
| | 48 | | } |
| | 49 | |
|
| 0 | 50 | | return cachedAnchors; |
| | 51 | | } |
| | 52 | |
|
| | 53 | | public void Dispose() |
| | 54 | | { |
| 0 | 55 | | Destroy(gameObject); |
| 0 | 56 | | } |
| | 57 | | } |
| | 58 | | } |