mirror of
https://github.com/FriendshipIsEpic/FiE-Game.git
synced 2024-11-26 15:27:59 +01:00
91 lines
2.1 KiB
C#
91 lines
2.1 KiB
C#
namespace Fie.Object
|
|
{
|
|
public class FieEmotion
|
|
{
|
|
public enum EmotionStatus
|
|
{
|
|
AUTO,
|
|
MANUAL
|
|
}
|
|
|
|
private FieGameCharacter _ownerCharacter;
|
|
|
|
private int _nowDefaultEmoteAnimationID = -1;
|
|
|
|
private FieSkeletonAnimationObject _latestAutoAnimation;
|
|
|
|
private EmotionStatus _emotionState;
|
|
|
|
public EmotionStatus emotionState => _emotionState;
|
|
|
|
public FieEmotion(FieGameCharacter ownerCharacter)
|
|
{
|
|
_ownerCharacter = ownerCharacter;
|
|
}
|
|
|
|
public void StopAutoAnimation()
|
|
{
|
|
if (_latestAutoAnimation != null)
|
|
{
|
|
_ownerCharacter.animationManager.UnbindAnimation(_latestAutoAnimation.trackID);
|
|
}
|
|
_emotionState = EmotionStatus.MANUAL;
|
|
}
|
|
|
|
public void RestartAutoAnimation()
|
|
{
|
|
_emotionState = EmotionStatus.AUTO;
|
|
if (_latestAutoAnimation != null)
|
|
{
|
|
SetEmoteAnimation(_latestAutoAnimation);
|
|
}
|
|
}
|
|
|
|
public void SetDefaultEmoteAnimationID(int newDefaultEmoteAnimId)
|
|
{
|
|
FieSkeletonAnimationObject animationData = _ownerCharacter.animationManager.GetAnimationData(newDefaultEmoteAnimId);
|
|
if (animationData != null)
|
|
{
|
|
_latestAutoAnimation = animationData;
|
|
_nowDefaultEmoteAnimationID = newDefaultEmoteAnimId;
|
|
}
|
|
}
|
|
|
|
public void RestoreEmotionFromDefaultData()
|
|
{
|
|
SetEmoteAnimation(_nowDefaultEmoteAnimationID);
|
|
}
|
|
|
|
public void SetEmoteAnimation(int emoteAnimId, bool isForceSet = false)
|
|
{
|
|
if (!(_ownerCharacter == null))
|
|
{
|
|
FieSkeletonAnimationObject animationData = _ownerCharacter.animationManager.GetAnimationData(emoteAnimId);
|
|
if (animationData != null)
|
|
{
|
|
SetEmoteAnimation(animationData);
|
|
}
|
|
}
|
|
}
|
|
|
|
private void SetEmoteAnimation(FieSkeletonAnimationObject data, bool isForceSet = false)
|
|
{
|
|
if (data != null && data.trackID == 1 && !(_ownerCharacter == null))
|
|
{
|
|
_latestAutoAnimation = data;
|
|
if (isForceSet || _emotionState == EmotionStatus.AUTO)
|
|
{
|
|
if (isForceSet)
|
|
{
|
|
_emotionState = EmotionStatus.AUTO;
|
|
if (_ownerCharacter.voiceController != null)
|
|
{
|
|
_ownerCharacter.voiceController.Interrupt();
|
|
}
|
|
}
|
|
_ownerCharacter.animationManager.SetAnimation(data, isLoop: true, isForceSet: true);
|
|
}
|
|
}
|
|
}
|
|
}
|
|
}
|