mirror of
https://github.com/misternebula/quantum-space-buddies.git
synced 2025-01-26 18:35:34 +00:00
add type to animtrigger
This commit is contained in:
parent
2048cbf735
commit
62cc41409d
@ -22,10 +22,12 @@ namespace QSB.Animation
|
||||
private PlayerCharacterController _playerController;
|
||||
private CrouchSync _crouchSync;
|
||||
|
||||
private RuntimeAnimatorController RiebeckController;
|
||||
private RuntimeAnimatorController ChertController;
|
||||
private RuntimeAnimatorController GabbroController;
|
||||
private RuntimeAnimatorController FeldsparController;
|
||||
private RuntimeAnimatorController _riebeckController;
|
||||
private RuntimeAnimatorController _chertController;
|
||||
private RuntimeAnimatorController _gabbroController;
|
||||
private RuntimeAnimatorController _feldsparController;
|
||||
|
||||
public AnimationType CurrentType;
|
||||
|
||||
private void Awake()
|
||||
{
|
||||
@ -56,13 +58,13 @@ namespace QSB.Animation
|
||||
private void OnSceneLoaded(OWScene scene, bool inUniverse)
|
||||
{
|
||||
var reibeckRoot = GameObject.Find("Traveller_HEA_Riebeck_ANIM_Talking");
|
||||
RiebeckController = reibeckRoot.GetComponent<Animator>().runtimeAnimatorController;
|
||||
_riebeckController = reibeckRoot.GetComponent<Animator>().runtimeAnimatorController;
|
||||
var chertRoot = GameObject.Find("Traveller_HEA_Chert_ANIM_Chatter_Chipper");
|
||||
ChertController = chertRoot.GetComponent<Animator>().runtimeAnimatorController;
|
||||
_chertController = chertRoot.GetComponent<Animator>().runtimeAnimatorController;
|
||||
var gabbroRoot = GameObject.Find("Traveller_HEA_Gabbro_ANIM_IdleFlute");
|
||||
GabbroController = gabbroRoot.GetComponent<Animator>().runtimeAnimatorController;
|
||||
_gabbroController = gabbroRoot.GetComponent<Animator>().runtimeAnimatorController;
|
||||
var feldsparRoot = GameObject.Find("Traveller_HEA_Feldspar_ANIM_Talking");
|
||||
FeldsparController = feldsparRoot.GetComponent<Animator>().runtimeAnimatorController;
|
||||
_feldsparController = feldsparRoot.GetComponent<Animator>().runtimeAnimatorController;
|
||||
}
|
||||
|
||||
private void InitCommon(Transform body)
|
||||
@ -144,7 +146,7 @@ namespace QSB.Animation
|
||||
|
||||
public void SendTrigger(AnimTrigger trigger, float value = 0)
|
||||
{
|
||||
GlobalMessenger<short, float>.FireEvent(EventNames.QSBAnimTrigger, (short)trigger, value);
|
||||
GlobalMessenger<short, short, float>.FireEvent(EventNames.QSBAnimTrigger, (short)CurrentType, (short)trigger, value);
|
||||
}
|
||||
|
||||
public void HandleTrigger(AnimTrigger trigger, float value)
|
||||
@ -196,6 +198,11 @@ namespace QSB.Animation
|
||||
|
||||
public void SetAnimationType(AnimationType type)
|
||||
{
|
||||
if (CurrentType == type)
|
||||
{
|
||||
return;
|
||||
}
|
||||
CurrentType = type;
|
||||
switch (type)
|
||||
{
|
||||
case AnimationType.PlayerSuited:
|
||||
@ -207,9 +214,9 @@ namespace QSB.Animation
|
||||
_anim.runtimeAnimatorController = _unsuitedAnimController;
|
||||
break;
|
||||
case AnimationType.Chert:
|
||||
_bodyAnim.runtimeAnimatorController = ChertController;
|
||||
_bodyAnim.runtimeAnimatorController = _chertController;
|
||||
_bodyAnim.SetTrigger("Playing");
|
||||
_anim.runtimeAnimatorController = ChertController;
|
||||
_anim.runtimeAnimatorController = _chertController;
|
||||
_anim.SetTrigger("Playing");
|
||||
_mirror.RebuildFloatParams();
|
||||
break;
|
||||
|
@ -7,15 +7,16 @@ namespace QSB.Animation.Events
|
||||
{
|
||||
public override EventType Type => EventType.AnimTrigger;
|
||||
|
||||
public override void SetupListener() => GlobalMessenger<short, float>.AddListener(EventNames.QSBAnimTrigger, Handler);
|
||||
public override void SetupListener() => GlobalMessenger<short, short, float>.AddListener(EventNames.QSBAnimTrigger, Handler);
|
||||
|
||||
public override void CloseListener() => GlobalMessenger<short, float>.RemoveListener(EventNames.QSBAnimTrigger, Handler);
|
||||
public override void CloseListener() => GlobalMessenger<short, short, float>.RemoveListener(EventNames.QSBAnimTrigger, Handler);
|
||||
|
||||
private void Handler(short triggerId, float value) => SendEvent(CreateMessage(triggerId, value));
|
||||
private void Handler(short typeId, short triggerId, float value) => SendEvent(CreateMessage(typeId, triggerId, value));
|
||||
|
||||
private AnimTriggerMessage CreateMessage(short triggerId, float value) => new AnimTriggerMessage
|
||||
private AnimTriggerMessage CreateMessage(short typeId, short triggerId, float value) => new AnimTriggerMessage
|
||||
{
|
||||
AboutId = LocalPlayerId,
|
||||
TypeId = typeId,
|
||||
TriggerId = triggerId,
|
||||
Value = value
|
||||
};
|
||||
@ -27,6 +28,7 @@ namespace QSB.Animation.Events
|
||||
{
|
||||
return;
|
||||
}
|
||||
animationSync.SetAnimationType((AnimationType)message.TypeId);
|
||||
animationSync.HandleTrigger((AnimTrigger)message.TriggerId, message.Value);
|
||||
}
|
||||
}
|
||||
|
@ -5,6 +5,7 @@ namespace QSB.Animation.Events
|
||||
{
|
||||
public class AnimTriggerMessage : PlayerMessage
|
||||
{
|
||||
public short TypeId;
|
||||
public short TriggerId;
|
||||
public float Value;
|
||||
|
||||
@ -13,6 +14,7 @@ namespace QSB.Animation.Events
|
||||
base.Deserialize(reader);
|
||||
Value = reader.ReadSingle();
|
||||
TriggerId = reader.ReadInt16();
|
||||
TypeId = reader.ReadInt16();
|
||||
}
|
||||
|
||||
public override void Serialize(NetworkWriter writer)
|
||||
@ -20,6 +22,7 @@ namespace QSB.Animation.Events
|
||||
base.Serialize(writer);
|
||||
writer.Write(Value);
|
||||
writer.Write(TriggerId);
|
||||
writer.Write(TypeId);
|
||||
}
|
||||
}
|
||||
}
|
||||
|
Loading…
x
Reference in New Issue
Block a user