Merge branch 'develop' into feature/npc-shop

This commit is contained in:
HungDK
2025-12-08 10:37:03 +07:00
23 changed files with 2249 additions and 259 deletions
@@ -10310,7 +10310,907 @@ AnimationClip:
m_Center: {x: 0, y: 0, z: 0}
m_Extent: {x: 0, y: 0, z: 0}
m_ClipBindingConstant:
genericBindings: []
genericBindings:
- serializedVersion: 2
path: 2904062089
attribute: 1
script: {fileID: 0}
typeID: 4
customType: 0
isPPtrCurve: 0
isIntCurve: 0
isSerializeReferenceCurve: 0
- serializedVersion: 2
path: 2697794434
attribute: 1
script: {fileID: 0}
typeID: 4
customType: 0
isPPtrCurve: 0
isIntCurve: 0
isSerializeReferenceCurve: 0
- serializedVersion: 2
path: 473984651
attribute: 1
script: {fileID: 0}
typeID: 4
customType: 0
isPPtrCurve: 0
isIntCurve: 0
isSerializeReferenceCurve: 0
- serializedVersion: 2
path: 623370192
attribute: 1
script: {fileID: 0}
typeID: 4
customType: 0
isPPtrCurve: 0
isIntCurve: 0
isSerializeReferenceCurve: 0
- serializedVersion: 2
path: 2562056908
attribute: 1
script: {fileID: 0}
typeID: 4
customType: 0
isPPtrCurve: 0
isIntCurve: 0
isSerializeReferenceCurve: 0
- serializedVersion: 2
path: 2941519199
attribute: 1
script: {fileID: 0}
typeID: 4
customType: 0
isPPtrCurve: 0
isIntCurve: 0
isSerializeReferenceCurve: 0
- serializedVersion: 2
path: 2904062089
attribute: 2
script: {fileID: 0}
typeID: 4
customType: 0
isPPtrCurve: 0
isIntCurve: 0
isSerializeReferenceCurve: 0
- serializedVersion: 2
path: 2671905850
attribute: 2
script: {fileID: 0}
typeID: 4
customType: 0
isPPtrCurve: 0
isIntCurve: 0
isSerializeReferenceCurve: 0
- serializedVersion: 2
path: 2320144522
attribute: 2
script: {fileID: 0}
typeID: 4
customType: 0
isPPtrCurve: 0
isIntCurve: 0
isSerializeReferenceCurve: 0
- serializedVersion: 2
path: 2697794434
attribute: 2
script: {fileID: 0}
typeID: 4
customType: 0
isPPtrCurve: 0
isIntCurve: 0
isSerializeReferenceCurve: 0
- serializedVersion: 2
path: 3205428742
attribute: 2
script: {fileID: 0}
typeID: 4
customType: 0
isPPtrCurve: 0
isIntCurve: 0
isSerializeReferenceCurve: 0
- serializedVersion: 2
path: 181291755
attribute: 2
script: {fileID: 0}
typeID: 4
customType: 0
isPPtrCurve: 0
isIntCurve: 0
isSerializeReferenceCurve: 0
- serializedVersion: 2
path: 154580831
attribute: 2
script: {fileID: 0}
typeID: 4
customType: 0
isPPtrCurve: 0
isIntCurve: 0
isSerializeReferenceCurve: 0
- serializedVersion: 2
path: 1777750735
attribute: 2
script: {fileID: 0}
typeID: 4
customType: 0
isPPtrCurve: 0
isIntCurve: 0
isSerializeReferenceCurve: 0
- serializedVersion: 2
path: 429640245
attribute: 2
script: {fileID: 0}
typeID: 4
customType: 0
isPPtrCurve: 0
isIntCurve: 0
isSerializeReferenceCurve: 0
- serializedVersion: 2
path: 2817243914
attribute: 2
script: {fileID: 0}
typeID: 4
customType: 0
isPPtrCurve: 0
isIntCurve: 0
isSerializeReferenceCurve: 0
- serializedVersion: 2
path: 1777417914
attribute: 2
script: {fileID: 0}
typeID: 4
customType: 0
isPPtrCurve: 0
isIntCurve: 0
isSerializeReferenceCurve: 0
- serializedVersion: 2
path: 519441964
attribute: 2
script: {fileID: 0}
typeID: 4
customType: 0
isPPtrCurve: 0
isIntCurve: 0
isSerializeReferenceCurve: 0
- serializedVersion: 2
path: 4002323032
attribute: 2
script: {fileID: 0}
typeID: 4
customType: 0
isPPtrCurve: 0
isIntCurve: 0
isSerializeReferenceCurve: 0
- serializedVersion: 2
path: 2613341690
attribute: 2
script: {fileID: 0}
typeID: 4
customType: 0
isPPtrCurve: 0
isIntCurve: 0
isSerializeReferenceCurve: 0
- serializedVersion: 2
path: 473984651
attribute: 2
script: {fileID: 0}
typeID: 4
customType: 0
isPPtrCurve: 0
isIntCurve: 0
isSerializeReferenceCurve: 0
- serializedVersion: 2
path: 4218330170
attribute: 2
script: {fileID: 0}
typeID: 4
customType: 0
isPPtrCurve: 0
isIntCurve: 0
isSerializeReferenceCurve: 0
- serializedVersion: 2
path: 973752780
attribute: 2
script: {fileID: 0}
typeID: 4
customType: 0
isPPtrCurve: 0
isIntCurve: 0
isSerializeReferenceCurve: 0
- serializedVersion: 2
path: 2596236104
attribute: 2
script: {fileID: 0}
typeID: 4
customType: 0
isPPtrCurve: 0
isIntCurve: 0
isSerializeReferenceCurve: 0
- serializedVersion: 2
path: 2425874665
attribute: 2
script: {fileID: 0}
typeID: 4
customType: 0
isPPtrCurve: 0
isIntCurve: 0
isSerializeReferenceCurve: 0
- serializedVersion: 2
path: 3885029503
attribute: 2
script: {fileID: 0}
typeID: 4
customType: 0
isPPtrCurve: 0
isIntCurve: 0
isSerializeReferenceCurve: 0
- serializedVersion: 2
path: 2123991493
attribute: 2
script: {fileID: 0}
typeID: 4
customType: 0
isPPtrCurve: 0
isIntCurve: 0
isSerializeReferenceCurve: 0
- serializedVersion: 2
path: 623370192
attribute: 2
script: {fileID: 0}
typeID: 4
customType: 0
isPPtrCurve: 0
isIntCurve: 0
isSerializeReferenceCurve: 0
- serializedVersion: 2
path: 3802533241
attribute: 2
script: {fileID: 0}
typeID: 4
customType: 0
isPPtrCurve: 0
isIntCurve: 0
isSerializeReferenceCurve: 0
- serializedVersion: 2
path: 681675820
attribute: 2
script: {fileID: 0}
typeID: 4
customType: 0
isPPtrCurve: 0
isIntCurve: 0
isSerializeReferenceCurve: 0
- serializedVersion: 2
path: 888812595
attribute: 2
script: {fileID: 0}
typeID: 4
customType: 0
isPPtrCurve: 0
isIntCurve: 0
isSerializeReferenceCurve: 0
- serializedVersion: 2
path: 2278634959
attribute: 2
script: {fileID: 0}
typeID: 4
customType: 0
isPPtrCurve: 0
isIntCurve: 0
isSerializeReferenceCurve: 0
- serializedVersion: 2
path: 2562056908
attribute: 2
script: {fileID: 0}
typeID: 4
customType: 0
isPPtrCurve: 0
isIntCurve: 0
isSerializeReferenceCurve: 0
- serializedVersion: 2
path: 4181503832
attribute: 2
script: {fileID: 0}
typeID: 4
customType: 0
isPPtrCurve: 0
isIntCurve: 0
isSerializeReferenceCurve: 0
- serializedVersion: 2
path: 2561672102
attribute: 2
script: {fileID: 0}
typeID: 4
customType: 0
isPPtrCurve: 0
isIntCurve: 0
isSerializeReferenceCurve: 0
- serializedVersion: 2
path: 2317553494
attribute: 2
script: {fileID: 0}
typeID: 4
customType: 0
isPPtrCurve: 0
isIntCurve: 0
isSerializeReferenceCurve: 0
- serializedVersion: 2
path: 2270638035
attribute: 2
script: {fileID: 0}
typeID: 4
customType: 0
isPPtrCurve: 0
isIntCurve: 0
isSerializeReferenceCurve: 0
- serializedVersion: 2
path: 4031782725
attribute: 2
script: {fileID: 0}
typeID: 4
customType: 0
isPPtrCurve: 0
isIntCurve: 0
isSerializeReferenceCurve: 0
- serializedVersion: 2
path: 1767460607
attribute: 2
script: {fileID: 0}
typeID: 4
customType: 0
isPPtrCurve: 0
isIntCurve: 0
isSerializeReferenceCurve: 0
- serializedVersion: 2
path: 2941519199
attribute: 2
script: {fileID: 0}
typeID: 4
customType: 0
isPPtrCurve: 0
isIntCurve: 0
isSerializeReferenceCurve: 0
- serializedVersion: 2
path: 970861809
attribute: 2
script: {fileID: 0}
typeID: 4
customType: 0
isPPtrCurve: 0
isIntCurve: 0
isSerializeReferenceCurve: 0
- serializedVersion: 2
path: 3764974733
attribute: 2
script: {fileID: 0}
typeID: 4
customType: 0
isPPtrCurve: 0
isIntCurve: 0
isSerializeReferenceCurve: 0
- serializedVersion: 2
path: 2271171554
attribute: 2
script: {fileID: 0}
typeID: 4
customType: 0
isPPtrCurve: 0
isIntCurve: 0
isSerializeReferenceCurve: 0
- serializedVersion: 2
path: 3784749727
attribute: 2
script: {fileID: 0}
typeID: 4
customType: 0
isPPtrCurve: 0
isIntCurve: 0
isSerializeReferenceCurve: 0
- serializedVersion: 2
path: 2526118409
attribute: 2
script: {fileID: 0}
typeID: 4
customType: 0
isPPtrCurve: 0
isIntCurve: 0
isSerializeReferenceCurve: 0
- serializedVersion: 2
path: 261673907
attribute: 2
script: {fileID: 0}
typeID: 4
customType: 0
isPPtrCurve: 0
isIntCurve: 0
isSerializeReferenceCurve: 0
- serializedVersion: 2
path: 2391830708
attribute: 2
script: {fileID: 0}
typeID: 4
customType: 0
isPPtrCurve: 0
isIntCurve: 0
isSerializeReferenceCurve: 0
- serializedVersion: 2
path: 2089267986
attribute: 2
script: {fileID: 0}
typeID: 4
customType: 0
isPPtrCurve: 0
isIntCurve: 0
isSerializeReferenceCurve: 0
- serializedVersion: 2
path: 1177066612
attribute: 2
script: {fileID: 0}
typeID: 4
customType: 0
isPPtrCurve: 0
isIntCurve: 0
isSerializeReferenceCurve: 0
- serializedVersion: 2
path: 2872170345
attribute: 2
script: {fileID: 0}
typeID: 4
customType: 0
isPPtrCurve: 0
isIntCurve: 0
isSerializeReferenceCurve: 0
- serializedVersion: 2
path: 4131753032
attribute: 2
script: {fileID: 0}
typeID: 4
customType: 0
isPPtrCurve: 0
isIntCurve: 0
isSerializeReferenceCurve: 0
- serializedVersion: 2
path: 582302429
attribute: 1
script: {fileID: 0}
typeID: 4
customType: 0
isPPtrCurve: 0
isIntCurve: 0
isSerializeReferenceCurve: 0
- serializedVersion: 2
path: 2127582788
attribute: 1
script: {fileID: 0}
typeID: 4
customType: 0
isPPtrCurve: 0
isIntCurve: 0
isSerializeReferenceCurve: 0
- serializedVersion: 2
path: 2671905850
attribute: 1
script: {fileID: 0}
typeID: 4
customType: 0
isPPtrCurve: 0
isIntCurve: 0
isSerializeReferenceCurve: 0
- serializedVersion: 2
path: 2320144522
attribute: 1
script: {fileID: 0}
typeID: 4
customType: 0
isPPtrCurve: 0
isIntCurve: 0
isSerializeReferenceCurve: 0
- serializedVersion: 2
path: 3205428742
attribute: 1
script: {fileID: 0}
typeID: 4
customType: 0
isPPtrCurve: 0
isIntCurve: 0
isSerializeReferenceCurve: 0
- serializedVersion: 2
path: 181291755
attribute: 1
script: {fileID: 0}
typeID: 4
customType: 0
isPPtrCurve: 0
isIntCurve: 0
isSerializeReferenceCurve: 0
- serializedVersion: 2
path: 154580831
attribute: 1
script: {fileID: 0}
typeID: 4
customType: 0
isPPtrCurve: 0
isIntCurve: 0
isSerializeReferenceCurve: 0
- serializedVersion: 2
path: 1777750735
attribute: 1
script: {fileID: 0}
typeID: 4
customType: 0
isPPtrCurve: 0
isIntCurve: 0
isSerializeReferenceCurve: 0
- serializedVersion: 2
path: 429640245
attribute: 1
script: {fileID: 0}
typeID: 4
customType: 0
isPPtrCurve: 0
isIntCurve: 0
isSerializeReferenceCurve: 0
- serializedVersion: 2
path: 3505163164
attribute: 1
script: {fileID: 0}
typeID: 4
customType: 0
isPPtrCurve: 0
isIntCurve: 0
isSerializeReferenceCurve: 0
- serializedVersion: 2
path: 2817243914
attribute: 1
script: {fileID: 0}
typeID: 4
customType: 0
isPPtrCurve: 0
isIntCurve: 0
isSerializeReferenceCurve: 0
- serializedVersion: 2
path: 1777417914
attribute: 1
script: {fileID: 0}
typeID: 4
customType: 0
isPPtrCurve: 0
isIntCurve: 0
isSerializeReferenceCurve: 0
- serializedVersion: 2
path: 519441964
attribute: 1
script: {fileID: 0}
typeID: 4
customType: 0
isPPtrCurve: 0
isIntCurve: 0
isSerializeReferenceCurve: 0
- serializedVersion: 2
path: 4002323032
attribute: 1
script: {fileID: 0}
typeID: 4
customType: 0
isPPtrCurve: 0
isIntCurve: 0
isSerializeReferenceCurve: 0
- serializedVersion: 2
path: 2613341690
attribute: 1
script: {fileID: 0}
typeID: 4
customType: 0
isPPtrCurve: 0
isIntCurve: 0
isSerializeReferenceCurve: 0
- serializedVersion: 2
path: 4218330170
attribute: 1
script: {fileID: 0}
typeID: 4
customType: 0
isPPtrCurve: 0
isIntCurve: 0
isSerializeReferenceCurve: 0
- serializedVersion: 2
path: 973752780
attribute: 1
script: {fileID: 0}
typeID: 4
customType: 0
isPPtrCurve: 0
isIntCurve: 0
isSerializeReferenceCurve: 0
- serializedVersion: 2
path: 2596236104
attribute: 1
script: {fileID: 0}
typeID: 4
customType: 0
isPPtrCurve: 0
isIntCurve: 0
isSerializeReferenceCurve: 0
- serializedVersion: 2
path: 2425874665
attribute: 1
script: {fileID: 0}
typeID: 4
customType: 0
isPPtrCurve: 0
isIntCurve: 0
isSerializeReferenceCurve: 0
- serializedVersion: 2
path: 3885029503
attribute: 1
script: {fileID: 0}
typeID: 4
customType: 0
isPPtrCurve: 0
isIntCurve: 0
isSerializeReferenceCurve: 0
- serializedVersion: 2
path: 2123991493
attribute: 1
script: {fileID: 0}
typeID: 4
customType: 0
isPPtrCurve: 0
isIntCurve: 0
isSerializeReferenceCurve: 0
- serializedVersion: 2
path: 3802533241
attribute: 1
script: {fileID: 0}
typeID: 4
customType: 0
isPPtrCurve: 0
isIntCurve: 0
isSerializeReferenceCurve: 0
- serializedVersion: 2
path: 681675820
attribute: 1
script: {fileID: 0}
typeID: 4
customType: 0
isPPtrCurve: 0
isIntCurve: 0
isSerializeReferenceCurve: 0
- serializedVersion: 2
path: 888812595
attribute: 1
script: {fileID: 0}
typeID: 4
customType: 0
isPPtrCurve: 0
isIntCurve: 0
isSerializeReferenceCurve: 0
- serializedVersion: 2
path: 2278634959
attribute: 1
script: {fileID: 0}
typeID: 4
customType: 0
isPPtrCurve: 0
isIntCurve: 0
isSerializeReferenceCurve: 0
- serializedVersion: 2
path: 4040557913
attribute: 1
script: {fileID: 0}
typeID: 4
customType: 0
isPPtrCurve: 0
isIntCurve: 0
isSerializeReferenceCurve: 0
- serializedVersion: 2
path: 1776243939
attribute: 1
script: {fileID: 0}
typeID: 4
customType: 0
isPPtrCurve: 0
isIntCurve: 0
isSerializeReferenceCurve: 0
- serializedVersion: 2
path: 4181503832
attribute: 1
script: {fileID: 0}
typeID: 4
customType: 0
isPPtrCurve: 0
isIntCurve: 0
isSerializeReferenceCurve: 0
- serializedVersion: 2
path: 2561672102
attribute: 1
script: {fileID: 0}
typeID: 4
customType: 0
isPPtrCurve: 0
isIntCurve: 0
isSerializeReferenceCurve: 0
- serializedVersion: 2
path: 2317553494
attribute: 1
script: {fileID: 0}
typeID: 4
customType: 0
isPPtrCurve: 0
isIntCurve: 0
isSerializeReferenceCurve: 0
- serializedVersion: 2
path: 2270638035
attribute: 1
script: {fileID: 0}
typeID: 4
customType: 0
isPPtrCurve: 0
isIntCurve: 0
isSerializeReferenceCurve: 0
- serializedVersion: 2
path: 4031782725
attribute: 1
script: {fileID: 0}
typeID: 4
customType: 0
isPPtrCurve: 0
isIntCurve: 0
isSerializeReferenceCurve: 0
- serializedVersion: 2
path: 1767460607
attribute: 1
script: {fileID: 0}
typeID: 4
customType: 0
isPPtrCurve: 0
isIntCurve: 0
isSerializeReferenceCurve: 0
- serializedVersion: 2
path: 970861809
attribute: 1
script: {fileID: 0}
typeID: 4
customType: 0
isPPtrCurve: 0
isIntCurve: 0
isSerializeReferenceCurve: 0
- serializedVersion: 2
path: 3764974733
attribute: 1
script: {fileID: 0}
typeID: 4
customType: 0
isPPtrCurve: 0
isIntCurve: 0
isSerializeReferenceCurve: 0
- serializedVersion: 2
path: 2271171554
attribute: 1
script: {fileID: 0}
typeID: 4
customType: 0
isPPtrCurve: 0
isIntCurve: 0
isSerializeReferenceCurve: 0
- serializedVersion: 2
path: 3784749727
attribute: 1
script: {fileID: 0}
typeID: 4
customType: 0
isPPtrCurve: 0
isIntCurve: 0
isSerializeReferenceCurve: 0
- serializedVersion: 2
path: 2526118409
attribute: 1
script: {fileID: 0}
typeID: 4
customType: 0
isPPtrCurve: 0
isIntCurve: 0
isSerializeReferenceCurve: 0
- serializedVersion: 2
path: 261673907
attribute: 1
script: {fileID: 0}
typeID: 4
customType: 0
isPPtrCurve: 0
isIntCurve: 0
isSerializeReferenceCurve: 0
- serializedVersion: 2
path: 2391830708
attribute: 1
script: {fileID: 0}
typeID: 4
customType: 0
isPPtrCurve: 0
isIntCurve: 0
isSerializeReferenceCurve: 0
- serializedVersion: 2
path: 2089267986
attribute: 1
script: {fileID: 0}
typeID: 4
customType: 0
isPPtrCurve: 0
isIntCurve: 0
isSerializeReferenceCurve: 0
- serializedVersion: 2
path: 1177066612
attribute: 1
script: {fileID: 0}
typeID: 4
customType: 0
isPPtrCurve: 0
isIntCurve: 0
isSerializeReferenceCurve: 0
- serializedVersion: 2
path: 2872170345
attribute: 1
script: {fileID: 0}
typeID: 4
customType: 0
isPPtrCurve: 0
isIntCurve: 0
isSerializeReferenceCurve: 0
- serializedVersion: 2
path: 4131753032
attribute: 1
script: {fileID: 0}
typeID: 4
customType: 0
isPPtrCurve: 0
isIntCurve: 0
isSerializeReferenceCurve: 0
- serializedVersion: 2
path: 582302429
attribute: 2
script: {fileID: 0}
typeID: 4
customType: 0
isPPtrCurve: 0
isIntCurve: 0
isSerializeReferenceCurve: 0
- serializedVersion: 2
path: 2127582788
attribute: 2
script: {fileID: 0}
typeID: 4
customType: 0
isPPtrCurve: 0
isIntCurve: 0
isSerializeReferenceCurve: 0
- serializedVersion: 2
path: 3505163164
attribute: 2
script: {fileID: 0}
typeID: 4
customType: 0
isPPtrCurve: 0
isIntCurve: 0
isSerializeReferenceCurve: 0
- serializedVersion: 2
path: 4040557913
attribute: 2
script: {fileID: 0}
typeID: 4
customType: 0
isPPtrCurve: 0
isIntCurve: 0
isSerializeReferenceCurve: 0
- serializedVersion: 2
path: 1776243939
attribute: 2
script: {fileID: 0}
typeID: 4
customType: 0
isPPtrCurve: 0
isIntCurve: 0
isSerializeReferenceCurve: 0
pptrCurveMapping: []
m_AnimationClipSettings:
serializedVersion: 2
@@ -10322,7 +11222,7 @@ AnimationClip:
m_Level: 0
m_CycleOffset: 0
m_HasAdditiveReferencePose: 0
m_LoopTime: 0
m_LoopTime: 1
m_LoopBlend: 0
m_LoopBlendOrientation: 0
m_LoopBlendPositionY: 0
@@ -1,3 +1,4 @@
using System;
using System.Collections.Generic;
using System.Threading.Tasks;
using UnityEngine;
@@ -13,6 +14,7 @@ namespace BrewMonster.Scripts
private bool _isInitialized = false;
private Dictionary<string, AsyncOperationHandle<GameObject>> _loadedAssets = new();
public event Action OnDispose;
protected override void Initialize()
{
@@ -63,10 +65,71 @@ namespace BrewMonster.Scripts
/// <summary>
/// When the asset is no longer needed, call this method to unload it.
/// </summary>
/// <param name="assetPath"></param>
public void UnloadAsset(string assetPath)
/// <param name="assetPath">The asset path used when loading the asset</param>
public void ReleaseAsset(string assetPath)
{
Addressables.Release(assetPath);
if (_loadedAssets.TryGetValue(assetPath, out var handle))
{
if (handle.IsValid())
{
Addressables.Release(handle);
}
_loadedAssets.Remove(assetPath);
BMLogger.Log($"AddressableManager: Released asset: {assetPath}");
}
else
{
BMLogger.LogWarning($"AddressableManager: Asset not found in cache: {assetPath}");
}
}
/// <summary>
/// Release a specific asset by its handle directly.
/// </summary>
/// <param name="handle">The async operation handle to release</param>
public void ReleaseAsset(AsyncOperationHandle<GameObject> handle)
{
if (handle.IsValid())
{
Addressables.Release(handle);
}
}
/// <summary>
/// Release all loaded assets from the cache.
/// </summary>
public void ReleaseAllAssets()
{
foreach (var kvp in _loadedAssets)
{
if (kvp.Value.IsValid())
{
Addressables.Release(kvp.Value);
}
}
_loadedAssets.Clear();
BMLogger.Log("AddressableManager: Released all assets");
}
/// <summary>
/// Check if an asset is currently loaded in the cache.
/// </summary>
/// <param name="assetPath">The asset path to check</param>
/// <returns>True if the asset is loaded</returns>
public bool IsAssetLoaded(string assetPath)
{
return _loadedAssets.ContainsKey(assetPath) && _loadedAssets[assetPath].IsValid();
}
/// <summary>
/// Get the count of currently loaded assets.
/// </summary>
public int LoadedAssetCount => _loadedAssets.Count;
private void OnDestroy()
{
OnDispose?.Invoke();
ReleaseAllAssets();
}
}
}
@@ -1,4 +1,5 @@
using UnityEngine;
using System.Runtime.InteropServices;
using UnityEngine;
public static class GameConstants
{
@@ -46,6 +47,8 @@ public struct ROLEBASICPROP
iVigour = 0;
}
};
[StructLayout(LayoutKind.Sequential, Pack = 1)]
public struct ROLEEXTPROP
{
public ROLEEXTPROP_BASE bs;
@@ -63,6 +66,8 @@ public struct ROLEEXTPROP
max_ap = 0;
}
};
[StructLayout(LayoutKind.Sequential, Pack = 1)]
public struct ROLEEXTPROP_BASE
{
/* »ù´¡ÊôÐÔ */
@@ -100,6 +105,8 @@ public struct ROLEEXTPROP_BASE
this.mp_gen = mp_gen;
}
};
[StructLayout(LayoutKind.Sequential, Pack = 1)]
public struct ROLEEXTPROP_MOVE
{
/* Ô˶¯ËÙ¶È*/
@@ -125,6 +132,8 @@ public struct ROLEEXTPROP_MOVE
this.flight_speed = flight_speed;
}
};
[StructLayout(LayoutKind.Sequential, Pack = 1)]
public struct ROLEEXTPROP_ATK
{
// 物理攻击属性 / Attack properties
@@ -135,6 +144,7 @@ public struct ROLEEXTPROP_ATK
public float AttackRange; // 攻击范围
// 附加魔法伤害倍数(或附加魔法伤害范围)数组
[MarshalAs(UnmanagedType.ByValArray, SizeConst = 5)]
public AddonDamageEntry[] AddonDamage;
// 魔法攻击伤害
@@ -172,10 +182,12 @@ public struct ROLEEXTPROP_ATK
}
}
[StructLayout(LayoutKind.Sequential, Pack = 1)]
// Role (Player and NPC) extended properties, defense part
public struct ROLEEXTPROP_DEF
{
/* ·ÀÓùÊôÐÔ */
[MarshalAs(UnmanagedType.ByValArray, SizeConst = 5)]
public int[] resistance; // ħ·¨¿¹ÐÔ
public int defense; // ·ÀÓùÁ¦
public int armor; // ÉÁ¶ãÂÊ£¨×°¼×µÈ¼¶£©
@@ -7,6 +7,8 @@ using System.Collections.Generic;
using System.IO;
using System.Linq;
using System.Runtime.InteropServices;
using System.Text;
using ModelRenderer.Scripts.Common;
using UnityEngine;
namespace BrewMonster
@@ -741,6 +743,15 @@ public class CECAttackEvent
// TODO: Implement AddSkillGfxEvent
// CECGameRun.Instance.GetWorld().GetSkillGfxMan().AddSkillGfxEvent(m_idHost, data.idTarget,
// pszFlyGFX, pszHitGFX, m_timeToDoDamage, false, GfxMoveMode.enumLinearMove, 1, 0, null, vFlyScale, vHitScale, data.dwModifier);
var target = EC_ManMessageMono.Instance?.GetObject(data.idTarget, 0)?.gameObject.transform;
if (target == null)
{
BMLogger.LogError("Target is null!");
return false;
}
//todo: not set default like this
var fullGfx = "程序联入/击中/拳套击中";
CECGameRun.Instance.ShowVfx(fullGfx, target.position, null, 1f);
}
}
else
@@ -758,7 +769,8 @@ public class CECAttackEvent
{
TARGET_DATA data = m_targets[i];
// string fullGfx = pWeaponType.GetFileHitGfx();
var fullGfx = ByteToStringUtils.ByteArrayToCP936String(pWeaponType.file_hitgfx);
fullGfx = fullGfx.Substring(4);
// szGFX = fullGfx.Length > 4 ? fullGfx.Substring(4) : string.Empty; // skip gfx/
// szGFX = pWeaponType.file_hitgfx
// if ((data.dwModifier & (uint)MOD.MOD_NULLITY) != 0)
@@ -776,9 +788,10 @@ public class CECAttackEvent
BMLogger.LogError("Target is null!");
return false;
}
szGFX = "程序联入/击中/拳套击中";
CECGameRun.Instance.ShowVfx(szGFX, target.position, null, 1f);
//todo: not set default like this
fullGfx = "程序联入/击中/拳套击中";
CECGameRun.Instance.ShowVfx(fullGfx, target.position, null, 1f);
}
}
}
@@ -1,5 +1,6 @@
using BrewMonster.Network;
using System.Collections.Generic;
using UnityEngine;
namespace BrewMonster.Scripts
{
@@ -430,11 +431,25 @@ namespace BrewMonster.Scripts
public void CancelWork(CECHPWork pWork)
{
if (pWork == null)
{
//ASSERT(false);
return;
}
pWork.Cancel();
}
public void CancelWorkAtPriority(int iPriority)
{
if (!ValidatePriority(iPriority))
{
return;
}
WorkList workList = m_WorkStack[iPriority];
for (int i = 0; i < workList.Count; ++i)
{
CancelWork(workList[i]);
//LOG_DEBUG_INFO(AString().Format("CECHPWork::%s priority=%d cancelled", workList[i]->GetWorkName(), iPriority));
}
}
public bool DelayWork(int iPriority, CECHPWork pWork)
@@ -553,7 +568,7 @@ namespace BrewMonster.Scripts
//case CECHPWork.Host_work_ID.WORK_DEAD: pWork = new CECHPWorkDead(this); break;
//case CECHPWork.Host_work_ID.WORK_FOLLOW: pWork = new CECHPWorkFollow(this); break;
//case CECHPWork.Host_work_ID.WORK_FLYOFF: pWork = new CECHPWorkFly(this); break;
//case CECHPWork.Host_work_ID.WORK_FREEFALL: pWork = new CECHPWorkFall(this); break;
case CECHPWork.Host_work_ID.WORK_FREEFALL: pWork = new CECHPWorkFall(this); break;
//case CECHPWork.Host_work_ID.WORK_SIT: pWork = new CECHPWorkSit(this); break;
//case CECHPWork.Host_work_ID.WORK_PICKUP: pWork = new CECHPWorkPick(this); break;
//case CECHPWork.Host_work_ID.WORK_CONCENTRATE: pWork = new CECHPWorkConcentrate(this); break;
@@ -795,7 +810,7 @@ namespace BrewMonster.Scripts
int m_iPriority;
bool m_bNoDelay;
bool m_bShouldTick;
uint m_dwTickTime;
float m_dwTickTime;
// Constructor
public CECHPWorkPostTickRunWorkCommand(
@@ -803,7 +818,7 @@ namespace BrewMonster.Scripts
bool bNoDelay = false,
int iPriority = CECHPWorkMan.Work_priority.PRIORITY_1,
bool bShouldTick = false,
uint dwTickTime = 0)
float dwTickTime = 0)
{
m_pWork = pWork;
m_bNoDelay = bNoDelay;
@@ -0,0 +1,317 @@
using CSNetwork.GPDataType;
using System;
using System.Runtime.ConstrainedExecution;
using UnityEngine;
using static CECPlayer;
namespace BrewMonster.Scripts
{
public class CECHPWorkFall : CECHPWork
{
protected A3DVECTOR3 m_vDirH;
protected float m_fSpeedH;
protected bool m_bEnterWater;
protected int m_iFallMode;
protected int m_nCurStage;
protected int m_iFallType;
protected bool m_fForceDown;
Vector3 g_vOrigin = Vector3.zero;
public static class FlyFallStage
{
public const int enumStageNone = 0,
enumStageUpperAir = 1,
enumStageLowerAir = 2,
enumStageShallowWater = 3,
enumStageDeepWater = 4,
enumStageLandOn = 5;
};
// Fall type
public static class Fall_type
{
public const int TYPE_FREEFALL = 0,
TYPE_FLYFALL = 1;
};
// This work is do player moving ?
// public override bool IsMoving() { return true; }
// Copy work data
// Set fall type
public void SetFallType(int iType) { m_iFallType = iType; }
public int GetFallType() { return m_iFallType; }
public CECHPWorkFall(CECHPWorkMan pWorkMan) : base(Host_work_ID.WORK_FREEFALL, pWorkMan)
{
m_dwMask = Work_mask.MASK_FREEFALL;
m_dwTransMask = Work_mask.MASK_STAND;
Reset();
}
// Reset work
public override void Reset()
{
base.Reset();
m_bEnterWater = false;
m_nCurStage = FlyFallStage.enumStageNone;
m_iFallType = Fall_type.TYPE_FREEFALL;
m_fForceDown = false;
}
// Copy work data
public override bool CopyData(CECHPWork pWork)
{
if (!base.CopyData(pWork))
return false;
CECHPWorkFall pSrc = (CECHPWorkFall)pWork;
m_bEnterWater = pSrc.m_bEnterWater;
m_nCurStage = pSrc.m_nCurStage;
m_iFallType = pSrc.m_iFallType;
m_fForceDown = pSrc.m_fForceDown;
return true;
}
// On first tick
protected override void OnFirstTick()
{
m_pHost.m_iMoveEnv = (int)MoveEnvironment.MOVEENV_GROUND;
m_pHost.m_iMoveMode = (int)MoveMode.MOVE_FREEFALL;
m_vDirH = m_pHost.m_vVelocity;
m_vDirH.y = 0.0f;
m_fSpeedH = m_vDirH.Normalize();
if (m_fSpeedH > m_pHost.GetGroundSpeed())
m_fSpeedH = m_pHost.GetGroundSpeed();
// Clear N
m_pHost.m_CDRInfo.vTPNormal = Vector3.zero;
}
// Work is cancel
public override void Cancel()
{
m_pHost.m_CDRInfo.vAbsVelocity = Vector3.zero;
if (m_pHost.m_CDRInfo.vTPNormal == Vector3.zero)
m_pHost.m_CDRInfo.fYVel = 0.0f;
base.Cancel();
}
// Tick routine
public override bool Tick(float dwDeltaTime)
{
base.Tick(dwDeltaTime);
var m_pEquipPack = m_pHost.GetInventory(InventoryConst.IVTRTYPE_EQUIPPACK);
if (m_pEquipPack.GetItem(InventoryConst.EQUIPIVTR_FLYSWORD, false) == null)
m_iFallMode = (int)GPMoveMode.GP_MOVE_FALL;
else
m_iFallMode = (int)GPMoveMode.GP_MOVE_FLYFALL;
if (m_pHost.IsDead())
m_iFallMode |= (int)GPMoveMode.GP_MOVE_DEAD;
if (!m_pHost.IsRooting())
{
float fDeltaTime = dwDeltaTime * 0.001f;
if (m_pHost.m_iMoveEnv == (int)MoveEnvironment.MOVEENV_GROUND ||
m_pHost.m_iMoveEnv == (int)MoveEnvironment.MOVEENV_AIR)
{
if (m_iFallType == Fall_type.TYPE_FLYFALL)
Fall_Air(fDeltaTime);
else
FreeFall_Air(fDeltaTime);
}
//else // m_pHost.m_iMoveEnv == CECPlayer::MOVEENV_WATER
//{
// if (m_iFallType == Fall_type.TYPE_FLYFALL)
// Fall_Water(fDeltaTime);
// else
// FreeFall_Water(fDeltaTime);
//}
}
return true;
}
// Free fall in air
public bool Fall_Air(float fDeltaTime)
{
A3DVECTOR3 vCurPos = m_pHost.GetPos();
// A3DVECTOR3 vCurVel = m_pHost.m_vVelocity;
CDR_INFO cdr = m_pHost.m_CDRInfo;
bool bWorkEnd = false;
if (m_pHost.m_GndInfo.bOnGround)
{
bWorkEnd = true;
//if (m_pHost.UsingWing())
if (m_pHost.GetWingType() == enumWingType.WINGTYPE_WING)
m_pHost.PlayAction((int)PLAYER_ACTION_TYPE.ACT_LANDON, false);
else
m_pHost.PlayAction((int)PLAYER_ACTION_TYPE.ACT_LANDON_SWORD, false);
}
else
{
vCurPos = m_pHost.m_MoveCtrl.GroundMove(m_vDirH, m_fSpeedH, fDeltaTime);
if (m_pHost.m_MoveCtrl.MoveBlocked() >= 3)
{
bWorkEnd = true;
//if (m_pHost.UsingWing())
if (m_pHost.GetWingType() == enumWingType.WINGTYPE_WING)
m_pHost.PlayAction((int)PLAYER_ACTION_TYPE.ACT_LANDON, false);
else
m_pHost.PlayAction((int)PLAYER_ACTION_TYPE.ACT_LANDON_SWORD, false);
}
else
{
float fHei = vCurPos.y - m_pHost.m_GndInfo.fGndHei;
if (fHei > 25f)
{
if (m_nCurStage == FlyFallStage.enumStageNone)
{
m_nCurStage = FlyFallStage.enumStageUpperAir;
//if (m_pHost.UsingWing())
if (m_pHost.GetWingType() == enumWingType.WINGTYPE_WING)
m_pHost.PlayAction((int)PLAYER_ACTION_TYPE.ACT_FLYDOWN, false);
else
m_pHost.PlayAction((int)PLAYER_ACTION_TYPE.ACT_FLYDOWN_SWORD_HIGH, false);
}
}
else if (fHei > 20f)
{
if (m_nCurStage == FlyFallStage.enumStageNone)
{
m_nCurStage = FlyFallStage.enumStageLowerAir;
//if (m_pHost.UsingWing())
if (m_pHost.GetWingType() == enumWingType.WINGTYPE_WING)
m_pHost.PlayAction((int)PLAYER_ACTION_TYPE.ACT_FLYDOWN_WING_LOW, false);
else
m_pHost.PlayAction((int)PLAYER_ACTION_TYPE.ACT_FLYDOWN_SWORD_LOW, false);
}
}
else if (fHei > 3.0f)
{
if (m_nCurStage == FlyFallStage.enumStageNone
|| m_nCurStage == FlyFallStage.enumStageUpperAir)
{
m_nCurStage = FlyFallStage.enumStageLowerAir;
//if (m_pHost.UsingWing())
if (m_pHost.GetWingType() == enumWingType.WINGTYPE_WING)
m_pHost.PlayAction((int)PLAYER_ACTION_TYPE.ACT_FLYDOWN_WING_LOW, false);
else
m_pHost.PlayAction((int)PLAYER_ACTION_TYPE.ACT_FLYDOWN_SWORD_LOW, false);
}
}
else
{
if (m_nCurStage != FlyFallStage.enumStageLandOn)
{
m_nCurStage = FlyFallStage.enumStageLandOn;
//if (m_pHost.UsingWing())
if (m_pHost.GetWingType() == enumWingType.WINGTYPE_WING)
m_pHost.PlayAction((int)PLAYER_ACTION_TYPE.ACT_LANDON, false);
else
m_pHost.PlayAction((int)PLAYER_ACTION_TYPE.ACT_LANDON_SWORD, false);
}
}
}
m_pHost.SetPos(EC_Utility.ToVector3(vCurPos));
}
if (bWorkEnd)
{
Finish();
m_pHost.SetPos(EC_Utility.ToVector3(vCurPos));
float fSpeed = cdr.vAbsVelocity.magnitude;
if (Math.Abs(fSpeed - 0) < float.Epsilon)
fSpeed = m_pHost.GetFlySpeed();
m_pHost.m_MoveCtrl.SendStopMoveCmd(EC_Utility.ToVector3(vCurPos), fSpeed, m_iFallMode);
m_pHost.m_vVelocity.Clear();
return true;
}
else
{
m_pHost.m_MoveCtrl.SendMoveCmd(vCurPos, 2, EC_Utility.ToA3DVECTOR3(g_vOrigin), EC_Utility.ToA3DVECTOR3(cdr.vAbsVelocity), m_iFallMode);
}
return true;
}
// Free fall in air
public bool FreeFall_Air(float fDeltaTime)
{
A3DVECTOR3 vCurPos = m_pHost.GetPos();
// A3DVECTOR3 vCurVel = m_pHost.m_vVelocity;
CDR_INFO cdr = m_pHost.m_CDRInfo;
if (m_pHost.m_GndInfo.bOnGround)
{
Finish();
m_pHost.SetPos(EC_Utility.ToVector3(vCurPos));
float fSpeed = cdr.vAbsVelocity.magnitude;
if (Math.Abs(fSpeed - 0) < float.Epsilon)
fSpeed = m_pHost.GetFlySpeed();
m_pHost.m_MoveCtrl.SendStopMoveCmd(EC_Utility.ToVector3(vCurPos), fSpeed, m_iFallMode);
m_pHost.m_vVelocity.Clear();
}
else
{
vCurPos = m_pHost.m_MoveCtrl.GroundMove(m_vDirH, m_fSpeedH, fDeltaTime);
// If player is blocked, add disturb speed at random direction
if (m_pHost.m_MoveCtrl.MoveBlocked() >= 3)
{
cdr.fYVel = 0.0f;
Finish();
m_pHost.SetPos(EC_Utility.ToVector3(vCurPos));
m_pHost.m_MoveCtrl.SendStopMoveCmd(EC_Utility.ToVector3(vCurPos), 5.0f, m_iFallMode);
}
/* {
m_fSpeedH = 3.0f;
m_vDirH = glb_RandomVectorH();
}
else
{
m_fSpeedH = 0.0f;
m_vDirH.Clear();
} */
m_pHost.SetPos(EC_Utility.ToVector3(vCurPos));
m_pHost.m_MoveCtrl.SendMoveCmd(vCurPos, 2, EC_Utility.ToA3DVECTOR3(g_vOrigin), EC_Utility.ToA3DVECTOR3(cdr.vAbsVelocity), m_iFallMode);
m_pHost.PlayAction((int)PLAYER_ACTION_TYPE.ACT_JUMP_LOOP, false);
}
return true;
}
// Finish
public void Finish()
{
m_bFinished = true;
m_pHost.m_CDRInfo.vAbsVelocity = Vector3.zero;
// m_pHost.m_CDRInfo.fYVel = 0.0f;
//if (m_iFallType == Fall_type.TYPE_FLYFALL)
// m_pHost.ShowWing(false);
}
}
}
@@ -0,0 +1,2 @@
fileFormatVersion: 2
guid: a85280d3ca5f703449ffa56b24ca7e47
@@ -1,7 +1,6 @@
using BrewMonster.Network;
using CSNetwork.GPDataType;
using System;
using UnityEngine;
using static CECPlayer;
using Types = BrewMonster.Scripts.CECHPWorkMove.DestTypes;
namespace BrewMonster.Scripts
@@ -614,7 +613,7 @@ namespace BrewMonster.Scripts
}
else
{
vCurPos = m_pHost.m_MoveCtrl.GroundMove(GPDataTypeHelper.g_vOrigin, 0.0f, fDeltaTime, m_pHost.m_fVertSpeed);
vCurPos = m_pHost.m_MoveCtrl.GroundMove(GPDataTypeHelper.g_vOrigin, 0.0f, fDeltaTime, m_pHost.m_fVertSpeed);
m_pHost.SetPos(EC_Utility.ToVector3(vCurPos));
if (m_pHost.m_MoveCtrl.MoveBlocked() >= 3)
@@ -752,6 +751,120 @@ namespace BrewMonster.Scripts
// Tick routine of flying or swimming
protected bool Tick_FlySwim(float fDeltaTime)
{
A3DVECTOR3 vCurPos = m_pHost.GetPos();
int iMoveMode = (m_pHost.m_iMoveEnv == (int)MoveEnvironment.MOVEENV_AIR) ? (int)GPMoveMode.GP_MOVE_AIR : (int)GPMoveMode.GP_MOVE_WATER;
float na, fMaxSpeed;
bool bInAir;
if (m_pHost.m_iMoveEnv == (int)MoveEnvironment.MOVEENV_AIR)
{
bInAir = true;
na = CECHostMove.EC_NACCE_AIR;
fMaxSpeed = m_pHost.GetFlySpeed();
}
else
{
bInAir = false;
na = CECHostMove.EC_NACCE_WATER;
fMaxSpeed = m_pHost.GetSwimSpeedSev();
}
if (m_bReadyCancel || m_bMeetSlide)
{
m_pHost.m_MoveCtrl.SendStopMoveCmd(EC_Utility.ToVector3(vCurPos), fMaxSpeed, iMoveMode | (int)GPMoveMode.GP_MOVE_RUN);
Finish();
return true;
}
// for auto move
if (m_bUseAutoMoveDialog && m_fAutoHeight > 0.0f && m_iDestType != DestTypes.DEST_PUSH)
{
if (m_pHost.m_dwMoveRelDir == 0)
{
if ((int)(vCurPos.y / 10.0f) == (int)m_fAutoHeight)
{
if (!m_bReachedHeight)
{
m_pHost.m_vVelocity.y = 0.0f;
m_pHost.m_dwMoveRelDir &= ~((uint)(MOVE_DIR.MD_ABSUP | MOVE_DIR.MD_ABSDOWN));
m_bReachedHeight = true;
}
}
else
{
if (!m_bReachedHeight)
{
if (vCurPos.y < m_fAutoHeight * 10.0f)
{
m_pHost.m_dwMoveRelDir &= ~((uint)(MOVE_DIR.MD_ABSDOWN));
m_pHost.m_dwMoveRelDir |= ((uint)MOVE_DIR.MD_ABSUP);
}
else if (vCurPos.y > m_fAutoHeight * 10.0f)
{
m_pHost.m_dwMoveRelDir &= ~((uint)(MOVE_DIR.MD_ABSUP));
m_pHost.m_dwMoveRelDir |= (uint)MOVE_DIR.MD_ABSDOWN;
}
}
else // Auto adjust height, so we should refresh move height
{
m_fAutoHeight = vCurPos.y / 10.0f;
}
}
}
else // Player manually set auto move height
{
m_bReachedHeight = true;
m_fAutoHeight = vCurPos.y / 10.0f;
}
}
if ((m_pHost.m_dwMoveRelDir & (uint)(MOVE_DIR.MD_LEFT | MOVE_DIR.MD_RIGHT | MOVE_DIR.MD_FORWARD | MOVE_DIR.MD_BACK)) != 0)
m_iDestType = DestTypes.DEST_PUSH;
ON_AIR_CDR_INFO cdr = m_pHost.m_AirCDRInfo;
if (m_iDestType == DestTypes.DEST_DIR)
{
Vector3 vPushDir = Vector3.zero;
m_pHost.GetPushDir(ref vPushDir, (uint)MOVE_DIR.MD_ALL, 0);
vPushDir.x = vPushDir.z = 0.0f;
float fSpeed1H = m_pHost.m_vVelocity.MagnitudeH();
float fSpeed1V = m_pHost.m_vVelocity.y;
A3DVECTOR3 vMoveDirH = m_vMoveDest;
float pa = CECHostMove.EC_PUSH_ACCE;
float fSpeed2H = fSpeed1H + (pa + na) * fDeltaTime;
if (Math.Abs(pa - 0) < float.Epsilon && fSpeed2H < 0.0f)
fSpeed2H = 0.0f; // Only resistance couldn't generate negative speed
else if (fSpeed2H > fMaxSpeed)
fSpeed2H = fMaxSpeed;
Glide(5.0f, vMoveDirH, fDeltaTime, bInAir);
vMoveDirH = m_pHost.GetModelMoveDir();
vMoveDirH.y = 0;
vMoveDirH.Normalize();
// Vertical speed
float fSpeed2V = CalcFlySwimVertSpeed(fSpeed1V, vPushDir.y, CECHostMove.EC_PUSH_ACCE, fDeltaTime);
A3DVECTOR3 vVel2 = vMoveDirH * fSpeed2H + GPDataTypeHelper.g_vAxisY * fSpeed2V;
// Air/water move
vCurPos = m_pHost.m_MoveCtrl.AirWaterMove(vVel2, fDeltaTime, bInAir);
m_pHost.SetPos(EC_Utility.ToVector3(vCurPos));
m_pHost.m_vVelocity = vVel2;
if (m_pHost.m_MoveCtrl.MoveBlocked() >= 3)
{
Finish();
m_pHost.m_MoveCtrl.SendStopMoveCmd(EC_Utility.ToVector3(vCurPos), fMaxSpeed, iMoveMode | (int)GPMoveMode.GP_MOVE_RUN);
}
else
m_pHost.m_MoveCtrl.SendMoveCmd(vCurPos, 0, m_vMoveDest, vVel2, iMoveMode | (int)GPMoveMode.GP_MOVE_RUN);
}
return true;
}
// Start gliding
@@ -134,25 +134,24 @@ namespace BrewMonster.Scripts
{
pWork.SetDestination(CECHPWorkMove.DestTypes.DEST_STANDJUMP, GPDataTypeHelper.g_vOrigin);
m_pWorkMan.SetPostTickCommand(new CECHPWorkPostTickRunWorkCommand(
pWork, false, CECHPWorkMan.Work_priority.PRIORITY_1, true, (uint)dwDeltaTime));
pWork, false, CECHPWorkMan.Work_priority.PRIORITY_1, true, dwDeltaTime));
}
}
else if (iMoveReason == 2)
{
// var pWork = (CECHPWorkFall)m_pWorkMan.CreateWork(Host_work_ID.WORK_FREEFALL);
// if (pWork != null) {
// pWork.SetFallType(CECHPWorkFall.TYPE_FREEFALL);
// m_pWorkMan.SetPostTickCommand(new CECHPWorkPostTickRunWorkCommand(pWork));
// }
var pWork = (CECHPWorkFall)m_pWorkMan.CreateWork(Host_work_ID.WORK_FREEFALL);
if (pWork != null)
{
pWork.SetFallType(CECHPWorkFall.Fall_type.TYPE_FREEFALL);
m_pWorkMan.SetPostTickCommand(new CECHPWorkPostTickRunWorkCommand(pWork));
}
}
else
{
// ASSERT(0);
}
return true;
}
// Play appropriate actions
if (m_iPoseAction == (int)CECPlayer.PLAYER_ACTION_TYPE.ACT_STAND)
{
@@ -173,7 +172,7 @@ namespace BrewMonster.Scripts
if (m_iPoseAction == (int)CECPlayer.PLAYER_ACTION_TYPE.ACT_STAND)
{
// Chariot war special case omitted for now
m_pHost.PlayAction(m_iCurAction, false, 0);
m_pHost.PlayAction(m_iCurAction, false, 300);
//m_oldAction = m_iCurAction;
}
@@ -1,6 +1,7 @@
using BrewMonster;
using BrewMonster.Managers;
using BrewMonster.Network;
using BrewMonster.Scripts;
using CSNetwork;
using CSNetwork.GPDataType;
using CSNetwork.Protocols;
@@ -9,6 +10,7 @@ using PerfectWorld.Scripts.Player;
using System;
using System.Collections;
using System.Collections.Generic;
using System.Reflection;
using System.Runtime.InteropServices;
using TMPro;
using UnityEngine;
@@ -74,6 +76,9 @@ namespace PerfectWorld.Scripts.Managers
case EC_MsgDef.MSG_PM_PICKUPMATTER:
OnMsgPlayerPickupMatter(Msg);
break;
case EC_MsgDef.MSG_PM_PLAYEREXTPROP:
OnMsgPlayerExtProp(Msg);
break;
}
}
else
@@ -188,15 +193,15 @@ namespace PerfectWorld.Scripts.Managers
// TODO: Implement get faction
/*/
// Get faction info
if (pPlayer->GetFactionID() && !g_pGame->GetFactionMan()->GetFaction(pPlayer->GetFactionID()))
if (pPlayer.GetFactionID() && !g_pGame.GetFactionMan().GetFaction(pPlayer.GetFactionID()))
{
int i(0);
for (i = 0; i < a4.GetSize(); i++)
if (a4[i] == pPlayer->GetFactionID())
if (a4[i] == pPlayer.GetFactionID())
break;
if (i == a4.GetSize())
a4.Add(pPlayer->GetFactionID());
a4.Add(pPlayer.GetFactionID());
}
//*/
}
@@ -609,11 +614,11 @@ namespace PerfectWorld.Scripts.Managers
switch (Convert.ToInt32(Msg.dwParam2))
{
case int value2 when value2 == CommandID.OBJECT_CAST_SKILL: cid = (GPDataTypeHelper.FromBytes<cmd_object_cast_skill>((byte[]) Msg.dwParam1)).caster; break;
/* case CommandID.OBJECT_CAST_INSTANT_SKILL: cid = ((cmd_object_cast_instant_skill*)Msg.dwParam1)->caster; break;
case CommandID.OBJECT_CAST_POS_SKILL: cid = ((cmd_object_cast_pos_skill*)Msg.dwParam1)->caster; break;
case CommandID.SKILL_INTERRUPTED: cid = ((cmd_skill_interrupted*)Msg.dwParam1)->caster; break;
case CommandID.PLAYER_CAST_RUNE_SKILL: cid = ((cmd_player_cast_rune_skill*)Msg.dwParam1)->caster; break;
case CommandID.PLAYER_CAST_RUNE_INSTANT_SKILL: cid = ((cmd_player_cast_rune_instant_skill*)Msg.dwParam1)->caster; break;*/
/* case CommandID.OBJECT_CAST_INSTANT_SKILL: cid = ((cmd_object_cast_instant_skill*)Msg.dwParam1).caster; break;
case CommandID.OBJECT_CAST_POS_SKILL: cid = ((cmd_object_cast_pos_skill*)Msg.dwParam1).caster; break;
case CommandID.SKILL_INTERRUPTED: cid = ((cmd_skill_interrupted*)Msg.dwParam1).caster; break;
case CommandID.PLAYER_CAST_RUNE_SKILL: cid = ((cmd_player_cast_rune_skill*)Msg.dwParam1).caster; break;
case CommandID.PLAYER_CAST_RUNE_INSTANT_SKILL: cid = ((cmd_player_cast_rune_instant_skill*)Msg.dwParam1).caster; break;*/
}
break;
@@ -659,6 +664,72 @@ namespace PerfectWorld.Scripts.Managers
{
return CECGameRun.Instance.GetHostPlayer();
}
public bool OnMsgPlayerExtProp(ECMSG Msg)
{
object pData;
int idPlayer, iIndex;
switch (Msg.dwParam2)
{
case CommandID.PLAYER_EXT_PROP_BASE:
{
cmd_pep_base pCmd = GPDataTypeHelper.FromBytes<cmd_pep_base>((byte[])Msg.dwParam1);
idPlayer = pCmd.idPlayer;
pData = pCmd.ep_base;
iIndex = (int)ExtendPropertyClass.EXTPROPIDX_BASE;
break;
}
case CommandID.PLAYER_EXT_PROP_MOVE:
{
cmd_pep_move pCmd = GPDataTypeHelper.FromBytes<cmd_pep_move>((byte[])Msg.dwParam1);
idPlayer = pCmd.idPlayer;
pData = pCmd.ep_move;
iIndex = (int)ExtendPropertyClass.EXTPROPIDX_MOVE;
break;
}
case CommandID.PLAYER_EXT_PROP_ATK:
{
cmd_pep_attack pCmd = GPDataTypeHelper.FromBytes<cmd_pep_attack>((byte[])Msg.dwParam1);
idPlayer = pCmd.idPlayer;
pData = pCmd.ep_attack;
iIndex = (int)ExtendPropertyClass.EXTPROPIDX_ATTACK;
break;
}
case CommandID.PLAYER_EXT_PROP_DEF:
{
cmd_pep_def pCmd = GPDataTypeHelper.FromBytes<cmd_pep_def>((byte[])Msg.dwParam1);
idPlayer = pCmd.idPlayer;
pData = pCmd.ep_def;
iIndex = (int)ExtendPropertyClass.EXTPROPIDX_DEF;
break;
}
default:
return false;
}
if (!GPDataTypeHelper.ISPLAYERID(idPlayer))
{
//ASSERT(ISPLAYERID(idPlayer));
return false;
}
//CECGameSession* pSession = g_pGame.GetGameSession();
if (idPlayer == m_pHostPlayer.GetCharacterID())
{
GetHostPlayer().SetPartExtendProps(iIndex, pData);
}
else
{
EC_ElsePlayer pPlayer = SeekOutElsePlayer(idPlayer);
if (pPlayer)
pPlayer.SetPartExtendProps(iIndex, pData);
}
return true;
}
}
}
public struct EC_PLAYERLOADRESULT
@@ -17,6 +17,7 @@ public class CECObject : MonoBehaviour
protected static int ALPHA_HASH = Shader.PropertyToID("_Alpha");
protected Quaternion targetRotation;
protected Quaternion startRotation; // Store starting rotation for Slerp
protected Vector3 g_vAxisY = Vector3.up;
// Class ID
public static class Class_ID
@@ -115,6 +116,7 @@ public class CECObject : MonoBehaviour
m_bAdjustOrient = true;
m_dwOrientTime = dwTime;
m_dwOrientTimeCnt = 0;
startRotation = transform.rotation; // Store current rotation as start
targetRotation = Quaternion.LookRotation(vDir, Vector3.up);
}
@@ -182,13 +184,6 @@ public class CECObject : MonoBehaviour
{
vDir.Normalize();
}
// Xoay mượt từ rotation hiện tại sang rotation mục tiêu
/* transform.rotation = Quaternion.Slerp(
transform.rotation,
targetRotation,
Time.deltaTime * 5.0f
);*/
SetDestDirAndUp(vDir, g_vAxisY, timeturn);
}
protected virtual void Update()
@@ -287,25 +282,18 @@ public class CECObject : MonoBehaviour
protected void AdjustOrientation(float dwDeltaTime)
{
m_dwOrientTimeCnt += dwDeltaTime;
A3DMATRIX4 mat;
// Adjust model's orientation
if (m_dwOrientTimeCnt >= m_dwOrientTime)
{
SetDirAndUp(Vector3.forward,Vector3.up );
// Set final rotation to target (not Vector3.forward)
transform.rotation = targetRotation;
m_bAdjustOrient = false;
}
else
{
float f = (float)m_dwOrientTimeCnt / m_dwOrientTime;
transform.rotation = Quaternion.Slerp(
transform.rotation,
targetRotation,
f
);
SetDirAndUp(Vector3.forward, Vector3.up);
// Note: SetDirAndUp will change m_bAdjustOrient flag
// Interpolate from START to TARGET rotation based on time progress
float f = m_dwOrientTimeCnt / m_dwOrientTime;
transform.rotation = Quaternion.Slerp(startRotation, targetRotation, f);
m_bAdjustOrient = true;
}
}
+94 -13
View File
@@ -1,15 +1,7 @@
using BrewMonster.Network;
using BrewMonster.Scripts;
using CSNetwork;
using CSNetwork.C2SCommand;
using CSNetwork.GPDataType;
using CSNetwork.Protocols;
using System;
using System.Collections.Generic;
using System.Runtime.ConstrainedExecution;
using System.Security.Cryptography;
using System.Text;
using BrewMonster;
using UnityEngine;
namespace BrewMonster {
@@ -33,6 +25,21 @@ namespace BrewMonster {
float m_fBlockMove; // Block move counter
A3DVECTOR3 m_vBlockMove;
bool m_bLocalMove; // true, Moving info isn't sent to server
// Negative accelerate in water and air
public const float EC_NACCE_AIR = -5.0f;
public const float EC_NACCE_WATER = -5.0f;
// Push accelerate
public const float EC_PUSH_ACCE = 8.0f; // Normal push accelerate in air and water
public const float EC_FLYOFF_ACCE = 10.0f; // Fly off accelerate
public const float EC_SLOPE_Y = 0.5f;
public const float EC_GRAVITY = 9.8f;
// Move length minimum threshold
public const float MIN_MOVELEN_IN_AIR_WATER = 0.5f;
public const float MIN_MOVELEN_ON_GROUND = 0.5f;
public const float MIN_MOVELEN_FOR_DETECT_VIBRATION = 0.05f;
public CECHostMove(CECHostPlayer pHost)
{
@@ -112,7 +119,7 @@ namespace BrewMonster {
public void SendStopMoveCmd(in Vector3 vPos, float fSpeed, int iMoveMode)
{
Debug.LogWarning("HoangDev : SendStopMoveCmd");
UnityEngine.Debug.LogWarning("HoangDev : SendStopMoveCmd");
iMoveMode |= (int)GPMoveMode.GP_MOVE_DEAD;
if (cmdstopdelayCounter >= 500)
@@ -217,7 +224,7 @@ namespace BrewMonster {
if (fTime < 0.05f || fSpeed > 50.0f)
{
// tương đương ASSERT(0) trong C++, ở đây có thể Debug.LogWarning
Debug.LogWarning("CalcAverageSpeed: invalid input, fallback to default speed.");
UnityEngine.Debug.LogWarning("CalcAverageSpeed: invalid input, fallback to default speed.");
return fDefSpeed;
}
@@ -305,7 +312,7 @@ namespace BrewMonster {
cdr.fYVel += fSpeedV;
EC_CDR.OnGroundMove(ref cdr);
m_pHost.m_CDRInfo = cdr;
//if (g_pGame.GetGameRun().GetWorld().GetAssureMove())
// g_pGame.GetGameRun().GetWorld().GetAssureMove().AssureMove(m_pHost.m_aabbServer.Center, cdr.vCenter);
@@ -319,7 +326,9 @@ namespace BrewMonster {
m_iBlockedCnt = 0;
m_fBlockMove += (vNewPos - m_pHost.GetPos()).Magnitude();
m_vBlockMove += vNewPos - m_pHost.GetPos();
if ((m_fBlockTime += fTime) >= 1.0f)
m_fBlockTime += fTime;
//TO DO: in c++ set 1.0f. Convert to c#, this logic is wrong. If set time is 2.0, game run correct
if ((m_fBlockTime) >= 2.0f)
{
if (m_fBlockMove < GPDataTypeHelper.MIN_MOVELEN_ON_GROUND || m_vBlockMove.Magnitude() < GPDataTypeHelper.MIN_MOVELEN_FOR_DETECT_VIBRATION)
{
@@ -340,7 +349,79 @@ namespace BrewMonster {
public void SetSlideLock(bool bLock) { m_bSlideLock = bLock; }
// Is stoping ?
public bool IsStop() { return m_bStop; }
}
// Get host's last position sent to server
public Vector3 GetLastSevPos() { return m_vLastSevPos; }
public bool GetSlideLock() { return m_bSlideLock; }
// Air/Water move
public A3DVECTOR3 AirWaterMove(A3DVECTOR3 vSpeed, float fTime, bool bInAir, bool bTrace = false)
{
A3DVECTOR3 vDir = vSpeed;
float fSpeed = vDir.Normalize();
return AirWaterMove(vDir, fSpeed, fTime, bInAir, bTrace);
}
// Air/Water move
A3DVECTOR3 AirWaterMove(A3DVECTOR3 vDir, float fSpeed, float fTime, bool bInAir, bool bTrace/* false */)
{
A3DVECTOR3 vRealDir = vDir;
// OnAirMove only accept positive speed value
if (fSpeed< 0.0f)
{
vRealDir = -vDir;
fSpeed = -fSpeed;
}
float fMaxSpeed = bInAir ? m_pHost.GetFlySpeed() : m_pHost.GetSwimSpeedSev();
if (fSpeed > fMaxSpeed)
fSpeed = fMaxSpeed;
ON_AIR_CDR_INFO cdr = m_pHost.m_AirCDRInfo;
cdr.vCenter = m_pHost.m_aabbServer.Center;
cdr.vVelDir = vRealDir;
cdr.fSpeed = fSpeed;
cdr.fHeightThresh = bInAir? m_pHost.m_MoveConst.fMinAirHei : m_pHost.m_MoveConst.fMinWaterHei;
cdr.t = fTime;
cdr.bOnAir = bInAir;
// If player is tracing something, let he fly/swim low enough
// if (bTrace)
// cdr.fHeightThresh = 0.2f;
EC_CDR.OnAirMove(ref cdr);
// TO DO: fix later
//if(EC_Game.GetGameRun().GetWorld().GetAssureMove() )
// EC_Game.GetGameRun().GetWorld().GetAssureMove().NoAssureMove();
m_pHost.SetGroundNormal(GPDataTypeHelper.g_vAxisY);
A3DVECTOR3 vNewPos = cdr.vCenter - GPDataTypeHelper.g_vAxisY * m_pHost.m_aabbServer.Extents.y;
m_iBlockedCnt = 0;
m_fBlockMove += (vNewPos - m_pHost.GetPos()).Magnitude();
m_vBlockMove += vNewPos - m_pHost.GetPos();
if ((m_fBlockTime += fTime) >= 1.0f)
{
if (m_fBlockMove<MIN_MOVELEN_IN_AIR_WATER || m_vBlockMove.Magnitude() < MIN_MOVELEN_FOR_DETECT_VIBRATION)
{
m_iBlockedCnt = 5;
}
m_fBlockTime = 0.0f;
m_fBlockMove = 0.0f;
m_vBlockMove.Clear();
}
m_fMoveTime += fTime;
return vNewPos;
}
}
public struct CDR_INFO
{
//the aabb
+40 -7
View File
@@ -19,8 +19,6 @@ using Unity.VisualScripting;
using UnityEngine;
using UnityEngine.SceneManagement;
using BrewMonster.Network;
using UnityEngine.UIElements;
using static CECPlayer;
public abstract partial class CECPlayer : CECObject
{
@@ -64,7 +62,7 @@ public abstract partial class CECPlayer : CECObject
private QueueActionEvent queueActionEvent;
protected static PLAYER_LEVELEXP_CONFIG _player_levelup_exp;
private CECPlayerActionController m_pActionController;
private enumWingType m_wingType;
private enumWingType m_wingType = enumWingType.WINGTYPE_FLYSWORD;
protected int m_idCurSkillTarget;
protected CECSkill m_pCurSkill;
@@ -82,6 +80,7 @@ public abstract partial class CECPlayer : CECObject
string m_strName; // Player name
// 需要是可能 || Need is possible
protected bool m_bHangerOn = false;
protected int m_iCurAction;
public MOVECONST m_MoveConst; // Const used when moving control
public Move_Mode m_MoveMode;
@@ -382,7 +381,7 @@ public abstract partial class CECPlayer : CECObject
return PlayActionWithConfig(iAction, 0, bRestart, iTransTime, bQueue);
}
public bool PlayActionWithConfig(int iAction, int actionConfigID, bool bRestart = true, int iTransTime = 200,
private bool PlayActionWithConfig(int iAction, int actionConfigID, bool bRestart = true, int iTransTime = 200,
bool bQueue = false)
{
if (iAction < 0 || iAction >= (int)PLAYER_ACTION_TYPE.ACT_MAX)
@@ -406,13 +405,13 @@ public abstract partial class CECPlayer : CECObject
{
}
}
return PlayActionWithConfig(iAction, m_PlayerActions[iAction], bRestart, iTransTime, bQueue);
}
public bool PlayActionWithConfig(int iAction, in PLAYER_ACTION actionConfig,
private bool PlayActionWithConfig(int iAction, in PLAYER_ACTION actionConfig,
bool bRestart = true, int iTransTime = 200, bool bQueue = false)
{
m_iCurAction = iAction;
PLAYER_ACTION action = actionConfig;
var szAct = EC_Utility.BuildActionName(action, 0);
@@ -1444,7 +1443,7 @@ public abstract partial class CECPlayer : CECObject
public float GetGroundSpeed()
{
// return m_bWalkRun ? g_pGame.GetConfigs().GetHostRunSpeed() : m_ExtProps.mv.walk_speed;
return 5f;
//return 5f;
return m_bWalkRun ? m_ExtProps.mv.run_speed : m_ExtProps.mv.walk_speed;
}
@@ -1561,6 +1560,40 @@ public abstract partial class CECPlayer : CECObject
{
return m_strName;
}
public enumWingType GetWingType() { return m_wingType; }
// Set part extend properties
public void SetPartExtendProps(int iPropIdx, object pData)
{
switch (iPropIdx)
{
case (int)ExtendPropertyClass.EXTPROPIDX_BASE:
m_ExtProps.bs = (ROLEEXTPROP_BASE)pData;
break;
case (int)ExtendPropertyClass.EXTPROPIDX_MOVE:
m_ExtProps.mv = (ROLEEXTPROP_MOVE)pData;
break;
case (int)ExtendPropertyClass.EXTPROPIDX_ATTACK:
m_ExtProps.ak = (ROLEEXTPROP_ATK)pData;
break;
case (int)ExtendPropertyClass.EXTPROPIDX_DEF:
m_ExtProps.df = (ROLEEXTPROP_DEF)pData;
break;
default:
//ASSERT(0);
return;
}
}
}
public struct PlayActionEvent
+86 -28
View File
@@ -212,7 +212,7 @@ namespace BrewMonster.Scripts
{
vDelta = vVelocity * fTime;
float fDeltaDist = vDelta.magnitude;
//if (fDeltaDist < DIST_EPSILON) break;
if (fDeltaDist < DIST_EPSILON) break;
// TO DO: fix later beacuse logic in CollideWithEnv_BoxCast is wrong
//bool hasHit = CollideWithEnv_BoxCast(vStart, vDelta, vExt, mask,
@@ -227,7 +227,7 @@ namespace BrewMonster.Scripts
CDRInfo.fMoveDist += fDeltaDist;
break;
}
//if (bStartSolid)
//if (trcInfo.bStartSolid)
//{
// CDRInfo.fMoveDist = 0f;
// if (CDRInfo.vTPNormal.y < CDRInfo.fSlopeThresh) CDRInfo.vTPNormal = Vector3.up;
@@ -273,35 +273,35 @@ namespace BrewMonster.Scripts
bTryPull = true;
}
//if (!bPull)
//{
// if (vVelocity.sqrMagnitude > 1e-12f)
// {
// vVelDir = vVelocity.normalized;
// fVelSpeed = vVelocity.magnitude * (1f - nTry * 0.1f);
if (!bPull)
{
if (vVelocity.sqrMagnitude > 1e-12f)
{
vVelDir = vVelocity.normalized;
fVelSpeed = vVelocity.magnitude * (1f - nTry * 0.1f);
// dtp = Vector3.Dot(vNormal, vVelDir);
// float fRelSpeed = Mathf.Min(fVelSpeed, 5.0f);
dtp = Vector3.Dot(vNormal, vVelDir);
float fRelSpeed = Mathf.Min(fVelSpeed, 5.0f);
// if (dtp >= 0f && dtp < 1e-4f)
// {
// vVelocity += vNormal * VEL_REFLECT * fRelSpeed;
// }
// else
// {
// vVelocity = (vVelDir - vNormal * dtp) * fVelSpeed - vNormal * dtp * VEL_REFLECT * fRelSpeed;
// }
// }
if (dtp >= 0f && dtp < 1e-4f)
{
vVelocity += vNormal * VEL_REFLECT * fRelSpeed;
}
else
{
vVelocity = (vVelDir - vNormal * dtp) * fVelSpeed - vNormal * dtp * VEL_REFLECT * fRelSpeed;
}
}
// if (fYVel > VEL_EPSILON)
// {
// if (vNormal.y >= CDRInfo.fSlopeThresh || vNormal.y < -NORMAL_EPSILON) fYVel = 0f;
// }
// else if (fYVel < -VEL_EPSILON)
// {
// if (vNormal.y >= CDRInfo.fSlopeThresh) fYVel = 0f;
// }
//}
if (fYVel > VEL_EPSILON)
{
if (vNormal.y >= CDRInfo.fSlopeThresh || vNormal.y < -NORMAL_EPSILON) fYVel = 0f;
}
else if (fYVel < -VEL_EPSILON)
{
if (vNormal.y >= CDRInfo.fSlopeThresh) fYVel = 0f;
}
}
}
// “vertical ground trace” thay RetrieveSupportPlane
@@ -552,6 +552,30 @@ namespace BrewMonster.Scripts
//return bBrush;
}
public static void OnAirMove(ref ON_AIR_CDR_INFO awmInfo)
{
//assert(0 && "Not ready yet");
if (awmInfo.bOnAir)
{
AirMove(ref awmInfo);
}
else
{
WaterMove(ref awmInfo);
}
}
static void AirMove(ref ON_AIR_CDR_INFO awmInfo)
{
}
static void WaterMove(ref ON_AIR_CDR_INFO awmInfo)
{
}
}
public struct OtherPlayer_Move_Info
{
@@ -582,4 +606,38 @@ namespace BrewMonster.Scripts
public bool bStartSolid; //start in solid
public uint dwClsFlag; //collision flag
};
// for on-air move case
//@note : change to AABB. By Kuiwu[22/9/2005]
public struct ON_AIR_CDR_INFO
{
public A3DVECTOR3 vCenter;
public A3DVECTOR3 vExtent;
// Hold a height from the surface of terrain or building
public float fHeightThresh;
// Velocity Info
public A3DVECTOR3 vVelDir;
public float fSpeed;
// time span ( sec )
public float t;
//@note : SlopeThresh seems useless on air or under water. By Kuiwu[22/9/2005]
// Slope Thresh
//float fSlopeThresh;
// Distance Thresh under the water surface
public float fUnderWaterDistThresh;
public A3DVECTOR3 vTPNormal;
// On air or water, true if on air, false for on water case.
public bool bOnAir;
// After the move action is done, If the fHeightThresh
// still be satisfied, bMeetHeightThresh is set to true.
public bool bMeetHeightThresh;
};
}
+1 -1
View File
@@ -392,7 +392,7 @@ public class CECNPC : CECObject
{
return m_pNPCModelPolicy.PlayAttackAction(nAttackSpeed, attackevent);
}
void NPCTurnFaceTo(int idTarget, float dwTime = 0)
void NPCTurnFaceTo(int idTarget, float dwTime = 0.3f)
{
if (IsDirFixed())
{
@@ -55,7 +55,7 @@ namespace CSNetwork
public static int MSG_HST_GAINITEM = 243; // Gain item in or after trade
public static int MSG_HST_SELTARGET = 244; // Select / unselect target, p1 - data address; p2 - command ID
public static int MSG_HST_FIXCAMERA = 245; // Fix camera
public static int MSG_HST_OWNEXTPROP = 246; // Host extend properties
public const int MSG_HST_OWNEXTPROP = 246; // Host extend properties
public static int MSG_HST_ADDSTATUSPT = 247; // Add status point
public static int MSG_HST_RBTNCLICK = 248; // Left button click, p1 - x; p2 - y; p2 - y; p3 - SHIFT, ALT, CTRL key states
public static int MSG_HST_JOINTEAM = 249; // Host join team
@@ -174,7 +174,7 @@ namespace CSNetwork
public static int MSG_PM_PLAYERDISAPPEAR = 359; // Player disappear, p1 - data address
public static int MSG_PM_PLAYERSTOPMOVE = 360; // Player stop move, p1 - data address
public static int MSG_PM_PLAYERLEVELUP = 361; // Player level up
public static int MSG_PM_PLAYEREXTPROP = 362; // Player extend properties
public const int MSG_PM_PLAYEREXTPROP = 362; // Player extend properties
// #define MSG_PM_TEAMMEMBERDATA 363 // Team member data
public static int MSG_PM_LEAVETEAM = 364; // Player leave team
public static int MSG_PM_PLAYEREQUIPDATA = 365; // Player equipment data
@@ -1752,6 +1752,52 @@ namespace CSNetwork.GPDataType
public byte[] placeholder; // Task data ...
}
// PLAYER_EXT_PROP_BASE
[StructLayout(LayoutKind.Sequential, Pack = 1)]
public struct cmd_pep_base
{
public int idPlayer;
public ROLEEXTPROP_BASE ep_base;
};
// PLAYER_EXT_PROP_MOVE
[StructLayout(LayoutKind.Sequential, Pack = 1)]
public struct cmd_pep_move
{
public int idPlayer;
public ROLEEXTPROP_MOVE ep_move;
};
// PLAYER_EXT_PROP_ATK
[StructLayout(LayoutKind.Sequential, Pack = 1)]
public struct cmd_pep_attack
{
public int idPlayer;
public ROLEEXTPROP_ATK ep_attack;
};
// PLAYER_EXT_PROP_DEF
[StructLayout(LayoutKind.Sequential, Pack = 1)]
public struct cmd_pep_def
{
public int idPlayer;
public ROLEEXTPROP_DEF ep_def;
};
[StructLayout(LayoutKind.Sequential, Pack = 1)]
public struct cmd_own_ext_prop
{
public uint status_point;
public int attack_degree; //¹¥»÷µÈ¼¶
public int defend_degree; //·ÀÓùµÈ¼¶
public int crit_rate;
public int crit_damage_bonus;
public int invisible_degree;
public int anti_invisible_degree;
public int penetration;
public int resilience;
public int vigour;
public ROLEEXTPROP prop;
};
}
@@ -715,6 +715,15 @@ namespace CSNetwork
case CommandID.CHANGE_FACE_END:
EC_ManMessage.PostMessage(EC_MsgDef.MSG_HST_CHANGEFACE, MANAGER_INDEX.MAN_PLAYER, 0, pDataBuf, pCmdHeader, dwDataSize);
break;
case CommandID.PLAYER_EXT_PROP_BASE:
case CommandID.PLAYER_EXT_PROP_MOVE:
case CommandID.PLAYER_EXT_PROP_ATK:
case CommandID.PLAYER_EXT_PROP_DEF:
EC_ManMessage.PostMessage(EC_MsgDef.MSG_PM_PLAYEREXTPROP, MANAGER_INDEX.MAN_PLAYER, -1, pDataBuf, pCmdHeader);
break;
case CommandID.OWN_EXT_PROP:
EC_ManMessage.PostMessage(EC_MsgDef.MSG_HST_OWNEXTPROP, MANAGER_INDEX.MAN_PLAYER, 0, pDataBuf, pCmdHeader);
break;
}
}
@@ -46,7 +46,6 @@ namespace BrewMonster.Managers
private void OnDestroy()
{
EC_ManMessage.Dispose();
CECGameRun.Dispose();
}
private void Update()
@@ -139,7 +139,21 @@ namespace PerfectWorld.Scripts.Player
//if (!m_pPlayerModel) return;
//if (!IsValidAction(iCurAction)) return;
PlayAction(GetMoveStandAction(true), true, 1, false);
// PlayAction(GetMoveStandAction(true), true, 1, false);
// Play action
if (IsValidAction(m_iCurAction))
{
if (!IsPlayingAction((int)PLAYER_ACTION_TYPE.ACT_TRICK_JUMP) && !IsPlayingAction((int)PLAYER_ACTION_TYPE.ACT_TRICK_RUN))
{
if (m_iMoveMode == Move_Mode.MOVE_JUMP || m_iMoveMode == Move_Mode.MOVE_SLIDE)
PlayAction((int)PLAYER_ACTION_TYPE.ACT_JUMP_LOOP, false);
else
PlayAction(GetMoveStandAction(true), false);
}
}
else
PlayAction(GetMoveStandAction(true), true, 1, false);
}
public bool MovingTo(float dwDeltaTime)
@@ -155,15 +169,20 @@ namespace PerfectWorld.Scripts.Player
float fDist = vDir.Normalize();
if (vDir.IsZero()) return false;
Quaternion targetRotation = Quaternion.LookRotation(EC_Utility.ToVector3(vDir));
if (Quaternion.Angle(transform.rotation, targetRotation) < 0.5f)
transform.rotation = targetRotation;
else
transform.rotation = Quaternion.Slerp(
transform.rotation,
targetRotation,
rotationSpeed * Time.deltaTime
);
Vector3 flatDir = EC_Utility.ToVector3(vDir);
flatDir.y = 0;
if (flatDir.sqrMagnitude > 0.001f)
{
Quaternion targetRotation = Quaternion.LookRotation(flatDir);
if (Quaternion.Angle(transform.rotation, targetRotation) < 0.5f)
transform.rotation = targetRotation;
else
transform.rotation = Quaternion.Slerp(
transform.rotation,
targetRotation,
rotationSpeed * Time.deltaTime
);
}
vPos = MoveStep(vDir, m_fMoveSpeed, fDeltaTime);
@@ -188,15 +207,20 @@ namespace PerfectWorld.Scripts.Player
A3DVECTOR3 vDir = m_vMoveDir;
vDir.Normalize();
Quaternion targetRotation = Quaternion.LookRotation(EC_Utility.ToVector3(vDir));
if (Quaternion.Angle(transform.rotation, targetRotation) < 0.5f)
transform.rotation = targetRotation;
else
transform.rotation = Quaternion.Slerp(
transform.rotation,
targetRotation,
rotationSpeed * Time.deltaTime
);
Vector3 flatDir = EC_Utility.ToVector3(vDir);
flatDir.y = 0;
if (flatDir.sqrMagnitude > 0.001f)
{
Quaternion targetRotation = Quaternion.LookRotation(flatDir);
if (Quaternion.Angle(transform.rotation, targetRotation) < 0.5f)
transform.rotation = targetRotation;
else
transform.rotation = Quaternion.Slerp(
transform.rotation,
targetRotation,
rotationSpeed * Time.deltaTime
);
}
vPos = MoveStep(vDir, m_fMoveSpeed, fDeltaTime);
SetPos(vPos);
float fDist = A3d_Magnitude(m_vServerPos - vCurPos);
@@ -296,10 +320,10 @@ namespace PerfectWorld.Scripts.Player
m_cdr.vCenter += vDelta;
m_cdr.vecGroundNormal = g_vAxisY;
//if (m_cdr.bTraceGround)
// SetGroundNormal(m_cdr.vecGroundNormal);
//else
// SetGroundNormal(g_vAxisY);
if (m_cdr.bTraceGround)
SetGroundNormal(m_cdr.vecGroundNormal);
else
SetGroundNormal(g_vAxisY);
return m_cdr.vCenter - g_vAxisY * m_cdr.vExts.y;
}
@@ -614,6 +638,11 @@ namespace PerfectWorld.Scripts.Player
//
PlayGfx(EC_Resource.res_GFXFile((int)GfxResourceType.RES_GFX_LEVELUP), null, 1f,1);//PLAYERMODEL_TYPEALL
}
bool IsPlayingAction(int iAction)
{
return m_iCurAction == iAction;
}
}
// Player appear flag
@@ -44,7 +44,7 @@ namespace BrewMonster.PerfectWorld.Scripts.Vfx
{
if(!string.IsNullOrEmpty(_vfxPath))
{
AddressableManager.Instance.UnloadAsset(_vfxPath);
AddressableManager.Instance.ReleaseAsset(_vfxPath);
}
}
+7 -6
View File
@@ -29,25 +29,26 @@ public partial class CECGameRun
public void Init()
{
Application.targetFrameRate = 60;
instance = this;
// _gameRunConfig = Resources.Load<GameRunConfig>("GameRunConfig");
// _playerPrefab = _gameRunConfig.PlayerPrefab;
// _monsterPrefab = _gameRunConfig.MonsterPrefab;
// _npcServerPrefab = _gameRunConfig.NpcServerPrefab;
// _testVfxPrefab = _gameRunConfig.TestVfxPrefab;
LoadPrefabs();
// LoadPrefabs();
EC_ManMessage.RegisterHandler(this);
AddressableManager.Instance.OnDispose += Dispose;
}
public static void Dispose()
private static void Dispose()
{
instance = null;
AddressableManager.Instance.UnloadAsset(AddressResourceConfig.PlayerPrefab);
AddressableManager.Instance.UnloadAsset(AddressResourceConfig.MonsterPrefab);
AddressableManager.Instance.UnloadAsset(AddressResourceConfig.NpcServerPrefab);
AddressableManager.Instance.UnloadAsset(AddressResourceConfig.TestVfxPrefab);
AddressableManager.Instance.ReleaseAsset(AddressResourceConfig.PlayerPrefab);
AddressableManager.Instance.ReleaseAsset(AddressResourceConfig.MonsterPrefab);
AddressableManager.Instance.ReleaseAsset(AddressResourceConfig.NpcServerPrefab);
}
private async void LoadPrefabs()
+364 -123
View File
@@ -5,6 +5,7 @@ using BrewMonster.PerfectWorld.Scripts.Vfx;
using BrewMonster.Scripts;
using BrewMonster.Scripts.Managers;
using BrewMonster.Scripts.Skills;
using BrewMonster.Scripts.World;
using CSNetwork;
using CSNetwork.GPDataType;
using CSNetwork.Protocols.RPCData;
@@ -85,6 +86,10 @@ namespace BrewMonster
private float m_fPrayDistancePlus;
private A3DVECTOR3 g_vOrigin = new A3DVECTOR3(0f);
private Transform playerTransform;
private float EC_SLOPE_Y = 0.5f;
int m_iOldWalkMode = Move_Mode.MOVE_STAND; // Copy of work mode
public uint m_dwMoveRelDir = 0; // Move relative direction flags
public ON_AIR_CDR_INFO m_AirCDRInfo;
// ====== Ground cast config ======
[Header("Ground Cast")]
@@ -249,20 +254,23 @@ namespace BrewMonster
}
#endif
// Update cursor based on what's under mouse
EstimateCursor();
//Debug.Log($"(ulong)Time.deltaTime * 1000 {(ulong)(Time.deltaTime * 1000)}");
m_MoveCtrl.Tick((ulong)(Time.deltaTime * 1000));
// Nếu có thay đổi runtime, có thể lấy lại mỗi vài giây/Start nếu bạn thích:
// ccRadius = controller.radius; ccSkin = controller.skinWidth;
EstimateMoveEnv(GetPos());
OnKeyDown();
m_pWorkMan?.Tick(Time.deltaTime);
// Update cursor based on what's under mouse
EstimateCursor();
// Update GFXs
UpdateGFXs(Time.deltaTime);
//m_dwMoveRelDir = 0;
m_fVertSpeed = 0.0f;
}
public void StopMovement()
@@ -408,6 +416,7 @@ namespace BrewMonster
case int value when value == EC_MsgDef.MSG_HST_STARTATTACK: OnMsgHstStartAttack(Msg); break;
case int value when value == EC_MsgDef.MSG_HST_STOPATTACK: OnMsgHstStopAttack(Msg); break;
case int value when value == EC_MsgDef.MSG_HST_SKILLRESULT: OnMsgHstSkillResult(Msg); break;
case int value when value == EC_MsgDef.MSG_HST_OWNEXTPROP: OnMsgHstExtProp(Msg); break;
}
@@ -1243,25 +1252,38 @@ namespace BrewMonster
m_aabb.Center = GPDataTypeHelper.g_vOrigin;
m_aabb.Extents.Set(0.3f, 0.9f, 0.3f);
m_aabbServer = m_aabb;
m_MoveConst.fStepHei = 0.8f;
m_MoveConst.fMinAirHei = 1.6f;
m_MoveConst.fMinWaterHei = 0.3f;
m_MoveConst.fShoreDepth = 1.6f;
m_MoveConst.fWaterSurf = 0.6f;
CalcPlayerAABB();
SetPos(pos);
m_CDRInfo.fStepHeight = 0.8f;
//m_CDRInfo.vTPNormal = GroundCheck(out RaycastHit hit) ? hit.normal : Vector3.zero;
m_CDRInfo.vExtent = EC_Utility.ToVector3(m_aabbServer.Extents);
m_CDRInfo.vTPNormal = EC_Utility.ToVector3(g_vOrigin);
m_CDRInfo.fYVel = 0.0f;
m_CDRInfo.fSlopeThresh = EC_SLOPE_Y;
m_CDRInfo.fStepHeight = m_MoveConst.fStepHei;
m_AirCDRInfo.vExtent = m_aabbServer.Extents;
m_AirCDRInfo.fUnderWaterDistThresh = m_MoveConst.fWaterSurf;
// Create work manager
m_pWorkMan = new CECHPWorkMan(this);
m_pWorkMan.StartWork_p0(m_pWorkMan.CreateWork(Host_work_ID.WORK_STAND));
if (IsDead())
{
//CECHPWorkDead pWork = (CECHPWorkDead*)m_pWorkMan->CreateWork(CECHPWork.Host_work_ID.WORK_DEAD);
//pWork->SetBeDeadFlag(true);
//m_pWorkMan->StartWork_p0(pWork);
EventBus.PublishChannel(GetCharacterID(), new CECPlayer.ClearComActFlagAllRankNodesEvent(true));
PlayAction((int)PLAYER_ACTION_TYPE.ACT_GROUNDDIE);
if (PopupManager.Instance != null)
{
PopupManager.Instance.OnPlayerDied();
}
//CECHPWorkDead pWork = (CECHPWorkDead*)m_pWorkMan.CreateWork(CECHPWork.Host_work_ID.WORK_DEAD);
//pWork.SetBeDeadFlag(true);
//m_pWorkMan.StartWork_p0(pWork);
EventBus.PublishChannel(GetCharacterID(), new CECPlayer.ClearComActFlagAllRankNodesEvent(true));
PlayAction((int)PLAYER_ACTION_TYPE.ACT_GROUNDDIE);
if (PopupManager.Instance != null)
{
PopupManager.Instance.OnPlayerDied();
}
}
else
{
@@ -1276,7 +1298,7 @@ namespace BrewMonster
pWork.SetBeSittingFlag(true);
m_pWorkMan.StartWork_p1(pWork);
}*/
m_GndInfo.bOnGround = GroundCheck(out lastGroundHit);
LoadResources();
if (m_pWorkMan == null)
{
@@ -1791,6 +1813,44 @@ namespace BrewMonster
{
return m_ExtProps.mv.swim_speed;
}
public float GetSwimSpeedSev()
{
float fSpeedSev = GetSwimSpeed();
LayerMask layerGround = 1 << 6;
LayerMask layerWater = 1 << 8;
while (true)
{
if (!IsUnderWater()) break;
CECWorld pWorld = EC_Game.GetGameRun().GetWorld();
if (pWorld == null) break;
A3DVECTOR3 vPos = GetPos();
Vector3 startPoint = EC_Utility.ToVector3(vPos);
Vector3 dir = EC_Utility.ToVector3(vPos) + Vector3.down;
float fTerrainHeight = 0f;
if (Physics.Raycast(startPoint, dir, out hit, layerGround))
{
fTerrainHeight = Vector3.Distance(hit.point, startPoint);
}
float fWaterHeight = 0f;
if (Physics.Raycast(startPoint, dir, out hit, layerWater))
{
fWaterHeight = Vector3.Distance(hit.point, startPoint);
}
if (fWaterHeight <= fTerrainHeight) break;
float fBorderLine = fWaterHeight - 2.0f;
if (vPos.y <= fBorderLine) break;
// ·þÎñÆ÷¶Ë½«Ë®ÃæÒÔÏÂ2Ã×ÒÔÉÏ´¦ÀíΪ run_speed£¨ÓÐÎÊÌ⣩
// µ«Î´Ê¹ÓüÓËÙ¼¼ÄÜʱ swim_speed СÓÚ run_speed£¬
// ¿ÉÒÔÔÚË®ÃæÒÔÏÂ2Ã×ÒÔÉÏ»ñÈ¡³¬¹ý swim_speed µÄËÙ¶È£¬Òò´Ë£¬´Ë´¦È¡Á½Õß½ÏСֵΪºÏÀí×ö·¨
fSpeedSev = Math.Min(m_ExtProps.mv.run_speed, fSpeedSev);
break;
}
return fSpeedSev;
}
public bool ApplySkillShortcut(int idSkill, bool bCombo = false /* false */,
int idSelTarget = 0/* 0 */, int iForceAtk = -1/* -1 */)
{
@@ -2866,134 +2926,134 @@ namespace BrewMonster
vRight.z = joystick.Vertical;
vRight.y = 0f;
vRight.Normalize();
if(vRight == Vector3.zero)
if (vRight == Vector3.zero)
{
return false;
}
vPushDir = vRight;
/* // reset
vPushDir = Vector3.zero;
Vector3 vRight = Vector3.zero;
bool bMove = false;
/* // reset
vPushDir = Vector3.zero;
Vector3 vRight = Vector3.zero;
bool bMove = false;
// Không bấm gì → không có hướng
if (m_dwMoveRelDir == 0)
return false;
// Không bấm gì → không có hướng
if (m_dwMoveRelDir == 0)
return false;
// ===== LEFT =====
if ((m_dwMoveRelDir & MD_LEFT) != 0)
{
// Nếu trên không → xoay camera thay vì di chuyển
if (m_iMoveEnv == MOVEENV_AIR)
{
// giữ nguyên logic PW
ECMSG msg = new ECMSG();
msg.dwParam2 = 0;
msg.dwParam1 = (uint)(_yaw_vel_air * deltaTime);
// ===== LEFT =====
if ((m_dwMoveRelDir & MD_LEFT) != 0)
{
// Nếu trên không → xoay camera thay vì di chuyển
if (m_iMoveEnv == MOVEENV_AIR)
{
// giữ nguyên logic PW
ECMSG msg = new ECMSG();
msg.dwParam2 = 0;
msg.dwParam1 = (uint)(_yaw_vel_air * deltaTime);
if ((m_dwMoveRelDir & MD_BACK) != 0)
msg.dwParam1 = (uint)(-(int)msg.dwParam1);
if ((m_dwMoveRelDir & MD_BACK) != 0)
msg.dwParam1 = (uint)(-(int)msg.dwParam1);
OnMsgHstYaw(msg); // TODO: bạn map hàm này sang Unity
}
else if (m_iMoveEnv == MOVEENV_WATER)
{
ECMSG msg = new ECMSG();
msg.dwParam2 = 0;
msg.dwParam1 = (uint)(_yaw_vel * deltaTime);
OnMsgHstYaw(msg); // TODO: bạn map hàm này sang Unity
}
else if (m_iMoveEnv == MOVEENV_WATER)
{
ECMSG msg = new ECMSG();
msg.dwParam2 = 0;
msg.dwParam1 = (uint)(_yaw_vel * deltaTime);
if ((m_dwMoveRelDir & MD_BACK) != 0)
msg.dwParam1 = (uint)(-(int)msg.dwParam1);
if ((m_dwMoveRelDir & MD_BACK) != 0)
msg.dwParam1 = (uint)(-(int)msg.dwParam1);
OnMsgHstYaw(msg); // TODO
}
else
{
// Mặt đất → di chuyển sang trái theo camera
// C++: vRight = -m_CameraCoord.GetRight();
Vector3 camRight = m_CameraCoord.GetRight(); // TODO: map sang Unity Camera?
vRight = -camRight;
vRight.y = 0;
vRight.Normalize();
OnMsgHstYaw(msg); // TODO
}
else
{
// Mặt đất → di chuyển sang trái theo camera
// C++: vRight = -m_CameraCoord.GetRight();
Vector3 camRight = m_CameraCoord.GetRight(); // TODO: map sang Unity Camera?
vRight = -camRight;
vRight.y = 0;
vRight.Normalize();
vPushDir = vRight;
bMove = true;
}
}
vPushDir = vRight;
bMove = true;
}
}
// ===== RIGHT =====
else if ((m_dwMoveRelDir & MD_RIGHT) != 0)
{
if (m_iMoveEnv == MOVEENV_AIR)
{
ECMSG msg = new ECMSG();
msg.dwParam2 = 0;
msg.dwParam1 = (uint)((-_yaw_vel_air) * deltaTime);
// ===== RIGHT =====
else if ((m_dwMoveRelDir & MD_RIGHT) != 0)
{
if (m_iMoveEnv == MOVEENV_AIR)
{
ECMSG msg = new ECMSG();
msg.dwParam2 = 0;
msg.dwParam1 = (uint)((-_yaw_vel_air) * deltaTime);
if ((m_dwMoveRelDir & MD_BACK) != 0)
msg.dwParam1 = (uint)(-(int)msg.dwParam1);
if ((m_dwMoveRelDir & MD_BACK) != 0)
msg.dwParam1 = (uint)(-(int)msg.dwParam1);
OnMsgHstYaw(msg); // TODO
}
else if (m_iMoveEnv == MOVEENV_WATER)
{
ECMSG msg = new ECMSG();
msg.dwParam2 = 0;
msg.dwParam1 = (uint)((-_yaw_vel) * deltaTime);
OnMsgHstYaw(msg); // TODO
}
else if (m_iMoveEnv == MOVEENV_WATER)
{
ECMSG msg = new ECMSG();
msg.dwParam2 = 0;
msg.dwParam1 = (uint)((-_yaw_vel) * deltaTime);
if ((m_dwMoveRelDir & MD_BACK) != 0)
msg.dwParam1 = (uint)(-(int)msg.dwParam1);
if ((m_dwMoveRelDir & MD_BACK) != 0)
msg.dwParam1 = (uint)(-(int)msg.dwParam1);
OnMsgHstYaw(msg); // TODO
}
else
{
// Mặt đất → di chuyển sang phải theo camera
Vector3 camRight = m_CameraCoord.GetRight(); // TODO
vRight = camRight;
vRight.y = 0;
vRight.Normalize();
OnMsgHstYaw(msg); // TODO
}
else
{
// Mặt đất → di chuyển sang phải theo camera
Vector3 camRight = m_CameraCoord.GetRight(); // TODO
vRight = camRight;
vRight.y = 0;
vRight.Normalize();
vPushDir = vRight;
bMove = true;
}
}
vPushDir = vRight;
bMove = true;
}
}
// ===== FORWARD =====
if ((m_dwMoveRelDir & MD_FORWARD) != 0)
{
Vector3 forward = m_CameraCoord.GetDir(); // TODO
forward.y = 0;
forward.Normalize();
// ===== FORWARD =====
if ((m_dwMoveRelDir & MD_FORWARD) != 0)
{
Vector3 forward = m_CameraCoord.GetDir(); // TODO
forward.y = 0;
forward.Normalize();
vPushDir = forward;
vPushDir = forward;
if (bMove)
{
vPushDir += vRight;
vPushDir.Normalize();
}
}
// ===== BACK =====
else if ((m_dwMoveRelDir & MD_BACK) != 0)
{
Vector3 back = -m_CameraCoord.GetDir(); // TODO
back.y = 0;
back.Normalize();
if (bMove)
{
vPushDir += vRight;
vPushDir.Normalize();
}
}
// ===== BACK =====
else if ((m_dwMoveRelDir & MD_BACK) != 0)
{
Vector3 back = -m_CameraCoord.GetDir(); // TODO
back.y = 0;
back.Normalize();
vPushDir = back;
vPushDir = back;
if (bMove)
{
vPushDir += vRight;
vPushDir.Normalize();
}
}
// ===== ABS UP (nếu mask cho phép) =====
else if (((m_dwMoveRelDir & MD_ABSUP) != 0) && ((dwMask & MD_ABSUP) != 0))
{
vPushDir = Vector3.up;
}*/
if (bMove)
{
vPushDir += vRight;
vPushDir.Normalize();
}
}
// ===== ABS UP (nếu mask cho phép) =====
else if (((m_dwMoveRelDir & MD_ABSUP) != 0) && ((dwMask & MD_ABSUP) != 0))
{
vPushDir = Vector3.up;
}*/
return true;
}
@@ -3350,10 +3410,192 @@ namespace BrewMonster
}
public void SetRotationHP(Vector3 dir)
{
{
transform.rotation = Quaternion.LookRotation(dir);
}
}
// Estimate move environment
void EstimateMoveEnv(A3DVECTOR3 vPos)
{
if (IsFlying())
{
m_iMoveEnv = Move_environment.MOVEENV_AIR;
return;
}
CECWorld pWorld = EC_Game.GetGameRun().GetWorld();
LayerMask layerMaskTerrain = 1 << 6;
LayerMask layerMaskBush = 1 << 7;
Vector3 vStart = EC_Utility.ToVector3(vPos);
Vector3 vGndPos0 = Vector3.zero;
Vector3 vTestPos0 = m_MoveCtrl.GetLastSevPos() + g_vAxisY * m_aabbServer.Extents.y;
VertRayTrace(vTestPos0, ref vGndPos0, ref m_GndInfo.vGndNormal, 1000f);
m_GndInfo.fGndHei = vGndPos0.y;
Vector3 vAABBGnd = Vector3.zero;
VertAABBTrace(vTestPos0, EC_Utility.ToVector3(m_aabbServer.Extents), ref vAABBGnd, ref m_GndInfo.vGndNormal, 1000f);
vAABBGnd.y -= m_aabbServer.Extents.y;
bool bIsInAir = false;
if (m_MoveCtrl.GetLastSevPos().y - vAABBGnd.y > 0.2f)
bIsInAir = true;
Vector3 vGndPos = Vector3.zero;
A3DVECTOR3 vTestPos = vPos + EC_Utility.ToA3DVECTOR3(g_vAxisY) * m_aabbServer.Extents.y;
VertRayTrace(EC_Utility.ToVector3(vTestPos), ref vGndPos, ref m_GndInfo.vGndNormal, 1000f);
m_GndInfo.fGndHei = vGndPos.y;
//m_GndInfo.fWaterHei = pWorld.GetWaterHeight(vTestPos);
VertAABBTrace(EC_Utility.ToVector3(vTestPos), EC_Utility.ToVector3(m_aabbServer.Extents), ref vAABBGnd, ref m_GndInfo.vGndNormal, 1000f);
vAABBGnd.y -= m_aabbServer.Extents.y;
int iNewEnv = Move_environment.MOVEENV_GROUND;
if (iNewEnv == Move_environment.MOVEENV_GROUND && GetPos().y - vAABBGnd.y < 0.2f && bIsInAir && EC_Utility.ToVector3(GetPos()) != m_MoveCtrl.GetLastSevPos())
{
m_MoveCtrl.SendMoveCmd(GetPos(), 2, EC_Utility.ToA3DVECTOR3(g_vAxisY), EC_Utility.ToA3DVECTOR3(m_CDRInfo.vAbsVelocity), m_iMoveMode, true);
// BubbleText(BUBBLE_LEVELUP, 0);
}
if (iNewEnv == Move_environment.MOVEENV_GROUND)
{
m_GndInfo.bOnGround = true;
// if (vPos.y > m_GndInfo.fGndHei + 0.2f)
if (m_CDRInfo.vTPNormal == Vector3.zero)
{
if (m_iMoveMode != (int)MoveMode.MOVE_FREEFALL)
m_iMoveMode = (int)MoveMode.MOVE_FREEFALL;
m_GndInfo.bOnGround = false;
if (IsJumping() && m_CDRInfo.vAbsVelocity.y < 0.0f && vPos.y - vAABBGnd.y < 0.6f)
{
PlayAction((int)PLAYER_ACTION_TYPE.ACT_JUMP_LAND, false);
}
}
else
{
if (IsJumping() && m_CDRInfo.vAbsVelocity.y < 0.0f && vPos.y - vAABBGnd.y < 0.6f)
{
PlayAction((int)PLAYER_ACTION_TYPE.ACT_JUMP_LAND, false);
ResetJump();
}
// if (m_GndInfo.vGndNormal.y < EC_SLOPE_Y)
if (m_CDRInfo.vTPNormal.y < EC_SLOPE_Y)
{
if (!m_MoveCtrl.GetSlideLock())
{
if (m_iMoveMode != (int)MoveMode.MOVE_SLIDE)
{
m_iOldWalkMode = m_iMoveMode;
m_iMoveMode = (int)MoveMode.MOVE_SLIDE;
}
}
else
{
m_MoveCtrl.SetSlideLock(false);
m_iMoveMode = (int)MoveMode.MOVE_STAND;
}
}
else
{
m_MoveCtrl.SetSlideLock(false);
if (m_iMoveMode == (int)MoveMode.MOVE_FREEFALL)
{
m_iMoveMode = (int)MoveMode.MOVE_STAND;
}
else if (m_iMoveMode == (int)MoveMode.MOVE_SLIDE)
m_iMoveMode = m_iOldWalkMode;
}
}
}
//else if (iNewEnv == MOVEENV_WATER)
//{
// m_CDRInfo.fYVel = 0.0f;
// if (m_iMoveMode == MOVE_SLIDE)
// {
// if (m_pWorkMan.IsMoving())
// m_iMoveMode = MOVE_MOVE;
// else
// m_iMoveMode = MOVE_STAND;
// }
//}
m_iMoveEnv = iNewEnv;
}
// ÏòÏ Trace µØÐκͽ¨Öþ£¬²¢·µ»ØµÚÒ»¸öÅöײµãµÄÇé¿ö
bool VertRayTrace(Vector3 vPos, ref Vector3 vHitPos, ref A3DVECTOR3 vHitNormal, float DeltaY)
{
Vector3 vTerrainPos = Vector3.zero;
Vector3 vTerrainNormal = Vector3.zero;
Vector3 vBuildingPos = Vector3.zero;
Vector3 vBuildingNormal = Vector3.zero;
LayerMask layerMaskTerrain = 1 << 6;
LayerMask layerMaskBush = 1 << 7;
if (Physics.Raycast(vPos, (vPos + Vector3.down), out hit, layerMaskTerrain))
{
vTerrainPos = hit.point;
vTerrainNormal = hit.normal;
}
if (Physics.Raycast(vPos, (vPos + Vector3.down), out hit, DeltaY, layerMaskTerrain))
{
if (vBuildingPos.y > vTerrainPos.y)
{
// Ó뽨Öþ·¢ÉúÁËÅöײ
vHitPos = vBuildingPos;
vHitNormal = EC_Utility.ToA3DVECTOR3(vBuildingNormal);
return true;
}
}
if (vTerrainPos.y > vPos.y || (vTerrainPos.y <= vPos.y && vTerrainPos.y >= vPos.y - DeltaY))
{
vHitPos = vTerrainPos;
vHitNormal = EC_Utility.ToA3DVECTOR3(vTerrainNormal);
return true;
}
return false;
}
void VertAABBTrace(Vector3 vCenter, Vector3 vExt, ref Vector3 vHitPos, ref A3DVECTOR3 vHitNormal, float DeltaY/* =100.0f */)
{
vHitPos = vCenter;
vHitPos.y -= DeltaY;
LayerMask layerMask = 1 << 6 | 1 << 7;
if(!Physics.BoxCast(vCenter, vExt, (vCenter + Vector3.down).normalized,
out hit, transform.rotation, DeltaY, layerMask))
{
vHitPos = vCenter;
vHitNormal = EC_Utility.ToA3DVECTOR3(Vector3.up);
}
else
{
vHitPos = hit.point;
vHitNormal = EC_Utility.ToA3DVECTOR3(hit.normal);
}
}
void OnMsgHstExtProp(ECMSG Msg)
{
cmd_own_ext_prop pCmd = GPDataTypeHelper.FromBytes<cmd_own_ext_prop>((byte[])Msg.dwParam1);
m_ExtProps = pCmd.prop;
m_BasicProps.iStatusPt = (int) pCmd.status_point;
m_BasicProps.iAtkDegree = pCmd.attack_degree;
m_BasicProps.iDefDegree = pCmd.defend_degree;
m_BasicProps.iCritRate = pCmd.crit_rate;
m_BasicProps.iCritDamageBonus = pCmd.crit_damage_bonus;
m_BasicProps.iInvisibleDegree = pCmd.invisible_degree;
m_BasicProps.iAntiInvisibleDegree = pCmd.anti_invisible_degree;
m_BasicProps.iPenetration = pCmd.penetration;
m_BasicProps.iResilience = pCmd.resilience;
m_BasicProps.iVigour = pCmd.vigour;
}
}
public enum StateAnim
{
@@ -3400,7 +3642,6 @@ namespace BrewMonster
}
}
enum MOVE_DIR
{
MD_FORWARD = 0x01,
MD_RIGHT = 0x02,