Merge remote-tracking branch 'origin/develop' into feature/Addessable_CDN
This commit is contained in:
@@ -129,32 +129,32 @@ namespace BrewMonster
|
||||
private void OnMsgHstHurtResult(ECMSG Msg)
|
||||
{
|
||||
//BMLogger.LogError("HoangDev : OnMsgHstHurtResult");
|
||||
/* int cmd = Convert.ToInt32(Msg.dwParam2);
|
||||
int cmd = Convert.ToInt32(Msg.dwParam2);
|
||||
if (cmd == CommandID.BE_HURT)
|
||||
{
|
||||
cmd_be_hurt pCmd = (cmd_be_hurt)Msg.dwParam1;
|
||||
cmd_be_hurt pCmd = GPDataTypeHelper.FromBytes<cmd_be_hurt>((byte[])Msg.dwParam1 );
|
||||
if (pCmd.damage != 0)
|
||||
Damaged(pCmd.damage);
|
||||
}
|
||||
else if (cmd == CommandID.HURT_RESULT)
|
||||
{
|
||||
cmd_hurt_result pCmd = (cmd_hurt_result)Msg.dwParam1;
|
||||
cmd_hurt_result pCmd = GPDataTypeHelper.FromBytes<cmd_hurt_result>((byte[])Msg.dwParam1 );
|
||||
if (pCmd.target_id == m_PlayerInfo.cid)
|
||||
return; // Host himself will receive BE_HURT, so ignore this.
|
||||
|
||||
if (UnityGameSession.Instance.GameSession.ISPLAYERID(pCmd.target_id))
|
||||
{
|
||||
CECElsePlayer pTarget = m_pPlayerMan.GetElsePlayer(pCmd.target_id);
|
||||
EC_ElsePlayer pTarget = m_pPlayerMan.GetElsePlayer(pCmd.target_id);
|
||||
if (pTarget)
|
||||
pTarget.Damaged(pCmd.damage);
|
||||
}
|
||||
else if (UnityGameSession.Instance.GameSession.ISNPCID(pCmd.target_id))
|
||||
{
|
||||
CECNPC pTarget = EC_ManMessageMono.Instance._CECNPCMan.GetNPC(pCmd.target_id);
|
||||
CECNPC pTarget = EC_ManMessageMono.Instance.CECNPCMan.GetNPC(pCmd.target_id);
|
||||
if (pTarget)
|
||||
pTarget.Damaged(pCmd.damage);
|
||||
}
|
||||
}*/
|
||||
}
|
||||
}
|
||||
|
||||
private void OnMsgHstStartAttack(in ECMSG Msg)
|
||||
|
||||
@@ -145,6 +145,7 @@ public partial class CECGameRun : ITickable
|
||||
{
|
||||
BMLogger.LogWarning("CECGameRun::LoadPrefabs, Loading prefabs from Resources. Consider using Addressables for better performance and memory management.");
|
||||
_playerPrefab = Resources.Load<GameObject>(AddressResourceConfig.PlayerPrefab);
|
||||
PrefabPoolManager.Instance.InitPool(_playerPrefab);
|
||||
_monsterPrefab = Resources.Load<GameObject>(AddressResourceConfig.MonsterPrefab);
|
||||
PrefabPoolManager.Instance.InitPool(_monsterPrefab, defaultCapacity: 200, maxSize: 250);
|
||||
_npcServerPrefab = Resources.Load<GameObject>(AddressResourceConfig.NpcServerPrefab);
|
||||
@@ -386,7 +387,7 @@ public partial class CECGameRun : ITickable
|
||||
}
|
||||
|
||||
CECPlayer.InitStaticRes();
|
||||
m_pHostPlayer = ObjectSpawner.Instance.InstantiateObject(_playerPrefab, setThisAsParent: true).AddComponent<CECHostPlayer>();
|
||||
m_pHostPlayer = PrefabPoolManager.Instance.Spawn(_playerPrefab, Vector3.zero, Quaternion.identity, ObjectSpawner.Instance.transform).AddComponent<CECHostPlayer>();
|
||||
m_pHostPlayer.InitCharacter(info);
|
||||
|
||||
if (m_pHostPlayer != null)
|
||||
@@ -453,7 +454,7 @@ public partial class CECGameRun : ITickable
|
||||
Debug.LogError("null prefab");
|
||||
return null;
|
||||
}
|
||||
GameObject character = ObjectSpawner.Instance.InstantiateObject(_playerPrefab, setThisAsParent: true);
|
||||
GameObject character = PrefabPoolManager.Instance.Spawn(_playerPrefab, Vector3.zero, Quaternion.identity, ObjectSpawner.Instance.transform);
|
||||
return character.gameObject;
|
||||
}
|
||||
|
||||
|
||||
@@ -46,20 +46,27 @@ namespace BrewMonster
|
||||
}
|
||||
if (_animationQueue.Count > 0)
|
||||
{
|
||||
_animationQueue.Enqueue(new AnimationQueue
|
||||
if(@event.IsForceStopPrevious)
|
||||
{
|
||||
AnimationName = @event.AnimationName,
|
||||
IsForceStopPrevious = @event.IsForceStopPrevious,
|
||||
AttackEvent = @event.AttackEvent,
|
||||
ChannelAct = @event.ChannelAct,
|
||||
Rank = @event.Rank
|
||||
});
|
||||
_animationList = _animationQueue.Select(q => q.AnimationName).ToList();
|
||||
return;
|
||||
_animationQueue.Clear();
|
||||
}
|
||||
else
|
||||
{
|
||||
_animationQueue.Enqueue(new AnimationQueue
|
||||
{
|
||||
AnimationName = @event.AnimationName,
|
||||
IsForceStopPrevious = @event.IsForceStopPrevious,
|
||||
AttackEvent = @event.AttackEvent,
|
||||
ChannelAct = @event.ChannelAct,
|
||||
Rank = @event.Rank
|
||||
});
|
||||
_animationList = _animationQueue.Select(q => q.AnimationName).ToList();
|
||||
return;
|
||||
}
|
||||
}
|
||||
previousAnimationName = @event.AnimationName;
|
||||
InternalPlayAnimation(@event.AnimationName, @event.ITransTime, FadeMode, @event.IsLoop);
|
||||
ApplyAnimationEndCallbacks(@event.AttackEvent, @event.ChannelAct, @event.Rank, @event.AnimationName);
|
||||
InternalPlayAnimation(@event.AnimationName, @event.ITransTime, FadeMode);
|
||||
ApplyAnimationEndCallbacks(@event.AttackEvent, @event.ChannelAct, @event.Rank, @event.AnimationName, @event.IsLoop);
|
||||
}
|
||||
public void InitPlayerEventDoneHandler()
|
||||
{
|
||||
@@ -195,6 +202,7 @@ namespace BrewMonster
|
||||
AttackEvent = null,
|
||||
IsLoop = true
|
||||
});
|
||||
Debug.Log($"EnqueueAnimationForLooping: {animationName}, _animationQueue: {string.Join(", ", _animationList)}");
|
||||
_animationList = _animationQueue.Select(q => q.AnimationName).ToList();
|
||||
return true;
|
||||
}
|
||||
@@ -205,14 +213,6 @@ namespace BrewMonster
|
||||
{
|
||||
return;
|
||||
}
|
||||
else
|
||||
{
|
||||
string animationQueueString = "";
|
||||
foreach(var animation in _animationQueue)
|
||||
{
|
||||
animationQueueString += animation.AnimationName + ", ";
|
||||
}
|
||||
}
|
||||
|
||||
if (_animationQueue.Peek().IsForceStopPrevious)
|
||||
{
|
||||
@@ -227,21 +227,26 @@ namespace BrewMonster
|
||||
var animationQueue = _animationQueue.Dequeue();
|
||||
_animationList = _animationQueue.Select(q => q.AnimationName).ToList();
|
||||
previousAnimationName = animationQueue.AnimationName;
|
||||
InternalPlayAnimation(animationQueue.AnimationName, animationQueue.ITransTime, FadeMode, animationQueue.IsLoop);
|
||||
ApplyAnimationEndCallbacks(animationQueue.AttackEvent, animationQueue.ChannelAct, animationQueue.Rank, animationQueue.AnimationName);
|
||||
InternalPlayAnimation(animationQueue.AnimationName, animationQueue.ITransTime, FadeMode);
|
||||
ApplyAnimationEndCallbacks(animationQueue.AttackEvent, animationQueue.ChannelAct, animationQueue.Rank, animationQueue.AnimationName,animationQueue.IsLoop);
|
||||
}
|
||||
|
||||
private void ApplyAnimationEndCallbacks(CECAttackEvent attackEvent, ChannelAct channelAct, int rank, string animationName)
|
||||
private void ApplyAnimationEndCallbacks(CECAttackEvent attackEvent, ChannelAct channelAct, int rank, string animationName, bool isLoop)
|
||||
{
|
||||
if (_currentState == null) return;
|
||||
_currentState.Events.OnEnd = () =>
|
||||
{
|
||||
if (attackEvent != null)
|
||||
attackEvent.m_bSignaled = true;
|
||||
if(isLoop)
|
||||
{
|
||||
EnqueueAnimationForLooping(animationName);
|
||||
}
|
||||
if (channelAct == null || string.IsNullOrEmpty(animationName))
|
||||
return;
|
||||
var node = channelAct.GetNodeByRank((byte)rank);
|
||||
node?.m_pActive?.m_ActionNames?.Remove(animationName);
|
||||
|
||||
};
|
||||
}
|
||||
void ApplyDamage()
|
||||
@@ -258,6 +263,12 @@ namespace BrewMonster
|
||||
{
|
||||
UnregisterPlayerEventHandlers();
|
||||
}
|
||||
|
||||
private void OnDisable()
|
||||
{
|
||||
UnregisterPlayerEventHandlers();
|
||||
}
|
||||
|
||||
public bool IsAnimationExist(string animationName)
|
||||
{
|
||||
var exists = namedAnimancer.States.TryGet("ActionName", out var existingState) ? true : false;
|
||||
@@ -271,7 +282,7 @@ namespace BrewMonster
|
||||
/// <param name="animationName"></param>
|
||||
/// <param name="duration"></param>
|
||||
/// <param name="fadeMode"></param>
|
||||
private void InternalPlayAnimation(string animationName, float duration = FadeTime, FadeMode fadeMode = FadeMode, bool isLoop = false)
|
||||
private void InternalPlayAnimation(string animationName, float duration = FadeTime, FadeMode fadeMode = FadeMode)
|
||||
{
|
||||
if (namedAnimancer == null)
|
||||
{
|
||||
@@ -281,13 +292,8 @@ namespace BrewMonster
|
||||
if (isState)
|
||||
{
|
||||
_currentState = namedAnimancer.TryPlay(animationName, duration / 1000, fadeMode);
|
||||
_currentState.Time = 0;
|
||||
_currentAnimationName = animationName;
|
||||
//if the animation is looping and the current state is not looping, play the animation again
|
||||
if(isLoop == true && _currentState.IsLooping == false)
|
||||
{
|
||||
_currentState.Time = 0;
|
||||
_currentState.Events.OnEnd = () => EnqueueAnimationForLooping(animationName);
|
||||
}
|
||||
return;
|
||||
}
|
||||
//BMLogger.LogError($"Null name animation: {animationName}");
|
||||
@@ -395,4 +401,4 @@ namespace BrewMonster
|
||||
return true;
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
Reference in New Issue
Block a user