public void PlayerAssign(CraHandle player, Transform root, CraMask?mask = null) { Debug.Assert(root != null); if (CraSettings.BoneHashFunction == null) { throw new Exception("CraSettings.BoneHashFunction is not assigned! You need to assign a custom hash function!"); } List <int> assignedBones = PlayerAssignedBones[player.Handle]; if (assignedBones.Count > 0) { Debug.LogWarning($"Player {player.Handle} already has bones assigned!"); return; } (CraPlayerData data, int subIdex) = PlayerGet(player); int clipIdx = data.ClipIndex[subIdex]; if (clipIdx < 0) { Debug.LogError($"Cannot assign Transform '{root.name}' to CraPlayer! No clip(s) set!"); return; } CraClip clip = KnownClips[clipIdx]; PlayerAssignInternal(assignedBones, clip, clipIdx, root, mask); data.Transition[subIdex] = 1f; PlayerSet(player, ref data); PlayerCaptureBones(player); }
public void PlayerSetClip(CraHandle player, CraClip clip) { Debug.Assert(clip != null); (CraPlayerData data, int subIdex) = PlayerGet(player); int clipIdx = data.ClipIndex[subIdex]; if (clipIdx >= 0) { Debug.LogWarning($"Player {player.Handle} already has clip {clipIdx} assigned!"); return; } if (!KnownClipIndices.TryGetValue(clip, out clipIdx)) { clipIdx = CopyClip(clip); if (clipIdx < 0) { Debug.LogError($"Setting clip {clip.Name} to Player {player.Handle} failed!"); return; } } data.ClipIndex[subIdex] = clipIdx; data.Duration[subIdex] = clip.FrameCount / clip.Fps; data.Transition[subIdex] = 1f; PlayerSet(player, ref data); }
public void PlayerReset(CraHandle player) { (CraPlayerData data, int subIdex) = PlayerGet(player); data.Finished[subIdex] = false; data.Playback[subIdex] = 0f; data.IsPlaying[subIdex] = false; PlayerSet(player, ref data); }
public void PlayerPlay(CraHandle player, bool transit = false) { (CraPlayerData data, int subIdex) = PlayerGet(player); if (data.PlaybackSpeed[subIdex] > 0f) { data.Playback[subIdex] = .001f; } else { data.Playback[subIdex] = data.Duration[subIdex] - .001f; } data.IsPlaying[subIdex] = true; data.Transition[subIdex] = transit ? 0f : 1f; PlayerSet(player, ref data); }
public void PlayerCaptureBones(CraHandle player) { List <int> boneIndices = PlayerAssignedBones[player.Handle]; for (int i = 0; i < boneIndices.Count; ++i) { int boneIdx = boneIndices[i]; (CraPlayerData playerData, int subIdex) = PlayerGet(player); int clipIdx = playerData.ClipIndex[subIdex]; // Let the bone point to our Player and Clip CraBoneData boneData = BoneData.Get(boneIdx); boneData.PlayerIndex = player.Handle; boneData.ClipBoneIndex = BonePlayerClipIndices[boneIdx][clipIdx]; BoneData.Set(boneIdx, in boneData); } }
public bool PlayerIsFinished(CraHandle player) { (CraPlayerData data, int subIdex) = PlayerGet(player); return(data.Finished[subIdex]); }
public void PlayerSetLooping(CraHandle player, bool loop) { (CraPlayerData data, int subIdex) = PlayerGet(player); data.Looping[subIdex] = loop; PlayerSet(player, ref data); }
public bool PlayerIsLooping(CraHandle player) { (CraPlayerData data, int subIdex) = PlayerGet(player); return(data.Looping[subIdex]); }
public void PlayerResetTransition(CraHandle player) { (CraPlayerData data, int subIdex) = PlayerGet(player); data.Transition[subIdex] = 0f; PlayerSet(player, ref data); }
public void PlayerSetPlaybackSpeed(CraHandle player, float speed) { (CraPlayerData data, int subIdex) = PlayerGet(player); data.PlaybackSpeed[subIdex] = speed;//Mathf.Max(speed, 0.01f); PlayerSet(player, ref data); }
public float PlayerGetPlaybackSpeed(CraHandle player) { (CraPlayerData data, int subIdex) = PlayerGet(player); return(data.PlaybackSpeed[subIdex]); }
public float PlayerGetDuration(CraHandle player) { (CraPlayerData data, int subIdex) = PlayerGet(player); return(data.Duration[subIdex]); }