diff --git a/Assets/Plugins/kbengine_unity3d_plugins/AccountBase.cs b/Assets/Plugins/kbengine_unity3d_plugins/AccountBase.cs index 41e1e72..4e22b9f 100644 --- a/Assets/Plugins/kbengine_unity3d_plugins/AccountBase.cs +++ b/Assets/Plugins/kbengine_unity3d_plugins/AccountBase.cs @@ -1,307 +1,307 @@ -/* - Generated by KBEngine! - Please do not modify this file! - Please inherit this module, such as: (class Account : AccountBase) - tools = kbcmd -*/ - -namespace KBEngine -{ - using UnityEngine; - using System; - using System.Collections; - using System.Collections.Generic; - - // defined in */scripts/entity_defs/Account.def - // Please inherit and implement "class Account : AccountBase" - public abstract class AccountBase : Entity - { - public EntityBaseEntityCall_AccountBase baseEntityCall = null; - public EntityCellEntityCall_AccountBase cellEntityCall = null; - - public UInt64 lastSelCharacter = 0; - public virtual void onLastSelCharacterChanged(UInt64 oldValue) {} - - public abstract void onCreateAvatarResult(Byte arg1, AVATAR_INFOS arg2); - public abstract void onRemoveAvatar(UInt64 arg1); - public abstract void onReqAvatarList(AVATAR_INFOS_LIST arg1); - - public AccountBase() - { - } - - public override void onComponentsEnterworld() - { - } - - public override void onComponentsLeaveworld() - { - } - - public override void onGetBase() - { - baseEntityCall = new EntityBaseEntityCall_AccountBase(id, className); - } - - public override void onGetCell() - { - cellEntityCall = new EntityCellEntityCall_AccountBase(id, className); - } - - public override void onLoseCell() - { - cellEntityCall = null; - } - - public override EntityCall getBaseEntityCall() - { - return baseEntityCall; - } - - public override EntityCall getCellEntityCall() - { - return cellEntityCall; - } - - public override void attachComponents() - { - } - - public override void detachComponents() - { - } - - public override void onRemoteMethodCall(MemoryStream stream) - { - ScriptModule sm = EntityDef.moduledefs["Account"]; - - UInt16 methodUtype = 0; - UInt16 componentPropertyUType = 0; - - if(sm.usePropertyDescrAlias) - { - componentPropertyUType = stream.readUint8(); - } - else - { - componentPropertyUType = stream.readUint16(); - } - - if(sm.useMethodDescrAlias) - { - methodUtype = stream.readUint8(); - } - else - { - methodUtype = stream.readUint16(); - } - - Method method = null; - - if(componentPropertyUType == 0) - { - method = sm.idmethods[methodUtype]; - } - else - { - Property pComponentPropertyDescription = sm.idpropertys[componentPropertyUType]; - switch(pComponentPropertyDescription.properUtype) - { - default: - break; - } - - return; - } - - switch(method.methodUtype) - { - case 10005: - Byte onCreateAvatarResult_arg1 = stream.readUint8(); - AVATAR_INFOS onCreateAvatarResult_arg2 = ((DATATYPE_AVATAR_INFOS)method.args[1]).createFromStreamEx(stream); - onCreateAvatarResult(onCreateAvatarResult_arg1, onCreateAvatarResult_arg2); - break; - case 3: - UInt64 onRemoveAvatar_arg1 = stream.readUint64(); - onRemoveAvatar(onRemoveAvatar_arg1); - break; - case 10003: - AVATAR_INFOS_LIST onReqAvatarList_arg1 = ((DATATYPE_AVATAR_INFOS_LIST)method.args[0]).createFromStreamEx(stream); - onReqAvatarList(onReqAvatarList_arg1); - break; - default: - break; - }; - } - - public override void onUpdatePropertys(MemoryStream stream) - { - ScriptModule sm = EntityDef.moduledefs["Account"]; - Dictionary pdatas = sm.idpropertys; - - while(stream.length() > 0) - { - UInt16 _t_utype = 0; - UInt16 _t_child_utype = 0; - - { - if(sm.usePropertyDescrAlias) - { - _t_utype = stream.readUint8(); - _t_child_utype = stream.readUint8(); - } - else - { - _t_utype = stream.readUint16(); - _t_child_utype = stream.readUint16(); - } - } - - Property prop = null; - - if(_t_utype == 0) - { - prop = pdatas[_t_child_utype]; - } - else - { - Property pComponentPropertyDescription = pdatas[_t_utype]; - switch(pComponentPropertyDescription.properUtype) - { - default: - break; - } - - return; - } - - switch(prop.properUtype) - { - case 40001: - Vector3 oldval_direction = direction; - direction = stream.readVector3(); - - if(prop.isBase()) - { - if(inited) - onDirectionChanged(oldval_direction); - } - else - { - if(inWorld) - onDirectionChanged(oldval_direction); - } - - break; - case 2: - UInt64 oldval_lastSelCharacter = lastSelCharacter; - lastSelCharacter = stream.readUint64(); - - if(prop.isBase()) - { - if(inited) - onLastSelCharacterChanged(oldval_lastSelCharacter); - } - else - { - if(inWorld) - onLastSelCharacterChanged(oldval_lastSelCharacter); - } - - break; - case 40000: - Vector3 oldval_position = position; - position = stream.readVector3(); - - if(prop.isBase()) - { - if(inited) - onPositionChanged(oldval_position); - } - else - { - if(inWorld) - onPositionChanged(oldval_position); - } - - break; - case 40002: - stream.readUint32(); - break; - default: - break; - }; - } - } - - public override void callPropertysSetMethods() - { - ScriptModule sm = EntityDef.moduledefs["Account"]; - Dictionary pdatas = sm.idpropertys; - - Vector3 oldval_direction = direction; - Property prop_direction = pdatas[2]; - if(prop_direction.isBase()) - { - if(inited && !inWorld) - onDirectionChanged(oldval_direction); - } - else - { - if(inWorld) - { - if(prop_direction.isOwnerOnly() && !isPlayer()) - { - } - else - { - onDirectionChanged(oldval_direction); - } - } - } - - UInt64 oldval_lastSelCharacter = lastSelCharacter; - Property prop_lastSelCharacter = pdatas[4]; - if(prop_lastSelCharacter.isBase()) - { - if(inited && !inWorld) - onLastSelCharacterChanged(oldval_lastSelCharacter); - } - else - { - if(inWorld) - { - if(prop_lastSelCharacter.isOwnerOnly() && !isPlayer()) - { - } - else - { - onLastSelCharacterChanged(oldval_lastSelCharacter); - } - } - } - - Vector3 oldval_position = position; - Property prop_position = pdatas[1]; - if(prop_position.isBase()) - { - if(inited && !inWorld) - onPositionChanged(oldval_position); - } - else - { - if(inWorld) - { - if(prop_position.isOwnerOnly() && !isPlayer()) - { - } - else - { - onPositionChanged(oldval_position); - } - } - } - - } - } +/* + Generated by KBEngine! + Please do not modify this file! + Please inherit this module, such as: (class Account : AccountBase) + tools = kbcmd +*/ + +namespace KBEngine +{ + using UnityEngine; + using System; + using System.Collections; + using System.Collections.Generic; + + // defined in */scripts/entity_defs/Account.def + // Please inherit and implement "class Account : AccountBase" + public abstract class AccountBase : Entity + { + public EntityBaseEntityCall_AccountBase baseEntityCall = null; + public EntityCellEntityCall_AccountBase cellEntityCall = null; + + public UInt64 lastSelCharacter = 0; + public virtual void onLastSelCharacterChanged(UInt64 oldValue) {} + + public abstract void onCreateAvatarResult(Byte arg1, AVATAR_INFOS arg2); + public abstract void onRemoveAvatar(UInt64 arg1); + public abstract void onReqAvatarList(AVATAR_INFOS_LIST arg1); + + public AccountBase() + { + } + + public override void onComponentsEnterworld() + { + } + + public override void onComponentsLeaveworld() + { + } + + public override void onGetBase() + { + baseEntityCall = new EntityBaseEntityCall_AccountBase(id, className); + } + + public override void onGetCell() + { + cellEntityCall = new EntityCellEntityCall_AccountBase(id, className); + } + + public override void onLoseCell() + { + cellEntityCall = null; + } + + public override EntityCall getBaseEntityCall() + { + return baseEntityCall; + } + + public override EntityCall getCellEntityCall() + { + return cellEntityCall; + } + + public override void attachComponents() + { + } + + public override void detachComponents() + { + } + + public override void onRemoteMethodCall(MemoryStream stream) + { + ScriptModule sm = EntityDef.moduledefs["Account"]; + + UInt16 methodUtype = 0; + UInt16 componentPropertyUType = 0; + + if(sm.usePropertyDescrAlias) + { + componentPropertyUType = stream.readUint8(); + } + else + { + componentPropertyUType = stream.readUint16(); + } + + if(sm.useMethodDescrAlias) + { + methodUtype = stream.readUint8(); + } + else + { + methodUtype = stream.readUint16(); + } + + Method method = null; + + if(componentPropertyUType == 0) + { + method = sm.idmethods[methodUtype]; + } + else + { + Property pComponentPropertyDescription = sm.idpropertys[componentPropertyUType]; + switch(pComponentPropertyDescription.properUtype) + { + default: + break; + } + + return; + } + + switch(method.methodUtype) + { + case 10005: + Byte onCreateAvatarResult_arg1 = stream.readUint8(); + AVATAR_INFOS onCreateAvatarResult_arg2 = ((DATATYPE_AVATAR_INFOS)method.args[1]).createFromStreamEx(stream); + onCreateAvatarResult(onCreateAvatarResult_arg1, onCreateAvatarResult_arg2); + break; + case 3: + UInt64 onRemoveAvatar_arg1 = stream.readUint64(); + onRemoveAvatar(onRemoveAvatar_arg1); + break; + case 10003: + AVATAR_INFOS_LIST onReqAvatarList_arg1 = ((DATATYPE_AVATAR_INFOS_LIST)method.args[0]).createFromStreamEx(stream); + onReqAvatarList(onReqAvatarList_arg1); + break; + default: + break; + }; + } + + public override void onUpdatePropertys(MemoryStream stream) + { + ScriptModule sm = EntityDef.moduledefs["Account"]; + Dictionary pdatas = sm.idpropertys; + + while(stream.length() > 0) + { + UInt16 _t_utype = 0; + UInt16 _t_child_utype = 0; + + { + if(sm.usePropertyDescrAlias) + { + _t_utype = stream.readUint8(); + _t_child_utype = stream.readUint8(); + } + else + { + _t_utype = stream.readUint16(); + _t_child_utype = stream.readUint16(); + } + } + + Property prop = null; + + if(_t_utype == 0) + { + prop = pdatas[_t_child_utype]; + } + else + { + Property pComponentPropertyDescription = pdatas[_t_utype]; + switch(pComponentPropertyDescription.properUtype) + { + default: + break; + } + + return; + } + + switch(prop.properUtype) + { + case 40001: + Vector3 oldval_direction = direction; + direction = stream.readVector3(); + + if(prop.isBase()) + { + if(inited) + onDirectionChanged(oldval_direction); + } + else + { + if(inWorld) + onDirectionChanged(oldval_direction); + } + + break; + case 2: + UInt64 oldval_lastSelCharacter = lastSelCharacter; + lastSelCharacter = stream.readUint64(); + + if(prop.isBase()) + { + if(inited) + onLastSelCharacterChanged(oldval_lastSelCharacter); + } + else + { + if(inWorld) + onLastSelCharacterChanged(oldval_lastSelCharacter); + } + + break; + case 40000: + Vector3 oldval_position = position; + position = stream.readVector3(); + + if(prop.isBase()) + { + if(inited) + onPositionChanged(oldval_position); + } + else + { + if(inWorld) + onPositionChanged(oldval_position); + } + + break; + case 40002: + stream.readUint32(); + break; + default: + break; + }; + } + } + + public override void callPropertysSetMethods() + { + ScriptModule sm = EntityDef.moduledefs["Account"]; + Dictionary pdatas = sm.idpropertys; + + Vector3 oldval_direction = direction; + Property prop_direction = pdatas[2]; + if(prop_direction.isBase()) + { + if(inited && !inWorld) + onDirectionChanged(oldval_direction); + } + else + { + if(inWorld) + { + if(prop_direction.isOwnerOnly() && !isPlayer()) + { + } + else + { + onDirectionChanged(oldval_direction); + } + } + } + + UInt64 oldval_lastSelCharacter = lastSelCharacter; + Property prop_lastSelCharacter = pdatas[4]; + if(prop_lastSelCharacter.isBase()) + { + if(inited && !inWorld) + onLastSelCharacterChanged(oldval_lastSelCharacter); + } + else + { + if(inWorld) + { + if(prop_lastSelCharacter.isOwnerOnly() && !isPlayer()) + { + } + else + { + onLastSelCharacterChanged(oldval_lastSelCharacter); + } + } + } + + Vector3 oldval_position = position; + Property prop_position = pdatas[1]; + if(prop_position.isBase()) + { + if(inited && !inWorld) + onPositionChanged(oldval_position); + } + else + { + if(inWorld) + { + if(prop_position.isOwnerOnly() && !isPlayer()) + { + } + else + { + onPositionChanged(oldval_position); + } + } + } + + } + } } \ No newline at end of file diff --git a/Assets/Plugins/kbengine_unity3d_plugins/AvatarBase.cs b/Assets/Plugins/kbengine_unity3d_plugins/AvatarBase.cs index a73b957..2e5427e 100644 --- a/Assets/Plugins/kbengine_unity3d_plugins/AvatarBase.cs +++ b/Assets/Plugins/kbengine_unity3d_plugins/AvatarBase.cs @@ -1,1008 +1,1008 @@ -/* - Generated by KBEngine! - Please do not modify this file! - Please inherit this module, such as: (class Avatar : AvatarBase) - tools = kbcmd -*/ - -namespace KBEngine -{ - using UnityEngine; - using System; - using System.Collections; - using System.Collections.Generic; - - // defined in */scripts/entity_defs/Avatar.def - // Please inherit and implement "class Avatar : AvatarBase" - public abstract class AvatarBase : Entity - { - public EntityBaseEntityCall_AvatarBase baseEntityCall = null; - public EntityCellEntityCall_AvatarBase cellEntityCall = null; - - public Int32 HP = 0; - public virtual void onHPChanged(Int32 oldValue) {} - public Int32 HP_Max = 0; - public virtual void onHP_MaxChanged(Int32 oldValue) {} - public Int32 MP = 0; - public virtual void onMPChanged(Int32 oldValue) {} - public Int32 MP_Max = 0; - public virtual void onMP_MaxChanged(Int32 oldValue) {} - public TestBase component1 = null; - public TestBase component2 = null; - public TestNoBaseBase component3 = null; - public Int32 forbids = 0; - public virtual void onForbidsChanged(Int32 oldValue) {} - public UInt16 level = 0; - public virtual void onLevelChanged(UInt16 oldValue) {} - public UInt32 modelID = 0; - public virtual void onModelIDChanged(UInt32 oldValue) {} - public Byte modelScale = 30; - public virtual void onModelScaleChanged(Byte oldValue) {} - public Byte moveSpeed = 50; - public virtual void onMoveSpeedChanged(Byte oldValue) {} - public string name = ""; - public virtual void onNameChanged(string oldValue) {} - public UInt16 own_val = 0; - public virtual void onOwn_valChanged(UInt16 oldValue) {} - public UInt32 spaceUType = 0; - public virtual void onSpaceUTypeChanged(UInt32 oldValue) {} - public SByte state = 0; - public virtual void onStateChanged(SByte oldValue) {} - public Byte subState = 0; - public virtual void onSubStateChanged(Byte oldValue) {} - public UInt32 uid = 0; - public virtual void onUidChanged(UInt32 oldValue) {} - public UInt32 utype = 0; - public virtual void onUtypeChanged(UInt32 oldValue) {} - - public abstract void dialog_addOption(Byte arg1, UInt32 arg2, string arg3, Int32 arg4); - public abstract void dialog_close(); - public abstract void dialog_setText(string arg1, Byte arg2, UInt32 arg3, string arg4); - public abstract void onAddSkill(Int32 arg1); - public abstract void onJump(); - public abstract void onRemoveSkill(Int32 arg1); - public abstract void recvDamage(Int32 arg1, Int32 arg2, Int32 arg3, Int32 arg4); - - public AvatarBase() - { - foreach (System.Reflection.Assembly ass in AppDomain.CurrentDomain.GetAssemblies()) - { - Type entityComponentScript = ass.GetType("KBEngine.Test"); - if(entityComponentScript != null) - { - component1 = (TestBase)Activator.CreateInstance(entityComponentScript); - component1.owner = this; - component1.entityComponentPropertyID = 16; - } - } - - if(component1 == null) - throw new Exception("Please inherit and implement, such as: \"class Test : TestBase\""); - - foreach (System.Reflection.Assembly ass in AppDomain.CurrentDomain.GetAssemblies()) - { - Type entityComponentScript = ass.GetType("KBEngine.Test"); - if(entityComponentScript != null) - { - component2 = (TestBase)Activator.CreateInstance(entityComponentScript); - component2.owner = this; - component2.entityComponentPropertyID = 21; - } - } - - if(component2 == null) - throw new Exception("Please inherit and implement, such as: \"class Test : TestBase\""); - - foreach (System.Reflection.Assembly ass in AppDomain.CurrentDomain.GetAssemblies()) - { - Type entityComponentScript = ass.GetType("KBEngine.TestNoBase"); - if(entityComponentScript != null) - { - component3 = (TestNoBaseBase)Activator.CreateInstance(entityComponentScript); - component3.owner = this; - component3.entityComponentPropertyID = 22; - } - } - - if(component3 == null) - throw new Exception("Please inherit and implement, such as: \"class TestNoBase : TestNoBaseBase\""); - - } - - public override void onComponentsEnterworld() - { - component1.onEnterworld(); - component2.onEnterworld(); - component3.onEnterworld(); - } - - public override void onComponentsLeaveworld() - { - component1.onLeaveworld(); - component2.onLeaveworld(); - component3.onLeaveworld(); - } - - public override void onGetBase() - { - baseEntityCall = new EntityBaseEntityCall_AvatarBase(id, className); - } - - public override void onGetCell() - { - cellEntityCall = new EntityCellEntityCall_AvatarBase(id, className); - } - - public override void onLoseCell() - { - cellEntityCall = null; - } - - public override EntityCall getBaseEntityCall() - { - return baseEntityCall; - } - - public override EntityCall getCellEntityCall() - { - return cellEntityCall; - } - - public override void attachComponents() - { - component1.onAttached(this); - component2.onAttached(this); - component3.onAttached(this); - } - - public override void detachComponents() - { - component1.onDetached(this); - component2.onDetached(this); - component3.onDetached(this); - } - - public override void onRemoteMethodCall(MemoryStream stream) - { - ScriptModule sm = EntityDef.moduledefs["Avatar"]; - - UInt16 methodUtype = 0; - UInt16 componentPropertyUType = 0; - - if(sm.usePropertyDescrAlias) - { - componentPropertyUType = stream.readUint8(); - } - else - { - componentPropertyUType = stream.readUint16(); - } - - if(sm.useMethodDescrAlias) - { - methodUtype = stream.readUint8(); - } - else - { - methodUtype = stream.readUint16(); - } - - Method method = null; - - if(componentPropertyUType == 0) - { - method = sm.idmethods[methodUtype]; - } - else - { - Property pComponentPropertyDescription = sm.idpropertys[componentPropertyUType]; - switch(pComponentPropertyDescription.properUtype) - { - case 16: - component1.onRemoteMethodCall(methodUtype, stream); - break; - case 21: - component2.onRemoteMethodCall(methodUtype, stream); - break; - case 22: - component3.onRemoteMethodCall(methodUtype, stream); - break; - default: - break; - } - - return; - } - - switch(method.methodUtype) - { - case 10101: - Byte dialog_addOption_arg1 = stream.readUint8(); - UInt32 dialog_addOption_arg2 = stream.readUint32(); - string dialog_addOption_arg3 = stream.readUnicode(); - Int32 dialog_addOption_arg4 = stream.readInt32(); - dialog_addOption(dialog_addOption_arg1, dialog_addOption_arg2, dialog_addOption_arg3, dialog_addOption_arg4); - break; - case 10104: - dialog_close(); - break; - case 10102: - string dialog_setText_arg1 = stream.readUnicode(); - Byte dialog_setText_arg2 = stream.readUint8(); - UInt32 dialog_setText_arg3 = stream.readUint32(); - string dialog_setText_arg4 = stream.readUnicode(); - dialog_setText(dialog_setText_arg1, dialog_setText_arg2, dialog_setText_arg3, dialog_setText_arg4); - break; - case 12: - Int32 onAddSkill_arg1 = stream.readInt32(); - onAddSkill(onAddSkill_arg1); - break; - case 7: - onJump(); - break; - case 13: - Int32 onRemoveSkill_arg1 = stream.readInt32(); - onRemoveSkill(onRemoveSkill_arg1); - break; - case 16: - Int32 recvDamage_arg1 = stream.readInt32(); - Int32 recvDamage_arg2 = stream.readInt32(); - Int32 recvDamage_arg3 = stream.readInt32(); - Int32 recvDamage_arg4 = stream.readInt32(); - recvDamage(recvDamage_arg1, recvDamage_arg2, recvDamage_arg3, recvDamage_arg4); - break; - default: - break; - }; - } - - public override void onUpdatePropertys(MemoryStream stream) - { - ScriptModule sm = EntityDef.moduledefs["Avatar"]; - Dictionary pdatas = sm.idpropertys; - - while(stream.length() > 0) - { - UInt16 _t_utype = 0; - UInt16 _t_child_utype = 0; - - { - if(sm.usePropertyDescrAlias) - { - _t_utype = stream.readUint8(); - _t_child_utype = stream.readUint8(); - } - else - { - _t_utype = stream.readUint16(); - _t_child_utype = stream.readUint16(); - } - } - - Property prop = null; - - if(_t_utype == 0) - { - prop = pdatas[_t_child_utype]; - } - else - { - Property pComponentPropertyDescription = pdatas[_t_utype]; - switch(pComponentPropertyDescription.properUtype) - { - case 16: - component1.onUpdatePropertys(_t_child_utype, stream, -1); - break; - case 21: - component2.onUpdatePropertys(_t_child_utype, stream, -1); - break; - case 22: - component3.onUpdatePropertys(_t_child_utype, stream, -1); - break; - default: - break; - } - - return; - } - - switch(prop.properUtype) - { - case 47001: - Int32 oldval_HP = HP; - HP = stream.readInt32(); - - if(prop.isBase()) - { - if(inited) - onHPChanged(oldval_HP); - } - else - { - if(inWorld) - onHPChanged(oldval_HP); - } - - break; - case 47002: - Int32 oldval_HP_Max = HP_Max; - HP_Max = stream.readInt32(); - - if(prop.isBase()) - { - if(inited) - onHP_MaxChanged(oldval_HP_Max); - } - else - { - if(inWorld) - onHP_MaxChanged(oldval_HP_Max); - } - - break; - case 47003: - Int32 oldval_MP = MP; - MP = stream.readInt32(); - - if(prop.isBase()) - { - if(inited) - onMPChanged(oldval_MP); - } - else - { - if(inWorld) - onMPChanged(oldval_MP); - } - - break; - case 47004: - Int32 oldval_MP_Max = MP_Max; - MP_Max = stream.readInt32(); - - if(prop.isBase()) - { - if(inited) - onMP_MaxChanged(oldval_MP_Max); - } - else - { - if(inWorld) - onMP_MaxChanged(oldval_MP_Max); - } - - break; - case 16: - component1.createFromStream(stream); - break; - case 21: - component2.createFromStream(stream); - break; - case 22: - component3.createFromStream(stream); - break; - case 40001: - Vector3 oldval_direction = direction; - direction = stream.readVector3(); - - if(prop.isBase()) - { - if(inited) - onDirectionChanged(oldval_direction); - } - else - { - if(inWorld) - onDirectionChanged(oldval_direction); - } - - break; - case 47005: - Int32 oldval_forbids = forbids; - forbids = stream.readInt32(); - - if(prop.isBase()) - { - if(inited) - onForbidsChanged(oldval_forbids); - } - else - { - if(inWorld) - onForbidsChanged(oldval_forbids); - } - - break; - case 41002: - UInt16 oldval_level = level; - level = stream.readUint16(); - - if(prop.isBase()) - { - if(inited) - onLevelChanged(oldval_level); - } - else - { - if(inWorld) - onLevelChanged(oldval_level); - } - - break; - case 41006: - UInt32 oldval_modelID = modelID; - modelID = stream.readUint32(); - - if(prop.isBase()) - { - if(inited) - onModelIDChanged(oldval_modelID); - } - else - { - if(inWorld) - onModelIDChanged(oldval_modelID); - } - - break; - case 41007: - Byte oldval_modelScale = modelScale; - modelScale = stream.readUint8(); - - if(prop.isBase()) - { - if(inited) - onModelScaleChanged(oldval_modelScale); - } - else - { - if(inWorld) - onModelScaleChanged(oldval_modelScale); - } - - break; - case 11: - Byte oldval_moveSpeed = moveSpeed; - moveSpeed = stream.readUint8(); - - if(prop.isBase()) - { - if(inited) - onMoveSpeedChanged(oldval_moveSpeed); - } - else - { - if(inWorld) - onMoveSpeedChanged(oldval_moveSpeed); - } - - break; - case 41003: - string oldval_name = name; - name = stream.readUnicode(); - - if(prop.isBase()) - { - if(inited) - onNameChanged(oldval_name); - } - else - { - if(inWorld) - onNameChanged(oldval_name); - } - - break; - case 6: - UInt16 oldval_own_val = own_val; - own_val = stream.readUint16(); - - if(prop.isBase()) - { - if(inited) - onOwn_valChanged(oldval_own_val); - } - else - { - if(inWorld) - onOwn_valChanged(oldval_own_val); - } - - break; - case 40000: - Vector3 oldval_position = position; - position = stream.readVector3(); - - if(prop.isBase()) - { - if(inited) - onPositionChanged(oldval_position); - } - else - { - if(inWorld) - onPositionChanged(oldval_position); - } - - break; - case 40002: - stream.readUint32(); - break; - case 41001: - UInt32 oldval_spaceUType = spaceUType; - spaceUType = stream.readUint32(); - - if(prop.isBase()) - { - if(inited) - onSpaceUTypeChanged(oldval_spaceUType); - } - else - { - if(inWorld) - onSpaceUTypeChanged(oldval_spaceUType); - } - - break; - case 47006: - SByte oldval_state = state; - state = stream.readInt8(); - - if(prop.isBase()) - { - if(inited) - onStateChanged(oldval_state); - } - else - { - if(inWorld) - onStateChanged(oldval_state); - } - - break; - case 47007: - Byte oldval_subState = subState; - subState = stream.readUint8(); - - if(prop.isBase()) - { - if(inited) - onSubStateChanged(oldval_subState); - } - else - { - if(inWorld) - onSubStateChanged(oldval_subState); - } - - break; - case 41004: - UInt32 oldval_uid = uid; - uid = stream.readUint32(); - - if(prop.isBase()) - { - if(inited) - onUidChanged(oldval_uid); - } - else - { - if(inWorld) - onUidChanged(oldval_uid); - } - - break; - case 41005: - UInt32 oldval_utype = utype; - utype = stream.readUint32(); - - if(prop.isBase()) - { - if(inited) - onUtypeChanged(oldval_utype); - } - else - { - if(inWorld) - onUtypeChanged(oldval_utype); - } - - break; - default: - break; - }; - } - } - - public override void callPropertysSetMethods() - { - ScriptModule sm = EntityDef.moduledefs["Avatar"]; - Dictionary pdatas = sm.idpropertys; - - Int32 oldval_HP = HP; - Property prop_HP = pdatas[4]; - if(prop_HP.isBase()) - { - if(inited && !inWorld) - onHPChanged(oldval_HP); - } - else - { - if(inWorld) - { - if(prop_HP.isOwnerOnly() && !isPlayer()) - { - } - else - { - onHPChanged(oldval_HP); - } - } - } - - Int32 oldval_HP_Max = HP_Max; - Property prop_HP_Max = pdatas[5]; - if(prop_HP_Max.isBase()) - { - if(inited && !inWorld) - onHP_MaxChanged(oldval_HP_Max); - } - else - { - if(inWorld) - { - if(prop_HP_Max.isOwnerOnly() && !isPlayer()) - { - } - else - { - onHP_MaxChanged(oldval_HP_Max); - } - } - } - - Int32 oldval_MP = MP; - Property prop_MP = pdatas[6]; - if(prop_MP.isBase()) - { - if(inited && !inWorld) - onMPChanged(oldval_MP); - } - else - { - if(inWorld) - { - if(prop_MP.isOwnerOnly() && !isPlayer()) - { - } - else - { - onMPChanged(oldval_MP); - } - } - } - - Int32 oldval_MP_Max = MP_Max; - Property prop_MP_Max = pdatas[7]; - if(prop_MP_Max.isBase()) - { - if(inited && !inWorld) - onMP_MaxChanged(oldval_MP_Max); - } - else - { - if(inWorld) - { - if(prop_MP_Max.isOwnerOnly() && !isPlayer()) - { - } - else - { - onMP_MaxChanged(oldval_MP_Max); - } - } - } - - component1.callPropertysSetMethods(); - - component2.callPropertysSetMethods(); - - component3.callPropertysSetMethods(); - - Vector3 oldval_direction = direction; - Property prop_direction = pdatas[2]; - if(prop_direction.isBase()) - { - if(inited && !inWorld) - onDirectionChanged(oldval_direction); - } - else - { - if(inWorld) - { - if(prop_direction.isOwnerOnly() && !isPlayer()) - { - } - else - { - onDirectionChanged(oldval_direction); - } - } - } - - Int32 oldval_forbids = forbids; - Property prop_forbids = pdatas[11]; - if(prop_forbids.isBase()) - { - if(inited && !inWorld) - onForbidsChanged(oldval_forbids); - } - else - { - if(inWorld) - { - if(prop_forbids.isOwnerOnly() && !isPlayer()) - { - } - else - { - onForbidsChanged(oldval_forbids); - } - } - } - - UInt16 oldval_level = level; - Property prop_level = pdatas[12]; - if(prop_level.isBase()) - { - if(inited && !inWorld) - onLevelChanged(oldval_level); - } - else - { - if(inWorld) - { - if(prop_level.isOwnerOnly() && !isPlayer()) - { - } - else - { - onLevelChanged(oldval_level); - } - } - } - - UInt32 oldval_modelID = modelID; - Property prop_modelID = pdatas[13]; - if(prop_modelID.isBase()) - { - if(inited && !inWorld) - onModelIDChanged(oldval_modelID); - } - else - { - if(inWorld) - { - if(prop_modelID.isOwnerOnly() && !isPlayer()) - { - } - else - { - onModelIDChanged(oldval_modelID); - } - } - } - - Byte oldval_modelScale = modelScale; - Property prop_modelScale = pdatas[14]; - if(prop_modelScale.isBase()) - { - if(inited && !inWorld) - onModelScaleChanged(oldval_modelScale); - } - else - { - if(inWorld) - { - if(prop_modelScale.isOwnerOnly() && !isPlayer()) - { - } - else - { - onModelScaleChanged(oldval_modelScale); - } - } - } - - Byte oldval_moveSpeed = moveSpeed; - Property prop_moveSpeed = pdatas[15]; - if(prop_moveSpeed.isBase()) - { - if(inited && !inWorld) - onMoveSpeedChanged(oldval_moveSpeed); - } - else - { - if(inWorld) - { - if(prop_moveSpeed.isOwnerOnly() && !isPlayer()) - { - } - else - { - onMoveSpeedChanged(oldval_moveSpeed); - } - } - } - - string oldval_name = name; - Property prop_name = pdatas[16]; - if(prop_name.isBase()) - { - if(inited && !inWorld) - onNameChanged(oldval_name); - } - else - { - if(inWorld) - { - if(prop_name.isOwnerOnly() && !isPlayer()) - { - } - else - { - onNameChanged(oldval_name); - } - } - } - - UInt16 oldval_own_val = own_val; - Property prop_own_val = pdatas[17]; - if(prop_own_val.isBase()) - { - if(inited && !inWorld) - onOwn_valChanged(oldval_own_val); - } - else - { - if(inWorld) - { - if(prop_own_val.isOwnerOnly() && !isPlayer()) - { - } - else - { - onOwn_valChanged(oldval_own_val); - } - } - } - - Vector3 oldval_position = position; - Property prop_position = pdatas[1]; - if(prop_position.isBase()) - { - if(inited && !inWorld) - onPositionChanged(oldval_position); - } - else - { - if(inWorld) - { - if(prop_position.isOwnerOnly() && !isPlayer()) - { - } - else - { - onPositionChanged(oldval_position); - } - } - } - - UInt32 oldval_spaceUType = spaceUType; - Property prop_spaceUType = pdatas[18]; - if(prop_spaceUType.isBase()) - { - if(inited && !inWorld) - onSpaceUTypeChanged(oldval_spaceUType); - } - else - { - if(inWorld) - { - if(prop_spaceUType.isOwnerOnly() && !isPlayer()) - { - } - else - { - onSpaceUTypeChanged(oldval_spaceUType); - } - } - } - - SByte oldval_state = state; - Property prop_state = pdatas[19]; - if(prop_state.isBase()) - { - if(inited && !inWorld) - onStateChanged(oldval_state); - } - else - { - if(inWorld) - { - if(prop_state.isOwnerOnly() && !isPlayer()) - { - } - else - { - onStateChanged(oldval_state); - } - } - } - - Byte oldval_subState = subState; - Property prop_subState = pdatas[20]; - if(prop_subState.isBase()) - { - if(inited && !inWorld) - onSubStateChanged(oldval_subState); - } - else - { - if(inWorld) - { - if(prop_subState.isOwnerOnly() && !isPlayer()) - { - } - else - { - onSubStateChanged(oldval_subState); - } - } - } - - UInt32 oldval_uid = uid; - Property prop_uid = pdatas[21]; - if(prop_uid.isBase()) - { - if(inited && !inWorld) - onUidChanged(oldval_uid); - } - else - { - if(inWorld) - { - if(prop_uid.isOwnerOnly() && !isPlayer()) - { - } - else - { - onUidChanged(oldval_uid); - } - } - } - - UInt32 oldval_utype = utype; - Property prop_utype = pdatas[22]; - if(prop_utype.isBase()) - { - if(inited && !inWorld) - onUtypeChanged(oldval_utype); - } - else - { - if(inWorld) - { - if(prop_utype.isOwnerOnly() && !isPlayer()) - { - } - else - { - onUtypeChanged(oldval_utype); - } - } - } - - } - } +/* + Generated by KBEngine! + Please do not modify this file! + Please inherit this module, such as: (class Avatar : AvatarBase) + tools = kbcmd +*/ + +namespace KBEngine +{ + using UnityEngine; + using System; + using System.Collections; + using System.Collections.Generic; + + // defined in */scripts/entity_defs/Avatar.def + // Please inherit and implement "class Avatar : AvatarBase" + public abstract class AvatarBase : Entity + { + public EntityBaseEntityCall_AvatarBase baseEntityCall = null; + public EntityCellEntityCall_AvatarBase cellEntityCall = null; + + public Int32 HP = 0; + public virtual void onHPChanged(Int32 oldValue) {} + public Int32 HP_Max = 0; + public virtual void onHP_MaxChanged(Int32 oldValue) {} + public Int32 MP = 0; + public virtual void onMPChanged(Int32 oldValue) {} + public Int32 MP_Max = 0; + public virtual void onMP_MaxChanged(Int32 oldValue) {} + public TestBase component1 = null; + public TestBase component2 = null; + public TestNoBaseBase component3 = null; + public Int32 forbids = 0; + public virtual void onForbidsChanged(Int32 oldValue) {} + public UInt16 level = 0; + public virtual void onLevelChanged(UInt16 oldValue) {} + public UInt32 modelID = 0; + public virtual void onModelIDChanged(UInt32 oldValue) {} + public Byte modelScale = 30; + public virtual void onModelScaleChanged(Byte oldValue) {} + public Byte moveSpeed = 50; + public virtual void onMoveSpeedChanged(Byte oldValue) {} + public string name = ""; + public virtual void onNameChanged(string oldValue) {} + public UInt16 own_val = 0; + public virtual void onOwn_valChanged(UInt16 oldValue) {} + public UInt32 spaceUType = 0; + public virtual void onSpaceUTypeChanged(UInt32 oldValue) {} + public SByte state = 0; + public virtual void onStateChanged(SByte oldValue) {} + public Byte subState = 0; + public virtual void onSubStateChanged(Byte oldValue) {} + public UInt32 uid = 0; + public virtual void onUidChanged(UInt32 oldValue) {} + public UInt32 utype = 0; + public virtual void onUtypeChanged(UInt32 oldValue) {} + + public abstract void dialog_addOption(Byte arg1, UInt32 arg2, string arg3, Int32 arg4); + public abstract void dialog_close(); + public abstract void dialog_setText(string arg1, Byte arg2, UInt32 arg3, string arg4); + public abstract void onAddSkill(Int32 arg1); + public abstract void onJump(); + public abstract void onRemoveSkill(Int32 arg1); + public abstract void recvDamage(Int32 arg1, Int32 arg2, Int32 arg3, Int32 arg4); + + public AvatarBase() + { + foreach (System.Reflection.Assembly ass in AppDomain.CurrentDomain.GetAssemblies()) + { + Type entityComponentScript = ass.GetType("KBEngine.Test"); + if(entityComponentScript != null) + { + component1 = (TestBase)Activator.CreateInstance(entityComponentScript); + component1.owner = this; + component1.entityComponentPropertyID = 16; + } + } + + if(component1 == null) + throw new Exception("Please inherit and implement, such as: \"class Test : TestBase\""); + + foreach (System.Reflection.Assembly ass in AppDomain.CurrentDomain.GetAssemblies()) + { + Type entityComponentScript = ass.GetType("KBEngine.Test"); + if(entityComponentScript != null) + { + component2 = (TestBase)Activator.CreateInstance(entityComponentScript); + component2.owner = this; + component2.entityComponentPropertyID = 21; + } + } + + if(component2 == null) + throw new Exception("Please inherit and implement, such as: \"class Test : TestBase\""); + + foreach (System.Reflection.Assembly ass in AppDomain.CurrentDomain.GetAssemblies()) + { + Type entityComponentScript = ass.GetType("KBEngine.TestNoBase"); + if(entityComponentScript != null) + { + component3 = (TestNoBaseBase)Activator.CreateInstance(entityComponentScript); + component3.owner = this; + component3.entityComponentPropertyID = 22; + } + } + + if(component3 == null) + throw new Exception("Please inherit and implement, such as: \"class TestNoBase : TestNoBaseBase\""); + + } + + public override void onComponentsEnterworld() + { + component1.onEnterworld(); + component2.onEnterworld(); + component3.onEnterworld(); + } + + public override void onComponentsLeaveworld() + { + component1.onLeaveworld(); + component2.onLeaveworld(); + component3.onLeaveworld(); + } + + public override void onGetBase() + { + baseEntityCall = new EntityBaseEntityCall_AvatarBase(id, className); + } + + public override void onGetCell() + { + cellEntityCall = new EntityCellEntityCall_AvatarBase(id, className); + } + + public override void onLoseCell() + { + cellEntityCall = null; + } + + public override EntityCall getBaseEntityCall() + { + return baseEntityCall; + } + + public override EntityCall getCellEntityCall() + { + return cellEntityCall; + } + + public override void attachComponents() + { + component1.onAttached(this); + component2.onAttached(this); + component3.onAttached(this); + } + + public override void detachComponents() + { + component1.onDetached(this); + component2.onDetached(this); + component3.onDetached(this); + } + + public override void onRemoteMethodCall(MemoryStream stream) + { + ScriptModule sm = EntityDef.moduledefs["Avatar"]; + + UInt16 methodUtype = 0; + UInt16 componentPropertyUType = 0; + + if(sm.usePropertyDescrAlias) + { + componentPropertyUType = stream.readUint8(); + } + else + { + componentPropertyUType = stream.readUint16(); + } + + if(sm.useMethodDescrAlias) + { + methodUtype = stream.readUint8(); + } + else + { + methodUtype = stream.readUint16(); + } + + Method method = null; + + if(componentPropertyUType == 0) + { + method = sm.idmethods[methodUtype]; + } + else + { + Property pComponentPropertyDescription = sm.idpropertys[componentPropertyUType]; + switch(pComponentPropertyDescription.properUtype) + { + case 16: + component1.onRemoteMethodCall(methodUtype, stream); + break; + case 21: + component2.onRemoteMethodCall(methodUtype, stream); + break; + case 22: + component3.onRemoteMethodCall(methodUtype, stream); + break; + default: + break; + } + + return; + } + + switch(method.methodUtype) + { + case 10101: + Byte dialog_addOption_arg1 = stream.readUint8(); + UInt32 dialog_addOption_arg2 = stream.readUint32(); + string dialog_addOption_arg3 = stream.readUnicode(); + Int32 dialog_addOption_arg4 = stream.readInt32(); + dialog_addOption(dialog_addOption_arg1, dialog_addOption_arg2, dialog_addOption_arg3, dialog_addOption_arg4); + break; + case 10104: + dialog_close(); + break; + case 10102: + string dialog_setText_arg1 = stream.readUnicode(); + Byte dialog_setText_arg2 = stream.readUint8(); + UInt32 dialog_setText_arg3 = stream.readUint32(); + string dialog_setText_arg4 = stream.readUnicode(); + dialog_setText(dialog_setText_arg1, dialog_setText_arg2, dialog_setText_arg3, dialog_setText_arg4); + break; + case 12: + Int32 onAddSkill_arg1 = stream.readInt32(); + onAddSkill(onAddSkill_arg1); + break; + case 7: + onJump(); + break; + case 13: + Int32 onRemoveSkill_arg1 = stream.readInt32(); + onRemoveSkill(onRemoveSkill_arg1); + break; + case 16: + Int32 recvDamage_arg1 = stream.readInt32(); + Int32 recvDamage_arg2 = stream.readInt32(); + Int32 recvDamage_arg3 = stream.readInt32(); + Int32 recvDamage_arg4 = stream.readInt32(); + recvDamage(recvDamage_arg1, recvDamage_arg2, recvDamage_arg3, recvDamage_arg4); + break; + default: + break; + }; + } + + public override void onUpdatePropertys(MemoryStream stream) + { + ScriptModule sm = EntityDef.moduledefs["Avatar"]; + Dictionary pdatas = sm.idpropertys; + + while(stream.length() > 0) + { + UInt16 _t_utype = 0; + UInt16 _t_child_utype = 0; + + { + if(sm.usePropertyDescrAlias) + { + _t_utype = stream.readUint8(); + _t_child_utype = stream.readUint8(); + } + else + { + _t_utype = stream.readUint16(); + _t_child_utype = stream.readUint16(); + } + } + + Property prop = null; + + if(_t_utype == 0) + { + prop = pdatas[_t_child_utype]; + } + else + { + Property pComponentPropertyDescription = pdatas[_t_utype]; + switch(pComponentPropertyDescription.properUtype) + { + case 16: + component1.onUpdatePropertys(_t_child_utype, stream, -1); + break; + case 21: + component2.onUpdatePropertys(_t_child_utype, stream, -1); + break; + case 22: + component3.onUpdatePropertys(_t_child_utype, stream, -1); + break; + default: + break; + } + + return; + } + + switch(prop.properUtype) + { + case 47001: + Int32 oldval_HP = HP; + HP = stream.readInt32(); + + if(prop.isBase()) + { + if(inited) + onHPChanged(oldval_HP); + } + else + { + if(inWorld) + onHPChanged(oldval_HP); + } + + break; + case 47002: + Int32 oldval_HP_Max = HP_Max; + HP_Max = stream.readInt32(); + + if(prop.isBase()) + { + if(inited) + onHP_MaxChanged(oldval_HP_Max); + } + else + { + if(inWorld) + onHP_MaxChanged(oldval_HP_Max); + } + + break; + case 47003: + Int32 oldval_MP = MP; + MP = stream.readInt32(); + + if(prop.isBase()) + { + if(inited) + onMPChanged(oldval_MP); + } + else + { + if(inWorld) + onMPChanged(oldval_MP); + } + + break; + case 47004: + Int32 oldval_MP_Max = MP_Max; + MP_Max = stream.readInt32(); + + if(prop.isBase()) + { + if(inited) + onMP_MaxChanged(oldval_MP_Max); + } + else + { + if(inWorld) + onMP_MaxChanged(oldval_MP_Max); + } + + break; + case 16: + component1.createFromStream(stream); + break; + case 21: + component2.createFromStream(stream); + break; + case 22: + component3.createFromStream(stream); + break; + case 40001: + Vector3 oldval_direction = direction; + direction = stream.readVector3(); + + if(prop.isBase()) + { + if(inited) + onDirectionChanged(oldval_direction); + } + else + { + if(inWorld) + onDirectionChanged(oldval_direction); + } + + break; + case 47005: + Int32 oldval_forbids = forbids; + forbids = stream.readInt32(); + + if(prop.isBase()) + { + if(inited) + onForbidsChanged(oldval_forbids); + } + else + { + if(inWorld) + onForbidsChanged(oldval_forbids); + } + + break; + case 41002: + UInt16 oldval_level = level; + level = stream.readUint16(); + + if(prop.isBase()) + { + if(inited) + onLevelChanged(oldval_level); + } + else + { + if(inWorld) + onLevelChanged(oldval_level); + } + + break; + case 41006: + UInt32 oldval_modelID = modelID; + modelID = stream.readUint32(); + + if(prop.isBase()) + { + if(inited) + onModelIDChanged(oldval_modelID); + } + else + { + if(inWorld) + onModelIDChanged(oldval_modelID); + } + + break; + case 41007: + Byte oldval_modelScale = modelScale; + modelScale = stream.readUint8(); + + if(prop.isBase()) + { + if(inited) + onModelScaleChanged(oldval_modelScale); + } + else + { + if(inWorld) + onModelScaleChanged(oldval_modelScale); + } + + break; + case 11: + Byte oldval_moveSpeed = moveSpeed; + moveSpeed = stream.readUint8(); + + if(prop.isBase()) + { + if(inited) + onMoveSpeedChanged(oldval_moveSpeed); + } + else + { + if(inWorld) + onMoveSpeedChanged(oldval_moveSpeed); + } + + break; + case 41003: + string oldval_name = name; + name = stream.readUnicode(); + + if(prop.isBase()) + { + if(inited) + onNameChanged(oldval_name); + } + else + { + if(inWorld) + onNameChanged(oldval_name); + } + + break; + case 6: + UInt16 oldval_own_val = own_val; + own_val = stream.readUint16(); + + if(prop.isBase()) + { + if(inited) + onOwn_valChanged(oldval_own_val); + } + else + { + if(inWorld) + onOwn_valChanged(oldval_own_val); + } + + break; + case 40000: + Vector3 oldval_position = position; + position = stream.readVector3(); + + if(prop.isBase()) + { + if(inited) + onPositionChanged(oldval_position); + } + else + { + if(inWorld) + onPositionChanged(oldval_position); + } + + break; + case 40002: + stream.readUint32(); + break; + case 41001: + UInt32 oldval_spaceUType = spaceUType; + spaceUType = stream.readUint32(); + + if(prop.isBase()) + { + if(inited) + onSpaceUTypeChanged(oldval_spaceUType); + } + else + { + if(inWorld) + onSpaceUTypeChanged(oldval_spaceUType); + } + + break; + case 47006: + SByte oldval_state = state; + state = stream.readInt8(); + + if(prop.isBase()) + { + if(inited) + onStateChanged(oldval_state); + } + else + { + if(inWorld) + onStateChanged(oldval_state); + } + + break; + case 47007: + Byte oldval_subState = subState; + subState = stream.readUint8(); + + if(prop.isBase()) + { + if(inited) + onSubStateChanged(oldval_subState); + } + else + { + if(inWorld) + onSubStateChanged(oldval_subState); + } + + break; + case 41004: + UInt32 oldval_uid = uid; + uid = stream.readUint32(); + + if(prop.isBase()) + { + if(inited) + onUidChanged(oldval_uid); + } + else + { + if(inWorld) + onUidChanged(oldval_uid); + } + + break; + case 41005: + UInt32 oldval_utype = utype; + utype = stream.readUint32(); + + if(prop.isBase()) + { + if(inited) + onUtypeChanged(oldval_utype); + } + else + { + if(inWorld) + onUtypeChanged(oldval_utype); + } + + break; + default: + break; + }; + } + } + + public override void callPropertysSetMethods() + { + ScriptModule sm = EntityDef.moduledefs["Avatar"]; + Dictionary pdatas = sm.idpropertys; + + Int32 oldval_HP = HP; + Property prop_HP = pdatas[4]; + if(prop_HP.isBase()) + { + if(inited && !inWorld) + onHPChanged(oldval_HP); + } + else + { + if(inWorld) + { + if(prop_HP.isOwnerOnly() && !isPlayer()) + { + } + else + { + onHPChanged(oldval_HP); + } + } + } + + Int32 oldval_HP_Max = HP_Max; + Property prop_HP_Max = pdatas[5]; + if(prop_HP_Max.isBase()) + { + if(inited && !inWorld) + onHP_MaxChanged(oldval_HP_Max); + } + else + { + if(inWorld) + { + if(prop_HP_Max.isOwnerOnly() && !isPlayer()) + { + } + else + { + onHP_MaxChanged(oldval_HP_Max); + } + } + } + + Int32 oldval_MP = MP; + Property prop_MP = pdatas[6]; + if(prop_MP.isBase()) + { + if(inited && !inWorld) + onMPChanged(oldval_MP); + } + else + { + if(inWorld) + { + if(prop_MP.isOwnerOnly() && !isPlayer()) + { + } + else + { + onMPChanged(oldval_MP); + } + } + } + + Int32 oldval_MP_Max = MP_Max; + Property prop_MP_Max = pdatas[7]; + if(prop_MP_Max.isBase()) + { + if(inited && !inWorld) + onMP_MaxChanged(oldval_MP_Max); + } + else + { + if(inWorld) + { + if(prop_MP_Max.isOwnerOnly() && !isPlayer()) + { + } + else + { + onMP_MaxChanged(oldval_MP_Max); + } + } + } + + component1.callPropertysSetMethods(); + + component2.callPropertysSetMethods(); + + component3.callPropertysSetMethods(); + + Vector3 oldval_direction = direction; + Property prop_direction = pdatas[2]; + if(prop_direction.isBase()) + { + if(inited && !inWorld) + onDirectionChanged(oldval_direction); + } + else + { + if(inWorld) + { + if(prop_direction.isOwnerOnly() && !isPlayer()) + { + } + else + { + onDirectionChanged(oldval_direction); + } + } + } + + Int32 oldval_forbids = forbids; + Property prop_forbids = pdatas[11]; + if(prop_forbids.isBase()) + { + if(inited && !inWorld) + onForbidsChanged(oldval_forbids); + } + else + { + if(inWorld) + { + if(prop_forbids.isOwnerOnly() && !isPlayer()) + { + } + else + { + onForbidsChanged(oldval_forbids); + } + } + } + + UInt16 oldval_level = level; + Property prop_level = pdatas[12]; + if(prop_level.isBase()) + { + if(inited && !inWorld) + onLevelChanged(oldval_level); + } + else + { + if(inWorld) + { + if(prop_level.isOwnerOnly() && !isPlayer()) + { + } + else + { + onLevelChanged(oldval_level); + } + } + } + + UInt32 oldval_modelID = modelID; + Property prop_modelID = pdatas[13]; + if(prop_modelID.isBase()) + { + if(inited && !inWorld) + onModelIDChanged(oldval_modelID); + } + else + { + if(inWorld) + { + if(prop_modelID.isOwnerOnly() && !isPlayer()) + { + } + else + { + onModelIDChanged(oldval_modelID); + } + } + } + + Byte oldval_modelScale = modelScale; + Property prop_modelScale = pdatas[14]; + if(prop_modelScale.isBase()) + { + if(inited && !inWorld) + onModelScaleChanged(oldval_modelScale); + } + else + { + if(inWorld) + { + if(prop_modelScale.isOwnerOnly() && !isPlayer()) + { + } + else + { + onModelScaleChanged(oldval_modelScale); + } + } + } + + Byte oldval_moveSpeed = moveSpeed; + Property prop_moveSpeed = pdatas[15]; + if(prop_moveSpeed.isBase()) + { + if(inited && !inWorld) + onMoveSpeedChanged(oldval_moveSpeed); + } + else + { + if(inWorld) + { + if(prop_moveSpeed.isOwnerOnly() && !isPlayer()) + { + } + else + { + onMoveSpeedChanged(oldval_moveSpeed); + } + } + } + + string oldval_name = name; + Property prop_name = pdatas[16]; + if(prop_name.isBase()) + { + if(inited && !inWorld) + onNameChanged(oldval_name); + } + else + { + if(inWorld) + { + if(prop_name.isOwnerOnly() && !isPlayer()) + { + } + else + { + onNameChanged(oldval_name); + } + } + } + + UInt16 oldval_own_val = own_val; + Property prop_own_val = pdatas[17]; + if(prop_own_val.isBase()) + { + if(inited && !inWorld) + onOwn_valChanged(oldval_own_val); + } + else + { + if(inWorld) + { + if(prop_own_val.isOwnerOnly() && !isPlayer()) + { + } + else + { + onOwn_valChanged(oldval_own_val); + } + } + } + + Vector3 oldval_position = position; + Property prop_position = pdatas[1]; + if(prop_position.isBase()) + { + if(inited && !inWorld) + onPositionChanged(oldval_position); + } + else + { + if(inWorld) + { + if(prop_position.isOwnerOnly() && !isPlayer()) + { + } + else + { + onPositionChanged(oldval_position); + } + } + } + + UInt32 oldval_spaceUType = spaceUType; + Property prop_spaceUType = pdatas[18]; + if(prop_spaceUType.isBase()) + { + if(inited && !inWorld) + onSpaceUTypeChanged(oldval_spaceUType); + } + else + { + if(inWorld) + { + if(prop_spaceUType.isOwnerOnly() && !isPlayer()) + { + } + else + { + onSpaceUTypeChanged(oldval_spaceUType); + } + } + } + + SByte oldval_state = state; + Property prop_state = pdatas[19]; + if(prop_state.isBase()) + { + if(inited && !inWorld) + onStateChanged(oldval_state); + } + else + { + if(inWorld) + { + if(prop_state.isOwnerOnly() && !isPlayer()) + { + } + else + { + onStateChanged(oldval_state); + } + } + } + + Byte oldval_subState = subState; + Property prop_subState = pdatas[20]; + if(prop_subState.isBase()) + { + if(inited && !inWorld) + onSubStateChanged(oldval_subState); + } + else + { + if(inWorld) + { + if(prop_subState.isOwnerOnly() && !isPlayer()) + { + } + else + { + onSubStateChanged(oldval_subState); + } + } + } + + UInt32 oldval_uid = uid; + Property prop_uid = pdatas[21]; + if(prop_uid.isBase()) + { + if(inited && !inWorld) + onUidChanged(oldval_uid); + } + else + { + if(inWorld) + { + if(prop_uid.isOwnerOnly() && !isPlayer()) + { + } + else + { + onUidChanged(oldval_uid); + } + } + } + + UInt32 oldval_utype = utype; + Property prop_utype = pdatas[22]; + if(prop_utype.isBase()) + { + if(inited && !inWorld) + onUtypeChanged(oldval_utype); + } + else + { + if(inWorld) + { + if(prop_utype.isOwnerOnly() && !isPlayer()) + { + } + else + { + onUtypeChanged(oldval_utype); + } + } + } + + } + } } \ No newline at end of file diff --git a/Assets/Plugins/kbengine_unity3d_plugins/Blowfish.cs b/Assets/Plugins/kbengine_unity3d_plugins/Blowfish.cs index 06fd479..7d32e65 100644 --- a/Assets/Plugins/kbengine_unity3d_plugins/Blowfish.cs +++ b/Assets/Plugins/kbengine_unity3d_plugins/Blowfish.cs @@ -1,531 +1,531 @@ -namespace KBEngine -{ - using System; - using System.IO; - using System.Text; - using System.Collections; - using System.Collections.Generic; - using System.Security.Cryptography; - - public class Blowfish - { - const int N = 16; - const int KEYBYTES = 8; - private byte[] _key = new byte[0]; - private bool _isGood = true; - - private static RNGCryptoServiceProvider rngCsp = new RNGCryptoServiceProvider(); - - // key的最小和最大大小 - private const int MIN_KEY_SIZE = 32 / 8; - private const int MAX_KEY_SIZE = 448 / 8; - - // 默认key的大小 - private const int DEFAULT_KEY_SIZE = 128 / 8; - - static uint[] _P = - { - 0x243f6a88, 0x85a308d3, 0x13198a2e, 0x03707344, 0xa4093822, 0x299f31d0, - 0x082efa98, 0xec4e6c89, 0x452821e6, 0x38d01377, 0xbe5466cf, 0x34e90c6c, - 0xc0ac29b7, 0xc97c50dd, 0x3f84d5b5, 0xb5470917, 0x9216d5d9, 0x8979fb1b - }; - static uint[,] _S = - { - { - 0xd1310ba6, 0x98dfb5ac, 0x2ffd72db, 0xd01adfb7, 0xb8e1afed, 0x6a267e96, - 0xba7c9045, 0xf12c7f99, 0x24a19947, 0xb3916cf7, 0x0801f2e2, 0x858efc16, - 0x636920d8, 0x71574e69, 0xa458fea3, 0xf4933d7e, 0x0d95748f, 0x728eb658, - 0x718bcd58, 0x82154aee, 0x7b54a41d, 0xc25a59b5, 0x9c30d539, 0x2af26013, - 0xc5d1b023, 0x286085f0, 0xca417918, 0xb8db38ef, 0x8e79dcb0, 0x603a180e, - 0x6c9e0e8b, 0xb01e8a3e, 0xd71577c1, 0xbd314b27, 0x78af2fda, 0x55605c60, - 0xe65525f3, 0xaa55ab94, 0x57489862, 0x63e81440, 0x55ca396a, 0x2aab10b6, - 0xb4cc5c34, 0x1141e8ce, 0xa15486af, 0x7c72e993, 0xb3ee1411, 0x636fbc2a, - 0x2ba9c55d, 0x741831f6, 0xce5c3e16, 0x9b87931e, 0xafd6ba33, 0x6c24cf5c, - 0x7a325381, 0x28958677, 0x3b8f4898, 0x6b4bb9af, 0xc4bfe81b, 0x66282193, - 0x61d809cc, 0xfb21a991, 0x487cac60, 0x5dec8032, 0xef845d5d, 0xe98575b1, - 0xdc262302, 0xeb651b88, 0x23893e81, 0xd396acc5, 0x0f6d6ff3, 0x83f44239, - 0x2e0b4482, 0xa4842004, 0x69c8f04a, 0x9e1f9b5e, 0x21c66842, 0xf6e96c9a, - 0x670c9c61, 0xabd388f0, 0x6a51a0d2, 0xd8542f68, 0x960fa728, 0xab5133a3, - 0x6eef0b6c, 0x137a3be4, 0xba3bf050, 0x7efb2a98, 0xa1f1651d, 0x39af0176, - 0x66ca593e, 0x82430e88, 0x8cee8619, 0x456f9fb4, 0x7d84a5c3, 0x3b8b5ebe, - 0xe06f75d8, 0x85c12073, 0x401a449f, 0x56c16aa6, 0x4ed3aa62, 0x363f7706, - 0x1bfedf72, 0x429b023d, 0x37d0d724, 0xd00a1248, 0xdb0fead3, 0x49f1c09b, - 0x075372c9, 0x80991b7b, 0x25d479d8, 0xf6e8def7, 0xe3fe501a, 0xb6794c3b, - 0x976ce0bd, 0x04c006ba, 0xc1a94fb6, 0x409f60c4, 0x5e5c9ec2, 0x196a2463, - 0x68fb6faf, 0x3e6c53b5, 0x1339b2eb, 0x3b52ec6f, 0x6dfc511f, 0x9b30952c, - 0xcc814544, 0xaf5ebd09, 0xbee3d004, 0xde334afd, 0x660f2807, 0x192e4bb3, - 0xc0cba857, 0x45c8740f, 0xd20b5f39, 0xb9d3fbdb, 0x5579c0bd, 0x1a60320a, - 0xd6a100c6, 0x402c7279, 0x679f25fe, 0xfb1fa3cc, 0x8ea5e9f8, 0xdb3222f8, - 0x3c7516df, 0xfd616b15, 0x2f501ec8, 0xad0552ab, 0x323db5fa, 0xfd238760, - 0x53317b48, 0x3e00df82, 0x9e5c57bb, 0xca6f8ca0, 0x1a87562e, 0xdf1769db, - 0xd542a8f6, 0x287effc3, 0xac6732c6, 0x8c4f5573, 0x695b27b0, 0xbbca58c8, - 0xe1ffa35d, 0xb8f011a0, 0x10fa3d98, 0xfd2183b8, 0x4afcb56c, 0x2dd1d35b, - 0x9a53e479, 0xb6f84565, 0xd28e49bc, 0x4bfb9790, 0xe1ddf2da, 0xa4cb7e33, - 0x62fb1341, 0xcee4c6e8, 0xef20cada, 0x36774c01, 0xd07e9efe, 0x2bf11fb4, - 0x95dbda4d, 0xae909198, 0xeaad8e71, 0x6b93d5a0, 0xd08ed1d0, 0xafc725e0, - 0x8e3c5b2f, 0x8e7594b7, 0x8ff6e2fb, 0xf2122b64, 0x8888b812, 0x900df01c, - 0x4fad5ea0, 0x688fc31c, 0xd1cff191, 0xb3a8c1ad, 0x2f2f2218, 0xbe0e1777, - 0xea752dfe, 0x8b021fa1, 0xe5a0cc0f, 0xb56f74e8, 0x18acf3d6, 0xce89e299, - 0xb4a84fe0, 0xfd13e0b7, 0x7cc43b81, 0xd2ada8d9, 0x165fa266, 0x80957705, - 0x93cc7314, 0x211a1477, 0xe6ad2065, 0x77b5fa86, 0xc75442f5, 0xfb9d35cf, - 0xebcdaf0c, 0x7b3e89a0, 0xd6411bd3, 0xae1e7e49, 0x00250e2d, 0x2071b35e, - 0x226800bb, 0x57b8e0af, 0x2464369b, 0xf009b91e, 0x5563911d, 0x59dfa6aa, - 0x78c14389, 0xd95a537f, 0x207d5ba2, 0x02e5b9c5, 0x83260376, 0x6295cfa9, - 0x11c81968, 0x4e734a41, 0xb3472dca, 0x7b14a94a, 0x1b510052, 0x9a532915, - 0xd60f573f, 0xbc9bc6e4, 0x2b60a476, 0x81e67400, 0x08ba6fb5, 0x571be91f, - 0xf296ec6b, 0x2a0dd915, 0xb6636521, 0xe7b9f9b6, 0xff34052e, 0xc5855664, - 0x53b02d5d, 0xa99f8fa1, 0x08ba4799, 0x6e85076a - }, - { - 0x4b7a70e9, 0xb5b32944, 0xdb75092e, 0xc4192623, 0xad6ea6b0, 0x49a7df7d, - 0x9cee60b8, 0x8fedb266, 0xecaa8c71, 0x699a17ff, 0x5664526c, 0xc2b19ee1, - 0x193602a5, 0x75094c29, 0xa0591340, 0xe4183a3e, 0x3f54989a, 0x5b429d65, - 0x6b8fe4d6, 0x99f73fd6, 0xa1d29c07, 0xefe830f5, 0x4d2d38e6, 0xf0255dc1, - 0x4cdd2086, 0x8470eb26, 0x6382e9c6, 0x021ecc5e, 0x09686b3f, 0x3ebaefc9, - 0x3c971814, 0x6b6a70a1, 0x687f3584, 0x52a0e286, 0xb79c5305, 0xaa500737, - 0x3e07841c, 0x7fdeae5c, 0x8e7d44ec, 0x5716f2b8, 0xb03ada37, 0xf0500c0d, - 0xf01c1f04, 0x0200b3ff, 0xae0cf51a, 0x3cb574b2, 0x25837a58, 0xdc0921bd, - 0xd19113f9, 0x7ca92ff6, 0x94324773, 0x22f54701, 0x3ae5e581, 0x37c2dadc, - 0xc8b57634, 0x9af3dda7, 0xa9446146, 0x0fd0030e, 0xecc8c73e, 0xa4751e41, - 0xe238cd99, 0x3bea0e2f, 0x3280bba1, 0x183eb331, 0x4e548b38, 0x4f6db908, - 0x6f420d03, 0xf60a04bf, 0x2cb81290, 0x24977c79, 0x5679b072, 0xbcaf89af, - 0xde9a771f, 0xd9930810, 0xb38bae12, 0xdccf3f2e, 0x5512721f, 0x2e6b7124, - 0x501adde6, 0x9f84cd87, 0x7a584718, 0x7408da17, 0xbc9f9abc, 0xe94b7d8c, - 0xec7aec3a, 0xdb851dfa, 0x63094366, 0xc464c3d2, 0xef1c1847, 0x3215d908, - 0xdd433b37, 0x24c2ba16, 0x12a14d43, 0x2a65c451, 0x50940002, 0x133ae4dd, - 0x71dff89e, 0x10314e55, 0x81ac77d6, 0x5f11199b, 0x043556f1, 0xd7a3c76b, - 0x3c11183b, 0x5924a509, 0xf28fe6ed, 0x97f1fbfa, 0x9ebabf2c, 0x1e153c6e, - 0x86e34570, 0xeae96fb1, 0x860e5e0a, 0x5a3e2ab3, 0x771fe71c, 0x4e3d06fa, - 0x2965dcb9, 0x99e71d0f, 0x803e89d6, 0x5266c825, 0x2e4cc978, 0x9c10b36a, - 0xc6150eba, 0x94e2ea78, 0xa5fc3c53, 0x1e0a2df4, 0xf2f74ea7, 0x361d2b3d, - 0x1939260f, 0x19c27960, 0x5223a708, 0xf71312b6, 0xebadfe6e, 0xeac31f66, - 0xe3bc4595, 0xa67bc883, 0xb17f37d1, 0x018cff28, 0xc332ddef, 0xbe6c5aa5, - 0x65582185, 0x68ab9802, 0xeecea50f, 0xdb2f953b, 0x2aef7dad, 0x5b6e2f84, - 0x1521b628, 0x29076170, 0xecdd4775, 0x619f1510, 0x13cca830, 0xeb61bd96, - 0x0334fe1e, 0xaa0363cf, 0xb5735c90, 0x4c70a239, 0xd59e9e0b, 0xcbaade14, - 0xeecc86bc, 0x60622ca7, 0x9cab5cab, 0xb2f3846e, 0x648b1eaf, 0x19bdf0ca, - 0xa02369b9, 0x655abb50, 0x40685a32, 0x3c2ab4b3, 0x319ee9d5, 0xc021b8f7, - 0x9b540b19, 0x875fa099, 0x95f7997e, 0x623d7da8, 0xf837889a, 0x97e32d77, - 0x11ed935f, 0x16681281, 0x0e358829, 0xc7e61fd6, 0x96dedfa1, 0x7858ba99, - 0x57f584a5, 0x1b227263, 0x9b83c3ff, 0x1ac24696, 0xcdb30aeb, 0x532e3054, - 0x8fd948e4, 0x6dbc3128, 0x58ebf2ef, 0x34c6ffea, 0xfe28ed61, 0xee7c3c73, - 0x5d4a14d9, 0xe864b7e3, 0x42105d14, 0x203e13e0, 0x45eee2b6, 0xa3aaabea, - 0xdb6c4f15, 0xfacb4fd0, 0xc742f442, 0xef6abbb5, 0x654f3b1d, 0x41cd2105, - 0xd81e799e, 0x86854dc7, 0xe44b476a, 0x3d816250, 0xcf62a1f2, 0x5b8d2646, - 0xfc8883a0, 0xc1c7b6a3, 0x7f1524c3, 0x69cb7492, 0x47848a0b, 0x5692b285, - 0x095bbf00, 0xad19489d, 0x1462b174, 0x23820e00, 0x58428d2a, 0x0c55f5ea, - 0x1dadf43e, 0x233f7061, 0x3372f092, 0x8d937e41, 0xd65fecf1, 0x6c223bdb, - 0x7cde3759, 0xcbee7460, 0x4085f2a7, 0xce77326e, 0xa6078084, 0x19f8509e, - 0xe8efd855, 0x61d99735, 0xa969a7aa, 0xc50c06c2, 0x5a04abfc, 0x800bcadc, - 0x9e447a2e, 0xc3453484, 0xfdd56705, 0x0e1e9ec9, 0xdb73dbd3, 0x105588cd, - 0x675fda79, 0xe3674340, 0xc5c43465, 0x713e38d8, 0x3d28f89e, 0xf16dff20, - 0x153e21e7, 0x8fb03d4a, 0xe6e39f2b, 0xdb83adf7 - }, - { - 0xe93d5a68, 0x948140f7, 0xf64c261c, 0x94692934, 0x411520f7, 0x7602d4f7, - 0xbcf46b2e, 0xd4a20068, 0xd4082471, 0x3320f46a, 0x43b7d4b7, 0x500061af, - 0x1e39f62e, 0x97244546, 0x14214f74, 0xbf8b8840, 0x4d95fc1d, 0x96b591af, - 0x70f4ddd3, 0x66a02f45, 0xbfbc09ec, 0x03bd9785, 0x7fac6dd0, 0x31cb8504, - 0x96eb27b3, 0x55fd3941, 0xda2547e6, 0xabca0a9a, 0x28507825, 0x530429f4, - 0x0a2c86da, 0xe9b66dfb, 0x68dc1462, 0xd7486900, 0x680ec0a4, 0x27a18dee, - 0x4f3ffea2, 0xe887ad8c, 0xb58ce006, 0x7af4d6b6, 0xaace1e7c, 0xd3375fec, - 0xce78a399, 0x406b2a42, 0x20fe9e35, 0xd9f385b9, 0xee39d7ab, 0x3b124e8b, - 0x1dc9faf7, 0x4b6d1856, 0x26a36631, 0xeae397b2, 0x3a6efa74, 0xdd5b4332, - 0x6841e7f7, 0xca7820fb, 0xfb0af54e, 0xd8feb397, 0x454056ac, 0xba489527, - 0x55533a3a, 0x20838d87, 0xfe6ba9b7, 0xd096954b, 0x55a867bc, 0xa1159a58, - 0xcca92963, 0x99e1db33, 0xa62a4a56, 0x3f3125f9, 0x5ef47e1c, 0x9029317c, - 0xfdf8e802, 0x04272f70, 0x80bb155c, 0x05282ce3, 0x95c11548, 0xe4c66d22, - 0x48c1133f, 0xc70f86dc, 0x07f9c9ee, 0x41041f0f, 0x404779a4, 0x5d886e17, - 0x325f51eb, 0xd59bc0d1, 0xf2bcc18f, 0x41113564, 0x257b7834, 0x602a9c60, - 0xdff8e8a3, 0x1f636c1b, 0x0e12b4c2, 0x02e1329e, 0xaf664fd1, 0xcad18115, - 0x6b2395e0, 0x333e92e1, 0x3b240b62, 0xeebeb922, 0x85b2a20e, 0xe6ba0d99, - 0xde720c8c, 0x2da2f728, 0xd0127845, 0x95b794fd, 0x647d0862, 0xe7ccf5f0, - 0x5449a36f, 0x877d48fa, 0xc39dfd27, 0xf33e8d1e, 0x0a476341, 0x992eff74, - 0x3a6f6eab, 0xf4f8fd37, 0xa812dc60, 0xa1ebddf8, 0x991be14c, 0xdb6e6b0d, - 0xc67b5510, 0x6d672c37, 0x2765d43b, 0xdcd0e804, 0xf1290dc7, 0xcc00ffa3, - 0xb5390f92, 0x690fed0b, 0x667b9ffb, 0xcedb7d9c, 0xa091cf0b, 0xd9155ea3, - 0xbb132f88, 0x515bad24, 0x7b9479bf, 0x763bd6eb, 0x37392eb3, 0xcc115979, - 0x8026e297, 0xf42e312d, 0x6842ada7, 0xc66a2b3b, 0x12754ccc, 0x782ef11c, - 0x6a124237, 0xb79251e7, 0x06a1bbe6, 0x4bfb6350, 0x1a6b1018, 0x11caedfa, - 0x3d25bdd8, 0xe2e1c3c9, 0x44421659, 0x0a121386, 0xd90cec6e, 0xd5abea2a, - 0x64af674e, 0xda86a85f, 0xbebfe988, 0x64e4c3fe, 0x9dbc8057, 0xf0f7c086, - 0x60787bf8, 0x6003604d, 0xd1fd8346, 0xf6381fb0, 0x7745ae04, 0xd736fccc, - 0x83426b33, 0xf01eab71, 0xb0804187, 0x3c005e5f, 0x77a057be, 0xbde8ae24, - 0x55464299, 0xbf582e61, 0x4e58f48f, 0xf2ddfda2, 0xf474ef38, 0x8789bdc2, - 0x5366f9c3, 0xc8b38e74, 0xb475f255, 0x46fcd9b9, 0x7aeb2661, 0x8b1ddf84, - 0x846a0e79, 0x915f95e2, 0x466e598e, 0x20b45770, 0x8cd55591, 0xc902de4c, - 0xb90bace1, 0xbb8205d0, 0x11a86248, 0x7574a99e, 0xb77f19b6, 0xe0a9dc09, - 0x662d09a1, 0xc4324633, 0xe85a1f02, 0x09f0be8c, 0x4a99a025, 0x1d6efe10, - 0x1ab93d1d, 0x0ba5a4df, 0xa186f20f, 0x2868f169, 0xdcb7da83, 0x573906fe, - 0xa1e2ce9b, 0x4fcd7f52, 0x50115e01, 0xa70683fa, 0xa002b5c4, 0x0de6d027, - 0x9af88c27, 0x773f8641, 0xc3604c06, 0x61a806b5, 0xf0177a28, 0xc0f586e0, - 0x006058aa, 0x30dc7d62, 0x11e69ed7, 0x2338ea63, 0x53c2dd94, 0xc2c21634, - 0xbbcbee56, 0x90bcb6de, 0xebfc7da1, 0xce591d76, 0x6f05e409, 0x4b7c0188, - 0x39720a3d, 0x7c927c24, 0x86e3725f, 0x724d9db9, 0x1ac15bb4, 0xd39eb8fc, - 0xed545578, 0x08fca5b5, 0xd83d7cd3, 0x4dad0fc4, 0x1e50ef5e, 0xb161e6f8, - 0xa28514d9, 0x6c51133c, 0x6fd5c7e7, 0x56e14ec4, 0x362abfce, 0xddc6c837, - 0xd79a3234, 0x92638212, 0x670efa8e, 0x406000e0 - }, - { - 0x3a39ce37, 0xd3faf5cf, 0xabc27737, 0x5ac52d1b, 0x5cb0679e, 0x4fa33742, - 0xd3822740, 0x99bc9bbe, 0xd5118e9d, 0xbf0f7315, 0xd62d1c7e, 0xc700c47b, - 0xb78c1b6b, 0x21a19045, 0xb26eb1be, 0x6a366eb4, 0x5748ab2f, 0xbc946e79, - 0xc6a376d2, 0x6549c2c8, 0x530ff8ee, 0x468dde7d, 0xd5730a1d, 0x4cd04dc6, - 0x2939bbdb, 0xa9ba4650, 0xac9526e8, 0xbe5ee304, 0xa1fad5f0, 0x6a2d519a, - 0x63ef8ce2, 0x9a86ee22, 0xc089c2b8, 0x43242ef6, 0xa51e03aa, 0x9cf2d0a4, - 0x83c061ba, 0x9be96a4d, 0x8fe51550, 0xba645bd6, 0x2826a2f9, 0xa73a3ae1, - 0x4ba99586, 0xef5562e9, 0xc72fefd3, 0xf752f7da, 0x3f046f69, 0x77fa0a59, - 0x80e4a915, 0x87b08601, 0x9b09e6ad, 0x3b3ee593, 0xe990fd5a, 0x9e34d797, - 0x2cf0b7d9, 0x022b8b51, 0x96d5ac3a, 0x017da67d, 0xd1cf3ed6, 0x7c7d2d28, - 0x1f9f25cf, 0xadf2b89b, 0x5ad6b472, 0x5a88f54c, 0xe029ac71, 0xe019a5e6, - 0x47b0acfd, 0xed93fa9b, 0xe8d3c48d, 0x283b57cc, 0xf8d56629, 0x79132e28, - 0x785f0191, 0xed756055, 0xf7960e44, 0xe3d35e8c, 0x15056dd4, 0x88f46dba, - 0x03a16125, 0x0564f0bd, 0xc3eb9e15, 0x3c9057a2, 0x97271aec, 0xa93a072a, - 0x1b3f6d9b, 0x1e6321f5, 0xf59c66fb, 0x26dcf319, 0x7533d928, 0xb155fdf5, - 0x03563482, 0x8aba3cbb, 0x28517711, 0xc20ad9f8, 0xabcc5167, 0xccad925f, - 0x4de81751, 0x3830dc8e, 0x379d5862, 0x9320f991, 0xea7a90c2, 0xfb3e7bce, - 0x5121ce64, 0x774fbe32, 0xa8b6e37e, 0xc3293d46, 0x48de5369, 0x6413e680, - 0xa2ae0810, 0xdd6db224, 0x69852dfd, 0x09072166, 0xb39a460a, 0x6445c0dd, - 0x586cdecf, 0x1c20c8ae, 0x5bbef7dd, 0x1b588d40, 0xccd2017f, 0x6bb4e3bb, - 0xdda26a7e, 0x3a59ff45, 0x3e350a44, 0xbcb4cdd5, 0x72eacea8, 0xfa6484bb, - 0x8d6612ae, 0xbf3c6f47, 0xd29be463, 0x542f5d9e, 0xaec2771b, 0xf64e6370, - 0x740e0d8d, 0xe75b1357, 0xf8721671, 0xaf537d5d, 0x4040cb08, 0x4eb4e2cc, - 0x34d2466a, 0x0115af84, 0xe1b00428, 0x95983a1d, 0x06b89fb4, 0xce6ea048, - 0x6f3f3b82, 0x3520ab82, 0x011a1d4b, 0x277227f8, 0x611560b1, 0xe7933fdc, - 0xbb3a792b, 0x344525bd, 0xa08839e1, 0x51ce794b, 0x2f32c9b7, 0xa01fbac9, - 0xe01cc87e, 0xbcc7d1f6, 0xcf0111c3, 0xa1e8aac7, 0x1a908749, 0xd44fbd9a, - 0xd0dadecb, 0xd50ada38, 0x0339c32a, 0xc6913667, 0x8df9317c, 0xe0b12b4f, - 0xf79e59b7, 0x43f5bb3a, 0xf2d519ff, 0x27d9459c, 0xbf97222c, 0x15e6fc2a, - 0x0f91fc71, 0x9b941525, 0xfae59361, 0xceb69ceb, 0xc2a86459, 0x12baa8d1, - 0xb6c1075e, 0xe3056a0c, 0x10d25065, 0xcb03a442, 0xe0ec6e0e, 0x1698db3b, - 0x4c98a0be, 0x3278e964, 0x9f1f9532, 0xe0d392df, 0xd3a0342b, 0x8971f21e, - 0x1b0a7441, 0x4ba3348c, 0xc5be7120, 0xc37632d8, 0xdf359f8d, 0x9b992f2e, - 0xe60b6f47, 0x0fe3f11d, 0xe54cda54, 0x1edad891, 0xce6279cf, 0xcd3e7e6f, - 0x1618b166, 0xfd2c1d05, 0x848fd2c5, 0xf6fb2299, 0xf523f357, 0xa6327623, - 0x93a83531, 0x56cccd02, 0xacf08162, 0x5a75ebb5, 0x6e163697, 0x88d273cc, - 0xde966292, 0x81b949d0, 0x4c50901b, 0x71c65614, 0xe6c6c7bd, 0x327a140a, - 0x45e1d006, 0xc3f27b9a, 0xc9aa53fd, 0x62a80f00, 0xbb25bfe2, 0x35bdd2f6, - 0x71126905, 0xb2040222, 0xb6cbcf7c, 0xcd769c2b, 0x53113ec0, 0x1640e3d3, - 0x38abbd60, 0x2547adf0, 0xba38209c, 0xf746ce76, 0x77afa1c5, 0x20756060, - 0x85cbfe4e, 0x8ae88dd8, 0x7aaaf9b0, 0x4cf9aa7e, 0x1948c25c, 0x02fb8a8c, - 0x01c36ae4, 0xd6ebe1f9, 0x90d4f869, 0xa65cdea0, 0x3f09252d, 0xc208e69f, - 0xb74e6132, 0xce77e25b, 0x578fdfe3, 0x3ac372e6 - } - }; - - uint[] P; - uint[,] S; - - public Blowfish(byte[] key) - { - _key = key; - init(); - } - - public Blowfish(string key) : this(Encoding.Unicode.GetBytes(key)) - { - - } - - public Blowfish(int keySize = DEFAULT_KEY_SIZE) - { - _key = new byte[keySize]; - rngCsp.GetBytes(_key); - init(); - } - - ~Blowfish() - { - } - - public bool isGood() - { - return _isGood; - } - - private void init() - { - if(_key.Length < MIN_KEY_SIZE || _key.Length > MAX_KEY_SIZE) - { - _isGood = false; - Dbg.ERROR_MSG("Blowfish::init: invalid length " + _key.Length); - return; - } - - short i; - short j; - short k; - uint data; - uint datal; - uint datar; - - P = _P.Clone() as uint[]; - S = _S.Clone() as uint[,]; - - j = 0; - for (i = 0; i < N + 2; ++i) - { - data = 0x00000000; - for (k = 0; k < 4; ++k) - { - data = (data << 8) | _key[j]; - j++; - if (j >= _key.Length) - { - j = 0; - } - } - P[i] = P[i] ^ data; - } - - datal = 0x00000000; - datar = 0x00000000; - - for (i = 0; i < N + 2; i += 2) - { - encipher(ref datal, ref datar); - P[i] = datal; - P[i + 1] = datar; - } - - for (i = 0; i < 4; ++i) - { - for (j = 0; j < 256; j += 2) - { - encipher(ref datal, ref datar); - - S[i, j] = datal; - S[i, j + 1] = datar; - } - } - - _isGood = true; - } - - private uint f(uint x) - { - ushort a; - ushort b; - ushort c; - ushort d; - uint y; - - d = (ushort)(x & 0x00FF); - x >>= 8; - c = (ushort)(x & 0x00FF); - x >>= 8; - b = (ushort)(x & 0x00FF); - x >>= 8; - a = (ushort)(x & 0x00FF); - //y = ((S[0][a] + S[1][b]) ^ S[2][c]) + S[3][d]; - y = S[0, a] + S[1, b]; - y = y ^ S[2, c]; - y = y + S[3, d]; - - return y; - } - - /// - /// Encrypts a byte array in place. - /// - /// The array to encrypt. - /// The amount to encrypt. - public void encipher(byte[] data, int length) - { - if ((length % 8) != 0) - throw new Exception("Invalid Length"); - - uint xl, xr; - UInt64 prevBlock = 0; - - for (int i = 0; i < length; i += 8) - { - if (prevBlock != 0) - { - UInt64 oldValue = BitConverter.ToUInt64(data, i); - UInt64 ret = oldValue ^ prevBlock; - prevBlock = oldValue; - - data[i] = (byte)ret; - data[i + 1] = (byte)(ret >> 0x8); - data[i + 2] = (byte)(ret >> 0x10); - data[i + 3] = (byte)(ret >> 0x18); - data[i + 4] = (byte)(ret >> 0x20); - data[i + 5] = (byte)(ret >> 0x28); - data[i + 6] = (byte)(ret >> 0x30); - data[i + 7] = (byte)(ret >> 0x38); - } - else - { - prevBlock = BitConverter.ToUInt64(data, i); - } - - // Encode the data in 8 byte blocks. - xl = (uint)((data[i] << 24) | (data[i + 1] << 16) | (data[i + 2] << 8) | data[i + 3]); - xr = (uint)((data[i + 4] << 24) | (data[i + 5] << 16) | (data[i + 6] << 8) | data[i + 7]); - encipher(ref xl, ref xr); - // Now Replace the data. - data[i] = (byte)(xl >> 24); - data[i + 1] = (byte)(xl >> 16); - data[i + 2] = (byte)(xl >> 8); - data[i + 3] = (byte)(xl); - data[i + 4] = (byte)(xr >> 24); - data[i + 5] = (byte)(xr >> 16); - data[i + 6] = (byte)(xr >> 8); - data[i + 7] = (byte)(xr); - } - } - - /// - /// Encrypts 8 bytes of data (1 block) - /// - /// The left part of the 8 bytes. - /// The right part of the 8 bytes. - private void encipher(ref uint xl, ref uint xr) - { - uint Xl; - uint Xr; - uint temp; - short i; - - Xl = xl; - Xr = xr; - - for (i = 0; i < N; ++i) - { - Xl = Xl ^ P[i]; - Xr = f(Xl) ^ Xr; - - temp = Xl; - Xl = Xr; - Xr = temp; - } - - temp = Xl; - Xl = Xr; - Xr = temp; - - Xr = Xr ^ P[N]; - Xl = Xl ^ P[N + 1]; - - xl = Xl; - xr = Xr; - } - - /// - /// Encrypts string - /// - /// The string to encrypt - /// Encrypted string - public String encipher(String data) - { - byte[] b = Encoding.Unicode.GetBytes(data); - encipher(b, b.Length); - - return Convert.ToBase64String(b); - } - - /// - /// Decrypts a byte array in place. - /// - /// The array to decrypt. - /// The amount to decrypt. - public void decipher(byte[] data, int startIndex, int length) - { - uint xl, xr; - if ((length % 8) != 0) - throw new Exception("Invalid Length"); - - UInt64 prevBlock = 0; - for (int i = 0; i < length; i += 8) - { - // Encode the data in 8 byte blocks. - int index = startIndex + i; - xl = (uint)((data[index] << 24) | (data[index + 1] << 16) | (data[index + 2] << 8) | data[index + 3]); - xr = (uint)((data[index + 4] << 24) | (data[index + 5] << 16) | (data[index + 6] << 8) | data[index + 7]); - decipher(ref xl, ref xr); - // Now Replace the data. - data[index] = (byte)(xl >> 24); - data[index + 1] = (byte)(xl >> 16); - data[index + 2] = (byte)(xl >> 8); - data[index + 3] = (byte)(xl); - data[index + 4] = (byte)(xr >> 24); - data[index + 5] = (byte)(xr >> 16); - data[index + 6] = (byte)(xr >> 8); - data[index + 7] = (byte)(xr); - - if(prevBlock != 0) - { - UInt64 ret = BitConverter.ToUInt64(data, index) ^ prevBlock; - - data[index] = (byte)ret; - data[index + 1] = (byte)(ret >> 0x08); - data[index + 2] = (byte)(ret >> 0x10); - data[index + 3] = (byte)(ret >> 0x18); - data[index + 4] = (byte)(ret >> 0x20); - data[index + 5] = (byte)(ret >> 0x28); - data[index + 6] = (byte)(ret >> 0x30); - data[index + 7] = (byte)(ret >> 0x38); - } - - prevBlock = BitConverter.ToUInt64(data, index); - } - } - - /// - /// Decrypts 8 bytes of data (1 block) - /// - /// The left part of the 8 bytes. - /// The right part of the 8 bytes. - private void decipher(ref uint xl, ref uint xr) - { - uint Xl; - uint Xr; - uint temp; - short i; - - Xl = xl; - Xr = xr; - - for (i = N + 1; i > 1; --i) - { - Xl = Xl ^ P[i]; - Xr = f(Xl) ^ Xr; - - /* Exchange Xl and Xr */ - temp = Xl; - Xl = Xr; - Xr = temp; - } - - /* Exchange Xl and Xr */ - temp = Xl; - Xl = Xr; - Xr = temp; - - Xr = Xr ^ P[1]; - Xl = Xl ^ P[0]; - - xl = Xl; - xr = Xr; - } - - /// - /// Decrypt string - /// - /// The String to decrypt - /// Decrypted string - public String decipher(String data) - { - byte[] b = Convert.FromBase64String(data); - decipher(b, 0, b.Length); - - return Encoding.Unicode.GetString(b); - } - - public byte[] key() - { - return _key; - } - } -} +namespace KBEngine +{ + using System; + using System.IO; + using System.Text; + using System.Collections; + using System.Collections.Generic; + using System.Security.Cryptography; + + public class Blowfish + { + const int N = 16; + const int KEYBYTES = 8; + private byte[] _key = new byte[0]; + private bool _isGood = true; + + private static RNGCryptoServiceProvider rngCsp = new RNGCryptoServiceProvider(); + + // key的最小和最大大小 + private const int MIN_KEY_SIZE = 32 / 8; + private const int MAX_KEY_SIZE = 448 / 8; + + // 默认key的大小 + private const int DEFAULT_KEY_SIZE = 128 / 8; + + static uint[] _P = + { + 0x243f6a88, 0x85a308d3, 0x13198a2e, 0x03707344, 0xa4093822, 0x299f31d0, + 0x082efa98, 0xec4e6c89, 0x452821e6, 0x38d01377, 0xbe5466cf, 0x34e90c6c, + 0xc0ac29b7, 0xc97c50dd, 0x3f84d5b5, 0xb5470917, 0x9216d5d9, 0x8979fb1b + }; + static uint[,] _S = + { + { + 0xd1310ba6, 0x98dfb5ac, 0x2ffd72db, 0xd01adfb7, 0xb8e1afed, 0x6a267e96, + 0xba7c9045, 0xf12c7f99, 0x24a19947, 0xb3916cf7, 0x0801f2e2, 0x858efc16, + 0x636920d8, 0x71574e69, 0xa458fea3, 0xf4933d7e, 0x0d95748f, 0x728eb658, + 0x718bcd58, 0x82154aee, 0x7b54a41d, 0xc25a59b5, 0x9c30d539, 0x2af26013, + 0xc5d1b023, 0x286085f0, 0xca417918, 0xb8db38ef, 0x8e79dcb0, 0x603a180e, + 0x6c9e0e8b, 0xb01e8a3e, 0xd71577c1, 0xbd314b27, 0x78af2fda, 0x55605c60, + 0xe65525f3, 0xaa55ab94, 0x57489862, 0x63e81440, 0x55ca396a, 0x2aab10b6, + 0xb4cc5c34, 0x1141e8ce, 0xa15486af, 0x7c72e993, 0xb3ee1411, 0x636fbc2a, + 0x2ba9c55d, 0x741831f6, 0xce5c3e16, 0x9b87931e, 0xafd6ba33, 0x6c24cf5c, + 0x7a325381, 0x28958677, 0x3b8f4898, 0x6b4bb9af, 0xc4bfe81b, 0x66282193, + 0x61d809cc, 0xfb21a991, 0x487cac60, 0x5dec8032, 0xef845d5d, 0xe98575b1, + 0xdc262302, 0xeb651b88, 0x23893e81, 0xd396acc5, 0x0f6d6ff3, 0x83f44239, + 0x2e0b4482, 0xa4842004, 0x69c8f04a, 0x9e1f9b5e, 0x21c66842, 0xf6e96c9a, + 0x670c9c61, 0xabd388f0, 0x6a51a0d2, 0xd8542f68, 0x960fa728, 0xab5133a3, + 0x6eef0b6c, 0x137a3be4, 0xba3bf050, 0x7efb2a98, 0xa1f1651d, 0x39af0176, + 0x66ca593e, 0x82430e88, 0x8cee8619, 0x456f9fb4, 0x7d84a5c3, 0x3b8b5ebe, + 0xe06f75d8, 0x85c12073, 0x401a449f, 0x56c16aa6, 0x4ed3aa62, 0x363f7706, + 0x1bfedf72, 0x429b023d, 0x37d0d724, 0xd00a1248, 0xdb0fead3, 0x49f1c09b, + 0x075372c9, 0x80991b7b, 0x25d479d8, 0xf6e8def7, 0xe3fe501a, 0xb6794c3b, + 0x976ce0bd, 0x04c006ba, 0xc1a94fb6, 0x409f60c4, 0x5e5c9ec2, 0x196a2463, + 0x68fb6faf, 0x3e6c53b5, 0x1339b2eb, 0x3b52ec6f, 0x6dfc511f, 0x9b30952c, + 0xcc814544, 0xaf5ebd09, 0xbee3d004, 0xde334afd, 0x660f2807, 0x192e4bb3, + 0xc0cba857, 0x45c8740f, 0xd20b5f39, 0xb9d3fbdb, 0x5579c0bd, 0x1a60320a, + 0xd6a100c6, 0x402c7279, 0x679f25fe, 0xfb1fa3cc, 0x8ea5e9f8, 0xdb3222f8, + 0x3c7516df, 0xfd616b15, 0x2f501ec8, 0xad0552ab, 0x323db5fa, 0xfd238760, + 0x53317b48, 0x3e00df82, 0x9e5c57bb, 0xca6f8ca0, 0x1a87562e, 0xdf1769db, + 0xd542a8f6, 0x287effc3, 0xac6732c6, 0x8c4f5573, 0x695b27b0, 0xbbca58c8, + 0xe1ffa35d, 0xb8f011a0, 0x10fa3d98, 0xfd2183b8, 0x4afcb56c, 0x2dd1d35b, + 0x9a53e479, 0xb6f84565, 0xd28e49bc, 0x4bfb9790, 0xe1ddf2da, 0xa4cb7e33, + 0x62fb1341, 0xcee4c6e8, 0xef20cada, 0x36774c01, 0xd07e9efe, 0x2bf11fb4, + 0x95dbda4d, 0xae909198, 0xeaad8e71, 0x6b93d5a0, 0xd08ed1d0, 0xafc725e0, + 0x8e3c5b2f, 0x8e7594b7, 0x8ff6e2fb, 0xf2122b64, 0x8888b812, 0x900df01c, + 0x4fad5ea0, 0x688fc31c, 0xd1cff191, 0xb3a8c1ad, 0x2f2f2218, 0xbe0e1777, + 0xea752dfe, 0x8b021fa1, 0xe5a0cc0f, 0xb56f74e8, 0x18acf3d6, 0xce89e299, + 0xb4a84fe0, 0xfd13e0b7, 0x7cc43b81, 0xd2ada8d9, 0x165fa266, 0x80957705, + 0x93cc7314, 0x211a1477, 0xe6ad2065, 0x77b5fa86, 0xc75442f5, 0xfb9d35cf, + 0xebcdaf0c, 0x7b3e89a0, 0xd6411bd3, 0xae1e7e49, 0x00250e2d, 0x2071b35e, + 0x226800bb, 0x57b8e0af, 0x2464369b, 0xf009b91e, 0x5563911d, 0x59dfa6aa, + 0x78c14389, 0xd95a537f, 0x207d5ba2, 0x02e5b9c5, 0x83260376, 0x6295cfa9, + 0x11c81968, 0x4e734a41, 0xb3472dca, 0x7b14a94a, 0x1b510052, 0x9a532915, + 0xd60f573f, 0xbc9bc6e4, 0x2b60a476, 0x81e67400, 0x08ba6fb5, 0x571be91f, + 0xf296ec6b, 0x2a0dd915, 0xb6636521, 0xe7b9f9b6, 0xff34052e, 0xc5855664, + 0x53b02d5d, 0xa99f8fa1, 0x08ba4799, 0x6e85076a + }, + { + 0x4b7a70e9, 0xb5b32944, 0xdb75092e, 0xc4192623, 0xad6ea6b0, 0x49a7df7d, + 0x9cee60b8, 0x8fedb266, 0xecaa8c71, 0x699a17ff, 0x5664526c, 0xc2b19ee1, + 0x193602a5, 0x75094c29, 0xa0591340, 0xe4183a3e, 0x3f54989a, 0x5b429d65, + 0x6b8fe4d6, 0x99f73fd6, 0xa1d29c07, 0xefe830f5, 0x4d2d38e6, 0xf0255dc1, + 0x4cdd2086, 0x8470eb26, 0x6382e9c6, 0x021ecc5e, 0x09686b3f, 0x3ebaefc9, + 0x3c971814, 0x6b6a70a1, 0x687f3584, 0x52a0e286, 0xb79c5305, 0xaa500737, + 0x3e07841c, 0x7fdeae5c, 0x8e7d44ec, 0x5716f2b8, 0xb03ada37, 0xf0500c0d, + 0xf01c1f04, 0x0200b3ff, 0xae0cf51a, 0x3cb574b2, 0x25837a58, 0xdc0921bd, + 0xd19113f9, 0x7ca92ff6, 0x94324773, 0x22f54701, 0x3ae5e581, 0x37c2dadc, + 0xc8b57634, 0x9af3dda7, 0xa9446146, 0x0fd0030e, 0xecc8c73e, 0xa4751e41, + 0xe238cd99, 0x3bea0e2f, 0x3280bba1, 0x183eb331, 0x4e548b38, 0x4f6db908, + 0x6f420d03, 0xf60a04bf, 0x2cb81290, 0x24977c79, 0x5679b072, 0xbcaf89af, + 0xde9a771f, 0xd9930810, 0xb38bae12, 0xdccf3f2e, 0x5512721f, 0x2e6b7124, + 0x501adde6, 0x9f84cd87, 0x7a584718, 0x7408da17, 0xbc9f9abc, 0xe94b7d8c, + 0xec7aec3a, 0xdb851dfa, 0x63094366, 0xc464c3d2, 0xef1c1847, 0x3215d908, + 0xdd433b37, 0x24c2ba16, 0x12a14d43, 0x2a65c451, 0x50940002, 0x133ae4dd, + 0x71dff89e, 0x10314e55, 0x81ac77d6, 0x5f11199b, 0x043556f1, 0xd7a3c76b, + 0x3c11183b, 0x5924a509, 0xf28fe6ed, 0x97f1fbfa, 0x9ebabf2c, 0x1e153c6e, + 0x86e34570, 0xeae96fb1, 0x860e5e0a, 0x5a3e2ab3, 0x771fe71c, 0x4e3d06fa, + 0x2965dcb9, 0x99e71d0f, 0x803e89d6, 0x5266c825, 0x2e4cc978, 0x9c10b36a, + 0xc6150eba, 0x94e2ea78, 0xa5fc3c53, 0x1e0a2df4, 0xf2f74ea7, 0x361d2b3d, + 0x1939260f, 0x19c27960, 0x5223a708, 0xf71312b6, 0xebadfe6e, 0xeac31f66, + 0xe3bc4595, 0xa67bc883, 0xb17f37d1, 0x018cff28, 0xc332ddef, 0xbe6c5aa5, + 0x65582185, 0x68ab9802, 0xeecea50f, 0xdb2f953b, 0x2aef7dad, 0x5b6e2f84, + 0x1521b628, 0x29076170, 0xecdd4775, 0x619f1510, 0x13cca830, 0xeb61bd96, + 0x0334fe1e, 0xaa0363cf, 0xb5735c90, 0x4c70a239, 0xd59e9e0b, 0xcbaade14, + 0xeecc86bc, 0x60622ca7, 0x9cab5cab, 0xb2f3846e, 0x648b1eaf, 0x19bdf0ca, + 0xa02369b9, 0x655abb50, 0x40685a32, 0x3c2ab4b3, 0x319ee9d5, 0xc021b8f7, + 0x9b540b19, 0x875fa099, 0x95f7997e, 0x623d7da8, 0xf837889a, 0x97e32d77, + 0x11ed935f, 0x16681281, 0x0e358829, 0xc7e61fd6, 0x96dedfa1, 0x7858ba99, + 0x57f584a5, 0x1b227263, 0x9b83c3ff, 0x1ac24696, 0xcdb30aeb, 0x532e3054, + 0x8fd948e4, 0x6dbc3128, 0x58ebf2ef, 0x34c6ffea, 0xfe28ed61, 0xee7c3c73, + 0x5d4a14d9, 0xe864b7e3, 0x42105d14, 0x203e13e0, 0x45eee2b6, 0xa3aaabea, + 0xdb6c4f15, 0xfacb4fd0, 0xc742f442, 0xef6abbb5, 0x654f3b1d, 0x41cd2105, + 0xd81e799e, 0x86854dc7, 0xe44b476a, 0x3d816250, 0xcf62a1f2, 0x5b8d2646, + 0xfc8883a0, 0xc1c7b6a3, 0x7f1524c3, 0x69cb7492, 0x47848a0b, 0x5692b285, + 0x095bbf00, 0xad19489d, 0x1462b174, 0x23820e00, 0x58428d2a, 0x0c55f5ea, + 0x1dadf43e, 0x233f7061, 0x3372f092, 0x8d937e41, 0xd65fecf1, 0x6c223bdb, + 0x7cde3759, 0xcbee7460, 0x4085f2a7, 0xce77326e, 0xa6078084, 0x19f8509e, + 0xe8efd855, 0x61d99735, 0xa969a7aa, 0xc50c06c2, 0x5a04abfc, 0x800bcadc, + 0x9e447a2e, 0xc3453484, 0xfdd56705, 0x0e1e9ec9, 0xdb73dbd3, 0x105588cd, + 0x675fda79, 0xe3674340, 0xc5c43465, 0x713e38d8, 0x3d28f89e, 0xf16dff20, + 0x153e21e7, 0x8fb03d4a, 0xe6e39f2b, 0xdb83adf7 + }, + { + 0xe93d5a68, 0x948140f7, 0xf64c261c, 0x94692934, 0x411520f7, 0x7602d4f7, + 0xbcf46b2e, 0xd4a20068, 0xd4082471, 0x3320f46a, 0x43b7d4b7, 0x500061af, + 0x1e39f62e, 0x97244546, 0x14214f74, 0xbf8b8840, 0x4d95fc1d, 0x96b591af, + 0x70f4ddd3, 0x66a02f45, 0xbfbc09ec, 0x03bd9785, 0x7fac6dd0, 0x31cb8504, + 0x96eb27b3, 0x55fd3941, 0xda2547e6, 0xabca0a9a, 0x28507825, 0x530429f4, + 0x0a2c86da, 0xe9b66dfb, 0x68dc1462, 0xd7486900, 0x680ec0a4, 0x27a18dee, + 0x4f3ffea2, 0xe887ad8c, 0xb58ce006, 0x7af4d6b6, 0xaace1e7c, 0xd3375fec, + 0xce78a399, 0x406b2a42, 0x20fe9e35, 0xd9f385b9, 0xee39d7ab, 0x3b124e8b, + 0x1dc9faf7, 0x4b6d1856, 0x26a36631, 0xeae397b2, 0x3a6efa74, 0xdd5b4332, + 0x6841e7f7, 0xca7820fb, 0xfb0af54e, 0xd8feb397, 0x454056ac, 0xba489527, + 0x55533a3a, 0x20838d87, 0xfe6ba9b7, 0xd096954b, 0x55a867bc, 0xa1159a58, + 0xcca92963, 0x99e1db33, 0xa62a4a56, 0x3f3125f9, 0x5ef47e1c, 0x9029317c, + 0xfdf8e802, 0x04272f70, 0x80bb155c, 0x05282ce3, 0x95c11548, 0xe4c66d22, + 0x48c1133f, 0xc70f86dc, 0x07f9c9ee, 0x41041f0f, 0x404779a4, 0x5d886e17, + 0x325f51eb, 0xd59bc0d1, 0xf2bcc18f, 0x41113564, 0x257b7834, 0x602a9c60, + 0xdff8e8a3, 0x1f636c1b, 0x0e12b4c2, 0x02e1329e, 0xaf664fd1, 0xcad18115, + 0x6b2395e0, 0x333e92e1, 0x3b240b62, 0xeebeb922, 0x85b2a20e, 0xe6ba0d99, + 0xde720c8c, 0x2da2f728, 0xd0127845, 0x95b794fd, 0x647d0862, 0xe7ccf5f0, + 0x5449a36f, 0x877d48fa, 0xc39dfd27, 0xf33e8d1e, 0x0a476341, 0x992eff74, + 0x3a6f6eab, 0xf4f8fd37, 0xa812dc60, 0xa1ebddf8, 0x991be14c, 0xdb6e6b0d, + 0xc67b5510, 0x6d672c37, 0x2765d43b, 0xdcd0e804, 0xf1290dc7, 0xcc00ffa3, + 0xb5390f92, 0x690fed0b, 0x667b9ffb, 0xcedb7d9c, 0xa091cf0b, 0xd9155ea3, + 0xbb132f88, 0x515bad24, 0x7b9479bf, 0x763bd6eb, 0x37392eb3, 0xcc115979, + 0x8026e297, 0xf42e312d, 0x6842ada7, 0xc66a2b3b, 0x12754ccc, 0x782ef11c, + 0x6a124237, 0xb79251e7, 0x06a1bbe6, 0x4bfb6350, 0x1a6b1018, 0x11caedfa, + 0x3d25bdd8, 0xe2e1c3c9, 0x44421659, 0x0a121386, 0xd90cec6e, 0xd5abea2a, + 0x64af674e, 0xda86a85f, 0xbebfe988, 0x64e4c3fe, 0x9dbc8057, 0xf0f7c086, + 0x60787bf8, 0x6003604d, 0xd1fd8346, 0xf6381fb0, 0x7745ae04, 0xd736fccc, + 0x83426b33, 0xf01eab71, 0xb0804187, 0x3c005e5f, 0x77a057be, 0xbde8ae24, + 0x55464299, 0xbf582e61, 0x4e58f48f, 0xf2ddfda2, 0xf474ef38, 0x8789bdc2, + 0x5366f9c3, 0xc8b38e74, 0xb475f255, 0x46fcd9b9, 0x7aeb2661, 0x8b1ddf84, + 0x846a0e79, 0x915f95e2, 0x466e598e, 0x20b45770, 0x8cd55591, 0xc902de4c, + 0xb90bace1, 0xbb8205d0, 0x11a86248, 0x7574a99e, 0xb77f19b6, 0xe0a9dc09, + 0x662d09a1, 0xc4324633, 0xe85a1f02, 0x09f0be8c, 0x4a99a025, 0x1d6efe10, + 0x1ab93d1d, 0x0ba5a4df, 0xa186f20f, 0x2868f169, 0xdcb7da83, 0x573906fe, + 0xa1e2ce9b, 0x4fcd7f52, 0x50115e01, 0xa70683fa, 0xa002b5c4, 0x0de6d027, + 0x9af88c27, 0x773f8641, 0xc3604c06, 0x61a806b5, 0xf0177a28, 0xc0f586e0, + 0x006058aa, 0x30dc7d62, 0x11e69ed7, 0x2338ea63, 0x53c2dd94, 0xc2c21634, + 0xbbcbee56, 0x90bcb6de, 0xebfc7da1, 0xce591d76, 0x6f05e409, 0x4b7c0188, + 0x39720a3d, 0x7c927c24, 0x86e3725f, 0x724d9db9, 0x1ac15bb4, 0xd39eb8fc, + 0xed545578, 0x08fca5b5, 0xd83d7cd3, 0x4dad0fc4, 0x1e50ef5e, 0xb161e6f8, + 0xa28514d9, 0x6c51133c, 0x6fd5c7e7, 0x56e14ec4, 0x362abfce, 0xddc6c837, + 0xd79a3234, 0x92638212, 0x670efa8e, 0x406000e0 + }, + { + 0x3a39ce37, 0xd3faf5cf, 0xabc27737, 0x5ac52d1b, 0x5cb0679e, 0x4fa33742, + 0xd3822740, 0x99bc9bbe, 0xd5118e9d, 0xbf0f7315, 0xd62d1c7e, 0xc700c47b, + 0xb78c1b6b, 0x21a19045, 0xb26eb1be, 0x6a366eb4, 0x5748ab2f, 0xbc946e79, + 0xc6a376d2, 0x6549c2c8, 0x530ff8ee, 0x468dde7d, 0xd5730a1d, 0x4cd04dc6, + 0x2939bbdb, 0xa9ba4650, 0xac9526e8, 0xbe5ee304, 0xa1fad5f0, 0x6a2d519a, + 0x63ef8ce2, 0x9a86ee22, 0xc089c2b8, 0x43242ef6, 0xa51e03aa, 0x9cf2d0a4, + 0x83c061ba, 0x9be96a4d, 0x8fe51550, 0xba645bd6, 0x2826a2f9, 0xa73a3ae1, + 0x4ba99586, 0xef5562e9, 0xc72fefd3, 0xf752f7da, 0x3f046f69, 0x77fa0a59, + 0x80e4a915, 0x87b08601, 0x9b09e6ad, 0x3b3ee593, 0xe990fd5a, 0x9e34d797, + 0x2cf0b7d9, 0x022b8b51, 0x96d5ac3a, 0x017da67d, 0xd1cf3ed6, 0x7c7d2d28, + 0x1f9f25cf, 0xadf2b89b, 0x5ad6b472, 0x5a88f54c, 0xe029ac71, 0xe019a5e6, + 0x47b0acfd, 0xed93fa9b, 0xe8d3c48d, 0x283b57cc, 0xf8d56629, 0x79132e28, + 0x785f0191, 0xed756055, 0xf7960e44, 0xe3d35e8c, 0x15056dd4, 0x88f46dba, + 0x03a16125, 0x0564f0bd, 0xc3eb9e15, 0x3c9057a2, 0x97271aec, 0xa93a072a, + 0x1b3f6d9b, 0x1e6321f5, 0xf59c66fb, 0x26dcf319, 0x7533d928, 0xb155fdf5, + 0x03563482, 0x8aba3cbb, 0x28517711, 0xc20ad9f8, 0xabcc5167, 0xccad925f, + 0x4de81751, 0x3830dc8e, 0x379d5862, 0x9320f991, 0xea7a90c2, 0xfb3e7bce, + 0x5121ce64, 0x774fbe32, 0xa8b6e37e, 0xc3293d46, 0x48de5369, 0x6413e680, + 0xa2ae0810, 0xdd6db224, 0x69852dfd, 0x09072166, 0xb39a460a, 0x6445c0dd, + 0x586cdecf, 0x1c20c8ae, 0x5bbef7dd, 0x1b588d40, 0xccd2017f, 0x6bb4e3bb, + 0xdda26a7e, 0x3a59ff45, 0x3e350a44, 0xbcb4cdd5, 0x72eacea8, 0xfa6484bb, + 0x8d6612ae, 0xbf3c6f47, 0xd29be463, 0x542f5d9e, 0xaec2771b, 0xf64e6370, + 0x740e0d8d, 0xe75b1357, 0xf8721671, 0xaf537d5d, 0x4040cb08, 0x4eb4e2cc, + 0x34d2466a, 0x0115af84, 0xe1b00428, 0x95983a1d, 0x06b89fb4, 0xce6ea048, + 0x6f3f3b82, 0x3520ab82, 0x011a1d4b, 0x277227f8, 0x611560b1, 0xe7933fdc, + 0xbb3a792b, 0x344525bd, 0xa08839e1, 0x51ce794b, 0x2f32c9b7, 0xa01fbac9, + 0xe01cc87e, 0xbcc7d1f6, 0xcf0111c3, 0xa1e8aac7, 0x1a908749, 0xd44fbd9a, + 0xd0dadecb, 0xd50ada38, 0x0339c32a, 0xc6913667, 0x8df9317c, 0xe0b12b4f, + 0xf79e59b7, 0x43f5bb3a, 0xf2d519ff, 0x27d9459c, 0xbf97222c, 0x15e6fc2a, + 0x0f91fc71, 0x9b941525, 0xfae59361, 0xceb69ceb, 0xc2a86459, 0x12baa8d1, + 0xb6c1075e, 0xe3056a0c, 0x10d25065, 0xcb03a442, 0xe0ec6e0e, 0x1698db3b, + 0x4c98a0be, 0x3278e964, 0x9f1f9532, 0xe0d392df, 0xd3a0342b, 0x8971f21e, + 0x1b0a7441, 0x4ba3348c, 0xc5be7120, 0xc37632d8, 0xdf359f8d, 0x9b992f2e, + 0xe60b6f47, 0x0fe3f11d, 0xe54cda54, 0x1edad891, 0xce6279cf, 0xcd3e7e6f, + 0x1618b166, 0xfd2c1d05, 0x848fd2c5, 0xf6fb2299, 0xf523f357, 0xa6327623, + 0x93a83531, 0x56cccd02, 0xacf08162, 0x5a75ebb5, 0x6e163697, 0x88d273cc, + 0xde966292, 0x81b949d0, 0x4c50901b, 0x71c65614, 0xe6c6c7bd, 0x327a140a, + 0x45e1d006, 0xc3f27b9a, 0xc9aa53fd, 0x62a80f00, 0xbb25bfe2, 0x35bdd2f6, + 0x71126905, 0xb2040222, 0xb6cbcf7c, 0xcd769c2b, 0x53113ec0, 0x1640e3d3, + 0x38abbd60, 0x2547adf0, 0xba38209c, 0xf746ce76, 0x77afa1c5, 0x20756060, + 0x85cbfe4e, 0x8ae88dd8, 0x7aaaf9b0, 0x4cf9aa7e, 0x1948c25c, 0x02fb8a8c, + 0x01c36ae4, 0xd6ebe1f9, 0x90d4f869, 0xa65cdea0, 0x3f09252d, 0xc208e69f, + 0xb74e6132, 0xce77e25b, 0x578fdfe3, 0x3ac372e6 + } + }; + + uint[] P; + uint[,] S; + + public Blowfish(byte[] key) + { + _key = key; + init(); + } + + public Blowfish(string key) : this(Encoding.Unicode.GetBytes(key)) + { + + } + + public Blowfish(int keySize = DEFAULT_KEY_SIZE) + { + _key = new byte[keySize]; + rngCsp.GetBytes(_key); + init(); + } + + ~Blowfish() + { + } + + public bool isGood() + { + return _isGood; + } + + private void init() + { + if(_key.Length < MIN_KEY_SIZE || _key.Length > MAX_KEY_SIZE) + { + _isGood = false; + Dbg.ERROR_MSG("Blowfish::init: invalid length " + _key.Length); + return; + } + + short i; + short j; + short k; + uint data; + uint datal; + uint datar; + + P = _P.Clone() as uint[]; + S = _S.Clone() as uint[,]; + + j = 0; + for (i = 0; i < N + 2; ++i) + { + data = 0x00000000; + for (k = 0; k < 4; ++k) + { + data = (data << 8) | _key[j]; + j++; + if (j >= _key.Length) + { + j = 0; + } + } + P[i] = P[i] ^ data; + } + + datal = 0x00000000; + datar = 0x00000000; + + for (i = 0; i < N + 2; i += 2) + { + encipher(ref datal, ref datar); + P[i] = datal; + P[i + 1] = datar; + } + + for (i = 0; i < 4; ++i) + { + for (j = 0; j < 256; j += 2) + { + encipher(ref datal, ref datar); + + S[i, j] = datal; + S[i, j + 1] = datar; + } + } + + _isGood = true; + } + + private uint f(uint x) + { + ushort a; + ushort b; + ushort c; + ushort d; + uint y; + + d = (ushort)(x & 0x00FF); + x >>= 8; + c = (ushort)(x & 0x00FF); + x >>= 8; + b = (ushort)(x & 0x00FF); + x >>= 8; + a = (ushort)(x & 0x00FF); + //y = ((S[0][a] + S[1][b]) ^ S[2][c]) + S[3][d]; + y = S[0, a] + S[1, b]; + y = y ^ S[2, c]; + y = y + S[3, d]; + + return y; + } + + /// + /// Encrypts a byte array in place. + /// + /// The array to encrypt. + /// The amount to encrypt. + public void encipher(byte[] data, int length) + { + if ((length % 8) != 0) + throw new Exception("Invalid Length"); + + uint xl, xr; + UInt64 prevBlock = 0; + + for (int i = 0; i < length; i += 8) + { + if (prevBlock != 0) + { + UInt64 oldValue = BitConverter.ToUInt64(data, i); + UInt64 ret = oldValue ^ prevBlock; + prevBlock = oldValue; + + data[i] = (byte)ret; + data[i + 1] = (byte)(ret >> 0x8); + data[i + 2] = (byte)(ret >> 0x10); + data[i + 3] = (byte)(ret >> 0x18); + data[i + 4] = (byte)(ret >> 0x20); + data[i + 5] = (byte)(ret >> 0x28); + data[i + 6] = (byte)(ret >> 0x30); + data[i + 7] = (byte)(ret >> 0x38); + } + else + { + prevBlock = BitConverter.ToUInt64(data, i); + } + + // Encode the data in 8 byte blocks. + xl = (uint)((data[i] << 24) | (data[i + 1] << 16) | (data[i + 2] << 8) | data[i + 3]); + xr = (uint)((data[i + 4] << 24) | (data[i + 5] << 16) | (data[i + 6] << 8) | data[i + 7]); + encipher(ref xl, ref xr); + // Now Replace the data. + data[i] = (byte)(xl >> 24); + data[i + 1] = (byte)(xl >> 16); + data[i + 2] = (byte)(xl >> 8); + data[i + 3] = (byte)(xl); + data[i + 4] = (byte)(xr >> 24); + data[i + 5] = (byte)(xr >> 16); + data[i + 6] = (byte)(xr >> 8); + data[i + 7] = (byte)(xr); + } + } + + /// + /// Encrypts 8 bytes of data (1 block) + /// + /// The left part of the 8 bytes. + /// The right part of the 8 bytes. + private void encipher(ref uint xl, ref uint xr) + { + uint Xl; + uint Xr; + uint temp; + short i; + + Xl = xl; + Xr = xr; + + for (i = 0; i < N; ++i) + { + Xl = Xl ^ P[i]; + Xr = f(Xl) ^ Xr; + + temp = Xl; + Xl = Xr; + Xr = temp; + } + + temp = Xl; + Xl = Xr; + Xr = temp; + + Xr = Xr ^ P[N]; + Xl = Xl ^ P[N + 1]; + + xl = Xl; + xr = Xr; + } + + /// + /// Encrypts string + /// + /// The string to encrypt + /// Encrypted string + public String encipher(String data) + { + byte[] b = Encoding.Unicode.GetBytes(data); + encipher(b, b.Length); + + return Convert.ToBase64String(b); + } + + /// + /// Decrypts a byte array in place. + /// + /// The array to decrypt. + /// The amount to decrypt. + public void decipher(byte[] data, int startIndex, int length) + { + uint xl, xr; + if ((length % 8) != 0) + throw new Exception("Invalid Length"); + + UInt64 prevBlock = 0; + for (int i = 0; i < length; i += 8) + { + // Encode the data in 8 byte blocks. + int index = startIndex + i; + xl = (uint)((data[index] << 24) | (data[index + 1] << 16) | (data[index + 2] << 8) | data[index + 3]); + xr = (uint)((data[index + 4] << 24) | (data[index + 5] << 16) | (data[index + 6] << 8) | data[index + 7]); + decipher(ref xl, ref xr); + // Now Replace the data. + data[index] = (byte)(xl >> 24); + data[index + 1] = (byte)(xl >> 16); + data[index + 2] = (byte)(xl >> 8); + data[index + 3] = (byte)(xl); + data[index + 4] = (byte)(xr >> 24); + data[index + 5] = (byte)(xr >> 16); + data[index + 6] = (byte)(xr >> 8); + data[index + 7] = (byte)(xr); + + if(prevBlock != 0) + { + UInt64 ret = BitConverter.ToUInt64(data, index) ^ prevBlock; + + data[index] = (byte)ret; + data[index + 1] = (byte)(ret >> 0x08); + data[index + 2] = (byte)(ret >> 0x10); + data[index + 3] = (byte)(ret >> 0x18); + data[index + 4] = (byte)(ret >> 0x20); + data[index + 5] = (byte)(ret >> 0x28); + data[index + 6] = (byte)(ret >> 0x30); + data[index + 7] = (byte)(ret >> 0x38); + } + + prevBlock = BitConverter.ToUInt64(data, index); + } + } + + /// + /// Decrypts 8 bytes of data (1 block) + /// + /// The left part of the 8 bytes. + /// The right part of the 8 bytes. + private void decipher(ref uint xl, ref uint xr) + { + uint Xl; + uint Xr; + uint temp; + short i; + + Xl = xl; + Xr = xr; + + for (i = N + 1; i > 1; --i) + { + Xl = Xl ^ P[i]; + Xr = f(Xl) ^ Xr; + + /* Exchange Xl and Xr */ + temp = Xl; + Xl = Xr; + Xr = temp; + } + + /* Exchange Xl and Xr */ + temp = Xl; + Xl = Xr; + Xr = temp; + + Xr = Xr ^ P[1]; + Xl = Xl ^ P[0]; + + xl = Xl; + xr = Xr; + } + + /// + /// Decrypt string + /// + /// The String to decrypt + /// Decrypted string + public String decipher(String data) + { + byte[] b = Convert.FromBase64String(data); + decipher(b, 0, b.Length); + + return Encoding.Unicode.GetString(b); + } + + public byte[] key() + { + return _key; + } + } +} diff --git a/Assets/Plugins/kbengine_unity3d_plugins/Bundle.cs b/Assets/Plugins/kbengine_unity3d_plugins/Bundle.cs index 711e88c..3d1adba 100644 --- a/Assets/Plugins/kbengine_unity3d_plugins/Bundle.cs +++ b/Assets/Plugins/kbengine_unity3d_plugins/Bundle.cs @@ -1,261 +1,261 @@ -namespace KBEngine -{ - using UnityEngine; - using System; - using System.Collections; - using System.Collections.Generic; - - /* - 这个模块将多个数据包打捆在一起 - 由于每个数据包都有最大上限, 向Bundle中写入大量数据将会在内部产生多个MemoryStream - 在send时会全部发送出去 - */ - public class Bundle : ObjectPool - { - public MemoryStream stream = new MemoryStream(); - public List streamList = new List(); - public int numMessage = 0; - public int messageLength = 0; - public Message msgtype = null; - private int _curMsgStreamIndex = 0; - - public Bundle() - { - } - - public void clear() - { - // 把不用的MemoryStream放回缓冲池,以减少垃圾回收的消耗 - for (int i = 0; i < streamList.Count; ++i) - { - if (stream != streamList[i]) - streamList[i].reclaimObject(); - } - - streamList.Clear(); - - if(stream != null) - stream.clear(); - else - stream = MemoryStream.createObject(); - - numMessage = 0; - messageLength = 0; - msgtype = null; - _curMsgStreamIndex = 0; - } - - /// - /// 把自己放回缓冲池 - /// - public void reclaimObject() - { - clear(); - reclaimObject(this); - } - - public void newMessage(Message mt) - { - fini(false); - - msgtype = mt; - numMessage += 1; - - writeUint16(msgtype.id); - - if(msgtype.msglen == -1) - { - writeUint16(0); - messageLength = 0; - } - - _curMsgStreamIndex = 0; - } - - public void writeMsgLength() - { - if(msgtype.msglen != -1) - return; - - MemoryStream stream = this.stream; - if(_curMsgStreamIndex > 0) - { - stream = streamList[streamList.Count - _curMsgStreamIndex]; - } - stream.data()[2] = (Byte)(messageLength & 0xff); - stream.data()[3] = (Byte)(messageLength >> 8 & 0xff); - } - - public void fini(bool issend) - { - if(numMessage > 0) - { - writeMsgLength(); - - streamList.Add(stream); - stream = MemoryStream.createObject(); - } - - if(issend) - { - numMessage = 0; - msgtype = null; - } - - _curMsgStreamIndex = 0; - } - - public void send(NetworkInterfaceBase networkInterface) - { - fini(true); - - if(networkInterface.valid()) - { - for(int i=0; i stream.space()) - { - streamList.Add(stream); - stream = MemoryStream.createObject(); - ++ _curMsgStreamIndex; - } - - messageLength += v; - } - - //--------------------------------------------------------------------------------- - public void writeInt8(SByte v) - { - checkStream(1); - stream.writeInt8(v); - } - - public void writeInt16(Int16 v) - { - checkStream(2); - stream.writeInt16(v); - } - - public void writeInt32(Int32 v) - { - checkStream(4); - stream.writeInt32(v); - } - - public void writeInt64(Int64 v) - { - checkStream(8); - stream.writeInt64(v); - } - - public void writeUint8(Byte v) - { - checkStream(1); - stream.writeUint8(v); - } - - public void writeUint16(UInt16 v) - { - checkStream(2); - stream.writeUint16(v); - } - - public void writeUint32(UInt32 v) - { - checkStream(4); - stream.writeUint32(v); - } - - public void writeUint64(UInt64 v) - { - checkStream(8); - stream.writeUint64(v); - } - - public void writeFloat(float v) - { - checkStream(4); - stream.writeFloat(v); - } - - public void writeDouble(double v) - { - checkStream(8); - stream.writeDouble(v); - } - - public void writeString(string v) - { - checkStream(v.Length + 1); - stream.writeString(v); - } - - public void writeUnicode(string v) - { - writeBlob(System.Text.Encoding.UTF8.GetBytes((string)v)); - } - - public void writeBlob(byte[] v) - { - checkStream(v.Length + 4); - stream.writeBlob(v); - } - - public void writePython(byte[] v) - { - writeBlob(v); - } - - public void writeVector2(Vector2 v) - { - checkStream(8); - stream.writeVector2(v); - } - - public void writeVector3(Vector3 v) - { - checkStream(12); - stream.writeVector3(v); - } - - public void writeVector4(Vector4 v) - { - checkStream(16); - stream.writeVector4(v); - } - - public void writeEntitycall(byte[] v) - { - checkStream(16); - - UInt64 cid = 0; - Int32 id = 0; - UInt16 type = 0; - UInt16 utype = 0; - - stream.writeUint64(cid); - stream.writeInt32(id); - stream.writeUint16(type); - stream.writeUint16(utype); - } - } -} +namespace KBEngine +{ + using UnityEngine; + using System; + using System.Collections; + using System.Collections.Generic; + + /* + 这个模块将多个数据包打捆在一起 + 由于每个数据包都有最大上限, 向Bundle中写入大量数据将会在内部产生多个MemoryStream + 在send时会全部发送出去 + */ + public class Bundle : ObjectPool + { + public MemoryStream stream = new MemoryStream(); + public List streamList = new List(); + public int numMessage = 0; + public int messageLength = 0; + public Message msgtype = null; + private int _curMsgStreamIndex = 0; + + public Bundle() + { + } + + public void clear() + { + // 把不用的MemoryStream放回缓冲池,以减少垃圾回收的消耗 + for (int i = 0; i < streamList.Count; ++i) + { + if (stream != streamList[i]) + streamList[i].reclaimObject(); + } + + streamList.Clear(); + + if(stream != null) + stream.clear(); + else + stream = MemoryStream.createObject(); + + numMessage = 0; + messageLength = 0; + msgtype = null; + _curMsgStreamIndex = 0; + } + + /// + /// 把自己放回缓冲池 + /// + public void reclaimObject() + { + clear(); + reclaimObject(this); + } + + public void newMessage(Message mt) + { + fini(false); + + msgtype = mt; + numMessage += 1; + + writeUint16(msgtype.id); + + if(msgtype.msglen == -1) + { + writeUint16(0); + messageLength = 0; + } + + _curMsgStreamIndex = 0; + } + + public void writeMsgLength() + { + if(msgtype.msglen != -1) + return; + + MemoryStream stream = this.stream; + if(_curMsgStreamIndex > 0) + { + stream = streamList[streamList.Count - _curMsgStreamIndex]; + } + stream.data()[2] = (Byte)(messageLength & 0xff); + stream.data()[3] = (Byte)(messageLength >> 8 & 0xff); + } + + public void fini(bool issend) + { + if(numMessage > 0) + { + writeMsgLength(); + + streamList.Add(stream); + stream = MemoryStream.createObject(); + } + + if(issend) + { + numMessage = 0; + msgtype = null; + } + + _curMsgStreamIndex = 0; + } + + public void send(NetworkInterfaceBase networkInterface) + { + fini(true); + + if(networkInterface.valid()) + { + for(int i=0; i stream.space()) + { + streamList.Add(stream); + stream = MemoryStream.createObject(); + ++ _curMsgStreamIndex; + } + + messageLength += v; + } + + //--------------------------------------------------------------------------------- + public void writeInt8(SByte v) + { + checkStream(1); + stream.writeInt8(v); + } + + public void writeInt16(Int16 v) + { + checkStream(2); + stream.writeInt16(v); + } + + public void writeInt32(Int32 v) + { + checkStream(4); + stream.writeInt32(v); + } + + public void writeInt64(Int64 v) + { + checkStream(8); + stream.writeInt64(v); + } + + public void writeUint8(Byte v) + { + checkStream(1); + stream.writeUint8(v); + } + + public void writeUint16(UInt16 v) + { + checkStream(2); + stream.writeUint16(v); + } + + public void writeUint32(UInt32 v) + { + checkStream(4); + stream.writeUint32(v); + } + + public void writeUint64(UInt64 v) + { + checkStream(8); + stream.writeUint64(v); + } + + public void writeFloat(float v) + { + checkStream(4); + stream.writeFloat(v); + } + + public void writeDouble(double v) + { + checkStream(8); + stream.writeDouble(v); + } + + public void writeString(string v) + { + checkStream(v.Length + 1); + stream.writeString(v); + } + + public void writeUnicode(string v) + { + writeBlob(System.Text.Encoding.UTF8.GetBytes((string)v)); + } + + public void writeBlob(byte[] v) + { + checkStream(v.Length + 4); + stream.writeBlob(v); + } + + public void writePython(byte[] v) + { + writeBlob(v); + } + + public void writeVector2(Vector2 v) + { + checkStream(8); + stream.writeVector2(v); + } + + public void writeVector3(Vector3 v) + { + checkStream(12); + stream.writeVector3(v); + } + + public void writeVector4(Vector4 v) + { + checkStream(16); + stream.writeVector4(v); + } + + public void writeEntitycall(byte[] v) + { + checkStream(16); + + UInt64 cid = 0; + Int32 id = 0; + UInt16 type = 0; + UInt16 utype = 0; + + stream.writeUint64(cid); + stream.writeInt32(id); + stream.writeUint16(type); + stream.writeUint16(utype); + } + } +} diff --git a/Assets/Plugins/kbengine_unity3d_plugins/ClientSDKUpdater.cs b/Assets/Plugins/kbengine_unity3d_plugins/ClientSDKUpdater.cs index c96e3b7..acfa954 100644 --- a/Assets/Plugins/kbengine_unity3d_plugins/ClientSDKUpdater.cs +++ b/Assets/Plugins/kbengine_unity3d_plugins/ClientSDKUpdater.cs @@ -1,158 +1,158 @@ -namespace KBEngine -{ -#if UNITY_EDITOR - using UnityEngine; - using UnityEditor; - using System.Collections; - using System; - using System.IO; - using KBEngine; - - public class ClientSDKUpdater : MonoBehaviour - { - string warnUpdateSDK = ""; - MemoryStream sdkFileStream = null; - int downloadFiles = 0; - string sdkPath = ""; - string sdkTempPath = ""; - string sdkBakPath = ""; - - void Start() - { - string kbengineCoreFile = "KBEngine.cs"; - string[] res = System.IO.Directory.GetFiles(Application.dataPath, kbengineCoreFile, SearchOption.AllDirectories); - sdkPath = res[0].Replace(kbengineCoreFile, "").Replace("\\", "/"); - sdkPath = sdkPath.Remove(sdkPath.Length - 1, 1); - - sdkTempPath = sdkPath + "_temp"; - sdkBakPath = sdkPath + "_bak"; - - warnUpdateSDK = "Version does not match the server.\nClick to update KBEnginePlugin!\nPull from: " + KBEngineApp.app.getInitArgs().ip + ":" + KBEngineApp.app.getInitArgs().port; - installEvents(); - - GameObject[] objs = FindObjectsOfType(typeof(GameObject)) as GameObject[]; - foreach (GameObject child in objs) - { - if (!child.gameObject.GetComponent() && - !child.gameObject.GetComponent() && - !child.gameObject.GetComponent()) - { - child.gameObject.SetActive(false); - } - } - } - - public virtual void installEvents() - { - Event.registerIn("onImportClientSDK", this, "onImportClientSDK"); - } - - protected virtual void OnDestroy() - { - KBEngine.Event.deregisterOut(this); - } - - public void onImportClientSDK(int remainingFiles, string fileName, int fileSize, byte[] fileDatas) - { - if (sdkFileStream == null) - sdkFileStream = MemoryStream.createObject(); - - sdkFileStream.append(fileDatas, (uint)sdkFileStream.rpos, (uint)fileDatas.Length); - - warnUpdateSDK = "Download:" + fileName + " -> " + sdkFileStream.length() + "/" + fileSize + "bytes! " + (int)(((float)downloadFiles / (float)(downloadFiles + remainingFiles)) * 100) + "%"; - Debug.Log(warnUpdateSDK); - - if (sdkFileStream.length() == fileSize) - { - Debug.Log("onImportClientSDK: " + fileName + "->" + fileSize + "bytes success!"); - - string path = Path.GetDirectoryName(sdkTempPath + "//" + fileName); - if (!Directory.Exists(path)) - Directory.CreateDirectory(path); - - StreamWriter sw; - FileInfo t = new FileInfo(sdkTempPath + "//" + fileName); - string data = System.Text.Encoding.UTF8.GetString(sdkFileStream.data(), 0, fileSize); - sw = t.CreateText(); - sw.WriteLine(data); - sw.Close(); - sw.Dispose(); - - sdkFileStream.reclaimObject(); - sdkFileStream = null; - downloadFiles += 1; - - if (remainingFiles == 0) - { - warnUpdateSDK = ""; - downloadFiles = 0; - replaceNewSDK(); - } - } - } - - void downloadSDKFromServer() - { - downloadFiles = 0; - - if (Directory.Exists(sdkTempPath)) - Directory.Delete(sdkTempPath, true); - - Directory.CreateDirectory(sdkTempPath); - - if (sdkFileStream != null) - { - sdkFileStream.reclaimObject(); - sdkFileStream = null; - } - - // kbcmd options - string tool_options = "Unity"; - string callbackIP = ""; - UInt16 callbackPort = 0; - int clientWindowSize = (int)KBEngineApp.app.getInitArgs().TCP_RECV_BUFFER_MAX; - - Bundle bundle = Bundle.createObject(); - bundle.newMessage(Messages.messages["Loginapp_importClientSDK"]); - bundle.writeString(tool_options); - bundle.writeInt32(clientWindowSize); - bundle.writeString(callbackIP); - bundle.writeUint16(callbackPort); - bundle.send(KBEngineApp.app.networkInterface()); - } - - void replaceNewSDK() - { - System.IO.Directory.Move(sdkPath, sdkBakPath); - System.IO.Directory.Move(sdkTempPath, sdkPath); - - // 删除旧的SKD文件夹 - Directory.Delete(sdkBakPath, true); - - EditorApplication.isPlaying = false; - AssetDatabase.Refresh(); - } - - void OnGUI() - { - if (warnUpdateSDK.Length > 0) - { - GUI.contentColor = Color.red; - GUI.backgroundColor = Color.red; - - if (GUI.Button(new Rect(Screen.width * 0.25f, Screen.height * 0.4f, Screen.width * 0.5f, Screen.height * 0.2f), warnUpdateSDK)) - { - // 从服务器下载新的SDK - downloadSDKFromServer(); - } - } - } - - void Update() - { - - - } - } -#endif -} +namespace KBEngine +{ +#if UNITY_EDITOR + using UnityEngine; + using UnityEditor; + using System.Collections; + using System; + using System.IO; + using KBEngine; + + public class ClientSDKUpdater : MonoBehaviour + { + string warnUpdateSDK = ""; + MemoryStream sdkFileStream = null; + int downloadFiles = 0; + string sdkPath = ""; + string sdkTempPath = ""; + string sdkBakPath = ""; + + void Start() + { + string kbengineCoreFile = "KBEngine.cs"; + string[] res = System.IO.Directory.GetFiles(Application.dataPath, kbengineCoreFile, SearchOption.AllDirectories); + sdkPath = res[0].Replace(kbengineCoreFile, "").Replace("\\", "/"); + sdkPath = sdkPath.Remove(sdkPath.Length - 1, 1); + + sdkTempPath = sdkPath + "_temp"; + sdkBakPath = sdkPath + "_bak"; + + warnUpdateSDK = "Version does not match the server.\nClick to update KBEnginePlugin!\nPull from: " + KBEngineApp.app.getInitArgs().ip + ":" + KBEngineApp.app.getInitArgs().port; + installEvents(); + + GameObject[] objs = FindObjectsOfType(typeof(GameObject)) as GameObject[]; + foreach (GameObject child in objs) + { + if (!child.gameObject.GetComponent() && + !child.gameObject.GetComponent() && + !child.gameObject.GetComponent()) + { + child.gameObject.SetActive(false); + } + } + } + + public virtual void installEvents() + { + Event.registerIn("onImportClientSDK", this, "onImportClientSDK"); + } + + protected virtual void OnDestroy() + { + KBEngine.Event.deregisterOut(this); + } + + public void onImportClientSDK(int remainingFiles, string fileName, int fileSize, byte[] fileDatas) + { + if (sdkFileStream == null) + sdkFileStream = MemoryStream.createObject(); + + sdkFileStream.append(fileDatas, (uint)sdkFileStream.rpos, (uint)fileDatas.Length); + + warnUpdateSDK = "Download:" + fileName + " -> " + sdkFileStream.length() + "/" + fileSize + "bytes! " + (int)(((float)downloadFiles / (float)(downloadFiles + remainingFiles)) * 100) + "%"; + Debug.Log(warnUpdateSDK); + + if (sdkFileStream.length() == fileSize) + { + Debug.Log("onImportClientSDK: " + fileName + "->" + fileSize + "bytes success!"); + + string path = Path.GetDirectoryName(sdkTempPath + "//" + fileName); + if (!Directory.Exists(path)) + Directory.CreateDirectory(path); + + StreamWriter sw; + FileInfo t = new FileInfo(sdkTempPath + "//" + fileName); + string data = System.Text.Encoding.UTF8.GetString(sdkFileStream.data(), 0, fileSize); + sw = t.CreateText(); + sw.WriteLine(data); + sw.Close(); + sw.Dispose(); + + sdkFileStream.reclaimObject(); + sdkFileStream = null; + downloadFiles += 1; + + if (remainingFiles == 0) + { + warnUpdateSDK = ""; + downloadFiles = 0; + replaceNewSDK(); + } + } + } + + void downloadSDKFromServer() + { + downloadFiles = 0; + + if (Directory.Exists(sdkTempPath)) + Directory.Delete(sdkTempPath, true); + + Directory.CreateDirectory(sdkTempPath); + + if (sdkFileStream != null) + { + sdkFileStream.reclaimObject(); + sdkFileStream = null; + } + + // kbcmd options + string tool_options = "Unity"; + string callbackIP = ""; + UInt16 callbackPort = 0; + int clientWindowSize = (int)KBEngineApp.app.getInitArgs().TCP_RECV_BUFFER_MAX; + + Bundle bundle = Bundle.createObject(); + bundle.newMessage(Messages.messages["Loginapp_importClientSDK"]); + bundle.writeString(tool_options); + bundle.writeInt32(clientWindowSize); + bundle.writeString(callbackIP); + bundle.writeUint16(callbackPort); + bundle.send(KBEngineApp.app.networkInterface()); + } + + void replaceNewSDK() + { + System.IO.Directory.Move(sdkPath, sdkBakPath); + System.IO.Directory.Move(sdkTempPath, sdkPath); + + // 删除旧的SKD文件夹 + Directory.Delete(sdkBakPath, true); + + EditorApplication.isPlaying = false; + AssetDatabase.Refresh(); + } + + void OnGUI() + { + if (warnUpdateSDK.Length > 0) + { + GUI.contentColor = Color.red; + GUI.backgroundColor = Color.red; + + if (GUI.Button(new Rect(Screen.width * 0.25f, Screen.height * 0.4f, Screen.width * 0.5f, Screen.height * 0.2f), warnUpdateSDK)) + { + // 从服务器下载新的SDK + downloadSDKFromServer(); + } + } + } + + void Update() + { + + + } + } +#endif +} diff --git a/Assets/Plugins/kbengine_unity3d_plugins/CustomDataTypes.cs b/Assets/Plugins/kbengine_unity3d_plugins/CustomDataTypes.cs index 9b12ce1..4a5dc69 100644 --- a/Assets/Plugins/kbengine_unity3d_plugins/CustomDataTypes.cs +++ b/Assets/Plugins/kbengine_unity3d_plugins/CustomDataTypes.cs @@ -1,283 +1,283 @@ -/* - Generated by KBEngine! - Please do not modify this file! - tools = kbcmd -*/ - -namespace KBEngine -{ - using UnityEngine; - using System; - using System.Collections; - using System.Collections.Generic; - - - - public class DATATYPE_ENTITY_FORBID_COUNTER : DATATYPE_BASE - { - public ENTITY_FORBID_COUNTER createFromStreamEx(MemoryStream stream) - { - UInt32 size = stream.readUint32(); - ENTITY_FORBID_COUNTER datas = new ENTITY_FORBID_COUNTER(); - - while(size > 0) - { - --size; - datas.Add(stream.readInt8()); - }; - - return datas; - } - - public void addToStreamEx(Bundle stream, ENTITY_FORBID_COUNTER v) - { - stream.writeUint32((UInt32)v.Count); - for(int i=0; i 0) - { - --size; - datas.Add(stream.readInt32()); - }; - - return datas; - } - - public void addToStreamEx(Bundle stream, ENTITYID_LIST v) - { - stream.writeUint32((UInt32)v.Count); - for(int i=0; i createFromStreamEx(MemoryStream stream) - { - UInt32 size = stream.readUint32(); - List datas = new List(); - - while(size > 0) - { - --size; - datas.Add(itemType.createFromStreamEx(stream)); - }; - - return datas; - } - - public void addToStreamEx(Bundle stream, List v) - { - stream.writeUint32((UInt32)v.Count); - for(int i=0; i createFromStreamEx(MemoryStream stream) - { - UInt32 size = stream.readUint32(); - List datas = new List(); - - while(size > 0) - { - --size; - datas.Add(stream.readInt64()); - }; - - return datas; - } - - public void addToStreamEx(Bundle stream, List v) - { - stream.writeUint32((UInt32)v.Count); - for(int i=0; i> createFromStreamEx(MemoryStream stream) - { - UInt32 size = stream.readUint32(); - List> datas = new List>(); - - while(size > 0) - { - --size; - datas.Add(itemType.createFromStreamEx(stream)); - }; - - return datas; - } - - public void addToStreamEx(Bundle stream, List> v) - { - stream.writeUint32((UInt32)v.Count); - for(int i=0; i createFromStreamEx(MemoryStream stream) - { - UInt32 size = stream.readUint32(); - List datas = new List(); - - while(size > 0) - { - --size; - datas.Add(stream.readInt32()); - }; - - return datas; - } - - public void addToStreamEx(Bundle stream, List v) - { - stream.writeUint32((UInt32)v.Count); - for(int i=0; i 0) + { + --size; + datas.Add(stream.readInt8()); + }; + + return datas; + } + + public void addToStreamEx(Bundle stream, ENTITY_FORBID_COUNTER v) + { + stream.writeUint32((UInt32)v.Count); + for(int i=0; i 0) + { + --size; + datas.Add(stream.readInt32()); + }; + + return datas; + } + + public void addToStreamEx(Bundle stream, ENTITYID_LIST v) + { + stream.writeUint32((UInt32)v.Count); + for(int i=0; i createFromStreamEx(MemoryStream stream) + { + UInt32 size = stream.readUint32(); + List datas = new List(); + + while(size > 0) + { + --size; + datas.Add(itemType.createFromStreamEx(stream)); + }; + + return datas; + } + + public void addToStreamEx(Bundle stream, List v) + { + stream.writeUint32((UInt32)v.Count); + for(int i=0; i createFromStreamEx(MemoryStream stream) + { + UInt32 size = stream.readUint32(); + List datas = new List(); + + while(size > 0) + { + --size; + datas.Add(stream.readInt64()); + }; + + return datas; + } + + public void addToStreamEx(Bundle stream, List v) + { + stream.writeUint32((UInt32)v.Count); + for(int i=0; i> createFromStreamEx(MemoryStream stream) + { + UInt32 size = stream.readUint32(); + List> datas = new List>(); + + while(size > 0) + { + --size; + datas.Add(itemType.createFromStreamEx(stream)); + }; + + return datas; + } + + public void addToStreamEx(Bundle stream, List> v) + { + stream.writeUint32((UInt32)v.Count); + for(int i=0; i createFromStreamEx(MemoryStream stream) + { + UInt32 size = stream.readUint32(); + List datas = new List(); + + while(size > 0) + { + --size; + datas.Add(stream.readInt32()); + }; + + return datas; + } + + public void addToStreamEx(Bundle stream, List v) + { + stream.writeUint32((UInt32)v.Count); + for(int i=0; i= sbyte.MinValue && v1 <= sbyte.MaxValue; - } - } - - public class DATATYPE_INT16 : DATATYPE_BASE - { - public override object createFromStream(MemoryStream stream) - { - return stream.readInt16(); - } - - public override void addToStream(Bundle stream, object v) - { - stream.writeInt16(Convert.ToInt16(v)); - } - - public override object parseDefaultValStr(string v) - { - Int16 ret = 0; - Int16.TryParse(v, out ret); - return ret; - } - - public override bool isSameType(object v) - { - if (!KBEMath.isNumeric (v)) - return false; - - decimal v1 = Convert.ToDecimal (v); - return v1 >= Int16.MinValue && v1 <= Int16.MaxValue; - } - } - - public class DATATYPE_INT32 : DATATYPE_BASE - { - public override object createFromStream(MemoryStream stream) - { - return stream.readInt32(); - } - - public override void addToStream(Bundle stream, object v) - { - stream.writeInt32(Convert.ToInt32(v)); - } - - public override object parseDefaultValStr(string v) - { - Int32 ret = 0; - Int32.TryParse(v, out ret); - return ret; - } - - public override bool isSameType(object v) - { - if (!KBEMath.isNumeric (v)) - return false; - - decimal v1 = Convert.ToDecimal (v); - return v1 >= Int32.MinValue && v1 <= Int32.MaxValue; - } - } - - public class DATATYPE_INT64 : DATATYPE_BASE - { - public override object createFromStream(MemoryStream stream) - { - return stream.readInt64(); - } - - public override void addToStream(Bundle stream, object v) - { - stream.writeInt64(Convert.ToInt64(v)); - } - - public override object parseDefaultValStr(string v) - { - Int64 ret = 0; - Int64.TryParse(v, out ret); - return ret; - } - - public override bool isSameType(object v) - { - if (!KBEMath.isNumeric (v)) - return false; - - decimal v1 = Convert.ToDecimal (v); - return v1 >= Int64.MinValue && v1 <= Int64.MaxValue; - } - } - - public class DATATYPE_UINT8 : DATATYPE_BASE - { - public override object createFromStream(MemoryStream stream) - { - return stream.readUint8(); - } - - public override void addToStream(Bundle stream, object v) - { - stream.writeUint8(Convert.ToByte(v)); - } - - public override object parseDefaultValStr(string v) - { - Byte ret = 0; - Byte.TryParse(v, out ret); - return ret; - } - - public override bool isSameType(object v) - { - if (!KBEMath.isNumeric (v)) - return false; - - decimal v1 = Convert.ToDecimal (v); - return v1 >= Byte.MinValue && v1 <= Byte.MaxValue; - } - } - - public class DATATYPE_UINT16 : DATATYPE_BASE - { - public override object createFromStream(MemoryStream stream) - { - return stream.readUint16(); - } - - public override void addToStream(Bundle stream, object v) - { - stream.writeUint16(Convert.ToUInt16(v)); - } - - public override object parseDefaultValStr(string v) - { - UInt16 ret = 0; - UInt16.TryParse(v, out ret); - return ret; - } - - public override bool isSameType(object v) - { - if (!KBEMath.isNumeric (v)) - return false; - - decimal v1 = Convert.ToDecimal (v); - return v1 >= UInt16.MinValue && v1 <= UInt16.MaxValue; - } - } - - public class DATATYPE_UINT32 : DATATYPE_BASE - { - public override object createFromStream(MemoryStream stream) - { - return stream.readUint32(); - } - - public override void addToStream(Bundle stream, object v) - { - stream.writeUint32(Convert.ToUInt32(v)); - } - - public override object parseDefaultValStr(string v) - { - UInt32 ret = 0; - UInt32.TryParse(v, out ret); - return ret; - } - - public override bool isSameType(object v) - { - if (!KBEMath.isNumeric (v)) - return false; - - decimal v1 = Convert.ToDecimal (v); - return v1 >= UInt32.MinValue && v1 <= UInt32.MaxValue; - } - } - - public class DATATYPE_UINT64 : DATATYPE_BASE - { - public override object createFromStream(MemoryStream stream) - { - return stream.readUint64(); - } - - public override void addToStream(Bundle stream, object v) - { - stream.writeUint64(Convert.ToUInt64(v)); - } - - public override object parseDefaultValStr(string v) - { - UInt64 ret = 0; - UInt64.TryParse(v, out ret); - return ret; - } - - public override bool isSameType(object v) - { - if (!KBEMath.isNumeric (v)) - return false; - - decimal v1 = Convert.ToDecimal (v); - return v1 >= UInt64.MinValue && v1 <= UInt64.MaxValue; - } - } - - public class DATATYPE_FLOAT : DATATYPE_BASE - { - public override object createFromStream(MemoryStream stream) - { - return stream.readFloat(); - } - - public override void addToStream(Bundle stream, object v) - { - stream.writeFloat((float)Convert.ToDouble(v)); - } - - public override object parseDefaultValStr(string v) - { - float ret = 0.0f; - float.TryParse(v, out ret); - return ret; - } - - public override bool isSameType(object v) - { - if(v is float) - return (float)v >= float.MinValue && (float)v <= float.MaxValue; - else if(v is double) - return (double)v >= float.MinValue && (double)v <= float.MaxValue; - - return false; - } - } - - public class DATATYPE_DOUBLE : DATATYPE_BASE - { - public override object createFromStream(MemoryStream stream) - { - return stream.readDouble(); - } - - public override void addToStream(Bundle stream, object v) - { - stream.writeDouble(Convert.ToDouble(v)); - } - - public override object parseDefaultValStr(string v) - { - double ret = 0.0; - double.TryParse(v, out ret); - return ret; - } - - public override bool isSameType(object v) - { - if(v is float) - return (float)v >= double.MinValue && (float)v <= double.MaxValue; - else if(v is double) - return (double)v >= double.MinValue && (double)v <= double.MaxValue; - - return false; - } - } - - public class DATATYPE_STRING : DATATYPE_BASE - { - public override object createFromStream(MemoryStream stream) - { - return stream.readString(); - } - - public override void addToStream(Bundle stream, object v) - { - stream.writeString(Convert.ToString(v)); - } - - public override object parseDefaultValStr(string v) - { - return v; - } - - public override bool isSameType(object v) - { - return v != null && v.GetType() == typeof(string); - } - } - - public class DATATYPE_VECTOR2 : DATATYPE_BASE - { - public override object createFromStream(MemoryStream stream) - { - return new Vector2(stream.readFloat(), stream.readFloat()); - } - - public override void addToStream(Bundle stream, object v) - { - stream.writeFloat(((Vector2)v).x); - stream.writeFloat(((Vector2)v).y); - } - - public override object parseDefaultValStr(string v) - { - return new Vector2(0.0f, 0.0f); - } - - public override bool isSameType(object v) - { - return v != null && v.GetType() == typeof(Vector2); - } - } - - public class DATATYPE_VECTOR3 : DATATYPE_BASE - { - public override object createFromStream(MemoryStream stream) - { - return new Vector3(stream.readFloat(), stream.readFloat(), stream.readFloat()); - } - - public override void addToStream(Bundle stream, object v) - { - stream.writeFloat(((Vector3)v).x); - stream.writeFloat(((Vector3)v).y); - stream.writeFloat(((Vector3)v).z); - } - - public override object parseDefaultValStr(string v) - { - return new Vector3(0.0f, 0.0f, 0.0f); - } - - public override bool isSameType(object v) - { - return v != null && v.GetType() == typeof(Vector3); - } - } - - public class DATATYPE_VECTOR4 : DATATYPE_BASE - { - public override object createFromStream(MemoryStream stream) - { - return new Vector4(stream.readFloat(), stream.readFloat(), stream.readFloat(), stream.readFloat()); - } - - public override void addToStream(Bundle stream, object v) - { - stream.writeFloat(((Vector4)v).x); - stream.writeFloat(((Vector4)v).y); - stream.writeFloat(((Vector4)v).z); - stream.writeFloat(((Vector4)v).w); - } - - public override object parseDefaultValStr(string v) - { - return new Vector4(0.0f, 0.0f, 0.0f, 0.0f); - } - - public override bool isSameType(object v) - { - return v != null && v.GetType() == typeof(Vector4); - } - } - - public class DATATYPE_PYTHON : DATATYPE_BASE - { - public override object createFromStream(MemoryStream stream) - { - return stream.readBlob(); - } - - public override void addToStream(Bundle stream, object v) - { - stream.writeBlob((byte[])v); - } - - public override object parseDefaultValStr(string v) - { - return new byte[0]; - } - - public override bool isSameType(object v) - { - return v != null && v.GetType() == typeof(byte[]); - } - } - - public class DATATYPE_UNICODE : DATATYPE_BASE - { - public override object createFromStream(MemoryStream stream) - { - return System.Text.Encoding.UTF8.GetString(stream.readBlob()); - } - - public override void addToStream(Bundle stream, object v) - { - stream.writeBlob(System.Text.Encoding.UTF8.GetBytes((string)v)); - } - - public override object parseDefaultValStr(string v) - { - return v; - } - - public override bool isSameType(object v) - { - return v != null && v.GetType() == typeof(string); - } - } - - public class DATATYPE_ENTITYCALL : DATATYPE_BASE - { - public override object createFromStream(MemoryStream stream) - { - return stream.readBlob(); - } - - public override void addToStream(Bundle stream, object v) - { - stream.writeBlob((byte[])v); - } - - public override object parseDefaultValStr(string v) - { - return new byte[0]; - } - - public override bool isSameType(object v) - { - return v != null && v.GetType() == typeof(byte[]); - } - } - - public class DATATYPE_BLOB : DATATYPE_BASE - { - public override object createFromStream(MemoryStream stream) - { - return stream.readBlob(); - } - - public override void addToStream(Bundle stream, object v) - { - stream.writeBlob((byte[])v); - } - - public override object parseDefaultValStr(string v) - { - return new byte[0]; - } - - public override bool isSameType(object v) - { - return v != null && v.GetType() == typeof(byte[]); - } - } - - public class DATATYPE_ARRAY : DATATYPE_BASE - { - public object vtype; - - public override void bind() - { - if(vtype.GetType ().BaseType.ToString() == "KBEngine.DATATYPE_BASE") - ((DATATYPE_BASE)vtype).bind(); - else - if(EntityDef.id2datatypes.ContainsKey((UInt16)vtype)) - vtype = EntityDef.id2datatypes[(UInt16)vtype]; - } - - public override object createFromStream(MemoryStream stream) - { - UInt32 size = stream.readUint32(); - List datas = new List(); - - while(size > 0) - { - size--; - // datas.Add(((DATATYPE_BASE)vtype).createFromStream(stream)); - }; - - return datas; - } - - public override void addToStream(Bundle stream, object v) - { - stream.writeUint32((UInt32)((List)v).Count); - for(int i=0; i<((List)v).Count; i++) - { - // ((DATATYPE_BASE)vtype).addToStream(stream, ((List)v)[i]); - } - } - - public override object parseDefaultValStr(string v) - { - return new byte[0]; - } - - public override bool isSameType(object v) - { - if(vtype.GetType ().BaseType.ToString() != "KBEngine.DATATYPE_BASE") - { - Dbg.ERROR_MSG(string.Format("DATATYPE_ARRAY::isSameType: has not bind! baseType={0}", - vtype.GetType ().BaseType.ToString())); - return false; - } - - if(v == null || v.GetType() != typeof(List)) - { - return false; - } - - for(int i=0; i<((List)v).Count; i++) - { - if(!((DATATYPE_BASE)vtype).isSameType(((List)v)[i])) - { - return false; - } - } - - return true; - } - } - - public class DATATYPE_FIXED_DICT : DATATYPE_BASE - { - public string implementedBy = ""; - public Dictionary dicttype = new Dictionary(); - - public override void bind() - { - string[] keys = new string[dicttype.Keys.Count]; - dicttype.Keys.CopyTo(keys, 0); - - foreach(string itemkey in keys) - { - object type = dicttype[itemkey]; - - if(type.GetType ().BaseType.ToString() == "KBEngine.DATATYPE_BASE") - ((DATATYPE_BASE)type).bind(); - else - if(EntityDef.id2datatypes.ContainsKey((UInt16)type)) - dicttype[itemkey] = EntityDef.id2datatypes[(UInt16)type]; - } - } - - public override object createFromStream(MemoryStream stream) - { - Dictionary datas = new Dictionary(); - foreach(string itemkey in dicttype.Keys) - { - // datas[itemkey] = ((DATATYPE_BASE)dicttype[itemkey]).createFromStream(stream); - } - - return datas; - } - - public override void addToStream(Bundle stream, object v) - { - foreach(string itemkey in dicttype.Keys) - { - // ((DATATYPE_BASE)dicttype[itemkey]).addToStream(stream, ((Dictionary)v)[itemkey]); - } - } - - public override object parseDefaultValStr(string v) - { - Dictionary datas = new Dictionary(); - foreach(string itemkey in dicttype.Keys) - { - datas[itemkey] = ((DATATYPE_BASE)dicttype[itemkey]).parseDefaultValStr(""); - } - - return datas; - } - - public override bool isSameType(object v) - { - if(v == null || v.GetType() != typeof(Dictionary)) - return false; - - foreach(KeyValuePair item in dicttype) - { - object value; - if(((Dictionary)v).TryGetValue(item.Key, out value)) - { - if(!((DATATYPE_BASE)item.Value).isSameType(value)) - { - return false; - } - } - else - { - return false; - } - } - - return true; - } - } -} +namespace KBEngine +{ + using UnityEngine; + using System; + using System.Collections; + using System.Collections.Generic; + + using MessageID = System.UInt16; + + /* + entitydef所支持的基本数据类型 + 改模块中的类抽象出了所有的支持类型并提供了这些类型的数据序列化成二进制数据与反序列化操作(主要用于网络通讯的打包与解包) + */ + public class DATATYPE_BASE + { + public virtual void bind() + { + } + + public virtual object createFromStream(MemoryStream stream) + { + return null; + } + + public virtual void addToStream(Bundle stream, object v) + { + } + + public virtual object parseDefaultValStr(string v) + { + return null; + } + + public virtual bool isSameType(object v) + { + return v == null; + } + } + + public class DATATYPE_INT8 : DATATYPE_BASE + { + public override object createFromStream(MemoryStream stream) + { + return stream.readInt8(); + } + + public override void addToStream(Bundle stream, object v) + { + stream.writeInt8(Convert.ToSByte(v)); + } + + public override object parseDefaultValStr(string v) + { + SByte ret = 0; + SByte.TryParse(v, out ret); + return ret; + } + + public override bool isSameType(object v) + { + if (!KBEMath.isNumeric (v)) + return false; + + decimal v1 = Convert.ToDecimal (v); + return v1 >= sbyte.MinValue && v1 <= sbyte.MaxValue; + } + } + + public class DATATYPE_INT16 : DATATYPE_BASE + { + public override object createFromStream(MemoryStream stream) + { + return stream.readInt16(); + } + + public override void addToStream(Bundle stream, object v) + { + stream.writeInt16(Convert.ToInt16(v)); + } + + public override object parseDefaultValStr(string v) + { + Int16 ret = 0; + Int16.TryParse(v, out ret); + return ret; + } + + public override bool isSameType(object v) + { + if (!KBEMath.isNumeric (v)) + return false; + + decimal v1 = Convert.ToDecimal (v); + return v1 >= Int16.MinValue && v1 <= Int16.MaxValue; + } + } + + public class DATATYPE_INT32 : DATATYPE_BASE + { + public override object createFromStream(MemoryStream stream) + { + return stream.readInt32(); + } + + public override void addToStream(Bundle stream, object v) + { + stream.writeInt32(Convert.ToInt32(v)); + } + + public override object parseDefaultValStr(string v) + { + Int32 ret = 0; + Int32.TryParse(v, out ret); + return ret; + } + + public override bool isSameType(object v) + { + if (!KBEMath.isNumeric (v)) + return false; + + decimal v1 = Convert.ToDecimal (v); + return v1 >= Int32.MinValue && v1 <= Int32.MaxValue; + } + } + + public class DATATYPE_INT64 : DATATYPE_BASE + { + public override object createFromStream(MemoryStream stream) + { + return stream.readInt64(); + } + + public override void addToStream(Bundle stream, object v) + { + stream.writeInt64(Convert.ToInt64(v)); + } + + public override object parseDefaultValStr(string v) + { + Int64 ret = 0; + Int64.TryParse(v, out ret); + return ret; + } + + public override bool isSameType(object v) + { + if (!KBEMath.isNumeric (v)) + return false; + + decimal v1 = Convert.ToDecimal (v); + return v1 >= Int64.MinValue && v1 <= Int64.MaxValue; + } + } + + public class DATATYPE_UINT8 : DATATYPE_BASE + { + public override object createFromStream(MemoryStream stream) + { + return stream.readUint8(); + } + + public override void addToStream(Bundle stream, object v) + { + stream.writeUint8(Convert.ToByte(v)); + } + + public override object parseDefaultValStr(string v) + { + Byte ret = 0; + Byte.TryParse(v, out ret); + return ret; + } + + public override bool isSameType(object v) + { + if (!KBEMath.isNumeric (v)) + return false; + + decimal v1 = Convert.ToDecimal (v); + return v1 >= Byte.MinValue && v1 <= Byte.MaxValue; + } + } + + public class DATATYPE_UINT16 : DATATYPE_BASE + { + public override object createFromStream(MemoryStream stream) + { + return stream.readUint16(); + } + + public override void addToStream(Bundle stream, object v) + { + stream.writeUint16(Convert.ToUInt16(v)); + } + + public override object parseDefaultValStr(string v) + { + UInt16 ret = 0; + UInt16.TryParse(v, out ret); + return ret; + } + + public override bool isSameType(object v) + { + if (!KBEMath.isNumeric (v)) + return false; + + decimal v1 = Convert.ToDecimal (v); + return v1 >= UInt16.MinValue && v1 <= UInt16.MaxValue; + } + } + + public class DATATYPE_UINT32 : DATATYPE_BASE + { + public override object createFromStream(MemoryStream stream) + { + return stream.readUint32(); + } + + public override void addToStream(Bundle stream, object v) + { + stream.writeUint32(Convert.ToUInt32(v)); + } + + public override object parseDefaultValStr(string v) + { + UInt32 ret = 0; + UInt32.TryParse(v, out ret); + return ret; + } + + public override bool isSameType(object v) + { + if (!KBEMath.isNumeric (v)) + return false; + + decimal v1 = Convert.ToDecimal (v); + return v1 >= UInt32.MinValue && v1 <= UInt32.MaxValue; + } + } + + public class DATATYPE_UINT64 : DATATYPE_BASE + { + public override object createFromStream(MemoryStream stream) + { + return stream.readUint64(); + } + + public override void addToStream(Bundle stream, object v) + { + stream.writeUint64(Convert.ToUInt64(v)); + } + + public override object parseDefaultValStr(string v) + { + UInt64 ret = 0; + UInt64.TryParse(v, out ret); + return ret; + } + + public override bool isSameType(object v) + { + if (!KBEMath.isNumeric (v)) + return false; + + decimal v1 = Convert.ToDecimal (v); + return v1 >= UInt64.MinValue && v1 <= UInt64.MaxValue; + } + } + + public class DATATYPE_FLOAT : DATATYPE_BASE + { + public override object createFromStream(MemoryStream stream) + { + return stream.readFloat(); + } + + public override void addToStream(Bundle stream, object v) + { + stream.writeFloat((float)Convert.ToDouble(v)); + } + + public override object parseDefaultValStr(string v) + { + float ret = 0.0f; + float.TryParse(v, out ret); + return ret; + } + + public override bool isSameType(object v) + { + if(v is float) + return (float)v >= float.MinValue && (float)v <= float.MaxValue; + else if(v is double) + return (double)v >= float.MinValue && (double)v <= float.MaxValue; + + return false; + } + } + + public class DATATYPE_DOUBLE : DATATYPE_BASE + { + public override object createFromStream(MemoryStream stream) + { + return stream.readDouble(); + } + + public override void addToStream(Bundle stream, object v) + { + stream.writeDouble(Convert.ToDouble(v)); + } + + public override object parseDefaultValStr(string v) + { + double ret = 0.0; + double.TryParse(v, out ret); + return ret; + } + + public override bool isSameType(object v) + { + if(v is float) + return (float)v >= double.MinValue && (float)v <= double.MaxValue; + else if(v is double) + return (double)v >= double.MinValue && (double)v <= double.MaxValue; + + return false; + } + } + + public class DATATYPE_STRING : DATATYPE_BASE + { + public override object createFromStream(MemoryStream stream) + { + return stream.readString(); + } + + public override void addToStream(Bundle stream, object v) + { + stream.writeString(Convert.ToString(v)); + } + + public override object parseDefaultValStr(string v) + { + return v; + } + + public override bool isSameType(object v) + { + return v != null && v.GetType() == typeof(string); + } + } + + public class DATATYPE_VECTOR2 : DATATYPE_BASE + { + public override object createFromStream(MemoryStream stream) + { + return new Vector2(stream.readFloat(), stream.readFloat()); + } + + public override void addToStream(Bundle stream, object v) + { + stream.writeFloat(((Vector2)v).x); + stream.writeFloat(((Vector2)v).y); + } + + public override object parseDefaultValStr(string v) + { + return new Vector2(0.0f, 0.0f); + } + + public override bool isSameType(object v) + { + return v != null && v.GetType() == typeof(Vector2); + } + } + + public class DATATYPE_VECTOR3 : DATATYPE_BASE + { + public override object createFromStream(MemoryStream stream) + { + return new Vector3(stream.readFloat(), stream.readFloat(), stream.readFloat()); + } + + public override void addToStream(Bundle stream, object v) + { + stream.writeFloat(((Vector3)v).x); + stream.writeFloat(((Vector3)v).y); + stream.writeFloat(((Vector3)v).z); + } + + public override object parseDefaultValStr(string v) + { + return new Vector3(0.0f, 0.0f, 0.0f); + } + + public override bool isSameType(object v) + { + return v != null && v.GetType() == typeof(Vector3); + } + } + + public class DATATYPE_VECTOR4 : DATATYPE_BASE + { + public override object createFromStream(MemoryStream stream) + { + return new Vector4(stream.readFloat(), stream.readFloat(), stream.readFloat(), stream.readFloat()); + } + + public override void addToStream(Bundle stream, object v) + { + stream.writeFloat(((Vector4)v).x); + stream.writeFloat(((Vector4)v).y); + stream.writeFloat(((Vector4)v).z); + stream.writeFloat(((Vector4)v).w); + } + + public override object parseDefaultValStr(string v) + { + return new Vector4(0.0f, 0.0f, 0.0f, 0.0f); + } + + public override bool isSameType(object v) + { + return v != null && v.GetType() == typeof(Vector4); + } + } + + public class DATATYPE_PYTHON : DATATYPE_BASE + { + public override object createFromStream(MemoryStream stream) + { + return stream.readBlob(); + } + + public override void addToStream(Bundle stream, object v) + { + stream.writeBlob((byte[])v); + } + + public override object parseDefaultValStr(string v) + { + return new byte[0]; + } + + public override bool isSameType(object v) + { + return v != null && v.GetType() == typeof(byte[]); + } + } + + public class DATATYPE_UNICODE : DATATYPE_BASE + { + public override object createFromStream(MemoryStream stream) + { + return System.Text.Encoding.UTF8.GetString(stream.readBlob()); + } + + public override void addToStream(Bundle stream, object v) + { + stream.writeBlob(System.Text.Encoding.UTF8.GetBytes((string)v)); + } + + public override object parseDefaultValStr(string v) + { + return v; + } + + public override bool isSameType(object v) + { + return v != null && v.GetType() == typeof(string); + } + } + + public class DATATYPE_ENTITYCALL : DATATYPE_BASE + { + public override object createFromStream(MemoryStream stream) + { + return stream.readBlob(); + } + + public override void addToStream(Bundle stream, object v) + { + stream.writeBlob((byte[])v); + } + + public override object parseDefaultValStr(string v) + { + return new byte[0]; + } + + public override bool isSameType(object v) + { + return v != null && v.GetType() == typeof(byte[]); + } + } + + public class DATATYPE_BLOB : DATATYPE_BASE + { + public override object createFromStream(MemoryStream stream) + { + return stream.readBlob(); + } + + public override void addToStream(Bundle stream, object v) + { + stream.writeBlob((byte[])v); + } + + public override object parseDefaultValStr(string v) + { + return new byte[0]; + } + + public override bool isSameType(object v) + { + return v != null && v.GetType() == typeof(byte[]); + } + } + + public class DATATYPE_ARRAY : DATATYPE_BASE + { + public object vtype; + + public override void bind() + { + if(vtype.GetType ().BaseType.ToString() == "KBEngine.DATATYPE_BASE") + ((DATATYPE_BASE)vtype).bind(); + else + if(EntityDef.id2datatypes.ContainsKey((UInt16)vtype)) + vtype = EntityDef.id2datatypes[(UInt16)vtype]; + } + + public override object createFromStream(MemoryStream stream) + { + UInt32 size = stream.readUint32(); + List datas = new List(); + + while(size > 0) + { + size--; + // datas.Add(((DATATYPE_BASE)vtype).createFromStream(stream)); + }; + + return datas; + } + + public override void addToStream(Bundle stream, object v) + { + stream.writeUint32((UInt32)((List)v).Count); + for(int i=0; i<((List)v).Count; i++) + { + // ((DATATYPE_BASE)vtype).addToStream(stream, ((List)v)[i]); + } + } + + public override object parseDefaultValStr(string v) + { + return new byte[0]; + } + + public override bool isSameType(object v) + { + if(vtype.GetType ().BaseType.ToString() != "KBEngine.DATATYPE_BASE") + { + Dbg.ERROR_MSG(string.Format("DATATYPE_ARRAY::isSameType: has not bind! baseType={0}", + vtype.GetType ().BaseType.ToString())); + return false; + } + + if(v == null || v.GetType() != typeof(List)) + { + return false; + } + + for(int i=0; i<((List)v).Count; i++) + { + if(!((DATATYPE_BASE)vtype).isSameType(((List)v)[i])) + { + return false; + } + } + + return true; + } + } + + public class DATATYPE_FIXED_DICT : DATATYPE_BASE + { + public string implementedBy = ""; + public Dictionary dicttype = new Dictionary(); + + public override void bind() + { + string[] keys = new string[dicttype.Keys.Count]; + dicttype.Keys.CopyTo(keys, 0); + + foreach(string itemkey in keys) + { + object type = dicttype[itemkey]; + + if(type.GetType ().BaseType.ToString() == "KBEngine.DATATYPE_BASE") + ((DATATYPE_BASE)type).bind(); + else + if(EntityDef.id2datatypes.ContainsKey((UInt16)type)) + dicttype[itemkey] = EntityDef.id2datatypes[(UInt16)type]; + } + } + + public override object createFromStream(MemoryStream stream) + { + Dictionary datas = new Dictionary(); + foreach(string itemkey in dicttype.Keys) + { + // datas[itemkey] = ((DATATYPE_BASE)dicttype[itemkey]).createFromStream(stream); + } + + return datas; + } + + public override void addToStream(Bundle stream, object v) + { + foreach(string itemkey in dicttype.Keys) + { + // ((DATATYPE_BASE)dicttype[itemkey]).addToStream(stream, ((Dictionary)v)[itemkey]); + } + } + + public override object parseDefaultValStr(string v) + { + Dictionary datas = new Dictionary(); + foreach(string itemkey in dicttype.Keys) + { + datas[itemkey] = ((DATATYPE_BASE)dicttype[itemkey]).parseDefaultValStr(""); + } + + return datas; + } + + public override bool isSameType(object v) + { + if(v == null || v.GetType() != typeof(Dictionary)) + return false; + + foreach(KeyValuePair item in dicttype) + { + object value; + if(((Dictionary)v).TryGetValue(item.Key, out value)) + { + if(!((DATATYPE_BASE)item.Value).isSameType(value)) + { + return false; + } + } + else + { + return false; + } + } + + return true; + } + } +} diff --git a/Assets/Plugins/kbengine_unity3d_plugins/Dbg.cs b/Assets/Plugins/kbengine_unity3d_plugins/Dbg.cs index 7be2d7e..34f9603 100644 --- a/Assets/Plugins/kbengine_unity3d_plugins/Dbg.cs +++ b/Assets/Plugins/kbengine_unity3d_plugins/Dbg.cs @@ -1,78 +1,78 @@ -using UnityEngine; -using KBEngine; -using System; -using System.Collections; -using System.Collections.Generic; - -namespace KBEngine -{ - public enum DEBUGLEVEL : int - { - DEBUG = 0, - INFO, - WARNING, - ERROR, - - NOLOG, // 放在最后面,使用这个时表示不输出任何日志(!!!慎用!!!) - } - - public class Dbg - { - static public DEBUGLEVEL debugLevel = DEBUGLEVEL.DEBUG; - -#if UNITY_EDITOR - static Dictionary _profiles = new Dictionary(); -#endif - - public static string getHead() - { - return "[" + DateTime.Now.ToString("yyyy-MM-dd HH:mm:ss fff") + "] "; - } - - public static void INFO_MSG(object s) - { - if (DEBUGLEVEL.INFO >= debugLevel) - Debug.Log(getHead() + s); - } - - public static void DEBUG_MSG(object s) - { - if (DEBUGLEVEL.DEBUG >= debugLevel) - Debug.Log(getHead() + s); - } - - public static void WARNING_MSG(object s) - { - if (DEBUGLEVEL.WARNING >= debugLevel) - Debug.LogWarning(getHead() + s); - } - - public static void ERROR_MSG(object s) - { - if (DEBUGLEVEL.ERROR >= debugLevel) - Debug.LogError(getHead() + s); - } - - public static void profileStart(string name) - { -#if UNITY_EDITOR - Profile p = null; - if(!_profiles.TryGetValue(name, out p)) - { - p = new Profile(name); - _profiles.Add(name, p); - } - - p.start(); -#endif - } - - public static void profileEnd(string name) - { -#if UNITY_EDITOR - _profiles[name].end(); -#endif - } - - } -} +using UnityEngine; +using KBEngine; +using System; +using System.Collections; +using System.Collections.Generic; + +namespace KBEngine +{ + public enum DEBUGLEVEL : int + { + DEBUG = 0, + INFO, + WARNING, + ERROR, + + NOLOG, // 放在最后面,使用这个时表示不输出任何日志(!!!慎用!!!) + } + + public class Dbg + { + static public DEBUGLEVEL debugLevel = DEBUGLEVEL.DEBUG; + +#if UNITY_EDITOR + static Dictionary _profiles = new Dictionary(); +#endif + + public static string getHead() + { + return "[" + DateTime.Now.ToString("yyyy-MM-dd HH:mm:ss fff") + "] "; + } + + public static void INFO_MSG(object s) + { + if (DEBUGLEVEL.INFO >= debugLevel) + Debug.Log(getHead() + s); + } + + public static void DEBUG_MSG(object s) + { + if (DEBUGLEVEL.DEBUG >= debugLevel) + Debug.Log(getHead() + s); + } + + public static void WARNING_MSG(object s) + { + if (DEBUGLEVEL.WARNING >= debugLevel) + Debug.LogWarning(getHead() + s); + } + + public static void ERROR_MSG(object s) + { + if (DEBUGLEVEL.ERROR >= debugLevel) + Debug.LogError(getHead() + s); + } + + public static void profileStart(string name) + { +#if UNITY_EDITOR + Profile p = null; + if(!_profiles.TryGetValue(name, out p)) + { + p = new Profile(name); + _profiles.Add(name, p); + } + + p.start(); +#endif + } + + public static void profileEnd(string name) + { +#if UNITY_EDITOR + _profiles[name].end(); +#endif + } + + } +} diff --git a/Assets/Plugins/kbengine_unity3d_plugins/EncryptionFilter.cs b/Assets/Plugins/kbengine_unity3d_plugins/EncryptionFilter.cs index 76ffe8c..cf96e9a 100644 --- a/Assets/Plugins/kbengine_unity3d_plugins/EncryptionFilter.cs +++ b/Assets/Plugins/kbengine_unity3d_plugins/EncryptionFilter.cs @@ -1,190 +1,190 @@ -namespace KBEngine -{ - using UnityEngine; - using System; - using System.Collections; - using System.Collections.Generic; - - public abstract class EncryptionFilter - { - public abstract void encrypt(MemoryStream stream); - - public abstract void decrypt(MemoryStream stream); - public abstract void decrypt(byte[] buffer, int startIndex, int length); - - public abstract bool send(PacketSenderBase sender, MemoryStream stream); - public abstract bool recv(MessageReaderBase reader, byte[] buffer, UInt32 rpos, UInt32 len); - } - - - class BlowfishFilter : EncryptionFilter - { - private Blowfish _blowfish = new Blowfish(); - - private MemoryStream _packet = new MemoryStream(); - MemoryStream _enctyptStrem = new MemoryStream(); - - private UINT8 _padSize = 0; - private UInt16 _packLen = 0; - const UInt32 BLOCK_SIZE = 8; - const UInt32 MIN_PACKET_SIZE = sizeof(UInt16) + 1 + BLOCK_SIZE; - - public BlowfishFilter() - { - } - - ~BlowfishFilter() - { - } - - public byte[] key() - { - return _blowfish.key(); - } - - public override void encrypt(MemoryStream stream) - { - int padSize = 0; - if (stream.length() % BLOCK_SIZE != 0) - { - padSize = (int)(BLOCK_SIZE - (stream.length() % BLOCK_SIZE)); - stream.wpos += padSize; - - if(stream.wpos > MemoryStream.BUFFER_MAX) - Debug.LogError("BlowfishFilter::encrypt: stream.wpos(" + stream.wpos + ") > MemoryStream.BUFFER_MAX(" + MemoryStream.BUFFER_MAX + ")!"); - } - - _blowfish.encipher(stream.data(), (int)stream.length()); - - UInt16 packLen = (UInt16)(stream.length() + 1); - _enctyptStrem.writeUint16(packLen); - _enctyptStrem.writeUint8((UINT8)padSize); - _enctyptStrem.append(stream.data(), (UInt32)stream.rpos, stream.length()); - - stream.swap(_enctyptStrem); - _enctyptStrem.clear(); - } - - public override void decrypt(MemoryStream stream) - { - _blowfish.decipher(stream.data(), stream.rpos, (int)stream.length()); - } - - public override void decrypt(byte[] buffer, int startIndex, int length) - { - _blowfish.decipher(buffer, startIndex, length); - } - - public override bool send(PacketSenderBase sender, MemoryStream stream) - { - if(!_blowfish.isGood()) - { - Dbg.ERROR_MSG("BlowfishFilter::send: Dropping packet, due to invalid filter"); - return false; - } - - encrypt(stream); - return sender.send(stream); - } - - public override bool recv(MessageReaderBase reader, byte[] buffer, UInt32 rpos, UInt32 len) - { - if (!_blowfish.isGood()) - { - Dbg.ERROR_MSG("BlowfishFilter::recv: Dropping packet, due to invalid filter"); - return false; - } - - if (_packet.length() == 0 && len >= MIN_PACKET_SIZE && BitConverter.ToUInt16(buffer, (int)rpos) - 1 == len - 3) - { - int packLen = BitConverter.ToUInt16(buffer, (int)rpos) - 1; - int padSize = buffer[rpos + 2]; - - decrypt(buffer, (int)(rpos + 3), (int)(len - 3)); - - int length = packLen - padSize; - if (reader != null) - { - reader.process(buffer, rpos + 3, (UInt32)length); - } - - return true; - } - - _packet.append(buffer, rpos, len); - - while(_packet.length() > 0) - { - UInt32 currLen = 0; - int oldwpos = 0; - if (_packLen <= 0) - { - // 如果满足一个最小包则尝试解包, 否则缓存这个包待与下一个包合并然后解包 - if (_packet.length() >= MIN_PACKET_SIZE) - { - _packLen = _packet.readUint16(); - _padSize = _packet.readUint8(); - - _packLen -= 1; - - if (_packet.length() > _packLen) - { - currLen = (UInt32)(_packet.rpos + _packLen); - oldwpos = _packet.wpos; - _packet.wpos = (int)currLen; - } - else if (_packet.length() < _packLen) - { - return false; - } - } - else - { - return false; - } - } - else - { - // 如果上一次有做过解包行为但包还没有完整则继续处理 - // 如果包是完整的下面流程会解密, 如果有多余的内容需要将其剪裁出来待与下一个包合并 - if (_packet.length() > _packLen) - { - currLen = (UInt32)(_packet.rpos + _packLen); - oldwpos = _packet.wpos; - _packet.wpos = (int)currLen; - } - else if (_packet.length() < _packLen) - { - return false; - } - } - - decrypt(_packet); - _packet.wpos -= _padSize; - - // 上面的流程能保证wpos之后不会有多余的包 - // 如果有多余的包数据会放在_recvStream - if (reader != null) - { - reader.process(_packet.data(), (UInt32)_packet.rpos, _packet.length()); - } - - if (currLen > 0) - { - _packet.rpos = (int)currLen; - _packet.wpos = oldwpos; - } - else - { - _packet.clear(); - } - - _packLen = 0; - _padSize = 0; - } - - return true; - } - } -} - +namespace KBEngine +{ + using UnityEngine; + using System; + using System.Collections; + using System.Collections.Generic; + + public abstract class EncryptionFilter + { + public abstract void encrypt(MemoryStream stream); + + public abstract void decrypt(MemoryStream stream); + public abstract void decrypt(byte[] buffer, int startIndex, int length); + + public abstract bool send(PacketSenderBase sender, MemoryStream stream); + public abstract bool recv(MessageReaderBase reader, byte[] buffer, UInt32 rpos, UInt32 len); + } + + + class BlowfishFilter : EncryptionFilter + { + private Blowfish _blowfish = new Blowfish(); + + private MemoryStream _packet = new MemoryStream(); + MemoryStream _enctyptStrem = new MemoryStream(); + + private UINT8 _padSize = 0; + private UInt16 _packLen = 0; + const UInt32 BLOCK_SIZE = 8; + const UInt32 MIN_PACKET_SIZE = sizeof(UInt16) + 1 + BLOCK_SIZE; + + public BlowfishFilter() + { + } + + ~BlowfishFilter() + { + } + + public byte[] key() + { + return _blowfish.key(); + } + + public override void encrypt(MemoryStream stream) + { + int padSize = 0; + if (stream.length() % BLOCK_SIZE != 0) + { + padSize = (int)(BLOCK_SIZE - (stream.length() % BLOCK_SIZE)); + stream.wpos += padSize; + + if(stream.wpos > MemoryStream.BUFFER_MAX) + Debug.LogError("BlowfishFilter::encrypt: stream.wpos(" + stream.wpos + ") > MemoryStream.BUFFER_MAX(" + MemoryStream.BUFFER_MAX + ")!"); + } + + _blowfish.encipher(stream.data(), (int)stream.length()); + + UInt16 packLen = (UInt16)(stream.length() + 1); + _enctyptStrem.writeUint16(packLen); + _enctyptStrem.writeUint8((UINT8)padSize); + _enctyptStrem.append(stream.data(), (UInt32)stream.rpos, stream.length()); + + stream.swap(_enctyptStrem); + _enctyptStrem.clear(); + } + + public override void decrypt(MemoryStream stream) + { + _blowfish.decipher(stream.data(), stream.rpos, (int)stream.length()); + } + + public override void decrypt(byte[] buffer, int startIndex, int length) + { + _blowfish.decipher(buffer, startIndex, length); + } + + public override bool send(PacketSenderBase sender, MemoryStream stream) + { + if(!_blowfish.isGood()) + { + Dbg.ERROR_MSG("BlowfishFilter::send: Dropping packet, due to invalid filter"); + return false; + } + + encrypt(stream); + return sender.send(stream); + } + + public override bool recv(MessageReaderBase reader, byte[] buffer, UInt32 rpos, UInt32 len) + { + if (!_blowfish.isGood()) + { + Dbg.ERROR_MSG("BlowfishFilter::recv: Dropping packet, due to invalid filter"); + return false; + } + + if (_packet.length() == 0 && len >= MIN_PACKET_SIZE && BitConverter.ToUInt16(buffer, (int)rpos) - 1 == len - 3) + { + int packLen = BitConverter.ToUInt16(buffer, (int)rpos) - 1; + int padSize = buffer[rpos + 2]; + + decrypt(buffer, (int)(rpos + 3), (int)(len - 3)); + + int length = packLen - padSize; + if (reader != null) + { + reader.process(buffer, rpos + 3, (UInt32)length); + } + + return true; + } + + _packet.append(buffer, rpos, len); + + while(_packet.length() > 0) + { + UInt32 currLen = 0; + int oldwpos = 0; + if (_packLen <= 0) + { + // 如果满足一个最小包则尝试解包, 否则缓存这个包待与下一个包合并然后解包 + if (_packet.length() >= MIN_PACKET_SIZE) + { + _packLen = _packet.readUint16(); + _padSize = _packet.readUint8(); + + _packLen -= 1; + + if (_packet.length() > _packLen) + { + currLen = (UInt32)(_packet.rpos + _packLen); + oldwpos = _packet.wpos; + _packet.wpos = (int)currLen; + } + else if (_packet.length() < _packLen) + { + return false; + } + } + else + { + return false; + } + } + else + { + // 如果上一次有做过解包行为但包还没有完整则继续处理 + // 如果包是完整的下面流程会解密, 如果有多余的内容需要将其剪裁出来待与下一个包合并 + if (_packet.length() > _packLen) + { + currLen = (UInt32)(_packet.rpos + _packLen); + oldwpos = _packet.wpos; + _packet.wpos = (int)currLen; + } + else if (_packet.length() < _packLen) + { + return false; + } + } + + decrypt(_packet); + _packet.wpos -= _padSize; + + // 上面的流程能保证wpos之后不会有多余的包 + // 如果有多余的包数据会放在_recvStream + if (reader != null) + { + reader.process(_packet.data(), (UInt32)_packet.rpos, _packet.length()); + } + + if (currLen > 0) + { + _packet.rpos = (int)currLen; + _packet.wpos = oldwpos; + } + else + { + _packet.clear(); + } + + _packLen = 0; + _padSize = 0; + } + + return true; + } + } +} + diff --git a/Assets/Plugins/kbengine_unity3d_plugins/Entity.cs b/Assets/Plugins/kbengine_unity3d_plugins/Entity.cs index 0d93b22..19648c5 100644 --- a/Assets/Plugins/kbengine_unity3d_plugins/Entity.cs +++ b/Assets/Plugins/kbengine_unity3d_plugins/Entity.cs @@ -1,395 +1,395 @@ -namespace KBEngine -{ - using UnityEngine; - using System; - using System.Collections; - using System.Collections.Generic; - - /* - KBEngine逻辑层的实体基础类 - 所有扩展出的游戏实体都应该继承于该模块 - */ - public class Entity - { - // 当前玩家最后一次同步到服务端的位置与朝向 - // 这两个属性是给引擎KBEngine.cs用的,别的地方不要修改 - public Vector3 _entityLastLocalPos = new Vector3(0f, 0f, 0f); - public Vector3 _entityLastLocalDir = new Vector3(0f, 0f, 0f); - - public Int32 id = 0; - public string className = ""; - public Vector3 position = new Vector3(0.0f, 0.0f, 0.0f); - public Vector3 direction = new Vector3(0.0f, 0.0f, 0.0f); - public float velocity = 0.0f; - - public bool isOnGround = true; - - public object renderObj = null; - - //public EntityCall baseEntityCall = null; - //public EntityCall cellEntityCall = null; - - // enterworld之后设置为true - public bool inWorld = false; - - /// - /// 对于玩家自身来说,它表示是否自己被其它玩家控制了; - /// 对于其它entity来说,表示我本机是否控制了这个entity - /// - public bool isControlled = false; - - // __init__调用之后设置为true - public bool inited = false; - - public static void clear() - { - } - - public Entity() - { - } - - public void destroy() - { - detachComponents(); - onDestroy(); - } - - public virtual void onDestroy() - { - } - - public bool isPlayer() - { - return id == KBEngineApp.app.entity_id; - } - - public virtual void onRemoteMethodCall(MemoryStream stream) - { - // 动态生成 - } - - public virtual void onUpdatePropertys(MemoryStream stream) - { - // 动态生成 - } - - public virtual void onGetBase() - { - // 动态生成 - } - - public virtual void onGetCell() - { - // 动态生成 - } - - public virtual void onLoseCell() - { - // 动态生成 - } - - public virtual void onComponentsEnterworld() - { - // 动态生成, 通知组件onEnterworld - } - - public virtual void onComponentsLeaveworld() - { - // 动态生成, 通知组件onLeaveworld - } - - public virtual EntityCall getBaseEntityCall() - { - // 动态生成 - return null; - } - - public virtual EntityCall getCellEntityCall() - { - // 动态生成 - return null; - } - - /* - KBEngine的实体构造函数,与服务器脚本对应。 - 存在于这样的构造函数是因为KBE需要创建好实体并将属性等数据填充好才能告诉脚本层初始化 - */ - public virtual void __init__() - { - } - - public virtual void callPropertysSetMethods() - { - // 动态生成 - } - - public virtual void attachComponents() - { - // 动态生成 - } - - public virtual void detachComponents() - { - // 动态生成 - } - - public void baseCall(string methodname, params object[] arguments) - { - if(KBEngineApp.app.currserver == "loginapp") - { - Dbg.ERROR_MSG(className + "::baseCall(" + methodname + "), currserver=!" + KBEngineApp.app.currserver); - return; - } - - ScriptModule module = null; - if(!EntityDef.moduledefs.TryGetValue(className, out module)) - { - Dbg.ERROR_MSG("entity::baseCall: entity-module(" + className + ") error, can not find from EntityDef.moduledefs"); - return; - } - - Method method = null; - if(!module.base_methods.TryGetValue(methodname, out method)) - { - Dbg.ERROR_MSG(className + "::baseCall(" + methodname + "), not found method!"); - return; - } - - UInt16 methodID = method.methodUtype; - - if(arguments.Length != method.args.Count) - { - Dbg.ERROR_MSG(className + "::baseCall(" + methodname + "): args(" + (arguments.Length) + "!= " + method.args.Count + ") size is error!"); - return; - } - - EntityCall baseEntityCall = getBaseEntityCall(); - - baseEntityCall.newCall(); - baseEntityCall.bundle.writeUint16(0); - baseEntityCall.bundle.writeUint16(methodID); - - try - { - for(var i=0; i " + v); - - if(isPlayer()) - KBEngineApp.app.entityServerPos(position); - - if(inWorld) - Event.fireOut(EventOutTypes.set_position, this); - } - - public virtual void onUpdateVolatileData() - { - } - - public virtual void onDirectionChanged(Vector3 oldValue) - { - //Dbg.DEBUG_MSG(className + "::set_direction: " + oldValue + " => " + v); - - if(inWorld) - { - direction.x = direction.x * 360 / ((float)System.Math.PI * 2); - direction.y = direction.y * 360 / ((float)System.Math.PI * 2); - direction.z = direction.z * 360 / ((float)System.Math.PI * 2); - Event.fireOut(EventOutTypes.set_direction, this); - } - else - { - direction = oldValue; - } - } - - /// - /// This callback method is called when the local entity control by the client has been enabled or disabled. - /// See the Entity.controlledBy() method in the CellApp server code for more infomation. - /// - /// - /// 对于玩家自身来说,它表示是否自己被其它玩家控制了; - /// 对于其它entity来说,表示我本机是否控制了这个entity - /// - public virtual void onControlled(bool isControlled_) - { - - } - } - -} +namespace KBEngine +{ + using UnityEngine; + using System; + using System.Collections; + using System.Collections.Generic; + + /* + KBEngine逻辑层的实体基础类 + 所有扩展出的游戏实体都应该继承于该模块 + */ + public class Entity + { + // 当前玩家最后一次同步到服务端的位置与朝向 + // 这两个属性是给引擎KBEngine.cs用的,别的地方不要修改 + public Vector3 _entityLastLocalPos = new Vector3(0f, 0f, 0f); + public Vector3 _entityLastLocalDir = new Vector3(0f, 0f, 0f); + + public Int32 id = 0; + public string className = ""; + public Vector3 position = new Vector3(0.0f, 0.0f, 0.0f); + public Vector3 direction = new Vector3(0.0f, 0.0f, 0.0f); + public float velocity = 0.0f; + + public bool isOnGround = true; + + public object renderObj = null; + + //public EntityCall baseEntityCall = null; + //public EntityCall cellEntityCall = null; + + // enterworld之后设置为true + public bool inWorld = false; + + /// + /// 对于玩家自身来说,它表示是否自己被其它玩家控制了; + /// 对于其它entity来说,表示我本机是否控制了这个entity + /// + public bool isControlled = false; + + // __init__调用之后设置为true + public bool inited = false; + + public static void clear() + { + } + + public Entity() + { + } + + public void destroy() + { + detachComponents(); + onDestroy(); + } + + public virtual void onDestroy() + { + } + + public bool isPlayer() + { + return id == KBEngineApp.app.entity_id; + } + + public virtual void onRemoteMethodCall(MemoryStream stream) + { + // 动态生成 + } + + public virtual void onUpdatePropertys(MemoryStream stream) + { + // 动态生成 + } + + public virtual void onGetBase() + { + // 动态生成 + } + + public virtual void onGetCell() + { + // 动态生成 + } + + public virtual void onLoseCell() + { + // 动态生成 + } + + public virtual void onComponentsEnterworld() + { + // 动态生成, 通知组件onEnterworld + } + + public virtual void onComponentsLeaveworld() + { + // 动态生成, 通知组件onLeaveworld + } + + public virtual EntityCall getBaseEntityCall() + { + // 动态生成 + return null; + } + + public virtual EntityCall getCellEntityCall() + { + // 动态生成 + return null; + } + + /* + KBEngine的实体构造函数,与服务器脚本对应。 + 存在于这样的构造函数是因为KBE需要创建好实体并将属性等数据填充好才能告诉脚本层初始化 + */ + public virtual void __init__() + { + } + + public virtual void callPropertysSetMethods() + { + // 动态生成 + } + + public virtual void attachComponents() + { + // 动态生成 + } + + public virtual void detachComponents() + { + // 动态生成 + } + + public void baseCall(string methodname, params object[] arguments) + { + if(KBEngineApp.app.currserver == "loginapp") + { + Dbg.ERROR_MSG(className + "::baseCall(" + methodname + "), currserver=!" + KBEngineApp.app.currserver); + return; + } + + ScriptModule module = null; + if(!EntityDef.moduledefs.TryGetValue(className, out module)) + { + Dbg.ERROR_MSG("entity::baseCall: entity-module(" + className + ") error, can not find from EntityDef.moduledefs"); + return; + } + + Method method = null; + if(!module.base_methods.TryGetValue(methodname, out method)) + { + Dbg.ERROR_MSG(className + "::baseCall(" + methodname + "), not found method!"); + return; + } + + UInt16 methodID = method.methodUtype; + + if(arguments.Length != method.args.Count) + { + Dbg.ERROR_MSG(className + "::baseCall(" + methodname + "): args(" + (arguments.Length) + "!= " + method.args.Count + ") size is error!"); + return; + } + + EntityCall baseEntityCall = getBaseEntityCall(); + + baseEntityCall.newCall(); + baseEntityCall.bundle.writeUint16(0); + baseEntityCall.bundle.writeUint16(methodID); + + try + { + for(var i=0; i " + v); + + if(isPlayer()) + KBEngineApp.app.entityServerPos(position); + + if(inWorld) + Event.fireOut(EventOutTypes.set_position, this); + } + + public virtual void onUpdateVolatileData() + { + } + + public virtual void onDirectionChanged(Vector3 oldValue) + { + //Dbg.DEBUG_MSG(className + "::set_direction: " + oldValue + " => " + v); + + if(inWorld) + { + direction.x = direction.x * 360 / ((float)System.Math.PI * 2); + direction.y = direction.y * 360 / ((float)System.Math.PI * 2); + direction.z = direction.z * 360 / ((float)System.Math.PI * 2); + Event.fireOut(EventOutTypes.set_direction, this); + } + else + { + direction = oldValue; + } + } + + /// + /// This callback method is called when the local entity control by the client has been enabled or disabled. + /// See the Entity.controlledBy() method in the CellApp server code for more infomation. + /// + /// + /// 对于玩家自身来说,它表示是否自己被其它玩家控制了; + /// 对于其它entity来说,表示我本机是否控制了这个entity + /// + public virtual void onControlled(bool isControlled_) + { + + } + } + +} diff --git a/Assets/Plugins/kbengine_unity3d_plugins/EntityCall.cs b/Assets/Plugins/kbengine_unity3d_plugins/EntityCall.cs index 9ce603d..9132f64 100644 --- a/Assets/Plugins/kbengine_unity3d_plugins/EntityCall.cs +++ b/Assets/Plugins/kbengine_unity3d_plugins/EntityCall.cs @@ -1,116 +1,116 @@ -namespace KBEngine -{ - using UnityEngine; - using System; - using System.Collections; - using System.Collections.Generic; - - /* - 实体的EntityCall - 关于EntityCall请参考API手册中对它的描述 - https://github.com/kbengine/kbengine/tree/master/docs/api - */ - public class EntityCall - { - // EntityCall的类别 - public enum ENTITYCALL_TYPE - { - ENTITYCALL_TYPE_CELL = 0, // CELL_ENTITYCALL_TYPE - ENTITYCALL_TYPE_BASE = 1 // BASE_ENTITYCALL_TYPE - } - - public Int32 id = 0; - public string className = ""; - public ENTITYCALL_TYPE type = ENTITYCALL_TYPE.ENTITYCALL_TYPE_CELL; - - public Bundle bundle = null; - - public EntityCall(Int32 eid, string ename) - { - id = eid; - className = ename; - } - - public virtual void __init__() - { - } - - public virtual bool isBase() - { - return type == ENTITYCALL_TYPE.ENTITYCALL_TYPE_BASE; - } - - public virtual bool isCell() - { - return type == ENTITYCALL_TYPE.ENTITYCALL_TYPE_CELL; - } - - /* - 创建新的mail - */ - public Bundle newCall() - { - if(bundle == null) - bundle = Bundle.createObject(); - - if(isCell()) - bundle.newMessage(Messages.messages["Baseapp_onRemoteCallCellMethodFromClient"]); - else - bundle.newMessage(Messages.messages["Entity_onRemoteMethodCall"]); - - bundle.writeInt32(this.id); - - return bundle; - } - - /* - 向服务端发送这个mail - */ - public void sendCall(Bundle inbundle) - { - if(inbundle == null) - inbundle = bundle; - - inbundle.send(KBEngineApp.app.networkInterface()); - - if(inbundle == bundle) - bundle = null; - } - - public Bundle newCall(string methodName, UInt16 entitycomponentPropertyID = 0) - { - if(KBEngineApp.app.currserver == "loginapp") - { - Dbg.ERROR_MSG(className + "::newCall(" + methodName + "), currserver=!" + KBEngineApp.app.currserver); - return null; - } - - ScriptModule module = null; - if(!EntityDef.moduledefs.TryGetValue(className, out module)) - { - Dbg.ERROR_MSG(className + "::newCall: entity-module(" + className + ") error, can not find from EntityDef.moduledefs"); - return null; - } - - Method method = null; - - if(isCell()) - { - method = module.cell_methods[methodName]; - } - else - { - method = module.base_methods[methodName]; - } - - UInt16 methodID = method.methodUtype; - - newCall(); - - bundle.writeUint16(entitycomponentPropertyID); - bundle.writeUint16(methodID); - return bundle; - } - } - -} +namespace KBEngine +{ + using UnityEngine; + using System; + using System.Collections; + using System.Collections.Generic; + + /* + 实体的EntityCall + 关于EntityCall请参考API手册中对它的描述 + https://github.com/kbengine/kbengine/tree/master/docs/api + */ + public class EntityCall + { + // EntityCall的类别 + public enum ENTITYCALL_TYPE + { + ENTITYCALL_TYPE_CELL = 0, // CELL_ENTITYCALL_TYPE + ENTITYCALL_TYPE_BASE = 1 // BASE_ENTITYCALL_TYPE + } + + public Int32 id = 0; + public string className = ""; + public ENTITYCALL_TYPE type = ENTITYCALL_TYPE.ENTITYCALL_TYPE_CELL; + + public Bundle bundle = null; + + public EntityCall(Int32 eid, string ename) + { + id = eid; + className = ename; + } + + public virtual void __init__() + { + } + + public virtual bool isBase() + { + return type == ENTITYCALL_TYPE.ENTITYCALL_TYPE_BASE; + } + + public virtual bool isCell() + { + return type == ENTITYCALL_TYPE.ENTITYCALL_TYPE_CELL; + } + + /* + 创建新的mail + */ + public Bundle newCall() + { + if(bundle == null) + bundle = Bundle.createObject(); + + if(isCell()) + bundle.newMessage(Messages.messages["Baseapp_onRemoteCallCellMethodFromClient"]); + else + bundle.newMessage(Messages.messages["Entity_onRemoteMethodCall"]); + + bundle.writeInt32(this.id); + + return bundle; + } + + /* + 向服务端发送这个mail + */ + public void sendCall(Bundle inbundle) + { + if(inbundle == null) + inbundle = bundle; + + inbundle.send(KBEngineApp.app.networkInterface()); + + if(inbundle == bundle) + bundle = null; + } + + public Bundle newCall(string methodName, UInt16 entitycomponentPropertyID = 0) + { + if(KBEngineApp.app.currserver == "loginapp") + { + Dbg.ERROR_MSG(className + "::newCall(" + methodName + "), currserver=!" + KBEngineApp.app.currserver); + return null; + } + + ScriptModule module = null; + if(!EntityDef.moduledefs.TryGetValue(className, out module)) + { + Dbg.ERROR_MSG(className + "::newCall: entity-module(" + className + ") error, can not find from EntityDef.moduledefs"); + return null; + } + + Method method = null; + + if(isCell()) + { + method = module.cell_methods[methodName]; + } + else + { + method = module.base_methods[methodName]; + } + + UInt16 methodID = method.methodUtype; + + newCall(); + + bundle.writeUint16(entitycomponentPropertyID); + bundle.writeUint16(methodID); + return bundle; + } + } + +} diff --git a/Assets/Plugins/kbengine_unity3d_plugins/EntityCallAccountBase.cs b/Assets/Plugins/kbengine_unity3d_plugins/EntityCallAccountBase.cs index 451a0c9..b432881 100644 --- a/Assets/Plugins/kbengine_unity3d_plugins/EntityCallAccountBase.cs +++ b/Assets/Plugins/kbengine_unity3d_plugins/EntityCallAccountBase.cs @@ -1,85 +1,85 @@ -/* - Generated by KBEngine! - Please do not modify this file! - - tools = kbcmd -*/ - -namespace KBEngine -{ - using UnityEngine; - using System; - using System.Collections; - using System.Collections.Generic; - - // defined in */scripts/entity_defs/Account.def - public class EntityBaseEntityCall_AccountBase : EntityCall - { - - public EntityBaseEntityCall_AccountBase(Int32 eid, string ename) : base(eid, ename) - { - type = ENTITYCALL_TYPE.ENTITYCALL_TYPE_BASE; - } - - public void reqAvatarList() - { - Bundle pBundle = newCall("reqAvatarList", 0); - if(pBundle == null) - return; - - sendCall(null); - } - - public void reqCreateAvatar(Byte arg1, string arg2) - { - Bundle pBundle = newCall("reqCreateAvatar", 0); - if(pBundle == null) - return; - - bundle.writeUint8(arg1); - bundle.writeUnicode(arg2); - sendCall(null); - } - - public void reqRemoveAvatar(string arg1) - { - Bundle pBundle = newCall("reqRemoveAvatar", 0); - if(pBundle == null) - return; - - bundle.writeUnicode(arg1); - sendCall(null); - } - - public void reqRemoveAvatarDBID(UInt64 arg1) - { - Bundle pBundle = newCall("reqRemoveAvatarDBID", 0); - if(pBundle == null) - return; - - bundle.writeUint64(arg1); - sendCall(null); - } - - public void selectAvatarGame(UInt64 arg1) - { - Bundle pBundle = newCall("selectAvatarGame", 0); - if(pBundle == null) - return; - - bundle.writeUint64(arg1); - sendCall(null); - } - - } - - public class EntityCellEntityCall_AccountBase : EntityCall - { - - public EntityCellEntityCall_AccountBase(Int32 eid, string ename) : base(eid, ename) - { - type = ENTITYCALL_TYPE.ENTITYCALL_TYPE_CELL; - } - - } - } +/* + Generated by KBEngine! + Please do not modify this file! + + tools = kbcmd +*/ + +namespace KBEngine +{ + using UnityEngine; + using System; + using System.Collections; + using System.Collections.Generic; + + // defined in */scripts/entity_defs/Account.def + public class EntityBaseEntityCall_AccountBase : EntityCall + { + + public EntityBaseEntityCall_AccountBase(Int32 eid, string ename) : base(eid, ename) + { + type = ENTITYCALL_TYPE.ENTITYCALL_TYPE_BASE; + } + + public void reqAvatarList() + { + Bundle pBundle = newCall("reqAvatarList", 0); + if(pBundle == null) + return; + + sendCall(null); + } + + public void reqCreateAvatar(Byte arg1, string arg2) + { + Bundle pBundle = newCall("reqCreateAvatar", 0); + if(pBundle == null) + return; + + bundle.writeUint8(arg1); + bundle.writeUnicode(arg2); + sendCall(null); + } + + public void reqRemoveAvatar(string arg1) + { + Bundle pBundle = newCall("reqRemoveAvatar", 0); + if(pBundle == null) + return; + + bundle.writeUnicode(arg1); + sendCall(null); + } + + public void reqRemoveAvatarDBID(UInt64 arg1) + { + Bundle pBundle = newCall("reqRemoveAvatarDBID", 0); + if(pBundle == null) + return; + + bundle.writeUint64(arg1); + sendCall(null); + } + + public void selectAvatarGame(UInt64 arg1) + { + Bundle pBundle = newCall("selectAvatarGame", 0); + if(pBundle == null) + return; + + bundle.writeUint64(arg1); + sendCall(null); + } + + } + + public class EntityCellEntityCall_AccountBase : EntityCall + { + + public EntityCellEntityCall_AccountBase(Int32 eid, string ename) : base(eid, ename) + { + type = ENTITYCALL_TYPE.ENTITYCALL_TYPE_CELL; + } + + } + } diff --git a/Assets/Plugins/kbengine_unity3d_plugins/EntityCallAvatarBase.cs b/Assets/Plugins/kbengine_unity3d_plugins/EntityCallAvatarBase.cs index 638138c..a83e091 100644 --- a/Assets/Plugins/kbengine_unity3d_plugins/EntityCallAvatarBase.cs +++ b/Assets/Plugins/kbengine_unity3d_plugins/EntityCallAvatarBase.cs @@ -1,97 +1,97 @@ -/* - Generated by KBEngine! - Please do not modify this file! - - tools = kbcmd -*/ - -namespace KBEngine -{ - using UnityEngine; - using System; - using System.Collections; - using System.Collections.Generic; - - // defined in */scripts/entity_defs/Avatar.def - public class EntityBaseEntityCall_AvatarBase : EntityCall - { - public EntityBaseEntityCall_TestBase component1 = null; - public EntityBaseEntityCall_TestBase component2 = null; - public EntityBaseEntityCall_TestNoBaseBase component3 = null; - - public EntityBaseEntityCall_AvatarBase(Int32 eid, string ename) : base(eid, ename) - { - component1 = new EntityBaseEntityCall_TestBase(16, id); - component2 = new EntityBaseEntityCall_TestBase(21, id); - component3 = new EntityBaseEntityCall_TestNoBaseBase(22, id); - type = ENTITYCALL_TYPE.ENTITYCALL_TYPE_BASE; - } - - } - - public class EntityCellEntityCall_AvatarBase : EntityCall - { - public EntityCellEntityCall_TestBase component1 = null; - public EntityCellEntityCall_TestBase component2 = null; - public EntityCellEntityCall_TestNoBaseBase component3 = null; - - public EntityCellEntityCall_AvatarBase(Int32 eid, string ename) : base(eid, ename) - { - component1 = new EntityCellEntityCall_TestBase(16, id); - component2 = new EntityCellEntityCall_TestBase(21, id); - component3 = new EntityCellEntityCall_TestNoBaseBase(22, id); - type = ENTITYCALL_TYPE.ENTITYCALL_TYPE_CELL; - } - - public void dialog(Int32 arg1, UInt32 arg2) - { - Bundle pBundle = newCall("dialog", 0); - if(pBundle == null) - return; - - bundle.writeInt32(arg1); - bundle.writeUint32(arg2); - sendCall(null); - } - - public void jump() - { - Bundle pBundle = newCall("jump", 0); - if(pBundle == null) - return; - - sendCall(null); - } - - public void relive(Byte arg1) - { - Bundle pBundle = newCall("relive", 0); - if(pBundle == null) - return; - - bundle.writeUint8(arg1); - sendCall(null); - } - - public void requestPull() - { - Bundle pBundle = newCall("requestPull", 0); - if(pBundle == null) - return; - - sendCall(null); - } - - public void useTargetSkill(Int32 arg1, Int32 arg2) - { - Bundle pBundle = newCall("useTargetSkill", 0); - if(pBundle == null) - return; - - bundle.writeInt32(arg1); - bundle.writeInt32(arg2); - sendCall(null); - } - - } - } +/* + Generated by KBEngine! + Please do not modify this file! + + tools = kbcmd +*/ + +namespace KBEngine +{ + using UnityEngine; + using System; + using System.Collections; + using System.Collections.Generic; + + // defined in */scripts/entity_defs/Avatar.def + public class EntityBaseEntityCall_AvatarBase : EntityCall + { + public EntityBaseEntityCall_TestBase component1 = null; + public EntityBaseEntityCall_TestBase component2 = null; + public EntityBaseEntityCall_TestNoBaseBase component3 = null; + + public EntityBaseEntityCall_AvatarBase(Int32 eid, string ename) : base(eid, ename) + { + component1 = new EntityBaseEntityCall_TestBase(16, id); + component2 = new EntityBaseEntityCall_TestBase(21, id); + component3 = new EntityBaseEntityCall_TestNoBaseBase(22, id); + type = ENTITYCALL_TYPE.ENTITYCALL_TYPE_BASE; + } + + } + + public class EntityCellEntityCall_AvatarBase : EntityCall + { + public EntityCellEntityCall_TestBase component1 = null; + public EntityCellEntityCall_TestBase component2 = null; + public EntityCellEntityCall_TestNoBaseBase component3 = null; + + public EntityCellEntityCall_AvatarBase(Int32 eid, string ename) : base(eid, ename) + { + component1 = new EntityCellEntityCall_TestBase(16, id); + component2 = new EntityCellEntityCall_TestBase(21, id); + component3 = new EntityCellEntityCall_TestNoBaseBase(22, id); + type = ENTITYCALL_TYPE.ENTITYCALL_TYPE_CELL; + } + + public void dialog(Int32 arg1, UInt32 arg2) + { + Bundle pBundle = newCall("dialog", 0); + if(pBundle == null) + return; + + bundle.writeInt32(arg1); + bundle.writeUint32(arg2); + sendCall(null); + } + + public void jump() + { + Bundle pBundle = newCall("jump", 0); + if(pBundle == null) + return; + + sendCall(null); + } + + public void relive(Byte arg1) + { + Bundle pBundle = newCall("relive", 0); + if(pBundle == null) + return; + + bundle.writeUint8(arg1); + sendCall(null); + } + + public void requestPull() + { + Bundle pBundle = newCall("requestPull", 0); + if(pBundle == null) + return; + + sendCall(null); + } + + public void useTargetSkill(Int32 arg1, Int32 arg2) + { + Bundle pBundle = newCall("useTargetSkill", 0); + if(pBundle == null) + return; + + bundle.writeInt32(arg1); + bundle.writeInt32(arg2); + sendCall(null); + } + + } + } diff --git a/Assets/Plugins/kbengine_unity3d_plugins/EntityCallGateBase.cs b/Assets/Plugins/kbengine_unity3d_plugins/EntityCallGateBase.cs index 28ea413..371840f 100644 --- a/Assets/Plugins/kbengine_unity3d_plugins/EntityCallGateBase.cs +++ b/Assets/Plugins/kbengine_unity3d_plugins/EntityCallGateBase.cs @@ -1,35 +1,35 @@ -/* - Generated by KBEngine! - Please do not modify this file! - - tools = kbcmd -*/ - -namespace KBEngine -{ - using UnityEngine; - using System; - using System.Collections; - using System.Collections.Generic; - - // defined in */scripts/entity_defs/Gate.def - public class EntityBaseEntityCall_GateBase : EntityCall - { - - public EntityBaseEntityCall_GateBase(Int32 eid, string ename) : base(eid, ename) - { - type = ENTITYCALL_TYPE.ENTITYCALL_TYPE_BASE; - } - - } - - public class EntityCellEntityCall_GateBase : EntityCall - { - - public EntityCellEntityCall_GateBase(Int32 eid, string ename) : base(eid, ename) - { - type = ENTITYCALL_TYPE.ENTITYCALL_TYPE_CELL; - } - - } - } +/* + Generated by KBEngine! + Please do not modify this file! + + tools = kbcmd +*/ + +namespace KBEngine +{ + using UnityEngine; + using System; + using System.Collections; + using System.Collections.Generic; + + // defined in */scripts/entity_defs/Gate.def + public class EntityBaseEntityCall_GateBase : EntityCall + { + + public EntityBaseEntityCall_GateBase(Int32 eid, string ename) : base(eid, ename) + { + type = ENTITYCALL_TYPE.ENTITYCALL_TYPE_BASE; + } + + } + + public class EntityCellEntityCall_GateBase : EntityCall + { + + public EntityCellEntityCall_GateBase(Int32 eid, string ename) : base(eid, ename) + { + type = ENTITYCALL_TYPE.ENTITYCALL_TYPE_CELL; + } + + } + } diff --git a/Assets/Plugins/kbengine_unity3d_plugins/EntityCallMonsterBase.cs b/Assets/Plugins/kbengine_unity3d_plugins/EntityCallMonsterBase.cs index b33882d..653b3f5 100644 --- a/Assets/Plugins/kbengine_unity3d_plugins/EntityCallMonsterBase.cs +++ b/Assets/Plugins/kbengine_unity3d_plugins/EntityCallMonsterBase.cs @@ -1,35 +1,35 @@ -/* - Generated by KBEngine! - Please do not modify this file! - - tools = kbcmd -*/ - -namespace KBEngine -{ - using UnityEngine; - using System; - using System.Collections; - using System.Collections.Generic; - - // defined in */scripts/entity_defs/Monster.def - public class EntityBaseEntityCall_MonsterBase : EntityCall - { - - public EntityBaseEntityCall_MonsterBase(Int32 eid, string ename) : base(eid, ename) - { - type = ENTITYCALL_TYPE.ENTITYCALL_TYPE_BASE; - } - - } - - public class EntityCellEntityCall_MonsterBase : EntityCall - { - - public EntityCellEntityCall_MonsterBase(Int32 eid, string ename) : base(eid, ename) - { - type = ENTITYCALL_TYPE.ENTITYCALL_TYPE_CELL; - } - - } - } +/* + Generated by KBEngine! + Please do not modify this file! + + tools = kbcmd +*/ + +namespace KBEngine +{ + using UnityEngine; + using System; + using System.Collections; + using System.Collections.Generic; + + // defined in */scripts/entity_defs/Monster.def + public class EntityBaseEntityCall_MonsterBase : EntityCall + { + + public EntityBaseEntityCall_MonsterBase(Int32 eid, string ename) : base(eid, ename) + { + type = ENTITYCALL_TYPE.ENTITYCALL_TYPE_BASE; + } + + } + + public class EntityCellEntityCall_MonsterBase : EntityCall + { + + public EntityCellEntityCall_MonsterBase(Int32 eid, string ename) : base(eid, ename) + { + type = ENTITYCALL_TYPE.ENTITYCALL_TYPE_CELL; + } + + } + } diff --git a/Assets/Plugins/kbengine_unity3d_plugins/EntityCallNPCBase.cs b/Assets/Plugins/kbengine_unity3d_plugins/EntityCallNPCBase.cs index 6b9b7ef..a155781 100644 --- a/Assets/Plugins/kbengine_unity3d_plugins/EntityCallNPCBase.cs +++ b/Assets/Plugins/kbengine_unity3d_plugins/EntityCallNPCBase.cs @@ -1,35 +1,35 @@ -/* - Generated by KBEngine! - Please do not modify this file! - - tools = kbcmd -*/ - -namespace KBEngine -{ - using UnityEngine; - using System; - using System.Collections; - using System.Collections.Generic; - - // defined in */scripts/entity_defs/NPC.def - public class EntityBaseEntityCall_NPCBase : EntityCall - { - - public EntityBaseEntityCall_NPCBase(Int32 eid, string ename) : base(eid, ename) - { - type = ENTITYCALL_TYPE.ENTITYCALL_TYPE_BASE; - } - - } - - public class EntityCellEntityCall_NPCBase : EntityCall - { - - public EntityCellEntityCall_NPCBase(Int32 eid, string ename) : base(eid, ename) - { - type = ENTITYCALL_TYPE.ENTITYCALL_TYPE_CELL; - } - - } - } +/* + Generated by KBEngine! + Please do not modify this file! + + tools = kbcmd +*/ + +namespace KBEngine +{ + using UnityEngine; + using System; + using System.Collections; + using System.Collections.Generic; + + // defined in */scripts/entity_defs/NPC.def + public class EntityBaseEntityCall_NPCBase : EntityCall + { + + public EntityBaseEntityCall_NPCBase(Int32 eid, string ename) : base(eid, ename) + { + type = ENTITYCALL_TYPE.ENTITYCALL_TYPE_BASE; + } + + } + + public class EntityCellEntityCall_NPCBase : EntityCall + { + + public EntityCellEntityCall_NPCBase(Int32 eid, string ename) : base(eid, ename) + { + type = ENTITYCALL_TYPE.ENTITYCALL_TYPE_CELL; + } + + } + } diff --git a/Assets/Plugins/kbengine_unity3d_plugins/EntityCallSpaceBase.cs b/Assets/Plugins/kbengine_unity3d_plugins/EntityCallSpaceBase.cs index 9b965e5..8e5dc35 100644 --- a/Assets/Plugins/kbengine_unity3d_plugins/EntityCallSpaceBase.cs +++ b/Assets/Plugins/kbengine_unity3d_plugins/EntityCallSpaceBase.cs @@ -1,35 +1,35 @@ -/* - Generated by KBEngine! - Please do not modify this file! - - tools = kbcmd -*/ - -namespace KBEngine -{ - using UnityEngine; - using System; - using System.Collections; - using System.Collections.Generic; - - // defined in */scripts/entity_defs/Space.def - public class EntityBaseEntityCall_SpaceBase : EntityCall - { - - public EntityBaseEntityCall_SpaceBase(Int32 eid, string ename) : base(eid, ename) - { - type = ENTITYCALL_TYPE.ENTITYCALL_TYPE_BASE; - } - - } - - public class EntityCellEntityCall_SpaceBase : EntityCall - { - - public EntityCellEntityCall_SpaceBase(Int32 eid, string ename) : base(eid, ename) - { - type = ENTITYCALL_TYPE.ENTITYCALL_TYPE_CELL; - } - - } - } +/* + Generated by KBEngine! + Please do not modify this file! + + tools = kbcmd +*/ + +namespace KBEngine +{ + using UnityEngine; + using System; + using System.Collections; + using System.Collections.Generic; + + // defined in */scripts/entity_defs/Space.def + public class EntityBaseEntityCall_SpaceBase : EntityCall + { + + public EntityBaseEntityCall_SpaceBase(Int32 eid, string ename) : base(eid, ename) + { + type = ENTITYCALL_TYPE.ENTITYCALL_TYPE_BASE; + } + + } + + public class EntityCellEntityCall_SpaceBase : EntityCall + { + + public EntityCellEntityCall_SpaceBase(Int32 eid, string ename) : base(eid, ename) + { + type = ENTITYCALL_TYPE.ENTITYCALL_TYPE_CELL; + } + + } + } diff --git a/Assets/Plugins/kbengine_unity3d_plugins/EntityCallSpaceDuplicateBase.cs b/Assets/Plugins/kbengine_unity3d_plugins/EntityCallSpaceDuplicateBase.cs index 75e7485..c60d26e 100644 --- a/Assets/Plugins/kbengine_unity3d_plugins/EntityCallSpaceDuplicateBase.cs +++ b/Assets/Plugins/kbengine_unity3d_plugins/EntityCallSpaceDuplicateBase.cs @@ -1,35 +1,35 @@ -/* - Generated by KBEngine! - Please do not modify this file! - - tools = kbcmd -*/ - -namespace KBEngine -{ - using UnityEngine; - using System; - using System.Collections; - using System.Collections.Generic; - - // defined in */scripts/entity_defs/SpaceDuplicate.def - public class EntityBaseEntityCall_SpaceDuplicateBase : EntityCall - { - - public EntityBaseEntityCall_SpaceDuplicateBase(Int32 eid, string ename) : base(eid, ename) - { - type = ENTITYCALL_TYPE.ENTITYCALL_TYPE_BASE; - } - - } - - public class EntityCellEntityCall_SpaceDuplicateBase : EntityCall - { - - public EntityCellEntityCall_SpaceDuplicateBase(Int32 eid, string ename) : base(eid, ename) - { - type = ENTITYCALL_TYPE.ENTITYCALL_TYPE_CELL; - } - - } - } +/* + Generated by KBEngine! + Please do not modify this file! + + tools = kbcmd +*/ + +namespace KBEngine +{ + using UnityEngine; + using System; + using System.Collections; + using System.Collections.Generic; + + // defined in */scripts/entity_defs/SpaceDuplicate.def + public class EntityBaseEntityCall_SpaceDuplicateBase : EntityCall + { + + public EntityBaseEntityCall_SpaceDuplicateBase(Int32 eid, string ename) : base(eid, ename) + { + type = ENTITYCALL_TYPE.ENTITYCALL_TYPE_BASE; + } + + } + + public class EntityCellEntityCall_SpaceDuplicateBase : EntityCall + { + + public EntityCellEntityCall_SpaceDuplicateBase(Int32 eid, string ename) : base(eid, ename) + { + type = ENTITYCALL_TYPE.ENTITYCALL_TYPE_CELL; + } + + } + } diff --git a/Assets/Plugins/kbengine_unity3d_plugins/EntityCallSpacesBase.cs b/Assets/Plugins/kbengine_unity3d_plugins/EntityCallSpacesBase.cs index 6ab9314..098a476 100644 --- a/Assets/Plugins/kbengine_unity3d_plugins/EntityCallSpacesBase.cs +++ b/Assets/Plugins/kbengine_unity3d_plugins/EntityCallSpacesBase.cs @@ -1,35 +1,35 @@ -/* - Generated by KBEngine! - Please do not modify this file! - - tools = kbcmd -*/ - -namespace KBEngine -{ - using UnityEngine; - using System; - using System.Collections; - using System.Collections.Generic; - - // defined in */scripts/entity_defs/Spaces.def - public class EntityBaseEntityCall_SpacesBase : EntityCall - { - - public EntityBaseEntityCall_SpacesBase(Int32 eid, string ename) : base(eid, ename) - { - type = ENTITYCALL_TYPE.ENTITYCALL_TYPE_BASE; - } - - } - - public class EntityCellEntityCall_SpacesBase : EntityCall - { - - public EntityCellEntityCall_SpacesBase(Int32 eid, string ename) : base(eid, ename) - { - type = ENTITYCALL_TYPE.ENTITYCALL_TYPE_CELL; - } - - } - } +/* + Generated by KBEngine! + Please do not modify this file! + + tools = kbcmd +*/ + +namespace KBEngine +{ + using UnityEngine; + using System; + using System.Collections; + using System.Collections.Generic; + + // defined in */scripts/entity_defs/Spaces.def + public class EntityBaseEntityCall_SpacesBase : EntityCall + { + + public EntityBaseEntityCall_SpacesBase(Int32 eid, string ename) : base(eid, ename) + { + type = ENTITYCALL_TYPE.ENTITYCALL_TYPE_BASE; + } + + } + + public class EntityCellEntityCall_SpacesBase : EntityCall + { + + public EntityCellEntityCall_SpacesBase(Int32 eid, string ename) : base(eid, ename) + { + type = ENTITYCALL_TYPE.ENTITYCALL_TYPE_CELL; + } + + } + } diff --git a/Assets/Plugins/kbengine_unity3d_plugins/EntityCallSpawnPointBase.cs b/Assets/Plugins/kbengine_unity3d_plugins/EntityCallSpawnPointBase.cs index 9570212..e772016 100644 --- a/Assets/Plugins/kbengine_unity3d_plugins/EntityCallSpawnPointBase.cs +++ b/Assets/Plugins/kbengine_unity3d_plugins/EntityCallSpawnPointBase.cs @@ -1,35 +1,35 @@ -/* - Generated by KBEngine! - Please do not modify this file! - - tools = kbcmd -*/ - -namespace KBEngine -{ - using UnityEngine; - using System; - using System.Collections; - using System.Collections.Generic; - - // defined in */scripts/entity_defs/SpawnPoint.def - public class EntityBaseEntityCall_SpawnPointBase : EntityCall - { - - public EntityBaseEntityCall_SpawnPointBase(Int32 eid, string ename) : base(eid, ename) - { - type = ENTITYCALL_TYPE.ENTITYCALL_TYPE_BASE; - } - - } - - public class EntityCellEntityCall_SpawnPointBase : EntityCall - { - - public EntityCellEntityCall_SpawnPointBase(Int32 eid, string ename) : base(eid, ename) - { - type = ENTITYCALL_TYPE.ENTITYCALL_TYPE_CELL; - } - - } - } +/* + Generated by KBEngine! + Please do not modify this file! + + tools = kbcmd +*/ + +namespace KBEngine +{ + using UnityEngine; + using System; + using System.Collections; + using System.Collections.Generic; + + // defined in */scripts/entity_defs/SpawnPoint.def + public class EntityBaseEntityCall_SpawnPointBase : EntityCall + { + + public EntityBaseEntityCall_SpawnPointBase(Int32 eid, string ename) : base(eid, ename) + { + type = ENTITYCALL_TYPE.ENTITYCALL_TYPE_BASE; + } + + } + + public class EntityCellEntityCall_SpawnPointBase : EntityCall + { + + public EntityCellEntityCall_SpawnPointBase(Int32 eid, string ename) : base(eid, ename) + { + type = ENTITYCALL_TYPE.ENTITYCALL_TYPE_CELL; + } + + } + } diff --git a/Assets/Plugins/kbengine_unity3d_plugins/EntityCallTestBase.cs b/Assets/Plugins/kbengine_unity3d_plugins/EntityCallTestBase.cs index c1ee258..cb21101 100644 --- a/Assets/Plugins/kbengine_unity3d_plugins/EntityCallTestBase.cs +++ b/Assets/Plugins/kbengine_unity3d_plugins/EntityCallTestBase.cs @@ -1,60 +1,60 @@ -/* - Generated by KBEngine! - Please do not modify this file! - - tools = kbcmd -*/ - -namespace KBEngine -{ - using UnityEngine; - using System; - using System.Collections; - using System.Collections.Generic; - - // defined in */scripts/entity_defs/Test.def - public class EntityBaseEntityCall_TestBase : EntityCall - { - public UInt16 entityComponentPropertyID = 0; - - public EntityBaseEntityCall_TestBase(UInt16 ecpID, Int32 eid) : base(eid, "Test") - { - entityComponentPropertyID = ecpID; - type = ENTITYCALL_TYPE.ENTITYCALL_TYPE_BASE; - } - - public void say(Int32 arg1) - { - Bundle pBundle = newCall("say", entityComponentPropertyID); - if(pBundle == null) - return; - - bundle.writeInt32(arg1); - sendCall(null); - } - - } - - public class EntityCellEntityCall_TestBase : EntityCall - { - public UInt16 entityComponentPropertyID = 0; - - public EntityCellEntityCall_TestBase(UInt16 ecpID, Int32 eid) : base(eid, "Test") - { - entityComponentPropertyID = ecpID; - className = "Test"; - type = ENTITYCALL_TYPE.ENTITYCALL_TYPE_CELL; - } - - public void hello(Int32 arg1) - { - Bundle pBundle = newCall("hello", entityComponentPropertyID); - if(pBundle == null) - return; - - bundle.writeInt32(arg1); - sendCall(null); - } - - } - } +/* + Generated by KBEngine! + Please do not modify this file! + + tools = kbcmd +*/ + +namespace KBEngine +{ + using UnityEngine; + using System; + using System.Collections; + using System.Collections.Generic; + + // defined in */scripts/entity_defs/Test.def + public class EntityBaseEntityCall_TestBase : EntityCall + { + public UInt16 entityComponentPropertyID = 0; + + public EntityBaseEntityCall_TestBase(UInt16 ecpID, Int32 eid) : base(eid, "Test") + { + entityComponentPropertyID = ecpID; + type = ENTITYCALL_TYPE.ENTITYCALL_TYPE_BASE; + } + + public void say(Int32 arg1) + { + Bundle pBundle = newCall("say", entityComponentPropertyID); + if(pBundle == null) + return; + + bundle.writeInt32(arg1); + sendCall(null); + } + + } + + public class EntityCellEntityCall_TestBase : EntityCall + { + public UInt16 entityComponentPropertyID = 0; + + public EntityCellEntityCall_TestBase(UInt16 ecpID, Int32 eid) : base(eid, "Test") + { + entityComponentPropertyID = ecpID; + className = "Test"; + type = ENTITYCALL_TYPE.ENTITYCALL_TYPE_CELL; + } + + public void hello(Int32 arg1) + { + Bundle pBundle = newCall("hello", entityComponentPropertyID); + if(pBundle == null) + return; + + bundle.writeInt32(arg1); + sendCall(null); + } + + } + } diff --git a/Assets/Plugins/kbengine_unity3d_plugins/EntityCallTestNoBaseBase.cs b/Assets/Plugins/kbengine_unity3d_plugins/EntityCallTestNoBaseBase.cs index 7ce8b93..c8630ec 100644 --- a/Assets/Plugins/kbengine_unity3d_plugins/EntityCallTestNoBaseBase.cs +++ b/Assets/Plugins/kbengine_unity3d_plugins/EntityCallTestNoBaseBase.cs @@ -1,50 +1,50 @@ -/* - Generated by KBEngine! - Please do not modify this file! - - tools = kbcmd -*/ - -namespace KBEngine -{ - using UnityEngine; - using System; - using System.Collections; - using System.Collections.Generic; - - // defined in */scripts/entity_defs/TestNoBase.def - public class EntityBaseEntityCall_TestNoBaseBase : EntityCall - { - public UInt16 entityComponentPropertyID = 0; - - public EntityBaseEntityCall_TestNoBaseBase(UInt16 ecpID, Int32 eid) : base(eid, "TestNoBase") - { - entityComponentPropertyID = ecpID; - type = ENTITYCALL_TYPE.ENTITYCALL_TYPE_BASE; - } - - } - - public class EntityCellEntityCall_TestNoBaseBase : EntityCall - { - public UInt16 entityComponentPropertyID = 0; - - public EntityCellEntityCall_TestNoBaseBase(UInt16 ecpID, Int32 eid) : base(eid, "TestNoBase") - { - entityComponentPropertyID = ecpID; - className = "TestNoBase"; - type = ENTITYCALL_TYPE.ENTITYCALL_TYPE_CELL; - } - - public void hello(Int32 arg1) - { - Bundle pBundle = newCall("hello", entityComponentPropertyID); - if(pBundle == null) - return; - - bundle.writeInt32(arg1); - sendCall(null); - } - - } - } +/* + Generated by KBEngine! + Please do not modify this file! + + tools = kbcmd +*/ + +namespace KBEngine +{ + using UnityEngine; + using System; + using System.Collections; + using System.Collections.Generic; + + // defined in */scripts/entity_defs/TestNoBase.def + public class EntityBaseEntityCall_TestNoBaseBase : EntityCall + { + public UInt16 entityComponentPropertyID = 0; + + public EntityBaseEntityCall_TestNoBaseBase(UInt16 ecpID, Int32 eid) : base(eid, "TestNoBase") + { + entityComponentPropertyID = ecpID; + type = ENTITYCALL_TYPE.ENTITYCALL_TYPE_BASE; + } + + } + + public class EntityCellEntityCall_TestNoBaseBase : EntityCall + { + public UInt16 entityComponentPropertyID = 0; + + public EntityCellEntityCall_TestNoBaseBase(UInt16 ecpID, Int32 eid) : base(eid, "TestNoBase") + { + entityComponentPropertyID = ecpID; + className = "TestNoBase"; + type = ENTITYCALL_TYPE.ENTITYCALL_TYPE_CELL; + } + + public void hello(Int32 arg1) + { + Bundle pBundle = newCall("hello", entityComponentPropertyID); + if(pBundle == null) + return; + + bundle.writeInt32(arg1); + sendCall(null); + } + + } + } diff --git a/Assets/Plugins/kbengine_unity3d_plugins/EntityComponent.cs b/Assets/Plugins/kbengine_unity3d_plugins/EntityComponent.cs index 1e8fbdf..7bf9157 100644 --- a/Assets/Plugins/kbengine_unity3d_plugins/EntityComponent.cs +++ b/Assets/Plugins/kbengine_unity3d_plugins/EntityComponent.cs @@ -1,72 +1,72 @@ -namespace KBEngine -{ - using UnityEngine; - using System; - using System.Collections; - using System.Collections.Generic; - using System.Threading; - - /* - 实体组件模块基础类 - */ - public class EntityComponent - { - public UInt16 entityComponentPropertyID = 0; - public UInt16 componentType = 0; - public Int32 ownerID = 0; - public Entity owner = null; - - public virtual void onAttached(Entity ownerEntity) - { - - } - - public virtual void onDetached(Entity ownerEntity) - { - - } - - public virtual void onEnterworld() - { - } - - public virtual void onLeaveworld() - { - } - - public virtual ScriptModule getScriptModule() - { - // 动态生成 - return null; - } - - public virtual void onRemoteMethodCall(UInt16 methodUtype, MemoryStream stream) - { - // 动态生成 - } - - public virtual void onUpdatePropertys(UInt16 propUtype, MemoryStream stream, int maxCount) - { - // 动态生成 - } - - public virtual void callPropertysSetMethods() - { - // 动态生成 - } - - public virtual void createFromStream(MemoryStream stream) - { - componentType = (UInt16)stream.readInt32(); - ownerID = stream.readInt32(); - - //UInt16 ComponentDescrsType; - stream.readUint16(); - - UInt16 count = stream.readUint16(); - - if(count > 0) - onUpdatePropertys(0, stream, count); - } - } +namespace KBEngine +{ + using UnityEngine; + using System; + using System.Collections; + using System.Collections.Generic; + using System.Threading; + + /* + 实体组件模块基础类 + */ + public class EntityComponent + { + public UInt16 entityComponentPropertyID = 0; + public UInt16 componentType = 0; + public Int32 ownerID = 0; + public Entity owner = null; + + public virtual void onAttached(Entity ownerEntity) + { + + } + + public virtual void onDetached(Entity ownerEntity) + { + + } + + public virtual void onEnterworld() + { + } + + public virtual void onLeaveworld() + { + } + + public virtual ScriptModule getScriptModule() + { + // 动态生成 + return null; + } + + public virtual void onRemoteMethodCall(UInt16 methodUtype, MemoryStream stream) + { + // 动态生成 + } + + public virtual void onUpdatePropertys(UInt16 propUtype, MemoryStream stream, int maxCount) + { + // 动态生成 + } + + public virtual void callPropertysSetMethods() + { + // 动态生成 + } + + public virtual void createFromStream(MemoryStream stream) + { + componentType = (UInt16)stream.readInt32(); + ownerID = stream.readInt32(); + + //UInt16 ComponentDescrsType; + stream.readUint16(); + + UInt16 count = stream.readUint16(); + + if(count > 0) + onUpdatePropertys(0, stream, count); + } + } } \ No newline at end of file diff --git a/Assets/Plugins/kbengine_unity3d_plugins/EntityDef.cs b/Assets/Plugins/kbengine_unity3d_plugins/EntityDef.cs index 1ae887b..6c3c546 100644 --- a/Assets/Plugins/kbengine_unity3d_plugins/EntityDef.cs +++ b/Assets/Plugins/kbengine_unity3d_plugins/EntityDef.cs @@ -1,1928 +1,1928 @@ -/* - Generated by KBEngine! - Please do not modify this file! - tools = kbcmd -*/ - -namespace KBEngine -{ - using UnityEngine; - using System; - using System.Collections; - using System.Collections.Generic; - - public class EntityDef - { - public static Dictionary datatype2id = new Dictionary(); - public static Dictionary datatypes = new Dictionary(); - public static Dictionary id2datatypes = new Dictionary(); - public static Dictionary entityclass = new Dictionary(); - public static Dictionary moduledefs = new Dictionary(); - public static Dictionary idmoduledefs = new Dictionary(); - - public static bool init() - { - initDataTypes(); - initDefTypes(); - initScriptModules(); - return true; - } - - public static bool reset() - { - clear(); - return init(); - } - - public static void clear() - { - datatype2id.Clear(); - datatypes.Clear(); - id2datatypes.Clear(); - entityclass.Clear(); - moduledefs.Clear(); - idmoduledefs.Clear(); - } - - public static void initDataTypes() - { - datatypes["UINT8"] = new DATATYPE_UINT8(); - datatypes["UINT16"] = new DATATYPE_UINT16(); - datatypes["UINT32"] = new DATATYPE_UINT32(); - datatypes["UINT64"] = new DATATYPE_UINT64(); - - datatypes["INT8"] = new DATATYPE_INT8(); - datatypes["INT16"] = new DATATYPE_INT16(); - datatypes["INT32"] = new DATATYPE_INT32(); - datatypes["INT64"] = new DATATYPE_INT64(); - - datatypes["FLOAT"] = new DATATYPE_FLOAT(); - datatypes["DOUBLE"] = new DATATYPE_DOUBLE(); - - datatypes["STRING"] = new DATATYPE_STRING(); - datatypes["VECTOR2"] = new DATATYPE_VECTOR2(); - - datatypes["VECTOR3"] = new DATATYPE_VECTOR3(); - - datatypes["VECTOR4"] = new DATATYPE_VECTOR4(); - datatypes["PYTHON"] = new DATATYPE_PYTHON(); - - datatypes["UNICODE"] = new DATATYPE_UNICODE(); - datatypes["ENTITYCALL"] = new DATATYPE_ENTITYCALL(); - - datatypes["BLOB"] = new DATATYPE_BLOB(); - } - - public static void initScriptModules() - { - ScriptModule pAccountModule = new ScriptModule("Account"); - EntityDef.moduledefs["Account"] = pAccountModule; - EntityDef.idmoduledefs[1] = pAccountModule; - - Property pAccount_position = new Property(); - pAccount_position.name = "position"; - pAccount_position.properUtype = 40000; - pAccount_position.properFlags = 4; - pAccount_position.aliasID = 1; - Vector3 Account_position_defval = new Vector3(); - pAccount_position.defaultVal = Account_position_defval; - pAccountModule.propertys["position"] = pAccount_position; - - pAccountModule.usePropertyDescrAlias = true; - pAccountModule.idpropertys[(UInt16)pAccount_position.aliasID] = pAccount_position; - - //Dbg.DEBUG_MSG("EntityDef::initScriptModules: add(Account), property(position / 40000)."); - - Property pAccount_direction = new Property(); - pAccount_direction.name = "direction"; - pAccount_direction.properUtype = 40001; - pAccount_direction.properFlags = 4; - pAccount_direction.aliasID = 2; - Vector3 Account_direction_defval = new Vector3(); - pAccount_direction.defaultVal = Account_direction_defval; - pAccountModule.propertys["direction"] = pAccount_direction; - - pAccountModule.usePropertyDescrAlias = true; - pAccountModule.idpropertys[(UInt16)pAccount_direction.aliasID] = pAccount_direction; - - //Dbg.DEBUG_MSG("EntityDef::initScriptModules: add(Account), property(direction / 40001)."); - - Property pAccount_spaceID = new Property(); - pAccount_spaceID.name = "spaceID"; - pAccount_spaceID.properUtype = 40002; - pAccount_spaceID.properFlags = 16; - pAccount_spaceID.aliasID = 3; - UInt32 Account_spaceID_defval; - UInt32.TryParse("", out Account_spaceID_defval); - pAccount_spaceID.defaultVal = Account_spaceID_defval; - pAccountModule.propertys["spaceID"] = pAccount_spaceID; - - pAccountModule.usePropertyDescrAlias = true; - pAccountModule.idpropertys[(UInt16)pAccount_spaceID.aliasID] = pAccount_spaceID; - - //Dbg.DEBUG_MSG("EntityDef::initScriptModules: add(Account), property(spaceID / 40002)."); - - Property pAccount_lastSelCharacter = new Property(); - pAccount_lastSelCharacter.name = "lastSelCharacter"; - pAccount_lastSelCharacter.properUtype = 2; - pAccount_lastSelCharacter.properFlags = 32; - pAccount_lastSelCharacter.aliasID = 4; - UInt64 Account_lastSelCharacter_defval; - UInt64.TryParse("0", out Account_lastSelCharacter_defval); - pAccount_lastSelCharacter.defaultVal = Account_lastSelCharacter_defval; - pAccountModule.propertys["lastSelCharacter"] = pAccount_lastSelCharacter; - - pAccountModule.usePropertyDescrAlias = true; - pAccountModule.idpropertys[(UInt16)pAccount_lastSelCharacter.aliasID] = pAccount_lastSelCharacter; - - //Dbg.DEBUG_MSG("EntityDef::initScriptModules: add(Account), property(lastSelCharacter / 2)."); - - List pAccount_onCreateAvatarResult_args = new List(); - pAccount_onCreateAvatarResult_args.Add(EntityDef.id2datatypes[2]); - pAccount_onCreateAvatarResult_args.Add(EntityDef.id2datatypes[25]); - - Method pAccount_onCreateAvatarResult = new Method(); - pAccount_onCreateAvatarResult.name = "onCreateAvatarResult"; - pAccount_onCreateAvatarResult.methodUtype = 10005; - pAccount_onCreateAvatarResult.aliasID = 1; - pAccount_onCreateAvatarResult.args = pAccount_onCreateAvatarResult_args; - - pAccountModule.methods["onCreateAvatarResult"] = pAccount_onCreateAvatarResult; - pAccountModule.useMethodDescrAlias = true; - pAccountModule.idmethods[(UInt16)pAccount_onCreateAvatarResult.aliasID] = pAccount_onCreateAvatarResult; - - //Dbg.DEBUG_MSG("EntityDef::initScriptModules: add(Account), method(onCreateAvatarResult / 10005)."); - - List pAccount_onRemoveAvatar_args = new List(); - pAccount_onRemoveAvatar_args.Add(EntityDef.id2datatypes[5]); - - Method pAccount_onRemoveAvatar = new Method(); - pAccount_onRemoveAvatar.name = "onRemoveAvatar"; - pAccount_onRemoveAvatar.methodUtype = 3; - pAccount_onRemoveAvatar.aliasID = 2; - pAccount_onRemoveAvatar.args = pAccount_onRemoveAvatar_args; - - pAccountModule.methods["onRemoveAvatar"] = pAccount_onRemoveAvatar; - pAccountModule.useMethodDescrAlias = true; - pAccountModule.idmethods[(UInt16)pAccount_onRemoveAvatar.aliasID] = pAccount_onRemoveAvatar; - - //Dbg.DEBUG_MSG("EntityDef::initScriptModules: add(Account), method(onRemoveAvatar / 3)."); - - List pAccount_onReqAvatarList_args = new List(); - pAccount_onReqAvatarList_args.Add(EntityDef.id2datatypes[26]); - - Method pAccount_onReqAvatarList = new Method(); - pAccount_onReqAvatarList.name = "onReqAvatarList"; - pAccount_onReqAvatarList.methodUtype = 10003; - pAccount_onReqAvatarList.aliasID = 3; - pAccount_onReqAvatarList.args = pAccount_onReqAvatarList_args; - - pAccountModule.methods["onReqAvatarList"] = pAccount_onReqAvatarList; - pAccountModule.useMethodDescrAlias = true; - pAccountModule.idmethods[(UInt16)pAccount_onReqAvatarList.aliasID] = pAccount_onReqAvatarList; - - //Dbg.DEBUG_MSG("EntityDef::initScriptModules: add(Account), method(onReqAvatarList / 10003)."); - - List pAccount_reqAvatarList_args = new List(); - - Method pAccount_reqAvatarList = new Method(); - pAccount_reqAvatarList.name = "reqAvatarList"; - pAccount_reqAvatarList.methodUtype = 10001; - pAccount_reqAvatarList.aliasID = -1; - pAccount_reqAvatarList.args = pAccount_reqAvatarList_args; - - pAccountModule.methods["reqAvatarList"] = pAccount_reqAvatarList; - pAccountModule.base_methods["reqAvatarList"] = pAccount_reqAvatarList; - - pAccountModule.idbase_methods[pAccount_reqAvatarList.methodUtype] = pAccount_reqAvatarList; - - //Dbg.DEBUG_MSG("EntityDef::initScriptModules: add(Account), method(reqAvatarList / 10001)."); - - List pAccount_reqCreateAvatar_args = new List(); - pAccount_reqCreateAvatar_args.Add(EntityDef.id2datatypes[2]); - pAccount_reqCreateAvatar_args.Add(EntityDef.id2datatypes[12]); - - Method pAccount_reqCreateAvatar = new Method(); - pAccount_reqCreateAvatar.name = "reqCreateAvatar"; - pAccount_reqCreateAvatar.methodUtype = 10002; - pAccount_reqCreateAvatar.aliasID = -1; - pAccount_reqCreateAvatar.args = pAccount_reqCreateAvatar_args; - - pAccountModule.methods["reqCreateAvatar"] = pAccount_reqCreateAvatar; - pAccountModule.base_methods["reqCreateAvatar"] = pAccount_reqCreateAvatar; - - pAccountModule.idbase_methods[pAccount_reqCreateAvatar.methodUtype] = pAccount_reqCreateAvatar; - - //Dbg.DEBUG_MSG("EntityDef::initScriptModules: add(Account), method(reqCreateAvatar / 10002)."); - - List pAccount_reqRemoveAvatar_args = new List(); - pAccount_reqRemoveAvatar_args.Add(EntityDef.id2datatypes[12]); - - Method pAccount_reqRemoveAvatar = new Method(); - pAccount_reqRemoveAvatar.name = "reqRemoveAvatar"; - pAccount_reqRemoveAvatar.methodUtype = 1; - pAccount_reqRemoveAvatar.aliasID = -1; - pAccount_reqRemoveAvatar.args = pAccount_reqRemoveAvatar_args; - - pAccountModule.methods["reqRemoveAvatar"] = pAccount_reqRemoveAvatar; - pAccountModule.base_methods["reqRemoveAvatar"] = pAccount_reqRemoveAvatar; - - pAccountModule.idbase_methods[pAccount_reqRemoveAvatar.methodUtype] = pAccount_reqRemoveAvatar; - - //Dbg.DEBUG_MSG("EntityDef::initScriptModules: add(Account), method(reqRemoveAvatar / 1)."); - - List pAccount_reqRemoveAvatarDBID_args = new List(); - pAccount_reqRemoveAvatarDBID_args.Add(EntityDef.id2datatypes[5]); - - Method pAccount_reqRemoveAvatarDBID = new Method(); - pAccount_reqRemoveAvatarDBID.name = "reqRemoveAvatarDBID"; - pAccount_reqRemoveAvatarDBID.methodUtype = 2; - pAccount_reqRemoveAvatarDBID.aliasID = -1; - pAccount_reqRemoveAvatarDBID.args = pAccount_reqRemoveAvatarDBID_args; - - pAccountModule.methods["reqRemoveAvatarDBID"] = pAccount_reqRemoveAvatarDBID; - pAccountModule.base_methods["reqRemoveAvatarDBID"] = pAccount_reqRemoveAvatarDBID; - - pAccountModule.idbase_methods[pAccount_reqRemoveAvatarDBID.methodUtype] = pAccount_reqRemoveAvatarDBID; - - //Dbg.DEBUG_MSG("EntityDef::initScriptModules: add(Account), method(reqRemoveAvatarDBID / 2)."); - - List pAccount_selectAvatarGame_args = new List(); - pAccount_selectAvatarGame_args.Add(EntityDef.id2datatypes[5]); - - Method pAccount_selectAvatarGame = new Method(); - pAccount_selectAvatarGame.name = "selectAvatarGame"; - pAccount_selectAvatarGame.methodUtype = 10004; - pAccount_selectAvatarGame.aliasID = -1; - pAccount_selectAvatarGame.args = pAccount_selectAvatarGame_args; - - pAccountModule.methods["selectAvatarGame"] = pAccount_selectAvatarGame; - pAccountModule.base_methods["selectAvatarGame"] = pAccount_selectAvatarGame; - - pAccountModule.idbase_methods[pAccount_selectAvatarGame.methodUtype] = pAccount_selectAvatarGame; - - //Dbg.DEBUG_MSG("EntityDef::initScriptModules: add(Account), method(selectAvatarGame / 10004)."); - - ScriptModule pAvatarModule = new ScriptModule("Avatar"); - EntityDef.moduledefs["Avatar"] = pAvatarModule; - EntityDef.idmoduledefs[2] = pAvatarModule; - - Property pAvatar_position = new Property(); - pAvatar_position.name = "position"; - pAvatar_position.properUtype = 40000; - pAvatar_position.properFlags = 4; - pAvatar_position.aliasID = 1; - Vector3 Avatar_position_defval = new Vector3(); - pAvatar_position.defaultVal = Avatar_position_defval; - pAvatarModule.propertys["position"] = pAvatar_position; - - pAvatarModule.usePropertyDescrAlias = true; - pAvatarModule.idpropertys[(UInt16)pAvatar_position.aliasID] = pAvatar_position; - - //Dbg.DEBUG_MSG("EntityDef::initScriptModules: add(Avatar), property(position / 40000)."); - - Property pAvatar_direction = new Property(); - pAvatar_direction.name = "direction"; - pAvatar_direction.properUtype = 40001; - pAvatar_direction.properFlags = 4; - pAvatar_direction.aliasID = 2; - Vector3 Avatar_direction_defval = new Vector3(); - pAvatar_direction.defaultVal = Avatar_direction_defval; - pAvatarModule.propertys["direction"] = pAvatar_direction; - - pAvatarModule.usePropertyDescrAlias = true; - pAvatarModule.idpropertys[(UInt16)pAvatar_direction.aliasID] = pAvatar_direction; - - //Dbg.DEBUG_MSG("EntityDef::initScriptModules: add(Avatar), property(direction / 40001)."); - - Property pAvatar_spaceID = new Property(); - pAvatar_spaceID.name = "spaceID"; - pAvatar_spaceID.properUtype = 40002; - pAvatar_spaceID.properFlags = 16; - pAvatar_spaceID.aliasID = 3; - UInt32 Avatar_spaceID_defval; - UInt32.TryParse("", out Avatar_spaceID_defval); - pAvatar_spaceID.defaultVal = Avatar_spaceID_defval; - pAvatarModule.propertys["spaceID"] = pAvatar_spaceID; - - pAvatarModule.usePropertyDescrAlias = true; - pAvatarModule.idpropertys[(UInt16)pAvatar_spaceID.aliasID] = pAvatar_spaceID; - - //Dbg.DEBUG_MSG("EntityDef::initScriptModules: add(Avatar), property(spaceID / 40002)."); - - Property pAvatar_HP = new Property(); - pAvatar_HP.name = "HP"; - pAvatar_HP.properUtype = 47001; - pAvatar_HP.properFlags = 4; - pAvatar_HP.aliasID = 4; - Int32 Avatar_HP_defval; - Int32.TryParse("0", out Avatar_HP_defval); - pAvatar_HP.defaultVal = Avatar_HP_defval; - pAvatarModule.propertys["HP"] = pAvatar_HP; - - pAvatarModule.usePropertyDescrAlias = true; - pAvatarModule.idpropertys[(UInt16)pAvatar_HP.aliasID] = pAvatar_HP; - - //Dbg.DEBUG_MSG("EntityDef::initScriptModules: add(Avatar), property(HP / 47001)."); - - Property pAvatar_HP_Max = new Property(); - pAvatar_HP_Max.name = "HP_Max"; - pAvatar_HP_Max.properUtype = 47002; - pAvatar_HP_Max.properFlags = 4; - pAvatar_HP_Max.aliasID = 5; - Int32 Avatar_HP_Max_defval; - Int32.TryParse("0", out Avatar_HP_Max_defval); - pAvatar_HP_Max.defaultVal = Avatar_HP_Max_defval; - pAvatarModule.propertys["HP_Max"] = pAvatar_HP_Max; - - pAvatarModule.usePropertyDescrAlias = true; - pAvatarModule.idpropertys[(UInt16)pAvatar_HP_Max.aliasID] = pAvatar_HP_Max; - - //Dbg.DEBUG_MSG("EntityDef::initScriptModules: add(Avatar), property(HP_Max / 47002)."); - - Property pAvatar_MP = new Property(); - pAvatar_MP.name = "MP"; - pAvatar_MP.properUtype = 47003; - pAvatar_MP.properFlags = 4; - pAvatar_MP.aliasID = 6; - Int32 Avatar_MP_defval; - Int32.TryParse("0", out Avatar_MP_defval); - pAvatar_MP.defaultVal = Avatar_MP_defval; - pAvatarModule.propertys["MP"] = pAvatar_MP; - - pAvatarModule.usePropertyDescrAlias = true; - pAvatarModule.idpropertys[(UInt16)pAvatar_MP.aliasID] = pAvatar_MP; - - //Dbg.DEBUG_MSG("EntityDef::initScriptModules: add(Avatar), property(MP / 47003)."); - - Property pAvatar_MP_Max = new Property(); - pAvatar_MP_Max.name = "MP_Max"; - pAvatar_MP_Max.properUtype = 47004; - pAvatar_MP_Max.properFlags = 4; - pAvatar_MP_Max.aliasID = 7; - Int32 Avatar_MP_Max_defval; - Int32.TryParse("0", out Avatar_MP_Max_defval); - pAvatar_MP_Max.defaultVal = Avatar_MP_Max_defval; - pAvatarModule.propertys["MP_Max"] = pAvatar_MP_Max; - - pAvatarModule.usePropertyDescrAlias = true; - pAvatarModule.idpropertys[(UInt16)pAvatar_MP_Max.aliasID] = pAvatar_MP_Max; - - //Dbg.DEBUG_MSG("EntityDef::initScriptModules: add(Avatar), property(MP_Max / 47004)."); - - Property pAvatar_component1 = new Property(); - pAvatar_component1.name = "component1"; - pAvatar_component1.properUtype = 16; - pAvatar_component1.properFlags = 253; - pAvatar_component1.aliasID = 8; - pAvatarModule.propertys["component1"] = pAvatar_component1; - - pAvatarModule.usePropertyDescrAlias = true; - pAvatarModule.idpropertys[(UInt16)pAvatar_component1.aliasID] = pAvatar_component1; - - //Dbg.DEBUG_MSG("EntityDef::initScriptModules: add(Avatar), property(component1 / 16)."); - - Property pAvatar_component2 = new Property(); - pAvatar_component2.name = "component2"; - pAvatar_component2.properUtype = 21; - pAvatar_component2.properFlags = 97; - pAvatar_component2.aliasID = 9; - pAvatarModule.propertys["component2"] = pAvatar_component2; - - pAvatarModule.usePropertyDescrAlias = true; - pAvatarModule.idpropertys[(UInt16)pAvatar_component2.aliasID] = pAvatar_component2; - - //Dbg.DEBUG_MSG("EntityDef::initScriptModules: add(Avatar), property(component2 / 21)."); - - Property pAvatar_component3 = new Property(); - pAvatar_component3.name = "component3"; - pAvatar_component3.properUtype = 22; - pAvatar_component3.properFlags = 157; - pAvatar_component3.aliasID = 10; - pAvatarModule.propertys["component3"] = pAvatar_component3; - - pAvatarModule.usePropertyDescrAlias = true; - pAvatarModule.idpropertys[(UInt16)pAvatar_component3.aliasID] = pAvatar_component3; - - //Dbg.DEBUG_MSG("EntityDef::initScriptModules: add(Avatar), property(component3 / 22)."); - - Property pAvatar_forbids = new Property(); - pAvatar_forbids.name = "forbids"; - pAvatar_forbids.properUtype = 47005; - pAvatar_forbids.properFlags = 4; - pAvatar_forbids.aliasID = 11; - Int32 Avatar_forbids_defval; - Int32.TryParse("0", out Avatar_forbids_defval); - pAvatar_forbids.defaultVal = Avatar_forbids_defval; - pAvatarModule.propertys["forbids"] = pAvatar_forbids; - - pAvatarModule.usePropertyDescrAlias = true; - pAvatarModule.idpropertys[(UInt16)pAvatar_forbids.aliasID] = pAvatar_forbids; - - //Dbg.DEBUG_MSG("EntityDef::initScriptModules: add(Avatar), property(forbids / 47005)."); - - Property pAvatar_level = new Property(); - pAvatar_level.name = "level"; - pAvatar_level.properUtype = 41002; - pAvatar_level.properFlags = 8; - pAvatar_level.aliasID = 12; - UInt16 Avatar_level_defval; - UInt16.TryParse("", out Avatar_level_defval); - pAvatar_level.defaultVal = Avatar_level_defval; - pAvatarModule.propertys["level"] = pAvatar_level; - - pAvatarModule.usePropertyDescrAlias = true; - pAvatarModule.idpropertys[(UInt16)pAvatar_level.aliasID] = pAvatar_level; - - //Dbg.DEBUG_MSG("EntityDef::initScriptModules: add(Avatar), property(level / 41002)."); - - Property pAvatar_modelID = new Property(); - pAvatar_modelID.name = "modelID"; - pAvatar_modelID.properUtype = 41006; - pAvatar_modelID.properFlags = 4; - pAvatar_modelID.aliasID = 13; - UInt32 Avatar_modelID_defval; - UInt32.TryParse("0", out Avatar_modelID_defval); - pAvatar_modelID.defaultVal = Avatar_modelID_defval; - pAvatarModule.propertys["modelID"] = pAvatar_modelID; - - pAvatarModule.usePropertyDescrAlias = true; - pAvatarModule.idpropertys[(UInt16)pAvatar_modelID.aliasID] = pAvatar_modelID; - - //Dbg.DEBUG_MSG("EntityDef::initScriptModules: add(Avatar), property(modelID / 41006)."); - - Property pAvatar_modelScale = new Property(); - pAvatar_modelScale.name = "modelScale"; - pAvatar_modelScale.properUtype = 41007; - pAvatar_modelScale.properFlags = 4; - pAvatar_modelScale.aliasID = 14; - Byte Avatar_modelScale_defval; - Byte.TryParse("30", out Avatar_modelScale_defval); - pAvatar_modelScale.defaultVal = Avatar_modelScale_defval; - pAvatarModule.propertys["modelScale"] = pAvatar_modelScale; - - pAvatarModule.usePropertyDescrAlias = true; - pAvatarModule.idpropertys[(UInt16)pAvatar_modelScale.aliasID] = pAvatar_modelScale; - - //Dbg.DEBUG_MSG("EntityDef::initScriptModules: add(Avatar), property(modelScale / 41007)."); - - Property pAvatar_moveSpeed = new Property(); - pAvatar_moveSpeed.name = "moveSpeed"; - pAvatar_moveSpeed.properUtype = 11; - pAvatar_moveSpeed.properFlags = 4; - pAvatar_moveSpeed.aliasID = 15; - Byte Avatar_moveSpeed_defval; - Byte.TryParse("50", out Avatar_moveSpeed_defval); - pAvatar_moveSpeed.defaultVal = Avatar_moveSpeed_defval; - pAvatarModule.propertys["moveSpeed"] = pAvatar_moveSpeed; - - pAvatarModule.usePropertyDescrAlias = true; - pAvatarModule.idpropertys[(UInt16)pAvatar_moveSpeed.aliasID] = pAvatar_moveSpeed; - - //Dbg.DEBUG_MSG("EntityDef::initScriptModules: add(Avatar), property(moveSpeed / 11)."); - - Property pAvatar_name = new Property(); - pAvatar_name.name = "name"; - pAvatar_name.properUtype = 41003; - pAvatar_name.properFlags = 4; - pAvatar_name.aliasID = 16; - string Avatar_name_defval = ""; - pAvatar_name.defaultVal = Avatar_name_defval; - pAvatarModule.propertys["name"] = pAvatar_name; - - pAvatarModule.usePropertyDescrAlias = true; - pAvatarModule.idpropertys[(UInt16)pAvatar_name.aliasID] = pAvatar_name; - - //Dbg.DEBUG_MSG("EntityDef::initScriptModules: add(Avatar), property(name / 41003)."); - - Property pAvatar_own_val = new Property(); - pAvatar_own_val.name = "own_val"; - pAvatar_own_val.properUtype = 6; - pAvatar_own_val.properFlags = 16; - pAvatar_own_val.aliasID = 17; - UInt16 Avatar_own_val_defval; - UInt16.TryParse("", out Avatar_own_val_defval); - pAvatar_own_val.defaultVal = Avatar_own_val_defval; - pAvatarModule.propertys["own_val"] = pAvatar_own_val; - - pAvatarModule.usePropertyDescrAlias = true; - pAvatarModule.idpropertys[(UInt16)pAvatar_own_val.aliasID] = pAvatar_own_val; - - //Dbg.DEBUG_MSG("EntityDef::initScriptModules: add(Avatar), property(own_val / 6)."); - - Property pAvatar_spaceUType = new Property(); - pAvatar_spaceUType.name = "spaceUType"; - pAvatar_spaceUType.properUtype = 41001; - pAvatar_spaceUType.properFlags = 8; - pAvatar_spaceUType.aliasID = 18; - UInt32 Avatar_spaceUType_defval; - UInt32.TryParse("", out Avatar_spaceUType_defval); - pAvatar_spaceUType.defaultVal = Avatar_spaceUType_defval; - pAvatarModule.propertys["spaceUType"] = pAvatar_spaceUType; - - pAvatarModule.usePropertyDescrAlias = true; - pAvatarModule.idpropertys[(UInt16)pAvatar_spaceUType.aliasID] = pAvatar_spaceUType; - - //Dbg.DEBUG_MSG("EntityDef::initScriptModules: add(Avatar), property(spaceUType / 41001)."); - - Property pAvatar_state = new Property(); - pAvatar_state.name = "state"; - pAvatar_state.properUtype = 47006; - pAvatar_state.properFlags = 4; - pAvatar_state.aliasID = 19; - SByte Avatar_state_defval; - SByte.TryParse("0", out Avatar_state_defval); - pAvatar_state.defaultVal = Avatar_state_defval; - pAvatarModule.propertys["state"] = pAvatar_state; - - pAvatarModule.usePropertyDescrAlias = true; - pAvatarModule.idpropertys[(UInt16)pAvatar_state.aliasID] = pAvatar_state; - - //Dbg.DEBUG_MSG("EntityDef::initScriptModules: add(Avatar), property(state / 47006)."); - - Property pAvatar_subState = new Property(); - pAvatar_subState.name = "subState"; - pAvatar_subState.properUtype = 47007; - pAvatar_subState.properFlags = 4; - pAvatar_subState.aliasID = 20; - Byte Avatar_subState_defval; - Byte.TryParse("", out Avatar_subState_defval); - pAvatar_subState.defaultVal = Avatar_subState_defval; - pAvatarModule.propertys["subState"] = pAvatar_subState; - - pAvatarModule.usePropertyDescrAlias = true; - pAvatarModule.idpropertys[(UInt16)pAvatar_subState.aliasID] = pAvatar_subState; - - //Dbg.DEBUG_MSG("EntityDef::initScriptModules: add(Avatar), property(subState / 47007)."); - - Property pAvatar_uid = new Property(); - pAvatar_uid.name = "uid"; - pAvatar_uid.properUtype = 41004; - pAvatar_uid.properFlags = 4; - pAvatar_uid.aliasID = 21; - UInt32 Avatar_uid_defval; - UInt32.TryParse("0", out Avatar_uid_defval); - pAvatar_uid.defaultVal = Avatar_uid_defval; - pAvatarModule.propertys["uid"] = pAvatar_uid; - - pAvatarModule.usePropertyDescrAlias = true; - pAvatarModule.idpropertys[(UInt16)pAvatar_uid.aliasID] = pAvatar_uid; - - //Dbg.DEBUG_MSG("EntityDef::initScriptModules: add(Avatar), property(uid / 41004)."); - - Property pAvatar_utype = new Property(); - pAvatar_utype.name = "utype"; - pAvatar_utype.properUtype = 41005; - pAvatar_utype.properFlags = 4; - pAvatar_utype.aliasID = 22; - UInt32 Avatar_utype_defval; - UInt32.TryParse("0", out Avatar_utype_defval); - pAvatar_utype.defaultVal = Avatar_utype_defval; - pAvatarModule.propertys["utype"] = pAvatar_utype; - - pAvatarModule.usePropertyDescrAlias = true; - pAvatarModule.idpropertys[(UInt16)pAvatar_utype.aliasID] = pAvatar_utype; - - //Dbg.DEBUG_MSG("EntityDef::initScriptModules: add(Avatar), property(utype / 41005)."); - - List pAvatar_dialog_addOption_args = new List(); - pAvatar_dialog_addOption_args.Add(EntityDef.id2datatypes[2]); - pAvatar_dialog_addOption_args.Add(EntityDef.id2datatypes[4]); - pAvatar_dialog_addOption_args.Add(EntityDef.id2datatypes[12]); - pAvatar_dialog_addOption_args.Add(EntityDef.id2datatypes[8]); - - Method pAvatar_dialog_addOption = new Method(); - pAvatar_dialog_addOption.name = "dialog_addOption"; - pAvatar_dialog_addOption.methodUtype = 10101; - pAvatar_dialog_addOption.aliasID = 1; - pAvatar_dialog_addOption.args = pAvatar_dialog_addOption_args; - - pAvatarModule.methods["dialog_addOption"] = pAvatar_dialog_addOption; - pAvatarModule.useMethodDescrAlias = true; - pAvatarModule.idmethods[(UInt16)pAvatar_dialog_addOption.aliasID] = pAvatar_dialog_addOption; - - //Dbg.DEBUG_MSG("EntityDef::initScriptModules: add(Avatar), method(dialog_addOption / 10101)."); - - List pAvatar_dialog_close_args = new List(); - - Method pAvatar_dialog_close = new Method(); - pAvatar_dialog_close.name = "dialog_close"; - pAvatar_dialog_close.methodUtype = 10104; - pAvatar_dialog_close.aliasID = 2; - pAvatar_dialog_close.args = pAvatar_dialog_close_args; - - pAvatarModule.methods["dialog_close"] = pAvatar_dialog_close; - pAvatarModule.useMethodDescrAlias = true; - pAvatarModule.idmethods[(UInt16)pAvatar_dialog_close.aliasID] = pAvatar_dialog_close; - - //Dbg.DEBUG_MSG("EntityDef::initScriptModules: add(Avatar), method(dialog_close / 10104)."); - - List pAvatar_dialog_setText_args = new List(); - pAvatar_dialog_setText_args.Add(EntityDef.id2datatypes[12]); - pAvatar_dialog_setText_args.Add(EntityDef.id2datatypes[2]); - pAvatar_dialog_setText_args.Add(EntityDef.id2datatypes[4]); - pAvatar_dialog_setText_args.Add(EntityDef.id2datatypes[12]); - - Method pAvatar_dialog_setText = new Method(); - pAvatar_dialog_setText.name = "dialog_setText"; - pAvatar_dialog_setText.methodUtype = 10102; - pAvatar_dialog_setText.aliasID = 3; - pAvatar_dialog_setText.args = pAvatar_dialog_setText_args; - - pAvatarModule.methods["dialog_setText"] = pAvatar_dialog_setText; - pAvatarModule.useMethodDescrAlias = true; - pAvatarModule.idmethods[(UInt16)pAvatar_dialog_setText.aliasID] = pAvatar_dialog_setText; - - //Dbg.DEBUG_MSG("EntityDef::initScriptModules: add(Avatar), method(dialog_setText / 10102)."); - - List pAvatar_onAddSkill_args = new List(); - pAvatar_onAddSkill_args.Add(EntityDef.id2datatypes[8]); - - Method pAvatar_onAddSkill = new Method(); - pAvatar_onAddSkill.name = "onAddSkill"; - pAvatar_onAddSkill.methodUtype = 12; - pAvatar_onAddSkill.aliasID = 4; - pAvatar_onAddSkill.args = pAvatar_onAddSkill_args; - - pAvatarModule.methods["onAddSkill"] = pAvatar_onAddSkill; - pAvatarModule.useMethodDescrAlias = true; - pAvatarModule.idmethods[(UInt16)pAvatar_onAddSkill.aliasID] = pAvatar_onAddSkill; - - //Dbg.DEBUG_MSG("EntityDef::initScriptModules: add(Avatar), method(onAddSkill / 12)."); - - List pAvatar_onJump_args = new List(); - - Method pAvatar_onJump = new Method(); - pAvatar_onJump.name = "onJump"; - pAvatar_onJump.methodUtype = 7; - pAvatar_onJump.aliasID = 5; - pAvatar_onJump.args = pAvatar_onJump_args; - - pAvatarModule.methods["onJump"] = pAvatar_onJump; - pAvatarModule.useMethodDescrAlias = true; - pAvatarModule.idmethods[(UInt16)pAvatar_onJump.aliasID] = pAvatar_onJump; - - //Dbg.DEBUG_MSG("EntityDef::initScriptModules: add(Avatar), method(onJump / 7)."); - - List pAvatar_onRemoveSkill_args = new List(); - pAvatar_onRemoveSkill_args.Add(EntityDef.id2datatypes[8]); - - Method pAvatar_onRemoveSkill = new Method(); - pAvatar_onRemoveSkill.name = "onRemoveSkill"; - pAvatar_onRemoveSkill.methodUtype = 13; - pAvatar_onRemoveSkill.aliasID = 6; - pAvatar_onRemoveSkill.args = pAvatar_onRemoveSkill_args; - - pAvatarModule.methods["onRemoveSkill"] = pAvatar_onRemoveSkill; - pAvatarModule.useMethodDescrAlias = true; - pAvatarModule.idmethods[(UInt16)pAvatar_onRemoveSkill.aliasID] = pAvatar_onRemoveSkill; - - //Dbg.DEBUG_MSG("EntityDef::initScriptModules: add(Avatar), method(onRemoveSkill / 13)."); - - List pAvatar_recvDamage_args = new List(); - pAvatar_recvDamage_args.Add(EntityDef.id2datatypes[8]); - pAvatar_recvDamage_args.Add(EntityDef.id2datatypes[8]); - pAvatar_recvDamage_args.Add(EntityDef.id2datatypes[8]); - pAvatar_recvDamage_args.Add(EntityDef.id2datatypes[8]); - - Method pAvatar_recvDamage = new Method(); - pAvatar_recvDamage.name = "recvDamage"; - pAvatar_recvDamage.methodUtype = 16; - pAvatar_recvDamage.aliasID = 7; - pAvatar_recvDamage.args = pAvatar_recvDamage_args; - - pAvatarModule.methods["recvDamage"] = pAvatar_recvDamage; - pAvatarModule.useMethodDescrAlias = true; - pAvatarModule.idmethods[(UInt16)pAvatar_recvDamage.aliasID] = pAvatar_recvDamage; - - //Dbg.DEBUG_MSG("EntityDef::initScriptModules: add(Avatar), method(recvDamage / 16)."); - - List pAvatar_dialog_args = new List(); - pAvatar_dialog_args.Add(EntityDef.id2datatypes[8]); - pAvatar_dialog_args.Add(EntityDef.id2datatypes[4]); - - Method pAvatar_dialog = new Method(); - pAvatar_dialog.name = "dialog"; - pAvatar_dialog.methodUtype = 11003; - pAvatar_dialog.aliasID = -1; - pAvatar_dialog.args = pAvatar_dialog_args; - - pAvatarModule.methods["dialog"] = pAvatar_dialog; - pAvatarModule.cell_methods["dialog"] = pAvatar_dialog; - - pAvatarModule.idcell_methods[pAvatar_dialog.methodUtype] = pAvatar_dialog; - - //Dbg.DEBUG_MSG("EntityDef::initScriptModules: add(Avatar), method(dialog / 11003)."); - - List pAvatar_jump_args = new List(); - - Method pAvatar_jump = new Method(); - pAvatar_jump.name = "jump"; - pAvatar_jump.methodUtype = 5; - pAvatar_jump.aliasID = -1; - pAvatar_jump.args = pAvatar_jump_args; - - pAvatarModule.methods["jump"] = pAvatar_jump; - pAvatarModule.cell_methods["jump"] = pAvatar_jump; - - pAvatarModule.idcell_methods[pAvatar_jump.methodUtype] = pAvatar_jump; - - //Dbg.DEBUG_MSG("EntityDef::initScriptModules: add(Avatar), method(jump / 5)."); - - List pAvatar_relive_args = new List(); - pAvatar_relive_args.Add(EntityDef.id2datatypes[2]); - - Method pAvatar_relive = new Method(); - pAvatar_relive.name = "relive"; - pAvatar_relive.methodUtype = 4; - pAvatar_relive.aliasID = -1; - pAvatar_relive.args = pAvatar_relive_args; - - pAvatarModule.methods["relive"] = pAvatar_relive; - pAvatarModule.cell_methods["relive"] = pAvatar_relive; - - pAvatarModule.idcell_methods[pAvatar_relive.methodUtype] = pAvatar_relive; - - //Dbg.DEBUG_MSG("EntityDef::initScriptModules: add(Avatar), method(relive / 4)."); - - List pAvatar_requestPull_args = new List(); - - Method pAvatar_requestPull = new Method(); - pAvatar_requestPull.name = "requestPull"; - pAvatar_requestPull.methodUtype = 11; - pAvatar_requestPull.aliasID = -1; - pAvatar_requestPull.args = pAvatar_requestPull_args; - - pAvatarModule.methods["requestPull"] = pAvatar_requestPull; - pAvatarModule.cell_methods["requestPull"] = pAvatar_requestPull; - - pAvatarModule.idcell_methods[pAvatar_requestPull.methodUtype] = pAvatar_requestPull; - - //Dbg.DEBUG_MSG("EntityDef::initScriptModules: add(Avatar), method(requestPull / 11)."); - - List pAvatar_useTargetSkill_args = new List(); - pAvatar_useTargetSkill_args.Add(EntityDef.id2datatypes[8]); - pAvatar_useTargetSkill_args.Add(EntityDef.id2datatypes[8]); - - Method pAvatar_useTargetSkill = new Method(); - pAvatar_useTargetSkill.name = "useTargetSkill"; - pAvatar_useTargetSkill.methodUtype = 11001; - pAvatar_useTargetSkill.aliasID = -1; - pAvatar_useTargetSkill.args = pAvatar_useTargetSkill_args; - - pAvatarModule.methods["useTargetSkill"] = pAvatar_useTargetSkill; - pAvatarModule.cell_methods["useTargetSkill"] = pAvatar_useTargetSkill; - - pAvatarModule.idcell_methods[pAvatar_useTargetSkill.methodUtype] = pAvatar_useTargetSkill; - - //Dbg.DEBUG_MSG("EntityDef::initScriptModules: add(Avatar), method(useTargetSkill / 11001)."); - - ScriptModule pTestModule = new ScriptModule("Test"); - EntityDef.moduledefs["Test"] = pTestModule; - EntityDef.idmoduledefs[3] = pTestModule; - - Property pTest_position = new Property(); - pTest_position.name = "position"; - pTest_position.properUtype = 40000; - pTest_position.properFlags = 4; - pTest_position.aliasID = 1; - Vector3 Test_position_defval = new Vector3(); - pTest_position.defaultVal = Test_position_defval; - pTestModule.propertys["position"] = pTest_position; - - pTestModule.usePropertyDescrAlias = true; - pTestModule.idpropertys[(UInt16)pTest_position.aliasID] = pTest_position; - - //Dbg.DEBUG_MSG("EntityDef::initScriptModules: add(Test), property(position / 40000)."); - - Property pTest_direction = new Property(); - pTest_direction.name = "direction"; - pTest_direction.properUtype = 40001; - pTest_direction.properFlags = 4; - pTest_direction.aliasID = 2; - Vector3 Test_direction_defval = new Vector3(); - pTest_direction.defaultVal = Test_direction_defval; - pTestModule.propertys["direction"] = pTest_direction; - - pTestModule.usePropertyDescrAlias = true; - pTestModule.idpropertys[(UInt16)pTest_direction.aliasID] = pTest_direction; - - //Dbg.DEBUG_MSG("EntityDef::initScriptModules: add(Test), property(direction / 40001)."); - - Property pTest_spaceID = new Property(); - pTest_spaceID.name = "spaceID"; - pTest_spaceID.properUtype = 40002; - pTest_spaceID.properFlags = 16; - pTest_spaceID.aliasID = 3; - UInt32 Test_spaceID_defval; - UInt32.TryParse("", out Test_spaceID_defval); - pTest_spaceID.defaultVal = Test_spaceID_defval; - pTestModule.propertys["spaceID"] = pTest_spaceID; - - pTestModule.usePropertyDescrAlias = true; - pTestModule.idpropertys[(UInt16)pTest_spaceID.aliasID] = pTest_spaceID; - - //Dbg.DEBUG_MSG("EntityDef::initScriptModules: add(Test), property(spaceID / 40002)."); - - Property pTest_own = new Property(); - pTest_own.name = "own"; - pTest_own.properUtype = 18; - pTest_own.properFlags = 8; - pTest_own.aliasID = 4; - Int32 Test_own_defval; - Int32.TryParse("1001", out Test_own_defval); - pTest_own.defaultVal = Test_own_defval; - pTestModule.propertys["own"] = pTest_own; - - pTestModule.usePropertyDescrAlias = true; - pTestModule.idpropertys[(UInt16)pTest_own.aliasID] = pTest_own; - - //Dbg.DEBUG_MSG("EntityDef::initScriptModules: add(Test), property(own / 18)."); - - Property pTest_state = new Property(); - pTest_state.name = "state"; - pTest_state.properUtype = 17; - pTest_state.properFlags = 4; - pTest_state.aliasID = 5; - Int32 Test_state_defval; - Int32.TryParse("100", out Test_state_defval); - pTest_state.defaultVal = Test_state_defval; - pTestModule.propertys["state"] = pTest_state; - - pTestModule.usePropertyDescrAlias = true; - pTestModule.idpropertys[(UInt16)pTest_state.aliasID] = pTest_state; - - //Dbg.DEBUG_MSG("EntityDef::initScriptModules: add(Test), property(state / 17)."); - - List pTest_helloCB_args = new List(); - pTest_helloCB_args.Add(EntityDef.id2datatypes[8]); - - Method pTest_helloCB = new Method(); - pTest_helloCB.name = "helloCB"; - pTest_helloCB.methodUtype = 28; - pTest_helloCB.aliasID = 1; - pTest_helloCB.args = pTest_helloCB_args; - - pTestModule.methods["helloCB"] = pTest_helloCB; - pTestModule.useMethodDescrAlias = true; - pTestModule.idmethods[(UInt16)pTest_helloCB.aliasID] = pTest_helloCB; - - //Dbg.DEBUG_MSG("EntityDef::initScriptModules: add(Test), method(helloCB / 28)."); - - List pTest_say_args = new List(); - pTest_say_args.Add(EntityDef.id2datatypes[8]); - - Method pTest_say = new Method(); - pTest_say.name = "say"; - pTest_say.methodUtype = 27; - pTest_say.aliasID = -1; - pTest_say.args = pTest_say_args; - - pTestModule.methods["say"] = pTest_say; - pTestModule.base_methods["say"] = pTest_say; - - pTestModule.idbase_methods[pTest_say.methodUtype] = pTest_say; - - //Dbg.DEBUG_MSG("EntityDef::initScriptModules: add(Test), method(say / 27)."); - - List pTest_hello_args = new List(); - pTest_hello_args.Add(EntityDef.id2datatypes[8]); - - Method pTest_hello = new Method(); - pTest_hello.name = "hello"; - pTest_hello.methodUtype = 26; - pTest_hello.aliasID = -1; - pTest_hello.args = pTest_hello_args; - - pTestModule.methods["hello"] = pTest_hello; - pTestModule.cell_methods["hello"] = pTest_hello; - - pTestModule.idcell_methods[pTest_hello.methodUtype] = pTest_hello; - - //Dbg.DEBUG_MSG("EntityDef::initScriptModules: add(Test), method(hello / 26)."); - - ScriptModule pTestNoBaseModule = new ScriptModule("TestNoBase"); - EntityDef.moduledefs["TestNoBase"] = pTestNoBaseModule; - EntityDef.idmoduledefs[4] = pTestNoBaseModule; - - Property pTestNoBase_position = new Property(); - pTestNoBase_position.name = "position"; - pTestNoBase_position.properUtype = 40000; - pTestNoBase_position.properFlags = 4; - pTestNoBase_position.aliasID = 1; - Vector3 TestNoBase_position_defval = new Vector3(); - pTestNoBase_position.defaultVal = TestNoBase_position_defval; - pTestNoBaseModule.propertys["position"] = pTestNoBase_position; - - pTestNoBaseModule.usePropertyDescrAlias = true; - pTestNoBaseModule.idpropertys[(UInt16)pTestNoBase_position.aliasID] = pTestNoBase_position; - - //Dbg.DEBUG_MSG("EntityDef::initScriptModules: add(TestNoBase), property(position / 40000)."); - - Property pTestNoBase_direction = new Property(); - pTestNoBase_direction.name = "direction"; - pTestNoBase_direction.properUtype = 40001; - pTestNoBase_direction.properFlags = 4; - pTestNoBase_direction.aliasID = 2; - Vector3 TestNoBase_direction_defval = new Vector3(); - pTestNoBase_direction.defaultVal = TestNoBase_direction_defval; - pTestNoBaseModule.propertys["direction"] = pTestNoBase_direction; - - pTestNoBaseModule.usePropertyDescrAlias = true; - pTestNoBaseModule.idpropertys[(UInt16)pTestNoBase_direction.aliasID] = pTestNoBase_direction; - - //Dbg.DEBUG_MSG("EntityDef::initScriptModules: add(TestNoBase), property(direction / 40001)."); - - Property pTestNoBase_spaceID = new Property(); - pTestNoBase_spaceID.name = "spaceID"; - pTestNoBase_spaceID.properUtype = 40002; - pTestNoBase_spaceID.properFlags = 16; - pTestNoBase_spaceID.aliasID = 3; - UInt32 TestNoBase_spaceID_defval; - UInt32.TryParse("", out TestNoBase_spaceID_defval); - pTestNoBase_spaceID.defaultVal = TestNoBase_spaceID_defval; - pTestNoBaseModule.propertys["spaceID"] = pTestNoBase_spaceID; - - pTestNoBaseModule.usePropertyDescrAlias = true; - pTestNoBaseModule.idpropertys[(UInt16)pTestNoBase_spaceID.aliasID] = pTestNoBase_spaceID; - - //Dbg.DEBUG_MSG("EntityDef::initScriptModules: add(TestNoBase), property(spaceID / 40002)."); - - Property pTestNoBase_own = new Property(); - pTestNoBase_own.name = "own"; - pTestNoBase_own.properUtype = 24; - pTestNoBase_own.properFlags = 8; - pTestNoBase_own.aliasID = 4; - Int32 TestNoBase_own_defval; - Int32.TryParse("1001", out TestNoBase_own_defval); - pTestNoBase_own.defaultVal = TestNoBase_own_defval; - pTestNoBaseModule.propertys["own"] = pTestNoBase_own; - - pTestNoBaseModule.usePropertyDescrAlias = true; - pTestNoBaseModule.idpropertys[(UInt16)pTestNoBase_own.aliasID] = pTestNoBase_own; - - //Dbg.DEBUG_MSG("EntityDef::initScriptModules: add(TestNoBase), property(own / 24)."); - - Property pTestNoBase_state = new Property(); - pTestNoBase_state.name = "state"; - pTestNoBase_state.properUtype = 23; - pTestNoBase_state.properFlags = 4; - pTestNoBase_state.aliasID = 5; - Int32 TestNoBase_state_defval; - Int32.TryParse("100", out TestNoBase_state_defval); - pTestNoBase_state.defaultVal = TestNoBase_state_defval; - pTestNoBaseModule.propertys["state"] = pTestNoBase_state; - - pTestNoBaseModule.usePropertyDescrAlias = true; - pTestNoBaseModule.idpropertys[(UInt16)pTestNoBase_state.aliasID] = pTestNoBase_state; - - //Dbg.DEBUG_MSG("EntityDef::initScriptModules: add(TestNoBase), property(state / 23)."); - - List pTestNoBase_helloCB_args = new List(); - pTestNoBase_helloCB_args.Add(EntityDef.id2datatypes[8]); - - Method pTestNoBase_helloCB = new Method(); - pTestNoBase_helloCB.name = "helloCB"; - pTestNoBase_helloCB.methodUtype = 30; - pTestNoBase_helloCB.aliasID = 1; - pTestNoBase_helloCB.args = pTestNoBase_helloCB_args; - - pTestNoBaseModule.methods["helloCB"] = pTestNoBase_helloCB; - pTestNoBaseModule.useMethodDescrAlias = true; - pTestNoBaseModule.idmethods[(UInt16)pTestNoBase_helloCB.aliasID] = pTestNoBase_helloCB; - - //Dbg.DEBUG_MSG("EntityDef::initScriptModules: add(TestNoBase), method(helloCB / 30)."); - - List pTestNoBase_hello_args = new List(); - pTestNoBase_hello_args.Add(EntityDef.id2datatypes[8]); - - Method pTestNoBase_hello = new Method(); - pTestNoBase_hello.name = "hello"; - pTestNoBase_hello.methodUtype = 29; - pTestNoBase_hello.aliasID = -1; - pTestNoBase_hello.args = pTestNoBase_hello_args; - - pTestNoBaseModule.methods["hello"] = pTestNoBase_hello; - pTestNoBaseModule.cell_methods["hello"] = pTestNoBase_hello; - - pTestNoBaseModule.idcell_methods[pTestNoBase_hello.methodUtype] = pTestNoBase_hello; - - //Dbg.DEBUG_MSG("EntityDef::initScriptModules: add(TestNoBase), method(hello / 29)."); - - ScriptModule pMonsterModule = new ScriptModule("Monster"); - EntityDef.moduledefs["Monster"] = pMonsterModule; - EntityDef.idmoduledefs[5] = pMonsterModule; - - Property pMonster_position = new Property(); - pMonster_position.name = "position"; - pMonster_position.properUtype = 40000; - pMonster_position.properFlags = 4; - pMonster_position.aliasID = 1; - Vector3 Monster_position_defval = new Vector3(); - pMonster_position.defaultVal = Monster_position_defval; - pMonsterModule.propertys["position"] = pMonster_position; - - pMonsterModule.usePropertyDescrAlias = true; - pMonsterModule.idpropertys[(UInt16)pMonster_position.aliasID] = pMonster_position; - - //Dbg.DEBUG_MSG("EntityDef::initScriptModules: add(Monster), property(position / 40000)."); - - Property pMonster_direction = new Property(); - pMonster_direction.name = "direction"; - pMonster_direction.properUtype = 40001; - pMonster_direction.properFlags = 4; - pMonster_direction.aliasID = 2; - Vector3 Monster_direction_defval = new Vector3(); - pMonster_direction.defaultVal = Monster_direction_defval; - pMonsterModule.propertys["direction"] = pMonster_direction; - - pMonsterModule.usePropertyDescrAlias = true; - pMonsterModule.idpropertys[(UInt16)pMonster_direction.aliasID] = pMonster_direction; - - //Dbg.DEBUG_MSG("EntityDef::initScriptModules: add(Monster), property(direction / 40001)."); - - Property pMonster_spaceID = new Property(); - pMonster_spaceID.name = "spaceID"; - pMonster_spaceID.properUtype = 40002; - pMonster_spaceID.properFlags = 16; - pMonster_spaceID.aliasID = 3; - UInt32 Monster_spaceID_defval; - UInt32.TryParse("", out Monster_spaceID_defval); - pMonster_spaceID.defaultVal = Monster_spaceID_defval; - pMonsterModule.propertys["spaceID"] = pMonster_spaceID; - - pMonsterModule.usePropertyDescrAlias = true; - pMonsterModule.idpropertys[(UInt16)pMonster_spaceID.aliasID] = pMonster_spaceID; - - //Dbg.DEBUG_MSG("EntityDef::initScriptModules: add(Monster), property(spaceID / 40002)."); - - Property pMonster_HP = new Property(); - pMonster_HP.name = "HP"; - pMonster_HP.properUtype = 47001; - pMonster_HP.properFlags = 4; - pMonster_HP.aliasID = 4; - Int32 Monster_HP_defval; - Int32.TryParse("0", out Monster_HP_defval); - pMonster_HP.defaultVal = Monster_HP_defval; - pMonsterModule.propertys["HP"] = pMonster_HP; - - pMonsterModule.usePropertyDescrAlias = true; - pMonsterModule.idpropertys[(UInt16)pMonster_HP.aliasID] = pMonster_HP; - - //Dbg.DEBUG_MSG("EntityDef::initScriptModules: add(Monster), property(HP / 47001)."); - - Property pMonster_HP_Max = new Property(); - pMonster_HP_Max.name = "HP_Max"; - pMonster_HP_Max.properUtype = 47002; - pMonster_HP_Max.properFlags = 4; - pMonster_HP_Max.aliasID = 5; - Int32 Monster_HP_Max_defval; - Int32.TryParse("0", out Monster_HP_Max_defval); - pMonster_HP_Max.defaultVal = Monster_HP_Max_defval; - pMonsterModule.propertys["HP_Max"] = pMonster_HP_Max; - - pMonsterModule.usePropertyDescrAlias = true; - pMonsterModule.idpropertys[(UInt16)pMonster_HP_Max.aliasID] = pMonster_HP_Max; - - //Dbg.DEBUG_MSG("EntityDef::initScriptModules: add(Monster), property(HP_Max / 47002)."); - - Property pMonster_MP = new Property(); - pMonster_MP.name = "MP"; - pMonster_MP.properUtype = 47003; - pMonster_MP.properFlags = 4; - pMonster_MP.aliasID = 6; - Int32 Monster_MP_defval; - Int32.TryParse("0", out Monster_MP_defval); - pMonster_MP.defaultVal = Monster_MP_defval; - pMonsterModule.propertys["MP"] = pMonster_MP; - - pMonsterModule.usePropertyDescrAlias = true; - pMonsterModule.idpropertys[(UInt16)pMonster_MP.aliasID] = pMonster_MP; - - //Dbg.DEBUG_MSG("EntityDef::initScriptModules: add(Monster), property(MP / 47003)."); - - Property pMonster_MP_Max = new Property(); - pMonster_MP_Max.name = "MP_Max"; - pMonster_MP_Max.properUtype = 47004; - pMonster_MP_Max.properFlags = 4; - pMonster_MP_Max.aliasID = 7; - Int32 Monster_MP_Max_defval; - Int32.TryParse("0", out Monster_MP_Max_defval); - pMonster_MP_Max.defaultVal = Monster_MP_Max_defval; - pMonsterModule.propertys["MP_Max"] = pMonster_MP_Max; - - pMonsterModule.usePropertyDescrAlias = true; - pMonsterModule.idpropertys[(UInt16)pMonster_MP_Max.aliasID] = pMonster_MP_Max; - - //Dbg.DEBUG_MSG("EntityDef::initScriptModules: add(Monster), property(MP_Max / 47004)."); - - Property pMonster_entityNO = new Property(); - pMonster_entityNO.name = "entityNO"; - pMonster_entityNO.properUtype = 51007; - pMonster_entityNO.properFlags = 4; - pMonster_entityNO.aliasID = 8; - UInt32 Monster_entityNO_defval; - UInt32.TryParse("0", out Monster_entityNO_defval); - pMonster_entityNO.defaultVal = Monster_entityNO_defval; - pMonsterModule.propertys["entityNO"] = pMonster_entityNO; - - pMonsterModule.usePropertyDescrAlias = true; - pMonsterModule.idpropertys[(UInt16)pMonster_entityNO.aliasID] = pMonster_entityNO; - - //Dbg.DEBUG_MSG("EntityDef::initScriptModules: add(Monster), property(entityNO / 51007)."); - - Property pMonster_forbids = new Property(); - pMonster_forbids.name = "forbids"; - pMonster_forbids.properUtype = 47005; - pMonster_forbids.properFlags = 4; - pMonster_forbids.aliasID = 9; - Int32 Monster_forbids_defval; - Int32.TryParse("0", out Monster_forbids_defval); - pMonster_forbids.defaultVal = Monster_forbids_defval; - pMonsterModule.propertys["forbids"] = pMonster_forbids; - - pMonsterModule.usePropertyDescrAlias = true; - pMonsterModule.idpropertys[(UInt16)pMonster_forbids.aliasID] = pMonster_forbids; - - //Dbg.DEBUG_MSG("EntityDef::initScriptModules: add(Monster), property(forbids / 47005)."); - - Property pMonster_modelID = new Property(); - pMonster_modelID.name = "modelID"; - pMonster_modelID.properUtype = 41006; - pMonster_modelID.properFlags = 4; - pMonster_modelID.aliasID = 10; - UInt32 Monster_modelID_defval; - UInt32.TryParse("0", out Monster_modelID_defval); - pMonster_modelID.defaultVal = Monster_modelID_defval; - pMonsterModule.propertys["modelID"] = pMonster_modelID; - - pMonsterModule.usePropertyDescrAlias = true; - pMonsterModule.idpropertys[(UInt16)pMonster_modelID.aliasID] = pMonster_modelID; - - //Dbg.DEBUG_MSG("EntityDef::initScriptModules: add(Monster), property(modelID / 41006)."); - - Property pMonster_modelScale = new Property(); - pMonster_modelScale.name = "modelScale"; - pMonster_modelScale.properUtype = 41007; - pMonster_modelScale.properFlags = 4; - pMonster_modelScale.aliasID = 11; - Byte Monster_modelScale_defval; - Byte.TryParse("30", out Monster_modelScale_defval); - pMonster_modelScale.defaultVal = Monster_modelScale_defval; - pMonsterModule.propertys["modelScale"] = pMonster_modelScale; - - pMonsterModule.usePropertyDescrAlias = true; - pMonsterModule.idpropertys[(UInt16)pMonster_modelScale.aliasID] = pMonster_modelScale; - - //Dbg.DEBUG_MSG("EntityDef::initScriptModules: add(Monster), property(modelScale / 41007)."); - - Property pMonster_moveSpeed = new Property(); - pMonster_moveSpeed.name = "moveSpeed"; - pMonster_moveSpeed.properUtype = 32; - pMonster_moveSpeed.properFlags = 4; - pMonster_moveSpeed.aliasID = 12; - Byte Monster_moveSpeed_defval; - Byte.TryParse("50", out Monster_moveSpeed_defval); - pMonster_moveSpeed.defaultVal = Monster_moveSpeed_defval; - pMonsterModule.propertys["moveSpeed"] = pMonster_moveSpeed; - - pMonsterModule.usePropertyDescrAlias = true; - pMonsterModule.idpropertys[(UInt16)pMonster_moveSpeed.aliasID] = pMonster_moveSpeed; - - //Dbg.DEBUG_MSG("EntityDef::initScriptModules: add(Monster), property(moveSpeed / 32)."); - - Property pMonster_name = new Property(); - pMonster_name.name = "name"; - pMonster_name.properUtype = 41003; - pMonster_name.properFlags = 4; - pMonster_name.aliasID = 13; - string Monster_name_defval = ""; - pMonster_name.defaultVal = Monster_name_defval; - pMonsterModule.propertys["name"] = pMonster_name; - - pMonsterModule.usePropertyDescrAlias = true; - pMonsterModule.idpropertys[(UInt16)pMonster_name.aliasID] = pMonster_name; - - //Dbg.DEBUG_MSG("EntityDef::initScriptModules: add(Monster), property(name / 41003)."); - - Property pMonster_state = new Property(); - pMonster_state.name = "state"; - pMonster_state.properUtype = 47006; - pMonster_state.properFlags = 4; - pMonster_state.aliasID = 14; - SByte Monster_state_defval; - SByte.TryParse("0", out Monster_state_defval); - pMonster_state.defaultVal = Monster_state_defval; - pMonsterModule.propertys["state"] = pMonster_state; - - pMonsterModule.usePropertyDescrAlias = true; - pMonsterModule.idpropertys[(UInt16)pMonster_state.aliasID] = pMonster_state; - - //Dbg.DEBUG_MSG("EntityDef::initScriptModules: add(Monster), property(state / 47006)."); - - Property pMonster_subState = new Property(); - pMonster_subState.name = "subState"; - pMonster_subState.properUtype = 47007; - pMonster_subState.properFlags = 4; - pMonster_subState.aliasID = 15; - Byte Monster_subState_defval; - Byte.TryParse("", out Monster_subState_defval); - pMonster_subState.defaultVal = Monster_subState_defval; - pMonsterModule.propertys["subState"] = pMonster_subState; - - pMonsterModule.usePropertyDescrAlias = true; - pMonsterModule.idpropertys[(UInt16)pMonster_subState.aliasID] = pMonster_subState; - - //Dbg.DEBUG_MSG("EntityDef::initScriptModules: add(Monster), property(subState / 47007)."); - - Property pMonster_uid = new Property(); - pMonster_uid.name = "uid"; - pMonster_uid.properUtype = 41004; - pMonster_uid.properFlags = 4; - pMonster_uid.aliasID = 16; - UInt32 Monster_uid_defval; - UInt32.TryParse("0", out Monster_uid_defval); - pMonster_uid.defaultVal = Monster_uid_defval; - pMonsterModule.propertys["uid"] = pMonster_uid; - - pMonsterModule.usePropertyDescrAlias = true; - pMonsterModule.idpropertys[(UInt16)pMonster_uid.aliasID] = pMonster_uid; - - //Dbg.DEBUG_MSG("EntityDef::initScriptModules: add(Monster), property(uid / 41004)."); - - Property pMonster_utype = new Property(); - pMonster_utype.name = "utype"; - pMonster_utype.properUtype = 41005; - pMonster_utype.properFlags = 4; - pMonster_utype.aliasID = 17; - UInt32 Monster_utype_defval; - UInt32.TryParse("0", out Monster_utype_defval); - pMonster_utype.defaultVal = Monster_utype_defval; - pMonsterModule.propertys["utype"] = pMonster_utype; - - pMonsterModule.usePropertyDescrAlias = true; - pMonsterModule.idpropertys[(UInt16)pMonster_utype.aliasID] = pMonster_utype; - - //Dbg.DEBUG_MSG("EntityDef::initScriptModules: add(Monster), property(utype / 41005)."); - - List pMonster_recvDamage_args = new List(); - pMonster_recvDamage_args.Add(EntityDef.id2datatypes[8]); - pMonster_recvDamage_args.Add(EntityDef.id2datatypes[8]); - pMonster_recvDamage_args.Add(EntityDef.id2datatypes[8]); - pMonster_recvDamage_args.Add(EntityDef.id2datatypes[8]); - - Method pMonster_recvDamage = new Method(); - pMonster_recvDamage.name = "recvDamage"; - pMonster_recvDamage.methodUtype = 34; - pMonster_recvDamage.aliasID = 1; - pMonster_recvDamage.args = pMonster_recvDamage_args; - - pMonsterModule.methods["recvDamage"] = pMonster_recvDamage; - pMonsterModule.useMethodDescrAlias = true; - pMonsterModule.idmethods[(UInt16)pMonster_recvDamage.aliasID] = pMonster_recvDamage; - - //Dbg.DEBUG_MSG("EntityDef::initScriptModules: add(Monster), method(recvDamage / 34)."); - - ScriptModule pNPCModule = new ScriptModule("NPC"); - EntityDef.moduledefs["NPC"] = pNPCModule; - EntityDef.idmoduledefs[6] = pNPCModule; - - Property pNPC_position = new Property(); - pNPC_position.name = "position"; - pNPC_position.properUtype = 40000; - pNPC_position.properFlags = 4; - pNPC_position.aliasID = 1; - Vector3 NPC_position_defval = new Vector3(); - pNPC_position.defaultVal = NPC_position_defval; - pNPCModule.propertys["position"] = pNPC_position; - - pNPCModule.usePropertyDescrAlias = true; - pNPCModule.idpropertys[(UInt16)pNPC_position.aliasID] = pNPC_position; - - //Dbg.DEBUG_MSG("EntityDef::initScriptModules: add(NPC), property(position / 40000)."); - - Property pNPC_direction = new Property(); - pNPC_direction.name = "direction"; - pNPC_direction.properUtype = 40001; - pNPC_direction.properFlags = 4; - pNPC_direction.aliasID = 2; - Vector3 NPC_direction_defval = new Vector3(); - pNPC_direction.defaultVal = NPC_direction_defval; - pNPCModule.propertys["direction"] = pNPC_direction; - - pNPCModule.usePropertyDescrAlias = true; - pNPCModule.idpropertys[(UInt16)pNPC_direction.aliasID] = pNPC_direction; - - //Dbg.DEBUG_MSG("EntityDef::initScriptModules: add(NPC), property(direction / 40001)."); - - Property pNPC_spaceID = new Property(); - pNPC_spaceID.name = "spaceID"; - pNPC_spaceID.properUtype = 40002; - pNPC_spaceID.properFlags = 16; - pNPC_spaceID.aliasID = 3; - UInt32 NPC_spaceID_defval; - UInt32.TryParse("", out NPC_spaceID_defval); - pNPC_spaceID.defaultVal = NPC_spaceID_defval; - pNPCModule.propertys["spaceID"] = pNPC_spaceID; - - pNPCModule.usePropertyDescrAlias = true; - pNPCModule.idpropertys[(UInt16)pNPC_spaceID.aliasID] = pNPC_spaceID; - - //Dbg.DEBUG_MSG("EntityDef::initScriptModules: add(NPC), property(spaceID / 40002)."); - - Property pNPC_entityNO = new Property(); - pNPC_entityNO.name = "entityNO"; - pNPC_entityNO.properUtype = 51007; - pNPC_entityNO.properFlags = 4; - pNPC_entityNO.aliasID = 4; - UInt32 NPC_entityNO_defval; - UInt32.TryParse("0", out NPC_entityNO_defval); - pNPC_entityNO.defaultVal = NPC_entityNO_defval; - pNPCModule.propertys["entityNO"] = pNPC_entityNO; - - pNPCModule.usePropertyDescrAlias = true; - pNPCModule.idpropertys[(UInt16)pNPC_entityNO.aliasID] = pNPC_entityNO; - - //Dbg.DEBUG_MSG("EntityDef::initScriptModules: add(NPC), property(entityNO / 51007)."); - - Property pNPC_modelID = new Property(); - pNPC_modelID.name = "modelID"; - pNPC_modelID.properUtype = 41006; - pNPC_modelID.properFlags = 4; - pNPC_modelID.aliasID = 5; - UInt32 NPC_modelID_defval; - UInt32.TryParse("0", out NPC_modelID_defval); - pNPC_modelID.defaultVal = NPC_modelID_defval; - pNPCModule.propertys["modelID"] = pNPC_modelID; - - pNPCModule.usePropertyDescrAlias = true; - pNPCModule.idpropertys[(UInt16)pNPC_modelID.aliasID] = pNPC_modelID; - - //Dbg.DEBUG_MSG("EntityDef::initScriptModules: add(NPC), property(modelID / 41006)."); - - Property pNPC_modelScale = new Property(); - pNPC_modelScale.name = "modelScale"; - pNPC_modelScale.properUtype = 41007; - pNPC_modelScale.properFlags = 4; - pNPC_modelScale.aliasID = 6; - Byte NPC_modelScale_defval; - Byte.TryParse("30", out NPC_modelScale_defval); - pNPC_modelScale.defaultVal = NPC_modelScale_defval; - pNPCModule.propertys["modelScale"] = pNPC_modelScale; - - pNPCModule.usePropertyDescrAlias = true; - pNPCModule.idpropertys[(UInt16)pNPC_modelScale.aliasID] = pNPC_modelScale; - - //Dbg.DEBUG_MSG("EntityDef::initScriptModules: add(NPC), property(modelScale / 41007)."); - - Property pNPC_moveSpeed = new Property(); - pNPC_moveSpeed.name = "moveSpeed"; - pNPC_moveSpeed.properUtype = 43; - pNPC_moveSpeed.properFlags = 4; - pNPC_moveSpeed.aliasID = 7; - Byte NPC_moveSpeed_defval; - Byte.TryParse("50", out NPC_moveSpeed_defval); - pNPC_moveSpeed.defaultVal = NPC_moveSpeed_defval; - pNPCModule.propertys["moveSpeed"] = pNPC_moveSpeed; - - pNPCModule.usePropertyDescrAlias = true; - pNPCModule.idpropertys[(UInt16)pNPC_moveSpeed.aliasID] = pNPC_moveSpeed; - - //Dbg.DEBUG_MSG("EntityDef::initScriptModules: add(NPC), property(moveSpeed / 43)."); - - Property pNPC_name = new Property(); - pNPC_name.name = "name"; - pNPC_name.properUtype = 41003; - pNPC_name.properFlags = 4; - pNPC_name.aliasID = 8; - string NPC_name_defval = ""; - pNPC_name.defaultVal = NPC_name_defval; - pNPCModule.propertys["name"] = pNPC_name; - - pNPCModule.usePropertyDescrAlias = true; - pNPCModule.idpropertys[(UInt16)pNPC_name.aliasID] = pNPC_name; - - //Dbg.DEBUG_MSG("EntityDef::initScriptModules: add(NPC), property(name / 41003)."); - - Property pNPC_uid = new Property(); - pNPC_uid.name = "uid"; - pNPC_uid.properUtype = 41004; - pNPC_uid.properFlags = 4; - pNPC_uid.aliasID = 9; - UInt32 NPC_uid_defval; - UInt32.TryParse("0", out NPC_uid_defval); - pNPC_uid.defaultVal = NPC_uid_defval; - pNPCModule.propertys["uid"] = pNPC_uid; - - pNPCModule.usePropertyDescrAlias = true; - pNPCModule.idpropertys[(UInt16)pNPC_uid.aliasID] = pNPC_uid; - - //Dbg.DEBUG_MSG("EntityDef::initScriptModules: add(NPC), property(uid / 41004)."); - - Property pNPC_utype = new Property(); - pNPC_utype.name = "utype"; - pNPC_utype.properUtype = 41005; - pNPC_utype.properFlags = 4; - pNPC_utype.aliasID = 10; - UInt32 NPC_utype_defval; - UInt32.TryParse("0", out NPC_utype_defval); - pNPC_utype.defaultVal = NPC_utype_defval; - pNPCModule.propertys["utype"] = pNPC_utype; - - pNPCModule.usePropertyDescrAlias = true; - pNPCModule.idpropertys[(UInt16)pNPC_utype.aliasID] = pNPC_utype; - - //Dbg.DEBUG_MSG("EntityDef::initScriptModules: add(NPC), property(utype / 41005)."); - - pNPCModule.useMethodDescrAlias = true; - ScriptModule pGateModule = new ScriptModule("Gate"); - EntityDef.moduledefs["Gate"] = pGateModule; - EntityDef.idmoduledefs[7] = pGateModule; - - Property pGate_position = new Property(); - pGate_position.name = "position"; - pGate_position.properUtype = 40000; - pGate_position.properFlags = 4; - pGate_position.aliasID = 1; - Vector3 Gate_position_defval = new Vector3(); - pGate_position.defaultVal = Gate_position_defval; - pGateModule.propertys["position"] = pGate_position; - - pGateModule.usePropertyDescrAlias = true; - pGateModule.idpropertys[(UInt16)pGate_position.aliasID] = pGate_position; - - //Dbg.DEBUG_MSG("EntityDef::initScriptModules: add(Gate), property(position / 40000)."); - - Property pGate_direction = new Property(); - pGate_direction.name = "direction"; - pGate_direction.properUtype = 40001; - pGate_direction.properFlags = 4; - pGate_direction.aliasID = 2; - Vector3 Gate_direction_defval = new Vector3(); - pGate_direction.defaultVal = Gate_direction_defval; - pGateModule.propertys["direction"] = pGate_direction; - - pGateModule.usePropertyDescrAlias = true; - pGateModule.idpropertys[(UInt16)pGate_direction.aliasID] = pGate_direction; - - //Dbg.DEBUG_MSG("EntityDef::initScriptModules: add(Gate), property(direction / 40001)."); - - Property pGate_spaceID = new Property(); - pGate_spaceID.name = "spaceID"; - pGate_spaceID.properUtype = 40002; - pGate_spaceID.properFlags = 16; - pGate_spaceID.aliasID = 3; - UInt32 Gate_spaceID_defval; - UInt32.TryParse("", out Gate_spaceID_defval); - pGate_spaceID.defaultVal = Gate_spaceID_defval; - pGateModule.propertys["spaceID"] = pGate_spaceID; - - pGateModule.usePropertyDescrAlias = true; - pGateModule.idpropertys[(UInt16)pGate_spaceID.aliasID] = pGate_spaceID; - - //Dbg.DEBUG_MSG("EntityDef::initScriptModules: add(Gate), property(spaceID / 40002)."); - - Property pGate_entityNO = new Property(); - pGate_entityNO.name = "entityNO"; - pGate_entityNO.properUtype = 51007; - pGate_entityNO.properFlags = 4; - pGate_entityNO.aliasID = 4; - UInt32 Gate_entityNO_defval; - UInt32.TryParse("0", out Gate_entityNO_defval); - pGate_entityNO.defaultVal = Gate_entityNO_defval; - pGateModule.propertys["entityNO"] = pGate_entityNO; - - pGateModule.usePropertyDescrAlias = true; - pGateModule.idpropertys[(UInt16)pGate_entityNO.aliasID] = pGate_entityNO; - - //Dbg.DEBUG_MSG("EntityDef::initScriptModules: add(Gate), property(entityNO / 51007)."); - - Property pGate_modelID = new Property(); - pGate_modelID.name = "modelID"; - pGate_modelID.properUtype = 41006; - pGate_modelID.properFlags = 4; - pGate_modelID.aliasID = 5; - UInt32 Gate_modelID_defval; - UInt32.TryParse("0", out Gate_modelID_defval); - pGate_modelID.defaultVal = Gate_modelID_defval; - pGateModule.propertys["modelID"] = pGate_modelID; - - pGateModule.usePropertyDescrAlias = true; - pGateModule.idpropertys[(UInt16)pGate_modelID.aliasID] = pGate_modelID; - - //Dbg.DEBUG_MSG("EntityDef::initScriptModules: add(Gate), property(modelID / 41006)."); - - Property pGate_modelScale = new Property(); - pGate_modelScale.name = "modelScale"; - pGate_modelScale.properUtype = 41007; - pGate_modelScale.properFlags = 4; - pGate_modelScale.aliasID = 6; - Byte Gate_modelScale_defval; - Byte.TryParse("30", out Gate_modelScale_defval); - pGate_modelScale.defaultVal = Gate_modelScale_defval; - pGateModule.propertys["modelScale"] = pGate_modelScale; - - pGateModule.usePropertyDescrAlias = true; - pGateModule.idpropertys[(UInt16)pGate_modelScale.aliasID] = pGate_modelScale; - - //Dbg.DEBUG_MSG("EntityDef::initScriptModules: add(Gate), property(modelScale / 41007)."); - - Property pGate_name = new Property(); - pGate_name.name = "name"; - pGate_name.properUtype = 41003; - pGate_name.properFlags = 4; - pGate_name.aliasID = 7; - string Gate_name_defval = ""; - pGate_name.defaultVal = Gate_name_defval; - pGateModule.propertys["name"] = pGate_name; - - pGateModule.usePropertyDescrAlias = true; - pGateModule.idpropertys[(UInt16)pGate_name.aliasID] = pGate_name; - - //Dbg.DEBUG_MSG("EntityDef::initScriptModules: add(Gate), property(name / 41003)."); - - Property pGate_uid = new Property(); - pGate_uid.name = "uid"; - pGate_uid.properUtype = 41004; - pGate_uid.properFlags = 4; - pGate_uid.aliasID = 8; - UInt32 Gate_uid_defval; - UInt32.TryParse("0", out Gate_uid_defval); - pGate_uid.defaultVal = Gate_uid_defval; - pGateModule.propertys["uid"] = pGate_uid; - - pGateModule.usePropertyDescrAlias = true; - pGateModule.idpropertys[(UInt16)pGate_uid.aliasID] = pGate_uid; - - //Dbg.DEBUG_MSG("EntityDef::initScriptModules: add(Gate), property(uid / 41004)."); - - Property pGate_utype = new Property(); - pGate_utype.name = "utype"; - pGate_utype.properUtype = 41005; - pGate_utype.properFlags = 4; - pGate_utype.aliasID = 9; - UInt32 Gate_utype_defval; - UInt32.TryParse("0", out Gate_utype_defval); - pGate_utype.defaultVal = Gate_utype_defval; - pGateModule.propertys["utype"] = pGate_utype; - - pGateModule.usePropertyDescrAlias = true; - pGateModule.idpropertys[(UInt16)pGate_utype.aliasID] = pGate_utype; - - //Dbg.DEBUG_MSG("EntityDef::initScriptModules: add(Gate), property(utype / 41005)."); - - pGateModule.useMethodDescrAlias = true; - } - - public static void initDefTypes() - { - { - UInt16 utype = 2; - string typeName = "ENTITY_SUBSTATE"; - string name = "UINT8"; - DATATYPE_BASE val = null; - EntityDef.datatypes.TryGetValue(name, out val); - EntityDef.datatypes[typeName] = val; - EntityDef.id2datatypes[utype] = EntityDef.datatypes[typeName]; - EntityDef.datatype2id[typeName] = utype; - } - - { - UInt16 utype = 3; - string typeName = "UINT16"; - string name = "UINT16"; - DATATYPE_BASE val = null; - EntityDef.datatypes.TryGetValue(name, out val); - EntityDef.datatypes[typeName] = val; - EntityDef.id2datatypes[utype] = EntityDef.datatypes[typeName]; - EntityDef.datatype2id[typeName] = utype; - } - - { - UInt16 utype = 5; - string typeName = "UID"; - string name = "UINT64"; - DATATYPE_BASE val = null; - EntityDef.datatypes.TryGetValue(name, out val); - EntityDef.datatypes[typeName] = val; - EntityDef.id2datatypes[utype] = EntityDef.datatypes[typeName]; - EntityDef.datatype2id[typeName] = utype; - } - - { - UInt16 utype = 4; - string typeName = "ENTITY_UTYPE"; - string name = "UINT32"; - DATATYPE_BASE val = null; - EntityDef.datatypes.TryGetValue(name, out val); - EntityDef.datatypes[typeName] = val; - EntityDef.id2datatypes[utype] = EntityDef.datatypes[typeName]; - EntityDef.datatype2id[typeName] = utype; - } - - { - UInt16 utype = 6; - string typeName = "ENTITY_STATE"; - string name = "INT8"; - DATATYPE_BASE val = null; - EntityDef.datatypes.TryGetValue(name, out val); - EntityDef.datatypes[typeName] = val; - EntityDef.id2datatypes[utype] = EntityDef.datatypes[typeName]; - EntityDef.datatype2id[typeName] = utype; - } - - { - UInt16 utype = 7; - string typeName = "INT16"; - string name = "INT16"; - DATATYPE_BASE val = null; - EntityDef.datatypes.TryGetValue(name, out val); - EntityDef.datatypes[typeName] = val; - EntityDef.id2datatypes[utype] = EntityDef.datatypes[typeName]; - EntityDef.datatype2id[typeName] = utype; - } - - { - UInt16 utype = 8; - string typeName = "ENTITY_FORBIDS"; - string name = "INT32"; - DATATYPE_BASE val = null; - EntityDef.datatypes.TryGetValue(name, out val); - EntityDef.datatypes[typeName] = val; - EntityDef.id2datatypes[utype] = EntityDef.datatypes[typeName]; - EntityDef.datatype2id[typeName] = utype; - } - - { - UInt16 utype = 9; - string typeName = "INT64"; - string name = "INT64"; - DATATYPE_BASE val = null; - EntityDef.datatypes.TryGetValue(name, out val); - EntityDef.datatypes[typeName] = val; - EntityDef.id2datatypes[utype] = EntityDef.datatypes[typeName]; - EntityDef.datatype2id[typeName] = utype; - } - - { - UInt16 utype = 1; - string typeName = "STRING"; - string name = "STRING"; - DATATYPE_BASE val = null; - EntityDef.datatypes.TryGetValue(name, out val); - EntityDef.datatypes[typeName] = val; - EntityDef.id2datatypes[utype] = EntityDef.datatypes[typeName]; - EntityDef.datatype2id[typeName] = utype; - } - - { - UInt16 utype = 12; - string typeName = "UNICODE"; - string name = "UNICODE"; - DATATYPE_BASE val = null; - EntityDef.datatypes.TryGetValue(name, out val); - EntityDef.datatypes[typeName] = val; - EntityDef.id2datatypes[utype] = EntityDef.datatypes[typeName]; - EntityDef.datatype2id[typeName] = utype; - } - - { - UInt16 utype = 13; - string typeName = "FLOAT"; - string name = "FLOAT"; - DATATYPE_BASE val = null; - EntityDef.datatypes.TryGetValue(name, out val); - EntityDef.datatypes[typeName] = val; - EntityDef.id2datatypes[utype] = EntityDef.datatypes[typeName]; - EntityDef.datatype2id[typeName] = utype; - } - - { - UInt16 utype = 14; - string typeName = "DOUBLE"; - string name = "DOUBLE"; - DATATYPE_BASE val = null; - EntityDef.datatypes.TryGetValue(name, out val); - EntityDef.datatypes[typeName] = val; - EntityDef.id2datatypes[utype] = EntityDef.datatypes[typeName]; - EntityDef.datatype2id[typeName] = utype; - } - - { - UInt16 utype = 10; - string typeName = "UID1"; - string name = "PYTHON"; - DATATYPE_BASE val = null; - EntityDef.datatypes.TryGetValue(name, out val); - EntityDef.datatypes[typeName] = val; - EntityDef.id2datatypes[utype] = EntityDef.datatypes[typeName]; - EntityDef.datatype2id[typeName] = utype; - } - - { - UInt16 utype = 10; - string typeName = "PY_DICT"; - string name = "PY_DICT"; - DATATYPE_BASE val = null; - EntityDef.datatypes.TryGetValue(name, out val); - EntityDef.datatypes[typeName] = val; - EntityDef.id2datatypes[utype] = EntityDef.datatypes[typeName]; - EntityDef.datatype2id[typeName] = utype; - } - - { - UInt16 utype = 10; - string typeName = "PY_TUPLE"; - string name = "PY_TUPLE"; - DATATYPE_BASE val = null; - EntityDef.datatypes.TryGetValue(name, out val); - EntityDef.datatypes[typeName] = val; - EntityDef.id2datatypes[utype] = EntityDef.datatypes[typeName]; - EntityDef.datatype2id[typeName] = utype; - } - - { - UInt16 utype = 10; - string typeName = "PY_LIST"; - string name = "PY_LIST"; - DATATYPE_BASE val = null; - EntityDef.datatypes.TryGetValue(name, out val); - EntityDef.datatypes[typeName] = val; - EntityDef.id2datatypes[utype] = EntityDef.datatypes[typeName]; - EntityDef.datatype2id[typeName] = utype; - } - - { - UInt16 utype = 20; - string typeName = "ENTITYCALL"; - string name = "ENTITYCALL"; - DATATYPE_BASE val = null; - EntityDef.datatypes.TryGetValue(name, out val); - EntityDef.datatypes[typeName] = val; - EntityDef.id2datatypes[utype] = EntityDef.datatypes[typeName]; - EntityDef.datatype2id[typeName] = utype; - } - - { - UInt16 utype = 11; - string typeName = "BLOB"; - string name = "BLOB"; - DATATYPE_BASE val = null; - EntityDef.datatypes.TryGetValue(name, out val); - EntityDef.datatypes[typeName] = val; - EntityDef.id2datatypes[utype] = EntityDef.datatypes[typeName]; - EntityDef.datatype2id[typeName] = utype; - } - - { - UInt16 utype = 15; - string typeName = "VECTOR2"; - string name = "VECTOR2"; - DATATYPE_BASE val = null; - EntityDef.datatypes.TryGetValue(name, out val); - EntityDef.datatypes[typeName] = val; - EntityDef.id2datatypes[utype] = EntityDef.datatypes[typeName]; - EntityDef.datatype2id[typeName] = utype; - } - - { - UInt16 utype = 16; - string typeName = "DIRECTION3D"; - string name = "VECTOR3"; - DATATYPE_BASE val = null; - EntityDef.datatypes.TryGetValue(name, out val); - EntityDef.datatypes[typeName] = val; - EntityDef.id2datatypes[utype] = EntityDef.datatypes[typeName]; - EntityDef.datatype2id[typeName] = utype; - } - - { - UInt16 utype = 17; - string typeName = "VECTOR4"; - string name = "VECTOR4"; - DATATYPE_BASE val = null; - EntityDef.datatypes.TryGetValue(name, out val); - EntityDef.datatypes[typeName] = val; - EntityDef.id2datatypes[utype] = EntityDef.datatypes[typeName]; - EntityDef.datatype2id[typeName] = utype; - } - - { - UInt16 utype = 22; - string typeName = "ENTITY_FORBID_COUNTER"; - DATATYPE_ENTITY_FORBID_COUNTER datatype = new DATATYPE_ENTITY_FORBID_COUNTER(); - EntityDef.datatypes[typeName] = datatype; - EntityDef.id2datatypes[utype] = EntityDef.datatypes[typeName]; - EntityDef.datatype2id[typeName] = utype; - } - - { - UInt16 utype = 23; - string typeName = "ENTITYID_LIST"; - DATATYPE_ENTITYID_LIST datatype = new DATATYPE_ENTITYID_LIST(); - EntityDef.datatypes[typeName] = datatype; - EntityDef.id2datatypes[utype] = EntityDef.datatypes[typeName]; - EntityDef.datatype2id[typeName] = utype; - } - - { - UInt16 utype = 24; - string typeName = "AVATAR_DATA"; - DATATYPE_AVATAR_DATA datatype = new DATATYPE_AVATAR_DATA(); - EntityDef.datatypes[typeName] = datatype; - EntityDef.id2datatypes[utype] = EntityDef.datatypes[typeName]; - EntityDef.datatype2id[typeName] = utype; - } - - { - UInt16 utype = 25; - string typeName = "AVATAR_INFOS"; - DATATYPE_AVATAR_INFOS datatype = new DATATYPE_AVATAR_INFOS(); - EntityDef.datatypes[typeName] = datatype; - EntityDef.id2datatypes[utype] = EntityDef.datatypes[typeName]; - EntityDef.datatype2id[typeName] = utype; - } - - { - UInt16 utype = 26; - string typeName = "AVATAR_INFOS_LIST"; - DATATYPE_AVATAR_INFOS_LIST datatype = new DATATYPE_AVATAR_INFOS_LIST(); - EntityDef.datatypes[typeName] = datatype; - EntityDef.id2datatypes[utype] = EntityDef.datatypes[typeName]; - EntityDef.datatype2id[typeName] = utype; - } - - { - UInt16 utype = 28; - string typeName = "BAG"; - DATATYPE_BAG datatype = new DATATYPE_BAG(); - EntityDef.datatypes[typeName] = datatype; - EntityDef.id2datatypes[utype] = EntityDef.datatypes[typeName]; - EntityDef.datatype2id[typeName] = utype; - } - - { - UInt16 utype = 31; - string typeName = "EXAMPLES"; - DATATYPE_EXAMPLES datatype = new DATATYPE_EXAMPLES(); - EntityDef.datatypes[typeName] = datatype; - EntityDef.id2datatypes[utype] = EntityDef.datatypes[typeName]; - EntityDef.datatype2id[typeName] = utype; - } - - { - UInt16 utype = 32; - string typeName = "AnonymousArray_32"; - DATATYPE_AnonymousArray_32 datatype = new DATATYPE_AnonymousArray_32(); - EntityDef.datatypes[typeName] = datatype; - EntityDef.id2datatypes[utype] = EntityDef.datatypes[typeName]; - EntityDef.datatype2id[typeName] = utype; - } - - { - UInt16 utype = 33; - string typeName = "AnonymousArray_33"; - string name = "ENTITY_COMPONENT"; - DATATYPE_BASE val = null; - EntityDef.datatypes.TryGetValue(name, out val); - EntityDef.datatypes[typeName] = val; - EntityDef.id2datatypes[utype] = EntityDef.datatypes[typeName]; - EntityDef.datatype2id[typeName] = utype; - } - - { - UInt16 utype = 34; - string typeName = "AnonymousArray_34"; - string name = "ENTITY_COMPONENT"; - DATATYPE_BASE val = null; - EntityDef.datatypes.TryGetValue(name, out val); - EntityDef.datatypes[typeName] = val; - EntityDef.id2datatypes[utype] = EntityDef.datatypes[typeName]; - EntityDef.datatype2id[typeName] = utype; - } - - { - UInt16 utype = 35; - string typeName = "AnonymousArray_35"; - string name = "ENTITY_COMPONENT"; - DATATYPE_BASE val = null; - EntityDef.datatypes.TryGetValue(name, out val); - EntityDef.datatypes[typeName] = val; - EntityDef.id2datatypes[utype] = EntityDef.datatypes[typeName]; - EntityDef.datatype2id[typeName] = utype; - } - - foreach(string datatypeStr in EntityDef.datatypes.Keys) - { - DATATYPE_BASE dataType = EntityDef.datatypes[datatypeStr]; - if(dataType != null) - { - dataType.bind(); - } - } - } - - } - - +/* + Generated by KBEngine! + Please do not modify this file! + tools = kbcmd +*/ + +namespace KBEngine +{ + using UnityEngine; + using System; + using System.Collections; + using System.Collections.Generic; + + public class EntityDef + { + public static Dictionary datatype2id = new Dictionary(); + public static Dictionary datatypes = new Dictionary(); + public static Dictionary id2datatypes = new Dictionary(); + public static Dictionary entityclass = new Dictionary(); + public static Dictionary moduledefs = new Dictionary(); + public static Dictionary idmoduledefs = new Dictionary(); + + public static bool init() + { + initDataTypes(); + initDefTypes(); + initScriptModules(); + return true; + } + + public static bool reset() + { + clear(); + return init(); + } + + public static void clear() + { + datatype2id.Clear(); + datatypes.Clear(); + id2datatypes.Clear(); + entityclass.Clear(); + moduledefs.Clear(); + idmoduledefs.Clear(); + } + + public static void initDataTypes() + { + datatypes["UINT8"] = new DATATYPE_UINT8(); + datatypes["UINT16"] = new DATATYPE_UINT16(); + datatypes["UINT32"] = new DATATYPE_UINT32(); + datatypes["UINT64"] = new DATATYPE_UINT64(); + + datatypes["INT8"] = new DATATYPE_INT8(); + datatypes["INT16"] = new DATATYPE_INT16(); + datatypes["INT32"] = new DATATYPE_INT32(); + datatypes["INT64"] = new DATATYPE_INT64(); + + datatypes["FLOAT"] = new DATATYPE_FLOAT(); + datatypes["DOUBLE"] = new DATATYPE_DOUBLE(); + + datatypes["STRING"] = new DATATYPE_STRING(); + datatypes["VECTOR2"] = new DATATYPE_VECTOR2(); + + datatypes["VECTOR3"] = new DATATYPE_VECTOR3(); + + datatypes["VECTOR4"] = new DATATYPE_VECTOR4(); + datatypes["PYTHON"] = new DATATYPE_PYTHON(); + + datatypes["UNICODE"] = new DATATYPE_UNICODE(); + datatypes["ENTITYCALL"] = new DATATYPE_ENTITYCALL(); + + datatypes["BLOB"] = new DATATYPE_BLOB(); + } + + public static void initScriptModules() + { + ScriptModule pAccountModule = new ScriptModule("Account"); + EntityDef.moduledefs["Account"] = pAccountModule; + EntityDef.idmoduledefs[1] = pAccountModule; + + Property pAccount_position = new Property(); + pAccount_position.name = "position"; + pAccount_position.properUtype = 40000; + pAccount_position.properFlags = 4; + pAccount_position.aliasID = 1; + Vector3 Account_position_defval = new Vector3(); + pAccount_position.defaultVal = Account_position_defval; + pAccountModule.propertys["position"] = pAccount_position; + + pAccountModule.usePropertyDescrAlias = true; + pAccountModule.idpropertys[(UInt16)pAccount_position.aliasID] = pAccount_position; + + //Dbg.DEBUG_MSG("EntityDef::initScriptModules: add(Account), property(position / 40000)."); + + Property pAccount_direction = new Property(); + pAccount_direction.name = "direction"; + pAccount_direction.properUtype = 40001; + pAccount_direction.properFlags = 4; + pAccount_direction.aliasID = 2; + Vector3 Account_direction_defval = new Vector3(); + pAccount_direction.defaultVal = Account_direction_defval; + pAccountModule.propertys["direction"] = pAccount_direction; + + pAccountModule.usePropertyDescrAlias = true; + pAccountModule.idpropertys[(UInt16)pAccount_direction.aliasID] = pAccount_direction; + + //Dbg.DEBUG_MSG("EntityDef::initScriptModules: add(Account), property(direction / 40001)."); + + Property pAccount_spaceID = new Property(); + pAccount_spaceID.name = "spaceID"; + pAccount_spaceID.properUtype = 40002; + pAccount_spaceID.properFlags = 16; + pAccount_spaceID.aliasID = 3; + UInt32 Account_spaceID_defval; + UInt32.TryParse("", out Account_spaceID_defval); + pAccount_spaceID.defaultVal = Account_spaceID_defval; + pAccountModule.propertys["spaceID"] = pAccount_spaceID; + + pAccountModule.usePropertyDescrAlias = true; + pAccountModule.idpropertys[(UInt16)pAccount_spaceID.aliasID] = pAccount_spaceID; + + //Dbg.DEBUG_MSG("EntityDef::initScriptModules: add(Account), property(spaceID / 40002)."); + + Property pAccount_lastSelCharacter = new Property(); + pAccount_lastSelCharacter.name = "lastSelCharacter"; + pAccount_lastSelCharacter.properUtype = 2; + pAccount_lastSelCharacter.properFlags = 32; + pAccount_lastSelCharacter.aliasID = 4; + UInt64 Account_lastSelCharacter_defval; + UInt64.TryParse("0", out Account_lastSelCharacter_defval); + pAccount_lastSelCharacter.defaultVal = Account_lastSelCharacter_defval; + pAccountModule.propertys["lastSelCharacter"] = pAccount_lastSelCharacter; + + pAccountModule.usePropertyDescrAlias = true; + pAccountModule.idpropertys[(UInt16)pAccount_lastSelCharacter.aliasID] = pAccount_lastSelCharacter; + + //Dbg.DEBUG_MSG("EntityDef::initScriptModules: add(Account), property(lastSelCharacter / 2)."); + + List pAccount_onCreateAvatarResult_args = new List(); + pAccount_onCreateAvatarResult_args.Add(EntityDef.id2datatypes[2]); + pAccount_onCreateAvatarResult_args.Add(EntityDef.id2datatypes[25]); + + Method pAccount_onCreateAvatarResult = new Method(); + pAccount_onCreateAvatarResult.name = "onCreateAvatarResult"; + pAccount_onCreateAvatarResult.methodUtype = 10005; + pAccount_onCreateAvatarResult.aliasID = 1; + pAccount_onCreateAvatarResult.args = pAccount_onCreateAvatarResult_args; + + pAccountModule.methods["onCreateAvatarResult"] = pAccount_onCreateAvatarResult; + pAccountModule.useMethodDescrAlias = true; + pAccountModule.idmethods[(UInt16)pAccount_onCreateAvatarResult.aliasID] = pAccount_onCreateAvatarResult; + + //Dbg.DEBUG_MSG("EntityDef::initScriptModules: add(Account), method(onCreateAvatarResult / 10005)."); + + List pAccount_onRemoveAvatar_args = new List(); + pAccount_onRemoveAvatar_args.Add(EntityDef.id2datatypes[5]); + + Method pAccount_onRemoveAvatar = new Method(); + pAccount_onRemoveAvatar.name = "onRemoveAvatar"; + pAccount_onRemoveAvatar.methodUtype = 3; + pAccount_onRemoveAvatar.aliasID = 2; + pAccount_onRemoveAvatar.args = pAccount_onRemoveAvatar_args; + + pAccountModule.methods["onRemoveAvatar"] = pAccount_onRemoveAvatar; + pAccountModule.useMethodDescrAlias = true; + pAccountModule.idmethods[(UInt16)pAccount_onRemoveAvatar.aliasID] = pAccount_onRemoveAvatar; + + //Dbg.DEBUG_MSG("EntityDef::initScriptModules: add(Account), method(onRemoveAvatar / 3)."); + + List pAccount_onReqAvatarList_args = new List(); + pAccount_onReqAvatarList_args.Add(EntityDef.id2datatypes[26]); + + Method pAccount_onReqAvatarList = new Method(); + pAccount_onReqAvatarList.name = "onReqAvatarList"; + pAccount_onReqAvatarList.methodUtype = 10003; + pAccount_onReqAvatarList.aliasID = 3; + pAccount_onReqAvatarList.args = pAccount_onReqAvatarList_args; + + pAccountModule.methods["onReqAvatarList"] = pAccount_onReqAvatarList; + pAccountModule.useMethodDescrAlias = true; + pAccountModule.idmethods[(UInt16)pAccount_onReqAvatarList.aliasID] = pAccount_onReqAvatarList; + + //Dbg.DEBUG_MSG("EntityDef::initScriptModules: add(Account), method(onReqAvatarList / 10003)."); + + List pAccount_reqAvatarList_args = new List(); + + Method pAccount_reqAvatarList = new Method(); + pAccount_reqAvatarList.name = "reqAvatarList"; + pAccount_reqAvatarList.methodUtype = 10001; + pAccount_reqAvatarList.aliasID = -1; + pAccount_reqAvatarList.args = pAccount_reqAvatarList_args; + + pAccountModule.methods["reqAvatarList"] = pAccount_reqAvatarList; + pAccountModule.base_methods["reqAvatarList"] = pAccount_reqAvatarList; + + pAccountModule.idbase_methods[pAccount_reqAvatarList.methodUtype] = pAccount_reqAvatarList; + + //Dbg.DEBUG_MSG("EntityDef::initScriptModules: add(Account), method(reqAvatarList / 10001)."); + + List pAccount_reqCreateAvatar_args = new List(); + pAccount_reqCreateAvatar_args.Add(EntityDef.id2datatypes[2]); + pAccount_reqCreateAvatar_args.Add(EntityDef.id2datatypes[12]); + + Method pAccount_reqCreateAvatar = new Method(); + pAccount_reqCreateAvatar.name = "reqCreateAvatar"; + pAccount_reqCreateAvatar.methodUtype = 10002; + pAccount_reqCreateAvatar.aliasID = -1; + pAccount_reqCreateAvatar.args = pAccount_reqCreateAvatar_args; + + pAccountModule.methods["reqCreateAvatar"] = pAccount_reqCreateAvatar; + pAccountModule.base_methods["reqCreateAvatar"] = pAccount_reqCreateAvatar; + + pAccountModule.idbase_methods[pAccount_reqCreateAvatar.methodUtype] = pAccount_reqCreateAvatar; + + //Dbg.DEBUG_MSG("EntityDef::initScriptModules: add(Account), method(reqCreateAvatar / 10002)."); + + List pAccount_reqRemoveAvatar_args = new List(); + pAccount_reqRemoveAvatar_args.Add(EntityDef.id2datatypes[12]); + + Method pAccount_reqRemoveAvatar = new Method(); + pAccount_reqRemoveAvatar.name = "reqRemoveAvatar"; + pAccount_reqRemoveAvatar.methodUtype = 1; + pAccount_reqRemoveAvatar.aliasID = -1; + pAccount_reqRemoveAvatar.args = pAccount_reqRemoveAvatar_args; + + pAccountModule.methods["reqRemoveAvatar"] = pAccount_reqRemoveAvatar; + pAccountModule.base_methods["reqRemoveAvatar"] = pAccount_reqRemoveAvatar; + + pAccountModule.idbase_methods[pAccount_reqRemoveAvatar.methodUtype] = pAccount_reqRemoveAvatar; + + //Dbg.DEBUG_MSG("EntityDef::initScriptModules: add(Account), method(reqRemoveAvatar / 1)."); + + List pAccount_reqRemoveAvatarDBID_args = new List(); + pAccount_reqRemoveAvatarDBID_args.Add(EntityDef.id2datatypes[5]); + + Method pAccount_reqRemoveAvatarDBID = new Method(); + pAccount_reqRemoveAvatarDBID.name = "reqRemoveAvatarDBID"; + pAccount_reqRemoveAvatarDBID.methodUtype = 2; + pAccount_reqRemoveAvatarDBID.aliasID = -1; + pAccount_reqRemoveAvatarDBID.args = pAccount_reqRemoveAvatarDBID_args; + + pAccountModule.methods["reqRemoveAvatarDBID"] = pAccount_reqRemoveAvatarDBID; + pAccountModule.base_methods["reqRemoveAvatarDBID"] = pAccount_reqRemoveAvatarDBID; + + pAccountModule.idbase_methods[pAccount_reqRemoveAvatarDBID.methodUtype] = pAccount_reqRemoveAvatarDBID; + + //Dbg.DEBUG_MSG("EntityDef::initScriptModules: add(Account), method(reqRemoveAvatarDBID / 2)."); + + List pAccount_selectAvatarGame_args = new List(); + pAccount_selectAvatarGame_args.Add(EntityDef.id2datatypes[5]); + + Method pAccount_selectAvatarGame = new Method(); + pAccount_selectAvatarGame.name = "selectAvatarGame"; + pAccount_selectAvatarGame.methodUtype = 10004; + pAccount_selectAvatarGame.aliasID = -1; + pAccount_selectAvatarGame.args = pAccount_selectAvatarGame_args; + + pAccountModule.methods["selectAvatarGame"] = pAccount_selectAvatarGame; + pAccountModule.base_methods["selectAvatarGame"] = pAccount_selectAvatarGame; + + pAccountModule.idbase_methods[pAccount_selectAvatarGame.methodUtype] = pAccount_selectAvatarGame; + + //Dbg.DEBUG_MSG("EntityDef::initScriptModules: add(Account), method(selectAvatarGame / 10004)."); + + ScriptModule pAvatarModule = new ScriptModule("Avatar"); + EntityDef.moduledefs["Avatar"] = pAvatarModule; + EntityDef.idmoduledefs[2] = pAvatarModule; + + Property pAvatar_position = new Property(); + pAvatar_position.name = "position"; + pAvatar_position.properUtype = 40000; + pAvatar_position.properFlags = 4; + pAvatar_position.aliasID = 1; + Vector3 Avatar_position_defval = new Vector3(); + pAvatar_position.defaultVal = Avatar_position_defval; + pAvatarModule.propertys["position"] = pAvatar_position; + + pAvatarModule.usePropertyDescrAlias = true; + pAvatarModule.idpropertys[(UInt16)pAvatar_position.aliasID] = pAvatar_position; + + //Dbg.DEBUG_MSG("EntityDef::initScriptModules: add(Avatar), property(position / 40000)."); + + Property pAvatar_direction = new Property(); + pAvatar_direction.name = "direction"; + pAvatar_direction.properUtype = 40001; + pAvatar_direction.properFlags = 4; + pAvatar_direction.aliasID = 2; + Vector3 Avatar_direction_defval = new Vector3(); + pAvatar_direction.defaultVal = Avatar_direction_defval; + pAvatarModule.propertys["direction"] = pAvatar_direction; + + pAvatarModule.usePropertyDescrAlias = true; + pAvatarModule.idpropertys[(UInt16)pAvatar_direction.aliasID] = pAvatar_direction; + + //Dbg.DEBUG_MSG("EntityDef::initScriptModules: add(Avatar), property(direction / 40001)."); + + Property pAvatar_spaceID = new Property(); + pAvatar_spaceID.name = "spaceID"; + pAvatar_spaceID.properUtype = 40002; + pAvatar_spaceID.properFlags = 16; + pAvatar_spaceID.aliasID = 3; + UInt32 Avatar_spaceID_defval; + UInt32.TryParse("", out Avatar_spaceID_defval); + pAvatar_spaceID.defaultVal = Avatar_spaceID_defval; + pAvatarModule.propertys["spaceID"] = pAvatar_spaceID; + + pAvatarModule.usePropertyDescrAlias = true; + pAvatarModule.idpropertys[(UInt16)pAvatar_spaceID.aliasID] = pAvatar_spaceID; + + //Dbg.DEBUG_MSG("EntityDef::initScriptModules: add(Avatar), property(spaceID / 40002)."); + + Property pAvatar_HP = new Property(); + pAvatar_HP.name = "HP"; + pAvatar_HP.properUtype = 47001; + pAvatar_HP.properFlags = 4; + pAvatar_HP.aliasID = 4; + Int32 Avatar_HP_defval; + Int32.TryParse("0", out Avatar_HP_defval); + pAvatar_HP.defaultVal = Avatar_HP_defval; + pAvatarModule.propertys["HP"] = pAvatar_HP; + + pAvatarModule.usePropertyDescrAlias = true; + pAvatarModule.idpropertys[(UInt16)pAvatar_HP.aliasID] = pAvatar_HP; + + //Dbg.DEBUG_MSG("EntityDef::initScriptModules: add(Avatar), property(HP / 47001)."); + + Property pAvatar_HP_Max = new Property(); + pAvatar_HP_Max.name = "HP_Max"; + pAvatar_HP_Max.properUtype = 47002; + pAvatar_HP_Max.properFlags = 4; + pAvatar_HP_Max.aliasID = 5; + Int32 Avatar_HP_Max_defval; + Int32.TryParse("0", out Avatar_HP_Max_defval); + pAvatar_HP_Max.defaultVal = Avatar_HP_Max_defval; + pAvatarModule.propertys["HP_Max"] = pAvatar_HP_Max; + + pAvatarModule.usePropertyDescrAlias = true; + pAvatarModule.idpropertys[(UInt16)pAvatar_HP_Max.aliasID] = pAvatar_HP_Max; + + //Dbg.DEBUG_MSG("EntityDef::initScriptModules: add(Avatar), property(HP_Max / 47002)."); + + Property pAvatar_MP = new Property(); + pAvatar_MP.name = "MP"; + pAvatar_MP.properUtype = 47003; + pAvatar_MP.properFlags = 4; + pAvatar_MP.aliasID = 6; + Int32 Avatar_MP_defval; + Int32.TryParse("0", out Avatar_MP_defval); + pAvatar_MP.defaultVal = Avatar_MP_defval; + pAvatarModule.propertys["MP"] = pAvatar_MP; + + pAvatarModule.usePropertyDescrAlias = true; + pAvatarModule.idpropertys[(UInt16)pAvatar_MP.aliasID] = pAvatar_MP; + + //Dbg.DEBUG_MSG("EntityDef::initScriptModules: add(Avatar), property(MP / 47003)."); + + Property pAvatar_MP_Max = new Property(); + pAvatar_MP_Max.name = "MP_Max"; + pAvatar_MP_Max.properUtype = 47004; + pAvatar_MP_Max.properFlags = 4; + pAvatar_MP_Max.aliasID = 7; + Int32 Avatar_MP_Max_defval; + Int32.TryParse("0", out Avatar_MP_Max_defval); + pAvatar_MP_Max.defaultVal = Avatar_MP_Max_defval; + pAvatarModule.propertys["MP_Max"] = pAvatar_MP_Max; + + pAvatarModule.usePropertyDescrAlias = true; + pAvatarModule.idpropertys[(UInt16)pAvatar_MP_Max.aliasID] = pAvatar_MP_Max; + + //Dbg.DEBUG_MSG("EntityDef::initScriptModules: add(Avatar), property(MP_Max / 47004)."); + + Property pAvatar_component1 = new Property(); + pAvatar_component1.name = "component1"; + pAvatar_component1.properUtype = 16; + pAvatar_component1.properFlags = 253; + pAvatar_component1.aliasID = 8; + pAvatarModule.propertys["component1"] = pAvatar_component1; + + pAvatarModule.usePropertyDescrAlias = true; + pAvatarModule.idpropertys[(UInt16)pAvatar_component1.aliasID] = pAvatar_component1; + + //Dbg.DEBUG_MSG("EntityDef::initScriptModules: add(Avatar), property(component1 / 16)."); + + Property pAvatar_component2 = new Property(); + pAvatar_component2.name = "component2"; + pAvatar_component2.properUtype = 21; + pAvatar_component2.properFlags = 97; + pAvatar_component2.aliasID = 9; + pAvatarModule.propertys["component2"] = pAvatar_component2; + + pAvatarModule.usePropertyDescrAlias = true; + pAvatarModule.idpropertys[(UInt16)pAvatar_component2.aliasID] = pAvatar_component2; + + //Dbg.DEBUG_MSG("EntityDef::initScriptModules: add(Avatar), property(component2 / 21)."); + + Property pAvatar_component3 = new Property(); + pAvatar_component3.name = "component3"; + pAvatar_component3.properUtype = 22; + pAvatar_component3.properFlags = 157; + pAvatar_component3.aliasID = 10; + pAvatarModule.propertys["component3"] = pAvatar_component3; + + pAvatarModule.usePropertyDescrAlias = true; + pAvatarModule.idpropertys[(UInt16)pAvatar_component3.aliasID] = pAvatar_component3; + + //Dbg.DEBUG_MSG("EntityDef::initScriptModules: add(Avatar), property(component3 / 22)."); + + Property pAvatar_forbids = new Property(); + pAvatar_forbids.name = "forbids"; + pAvatar_forbids.properUtype = 47005; + pAvatar_forbids.properFlags = 4; + pAvatar_forbids.aliasID = 11; + Int32 Avatar_forbids_defval; + Int32.TryParse("0", out Avatar_forbids_defval); + pAvatar_forbids.defaultVal = Avatar_forbids_defval; + pAvatarModule.propertys["forbids"] = pAvatar_forbids; + + pAvatarModule.usePropertyDescrAlias = true; + pAvatarModule.idpropertys[(UInt16)pAvatar_forbids.aliasID] = pAvatar_forbids; + + //Dbg.DEBUG_MSG("EntityDef::initScriptModules: add(Avatar), property(forbids / 47005)."); + + Property pAvatar_level = new Property(); + pAvatar_level.name = "level"; + pAvatar_level.properUtype = 41002; + pAvatar_level.properFlags = 8; + pAvatar_level.aliasID = 12; + UInt16 Avatar_level_defval; + UInt16.TryParse("", out Avatar_level_defval); + pAvatar_level.defaultVal = Avatar_level_defval; + pAvatarModule.propertys["level"] = pAvatar_level; + + pAvatarModule.usePropertyDescrAlias = true; + pAvatarModule.idpropertys[(UInt16)pAvatar_level.aliasID] = pAvatar_level; + + //Dbg.DEBUG_MSG("EntityDef::initScriptModules: add(Avatar), property(level / 41002)."); + + Property pAvatar_modelID = new Property(); + pAvatar_modelID.name = "modelID"; + pAvatar_modelID.properUtype = 41006; + pAvatar_modelID.properFlags = 4; + pAvatar_modelID.aliasID = 13; + UInt32 Avatar_modelID_defval; + UInt32.TryParse("0", out Avatar_modelID_defval); + pAvatar_modelID.defaultVal = Avatar_modelID_defval; + pAvatarModule.propertys["modelID"] = pAvatar_modelID; + + pAvatarModule.usePropertyDescrAlias = true; + pAvatarModule.idpropertys[(UInt16)pAvatar_modelID.aliasID] = pAvatar_modelID; + + //Dbg.DEBUG_MSG("EntityDef::initScriptModules: add(Avatar), property(modelID / 41006)."); + + Property pAvatar_modelScale = new Property(); + pAvatar_modelScale.name = "modelScale"; + pAvatar_modelScale.properUtype = 41007; + pAvatar_modelScale.properFlags = 4; + pAvatar_modelScale.aliasID = 14; + Byte Avatar_modelScale_defval; + Byte.TryParse("30", out Avatar_modelScale_defval); + pAvatar_modelScale.defaultVal = Avatar_modelScale_defval; + pAvatarModule.propertys["modelScale"] = pAvatar_modelScale; + + pAvatarModule.usePropertyDescrAlias = true; + pAvatarModule.idpropertys[(UInt16)pAvatar_modelScale.aliasID] = pAvatar_modelScale; + + //Dbg.DEBUG_MSG("EntityDef::initScriptModules: add(Avatar), property(modelScale / 41007)."); + + Property pAvatar_moveSpeed = new Property(); + pAvatar_moveSpeed.name = "moveSpeed"; + pAvatar_moveSpeed.properUtype = 11; + pAvatar_moveSpeed.properFlags = 4; + pAvatar_moveSpeed.aliasID = 15; + Byte Avatar_moveSpeed_defval; + Byte.TryParse("50", out Avatar_moveSpeed_defval); + pAvatar_moveSpeed.defaultVal = Avatar_moveSpeed_defval; + pAvatarModule.propertys["moveSpeed"] = pAvatar_moveSpeed; + + pAvatarModule.usePropertyDescrAlias = true; + pAvatarModule.idpropertys[(UInt16)pAvatar_moveSpeed.aliasID] = pAvatar_moveSpeed; + + //Dbg.DEBUG_MSG("EntityDef::initScriptModules: add(Avatar), property(moveSpeed / 11)."); + + Property pAvatar_name = new Property(); + pAvatar_name.name = "name"; + pAvatar_name.properUtype = 41003; + pAvatar_name.properFlags = 4; + pAvatar_name.aliasID = 16; + string Avatar_name_defval = ""; + pAvatar_name.defaultVal = Avatar_name_defval; + pAvatarModule.propertys["name"] = pAvatar_name; + + pAvatarModule.usePropertyDescrAlias = true; + pAvatarModule.idpropertys[(UInt16)pAvatar_name.aliasID] = pAvatar_name; + + //Dbg.DEBUG_MSG("EntityDef::initScriptModules: add(Avatar), property(name / 41003)."); + + Property pAvatar_own_val = new Property(); + pAvatar_own_val.name = "own_val"; + pAvatar_own_val.properUtype = 6; + pAvatar_own_val.properFlags = 16; + pAvatar_own_val.aliasID = 17; + UInt16 Avatar_own_val_defval; + UInt16.TryParse("", out Avatar_own_val_defval); + pAvatar_own_val.defaultVal = Avatar_own_val_defval; + pAvatarModule.propertys["own_val"] = pAvatar_own_val; + + pAvatarModule.usePropertyDescrAlias = true; + pAvatarModule.idpropertys[(UInt16)pAvatar_own_val.aliasID] = pAvatar_own_val; + + //Dbg.DEBUG_MSG("EntityDef::initScriptModules: add(Avatar), property(own_val / 6)."); + + Property pAvatar_spaceUType = new Property(); + pAvatar_spaceUType.name = "spaceUType"; + pAvatar_spaceUType.properUtype = 41001; + pAvatar_spaceUType.properFlags = 8; + pAvatar_spaceUType.aliasID = 18; + UInt32 Avatar_spaceUType_defval; + UInt32.TryParse("", out Avatar_spaceUType_defval); + pAvatar_spaceUType.defaultVal = Avatar_spaceUType_defval; + pAvatarModule.propertys["spaceUType"] = pAvatar_spaceUType; + + pAvatarModule.usePropertyDescrAlias = true; + pAvatarModule.idpropertys[(UInt16)pAvatar_spaceUType.aliasID] = pAvatar_spaceUType; + + //Dbg.DEBUG_MSG("EntityDef::initScriptModules: add(Avatar), property(spaceUType / 41001)."); + + Property pAvatar_state = new Property(); + pAvatar_state.name = "state"; + pAvatar_state.properUtype = 47006; + pAvatar_state.properFlags = 4; + pAvatar_state.aliasID = 19; + SByte Avatar_state_defval; + SByte.TryParse("0", out Avatar_state_defval); + pAvatar_state.defaultVal = Avatar_state_defval; + pAvatarModule.propertys["state"] = pAvatar_state; + + pAvatarModule.usePropertyDescrAlias = true; + pAvatarModule.idpropertys[(UInt16)pAvatar_state.aliasID] = pAvatar_state; + + //Dbg.DEBUG_MSG("EntityDef::initScriptModules: add(Avatar), property(state / 47006)."); + + Property pAvatar_subState = new Property(); + pAvatar_subState.name = "subState"; + pAvatar_subState.properUtype = 47007; + pAvatar_subState.properFlags = 4; + pAvatar_subState.aliasID = 20; + Byte Avatar_subState_defval; + Byte.TryParse("", out Avatar_subState_defval); + pAvatar_subState.defaultVal = Avatar_subState_defval; + pAvatarModule.propertys["subState"] = pAvatar_subState; + + pAvatarModule.usePropertyDescrAlias = true; + pAvatarModule.idpropertys[(UInt16)pAvatar_subState.aliasID] = pAvatar_subState; + + //Dbg.DEBUG_MSG("EntityDef::initScriptModules: add(Avatar), property(subState / 47007)."); + + Property pAvatar_uid = new Property(); + pAvatar_uid.name = "uid"; + pAvatar_uid.properUtype = 41004; + pAvatar_uid.properFlags = 4; + pAvatar_uid.aliasID = 21; + UInt32 Avatar_uid_defval; + UInt32.TryParse("0", out Avatar_uid_defval); + pAvatar_uid.defaultVal = Avatar_uid_defval; + pAvatarModule.propertys["uid"] = pAvatar_uid; + + pAvatarModule.usePropertyDescrAlias = true; + pAvatarModule.idpropertys[(UInt16)pAvatar_uid.aliasID] = pAvatar_uid; + + //Dbg.DEBUG_MSG("EntityDef::initScriptModules: add(Avatar), property(uid / 41004)."); + + Property pAvatar_utype = new Property(); + pAvatar_utype.name = "utype"; + pAvatar_utype.properUtype = 41005; + pAvatar_utype.properFlags = 4; + pAvatar_utype.aliasID = 22; + UInt32 Avatar_utype_defval; + UInt32.TryParse("0", out Avatar_utype_defval); + pAvatar_utype.defaultVal = Avatar_utype_defval; + pAvatarModule.propertys["utype"] = pAvatar_utype; + + pAvatarModule.usePropertyDescrAlias = true; + pAvatarModule.idpropertys[(UInt16)pAvatar_utype.aliasID] = pAvatar_utype; + + //Dbg.DEBUG_MSG("EntityDef::initScriptModules: add(Avatar), property(utype / 41005)."); + + List pAvatar_dialog_addOption_args = new List(); + pAvatar_dialog_addOption_args.Add(EntityDef.id2datatypes[2]); + pAvatar_dialog_addOption_args.Add(EntityDef.id2datatypes[4]); + pAvatar_dialog_addOption_args.Add(EntityDef.id2datatypes[12]); + pAvatar_dialog_addOption_args.Add(EntityDef.id2datatypes[8]); + + Method pAvatar_dialog_addOption = new Method(); + pAvatar_dialog_addOption.name = "dialog_addOption"; + pAvatar_dialog_addOption.methodUtype = 10101; + pAvatar_dialog_addOption.aliasID = 1; + pAvatar_dialog_addOption.args = pAvatar_dialog_addOption_args; + + pAvatarModule.methods["dialog_addOption"] = pAvatar_dialog_addOption; + pAvatarModule.useMethodDescrAlias = true; + pAvatarModule.idmethods[(UInt16)pAvatar_dialog_addOption.aliasID] = pAvatar_dialog_addOption; + + //Dbg.DEBUG_MSG("EntityDef::initScriptModules: add(Avatar), method(dialog_addOption / 10101)."); + + List pAvatar_dialog_close_args = new List(); + + Method pAvatar_dialog_close = new Method(); + pAvatar_dialog_close.name = "dialog_close"; + pAvatar_dialog_close.methodUtype = 10104; + pAvatar_dialog_close.aliasID = 2; + pAvatar_dialog_close.args = pAvatar_dialog_close_args; + + pAvatarModule.methods["dialog_close"] = pAvatar_dialog_close; + pAvatarModule.useMethodDescrAlias = true; + pAvatarModule.idmethods[(UInt16)pAvatar_dialog_close.aliasID] = pAvatar_dialog_close; + + //Dbg.DEBUG_MSG("EntityDef::initScriptModules: add(Avatar), method(dialog_close / 10104)."); + + List pAvatar_dialog_setText_args = new List(); + pAvatar_dialog_setText_args.Add(EntityDef.id2datatypes[12]); + pAvatar_dialog_setText_args.Add(EntityDef.id2datatypes[2]); + pAvatar_dialog_setText_args.Add(EntityDef.id2datatypes[4]); + pAvatar_dialog_setText_args.Add(EntityDef.id2datatypes[12]); + + Method pAvatar_dialog_setText = new Method(); + pAvatar_dialog_setText.name = "dialog_setText"; + pAvatar_dialog_setText.methodUtype = 10102; + pAvatar_dialog_setText.aliasID = 3; + pAvatar_dialog_setText.args = pAvatar_dialog_setText_args; + + pAvatarModule.methods["dialog_setText"] = pAvatar_dialog_setText; + pAvatarModule.useMethodDescrAlias = true; + pAvatarModule.idmethods[(UInt16)pAvatar_dialog_setText.aliasID] = pAvatar_dialog_setText; + + //Dbg.DEBUG_MSG("EntityDef::initScriptModules: add(Avatar), method(dialog_setText / 10102)."); + + List pAvatar_onAddSkill_args = new List(); + pAvatar_onAddSkill_args.Add(EntityDef.id2datatypes[8]); + + Method pAvatar_onAddSkill = new Method(); + pAvatar_onAddSkill.name = "onAddSkill"; + pAvatar_onAddSkill.methodUtype = 12; + pAvatar_onAddSkill.aliasID = 4; + pAvatar_onAddSkill.args = pAvatar_onAddSkill_args; + + pAvatarModule.methods["onAddSkill"] = pAvatar_onAddSkill; + pAvatarModule.useMethodDescrAlias = true; + pAvatarModule.idmethods[(UInt16)pAvatar_onAddSkill.aliasID] = pAvatar_onAddSkill; + + //Dbg.DEBUG_MSG("EntityDef::initScriptModules: add(Avatar), method(onAddSkill / 12)."); + + List pAvatar_onJump_args = new List(); + + Method pAvatar_onJump = new Method(); + pAvatar_onJump.name = "onJump"; + pAvatar_onJump.methodUtype = 7; + pAvatar_onJump.aliasID = 5; + pAvatar_onJump.args = pAvatar_onJump_args; + + pAvatarModule.methods["onJump"] = pAvatar_onJump; + pAvatarModule.useMethodDescrAlias = true; + pAvatarModule.idmethods[(UInt16)pAvatar_onJump.aliasID] = pAvatar_onJump; + + //Dbg.DEBUG_MSG("EntityDef::initScriptModules: add(Avatar), method(onJump / 7)."); + + List pAvatar_onRemoveSkill_args = new List(); + pAvatar_onRemoveSkill_args.Add(EntityDef.id2datatypes[8]); + + Method pAvatar_onRemoveSkill = new Method(); + pAvatar_onRemoveSkill.name = "onRemoveSkill"; + pAvatar_onRemoveSkill.methodUtype = 13; + pAvatar_onRemoveSkill.aliasID = 6; + pAvatar_onRemoveSkill.args = pAvatar_onRemoveSkill_args; + + pAvatarModule.methods["onRemoveSkill"] = pAvatar_onRemoveSkill; + pAvatarModule.useMethodDescrAlias = true; + pAvatarModule.idmethods[(UInt16)pAvatar_onRemoveSkill.aliasID] = pAvatar_onRemoveSkill; + + //Dbg.DEBUG_MSG("EntityDef::initScriptModules: add(Avatar), method(onRemoveSkill / 13)."); + + List pAvatar_recvDamage_args = new List(); + pAvatar_recvDamage_args.Add(EntityDef.id2datatypes[8]); + pAvatar_recvDamage_args.Add(EntityDef.id2datatypes[8]); + pAvatar_recvDamage_args.Add(EntityDef.id2datatypes[8]); + pAvatar_recvDamage_args.Add(EntityDef.id2datatypes[8]); + + Method pAvatar_recvDamage = new Method(); + pAvatar_recvDamage.name = "recvDamage"; + pAvatar_recvDamage.methodUtype = 16; + pAvatar_recvDamage.aliasID = 7; + pAvatar_recvDamage.args = pAvatar_recvDamage_args; + + pAvatarModule.methods["recvDamage"] = pAvatar_recvDamage; + pAvatarModule.useMethodDescrAlias = true; + pAvatarModule.idmethods[(UInt16)pAvatar_recvDamage.aliasID] = pAvatar_recvDamage; + + //Dbg.DEBUG_MSG("EntityDef::initScriptModules: add(Avatar), method(recvDamage / 16)."); + + List pAvatar_dialog_args = new List(); + pAvatar_dialog_args.Add(EntityDef.id2datatypes[8]); + pAvatar_dialog_args.Add(EntityDef.id2datatypes[4]); + + Method pAvatar_dialog = new Method(); + pAvatar_dialog.name = "dialog"; + pAvatar_dialog.methodUtype = 11003; + pAvatar_dialog.aliasID = -1; + pAvatar_dialog.args = pAvatar_dialog_args; + + pAvatarModule.methods["dialog"] = pAvatar_dialog; + pAvatarModule.cell_methods["dialog"] = pAvatar_dialog; + + pAvatarModule.idcell_methods[pAvatar_dialog.methodUtype] = pAvatar_dialog; + + //Dbg.DEBUG_MSG("EntityDef::initScriptModules: add(Avatar), method(dialog / 11003)."); + + List pAvatar_jump_args = new List(); + + Method pAvatar_jump = new Method(); + pAvatar_jump.name = "jump"; + pAvatar_jump.methodUtype = 5; + pAvatar_jump.aliasID = -1; + pAvatar_jump.args = pAvatar_jump_args; + + pAvatarModule.methods["jump"] = pAvatar_jump; + pAvatarModule.cell_methods["jump"] = pAvatar_jump; + + pAvatarModule.idcell_methods[pAvatar_jump.methodUtype] = pAvatar_jump; + + //Dbg.DEBUG_MSG("EntityDef::initScriptModules: add(Avatar), method(jump / 5)."); + + List pAvatar_relive_args = new List(); + pAvatar_relive_args.Add(EntityDef.id2datatypes[2]); + + Method pAvatar_relive = new Method(); + pAvatar_relive.name = "relive"; + pAvatar_relive.methodUtype = 4; + pAvatar_relive.aliasID = -1; + pAvatar_relive.args = pAvatar_relive_args; + + pAvatarModule.methods["relive"] = pAvatar_relive; + pAvatarModule.cell_methods["relive"] = pAvatar_relive; + + pAvatarModule.idcell_methods[pAvatar_relive.methodUtype] = pAvatar_relive; + + //Dbg.DEBUG_MSG("EntityDef::initScriptModules: add(Avatar), method(relive / 4)."); + + List pAvatar_requestPull_args = new List(); + + Method pAvatar_requestPull = new Method(); + pAvatar_requestPull.name = "requestPull"; + pAvatar_requestPull.methodUtype = 11; + pAvatar_requestPull.aliasID = -1; + pAvatar_requestPull.args = pAvatar_requestPull_args; + + pAvatarModule.methods["requestPull"] = pAvatar_requestPull; + pAvatarModule.cell_methods["requestPull"] = pAvatar_requestPull; + + pAvatarModule.idcell_methods[pAvatar_requestPull.methodUtype] = pAvatar_requestPull; + + //Dbg.DEBUG_MSG("EntityDef::initScriptModules: add(Avatar), method(requestPull / 11)."); + + List pAvatar_useTargetSkill_args = new List(); + pAvatar_useTargetSkill_args.Add(EntityDef.id2datatypes[8]); + pAvatar_useTargetSkill_args.Add(EntityDef.id2datatypes[8]); + + Method pAvatar_useTargetSkill = new Method(); + pAvatar_useTargetSkill.name = "useTargetSkill"; + pAvatar_useTargetSkill.methodUtype = 11001; + pAvatar_useTargetSkill.aliasID = -1; + pAvatar_useTargetSkill.args = pAvatar_useTargetSkill_args; + + pAvatarModule.methods["useTargetSkill"] = pAvatar_useTargetSkill; + pAvatarModule.cell_methods["useTargetSkill"] = pAvatar_useTargetSkill; + + pAvatarModule.idcell_methods[pAvatar_useTargetSkill.methodUtype] = pAvatar_useTargetSkill; + + //Dbg.DEBUG_MSG("EntityDef::initScriptModules: add(Avatar), method(useTargetSkill / 11001)."); + + ScriptModule pTestModule = new ScriptModule("Test"); + EntityDef.moduledefs["Test"] = pTestModule; + EntityDef.idmoduledefs[3] = pTestModule; + + Property pTest_position = new Property(); + pTest_position.name = "position"; + pTest_position.properUtype = 40000; + pTest_position.properFlags = 4; + pTest_position.aliasID = 1; + Vector3 Test_position_defval = new Vector3(); + pTest_position.defaultVal = Test_position_defval; + pTestModule.propertys["position"] = pTest_position; + + pTestModule.usePropertyDescrAlias = true; + pTestModule.idpropertys[(UInt16)pTest_position.aliasID] = pTest_position; + + //Dbg.DEBUG_MSG("EntityDef::initScriptModules: add(Test), property(position / 40000)."); + + Property pTest_direction = new Property(); + pTest_direction.name = "direction"; + pTest_direction.properUtype = 40001; + pTest_direction.properFlags = 4; + pTest_direction.aliasID = 2; + Vector3 Test_direction_defval = new Vector3(); + pTest_direction.defaultVal = Test_direction_defval; + pTestModule.propertys["direction"] = pTest_direction; + + pTestModule.usePropertyDescrAlias = true; + pTestModule.idpropertys[(UInt16)pTest_direction.aliasID] = pTest_direction; + + //Dbg.DEBUG_MSG("EntityDef::initScriptModules: add(Test), property(direction / 40001)."); + + Property pTest_spaceID = new Property(); + pTest_spaceID.name = "spaceID"; + pTest_spaceID.properUtype = 40002; + pTest_spaceID.properFlags = 16; + pTest_spaceID.aliasID = 3; + UInt32 Test_spaceID_defval; + UInt32.TryParse("", out Test_spaceID_defval); + pTest_spaceID.defaultVal = Test_spaceID_defval; + pTestModule.propertys["spaceID"] = pTest_spaceID; + + pTestModule.usePropertyDescrAlias = true; + pTestModule.idpropertys[(UInt16)pTest_spaceID.aliasID] = pTest_spaceID; + + //Dbg.DEBUG_MSG("EntityDef::initScriptModules: add(Test), property(spaceID / 40002)."); + + Property pTest_own = new Property(); + pTest_own.name = "own"; + pTest_own.properUtype = 18; + pTest_own.properFlags = 8; + pTest_own.aliasID = 4; + Int32 Test_own_defval; + Int32.TryParse("1001", out Test_own_defval); + pTest_own.defaultVal = Test_own_defval; + pTestModule.propertys["own"] = pTest_own; + + pTestModule.usePropertyDescrAlias = true; + pTestModule.idpropertys[(UInt16)pTest_own.aliasID] = pTest_own; + + //Dbg.DEBUG_MSG("EntityDef::initScriptModules: add(Test), property(own / 18)."); + + Property pTest_state = new Property(); + pTest_state.name = "state"; + pTest_state.properUtype = 17; + pTest_state.properFlags = 4; + pTest_state.aliasID = 5; + Int32 Test_state_defval; + Int32.TryParse("100", out Test_state_defval); + pTest_state.defaultVal = Test_state_defval; + pTestModule.propertys["state"] = pTest_state; + + pTestModule.usePropertyDescrAlias = true; + pTestModule.idpropertys[(UInt16)pTest_state.aliasID] = pTest_state; + + //Dbg.DEBUG_MSG("EntityDef::initScriptModules: add(Test), property(state / 17)."); + + List pTest_helloCB_args = new List(); + pTest_helloCB_args.Add(EntityDef.id2datatypes[8]); + + Method pTest_helloCB = new Method(); + pTest_helloCB.name = "helloCB"; + pTest_helloCB.methodUtype = 28; + pTest_helloCB.aliasID = 1; + pTest_helloCB.args = pTest_helloCB_args; + + pTestModule.methods["helloCB"] = pTest_helloCB; + pTestModule.useMethodDescrAlias = true; + pTestModule.idmethods[(UInt16)pTest_helloCB.aliasID] = pTest_helloCB; + + //Dbg.DEBUG_MSG("EntityDef::initScriptModules: add(Test), method(helloCB / 28)."); + + List pTest_say_args = new List(); + pTest_say_args.Add(EntityDef.id2datatypes[8]); + + Method pTest_say = new Method(); + pTest_say.name = "say"; + pTest_say.methodUtype = 27; + pTest_say.aliasID = -1; + pTest_say.args = pTest_say_args; + + pTestModule.methods["say"] = pTest_say; + pTestModule.base_methods["say"] = pTest_say; + + pTestModule.idbase_methods[pTest_say.methodUtype] = pTest_say; + + //Dbg.DEBUG_MSG("EntityDef::initScriptModules: add(Test), method(say / 27)."); + + List pTest_hello_args = new List(); + pTest_hello_args.Add(EntityDef.id2datatypes[8]); + + Method pTest_hello = new Method(); + pTest_hello.name = "hello"; + pTest_hello.methodUtype = 26; + pTest_hello.aliasID = -1; + pTest_hello.args = pTest_hello_args; + + pTestModule.methods["hello"] = pTest_hello; + pTestModule.cell_methods["hello"] = pTest_hello; + + pTestModule.idcell_methods[pTest_hello.methodUtype] = pTest_hello; + + //Dbg.DEBUG_MSG("EntityDef::initScriptModules: add(Test), method(hello / 26)."); + + ScriptModule pTestNoBaseModule = new ScriptModule("TestNoBase"); + EntityDef.moduledefs["TestNoBase"] = pTestNoBaseModule; + EntityDef.idmoduledefs[4] = pTestNoBaseModule; + + Property pTestNoBase_position = new Property(); + pTestNoBase_position.name = "position"; + pTestNoBase_position.properUtype = 40000; + pTestNoBase_position.properFlags = 4; + pTestNoBase_position.aliasID = 1; + Vector3 TestNoBase_position_defval = new Vector3(); + pTestNoBase_position.defaultVal = TestNoBase_position_defval; + pTestNoBaseModule.propertys["position"] = pTestNoBase_position; + + pTestNoBaseModule.usePropertyDescrAlias = true; + pTestNoBaseModule.idpropertys[(UInt16)pTestNoBase_position.aliasID] = pTestNoBase_position; + + //Dbg.DEBUG_MSG("EntityDef::initScriptModules: add(TestNoBase), property(position / 40000)."); + + Property pTestNoBase_direction = new Property(); + pTestNoBase_direction.name = "direction"; + pTestNoBase_direction.properUtype = 40001; + pTestNoBase_direction.properFlags = 4; + pTestNoBase_direction.aliasID = 2; + Vector3 TestNoBase_direction_defval = new Vector3(); + pTestNoBase_direction.defaultVal = TestNoBase_direction_defval; + pTestNoBaseModule.propertys["direction"] = pTestNoBase_direction; + + pTestNoBaseModule.usePropertyDescrAlias = true; + pTestNoBaseModule.idpropertys[(UInt16)pTestNoBase_direction.aliasID] = pTestNoBase_direction; + + //Dbg.DEBUG_MSG("EntityDef::initScriptModules: add(TestNoBase), property(direction / 40001)."); + + Property pTestNoBase_spaceID = new Property(); + pTestNoBase_spaceID.name = "spaceID"; + pTestNoBase_spaceID.properUtype = 40002; + pTestNoBase_spaceID.properFlags = 16; + pTestNoBase_spaceID.aliasID = 3; + UInt32 TestNoBase_spaceID_defval; + UInt32.TryParse("", out TestNoBase_spaceID_defval); + pTestNoBase_spaceID.defaultVal = TestNoBase_spaceID_defval; + pTestNoBaseModule.propertys["spaceID"] = pTestNoBase_spaceID; + + pTestNoBaseModule.usePropertyDescrAlias = true; + pTestNoBaseModule.idpropertys[(UInt16)pTestNoBase_spaceID.aliasID] = pTestNoBase_spaceID; + + //Dbg.DEBUG_MSG("EntityDef::initScriptModules: add(TestNoBase), property(spaceID / 40002)."); + + Property pTestNoBase_own = new Property(); + pTestNoBase_own.name = "own"; + pTestNoBase_own.properUtype = 24; + pTestNoBase_own.properFlags = 8; + pTestNoBase_own.aliasID = 4; + Int32 TestNoBase_own_defval; + Int32.TryParse("1001", out TestNoBase_own_defval); + pTestNoBase_own.defaultVal = TestNoBase_own_defval; + pTestNoBaseModule.propertys["own"] = pTestNoBase_own; + + pTestNoBaseModule.usePropertyDescrAlias = true; + pTestNoBaseModule.idpropertys[(UInt16)pTestNoBase_own.aliasID] = pTestNoBase_own; + + //Dbg.DEBUG_MSG("EntityDef::initScriptModules: add(TestNoBase), property(own / 24)."); + + Property pTestNoBase_state = new Property(); + pTestNoBase_state.name = "state"; + pTestNoBase_state.properUtype = 23; + pTestNoBase_state.properFlags = 4; + pTestNoBase_state.aliasID = 5; + Int32 TestNoBase_state_defval; + Int32.TryParse("100", out TestNoBase_state_defval); + pTestNoBase_state.defaultVal = TestNoBase_state_defval; + pTestNoBaseModule.propertys["state"] = pTestNoBase_state; + + pTestNoBaseModule.usePropertyDescrAlias = true; + pTestNoBaseModule.idpropertys[(UInt16)pTestNoBase_state.aliasID] = pTestNoBase_state; + + //Dbg.DEBUG_MSG("EntityDef::initScriptModules: add(TestNoBase), property(state / 23)."); + + List pTestNoBase_helloCB_args = new List(); + pTestNoBase_helloCB_args.Add(EntityDef.id2datatypes[8]); + + Method pTestNoBase_helloCB = new Method(); + pTestNoBase_helloCB.name = "helloCB"; + pTestNoBase_helloCB.methodUtype = 30; + pTestNoBase_helloCB.aliasID = 1; + pTestNoBase_helloCB.args = pTestNoBase_helloCB_args; + + pTestNoBaseModule.methods["helloCB"] = pTestNoBase_helloCB; + pTestNoBaseModule.useMethodDescrAlias = true; + pTestNoBaseModule.idmethods[(UInt16)pTestNoBase_helloCB.aliasID] = pTestNoBase_helloCB; + + //Dbg.DEBUG_MSG("EntityDef::initScriptModules: add(TestNoBase), method(helloCB / 30)."); + + List pTestNoBase_hello_args = new List(); + pTestNoBase_hello_args.Add(EntityDef.id2datatypes[8]); + + Method pTestNoBase_hello = new Method(); + pTestNoBase_hello.name = "hello"; + pTestNoBase_hello.methodUtype = 29; + pTestNoBase_hello.aliasID = -1; + pTestNoBase_hello.args = pTestNoBase_hello_args; + + pTestNoBaseModule.methods["hello"] = pTestNoBase_hello; + pTestNoBaseModule.cell_methods["hello"] = pTestNoBase_hello; + + pTestNoBaseModule.idcell_methods[pTestNoBase_hello.methodUtype] = pTestNoBase_hello; + + //Dbg.DEBUG_MSG("EntityDef::initScriptModules: add(TestNoBase), method(hello / 29)."); + + ScriptModule pMonsterModule = new ScriptModule("Monster"); + EntityDef.moduledefs["Monster"] = pMonsterModule; + EntityDef.idmoduledefs[5] = pMonsterModule; + + Property pMonster_position = new Property(); + pMonster_position.name = "position"; + pMonster_position.properUtype = 40000; + pMonster_position.properFlags = 4; + pMonster_position.aliasID = 1; + Vector3 Monster_position_defval = new Vector3(); + pMonster_position.defaultVal = Monster_position_defval; + pMonsterModule.propertys["position"] = pMonster_position; + + pMonsterModule.usePropertyDescrAlias = true; + pMonsterModule.idpropertys[(UInt16)pMonster_position.aliasID] = pMonster_position; + + //Dbg.DEBUG_MSG("EntityDef::initScriptModules: add(Monster), property(position / 40000)."); + + Property pMonster_direction = new Property(); + pMonster_direction.name = "direction"; + pMonster_direction.properUtype = 40001; + pMonster_direction.properFlags = 4; + pMonster_direction.aliasID = 2; + Vector3 Monster_direction_defval = new Vector3(); + pMonster_direction.defaultVal = Monster_direction_defval; + pMonsterModule.propertys["direction"] = pMonster_direction; + + pMonsterModule.usePropertyDescrAlias = true; + pMonsterModule.idpropertys[(UInt16)pMonster_direction.aliasID] = pMonster_direction; + + //Dbg.DEBUG_MSG("EntityDef::initScriptModules: add(Monster), property(direction / 40001)."); + + Property pMonster_spaceID = new Property(); + pMonster_spaceID.name = "spaceID"; + pMonster_spaceID.properUtype = 40002; + pMonster_spaceID.properFlags = 16; + pMonster_spaceID.aliasID = 3; + UInt32 Monster_spaceID_defval; + UInt32.TryParse("", out Monster_spaceID_defval); + pMonster_spaceID.defaultVal = Monster_spaceID_defval; + pMonsterModule.propertys["spaceID"] = pMonster_spaceID; + + pMonsterModule.usePropertyDescrAlias = true; + pMonsterModule.idpropertys[(UInt16)pMonster_spaceID.aliasID] = pMonster_spaceID; + + //Dbg.DEBUG_MSG("EntityDef::initScriptModules: add(Monster), property(spaceID / 40002)."); + + Property pMonster_HP = new Property(); + pMonster_HP.name = "HP"; + pMonster_HP.properUtype = 47001; + pMonster_HP.properFlags = 4; + pMonster_HP.aliasID = 4; + Int32 Monster_HP_defval; + Int32.TryParse("0", out Monster_HP_defval); + pMonster_HP.defaultVal = Monster_HP_defval; + pMonsterModule.propertys["HP"] = pMonster_HP; + + pMonsterModule.usePropertyDescrAlias = true; + pMonsterModule.idpropertys[(UInt16)pMonster_HP.aliasID] = pMonster_HP; + + //Dbg.DEBUG_MSG("EntityDef::initScriptModules: add(Monster), property(HP / 47001)."); + + Property pMonster_HP_Max = new Property(); + pMonster_HP_Max.name = "HP_Max"; + pMonster_HP_Max.properUtype = 47002; + pMonster_HP_Max.properFlags = 4; + pMonster_HP_Max.aliasID = 5; + Int32 Monster_HP_Max_defval; + Int32.TryParse("0", out Monster_HP_Max_defval); + pMonster_HP_Max.defaultVal = Monster_HP_Max_defval; + pMonsterModule.propertys["HP_Max"] = pMonster_HP_Max; + + pMonsterModule.usePropertyDescrAlias = true; + pMonsterModule.idpropertys[(UInt16)pMonster_HP_Max.aliasID] = pMonster_HP_Max; + + //Dbg.DEBUG_MSG("EntityDef::initScriptModules: add(Monster), property(HP_Max / 47002)."); + + Property pMonster_MP = new Property(); + pMonster_MP.name = "MP"; + pMonster_MP.properUtype = 47003; + pMonster_MP.properFlags = 4; + pMonster_MP.aliasID = 6; + Int32 Monster_MP_defval; + Int32.TryParse("0", out Monster_MP_defval); + pMonster_MP.defaultVal = Monster_MP_defval; + pMonsterModule.propertys["MP"] = pMonster_MP; + + pMonsterModule.usePropertyDescrAlias = true; + pMonsterModule.idpropertys[(UInt16)pMonster_MP.aliasID] = pMonster_MP; + + //Dbg.DEBUG_MSG("EntityDef::initScriptModules: add(Monster), property(MP / 47003)."); + + Property pMonster_MP_Max = new Property(); + pMonster_MP_Max.name = "MP_Max"; + pMonster_MP_Max.properUtype = 47004; + pMonster_MP_Max.properFlags = 4; + pMonster_MP_Max.aliasID = 7; + Int32 Monster_MP_Max_defval; + Int32.TryParse("0", out Monster_MP_Max_defval); + pMonster_MP_Max.defaultVal = Monster_MP_Max_defval; + pMonsterModule.propertys["MP_Max"] = pMonster_MP_Max; + + pMonsterModule.usePropertyDescrAlias = true; + pMonsterModule.idpropertys[(UInt16)pMonster_MP_Max.aliasID] = pMonster_MP_Max; + + //Dbg.DEBUG_MSG("EntityDef::initScriptModules: add(Monster), property(MP_Max / 47004)."); + + Property pMonster_entityNO = new Property(); + pMonster_entityNO.name = "entityNO"; + pMonster_entityNO.properUtype = 51007; + pMonster_entityNO.properFlags = 4; + pMonster_entityNO.aliasID = 8; + UInt32 Monster_entityNO_defval; + UInt32.TryParse("0", out Monster_entityNO_defval); + pMonster_entityNO.defaultVal = Monster_entityNO_defval; + pMonsterModule.propertys["entityNO"] = pMonster_entityNO; + + pMonsterModule.usePropertyDescrAlias = true; + pMonsterModule.idpropertys[(UInt16)pMonster_entityNO.aliasID] = pMonster_entityNO; + + //Dbg.DEBUG_MSG("EntityDef::initScriptModules: add(Monster), property(entityNO / 51007)."); + + Property pMonster_forbids = new Property(); + pMonster_forbids.name = "forbids"; + pMonster_forbids.properUtype = 47005; + pMonster_forbids.properFlags = 4; + pMonster_forbids.aliasID = 9; + Int32 Monster_forbids_defval; + Int32.TryParse("0", out Monster_forbids_defval); + pMonster_forbids.defaultVal = Monster_forbids_defval; + pMonsterModule.propertys["forbids"] = pMonster_forbids; + + pMonsterModule.usePropertyDescrAlias = true; + pMonsterModule.idpropertys[(UInt16)pMonster_forbids.aliasID] = pMonster_forbids; + + //Dbg.DEBUG_MSG("EntityDef::initScriptModules: add(Monster), property(forbids / 47005)."); + + Property pMonster_modelID = new Property(); + pMonster_modelID.name = "modelID"; + pMonster_modelID.properUtype = 41006; + pMonster_modelID.properFlags = 4; + pMonster_modelID.aliasID = 10; + UInt32 Monster_modelID_defval; + UInt32.TryParse("0", out Monster_modelID_defval); + pMonster_modelID.defaultVal = Monster_modelID_defval; + pMonsterModule.propertys["modelID"] = pMonster_modelID; + + pMonsterModule.usePropertyDescrAlias = true; + pMonsterModule.idpropertys[(UInt16)pMonster_modelID.aliasID] = pMonster_modelID; + + //Dbg.DEBUG_MSG("EntityDef::initScriptModules: add(Monster), property(modelID / 41006)."); + + Property pMonster_modelScale = new Property(); + pMonster_modelScale.name = "modelScale"; + pMonster_modelScale.properUtype = 41007; + pMonster_modelScale.properFlags = 4; + pMonster_modelScale.aliasID = 11; + Byte Monster_modelScale_defval; + Byte.TryParse("30", out Monster_modelScale_defval); + pMonster_modelScale.defaultVal = Monster_modelScale_defval; + pMonsterModule.propertys["modelScale"] = pMonster_modelScale; + + pMonsterModule.usePropertyDescrAlias = true; + pMonsterModule.idpropertys[(UInt16)pMonster_modelScale.aliasID] = pMonster_modelScale; + + //Dbg.DEBUG_MSG("EntityDef::initScriptModules: add(Monster), property(modelScale / 41007)."); + + Property pMonster_moveSpeed = new Property(); + pMonster_moveSpeed.name = "moveSpeed"; + pMonster_moveSpeed.properUtype = 32; + pMonster_moveSpeed.properFlags = 4; + pMonster_moveSpeed.aliasID = 12; + Byte Monster_moveSpeed_defval; + Byte.TryParse("50", out Monster_moveSpeed_defval); + pMonster_moveSpeed.defaultVal = Monster_moveSpeed_defval; + pMonsterModule.propertys["moveSpeed"] = pMonster_moveSpeed; + + pMonsterModule.usePropertyDescrAlias = true; + pMonsterModule.idpropertys[(UInt16)pMonster_moveSpeed.aliasID] = pMonster_moveSpeed; + + //Dbg.DEBUG_MSG("EntityDef::initScriptModules: add(Monster), property(moveSpeed / 32)."); + + Property pMonster_name = new Property(); + pMonster_name.name = "name"; + pMonster_name.properUtype = 41003; + pMonster_name.properFlags = 4; + pMonster_name.aliasID = 13; + string Monster_name_defval = ""; + pMonster_name.defaultVal = Monster_name_defval; + pMonsterModule.propertys["name"] = pMonster_name; + + pMonsterModule.usePropertyDescrAlias = true; + pMonsterModule.idpropertys[(UInt16)pMonster_name.aliasID] = pMonster_name; + + //Dbg.DEBUG_MSG("EntityDef::initScriptModules: add(Monster), property(name / 41003)."); + + Property pMonster_state = new Property(); + pMonster_state.name = "state"; + pMonster_state.properUtype = 47006; + pMonster_state.properFlags = 4; + pMonster_state.aliasID = 14; + SByte Monster_state_defval; + SByte.TryParse("0", out Monster_state_defval); + pMonster_state.defaultVal = Monster_state_defval; + pMonsterModule.propertys["state"] = pMonster_state; + + pMonsterModule.usePropertyDescrAlias = true; + pMonsterModule.idpropertys[(UInt16)pMonster_state.aliasID] = pMonster_state; + + //Dbg.DEBUG_MSG("EntityDef::initScriptModules: add(Monster), property(state / 47006)."); + + Property pMonster_subState = new Property(); + pMonster_subState.name = "subState"; + pMonster_subState.properUtype = 47007; + pMonster_subState.properFlags = 4; + pMonster_subState.aliasID = 15; + Byte Monster_subState_defval; + Byte.TryParse("", out Monster_subState_defval); + pMonster_subState.defaultVal = Monster_subState_defval; + pMonsterModule.propertys["subState"] = pMonster_subState; + + pMonsterModule.usePropertyDescrAlias = true; + pMonsterModule.idpropertys[(UInt16)pMonster_subState.aliasID] = pMonster_subState; + + //Dbg.DEBUG_MSG("EntityDef::initScriptModules: add(Monster), property(subState / 47007)."); + + Property pMonster_uid = new Property(); + pMonster_uid.name = "uid"; + pMonster_uid.properUtype = 41004; + pMonster_uid.properFlags = 4; + pMonster_uid.aliasID = 16; + UInt32 Monster_uid_defval; + UInt32.TryParse("0", out Monster_uid_defval); + pMonster_uid.defaultVal = Monster_uid_defval; + pMonsterModule.propertys["uid"] = pMonster_uid; + + pMonsterModule.usePropertyDescrAlias = true; + pMonsterModule.idpropertys[(UInt16)pMonster_uid.aliasID] = pMonster_uid; + + //Dbg.DEBUG_MSG("EntityDef::initScriptModules: add(Monster), property(uid / 41004)."); + + Property pMonster_utype = new Property(); + pMonster_utype.name = "utype"; + pMonster_utype.properUtype = 41005; + pMonster_utype.properFlags = 4; + pMonster_utype.aliasID = 17; + UInt32 Monster_utype_defval; + UInt32.TryParse("0", out Monster_utype_defval); + pMonster_utype.defaultVal = Monster_utype_defval; + pMonsterModule.propertys["utype"] = pMonster_utype; + + pMonsterModule.usePropertyDescrAlias = true; + pMonsterModule.idpropertys[(UInt16)pMonster_utype.aliasID] = pMonster_utype; + + //Dbg.DEBUG_MSG("EntityDef::initScriptModules: add(Monster), property(utype / 41005)."); + + List pMonster_recvDamage_args = new List(); + pMonster_recvDamage_args.Add(EntityDef.id2datatypes[8]); + pMonster_recvDamage_args.Add(EntityDef.id2datatypes[8]); + pMonster_recvDamage_args.Add(EntityDef.id2datatypes[8]); + pMonster_recvDamage_args.Add(EntityDef.id2datatypes[8]); + + Method pMonster_recvDamage = new Method(); + pMonster_recvDamage.name = "recvDamage"; + pMonster_recvDamage.methodUtype = 34; + pMonster_recvDamage.aliasID = 1; + pMonster_recvDamage.args = pMonster_recvDamage_args; + + pMonsterModule.methods["recvDamage"] = pMonster_recvDamage; + pMonsterModule.useMethodDescrAlias = true; + pMonsterModule.idmethods[(UInt16)pMonster_recvDamage.aliasID] = pMonster_recvDamage; + + //Dbg.DEBUG_MSG("EntityDef::initScriptModules: add(Monster), method(recvDamage / 34)."); + + ScriptModule pNPCModule = new ScriptModule("NPC"); + EntityDef.moduledefs["NPC"] = pNPCModule; + EntityDef.idmoduledefs[6] = pNPCModule; + + Property pNPC_position = new Property(); + pNPC_position.name = "position"; + pNPC_position.properUtype = 40000; + pNPC_position.properFlags = 4; + pNPC_position.aliasID = 1; + Vector3 NPC_position_defval = new Vector3(); + pNPC_position.defaultVal = NPC_position_defval; + pNPCModule.propertys["position"] = pNPC_position; + + pNPCModule.usePropertyDescrAlias = true; + pNPCModule.idpropertys[(UInt16)pNPC_position.aliasID] = pNPC_position; + + //Dbg.DEBUG_MSG("EntityDef::initScriptModules: add(NPC), property(position / 40000)."); + + Property pNPC_direction = new Property(); + pNPC_direction.name = "direction"; + pNPC_direction.properUtype = 40001; + pNPC_direction.properFlags = 4; + pNPC_direction.aliasID = 2; + Vector3 NPC_direction_defval = new Vector3(); + pNPC_direction.defaultVal = NPC_direction_defval; + pNPCModule.propertys["direction"] = pNPC_direction; + + pNPCModule.usePropertyDescrAlias = true; + pNPCModule.idpropertys[(UInt16)pNPC_direction.aliasID] = pNPC_direction; + + //Dbg.DEBUG_MSG("EntityDef::initScriptModules: add(NPC), property(direction / 40001)."); + + Property pNPC_spaceID = new Property(); + pNPC_spaceID.name = "spaceID"; + pNPC_spaceID.properUtype = 40002; + pNPC_spaceID.properFlags = 16; + pNPC_spaceID.aliasID = 3; + UInt32 NPC_spaceID_defval; + UInt32.TryParse("", out NPC_spaceID_defval); + pNPC_spaceID.defaultVal = NPC_spaceID_defval; + pNPCModule.propertys["spaceID"] = pNPC_spaceID; + + pNPCModule.usePropertyDescrAlias = true; + pNPCModule.idpropertys[(UInt16)pNPC_spaceID.aliasID] = pNPC_spaceID; + + //Dbg.DEBUG_MSG("EntityDef::initScriptModules: add(NPC), property(spaceID / 40002)."); + + Property pNPC_entityNO = new Property(); + pNPC_entityNO.name = "entityNO"; + pNPC_entityNO.properUtype = 51007; + pNPC_entityNO.properFlags = 4; + pNPC_entityNO.aliasID = 4; + UInt32 NPC_entityNO_defval; + UInt32.TryParse("0", out NPC_entityNO_defval); + pNPC_entityNO.defaultVal = NPC_entityNO_defval; + pNPCModule.propertys["entityNO"] = pNPC_entityNO; + + pNPCModule.usePropertyDescrAlias = true; + pNPCModule.idpropertys[(UInt16)pNPC_entityNO.aliasID] = pNPC_entityNO; + + //Dbg.DEBUG_MSG("EntityDef::initScriptModules: add(NPC), property(entityNO / 51007)."); + + Property pNPC_modelID = new Property(); + pNPC_modelID.name = "modelID"; + pNPC_modelID.properUtype = 41006; + pNPC_modelID.properFlags = 4; + pNPC_modelID.aliasID = 5; + UInt32 NPC_modelID_defval; + UInt32.TryParse("0", out NPC_modelID_defval); + pNPC_modelID.defaultVal = NPC_modelID_defval; + pNPCModule.propertys["modelID"] = pNPC_modelID; + + pNPCModule.usePropertyDescrAlias = true; + pNPCModule.idpropertys[(UInt16)pNPC_modelID.aliasID] = pNPC_modelID; + + //Dbg.DEBUG_MSG("EntityDef::initScriptModules: add(NPC), property(modelID / 41006)."); + + Property pNPC_modelScale = new Property(); + pNPC_modelScale.name = "modelScale"; + pNPC_modelScale.properUtype = 41007; + pNPC_modelScale.properFlags = 4; + pNPC_modelScale.aliasID = 6; + Byte NPC_modelScale_defval; + Byte.TryParse("30", out NPC_modelScale_defval); + pNPC_modelScale.defaultVal = NPC_modelScale_defval; + pNPCModule.propertys["modelScale"] = pNPC_modelScale; + + pNPCModule.usePropertyDescrAlias = true; + pNPCModule.idpropertys[(UInt16)pNPC_modelScale.aliasID] = pNPC_modelScale; + + //Dbg.DEBUG_MSG("EntityDef::initScriptModules: add(NPC), property(modelScale / 41007)."); + + Property pNPC_moveSpeed = new Property(); + pNPC_moveSpeed.name = "moveSpeed"; + pNPC_moveSpeed.properUtype = 43; + pNPC_moveSpeed.properFlags = 4; + pNPC_moveSpeed.aliasID = 7; + Byte NPC_moveSpeed_defval; + Byte.TryParse("50", out NPC_moveSpeed_defval); + pNPC_moveSpeed.defaultVal = NPC_moveSpeed_defval; + pNPCModule.propertys["moveSpeed"] = pNPC_moveSpeed; + + pNPCModule.usePropertyDescrAlias = true; + pNPCModule.idpropertys[(UInt16)pNPC_moveSpeed.aliasID] = pNPC_moveSpeed; + + //Dbg.DEBUG_MSG("EntityDef::initScriptModules: add(NPC), property(moveSpeed / 43)."); + + Property pNPC_name = new Property(); + pNPC_name.name = "name"; + pNPC_name.properUtype = 41003; + pNPC_name.properFlags = 4; + pNPC_name.aliasID = 8; + string NPC_name_defval = ""; + pNPC_name.defaultVal = NPC_name_defval; + pNPCModule.propertys["name"] = pNPC_name; + + pNPCModule.usePropertyDescrAlias = true; + pNPCModule.idpropertys[(UInt16)pNPC_name.aliasID] = pNPC_name; + + //Dbg.DEBUG_MSG("EntityDef::initScriptModules: add(NPC), property(name / 41003)."); + + Property pNPC_uid = new Property(); + pNPC_uid.name = "uid"; + pNPC_uid.properUtype = 41004; + pNPC_uid.properFlags = 4; + pNPC_uid.aliasID = 9; + UInt32 NPC_uid_defval; + UInt32.TryParse("0", out NPC_uid_defval); + pNPC_uid.defaultVal = NPC_uid_defval; + pNPCModule.propertys["uid"] = pNPC_uid; + + pNPCModule.usePropertyDescrAlias = true; + pNPCModule.idpropertys[(UInt16)pNPC_uid.aliasID] = pNPC_uid; + + //Dbg.DEBUG_MSG("EntityDef::initScriptModules: add(NPC), property(uid / 41004)."); + + Property pNPC_utype = new Property(); + pNPC_utype.name = "utype"; + pNPC_utype.properUtype = 41005; + pNPC_utype.properFlags = 4; + pNPC_utype.aliasID = 10; + UInt32 NPC_utype_defval; + UInt32.TryParse("0", out NPC_utype_defval); + pNPC_utype.defaultVal = NPC_utype_defval; + pNPCModule.propertys["utype"] = pNPC_utype; + + pNPCModule.usePropertyDescrAlias = true; + pNPCModule.idpropertys[(UInt16)pNPC_utype.aliasID] = pNPC_utype; + + //Dbg.DEBUG_MSG("EntityDef::initScriptModules: add(NPC), property(utype / 41005)."); + + pNPCModule.useMethodDescrAlias = true; + ScriptModule pGateModule = new ScriptModule("Gate"); + EntityDef.moduledefs["Gate"] = pGateModule; + EntityDef.idmoduledefs[7] = pGateModule; + + Property pGate_position = new Property(); + pGate_position.name = "position"; + pGate_position.properUtype = 40000; + pGate_position.properFlags = 4; + pGate_position.aliasID = 1; + Vector3 Gate_position_defval = new Vector3(); + pGate_position.defaultVal = Gate_position_defval; + pGateModule.propertys["position"] = pGate_position; + + pGateModule.usePropertyDescrAlias = true; + pGateModule.idpropertys[(UInt16)pGate_position.aliasID] = pGate_position; + + //Dbg.DEBUG_MSG("EntityDef::initScriptModules: add(Gate), property(position / 40000)."); + + Property pGate_direction = new Property(); + pGate_direction.name = "direction"; + pGate_direction.properUtype = 40001; + pGate_direction.properFlags = 4; + pGate_direction.aliasID = 2; + Vector3 Gate_direction_defval = new Vector3(); + pGate_direction.defaultVal = Gate_direction_defval; + pGateModule.propertys["direction"] = pGate_direction; + + pGateModule.usePropertyDescrAlias = true; + pGateModule.idpropertys[(UInt16)pGate_direction.aliasID] = pGate_direction; + + //Dbg.DEBUG_MSG("EntityDef::initScriptModules: add(Gate), property(direction / 40001)."); + + Property pGate_spaceID = new Property(); + pGate_spaceID.name = "spaceID"; + pGate_spaceID.properUtype = 40002; + pGate_spaceID.properFlags = 16; + pGate_spaceID.aliasID = 3; + UInt32 Gate_spaceID_defval; + UInt32.TryParse("", out Gate_spaceID_defval); + pGate_spaceID.defaultVal = Gate_spaceID_defval; + pGateModule.propertys["spaceID"] = pGate_spaceID; + + pGateModule.usePropertyDescrAlias = true; + pGateModule.idpropertys[(UInt16)pGate_spaceID.aliasID] = pGate_spaceID; + + //Dbg.DEBUG_MSG("EntityDef::initScriptModules: add(Gate), property(spaceID / 40002)."); + + Property pGate_entityNO = new Property(); + pGate_entityNO.name = "entityNO"; + pGate_entityNO.properUtype = 51007; + pGate_entityNO.properFlags = 4; + pGate_entityNO.aliasID = 4; + UInt32 Gate_entityNO_defval; + UInt32.TryParse("0", out Gate_entityNO_defval); + pGate_entityNO.defaultVal = Gate_entityNO_defval; + pGateModule.propertys["entityNO"] = pGate_entityNO; + + pGateModule.usePropertyDescrAlias = true; + pGateModule.idpropertys[(UInt16)pGate_entityNO.aliasID] = pGate_entityNO; + + //Dbg.DEBUG_MSG("EntityDef::initScriptModules: add(Gate), property(entityNO / 51007)."); + + Property pGate_modelID = new Property(); + pGate_modelID.name = "modelID"; + pGate_modelID.properUtype = 41006; + pGate_modelID.properFlags = 4; + pGate_modelID.aliasID = 5; + UInt32 Gate_modelID_defval; + UInt32.TryParse("0", out Gate_modelID_defval); + pGate_modelID.defaultVal = Gate_modelID_defval; + pGateModule.propertys["modelID"] = pGate_modelID; + + pGateModule.usePropertyDescrAlias = true; + pGateModule.idpropertys[(UInt16)pGate_modelID.aliasID] = pGate_modelID; + + //Dbg.DEBUG_MSG("EntityDef::initScriptModules: add(Gate), property(modelID / 41006)."); + + Property pGate_modelScale = new Property(); + pGate_modelScale.name = "modelScale"; + pGate_modelScale.properUtype = 41007; + pGate_modelScale.properFlags = 4; + pGate_modelScale.aliasID = 6; + Byte Gate_modelScale_defval; + Byte.TryParse("30", out Gate_modelScale_defval); + pGate_modelScale.defaultVal = Gate_modelScale_defval; + pGateModule.propertys["modelScale"] = pGate_modelScale; + + pGateModule.usePropertyDescrAlias = true; + pGateModule.idpropertys[(UInt16)pGate_modelScale.aliasID] = pGate_modelScale; + + //Dbg.DEBUG_MSG("EntityDef::initScriptModules: add(Gate), property(modelScale / 41007)."); + + Property pGate_name = new Property(); + pGate_name.name = "name"; + pGate_name.properUtype = 41003; + pGate_name.properFlags = 4; + pGate_name.aliasID = 7; + string Gate_name_defval = ""; + pGate_name.defaultVal = Gate_name_defval; + pGateModule.propertys["name"] = pGate_name; + + pGateModule.usePropertyDescrAlias = true; + pGateModule.idpropertys[(UInt16)pGate_name.aliasID] = pGate_name; + + //Dbg.DEBUG_MSG("EntityDef::initScriptModules: add(Gate), property(name / 41003)."); + + Property pGate_uid = new Property(); + pGate_uid.name = "uid"; + pGate_uid.properUtype = 41004; + pGate_uid.properFlags = 4; + pGate_uid.aliasID = 8; + UInt32 Gate_uid_defval; + UInt32.TryParse("0", out Gate_uid_defval); + pGate_uid.defaultVal = Gate_uid_defval; + pGateModule.propertys["uid"] = pGate_uid; + + pGateModule.usePropertyDescrAlias = true; + pGateModule.idpropertys[(UInt16)pGate_uid.aliasID] = pGate_uid; + + //Dbg.DEBUG_MSG("EntityDef::initScriptModules: add(Gate), property(uid / 41004)."); + + Property pGate_utype = new Property(); + pGate_utype.name = "utype"; + pGate_utype.properUtype = 41005; + pGate_utype.properFlags = 4; + pGate_utype.aliasID = 9; + UInt32 Gate_utype_defval; + UInt32.TryParse("0", out Gate_utype_defval); + pGate_utype.defaultVal = Gate_utype_defval; + pGateModule.propertys["utype"] = pGate_utype; + + pGateModule.usePropertyDescrAlias = true; + pGateModule.idpropertys[(UInt16)pGate_utype.aliasID] = pGate_utype; + + //Dbg.DEBUG_MSG("EntityDef::initScriptModules: add(Gate), property(utype / 41005)."); + + pGateModule.useMethodDescrAlias = true; + } + + public static void initDefTypes() + { + { + UInt16 utype = 2; + string typeName = "ENTITY_SUBSTATE"; + string name = "UINT8"; + DATATYPE_BASE val = null; + EntityDef.datatypes.TryGetValue(name, out val); + EntityDef.datatypes[typeName] = val; + EntityDef.id2datatypes[utype] = EntityDef.datatypes[typeName]; + EntityDef.datatype2id[typeName] = utype; + } + + { + UInt16 utype = 3; + string typeName = "UINT16"; + string name = "UINT16"; + DATATYPE_BASE val = null; + EntityDef.datatypes.TryGetValue(name, out val); + EntityDef.datatypes[typeName] = val; + EntityDef.id2datatypes[utype] = EntityDef.datatypes[typeName]; + EntityDef.datatype2id[typeName] = utype; + } + + { + UInt16 utype = 5; + string typeName = "UID"; + string name = "UINT64"; + DATATYPE_BASE val = null; + EntityDef.datatypes.TryGetValue(name, out val); + EntityDef.datatypes[typeName] = val; + EntityDef.id2datatypes[utype] = EntityDef.datatypes[typeName]; + EntityDef.datatype2id[typeName] = utype; + } + + { + UInt16 utype = 4; + string typeName = "ENTITY_UTYPE"; + string name = "UINT32"; + DATATYPE_BASE val = null; + EntityDef.datatypes.TryGetValue(name, out val); + EntityDef.datatypes[typeName] = val; + EntityDef.id2datatypes[utype] = EntityDef.datatypes[typeName]; + EntityDef.datatype2id[typeName] = utype; + } + + { + UInt16 utype = 6; + string typeName = "ENTITY_STATE"; + string name = "INT8"; + DATATYPE_BASE val = null; + EntityDef.datatypes.TryGetValue(name, out val); + EntityDef.datatypes[typeName] = val; + EntityDef.id2datatypes[utype] = EntityDef.datatypes[typeName]; + EntityDef.datatype2id[typeName] = utype; + } + + { + UInt16 utype = 7; + string typeName = "INT16"; + string name = "INT16"; + DATATYPE_BASE val = null; + EntityDef.datatypes.TryGetValue(name, out val); + EntityDef.datatypes[typeName] = val; + EntityDef.id2datatypes[utype] = EntityDef.datatypes[typeName]; + EntityDef.datatype2id[typeName] = utype; + } + + { + UInt16 utype = 8; + string typeName = "ENTITY_FORBIDS"; + string name = "INT32"; + DATATYPE_BASE val = null; + EntityDef.datatypes.TryGetValue(name, out val); + EntityDef.datatypes[typeName] = val; + EntityDef.id2datatypes[utype] = EntityDef.datatypes[typeName]; + EntityDef.datatype2id[typeName] = utype; + } + + { + UInt16 utype = 9; + string typeName = "INT64"; + string name = "INT64"; + DATATYPE_BASE val = null; + EntityDef.datatypes.TryGetValue(name, out val); + EntityDef.datatypes[typeName] = val; + EntityDef.id2datatypes[utype] = EntityDef.datatypes[typeName]; + EntityDef.datatype2id[typeName] = utype; + } + + { + UInt16 utype = 1; + string typeName = "STRING"; + string name = "STRING"; + DATATYPE_BASE val = null; + EntityDef.datatypes.TryGetValue(name, out val); + EntityDef.datatypes[typeName] = val; + EntityDef.id2datatypes[utype] = EntityDef.datatypes[typeName]; + EntityDef.datatype2id[typeName] = utype; + } + + { + UInt16 utype = 12; + string typeName = "UNICODE"; + string name = "UNICODE"; + DATATYPE_BASE val = null; + EntityDef.datatypes.TryGetValue(name, out val); + EntityDef.datatypes[typeName] = val; + EntityDef.id2datatypes[utype] = EntityDef.datatypes[typeName]; + EntityDef.datatype2id[typeName] = utype; + } + + { + UInt16 utype = 13; + string typeName = "FLOAT"; + string name = "FLOAT"; + DATATYPE_BASE val = null; + EntityDef.datatypes.TryGetValue(name, out val); + EntityDef.datatypes[typeName] = val; + EntityDef.id2datatypes[utype] = EntityDef.datatypes[typeName]; + EntityDef.datatype2id[typeName] = utype; + } + + { + UInt16 utype = 14; + string typeName = "DOUBLE"; + string name = "DOUBLE"; + DATATYPE_BASE val = null; + EntityDef.datatypes.TryGetValue(name, out val); + EntityDef.datatypes[typeName] = val; + EntityDef.id2datatypes[utype] = EntityDef.datatypes[typeName]; + EntityDef.datatype2id[typeName] = utype; + } + + { + UInt16 utype = 10; + string typeName = "UID1"; + string name = "PYTHON"; + DATATYPE_BASE val = null; + EntityDef.datatypes.TryGetValue(name, out val); + EntityDef.datatypes[typeName] = val; + EntityDef.id2datatypes[utype] = EntityDef.datatypes[typeName]; + EntityDef.datatype2id[typeName] = utype; + } + + { + UInt16 utype = 10; + string typeName = "PY_DICT"; + string name = "PY_DICT"; + DATATYPE_BASE val = null; + EntityDef.datatypes.TryGetValue(name, out val); + EntityDef.datatypes[typeName] = val; + EntityDef.id2datatypes[utype] = EntityDef.datatypes[typeName]; + EntityDef.datatype2id[typeName] = utype; + } + + { + UInt16 utype = 10; + string typeName = "PY_TUPLE"; + string name = "PY_TUPLE"; + DATATYPE_BASE val = null; + EntityDef.datatypes.TryGetValue(name, out val); + EntityDef.datatypes[typeName] = val; + EntityDef.id2datatypes[utype] = EntityDef.datatypes[typeName]; + EntityDef.datatype2id[typeName] = utype; + } + + { + UInt16 utype = 10; + string typeName = "PY_LIST"; + string name = "PY_LIST"; + DATATYPE_BASE val = null; + EntityDef.datatypes.TryGetValue(name, out val); + EntityDef.datatypes[typeName] = val; + EntityDef.id2datatypes[utype] = EntityDef.datatypes[typeName]; + EntityDef.datatype2id[typeName] = utype; + } + + { + UInt16 utype = 20; + string typeName = "ENTITYCALL"; + string name = "ENTITYCALL"; + DATATYPE_BASE val = null; + EntityDef.datatypes.TryGetValue(name, out val); + EntityDef.datatypes[typeName] = val; + EntityDef.id2datatypes[utype] = EntityDef.datatypes[typeName]; + EntityDef.datatype2id[typeName] = utype; + } + + { + UInt16 utype = 11; + string typeName = "BLOB"; + string name = "BLOB"; + DATATYPE_BASE val = null; + EntityDef.datatypes.TryGetValue(name, out val); + EntityDef.datatypes[typeName] = val; + EntityDef.id2datatypes[utype] = EntityDef.datatypes[typeName]; + EntityDef.datatype2id[typeName] = utype; + } + + { + UInt16 utype = 15; + string typeName = "VECTOR2"; + string name = "VECTOR2"; + DATATYPE_BASE val = null; + EntityDef.datatypes.TryGetValue(name, out val); + EntityDef.datatypes[typeName] = val; + EntityDef.id2datatypes[utype] = EntityDef.datatypes[typeName]; + EntityDef.datatype2id[typeName] = utype; + } + + { + UInt16 utype = 16; + string typeName = "DIRECTION3D"; + string name = "VECTOR3"; + DATATYPE_BASE val = null; + EntityDef.datatypes.TryGetValue(name, out val); + EntityDef.datatypes[typeName] = val; + EntityDef.id2datatypes[utype] = EntityDef.datatypes[typeName]; + EntityDef.datatype2id[typeName] = utype; + } + + { + UInt16 utype = 17; + string typeName = "VECTOR4"; + string name = "VECTOR4"; + DATATYPE_BASE val = null; + EntityDef.datatypes.TryGetValue(name, out val); + EntityDef.datatypes[typeName] = val; + EntityDef.id2datatypes[utype] = EntityDef.datatypes[typeName]; + EntityDef.datatype2id[typeName] = utype; + } + + { + UInt16 utype = 22; + string typeName = "ENTITY_FORBID_COUNTER"; + DATATYPE_ENTITY_FORBID_COUNTER datatype = new DATATYPE_ENTITY_FORBID_COUNTER(); + EntityDef.datatypes[typeName] = datatype; + EntityDef.id2datatypes[utype] = EntityDef.datatypes[typeName]; + EntityDef.datatype2id[typeName] = utype; + } + + { + UInt16 utype = 23; + string typeName = "ENTITYID_LIST"; + DATATYPE_ENTITYID_LIST datatype = new DATATYPE_ENTITYID_LIST(); + EntityDef.datatypes[typeName] = datatype; + EntityDef.id2datatypes[utype] = EntityDef.datatypes[typeName]; + EntityDef.datatype2id[typeName] = utype; + } + + { + UInt16 utype = 24; + string typeName = "AVATAR_DATA"; + DATATYPE_AVATAR_DATA datatype = new DATATYPE_AVATAR_DATA(); + EntityDef.datatypes[typeName] = datatype; + EntityDef.id2datatypes[utype] = EntityDef.datatypes[typeName]; + EntityDef.datatype2id[typeName] = utype; + } + + { + UInt16 utype = 25; + string typeName = "AVATAR_INFOS"; + DATATYPE_AVATAR_INFOS datatype = new DATATYPE_AVATAR_INFOS(); + EntityDef.datatypes[typeName] = datatype; + EntityDef.id2datatypes[utype] = EntityDef.datatypes[typeName]; + EntityDef.datatype2id[typeName] = utype; + } + + { + UInt16 utype = 26; + string typeName = "AVATAR_INFOS_LIST"; + DATATYPE_AVATAR_INFOS_LIST datatype = new DATATYPE_AVATAR_INFOS_LIST(); + EntityDef.datatypes[typeName] = datatype; + EntityDef.id2datatypes[utype] = EntityDef.datatypes[typeName]; + EntityDef.datatype2id[typeName] = utype; + } + + { + UInt16 utype = 28; + string typeName = "BAG"; + DATATYPE_BAG datatype = new DATATYPE_BAG(); + EntityDef.datatypes[typeName] = datatype; + EntityDef.id2datatypes[utype] = EntityDef.datatypes[typeName]; + EntityDef.datatype2id[typeName] = utype; + } + + { + UInt16 utype = 31; + string typeName = "EXAMPLES"; + DATATYPE_EXAMPLES datatype = new DATATYPE_EXAMPLES(); + EntityDef.datatypes[typeName] = datatype; + EntityDef.id2datatypes[utype] = EntityDef.datatypes[typeName]; + EntityDef.datatype2id[typeName] = utype; + } + + { + UInt16 utype = 32; + string typeName = "AnonymousArray_32"; + DATATYPE_AnonymousArray_32 datatype = new DATATYPE_AnonymousArray_32(); + EntityDef.datatypes[typeName] = datatype; + EntityDef.id2datatypes[utype] = EntityDef.datatypes[typeName]; + EntityDef.datatype2id[typeName] = utype; + } + + { + UInt16 utype = 33; + string typeName = "AnonymousArray_33"; + string name = "ENTITY_COMPONENT"; + DATATYPE_BASE val = null; + EntityDef.datatypes.TryGetValue(name, out val); + EntityDef.datatypes[typeName] = val; + EntityDef.id2datatypes[utype] = EntityDef.datatypes[typeName]; + EntityDef.datatype2id[typeName] = utype; + } + + { + UInt16 utype = 34; + string typeName = "AnonymousArray_34"; + string name = "ENTITY_COMPONENT"; + DATATYPE_BASE val = null; + EntityDef.datatypes.TryGetValue(name, out val); + EntityDef.datatypes[typeName] = val; + EntityDef.id2datatypes[utype] = EntityDef.datatypes[typeName]; + EntityDef.datatype2id[typeName] = utype; + } + + { + UInt16 utype = 35; + string typeName = "AnonymousArray_35"; + string name = "ENTITY_COMPONENT"; + DATATYPE_BASE val = null; + EntityDef.datatypes.TryGetValue(name, out val); + EntityDef.datatypes[typeName] = val; + EntityDef.id2datatypes[utype] = EntityDef.datatypes[typeName]; + EntityDef.datatype2id[typeName] = utype; + } + + foreach(string datatypeStr in EntityDef.datatypes.Keys) + { + DATATYPE_BASE dataType = EntityDef.datatypes[datatypeStr]; + if(dataType != null) + { + dataType.bind(); + } + } + } + + } + + } \ No newline at end of file diff --git a/Assets/Plugins/kbengine_unity3d_plugins/Event.cs b/Assets/Plugins/kbengine_unity3d_plugins/Event.cs index fc0a0f8..6773923 100644 --- a/Assets/Plugins/kbengine_unity3d_plugins/Event.cs +++ b/Assets/Plugins/kbengine_unity3d_plugins/Event.cs @@ -1,787 +1,787 @@ -namespace KBEngine -{ - using UnityEngine; - using System; - using System.Collections; - using System.Collections.Generic; - using System.Threading; - - /// - /// KBE-Plugin fire-out events(KBE => Unity): - /// - public class EventOutTypes - { - // ------------------------------------连接相关------------------------------------ - /// - /// Kicked of the current server. - /// param1(uint16): retcode. // server_errors - /// - public const string onKicked = "onKicked"; - - /// - /// Disconnected from the server. - /// - public const string onDisconnected = "onDisconnected"; - - /// - /// Status of connection server. - /// param1(bool): success or fail - /// - public const string onConnectionState = "onConnectionState"; - - // ------------------------------------logon相关------------------------------------ - /// - /// Create account feedback results. - /// param1(uint16): retcode. // server_errors - /// param2(bytes): datas. // If you use third-party account system, the system may fill some of the third-party additional datas. - /// - public const string onCreateAccountResult = "onCreateAccountResult"; - - /// - /// Engine version mismatch. - /// param1(string): clientVersion - /// param2(string): serverVersion - /// - public const string onVersionNotMatch = "onVersionNotMatch"; - - /// - /// script version mismatch. - /// param1(string): clientScriptVersion - /// param2(string): serverScriptVersion - /// - public const string onScriptVersionNotMatch = "onScriptVersionNotMatch"; - - /// - /// Login failed. - /// param1(uint16): retcode. // server_errors - /// - public const string onLoginFailed = "onLoginFailed"; - - /// - /// Login to baseapp. - /// - public const string onLoginBaseapp = "onLoginBaseapp"; - - /// - /// Login baseapp failed. - /// param1(uint16): retcode. // server_errors - /// - public const string onLoginBaseappFailed = "onLoginBaseappFailed"; - - /// - /// Relogin to baseapp. - /// - public const string onReloginBaseapp = "onReloginBaseapp"; - - /// - /// Relogin baseapp success. - /// - public const string onReloginBaseappSuccessfully = "onReloginBaseappSuccessfully"; - - /// - /// Relogin baseapp failed. - /// param1(uint16): retcode. // server_errors - /// - public const string onReloginBaseappFailed = "onReloginBaseappFailed"; - - // ------------------------------------实体cell相关事件------------------------------------ - - /// - /// Entity enter the client-world. - /// param1: Entity - /// - public const string onEnterWorld = "onEnterWorld"; - - /// - /// Entity leave the client-world. - /// param1: Entity - /// - public const string onLeaveWorld = "onLeaveWorld"; - - /// - /// Player enter the new space. - /// param1: Entity - /// - public const string onEnterSpace = "onEnterSpace"; - - /// - /// Player leave the space. - /// param1: Entity - /// - public const string onLeaveSpace = "onLeaveSpace"; - - /// - /// Sets the current position of the entity. - /// param1: Entity - /// - public const string set_position = "set_position"; - - /// - /// Sets the current direction of the entity. - /// param1: Entity - /// - public const string set_direction = "set_direction"; - - /// - /// The entity position is updated, you can smooth the moving entity to new location. - /// param1: Entity - /// - public const string updatePosition = "updatePosition"; - - /// - /// The current space is specified by the geometry mapping. - /// Popular said is to load the specified Map Resources. - /// param1(string): resPath - /// - public const string addSpaceGeometryMapping = "addSpaceGeometryMapping"; - - /// - /// Server spaceData set data. - /// param1(int32): spaceID - /// param2(string): key - /// param3(string): value - /// - public const string onSetSpaceData = "onSetSpaceData"; - - /// - /// Start downloading data. - /// param1(int32): rspaceID - /// param2(string): key - /// - public const string onDelSpaceData = "onDelSpaceData"; - - /// - /// Triggered when the entity is controlled or out of control. - /// param1: Entity - /// param2(bool): isControlled - /// - public const string onControlled = "onControlled"; - - /// - /// Lose controlled entity. - /// param1: Entity - /// - public const string onLoseControlledEntity = "onLoseControlledEntity"; - - // ------------------------------------数据下载相关------------------------------------ - /// - /// Start downloading data. - /// param1(uint16): resouce id - /// param2(uint32): data size - /// param3(string): description - /// - public const string onStreamDataStarted = "onStreamDataStarted"; - - /// - /// Receive data. - /// param1(uint16): resouce id - /// param2(bytes): datas - /// - public const string onStreamDataRecv = "onStreamDataRecv"; - - /// - /// The downloaded data is completed. - /// param1(uint16): resouce id - /// - public const string onStreamDataCompleted = "onStreamDataCompleted"; - }; - - /// - /// KBE-Plugin fire-in events(Unity => KBE): - /// - public class EventInTypes - { - /// - /// Create new account. - /// param1(string): accountName - /// param2(string): password - /// param3(bytes): datas // Datas by user defined. Data will be recorded into the KBE account database, you can access the datas through the script layer. If you use third-party account system, datas will be submitted to the third-party system. - /// - public const string createAccount = "createAccount"; - - /// - /// Login to server. - /// param1(string): accountName - /// param2(string): password - /// param3(bytes): datas // Datas by user defined. Data will be recorded into the KBE account database, you can access the datas through the script layer. If you use third-party account system, datas will be submitted to the third-party system. - /// - public const string login = "login"; - - /// - /// Logout to baseapp, called when exiting the client. - /// - public const string logout = "logout"; - - /// - /// Relogin to baseapp. - /// - public const string reloginBaseapp = "reloginBaseapp"; - - /// - /// Reset password. - /// param1(string): accountName - /// - public const string resetPassword = "resetPassword"; - - /// - /// Request to set up a new password for the account. Note: account must be online. - /// param1(string): old_password - /// param2(string): new_password - /// - public const string newPassword = "newPassword"; - - /// - /// Request server binding account Email. - /// param1(string): emailAddress - /// - public const string bindAccountEmail = "bindAccountEmail"; - }; - - /// - /// 事件模块: KBEngine插件层与Unity3D表现层通过事件来交互,特别是在多线程模式下较方便 - /// - public class Event - { - public struct Pair - { - public object obj; - public string funcname; - public System.Reflection.MethodInfo method; - }; - - public struct EventObj - { - public Pair info; - public string eventname; - public object[] args; - }; - - static Dictionary> events_out = new Dictionary>(); - - public static bool outEventsImmediately = true; - - static LinkedList firedEvents_out = new LinkedList(); - static LinkedList doingEvents_out = new LinkedList(); - - static Dictionary> events_in = new Dictionary>(); - - static LinkedList firedEvents_in = new LinkedList(); - static LinkedList doingEvents_in = new LinkedList(); - - static bool _isPauseOut = false; - - public Event() - { - } - - public static void clear() - { - events_out.Clear(); - events_in.Clear(); - clearFiredEvents(); - } - - public static void clearFiredEvents() - { - monitor_Enter(events_out); - firedEvents_out.Clear(); - monitor_Exit(events_out); - - doingEvents_out.Clear(); - - monitor_Enter(events_in); - firedEvents_in.Clear(); - monitor_Exit(events_in); - - doingEvents_in.Clear(); - - _isPauseOut = false; - } - - public static void pause() - { - _isPauseOut = true; - } - - public static void resume() - { - _isPauseOut = false; - processOutEvents(); - } - - public static bool isPause() - { - return _isPauseOut; - } - - public static void monitor_Enter(object obj) - { - if(KBEngineApp.app == null) - return; - - Monitor.Enter(obj); - } - - public static void monitor_Exit(object obj) - { - if(KBEngineApp.app == null) - return; - - Monitor.Exit(obj); - } - - public static bool hasRegisterOut(string eventname) - { - return _hasRegister(events_out, eventname); - } - - public static bool hasRegisterIn(string eventname) - { - return _hasRegister(events_in, eventname); - } - - private static bool _hasRegister(Dictionary> events, string eventname) - { - bool has = false; - - monitor_Enter(events); - has = events.ContainsKey(eventname); - monitor_Exit(events); - - return has; - } - - /// - /// 注册监听由kbe插件抛出的事件。(out = kbe->render) - /// 通常由渲染表现层来注册, 例如:监听角色血量属性的变化, 如果UI层注册这个事件, - /// 事件触发后就可以根据事件所附带的当前血量值来改变角色头顶的血条值。 - /// - public static bool registerOut(string eventname, object obj, string funcname) - { - return register(events_out, eventname, obj, funcname); - } - - /// - /// 注册监听由kbe插件抛出的事件。(out = kbe->render) - /// 通常由渲染表现层来注册, 例如:监听角色血量属性的变化, 如果UI层注册这个事件, - /// 事件触发后就可以根据事件所附带的当前血量值来改变角色头顶的血条值。 - /// - public static bool registerOut(string eventname, Action handler) - { - return registerOut(eventname, handler.Target, handler.Method.Name); - } - - /// - /// 注册监听由kbe插件抛出的事件。(out = kbe->render) - /// 通常由渲染表现层来注册, 例如:监听角色血量属性的变化, 如果UI层注册这个事件, - /// 事件触发后就可以根据事件所附带的当前血量值来改变角色头顶的血条值。 - /// - public static bool registerOut(string eventname, Action handler) - { - return registerOut(eventname, handler.Target, handler.Method.Name); - } - - /// - /// 注册监听由kbe插件抛出的事件。(out = kbe->render) - /// 通常由渲染表现层来注册, 例如:监听角色血量属性的变化, 如果UI层注册这个事件, - /// 事件触发后就可以根据事件所附带的当前血量值来改变角色头顶的血条值。 - /// - public static bool registerOut(string eventname, Action handler) - { - return registerOut(eventname, handler.Target, handler.Method.Name); - } - - /// - /// 注册监听由kbe插件抛出的事件。(out = kbe->render) - /// 通常由渲染表现层来注册, 例如:监听角色血量属性的变化, 如果UI层注册这个事件, - /// 事件触发后就可以根据事件所附带的当前血量值来改变角色头顶的血条值。 - /// - public static bool registerOut(string eventname, Action handler) - { - return registerOut(eventname, handler.Target, handler.Method.Name); - } - - /// - /// 注册监听由kbe插件抛出的事件。(out = kbe->render) - /// 通常由渲染表现层来注册, 例如:监听角色血量属性的变化, 如果UI层注册这个事件, - /// 事件触发后就可以根据事件所附带的当前血量值来改变角色头顶的血条值。 - /// - public static bool registerOut(string eventname, Action handler) - { - return registerOut(eventname, handler.Target, handler.Method.Name); - } - - /// - /// 注册监听由渲染表现层抛出的事件(in = render->kbe) - /// 通常由kbe插件层来注册, 例如:UI层点击登录, 此时需要触发一个事件给kbe插件层进行与服务端交互的处理。 - /// - public static bool registerIn(string eventname, object obj, string funcname) - { - return register(events_in, eventname, obj, funcname); - } - - /// - /// 注册监听由渲染表现层抛出的事件(in = render->kbe) - /// 通常由kbe插件层来注册, 例如:UI层点击登录, 此时需要触发一个事件给kbe插件层进行与服务端交互的处理。 - /// - public static bool registerIn(string eventname, Action handler) - { - return registerIn(eventname, handler.Target, handler.Method.Name); - } - - /// - /// 注册监听由渲染表现层抛出的事件(in = render->kbe) - /// 通常由kbe插件层来注册, 例如:UI层点击登录, 此时需要触发一个事件给kbe插件层进行与服务端交互的处理。 - /// - public static bool registerIn(string eventname, Action handler) - { - return registerIn(eventname, handler.Target, handler.Method.Name); - } - - /// - /// 注册监听由渲染表现层抛出的事件(in = render->kbe) - /// 通常由kbe插件层来注册, 例如:UI层点击登录, 此时需要触发一个事件给kbe插件层进行与服务端交互的处理。 - /// - public static bool registerIn(string eventname, Action handler) - { - return registerIn(eventname, handler.Target, handler.Method.Name); - } - - /// - /// 注册监听由渲染表现层抛出的事件(in = render->kbe) - /// 通常由kbe插件层来注册, 例如:UI层点击登录, 此时需要触发一个事件给kbe插件层进行与服务端交互的处理。 - /// - public static bool registerIn(string eventname, Action handler) - { - return registerIn(eventname, handler.Target, handler.Method.Name); - } - - /// - /// 注册监听由渲染表现层抛出的事件(in = render->kbe) - /// 通常由kbe插件层来注册, 例如:UI层点击登录, 此时需要触发一个事件给kbe插件层进行与服务端交互的处理。 - /// - public static bool registerIn(string eventname, Action handler) - { - return registerIn(eventname, handler.Target, handler.Method.Name); - } - - private static bool register(Dictionary> events, string eventname, object obj, string funcname) - { - deregister(events, eventname, obj, funcname); - List lst = null; - - Pair pair = new Pair(); - pair.obj = obj; - pair.funcname = funcname; - pair.method = obj.GetType().GetMethod(funcname); - - if(pair.method == null) - { - Dbg.ERROR_MSG("Event::register: " + obj + "not found method[" + funcname + "]"); - return false; - } - - monitor_Enter(events); - if(!events.TryGetValue(eventname, out lst)) - { - lst = new List(); - lst.Add(pair); - //Dbg.DEBUG_MSG("Event::register: event(" + eventname + ")!"); - events.Add(eventname, lst); - monitor_Exit(events); - return true; - } - - //Dbg.DEBUG_MSG("Event::register: event(" + eventname + ")!"); - lst.Add(pair); - monitor_Exit(events); - return true; - } - - public static bool deregisterOut(string eventname, object obj, string funcname) - { - removeFiredEventOut(obj, eventname, funcname); - return deregister(events_out, eventname, obj, funcname); - } - - public static bool deregisterOut(string eventname, Action handler) - { - return deregisterOut(eventname, handler.Target, handler.Method.Name); - } - - public static bool deregisterIn(string eventname, object obj, string funcname) - { - removeFiredEventIn(obj, eventname, funcname); - return deregister(events_in, eventname, obj, funcname); - } - - public static bool deregisterIn(string eventname, Action handler) - { - return deregisterIn(eventname, handler.Target, handler.Method.Name); - } - - private static bool deregister(Dictionary> events, string eventname, object obj, string funcname) - { - monitor_Enter(events); - List lst = null; - - if(!events.TryGetValue(eventname, out lst)) - { - monitor_Exit(events); - return false; - } - - for(int i=0; i> events, object obj) - { - monitor_Enter(events); - - var iter = events.GetEnumerator(); - while (iter.MoveNext()) - { - List lst = iter.Current.Value; - // 从后往前遍历,以避免中途删除的问题 - for (int i = lst.Count - 1; i >= 0; i--) - { - if (obj == lst[i].obj) - { - //Dbg.DEBUG_MSG("Event::deregister: event(" + e.Key + ":" + lst[i].funcname + ")!"); - lst.RemoveAt(i); - } - } - } - - monitor_Exit(events); - return true; - } - - /// - /// kbe插件触发事件(out = kbe->render) - /// 通常由渲染表现层来注册, 例如:监听角色血量属性的变化, 如果UI层注册这个事件, - /// 事件触发后就可以根据事件所附带的当前血量值来改变角色头顶的血条值。 - /// - public static void fireOut(string eventname, params object[] args) - { - fire_(events_out, firedEvents_out, eventname, args, outEventsImmediately); - } - - /// - /// 渲染表现层抛出事件(in = render->kbe) - /// 通常由kbe插件层来注册, 例如:UI层点击登录, 此时需要触发一个事件给kbe插件层进行与服务端交互的处理。 - /// - public static void fireIn(string eventname, params object[] args) - { - fire_(events_in, firedEvents_in, eventname, args, false); - } - - /// - /// 触发kbe插件和渲染表现层都能够收到的事件 - /// - public static void fireAll(string eventname, params object[] args) - { - fire_(events_in, firedEvents_in, eventname, args, false); - fire_(events_out, firedEvents_out, eventname, args, false); - } - - private static void fire_(Dictionary> events, LinkedList firedEvents, string eventname, object[] args, bool eventsImmediately) - { - monitor_Enter(events); - List lst = null; - - if(!events.TryGetValue(eventname, out lst)) - { - //if(events == events_in) - // Dbg.WARNING_MSG("Event::fireIn: event(" + eventname + ") not found!"); - //else - // Dbg.WARNING_MSG("Event::fireOut: event(" + eventname + ") not found!"); - - monitor_Exit(events); - return; - } - - if(eventsImmediately && !_isPauseOut) - { - for(int i=0; i 0) - { - var iter = firedEvents_out.GetEnumerator(); - while (iter.MoveNext()) - { - doingEvents_out.AddLast(iter.Current); - } - - firedEvents_out.Clear(); - } - - monitor_Exit(events_out); - - while (doingEvents_out.Count > 0 && !_isPauseOut) - { - - EventObj eobj = doingEvents_out.First.Value; - - //Debug.Log("processOutEvents:" + eobj.info.funcname + "(" + eobj.info + ")"); - //foreach(object v in eobj.args) - //{ - // Debug.Log("processOutEvents:args=" + v); - //} - try - { - eobj.info.method.Invoke (eobj.info.obj, eobj.args); - } - catch (Exception e) - { - Dbg.ERROR_MSG("Event::processOutEvents: event=" + eobj.info.method.DeclaringType.FullName + "::" + eobj.info.funcname + "\n" + e.ToString()); - } - - if(doingEvents_out.Count > 0) - doingEvents_out.RemoveFirst(); - } - } - - public static void processInEvents() - { - monitor_Enter(events_in); - - if(firedEvents_in.Count > 0) - { - var iter = firedEvents_in.GetEnumerator(); - while (iter.MoveNext()) - { - doingEvents_in.AddLast(iter.Current); - } - - firedEvents_in.Clear(); - } - - monitor_Exit(events_in); - - while (doingEvents_in.Count > 0) - { - - EventObj eobj = doingEvents_in.First.Value; - - //Debug.Log("processInEvents:" + eobj.info.funcname + "(" + eobj.info + ")"); - //foreach(object v in eobj.args) - //{ - // Debug.Log("processInEvents:args=" + v); - //} - try - { - eobj.info.method.Invoke (eobj.info.obj, eobj.args); - } - catch (Exception e) - { - Dbg.ERROR_MSG("Event::processInEvents: event=" + eobj.info.method.DeclaringType.FullName + "::" + eobj.info.funcname + "\n" + e.ToString()); - } - - if(doingEvents_in.Count > 0) - doingEvents_in.RemoveFirst(); - } - } - - public static void removeAllFiredEventIn(object obj) - { - removeFiredEvent(firedEvents_in, obj); - } - - public static void removeAllFiredEventOut(object obj) - { - removeFiredEvent(firedEvents_out, obj); - } - - public static void removeFiredEventIn(object obj, string eventname, string funcname) - { - removeFiredEvent(firedEvents_in, obj, eventname, funcname); - } - - public static void removeFiredEventOut(object obj, string eventname, string funcname) - { - removeFiredEvent(firedEvents_out, obj, eventname, funcname); - } - - public static void removeFiredEvent(LinkedList firedEvents, object obj, string eventname="", string funcname="") - { - monitor_Enter(firedEvents); - - while(true) - { - bool found = false; - foreach(EventObj eobj in firedEvents) - { - if( ((eventname == "" && funcname == "") || (eventname == eobj.eventname && funcname == eobj.info.funcname)) - && eobj.info.obj == obj) - { - firedEvents.Remove(eobj); - found = true; - break; - } - } - - if (!found) - break; - } - - monitor_Exit(firedEvents); - } - - } -} +namespace KBEngine +{ + using UnityEngine; + using System; + using System.Collections; + using System.Collections.Generic; + using System.Threading; + + /// + /// KBE-Plugin fire-out events(KBE => Unity): + /// + public class EventOutTypes + { + // ------------------------------------连接相关------------------------------------ + /// + /// Kicked of the current server. + /// param1(uint16): retcode. // server_errors + /// + public const string onKicked = "onKicked"; + + /// + /// Disconnected from the server. + /// + public const string onDisconnected = "onDisconnected"; + + /// + /// Status of connection server. + /// param1(bool): success or fail + /// + public const string onConnectionState = "onConnectionState"; + + // ------------------------------------logon相关------------------------------------ + /// + /// Create account feedback results. + /// param1(uint16): retcode. // server_errors + /// param2(bytes): datas. // If you use third-party account system, the system may fill some of the third-party additional datas. + /// + public const string onCreateAccountResult = "onCreateAccountResult"; + + /// + /// Engine version mismatch. + /// param1(string): clientVersion + /// param2(string): serverVersion + /// + public const string onVersionNotMatch = "onVersionNotMatch"; + + /// + /// script version mismatch. + /// param1(string): clientScriptVersion + /// param2(string): serverScriptVersion + /// + public const string onScriptVersionNotMatch = "onScriptVersionNotMatch"; + + /// + /// Login failed. + /// param1(uint16): retcode. // server_errors + /// + public const string onLoginFailed = "onLoginFailed"; + + /// + /// Login to baseapp. + /// + public const string onLoginBaseapp = "onLoginBaseapp"; + + /// + /// Login baseapp failed. + /// param1(uint16): retcode. // server_errors + /// + public const string onLoginBaseappFailed = "onLoginBaseappFailed"; + + /// + /// Relogin to baseapp. + /// + public const string onReloginBaseapp = "onReloginBaseapp"; + + /// + /// Relogin baseapp success. + /// + public const string onReloginBaseappSuccessfully = "onReloginBaseappSuccessfully"; + + /// + /// Relogin baseapp failed. + /// param1(uint16): retcode. // server_errors + /// + public const string onReloginBaseappFailed = "onReloginBaseappFailed"; + + // ------------------------------------实体cell相关事件------------------------------------ + + /// + /// Entity enter the client-world. + /// param1: Entity + /// + public const string onEnterWorld = "onEnterWorld"; + + /// + /// Entity leave the client-world. + /// param1: Entity + /// + public const string onLeaveWorld = "onLeaveWorld"; + + /// + /// Player enter the new space. + /// param1: Entity + /// + public const string onEnterSpace = "onEnterSpace"; + + /// + /// Player leave the space. + /// param1: Entity + /// + public const string onLeaveSpace = "onLeaveSpace"; + + /// + /// Sets the current position of the entity. + /// param1: Entity + /// + public const string set_position = "set_position"; + + /// + /// Sets the current direction of the entity. + /// param1: Entity + /// + public const string set_direction = "set_direction"; + + /// + /// The entity position is updated, you can smooth the moving entity to new location. + /// param1: Entity + /// + public const string updatePosition = "updatePosition"; + + /// + /// The current space is specified by the geometry mapping. + /// Popular said is to load the specified Map Resources. + /// param1(string): resPath + /// + public const string addSpaceGeometryMapping = "addSpaceGeometryMapping"; + + /// + /// Server spaceData set data. + /// param1(int32): spaceID + /// param2(string): key + /// param3(string): value + /// + public const string onSetSpaceData = "onSetSpaceData"; + + /// + /// Start downloading data. + /// param1(int32): rspaceID + /// param2(string): key + /// + public const string onDelSpaceData = "onDelSpaceData"; + + /// + /// Triggered when the entity is controlled or out of control. + /// param1: Entity + /// param2(bool): isControlled + /// + public const string onControlled = "onControlled"; + + /// + /// Lose controlled entity. + /// param1: Entity + /// + public const string onLoseControlledEntity = "onLoseControlledEntity"; + + // ------------------------------------数据下载相关------------------------------------ + /// + /// Start downloading data. + /// param1(uint16): resouce id + /// param2(uint32): data size + /// param3(string): description + /// + public const string onStreamDataStarted = "onStreamDataStarted"; + + /// + /// Receive data. + /// param1(uint16): resouce id + /// param2(bytes): datas + /// + public const string onStreamDataRecv = "onStreamDataRecv"; + + /// + /// The downloaded data is completed. + /// param1(uint16): resouce id + /// + public const string onStreamDataCompleted = "onStreamDataCompleted"; + }; + + /// + /// KBE-Plugin fire-in events(Unity => KBE): + /// + public class EventInTypes + { + /// + /// Create new account. + /// param1(string): accountName + /// param2(string): password + /// param3(bytes): datas // Datas by user defined. Data will be recorded into the KBE account database, you can access the datas through the script layer. If you use third-party account system, datas will be submitted to the third-party system. + /// + public const string createAccount = "createAccount"; + + /// + /// Login to server. + /// param1(string): accountName + /// param2(string): password + /// param3(bytes): datas // Datas by user defined. Data will be recorded into the KBE account database, you can access the datas through the script layer. If you use third-party account system, datas will be submitted to the third-party system. + /// + public const string login = "login"; + + /// + /// Logout to baseapp, called when exiting the client. + /// + public const string logout = "logout"; + + /// + /// Relogin to baseapp. + /// + public const string reloginBaseapp = "reloginBaseapp"; + + /// + /// Reset password. + /// param1(string): accountName + /// + public const string resetPassword = "resetPassword"; + + /// + /// Request to set up a new password for the account. Note: account must be online. + /// param1(string): old_password + /// param2(string): new_password + /// + public const string newPassword = "newPassword"; + + /// + /// Request server binding account Email. + /// param1(string): emailAddress + /// + public const string bindAccountEmail = "bindAccountEmail"; + }; + + /// + /// 事件模块: KBEngine插件层与Unity3D表现层通过事件来交互,特别是在多线程模式下较方便 + /// + public class Event + { + public struct Pair + { + public object obj; + public string funcname; + public System.Reflection.MethodInfo method; + }; + + public struct EventObj + { + public Pair info; + public string eventname; + public object[] args; + }; + + static Dictionary> events_out = new Dictionary>(); + + public static bool outEventsImmediately = true; + + static LinkedList firedEvents_out = new LinkedList(); + static LinkedList doingEvents_out = new LinkedList(); + + static Dictionary> events_in = new Dictionary>(); + + static LinkedList firedEvents_in = new LinkedList(); + static LinkedList doingEvents_in = new LinkedList(); + + static bool _isPauseOut = false; + + public Event() + { + } + + public static void clear() + { + events_out.Clear(); + events_in.Clear(); + clearFiredEvents(); + } + + public static void clearFiredEvents() + { + monitor_Enter(events_out); + firedEvents_out.Clear(); + monitor_Exit(events_out); + + doingEvents_out.Clear(); + + monitor_Enter(events_in); + firedEvents_in.Clear(); + monitor_Exit(events_in); + + doingEvents_in.Clear(); + + _isPauseOut = false; + } + + public static void pause() + { + _isPauseOut = true; + } + + public static void resume() + { + _isPauseOut = false; + processOutEvents(); + } + + public static bool isPause() + { + return _isPauseOut; + } + + public static void monitor_Enter(object obj) + { + if(KBEngineApp.app == null) + return; + + Monitor.Enter(obj); + } + + public static void monitor_Exit(object obj) + { + if(KBEngineApp.app == null) + return; + + Monitor.Exit(obj); + } + + public static bool hasRegisterOut(string eventname) + { + return _hasRegister(events_out, eventname); + } + + public static bool hasRegisterIn(string eventname) + { + return _hasRegister(events_in, eventname); + } + + private static bool _hasRegister(Dictionary> events, string eventname) + { + bool has = false; + + monitor_Enter(events); + has = events.ContainsKey(eventname); + monitor_Exit(events); + + return has; + } + + /// + /// 注册监听由kbe插件抛出的事件。(out = kbe->render) + /// 通常由渲染表现层来注册, 例如:监听角色血量属性的变化, 如果UI层注册这个事件, + /// 事件触发后就可以根据事件所附带的当前血量值来改变角色头顶的血条值。 + /// + public static bool registerOut(string eventname, object obj, string funcname) + { + return register(events_out, eventname, obj, funcname); + } + + /// + /// 注册监听由kbe插件抛出的事件。(out = kbe->render) + /// 通常由渲染表现层来注册, 例如:监听角色血量属性的变化, 如果UI层注册这个事件, + /// 事件触发后就可以根据事件所附带的当前血量值来改变角色头顶的血条值。 + /// + public static bool registerOut(string eventname, Action handler) + { + return registerOut(eventname, handler.Target, handler.Method.Name); + } + + /// + /// 注册监听由kbe插件抛出的事件。(out = kbe->render) + /// 通常由渲染表现层来注册, 例如:监听角色血量属性的变化, 如果UI层注册这个事件, + /// 事件触发后就可以根据事件所附带的当前血量值来改变角色头顶的血条值。 + /// + public static bool registerOut(string eventname, Action handler) + { + return registerOut(eventname, handler.Target, handler.Method.Name); + } + + /// + /// 注册监听由kbe插件抛出的事件。(out = kbe->render) + /// 通常由渲染表现层来注册, 例如:监听角色血量属性的变化, 如果UI层注册这个事件, + /// 事件触发后就可以根据事件所附带的当前血量值来改变角色头顶的血条值。 + /// + public static bool registerOut(string eventname, Action handler) + { + return registerOut(eventname, handler.Target, handler.Method.Name); + } + + /// + /// 注册监听由kbe插件抛出的事件。(out = kbe->render) + /// 通常由渲染表现层来注册, 例如:监听角色血量属性的变化, 如果UI层注册这个事件, + /// 事件触发后就可以根据事件所附带的当前血量值来改变角色头顶的血条值。 + /// + public static bool registerOut(string eventname, Action handler) + { + return registerOut(eventname, handler.Target, handler.Method.Name); + } + + /// + /// 注册监听由kbe插件抛出的事件。(out = kbe->render) + /// 通常由渲染表现层来注册, 例如:监听角色血量属性的变化, 如果UI层注册这个事件, + /// 事件触发后就可以根据事件所附带的当前血量值来改变角色头顶的血条值。 + /// + public static bool registerOut(string eventname, Action handler) + { + return registerOut(eventname, handler.Target, handler.Method.Name); + } + + /// + /// 注册监听由渲染表现层抛出的事件(in = render->kbe) + /// 通常由kbe插件层来注册, 例如:UI层点击登录, 此时需要触发一个事件给kbe插件层进行与服务端交互的处理。 + /// + public static bool registerIn(string eventname, object obj, string funcname) + { + return register(events_in, eventname, obj, funcname); + } + + /// + /// 注册监听由渲染表现层抛出的事件(in = render->kbe) + /// 通常由kbe插件层来注册, 例如:UI层点击登录, 此时需要触发一个事件给kbe插件层进行与服务端交互的处理。 + /// + public static bool registerIn(string eventname, Action handler) + { + return registerIn(eventname, handler.Target, handler.Method.Name); + } + + /// + /// 注册监听由渲染表现层抛出的事件(in = render->kbe) + /// 通常由kbe插件层来注册, 例如:UI层点击登录, 此时需要触发一个事件给kbe插件层进行与服务端交互的处理。 + /// + public static bool registerIn(string eventname, Action handler) + { + return registerIn(eventname, handler.Target, handler.Method.Name); + } + + /// + /// 注册监听由渲染表现层抛出的事件(in = render->kbe) + /// 通常由kbe插件层来注册, 例如:UI层点击登录, 此时需要触发一个事件给kbe插件层进行与服务端交互的处理。 + /// + public static bool registerIn(string eventname, Action handler) + { + return registerIn(eventname, handler.Target, handler.Method.Name); + } + + /// + /// 注册监听由渲染表现层抛出的事件(in = render->kbe) + /// 通常由kbe插件层来注册, 例如:UI层点击登录, 此时需要触发一个事件给kbe插件层进行与服务端交互的处理。 + /// + public static bool registerIn(string eventname, Action handler) + { + return registerIn(eventname, handler.Target, handler.Method.Name); + } + + /// + /// 注册监听由渲染表现层抛出的事件(in = render->kbe) + /// 通常由kbe插件层来注册, 例如:UI层点击登录, 此时需要触发一个事件给kbe插件层进行与服务端交互的处理。 + /// + public static bool registerIn(string eventname, Action handler) + { + return registerIn(eventname, handler.Target, handler.Method.Name); + } + + private static bool register(Dictionary> events, string eventname, object obj, string funcname) + { + deregister(events, eventname, obj, funcname); + List lst = null; + + Pair pair = new Pair(); + pair.obj = obj; + pair.funcname = funcname; + pair.method = obj.GetType().GetMethod(funcname); + + if(pair.method == null) + { + Dbg.ERROR_MSG("Event::register: " + obj + "not found method[" + funcname + "]"); + return false; + } + + monitor_Enter(events); + if(!events.TryGetValue(eventname, out lst)) + { + lst = new List(); + lst.Add(pair); + //Dbg.DEBUG_MSG("Event::register: event(" + eventname + ")!"); + events.Add(eventname, lst); + monitor_Exit(events); + return true; + } + + //Dbg.DEBUG_MSG("Event::register: event(" + eventname + ")!"); + lst.Add(pair); + monitor_Exit(events); + return true; + } + + public static bool deregisterOut(string eventname, object obj, string funcname) + { + removeFiredEventOut(obj, eventname, funcname); + return deregister(events_out, eventname, obj, funcname); + } + + public static bool deregisterOut(string eventname, Action handler) + { + return deregisterOut(eventname, handler.Target, handler.Method.Name); + } + + public static bool deregisterIn(string eventname, object obj, string funcname) + { + removeFiredEventIn(obj, eventname, funcname); + return deregister(events_in, eventname, obj, funcname); + } + + public static bool deregisterIn(string eventname, Action handler) + { + return deregisterIn(eventname, handler.Target, handler.Method.Name); + } + + private static bool deregister(Dictionary> events, string eventname, object obj, string funcname) + { + monitor_Enter(events); + List lst = null; + + if(!events.TryGetValue(eventname, out lst)) + { + monitor_Exit(events); + return false; + } + + for(int i=0; i> events, object obj) + { + monitor_Enter(events); + + var iter = events.GetEnumerator(); + while (iter.MoveNext()) + { + List lst = iter.Current.Value; + // 从后往前遍历,以避免中途删除的问题 + for (int i = lst.Count - 1; i >= 0; i--) + { + if (obj == lst[i].obj) + { + //Dbg.DEBUG_MSG("Event::deregister: event(" + e.Key + ":" + lst[i].funcname + ")!"); + lst.RemoveAt(i); + } + } + } + + monitor_Exit(events); + return true; + } + + /// + /// kbe插件触发事件(out = kbe->render) + /// 通常由渲染表现层来注册, 例如:监听角色血量属性的变化, 如果UI层注册这个事件, + /// 事件触发后就可以根据事件所附带的当前血量值来改变角色头顶的血条值。 + /// + public static void fireOut(string eventname, params object[] args) + { + fire_(events_out, firedEvents_out, eventname, args, outEventsImmediately); + } + + /// + /// 渲染表现层抛出事件(in = render->kbe) + /// 通常由kbe插件层来注册, 例如:UI层点击登录, 此时需要触发一个事件给kbe插件层进行与服务端交互的处理。 + /// + public static void fireIn(string eventname, params object[] args) + { + fire_(events_in, firedEvents_in, eventname, args, false); + } + + /// + /// 触发kbe插件和渲染表现层都能够收到的事件 + /// + public static void fireAll(string eventname, params object[] args) + { + fire_(events_in, firedEvents_in, eventname, args, false); + fire_(events_out, firedEvents_out, eventname, args, false); + } + + private static void fire_(Dictionary> events, LinkedList firedEvents, string eventname, object[] args, bool eventsImmediately) + { + monitor_Enter(events); + List lst = null; + + if(!events.TryGetValue(eventname, out lst)) + { + //if(events == events_in) + // Dbg.WARNING_MSG("Event::fireIn: event(" + eventname + ") not found!"); + //else + // Dbg.WARNING_MSG("Event::fireOut: event(" + eventname + ") not found!"); + + monitor_Exit(events); + return; + } + + if(eventsImmediately && !_isPauseOut) + { + for(int i=0; i 0) + { + var iter = firedEvents_out.GetEnumerator(); + while (iter.MoveNext()) + { + doingEvents_out.AddLast(iter.Current); + } + + firedEvents_out.Clear(); + } + + monitor_Exit(events_out); + + while (doingEvents_out.Count > 0 && !_isPauseOut) + { + + EventObj eobj = doingEvents_out.First.Value; + + //Debug.Log("processOutEvents:" + eobj.info.funcname + "(" + eobj.info + ")"); + //foreach(object v in eobj.args) + //{ + // Debug.Log("processOutEvents:args=" + v); + //} + try + { + eobj.info.method.Invoke (eobj.info.obj, eobj.args); + } + catch (Exception e) + { + Dbg.ERROR_MSG("Event::processOutEvents: event=" + eobj.info.method.DeclaringType.FullName + "::" + eobj.info.funcname + "\n" + e.ToString()); + } + + if(doingEvents_out.Count > 0) + doingEvents_out.RemoveFirst(); + } + } + + public static void processInEvents() + { + monitor_Enter(events_in); + + if(firedEvents_in.Count > 0) + { + var iter = firedEvents_in.GetEnumerator(); + while (iter.MoveNext()) + { + doingEvents_in.AddLast(iter.Current); + } + + firedEvents_in.Clear(); + } + + monitor_Exit(events_in); + + while (doingEvents_in.Count > 0) + { + + EventObj eobj = doingEvents_in.First.Value; + + //Debug.Log("processInEvents:" + eobj.info.funcname + "(" + eobj.info + ")"); + //foreach(object v in eobj.args) + //{ + // Debug.Log("processInEvents:args=" + v); + //} + try + { + eobj.info.method.Invoke (eobj.info.obj, eobj.args); + } + catch (Exception e) + { + Dbg.ERROR_MSG("Event::processInEvents: event=" + eobj.info.method.DeclaringType.FullName + "::" + eobj.info.funcname + "\n" + e.ToString()); + } + + if(doingEvents_in.Count > 0) + doingEvents_in.RemoveFirst(); + } + } + + public static void removeAllFiredEventIn(object obj) + { + removeFiredEvent(firedEvents_in, obj); + } + + public static void removeAllFiredEventOut(object obj) + { + removeFiredEvent(firedEvents_out, obj); + } + + public static void removeFiredEventIn(object obj, string eventname, string funcname) + { + removeFiredEvent(firedEvents_in, obj, eventname, funcname); + } + + public static void removeFiredEventOut(object obj, string eventname, string funcname) + { + removeFiredEvent(firedEvents_out, obj, eventname, funcname); + } + + public static void removeFiredEvent(LinkedList firedEvents, object obj, string eventname="", string funcname="") + { + monitor_Enter(firedEvents); + + while(true) + { + bool found = false; + foreach(EventObj eobj in firedEvents) + { + if( ((eventname == "" && funcname == "") || (eventname == eobj.eventname && funcname == eobj.info.funcname)) + && eobj.info.obj == obj) + { + firedEvents.Remove(eobj); + found = true; + break; + } + } + + if (!found) + break; + } + + monitor_Exit(firedEvents); + } + + } +} diff --git a/Assets/Plugins/kbengine_unity3d_plugins/GateBase.cs b/Assets/Plugins/kbengine_unity3d_plugins/GateBase.cs index 8879de6..cbce758 100644 --- a/Assets/Plugins/kbengine_unity3d_plugins/GateBase.cs +++ b/Assets/Plugins/kbengine_unity3d_plugins/GateBase.cs @@ -1,486 +1,486 @@ -/* - Generated by KBEngine! - Please do not modify this file! - Please inherit this module, such as: (class Gate : GateBase) - tools = kbcmd -*/ - -namespace KBEngine -{ - using UnityEngine; - using System; - using System.Collections; - using System.Collections.Generic; - - // defined in */scripts/entity_defs/Gate.def - // Please inherit and implement "class Gate : GateBase" - public abstract class GateBase : Entity - { - public EntityBaseEntityCall_GateBase baseEntityCall = null; - public EntityCellEntityCall_GateBase cellEntityCall = null; - - public UInt32 entityNO = 0; - public virtual void onEntityNOChanged(UInt32 oldValue) {} - public UInt32 modelID = 0; - public virtual void onModelIDChanged(UInt32 oldValue) {} - public Byte modelScale = 30; - public virtual void onModelScaleChanged(Byte oldValue) {} - public string name = ""; - public virtual void onNameChanged(string oldValue) {} - public UInt32 uid = 0; - public virtual void onUidChanged(UInt32 oldValue) {} - public UInt32 utype = 0; - public virtual void onUtypeChanged(UInt32 oldValue) {} - - - public GateBase() - { - } - - public override void onComponentsEnterworld() - { - } - - public override void onComponentsLeaveworld() - { - } - - public override void onGetBase() - { - baseEntityCall = new EntityBaseEntityCall_GateBase(id, className); - } - - public override void onGetCell() - { - cellEntityCall = new EntityCellEntityCall_GateBase(id, className); - } - - public override void onLoseCell() - { - cellEntityCall = null; - } - - public override EntityCall getBaseEntityCall() - { - return baseEntityCall; - } - - public override EntityCall getCellEntityCall() - { - return cellEntityCall; - } - - public override void attachComponents() - { - } - - public override void detachComponents() - { - } - - public override void onRemoteMethodCall(MemoryStream stream) - { - ScriptModule sm = EntityDef.moduledefs["Gate"]; - - UInt16 methodUtype = 0; - UInt16 componentPropertyUType = 0; - - if(sm.usePropertyDescrAlias) - { - componentPropertyUType = stream.readUint8(); - } - else - { - componentPropertyUType = stream.readUint16(); - } - - if(sm.useMethodDescrAlias) - { - methodUtype = stream.readUint8(); - } - else - { - methodUtype = stream.readUint16(); - } - - Method method = null; - - if(componentPropertyUType == 0) - { - method = sm.idmethods[methodUtype]; - } - else - { - Property pComponentPropertyDescription = sm.idpropertys[componentPropertyUType]; - switch(pComponentPropertyDescription.properUtype) - { - default: - break; - } - - return; - } - - switch(method.methodUtype) - { - default: - break; - }; - } - - public override void onUpdatePropertys(MemoryStream stream) - { - ScriptModule sm = EntityDef.moduledefs["Gate"]; - Dictionary pdatas = sm.idpropertys; - - while(stream.length() > 0) - { - UInt16 _t_utype = 0; - UInt16 _t_child_utype = 0; - - { - if(sm.usePropertyDescrAlias) - { - _t_utype = stream.readUint8(); - _t_child_utype = stream.readUint8(); - } - else - { - _t_utype = stream.readUint16(); - _t_child_utype = stream.readUint16(); - } - } - - Property prop = null; - - if(_t_utype == 0) - { - prop = pdatas[_t_child_utype]; - } - else - { - Property pComponentPropertyDescription = pdatas[_t_utype]; - switch(pComponentPropertyDescription.properUtype) - { - default: - break; - } - - return; - } - - switch(prop.properUtype) - { - case 40001: - Vector3 oldval_direction = direction; - direction = stream.readVector3(); - - if(prop.isBase()) - { - if(inited) - onDirectionChanged(oldval_direction); - } - else - { - if(inWorld) - onDirectionChanged(oldval_direction); - } - - break; - case 51007: - UInt32 oldval_entityNO = entityNO; - entityNO = stream.readUint32(); - - if(prop.isBase()) - { - if(inited) - onEntityNOChanged(oldval_entityNO); - } - else - { - if(inWorld) - onEntityNOChanged(oldval_entityNO); - } - - break; - case 41006: - UInt32 oldval_modelID = modelID; - modelID = stream.readUint32(); - - if(prop.isBase()) - { - if(inited) - onModelIDChanged(oldval_modelID); - } - else - { - if(inWorld) - onModelIDChanged(oldval_modelID); - } - - break; - case 41007: - Byte oldval_modelScale = modelScale; - modelScale = stream.readUint8(); - - if(prop.isBase()) - { - if(inited) - onModelScaleChanged(oldval_modelScale); - } - else - { - if(inWorld) - onModelScaleChanged(oldval_modelScale); - } - - break; - case 41003: - string oldval_name = name; - name = stream.readUnicode(); - - if(prop.isBase()) - { - if(inited) - onNameChanged(oldval_name); - } - else - { - if(inWorld) - onNameChanged(oldval_name); - } - - break; - case 40000: - Vector3 oldval_position = position; - position = stream.readVector3(); - - if(prop.isBase()) - { - if(inited) - onPositionChanged(oldval_position); - } - else - { - if(inWorld) - onPositionChanged(oldval_position); - } - - break; - case 40002: - stream.readUint32(); - break; - case 41004: - UInt32 oldval_uid = uid; - uid = stream.readUint32(); - - if(prop.isBase()) - { - if(inited) - onUidChanged(oldval_uid); - } - else - { - if(inWorld) - onUidChanged(oldval_uid); - } - - break; - case 41005: - UInt32 oldval_utype = utype; - utype = stream.readUint32(); - - if(prop.isBase()) - { - if(inited) - onUtypeChanged(oldval_utype); - } - else - { - if(inWorld) - onUtypeChanged(oldval_utype); - } - - break; - default: - break; - }; - } - } - - public override void callPropertysSetMethods() - { - ScriptModule sm = EntityDef.moduledefs["Gate"]; - Dictionary pdatas = sm.idpropertys; - - Vector3 oldval_direction = direction; - Property prop_direction = pdatas[2]; - if(prop_direction.isBase()) - { - if(inited && !inWorld) - onDirectionChanged(oldval_direction); - } - else - { - if(inWorld) - { - if(prop_direction.isOwnerOnly() && !isPlayer()) - { - } - else - { - onDirectionChanged(oldval_direction); - } - } - } - - UInt32 oldval_entityNO = entityNO; - Property prop_entityNO = pdatas[4]; - if(prop_entityNO.isBase()) - { - if(inited && !inWorld) - onEntityNOChanged(oldval_entityNO); - } - else - { - if(inWorld) - { - if(prop_entityNO.isOwnerOnly() && !isPlayer()) - { - } - else - { - onEntityNOChanged(oldval_entityNO); - } - } - } - - UInt32 oldval_modelID = modelID; - Property prop_modelID = pdatas[5]; - if(prop_modelID.isBase()) - { - if(inited && !inWorld) - onModelIDChanged(oldval_modelID); - } - else - { - if(inWorld) - { - if(prop_modelID.isOwnerOnly() && !isPlayer()) - { - } - else - { - onModelIDChanged(oldval_modelID); - } - } - } - - Byte oldval_modelScale = modelScale; - Property prop_modelScale = pdatas[6]; - if(prop_modelScale.isBase()) - { - if(inited && !inWorld) - onModelScaleChanged(oldval_modelScale); - } - else - { - if(inWorld) - { - if(prop_modelScale.isOwnerOnly() && !isPlayer()) - { - } - else - { - onModelScaleChanged(oldval_modelScale); - } - } - } - - string oldval_name = name; - Property prop_name = pdatas[7]; - if(prop_name.isBase()) - { - if(inited && !inWorld) - onNameChanged(oldval_name); - } - else - { - if(inWorld) - { - if(prop_name.isOwnerOnly() && !isPlayer()) - { - } - else - { - onNameChanged(oldval_name); - } - } - } - - Vector3 oldval_position = position; - Property prop_position = pdatas[1]; - if(prop_position.isBase()) - { - if(inited && !inWorld) - onPositionChanged(oldval_position); - } - else - { - if(inWorld) - { - if(prop_position.isOwnerOnly() && !isPlayer()) - { - } - else - { - onPositionChanged(oldval_position); - } - } - } - - UInt32 oldval_uid = uid; - Property prop_uid = pdatas[8]; - if(prop_uid.isBase()) - { - if(inited && !inWorld) - onUidChanged(oldval_uid); - } - else - { - if(inWorld) - { - if(prop_uid.isOwnerOnly() && !isPlayer()) - { - } - else - { - onUidChanged(oldval_uid); - } - } - } - - UInt32 oldval_utype = utype; - Property prop_utype = pdatas[9]; - if(prop_utype.isBase()) - { - if(inited && !inWorld) - onUtypeChanged(oldval_utype); - } - else - { - if(inWorld) - { - if(prop_utype.isOwnerOnly() && !isPlayer()) - { - } - else - { - onUtypeChanged(oldval_utype); - } - } - } - - } - } +/* + Generated by KBEngine! + Please do not modify this file! + Please inherit this module, such as: (class Gate : GateBase) + tools = kbcmd +*/ + +namespace KBEngine +{ + using UnityEngine; + using System; + using System.Collections; + using System.Collections.Generic; + + // defined in */scripts/entity_defs/Gate.def + // Please inherit and implement "class Gate : GateBase" + public abstract class GateBase : Entity + { + public EntityBaseEntityCall_GateBase baseEntityCall = null; + public EntityCellEntityCall_GateBase cellEntityCall = null; + + public UInt32 entityNO = 0; + public virtual void onEntityNOChanged(UInt32 oldValue) {} + public UInt32 modelID = 0; + public virtual void onModelIDChanged(UInt32 oldValue) {} + public Byte modelScale = 30; + public virtual void onModelScaleChanged(Byte oldValue) {} + public string name = ""; + public virtual void onNameChanged(string oldValue) {} + public UInt32 uid = 0; + public virtual void onUidChanged(UInt32 oldValue) {} + public UInt32 utype = 0; + public virtual void onUtypeChanged(UInt32 oldValue) {} + + + public GateBase() + { + } + + public override void onComponentsEnterworld() + { + } + + public override void onComponentsLeaveworld() + { + } + + public override void onGetBase() + { + baseEntityCall = new EntityBaseEntityCall_GateBase(id, className); + } + + public override void onGetCell() + { + cellEntityCall = new EntityCellEntityCall_GateBase(id, className); + } + + public override void onLoseCell() + { + cellEntityCall = null; + } + + public override EntityCall getBaseEntityCall() + { + return baseEntityCall; + } + + public override EntityCall getCellEntityCall() + { + return cellEntityCall; + } + + public override void attachComponents() + { + } + + public override void detachComponents() + { + } + + public override void onRemoteMethodCall(MemoryStream stream) + { + ScriptModule sm = EntityDef.moduledefs["Gate"]; + + UInt16 methodUtype = 0; + UInt16 componentPropertyUType = 0; + + if(sm.usePropertyDescrAlias) + { + componentPropertyUType = stream.readUint8(); + } + else + { + componentPropertyUType = stream.readUint16(); + } + + if(sm.useMethodDescrAlias) + { + methodUtype = stream.readUint8(); + } + else + { + methodUtype = stream.readUint16(); + } + + Method method = null; + + if(componentPropertyUType == 0) + { + method = sm.idmethods[methodUtype]; + } + else + { + Property pComponentPropertyDescription = sm.idpropertys[componentPropertyUType]; + switch(pComponentPropertyDescription.properUtype) + { + default: + break; + } + + return; + } + + switch(method.methodUtype) + { + default: + break; + }; + } + + public override void onUpdatePropertys(MemoryStream stream) + { + ScriptModule sm = EntityDef.moduledefs["Gate"]; + Dictionary pdatas = sm.idpropertys; + + while(stream.length() > 0) + { + UInt16 _t_utype = 0; + UInt16 _t_child_utype = 0; + + { + if(sm.usePropertyDescrAlias) + { + _t_utype = stream.readUint8(); + _t_child_utype = stream.readUint8(); + } + else + { + _t_utype = stream.readUint16(); + _t_child_utype = stream.readUint16(); + } + } + + Property prop = null; + + if(_t_utype == 0) + { + prop = pdatas[_t_child_utype]; + } + else + { + Property pComponentPropertyDescription = pdatas[_t_utype]; + switch(pComponentPropertyDescription.properUtype) + { + default: + break; + } + + return; + } + + switch(prop.properUtype) + { + case 40001: + Vector3 oldval_direction = direction; + direction = stream.readVector3(); + + if(prop.isBase()) + { + if(inited) + onDirectionChanged(oldval_direction); + } + else + { + if(inWorld) + onDirectionChanged(oldval_direction); + } + + break; + case 51007: + UInt32 oldval_entityNO = entityNO; + entityNO = stream.readUint32(); + + if(prop.isBase()) + { + if(inited) + onEntityNOChanged(oldval_entityNO); + } + else + { + if(inWorld) + onEntityNOChanged(oldval_entityNO); + } + + break; + case 41006: + UInt32 oldval_modelID = modelID; + modelID = stream.readUint32(); + + if(prop.isBase()) + { + if(inited) + onModelIDChanged(oldval_modelID); + } + else + { + if(inWorld) + onModelIDChanged(oldval_modelID); + } + + break; + case 41007: + Byte oldval_modelScale = modelScale; + modelScale = stream.readUint8(); + + if(prop.isBase()) + { + if(inited) + onModelScaleChanged(oldval_modelScale); + } + else + { + if(inWorld) + onModelScaleChanged(oldval_modelScale); + } + + break; + case 41003: + string oldval_name = name; + name = stream.readUnicode(); + + if(prop.isBase()) + { + if(inited) + onNameChanged(oldval_name); + } + else + { + if(inWorld) + onNameChanged(oldval_name); + } + + break; + case 40000: + Vector3 oldval_position = position; + position = stream.readVector3(); + + if(prop.isBase()) + { + if(inited) + onPositionChanged(oldval_position); + } + else + { + if(inWorld) + onPositionChanged(oldval_position); + } + + break; + case 40002: + stream.readUint32(); + break; + case 41004: + UInt32 oldval_uid = uid; + uid = stream.readUint32(); + + if(prop.isBase()) + { + if(inited) + onUidChanged(oldval_uid); + } + else + { + if(inWorld) + onUidChanged(oldval_uid); + } + + break; + case 41005: + UInt32 oldval_utype = utype; + utype = stream.readUint32(); + + if(prop.isBase()) + { + if(inited) + onUtypeChanged(oldval_utype); + } + else + { + if(inWorld) + onUtypeChanged(oldval_utype); + } + + break; + default: + break; + }; + } + } + + public override void callPropertysSetMethods() + { + ScriptModule sm = EntityDef.moduledefs["Gate"]; + Dictionary pdatas = sm.idpropertys; + + Vector3 oldval_direction = direction; + Property prop_direction = pdatas[2]; + if(prop_direction.isBase()) + { + if(inited && !inWorld) + onDirectionChanged(oldval_direction); + } + else + { + if(inWorld) + { + if(prop_direction.isOwnerOnly() && !isPlayer()) + { + } + else + { + onDirectionChanged(oldval_direction); + } + } + } + + UInt32 oldval_entityNO = entityNO; + Property prop_entityNO = pdatas[4]; + if(prop_entityNO.isBase()) + { + if(inited && !inWorld) + onEntityNOChanged(oldval_entityNO); + } + else + { + if(inWorld) + { + if(prop_entityNO.isOwnerOnly() && !isPlayer()) + { + } + else + { + onEntityNOChanged(oldval_entityNO); + } + } + } + + UInt32 oldval_modelID = modelID; + Property prop_modelID = pdatas[5]; + if(prop_modelID.isBase()) + { + if(inited && !inWorld) + onModelIDChanged(oldval_modelID); + } + else + { + if(inWorld) + { + if(prop_modelID.isOwnerOnly() && !isPlayer()) + { + } + else + { + onModelIDChanged(oldval_modelID); + } + } + } + + Byte oldval_modelScale = modelScale; + Property prop_modelScale = pdatas[6]; + if(prop_modelScale.isBase()) + { + if(inited && !inWorld) + onModelScaleChanged(oldval_modelScale); + } + else + { + if(inWorld) + { + if(prop_modelScale.isOwnerOnly() && !isPlayer()) + { + } + else + { + onModelScaleChanged(oldval_modelScale); + } + } + } + + string oldval_name = name; + Property prop_name = pdatas[7]; + if(prop_name.isBase()) + { + if(inited && !inWorld) + onNameChanged(oldval_name); + } + else + { + if(inWorld) + { + if(prop_name.isOwnerOnly() && !isPlayer()) + { + } + else + { + onNameChanged(oldval_name); + } + } + } + + Vector3 oldval_position = position; + Property prop_position = pdatas[1]; + if(prop_position.isBase()) + { + if(inited && !inWorld) + onPositionChanged(oldval_position); + } + else + { + if(inWorld) + { + if(prop_position.isOwnerOnly() && !isPlayer()) + { + } + else + { + onPositionChanged(oldval_position); + } + } + } + + UInt32 oldval_uid = uid; + Property prop_uid = pdatas[8]; + if(prop_uid.isBase()) + { + if(inited && !inWorld) + onUidChanged(oldval_uid); + } + else + { + if(inWorld) + { + if(prop_uid.isOwnerOnly() && !isPlayer()) + { + } + else + { + onUidChanged(oldval_uid); + } + } + } + + UInt32 oldval_utype = utype; + Property prop_utype = pdatas[9]; + if(prop_utype.isBase()) + { + if(inited && !inWorld) + onUtypeChanged(oldval_utype); + } + else + { + if(inWorld) + { + if(prop_utype.isOwnerOnly() && !isPlayer()) + { + } + else + { + onUtypeChanged(oldval_utype); + } + } + } + + } + } } \ No newline at end of file diff --git a/Assets/Plugins/kbengine_unity3d_plugins/KBEMain.cs b/Assets/Plugins/kbengine_unity3d_plugins/KBEMain.cs index bdb4427..9437050 100644 --- a/Assets/Plugins/kbengine_unity3d_plugins/KBEMain.cs +++ b/Assets/Plugins/kbengine_unity3d_plugins/KBEMain.cs @@ -1,128 +1,128 @@ -using UnityEngine; -using System; -using System.Collections; -using KBEngine; - -/* - 可以理解为插件的入口模块 - 在这个入口中安装了需要监听的事件(installEvents),同时初始化KBEngine(initKBEngine) -*/ - -public class KBEMain : MonoBehaviour -{ - public KBEngineApp gameapp = null; - - // 在unity3d界面中可见选项 - public DEBUGLEVEL debugLevel = DEBUGLEVEL.DEBUG; - public bool isMultiThreads = false; - public string ip = "127.0.0.1"; - public int port = 20013; - public KBEngineApp.CLIENT_TYPE clientType = KBEngineApp.CLIENT_TYPE.CLIENT_TYPE_MINI; - public KBEngineApp.NETWORK_ENCRYPT_TYPE networkEncryptType = KBEngineApp.NETWORK_ENCRYPT_TYPE.ENCRYPT_TYPE_NONE; - public int syncPlayerMS = 1000 / 10; - - public int threadUpdateHZ = 10 * 2; - public int serverHeartbeatTick = 60; - public int TCP_SEND_BUFFER_MAX = (int)KBEngine.NetworkInterfaceBase.TCP_PACKET_MAX; - public int TCP_RECV_BUFFER_MAX = (int)KBEngine.NetworkInterfaceBase.TCP_PACKET_MAX; - public int UDP_SEND_BUFFER_MAX = (int)KBEngine.NetworkInterfaceBase.UDP_PACKET_MAX; - public int UDP_RECV_BUFFER_MAX = (int)KBEngine.NetworkInterfaceBase.UDP_PACKET_MAX; - public bool useAliasEntityID = true; - public bool isOnInitCallPropertysSetMethods = true; - public bool forceDisableUDP = false; - - public bool automaticallyUpdateSDK = true; - - protected virtual void Awake() - { - DontDestroyOnLoad(transform.gameObject); - } - - // Use this for initialization - protected virtual void Start () - { - MonoBehaviour.print("clientapp::start()"); - installEvents(); - initKBEngine(); - } - - public virtual void installEvents() - { - KBEngine.Event.registerOut(EventOutTypes.onVersionNotMatch, this, "onVersionNotMatch"); - KBEngine.Event.registerOut(EventOutTypes.onScriptVersionNotMatch, this, "onScriptVersionNotMatch"); - } - - public void onVersionNotMatch(string verInfo, string serVerInfo) - { -#if UNITY_EDITOR - if(automaticallyUpdateSDK) - gameObject.AddComponent(); -#endif - } - - public void onScriptVersionNotMatch(string verInfo, string serVerInfo) - { -#if UNITY_EDITOR - if(automaticallyUpdateSDK) - gameObject.AddComponent(); -#endif - } - - public virtual void initKBEngine() - { - // 如果此处发生错误,请查看 Assets\Scripts\kbe_scripts\if_Entity_error_use______git_submodule_update_____kbengine_plugins_______open_this_file_and_I_will_tell_you.cs - - Dbg.debugLevel = debugLevel; - - KBEngineArgs args = new KBEngineArgs(); - - args.ip = ip; - args.port = port; - args.clientType = clientType; - args.networkEncryptType = networkEncryptType; - args.syncPlayerMS = syncPlayerMS; - args.threadUpdateHZ = threadUpdateHZ; - args.serverHeartbeatTick = serverHeartbeatTick / 2; - args.useAliasEntityID = useAliasEntityID; - args.isOnInitCallPropertysSetMethods = isOnInitCallPropertysSetMethods; - args.forceDisableUDP = forceDisableUDP; - - args.TCP_SEND_BUFFER_MAX = (UInt32)TCP_SEND_BUFFER_MAX; - args.TCP_RECV_BUFFER_MAX = (UInt32)TCP_RECV_BUFFER_MAX; - args.UDP_SEND_BUFFER_MAX = (UInt32)UDP_SEND_BUFFER_MAX; - args.UDP_RECV_BUFFER_MAX = (UInt32)UDP_RECV_BUFFER_MAX; - - args.isMultiThreads = isMultiThreads; - - if(isMultiThreads) - gameapp = new KBEngineAppThread(args); - else - gameapp = new KBEngineApp(args); - } - - protected virtual void OnDestroy() - { - MonoBehaviour.print("clientapp::OnDestroy(): begin"); - if (KBEngineApp.app != null) - { - KBEngineApp.app.destroy(); - KBEngineApp.app = null; - } - KBEngine.Event.clear(); - MonoBehaviour.print("clientapp::OnDestroy(): end"); - } - - protected virtual void FixedUpdate () - { - KBEUpdate(); - } - - public virtual void KBEUpdate() - { - // 单线程模式必须自己调用 - if(!isMultiThreads) - gameapp.process(); - - KBEngine.Event.processOutEvents(); - } -} +using UnityEngine; +using System; +using System.Collections; +using KBEngine; + +/* + 可以理解为插件的入口模块 + 在这个入口中安装了需要监听的事件(installEvents),同时初始化KBEngine(initKBEngine) +*/ + +public class KBEMain : MonoBehaviour +{ + public KBEngineApp gameapp = null; + + // 在unity3d界面中可见选项 + public DEBUGLEVEL debugLevel = DEBUGLEVEL.DEBUG; + public bool isMultiThreads = false; + public string ip = "127.0.0.1"; + public int port = 20013; + public KBEngineApp.CLIENT_TYPE clientType = KBEngineApp.CLIENT_TYPE.CLIENT_TYPE_MINI; + public KBEngineApp.NETWORK_ENCRYPT_TYPE networkEncryptType = KBEngineApp.NETWORK_ENCRYPT_TYPE.ENCRYPT_TYPE_NONE; + public int syncPlayerMS = 1000 / 10; + + public int threadUpdateHZ = 10 * 2; + public int serverHeartbeatTick = 60; + public int TCP_SEND_BUFFER_MAX = (int)KBEngine.NetworkInterfaceBase.TCP_PACKET_MAX; + public int TCP_RECV_BUFFER_MAX = (int)KBEngine.NetworkInterfaceBase.TCP_PACKET_MAX; + public int UDP_SEND_BUFFER_MAX = (int)KBEngine.NetworkInterfaceBase.UDP_PACKET_MAX; + public int UDP_RECV_BUFFER_MAX = (int)KBEngine.NetworkInterfaceBase.UDP_PACKET_MAX; + public bool useAliasEntityID = true; + public bool isOnInitCallPropertysSetMethods = true; + public bool forceDisableUDP = false; + + public bool automaticallyUpdateSDK = true; + + protected virtual void Awake() + { + DontDestroyOnLoad(transform.gameObject); + } + + // Use this for initialization + protected virtual void Start () + { + MonoBehaviour.print("clientapp::start()"); + installEvents(); + initKBEngine(); + } + + public virtual void installEvents() + { + KBEngine.Event.registerOut(EventOutTypes.onVersionNotMatch, this, "onVersionNotMatch"); + KBEngine.Event.registerOut(EventOutTypes.onScriptVersionNotMatch, this, "onScriptVersionNotMatch"); + } + + public void onVersionNotMatch(string verInfo, string serVerInfo) + { +#if UNITY_EDITOR + if(automaticallyUpdateSDK) + gameObject.AddComponent(); +#endif + } + + public void onScriptVersionNotMatch(string verInfo, string serVerInfo) + { +#if UNITY_EDITOR + if(automaticallyUpdateSDK) + gameObject.AddComponent(); +#endif + } + + public virtual void initKBEngine() + { + // 如果此处发生错误,请查看 Assets\Scripts\kbe_scripts\if_Entity_error_use______git_submodule_update_____kbengine_plugins_______open_this_file_and_I_will_tell_you.cs + + Dbg.debugLevel = debugLevel; + + KBEngineArgs args = new KBEngineArgs(); + + args.ip = ip; + args.port = port; + args.clientType = clientType; + args.networkEncryptType = networkEncryptType; + args.syncPlayerMS = syncPlayerMS; + args.threadUpdateHZ = threadUpdateHZ; + args.serverHeartbeatTick = serverHeartbeatTick / 2; + args.useAliasEntityID = useAliasEntityID; + args.isOnInitCallPropertysSetMethods = isOnInitCallPropertysSetMethods; + args.forceDisableUDP = forceDisableUDP; + + args.TCP_SEND_BUFFER_MAX = (UInt32)TCP_SEND_BUFFER_MAX; + args.TCP_RECV_BUFFER_MAX = (UInt32)TCP_RECV_BUFFER_MAX; + args.UDP_SEND_BUFFER_MAX = (UInt32)UDP_SEND_BUFFER_MAX; + args.UDP_RECV_BUFFER_MAX = (UInt32)UDP_RECV_BUFFER_MAX; + + args.isMultiThreads = isMultiThreads; + + if(isMultiThreads) + gameapp = new KBEngineAppThread(args); + else + gameapp = new KBEngineApp(args); + } + + protected virtual void OnDestroy() + { + MonoBehaviour.print("clientapp::OnDestroy(): begin"); + if (KBEngineApp.app != null) + { + KBEngineApp.app.destroy(); + KBEngineApp.app = null; + } + KBEngine.Event.clear(); + MonoBehaviour.print("clientapp::OnDestroy(): end"); + } + + protected virtual void FixedUpdate () + { + KBEUpdate(); + } + + public virtual void KBEUpdate() + { + // 单线程模式必须自己调用 + if(!isMultiThreads) + gameapp.process(); + + KBEngine.Event.processOutEvents(); + } +} diff --git a/Assets/Plugins/kbengine_unity3d_plugins/KBETypes.cs b/Assets/Plugins/kbengine_unity3d_plugins/KBETypes.cs index ef22740..a3bca7c 100644 --- a/Assets/Plugins/kbengine_unity3d_plugins/KBETypes.cs +++ b/Assets/Plugins/kbengine_unity3d_plugins/KBETypes.cs @@ -1,1605 +1,1605 @@ -/* - Generated by KBEngine! - Please do not modify this file! - tools = kbcmd -*/ - -namespace KBEngine -{ - using UnityEngine; - using System; - using System.Collections; - using System.Collections.Generic; - - - - // defined in */scripts/entity_defs/types.xml - - public struct UINT8 - { - Byte value; - - UINT8(Byte value) - { - this.value = value; - } - - public static implicit operator Byte(UINT8 value) - { - return value.value; - } - - public static implicit operator UINT8(Byte value) - { - Byte tvalue = (Byte)value; - return new UINT8(tvalue); - } - - public static Byte MaxValue - { - get - { - return Byte.MaxValue; - } - } - - public static Byte MinValue - { - get - { - return Byte.MinValue; - } - } - } - - public struct UINT16 - { - UInt16 value; - - UINT16(UInt16 value) - { - this.value = value; - } - - public static implicit operator UInt16(UINT16 value) - { - return value.value; - } - - public static implicit operator UINT16(UInt16 value) - { - UInt16 tvalue = (UInt16)value; - return new UINT16(tvalue); - } - - public static UInt16 MaxValue - { - get - { - return UInt16.MaxValue; - } - } - - public static UInt16 MinValue - { - get - { - return UInt16.MinValue; - } - } - } - - public struct UINT64 - { - UInt64 value; - - UINT64(UInt64 value) - { - this.value = value; - } - - public static implicit operator UInt64(UINT64 value) - { - return value.value; - } - - public static implicit operator UINT64(UInt64 value) - { - UInt64 tvalue = (UInt64)value; - return new UINT64(tvalue); - } - - public static UInt64 MaxValue - { - get - { - return UInt64.MaxValue; - } - } - - public static UInt64 MinValue - { - get - { - return UInt64.MinValue; - } - } - } - - public struct UINT32 - { - UInt32 value; - - UINT32(UInt32 value) - { - this.value = value; - } - - public static implicit operator UInt32(UINT32 value) - { - return value.value; - } - - public static implicit operator UINT32(UInt32 value) - { - UInt32 tvalue = (UInt32)value; - return new UINT32(tvalue); - } - - public static UInt32 MaxValue - { - get - { - return UInt32.MaxValue; - } - } - - public static UInt32 MinValue - { - get - { - return UInt32.MinValue; - } - } - } - - public struct INT8 - { - SByte value; - - INT8(SByte value) - { - this.value = value; - } - - public static implicit operator SByte(INT8 value) - { - return value.value; - } - - public static implicit operator INT8(SByte value) - { - SByte tvalue = (SByte)value; - return new INT8(tvalue); - } - - public static SByte MaxValue - { - get - { - return SByte.MaxValue; - } - } - - public static SByte MinValue - { - get - { - return SByte.MinValue; - } - } - } - - public struct INT16 - { - Int16 value; - - INT16(Int16 value) - { - this.value = value; - } - - public static implicit operator Int16(INT16 value) - { - return value.value; - } - - public static implicit operator INT16(Int16 value) - { - Int16 tvalue = (Int16)value; - return new INT16(tvalue); - } - - public static Int16 MaxValue - { - get - { - return Int16.MaxValue; - } - } - - public static Int16 MinValue - { - get - { - return Int16.MinValue; - } - } - } - - public struct INT32 - { - Int32 value; - - INT32(Int32 value) - { - this.value = value; - } - - public static implicit operator Int32(INT32 value) - { - return value.value; - } - - public static implicit operator INT32(Int32 value) - { - Int32 tvalue = (Int32)value; - return new INT32(tvalue); - } - - public static Int32 MaxValue - { - get - { - return Int32.MaxValue; - } - } - - public static Int32 MinValue - { - get - { - return Int32.MinValue; - } - } - } - - public struct INT64 - { - Int64 value; - - INT64(Int64 value) - { - this.value = value; - } - - public static implicit operator Int64(INT64 value) - { - return value.value; - } - - public static implicit operator INT64(Int64 value) - { - Int64 tvalue = (Int64)value; - return new INT64(tvalue); - } - - public static Int64 MaxValue - { - get - { - return Int64.MaxValue; - } - } - - public static Int64 MinValue - { - get - { - return Int64.MinValue; - } - } - } - - public struct STRING - { - string value; - - STRING(string value) - { - this.value = value; - } - - public static implicit operator string(STRING value) - { - return value.value; - } - - public static implicit operator STRING(string value) - { - string tvalue = (string)value; - return new STRING(tvalue); - } - } - - public struct UNICODE - { - string value; - - UNICODE(string value) - { - this.value = value; - } - - public static implicit operator string(UNICODE value) - { - return value.value; - } - - public static implicit operator UNICODE(string value) - { - string tvalue = (string)value; - return new UNICODE(tvalue); - } - } - - public struct FLOAT - { - float value; - - FLOAT(float value) - { - this.value = value; - } - - public static implicit operator float(FLOAT value) - { - return value.value; - } - - public static implicit operator FLOAT(float value) - { - float tvalue = (float)value; - return new FLOAT(tvalue); - } - - public static float MaxValue - { - get - { - return float.MaxValue; - } - } - - public static float MinValue - { - get - { - return float.MinValue; - } - } - } - - public struct DOUBLE - { - double value; - - DOUBLE(double value) - { - this.value = value; - } - - public static implicit operator double(DOUBLE value) - { - return value.value; - } - - public static implicit operator DOUBLE(double value) - { - double tvalue = (double)value; - return new DOUBLE(tvalue); - } - - public static double MaxValue - { - get - { - return double.MaxValue; - } - } - - public static double MinValue - { - get - { - return double.MinValue; - } - } - } - - public struct PYTHON - { - byte[] value; - - PYTHON(byte[] value) - { - this.value = value; - } - - public static implicit operator byte[](PYTHON value) - { - return value.value; - } - - public static implicit operator PYTHON(byte[] value) - { - byte[] tvalue = (byte[])value; - return new PYTHON(tvalue); - } - - public Byte this[int ID] - { - get { return value[ID]; } - set { this.value[ID] = value; } - } - } - - public struct PY_DICT - { - byte[] value; - - PY_DICT(byte[] value) - { - this.value = value; - } - - public static implicit operator byte[](PY_DICT value) - { - return value.value; - } - - public static implicit operator PY_DICT(byte[] value) - { - byte[] tvalue = (byte[])value; - return new PY_DICT(tvalue); - } - - public Byte this[int ID] - { - get { return value[ID]; } - set { this.value[ID] = value; } - } - } - - public struct PY_TUPLE - { - byte[] value; - - PY_TUPLE(byte[] value) - { - this.value = value; - } - - public static implicit operator byte[](PY_TUPLE value) - { - return value.value; - } - - public static implicit operator PY_TUPLE(byte[] value) - { - byte[] tvalue = (byte[])value; - return new PY_TUPLE(tvalue); - } - - public Byte this[int ID] - { - get { return value[ID]; } - set { this.value[ID] = value; } - } - } - - public struct PY_LIST - { - byte[] value; - - PY_LIST(byte[] value) - { - this.value = value; - } - - public static implicit operator byte[](PY_LIST value) - { - return value.value; - } - - public static implicit operator PY_LIST(byte[] value) - { - byte[] tvalue = (byte[])value; - return new PY_LIST(tvalue); - } - - public Byte this[int ID] - { - get { return value[ID]; } - set { this.value[ID] = value; } - } - } - - public struct ENTITYCALL - { - byte[] value; - - ENTITYCALL(byte[] value) - { - this.value = value; - } - - public static implicit operator byte[](ENTITYCALL value) - { - return value.value; - } - - public static implicit operator ENTITYCALL(byte[] value) - { - byte[] tvalue = (byte[])value; - return new ENTITYCALL(tvalue); - } - - public Byte this[int ID] - { - get { return value[ID]; } - set { this.value[ID] = value; } - } - } - - public struct BLOB - { - byte[] value; - - BLOB(byte[] value) - { - this.value = value; - } - - public static implicit operator byte[](BLOB value) - { - return value.value; - } - - public static implicit operator BLOB(byte[] value) - { - byte[] tvalue = (byte[])value; - return new BLOB(tvalue); - } - - public Byte this[int ID] - { - get { return value[ID]; } - set { this.value[ID] = value; } - } - } - - public struct VECTOR2 - { - Vector2 value; - - VECTOR2(Vector2 value) - { - this.value = value; - } - - public static implicit operator Vector2(VECTOR2 value) - { - return value.value; - } - - public static implicit operator VECTOR2(Vector2 value) - { - Vector2 tvalue = (Vector2)value; - return new VECTOR2(tvalue); - } - - public float x - { - get { return value.x; } - set { this.value.x = value; } - } - - public float y - { - get { return value.y; } - set { this.value.y = value; } - } - - } - - public struct VECTOR3 - { - Vector3 value; - - VECTOR3(Vector3 value) - { - this.value = value; - } - - public static implicit operator Vector3(VECTOR3 value) - { - return value.value; - } - - public static implicit operator VECTOR3(Vector3 value) - { - Vector3 tvalue = (Vector3)value; - return new VECTOR3(tvalue); - } - - public float x - { - get { return value.x; } - set { this.value.x = value; } - } - - public float y - { - get { return value.y; } - set { this.value.y = value; } - } - - public float z - { - get { return value.z; } - set { this.value.z = value; } - } - - } - - public struct VECTOR4 - { - Vector4 value; - - VECTOR4(Vector4 value) - { - this.value = value; - } - - public static implicit operator Vector4(VECTOR4 value) - { - return value.value; - } - - public static implicit operator VECTOR4(Vector4 value) - { - Vector4 tvalue = (Vector4)value; - return new VECTOR4(tvalue); - } - - public float x - { - get { return value.x; } - set { this.value.x = value; } - } - - public float y - { - get { return value.y; } - set { this.value.y = value; } - } - - public float z - { - get { return value.z; } - set { this.value.z = value; } - } - - public float w - { - get { return value.w; } - set { this.value.w = value; } - } - } - - public struct OBJECT_ID - { - Int32 value; - - OBJECT_ID(Int32 value) - { - this.value = value; - } - - public static implicit operator Int32(OBJECT_ID value) - { - return value.value; - } - - public static implicit operator OBJECT_ID(Int32 value) - { - Int32 tvalue = (Int32)value; - return new OBJECT_ID(tvalue); - } - - public static Int32 MaxValue - { - get - { - return Int32.MaxValue; - } - } - - public static Int32 MinValue - { - get - { - return Int32.MinValue; - } - } - } - - public struct BOOL - { - Byte value; - - BOOL(Byte value) - { - this.value = value; - } - - public static implicit operator Byte(BOOL value) - { - return value.value; - } - - public static implicit operator BOOL(Byte value) - { - Byte tvalue = (Byte)value; - return new BOOL(tvalue); - } - - public static Byte MaxValue - { - get - { - return Byte.MaxValue; - } - } - - public static Byte MinValue - { - get - { - return Byte.MinValue; - } - } - } - - public struct CONTROLLER_ID - { - Int32 value; - - CONTROLLER_ID(Int32 value) - { - this.value = value; - } - - public static implicit operator Int32(CONTROLLER_ID value) - { - return value.value; - } - - public static implicit operator CONTROLLER_ID(Int32 value) - { - Int32 tvalue = (Int32)value; - return new CONTROLLER_ID(tvalue); - } - - public static Int32 MaxValue - { - get - { - return Int32.MaxValue; - } - } - - public static Int32 MinValue - { - get - { - return Int32.MinValue; - } - } - } - - public struct EXPERIENCE - { - Int32 value; - - EXPERIENCE(Int32 value) - { - this.value = value; - } - - public static implicit operator Int32(EXPERIENCE value) - { - return value.value; - } - - public static implicit operator EXPERIENCE(Int32 value) - { - Int32 tvalue = (Int32)value; - return new EXPERIENCE(tvalue); - } - - public static Int32 MaxValue - { - get - { - return Int32.MaxValue; - } - } - - public static Int32 MinValue - { - get - { - return Int32.MinValue; - } - } - } - - public struct ITEM_ID - { - Int32 value; - - ITEM_ID(Int32 value) - { - this.value = value; - } - - public static implicit operator Int32(ITEM_ID value) - { - return value.value; - } - - public static implicit operator ITEM_ID(Int32 value) - { - Int32 tvalue = (Int32)value; - return new ITEM_ID(tvalue); - } - - public static Int32 MaxValue - { - get - { - return Int32.MaxValue; - } - } - - public static Int32 MinValue - { - get - { - return Int32.MinValue; - } - } - } - - public struct SKILLID - { - Int32 value; - - SKILLID(Int32 value) - { - this.value = value; - } - - public static implicit operator Int32(SKILLID value) - { - return value.value; - } - - public static implicit operator SKILLID(Int32 value) - { - Int32 tvalue = (Int32)value; - return new SKILLID(tvalue); - } - - public static Int32 MaxValue - { - get - { - return Int32.MaxValue; - } - } - - public static Int32 MinValue - { - get - { - return Int32.MinValue; - } - } - } - - public struct QUESTID - { - Int32 value; - - QUESTID(Int32 value) - { - this.value = value; - } - - public static implicit operator Int32(QUESTID value) - { - return value.value; - } - - public static implicit operator QUESTID(Int32 value) - { - Int32 tvalue = (Int32)value; - return new QUESTID(tvalue); - } - - public static Int32 MaxValue - { - get - { - return Int32.MaxValue; - } - } - - public static Int32 MinValue - { - get - { - return Int32.MinValue; - } - } - } - - public struct DBID - { - UInt64 value; - - DBID(UInt64 value) - { - this.value = value; - } - - public static implicit operator UInt64(DBID value) - { - return value.value; - } - - public static implicit operator DBID(UInt64 value) - { - UInt64 tvalue = (UInt64)value; - return new DBID(tvalue); - } - - public static UInt64 MaxValue - { - get - { - return UInt64.MaxValue; - } - } - - public static UInt64 MinValue - { - get - { - return UInt64.MinValue; - } - } - } - - public struct UID - { - UInt64 value; - - UID(UInt64 value) - { - this.value = value; - } - - public static implicit operator UInt64(UID value) - { - return value.value; - } - - public static implicit operator UID(UInt64 value) - { - UInt64 tvalue = (UInt64)value; - return new UID(tvalue); - } - - public static UInt64 MaxValue - { - get - { - return UInt64.MaxValue; - } - } - - public static UInt64 MinValue - { - get - { - return UInt64.MinValue; - } - } - } - - public struct UID1 - { - byte[] value; - - UID1(byte[] value) - { - this.value = value; - } - - public static implicit operator byte[](UID1 value) - { - return value.value; - } - - public static implicit operator UID1(byte[] value) - { - byte[] tvalue = (byte[])value; - return new UID1(tvalue); - } - - public Byte this[int ID] - { - get { return value[ID]; } - set { this.value[ID] = value; } - } - } - - public struct ENTITY_ID - { - Int32 value; - - ENTITY_ID(Int32 value) - { - this.value = value; - } - - public static implicit operator Int32(ENTITY_ID value) - { - return value.value; - } - - public static implicit operator ENTITY_ID(Int32 value) - { - Int32 tvalue = (Int32)value; - return new ENTITY_ID(tvalue); - } - - public static Int32 MaxValue - { - get - { - return Int32.MaxValue; - } - } - - public static Int32 MinValue - { - get - { - return Int32.MinValue; - } - } - } - - public struct ENTITY_NO - { - UInt32 value; - - ENTITY_NO(UInt32 value) - { - this.value = value; - } - - public static implicit operator UInt32(ENTITY_NO value) - { - return value.value; - } - - public static implicit operator ENTITY_NO(UInt32 value) - { - UInt32 tvalue = (UInt32)value; - return new ENTITY_NO(tvalue); - } - - public static UInt32 MaxValue - { - get - { - return UInt32.MaxValue; - } - } - - public static UInt32 MinValue - { - get - { - return UInt32.MinValue; - } - } - } - - public struct SPACE_ID - { - UInt32 value; - - SPACE_ID(UInt32 value) - { - this.value = value; - } - - public static implicit operator UInt32(SPACE_ID value) - { - return value.value; - } - - public static implicit operator SPACE_ID(UInt32 value) - { - UInt32 tvalue = (UInt32)value; - return new SPACE_ID(tvalue); - } - - public static UInt32 MaxValue - { - get - { - return UInt32.MaxValue; - } - } - - public static UInt32 MinValue - { - get - { - return UInt32.MinValue; - } - } - } - - public struct POSITION3D - { - Vector3 value; - - POSITION3D(Vector3 value) - { - this.value = value; - } - - public static implicit operator Vector3(POSITION3D value) - { - return value.value; - } - - public static implicit operator POSITION3D(Vector3 value) - { - Vector3 tvalue = (Vector3)value; - return new POSITION3D(tvalue); - } - - public float x - { - get { return value.x; } - set { this.value.x = value; } - } - - public float y - { - get { return value.y; } - set { this.value.y = value; } - } - - public float z - { - get { return value.z; } - set { this.value.z = value; } - } - - } - - public struct DIRECTION3D - { - Vector3 value; - - DIRECTION3D(Vector3 value) - { - this.value = value; - } - - public static implicit operator Vector3(DIRECTION3D value) - { - return value.value; - } - - public static implicit operator DIRECTION3D(Vector3 value) - { - Vector3 tvalue = (Vector3)value; - return new DIRECTION3D(tvalue); - } - - public float x - { - get { return value.x; } - set { this.value.x = value; } - } - - public float y - { - get { return value.y; } - set { this.value.y = value; } - } - - public float z - { - get { return value.z; } - set { this.value.z = value; } - } - - } - - public struct ENTITY_UTYPE - { - UInt32 value; - - ENTITY_UTYPE(UInt32 value) - { - this.value = value; - } - - public static implicit operator UInt32(ENTITY_UTYPE value) - { - return value.value; - } - - public static implicit operator ENTITY_UTYPE(UInt32 value) - { - UInt32 tvalue = (UInt32)value; - return new ENTITY_UTYPE(tvalue); - } - - public static UInt32 MaxValue - { - get - { - return UInt32.MaxValue; - } - } - - public static UInt32 MinValue - { - get - { - return UInt32.MinValue; - } - } - } - - public struct DAMAGE_TYPE - { - Int32 value; - - DAMAGE_TYPE(Int32 value) - { - this.value = value; - } - - public static implicit operator Int32(DAMAGE_TYPE value) - { - return value.value; - } - - public static implicit operator DAMAGE_TYPE(Int32 value) - { - Int32 tvalue = (Int32)value; - return new DAMAGE_TYPE(tvalue); - } - - public static Int32 MaxValue - { - get - { - return Int32.MaxValue; - } - } - - public static Int32 MinValue - { - get - { - return Int32.MinValue; - } - } - } - - public struct ENMITY - { - Int32 value; - - ENMITY(Int32 value) - { - this.value = value; - } - - public static implicit operator Int32(ENMITY value) - { - return value.value; - } - - public static implicit operator ENMITY(Int32 value) - { - Int32 tvalue = (Int32)value; - return new ENMITY(tvalue); - } - - public static Int32 MaxValue - { - get - { - return Int32.MaxValue; - } - } - - public static Int32 MinValue - { - get - { - return Int32.MinValue; - } - } - } - - public struct HP - { - Int32 value; - - HP(Int32 value) - { - this.value = value; - } - - public static implicit operator Int32(HP value) - { - return value.value; - } - - public static implicit operator HP(Int32 value) - { - Int32 tvalue = (Int32)value; - return new HP(tvalue); - } - - public static Int32 MaxValue - { - get - { - return Int32.MaxValue; - } - } - - public static Int32 MinValue - { - get - { - return Int32.MinValue; - } - } - } - - public struct MP - { - Int32 value; - - MP(Int32 value) - { - this.value = value; - } - - public static implicit operator Int32(MP value) - { - return value.value; - } - - public static implicit operator MP(Int32 value) - { - Int32 tvalue = (Int32)value; - return new MP(tvalue); - } - - public static Int32 MaxValue - { - get - { - return Int32.MaxValue; - } - } - - public static Int32 MinValue - { - get - { - return Int32.MinValue; - } - } - } - - public struct ENTITY_STATE - { - SByte value; - - ENTITY_STATE(SByte value) - { - this.value = value; - } - - public static implicit operator SByte(ENTITY_STATE value) - { - return value.value; - } - - public static implicit operator ENTITY_STATE(SByte value) - { - SByte tvalue = (SByte)value; - return new ENTITY_STATE(tvalue); - } - - public static SByte MaxValue - { - get - { - return SByte.MaxValue; - } - } - - public static SByte MinValue - { - get - { - return SByte.MinValue; - } - } - } - - public struct ENTITY_SUBSTATE - { - Byte value; - - ENTITY_SUBSTATE(Byte value) - { - this.value = value; - } - - public static implicit operator Byte(ENTITY_SUBSTATE value) - { - return value.value; - } - - public static implicit operator ENTITY_SUBSTATE(Byte value) - { - Byte tvalue = (Byte)value; - return new ENTITY_SUBSTATE(tvalue); - } - - public static Byte MaxValue - { - get - { - return Byte.MaxValue; - } - } - - public static Byte MinValue - { - get - { - return Byte.MinValue; - } - } - } - - public struct ENTITY_FORBIDS - { - Int32 value; - - ENTITY_FORBIDS(Int32 value) - { - this.value = value; - } - - public static implicit operator Int32(ENTITY_FORBIDS value) - { - return value.value; - } - - public static implicit operator ENTITY_FORBIDS(Int32 value) - { - Int32 tvalue = (Int32)value; - return new ENTITY_FORBIDS(tvalue); - } - - public static Int32 MaxValue - { - get - { - return Int32.MaxValue; - } - } - - public static Int32 MinValue - { - get - { - return Int32.MinValue; - } - } - } - - public class ENTITY_FORBID_COUNTER : List - { - - } - - public class ENTITYID_LIST : List - { - - } - - public class AVATAR_DATA - { - public SByte param1 = 0; - public byte[] param2 = new byte[0]; - - } - - public class AVATAR_INFOS - { - public UInt64 dbid = 0; - public string name = ""; - public Byte roleType = 0; - public UInt16 level = 0; - public AVATAR_DATA data = new AVATAR_DATA(); - - } - - public class AVATAR_INFOS_LIST - { - public List values = new List(); - - } - - public class BAG - { - public List> values22 = new List>(); - - } - - public class EXAMPLES - { - public Int64 k1 = 0; - public Int64 k2 = 0; - - } - - +/* + Generated by KBEngine! + Please do not modify this file! + tools = kbcmd +*/ + +namespace KBEngine +{ + using UnityEngine; + using System; + using System.Collections; + using System.Collections.Generic; + + + + // defined in */scripts/entity_defs/types.xml + + public struct UINT8 + { + Byte value; + + UINT8(Byte value) + { + this.value = value; + } + + public static implicit operator Byte(UINT8 value) + { + return value.value; + } + + public static implicit operator UINT8(Byte value) + { + Byte tvalue = (Byte)value; + return new UINT8(tvalue); + } + + public static Byte MaxValue + { + get + { + return Byte.MaxValue; + } + } + + public static Byte MinValue + { + get + { + return Byte.MinValue; + } + } + } + + public struct UINT16 + { + UInt16 value; + + UINT16(UInt16 value) + { + this.value = value; + } + + public static implicit operator UInt16(UINT16 value) + { + return value.value; + } + + public static implicit operator UINT16(UInt16 value) + { + UInt16 tvalue = (UInt16)value; + return new UINT16(tvalue); + } + + public static UInt16 MaxValue + { + get + { + return UInt16.MaxValue; + } + } + + public static UInt16 MinValue + { + get + { + return UInt16.MinValue; + } + } + } + + public struct UINT64 + { + UInt64 value; + + UINT64(UInt64 value) + { + this.value = value; + } + + public static implicit operator UInt64(UINT64 value) + { + return value.value; + } + + public static implicit operator UINT64(UInt64 value) + { + UInt64 tvalue = (UInt64)value; + return new UINT64(tvalue); + } + + public static UInt64 MaxValue + { + get + { + return UInt64.MaxValue; + } + } + + public static UInt64 MinValue + { + get + { + return UInt64.MinValue; + } + } + } + + public struct UINT32 + { + UInt32 value; + + UINT32(UInt32 value) + { + this.value = value; + } + + public static implicit operator UInt32(UINT32 value) + { + return value.value; + } + + public static implicit operator UINT32(UInt32 value) + { + UInt32 tvalue = (UInt32)value; + return new UINT32(tvalue); + } + + public static UInt32 MaxValue + { + get + { + return UInt32.MaxValue; + } + } + + public static UInt32 MinValue + { + get + { + return UInt32.MinValue; + } + } + } + + public struct INT8 + { + SByte value; + + INT8(SByte value) + { + this.value = value; + } + + public static implicit operator SByte(INT8 value) + { + return value.value; + } + + public static implicit operator INT8(SByte value) + { + SByte tvalue = (SByte)value; + return new INT8(tvalue); + } + + public static SByte MaxValue + { + get + { + return SByte.MaxValue; + } + } + + public static SByte MinValue + { + get + { + return SByte.MinValue; + } + } + } + + public struct INT16 + { + Int16 value; + + INT16(Int16 value) + { + this.value = value; + } + + public static implicit operator Int16(INT16 value) + { + return value.value; + } + + public static implicit operator INT16(Int16 value) + { + Int16 tvalue = (Int16)value; + return new INT16(tvalue); + } + + public static Int16 MaxValue + { + get + { + return Int16.MaxValue; + } + } + + public static Int16 MinValue + { + get + { + return Int16.MinValue; + } + } + } + + public struct INT32 + { + Int32 value; + + INT32(Int32 value) + { + this.value = value; + } + + public static implicit operator Int32(INT32 value) + { + return value.value; + } + + public static implicit operator INT32(Int32 value) + { + Int32 tvalue = (Int32)value; + return new INT32(tvalue); + } + + public static Int32 MaxValue + { + get + { + return Int32.MaxValue; + } + } + + public static Int32 MinValue + { + get + { + return Int32.MinValue; + } + } + } + + public struct INT64 + { + Int64 value; + + INT64(Int64 value) + { + this.value = value; + } + + public static implicit operator Int64(INT64 value) + { + return value.value; + } + + public static implicit operator INT64(Int64 value) + { + Int64 tvalue = (Int64)value; + return new INT64(tvalue); + } + + public static Int64 MaxValue + { + get + { + return Int64.MaxValue; + } + } + + public static Int64 MinValue + { + get + { + return Int64.MinValue; + } + } + } + + public struct STRING + { + string value; + + STRING(string value) + { + this.value = value; + } + + public static implicit operator string(STRING value) + { + return value.value; + } + + public static implicit operator STRING(string value) + { + string tvalue = (string)value; + return new STRING(tvalue); + } + } + + public struct UNICODE + { + string value; + + UNICODE(string value) + { + this.value = value; + } + + public static implicit operator string(UNICODE value) + { + return value.value; + } + + public static implicit operator UNICODE(string value) + { + string tvalue = (string)value; + return new UNICODE(tvalue); + } + } + + public struct FLOAT + { + float value; + + FLOAT(float value) + { + this.value = value; + } + + public static implicit operator float(FLOAT value) + { + return value.value; + } + + public static implicit operator FLOAT(float value) + { + float tvalue = (float)value; + return new FLOAT(tvalue); + } + + public static float MaxValue + { + get + { + return float.MaxValue; + } + } + + public static float MinValue + { + get + { + return float.MinValue; + } + } + } + + public struct DOUBLE + { + double value; + + DOUBLE(double value) + { + this.value = value; + } + + public static implicit operator double(DOUBLE value) + { + return value.value; + } + + public static implicit operator DOUBLE(double value) + { + double tvalue = (double)value; + return new DOUBLE(tvalue); + } + + public static double MaxValue + { + get + { + return double.MaxValue; + } + } + + public static double MinValue + { + get + { + return double.MinValue; + } + } + } + + public struct PYTHON + { + byte[] value; + + PYTHON(byte[] value) + { + this.value = value; + } + + public static implicit operator byte[](PYTHON value) + { + return value.value; + } + + public static implicit operator PYTHON(byte[] value) + { + byte[] tvalue = (byte[])value; + return new PYTHON(tvalue); + } + + public Byte this[int ID] + { + get { return value[ID]; } + set { this.value[ID] = value; } + } + } + + public struct PY_DICT + { + byte[] value; + + PY_DICT(byte[] value) + { + this.value = value; + } + + public static implicit operator byte[](PY_DICT value) + { + return value.value; + } + + public static implicit operator PY_DICT(byte[] value) + { + byte[] tvalue = (byte[])value; + return new PY_DICT(tvalue); + } + + public Byte this[int ID] + { + get { return value[ID]; } + set { this.value[ID] = value; } + } + } + + public struct PY_TUPLE + { + byte[] value; + + PY_TUPLE(byte[] value) + { + this.value = value; + } + + public static implicit operator byte[](PY_TUPLE value) + { + return value.value; + } + + public static implicit operator PY_TUPLE(byte[] value) + { + byte[] tvalue = (byte[])value; + return new PY_TUPLE(tvalue); + } + + public Byte this[int ID] + { + get { return value[ID]; } + set { this.value[ID] = value; } + } + } + + public struct PY_LIST + { + byte[] value; + + PY_LIST(byte[] value) + { + this.value = value; + } + + public static implicit operator byte[](PY_LIST value) + { + return value.value; + } + + public static implicit operator PY_LIST(byte[] value) + { + byte[] tvalue = (byte[])value; + return new PY_LIST(tvalue); + } + + public Byte this[int ID] + { + get { return value[ID]; } + set { this.value[ID] = value; } + } + } + + public struct ENTITYCALL + { + byte[] value; + + ENTITYCALL(byte[] value) + { + this.value = value; + } + + public static implicit operator byte[](ENTITYCALL value) + { + return value.value; + } + + public static implicit operator ENTITYCALL(byte[] value) + { + byte[] tvalue = (byte[])value; + return new ENTITYCALL(tvalue); + } + + public Byte this[int ID] + { + get { return value[ID]; } + set { this.value[ID] = value; } + } + } + + public struct BLOB + { + byte[] value; + + BLOB(byte[] value) + { + this.value = value; + } + + public static implicit operator byte[](BLOB value) + { + return value.value; + } + + public static implicit operator BLOB(byte[] value) + { + byte[] tvalue = (byte[])value; + return new BLOB(tvalue); + } + + public Byte this[int ID] + { + get { return value[ID]; } + set { this.value[ID] = value; } + } + } + + public struct VECTOR2 + { + Vector2 value; + + VECTOR2(Vector2 value) + { + this.value = value; + } + + public static implicit operator Vector2(VECTOR2 value) + { + return value.value; + } + + public static implicit operator VECTOR2(Vector2 value) + { + Vector2 tvalue = (Vector2)value; + return new VECTOR2(tvalue); + } + + public float x + { + get { return value.x; } + set { this.value.x = value; } + } + + public float y + { + get { return value.y; } + set { this.value.y = value; } + } + + } + + public struct VECTOR3 + { + Vector3 value; + + VECTOR3(Vector3 value) + { + this.value = value; + } + + public static implicit operator Vector3(VECTOR3 value) + { + return value.value; + } + + public static implicit operator VECTOR3(Vector3 value) + { + Vector3 tvalue = (Vector3)value; + return new VECTOR3(tvalue); + } + + public float x + { + get { return value.x; } + set { this.value.x = value; } + } + + public float y + { + get { return value.y; } + set { this.value.y = value; } + } + + public float z + { + get { return value.z; } + set { this.value.z = value; } + } + + } + + public struct VECTOR4 + { + Vector4 value; + + VECTOR4(Vector4 value) + { + this.value = value; + } + + public static implicit operator Vector4(VECTOR4 value) + { + return value.value; + } + + public static implicit operator VECTOR4(Vector4 value) + { + Vector4 tvalue = (Vector4)value; + return new VECTOR4(tvalue); + } + + public float x + { + get { return value.x; } + set { this.value.x = value; } + } + + public float y + { + get { return value.y; } + set { this.value.y = value; } + } + + public float z + { + get { return value.z; } + set { this.value.z = value; } + } + + public float w + { + get { return value.w; } + set { this.value.w = value; } + } + } + + public struct OBJECT_ID + { + Int32 value; + + OBJECT_ID(Int32 value) + { + this.value = value; + } + + public static implicit operator Int32(OBJECT_ID value) + { + return value.value; + } + + public static implicit operator OBJECT_ID(Int32 value) + { + Int32 tvalue = (Int32)value; + return new OBJECT_ID(tvalue); + } + + public static Int32 MaxValue + { + get + { + return Int32.MaxValue; + } + } + + public static Int32 MinValue + { + get + { + return Int32.MinValue; + } + } + } + + public struct BOOL + { + Byte value; + + BOOL(Byte value) + { + this.value = value; + } + + public static implicit operator Byte(BOOL value) + { + return value.value; + } + + public static implicit operator BOOL(Byte value) + { + Byte tvalue = (Byte)value; + return new BOOL(tvalue); + } + + public static Byte MaxValue + { + get + { + return Byte.MaxValue; + } + } + + public static Byte MinValue + { + get + { + return Byte.MinValue; + } + } + } + + public struct CONTROLLER_ID + { + Int32 value; + + CONTROLLER_ID(Int32 value) + { + this.value = value; + } + + public static implicit operator Int32(CONTROLLER_ID value) + { + return value.value; + } + + public static implicit operator CONTROLLER_ID(Int32 value) + { + Int32 tvalue = (Int32)value; + return new CONTROLLER_ID(tvalue); + } + + public static Int32 MaxValue + { + get + { + return Int32.MaxValue; + } + } + + public static Int32 MinValue + { + get + { + return Int32.MinValue; + } + } + } + + public struct EXPERIENCE + { + Int32 value; + + EXPERIENCE(Int32 value) + { + this.value = value; + } + + public static implicit operator Int32(EXPERIENCE value) + { + return value.value; + } + + public static implicit operator EXPERIENCE(Int32 value) + { + Int32 tvalue = (Int32)value; + return new EXPERIENCE(tvalue); + } + + public static Int32 MaxValue + { + get + { + return Int32.MaxValue; + } + } + + public static Int32 MinValue + { + get + { + return Int32.MinValue; + } + } + } + + public struct ITEM_ID + { + Int32 value; + + ITEM_ID(Int32 value) + { + this.value = value; + } + + public static implicit operator Int32(ITEM_ID value) + { + return value.value; + } + + public static implicit operator ITEM_ID(Int32 value) + { + Int32 tvalue = (Int32)value; + return new ITEM_ID(tvalue); + } + + public static Int32 MaxValue + { + get + { + return Int32.MaxValue; + } + } + + public static Int32 MinValue + { + get + { + return Int32.MinValue; + } + } + } + + public struct SKILLID + { + Int32 value; + + SKILLID(Int32 value) + { + this.value = value; + } + + public static implicit operator Int32(SKILLID value) + { + return value.value; + } + + public static implicit operator SKILLID(Int32 value) + { + Int32 tvalue = (Int32)value; + return new SKILLID(tvalue); + } + + public static Int32 MaxValue + { + get + { + return Int32.MaxValue; + } + } + + public static Int32 MinValue + { + get + { + return Int32.MinValue; + } + } + } + + public struct QUESTID + { + Int32 value; + + QUESTID(Int32 value) + { + this.value = value; + } + + public static implicit operator Int32(QUESTID value) + { + return value.value; + } + + public static implicit operator QUESTID(Int32 value) + { + Int32 tvalue = (Int32)value; + return new QUESTID(tvalue); + } + + public static Int32 MaxValue + { + get + { + return Int32.MaxValue; + } + } + + public static Int32 MinValue + { + get + { + return Int32.MinValue; + } + } + } + + public struct DBID + { + UInt64 value; + + DBID(UInt64 value) + { + this.value = value; + } + + public static implicit operator UInt64(DBID value) + { + return value.value; + } + + public static implicit operator DBID(UInt64 value) + { + UInt64 tvalue = (UInt64)value; + return new DBID(tvalue); + } + + public static UInt64 MaxValue + { + get + { + return UInt64.MaxValue; + } + } + + public static UInt64 MinValue + { + get + { + return UInt64.MinValue; + } + } + } + + public struct UID + { + UInt64 value; + + UID(UInt64 value) + { + this.value = value; + } + + public static implicit operator UInt64(UID value) + { + return value.value; + } + + public static implicit operator UID(UInt64 value) + { + UInt64 tvalue = (UInt64)value; + return new UID(tvalue); + } + + public static UInt64 MaxValue + { + get + { + return UInt64.MaxValue; + } + } + + public static UInt64 MinValue + { + get + { + return UInt64.MinValue; + } + } + } + + public struct UID1 + { + byte[] value; + + UID1(byte[] value) + { + this.value = value; + } + + public static implicit operator byte[](UID1 value) + { + return value.value; + } + + public static implicit operator UID1(byte[] value) + { + byte[] tvalue = (byte[])value; + return new UID1(tvalue); + } + + public Byte this[int ID] + { + get { return value[ID]; } + set { this.value[ID] = value; } + } + } + + public struct ENTITY_ID + { + Int32 value; + + ENTITY_ID(Int32 value) + { + this.value = value; + } + + public static implicit operator Int32(ENTITY_ID value) + { + return value.value; + } + + public static implicit operator ENTITY_ID(Int32 value) + { + Int32 tvalue = (Int32)value; + return new ENTITY_ID(tvalue); + } + + public static Int32 MaxValue + { + get + { + return Int32.MaxValue; + } + } + + public static Int32 MinValue + { + get + { + return Int32.MinValue; + } + } + } + + public struct ENTITY_NO + { + UInt32 value; + + ENTITY_NO(UInt32 value) + { + this.value = value; + } + + public static implicit operator UInt32(ENTITY_NO value) + { + return value.value; + } + + public static implicit operator ENTITY_NO(UInt32 value) + { + UInt32 tvalue = (UInt32)value; + return new ENTITY_NO(tvalue); + } + + public static UInt32 MaxValue + { + get + { + return UInt32.MaxValue; + } + } + + public static UInt32 MinValue + { + get + { + return UInt32.MinValue; + } + } + } + + public struct SPACE_ID + { + UInt32 value; + + SPACE_ID(UInt32 value) + { + this.value = value; + } + + public static implicit operator UInt32(SPACE_ID value) + { + return value.value; + } + + public static implicit operator SPACE_ID(UInt32 value) + { + UInt32 tvalue = (UInt32)value; + return new SPACE_ID(tvalue); + } + + public static UInt32 MaxValue + { + get + { + return UInt32.MaxValue; + } + } + + public static UInt32 MinValue + { + get + { + return UInt32.MinValue; + } + } + } + + public struct POSITION3D + { + Vector3 value; + + POSITION3D(Vector3 value) + { + this.value = value; + } + + public static implicit operator Vector3(POSITION3D value) + { + return value.value; + } + + public static implicit operator POSITION3D(Vector3 value) + { + Vector3 tvalue = (Vector3)value; + return new POSITION3D(tvalue); + } + + public float x + { + get { return value.x; } + set { this.value.x = value; } + } + + public float y + { + get { return value.y; } + set { this.value.y = value; } + } + + public float z + { + get { return value.z; } + set { this.value.z = value; } + } + + } + + public struct DIRECTION3D + { + Vector3 value; + + DIRECTION3D(Vector3 value) + { + this.value = value; + } + + public static implicit operator Vector3(DIRECTION3D value) + { + return value.value; + } + + public static implicit operator DIRECTION3D(Vector3 value) + { + Vector3 tvalue = (Vector3)value; + return new DIRECTION3D(tvalue); + } + + public float x + { + get { return value.x; } + set { this.value.x = value; } + } + + public float y + { + get { return value.y; } + set { this.value.y = value; } + } + + public float z + { + get { return value.z; } + set { this.value.z = value; } + } + + } + + public struct ENTITY_UTYPE + { + UInt32 value; + + ENTITY_UTYPE(UInt32 value) + { + this.value = value; + } + + public static implicit operator UInt32(ENTITY_UTYPE value) + { + return value.value; + } + + public static implicit operator ENTITY_UTYPE(UInt32 value) + { + UInt32 tvalue = (UInt32)value; + return new ENTITY_UTYPE(tvalue); + } + + public static UInt32 MaxValue + { + get + { + return UInt32.MaxValue; + } + } + + public static UInt32 MinValue + { + get + { + return UInt32.MinValue; + } + } + } + + public struct DAMAGE_TYPE + { + Int32 value; + + DAMAGE_TYPE(Int32 value) + { + this.value = value; + } + + public static implicit operator Int32(DAMAGE_TYPE value) + { + return value.value; + } + + public static implicit operator DAMAGE_TYPE(Int32 value) + { + Int32 tvalue = (Int32)value; + return new DAMAGE_TYPE(tvalue); + } + + public static Int32 MaxValue + { + get + { + return Int32.MaxValue; + } + } + + public static Int32 MinValue + { + get + { + return Int32.MinValue; + } + } + } + + public struct ENMITY + { + Int32 value; + + ENMITY(Int32 value) + { + this.value = value; + } + + public static implicit operator Int32(ENMITY value) + { + return value.value; + } + + public static implicit operator ENMITY(Int32 value) + { + Int32 tvalue = (Int32)value; + return new ENMITY(tvalue); + } + + public static Int32 MaxValue + { + get + { + return Int32.MaxValue; + } + } + + public static Int32 MinValue + { + get + { + return Int32.MinValue; + } + } + } + + public struct HP + { + Int32 value; + + HP(Int32 value) + { + this.value = value; + } + + public static implicit operator Int32(HP value) + { + return value.value; + } + + public static implicit operator HP(Int32 value) + { + Int32 tvalue = (Int32)value; + return new HP(tvalue); + } + + public static Int32 MaxValue + { + get + { + return Int32.MaxValue; + } + } + + public static Int32 MinValue + { + get + { + return Int32.MinValue; + } + } + } + + public struct MP + { + Int32 value; + + MP(Int32 value) + { + this.value = value; + } + + public static implicit operator Int32(MP value) + { + return value.value; + } + + public static implicit operator MP(Int32 value) + { + Int32 tvalue = (Int32)value; + return new MP(tvalue); + } + + public static Int32 MaxValue + { + get + { + return Int32.MaxValue; + } + } + + public static Int32 MinValue + { + get + { + return Int32.MinValue; + } + } + } + + public struct ENTITY_STATE + { + SByte value; + + ENTITY_STATE(SByte value) + { + this.value = value; + } + + public static implicit operator SByte(ENTITY_STATE value) + { + return value.value; + } + + public static implicit operator ENTITY_STATE(SByte value) + { + SByte tvalue = (SByte)value; + return new ENTITY_STATE(tvalue); + } + + public static SByte MaxValue + { + get + { + return SByte.MaxValue; + } + } + + public static SByte MinValue + { + get + { + return SByte.MinValue; + } + } + } + + public struct ENTITY_SUBSTATE + { + Byte value; + + ENTITY_SUBSTATE(Byte value) + { + this.value = value; + } + + public static implicit operator Byte(ENTITY_SUBSTATE value) + { + return value.value; + } + + public static implicit operator ENTITY_SUBSTATE(Byte value) + { + Byte tvalue = (Byte)value; + return new ENTITY_SUBSTATE(tvalue); + } + + public static Byte MaxValue + { + get + { + return Byte.MaxValue; + } + } + + public static Byte MinValue + { + get + { + return Byte.MinValue; + } + } + } + + public struct ENTITY_FORBIDS + { + Int32 value; + + ENTITY_FORBIDS(Int32 value) + { + this.value = value; + } + + public static implicit operator Int32(ENTITY_FORBIDS value) + { + return value.value; + } + + public static implicit operator ENTITY_FORBIDS(Int32 value) + { + Int32 tvalue = (Int32)value; + return new ENTITY_FORBIDS(tvalue); + } + + public static Int32 MaxValue + { + get + { + return Int32.MaxValue; + } + } + + public static Int32 MinValue + { + get + { + return Int32.MinValue; + } + } + } + + public class ENTITY_FORBID_COUNTER : List + { + + } + + public class ENTITYID_LIST : List + { + + } + + public class AVATAR_DATA + { + public SByte param1 = 0; + public byte[] param2 = new byte[0]; + + } + + public class AVATAR_INFOS + { + public UInt64 dbid = 0; + public string name = ""; + public Byte roleType = 0; + public UInt16 level = 0; + public AVATAR_DATA data = new AVATAR_DATA(); + + } + + public class AVATAR_INFOS_LIST + { + public List values = new List(); + + } + + public class BAG + { + public List> values22 = new List>(); + + } + + public class EXAMPLES + { + public Int64 k1 = 0; + public Int64 k2 = 0; + + } + + } \ No newline at end of file diff --git a/Assets/Plugins/kbengine_unity3d_plugins/KBEngine.cs b/Assets/Plugins/kbengine_unity3d_plugins/KBEngine.cs index ceba475..b113cef 100644 --- a/Assets/Plugins/kbengine_unity3d_plugins/KBEngine.cs +++ b/Assets/Plugins/kbengine_unity3d_plugins/KBEngine.cs @@ -1,2457 +1,2457 @@ -namespace KBEngine -{ - using UnityEngine; - using System; - using System.Collections; - using System.Collections.Generic; - using System.Text; - using System.Threading; - using System.Text.RegularExpressions; - - using MessageID = System.UInt16; - using MessageLength = System.UInt16; - - /* - 这是KBEngine插件的核心模块 - 包括网络创建、持久化协议、entities的管理、以及引起对外可调用接口。 - - 一些可以参考的地方: - http://www.kbengine.org/docs/programming/clientsdkprogramming.html - http://www.kbengine.org/docs/programming/kbe_message_format.html - - http://www.kbengine.org/cn/docs/programming/clientsdkprogramming.html - http://www.kbengine.org/cn/docs/programming/kbe_message_format.html - */ - public class KBEngineApp - { - public static KBEngineApp app = null; - private NetworkInterfaceBase _networkInterface = null; - - KBEngineArgs _args = null; - - // 客户端的类别 - // http://www.kbengine.org/docs/programming/clientsdkprogramming.html - // http://www.kbengine.org/cn/docs/programming/clientsdkprogramming.html - public enum CLIENT_TYPE - { - // Mobile(Phone, Pad) - CLIENT_TYPE_MOBILE = 1, - - // Windows Application program - CLIENT_TYPE_WIN = 2, - - // Linux Application program - CLIENT_TYPE_LINUX = 3, - - // Mac Application program - CLIENT_TYPE_MAC = 4, - - // Web,HTML5,Flash - CLIENT_TYPE_BROWSER = 5, - - // bots - CLIENT_TYPE_BOTS = 6, - - // Mini-Client - CLIENT_TYPE_MINI = 7, - }; - - //加密通信类型 - public enum NETWORK_ENCRYPT_TYPE - { - //无加密 - ENCRYPT_TYPE_NONE = 0, - - //Blowfish - ENCRYPT_TYPE_BLOWFISH = 1, - }; - - public string username = "kbengine"; - public string password = "123456"; - - // 服务端分配的baseapp地址 - public string baseappIP = ""; - public UInt16 baseappTcpPort = 0; - public UInt16 baseappUdpPort = 0; - - // 当前状态 - public string currserver = ""; - public string currstate = ""; - - // 服务端下行以及客户端上行用于登录时处理的账号绑定的二进制信息 - // 该信息由用户自己进行扩展 - private byte[] _serverdatas = new byte[0]; - private byte[] _clientdatas = new byte[0]; - - // 通信协议加密,blowfish协议 - private byte[] _encryptedKey = new byte[0]; - - // 服务端与客户端的版本号以及协议MD5 - public string serverVersion = ""; - public string clientVersion = "2.4.4"; - public string serverScriptVersion = ""; - public string clientScriptVersion = "0.1.0"; - public string serverProtocolMD5 = "F42554D167E152C876AC6EDC361151C2"; - public string serverEntitydefMD5 = "90AA620FCF194B85FBE7A8E4F4F8F938"; - - // 当前玩家的实体id与实体类别 - public UInt64 entity_uuid = 0; - public Int32 entity_id = 0; - public string entity_type = ""; - - private List _controlledEntities = new List(); - - // 当前服务端最后一次同步过来的玩家位置 - private Vector3 _entityServerPos = new Vector3(0f, 0f, 0f); - - // space的数据,具体看API手册关于spaceData - // https://github.com/kbengine/kbengine/tree/master/docs/api - private Dictionary _spacedatas = new Dictionary(); - - // 所有实体都保存于这里, 请参看API手册关于entities部分 - // https://github.com/kbengine/kbengine/tree/master/docs/api - public Dictionary entities = new Dictionary(); - - // 在玩家View范围小于256个实体时我们可以通过一字节索引来找到entity - private List _entityIDAliasIDList = new List(); - private Dictionary _bufferedCreateEntityMessages = new Dictionary(); - - // 所有服务端错误码对应的错误描述 - private ServerErrorDescrs _serverErrs = new ServerErrorDescrs(); - - private System.DateTime _lastTickTime = System.DateTime.Now; - private System.DateTime _lastTickCBTime = System.DateTime.Now; - private System.DateTime _lastUpdateToServerTime = System.DateTime.Now; - - //上传玩家信息到服务器间隔,单位毫秒 - private float _updatePlayerToServerPeroid = 100.0f; - private const int _1MS_TO_100NS = 10000; - - //加密过滤器 - private EncryptionFilter _filter = null; - - // 玩家当前所在空间的id, 以及空间对应的资源 - public UInt32 spaceID = 0; - public string spaceResPath = ""; - public bool isLoadedGeometry = false; - - // 按照标准,每个客户端部分都应该包含这个属性 - public const string component = "client"; - - public KBEngineApp(KBEngineArgs args) - { - if (app != null) - throw new Exception("Only one instance of KBEngineApp!"); - - app = this; - Event.outEventsImmediately = !args.isMultiThreads; - - initialize(args); - } - - public static KBEngineApp getSingleton() - { - if(KBEngineApp.app == null) - { - throw new Exception("Please create KBEngineApp!"); - } - - return KBEngineApp.app; - } - - public virtual bool initialize(KBEngineArgs args) - { - _args = args; - _updatePlayerToServerPeroid = (float)_args.syncPlayerMS; - - EntityDef.init(); - - initNetwork(); - - // 注册事件 - installEvents(); - - return true; - } - - void initNetwork() - { - _filter = null; - Messages.init(); - _networkInterface = new NetworkInterfaceTCP(); - } - - void installEvents() - { - Event.registerIn(EventInTypes.createAccount, this, "createAccount"); - Event.registerIn(EventInTypes.login, this, "login"); - Event.registerIn(EventInTypes.logout, this, "logout"); - Event.registerIn(EventInTypes.reloginBaseapp, this, "reloginBaseapp"); - Event.registerIn(EventInTypes.resetPassword, this, "resetPassword"); - Event.registerIn(EventInTypes.bindAccountEmail, this, "bindAccountEmail"); - Event.registerIn(EventInTypes.newPassword, this, "newPassword"); - - // 内部事件 - Event.registerIn("_closeNetwork", this, "_closeNetwork"); - } - - public KBEngineArgs getInitArgs() - { - return _args; - } - - public virtual void destroy() - { - Dbg.WARNING_MSG("KBEngine::destroy()"); - - if(currserver == "baseapp") - logout(); - - reset(); - KBEngine.Event.deregisterIn(this); - resetMessages(); - - KBEngineApp.app = null; - } - - public NetworkInterfaceBase networkInterface() - { - return _networkInterface; - } - - public byte[] serverdatas() - { - return _serverdatas; - } - - public void entityServerPos(Vector3 pos) - { - _entityServerPos = pos; - } - - public void resetMessages() - { - _serverErrs.Clear(); - Messages.clear(); - EntityDef.reset(); - - Entity.clear(); - Dbg.DEBUG_MSG("KBEngine::resetMessages()"); - } - - public virtual void reset() - { - KBEngine.Event.clearFiredEvents(); - - clearEntities(true); - - currserver = ""; - currstate = ""; - _serverdatas = new byte[0]; - serverVersion = ""; - serverScriptVersion = ""; - - entity_uuid = 0; - entity_id = 0; - entity_type = ""; - - _entityIDAliasIDList.Clear(); - _bufferedCreateEntityMessages.Clear(); - - _lastTickTime = System.DateTime.Now; - _lastTickCBTime = System.DateTime.Now; - _lastUpdateToServerTime = System.DateTime.Now; - - spaceID = 0; - spaceResPath = ""; - isLoadedGeometry = false; - - if (_networkInterface != null) - _networkInterface.reset(); - - _filter = null; - _networkInterface = new NetworkInterfaceTCP(); - - _spacedatas.Clear(); - } - - public static bool validEmail(string strEmail) - { - return Regex.IsMatch(strEmail, @"^([\w-\.]+)@((\[[0-9]{1,3}\.[0-9]{1,3}\.[0-9]{1,3}\.) - |(([\w-]+\.)+))([a-zA-Z]{2,4}|[0-9]{1,3})(\]?)$"); - } - - /* - 插件的主循环处理函数 - */ - public virtual void process() - { - // 处理网络 - if (_networkInterface != null) - _networkInterface.process(); - - // 处理外层抛入的事件 - Event.processInEvents(); - - // 向服务端发送心跳以及同步角色信息到服务端 - sendTick(); - } - - /* - 当前玩家entity - */ - public Entity player() - { - Entity e; - if(entities.TryGetValue(entity_id, out e)) - return e; - - return null; - } - - public void _closeNetwork(NetworkInterfaceBase networkInterface) - { - networkInterface.close(); - } - - /* - 向服务端发送心跳以及同步角色信息到服务端 - */ - public void sendTick() - { - if(_networkInterface == null || _networkInterface.connected == false) - return; - - TimeSpan span = DateTime.Now - _lastTickTime; - - // 更新玩家的位置与朝向到服务端 - updatePlayerToServer(); - - if(_args.serverHeartbeatTick > 0 && span.Seconds > _args.serverHeartbeatTick) - { - span = _lastTickCBTime - _lastTickTime; - - // 如果心跳回调接收时间小于心跳发送时间,说明没有收到回调 - // 此时应该通知客户端掉线了 - if(span.Seconds < 0) - { - Dbg.ERROR_MSG("sendTick: Receive appTick timeout!"); - _networkInterface.close(); - return; - } - - Message Loginapp_onClientActiveTickMsg = null; - Message Baseapp_onClientActiveTickMsg = null; - - Messages.messages.TryGetValue("Loginapp_onClientActiveTick", out Loginapp_onClientActiveTickMsg); - Messages.messages.TryGetValue("Baseapp_onClientActiveTick", out Baseapp_onClientActiveTickMsg); - - if(currserver == "loginapp") - { - if(Loginapp_onClientActiveTickMsg != null) - { - Bundle bundle = Bundle.createObject(); - bundle.newMessage(Messages.messages["Loginapp_onClientActiveTick"]); - bundle.send(_networkInterface); - } - } - else - { - if(Baseapp_onClientActiveTickMsg != null) - { - Bundle bundle = Bundle.createObject(); - bundle.newMessage(Messages.messages["Baseapp_onClientActiveTick"]); - bundle.send(_networkInterface); - } - } - - _lastTickTime = System.DateTime.Now; - } - } - - /* - 服务器心跳回调 - */ - public void Client_onAppActiveTickCB() - { - _lastTickCBTime = System.DateTime.Now; - } - - /* - 与服务端握手,与任何一个进程连接之后应该第一时间进行握手 - */ - public void hello() - { - Bundle bundle = Bundle.createObject(); - if(currserver == "loginapp") - bundle.newMessage(Messages.messages["Loginapp_hello"]); - else - bundle.newMessage(Messages.messages["Baseapp_hello"]); - - _filter = null; - - if (_args.networkEncryptType == NETWORK_ENCRYPT_TYPE.ENCRYPT_TYPE_BLOWFISH) - { - _filter = new BlowfishFilter(); - _encryptedKey = ((BlowfishFilter)_filter).key(); - _networkInterface.setFilter(null); - } - - bundle.writeString(clientVersion); - bundle.writeString(clientScriptVersion); - bundle.writeBlob(_encryptedKey); - bundle.send(_networkInterface); - } - - /* - 握手之后服务端的回调 - */ - public void Client_onHelloCB(MemoryStream stream) - { - string str_serverVersion = stream.readString(); - serverScriptVersion = stream.readString(); - string currentServerProtocolMD5 = stream.readString(); - string currentServerEntitydefMD5 = stream.readString(); - Int32 ctype = stream.readInt32(); - - Dbg.DEBUG_MSG("KBEngine::Client_onHelloCB: verInfo(" + str_serverVersion - + "), scriptVersion("+ serverScriptVersion + "), srvProtocolMD5("+ serverProtocolMD5 - + "), srvEntitydefMD5("+ serverEntitydefMD5 + "), + ctype(" + ctype + ")!"); - - if(str_serverVersion != "Getting") - { - serverVersion = str_serverVersion; - - /* - if(serverProtocolMD5 != currentServerProtocolMD5) - { - Dbg.ERROR_MSG("Client_onHelloCB: digest not match! serverProtocolMD5=" + serverProtocolMD5 + "(server: " + currentServerProtocolMD5 + ")"); - Event.fireAll(EventOutTypes.onVersionNotMatch, clientVersion, serverVersion); - return; - } - */ - - if (serverEntitydefMD5 != currentServerEntitydefMD5) - { - Dbg.ERROR_MSG("Client_onHelloCB: digest not match! serverEntitydefMD5=" + serverEntitydefMD5 + "(server: " + currentServerEntitydefMD5 + ")"); - Event.fireAll(EventOutTypes.onVersionNotMatch, clientVersion, serverVersion); - return; - } - } - - if (_args.networkEncryptType == NETWORK_ENCRYPT_TYPE.ENCRYPT_TYPE_BLOWFISH) - { - _networkInterface.setFilter(_filter); - _filter = null; - } - - onServerDigest(); - - if(currserver == "baseapp") - { - onLogin_baseapp(); - } - else - { - onLogin_loginapp(); - } - } - - /* - 服务端错误描述导入了 - */ - public void Client_onImportServerErrorsDescr(MemoryStream stream) - { - // 无需实现,已由插件生成静态代码 - } - - /* - 从服务端返回的二进制流导入客户端消息协议 - */ - public void Client_onImportClientMessages(MemoryStream stream) - { - // 无需实现,已由插件生成静态代码 - } - - /* - 从服务端返回的二进制流导入客户端消息协议 - */ - public void Client_onImportClientEntityDef(MemoryStream stream) - { - // 无需实现,已由插件生成静态代码 - } - - public void Client_onImportClientSDK(MemoryStream stream) - { - int remainingFiles = 0; - remainingFiles = stream.readInt32(); - - string fileName; - fileName = stream.readString(); - - int fileSize = 0; - fileSize = stream.readInt32(); - - byte[] fileDatas = new byte[0]; - fileDatas = stream.readBlob(); - - Event.fireIn("onImportClientSDK", remainingFiles, fileName, fileSize, fileDatas); - } - - /* - 引擎版本不匹配 - */ - public void Client_onVersionNotMatch(MemoryStream stream) - { - serverVersion = stream.readString(); - - Dbg.ERROR_MSG("Client_onVersionNotMatch: verInfo=" + clientVersion + "(server: " + serverVersion + ")"); - Event.fireAll(EventOutTypes.onVersionNotMatch, clientVersion, serverVersion); - } - - /* - 脚本版本不匹配 - */ - public void Client_onScriptVersionNotMatch(MemoryStream stream) - { - serverScriptVersion = stream.readString(); - - Dbg.ERROR_MSG("Client_onScriptVersionNotMatch: verInfo=" + clientScriptVersion + "(server: " + serverScriptVersion + ")"); - Event.fireAll(EventOutTypes.onScriptVersionNotMatch, clientScriptVersion, serverScriptVersion); - } - - /* - 被服务端踢出 - */ - public void Client_onKicked(UInt16 failedcode) - { - Dbg.DEBUG_MSG("Client_onKicked: failedcode=" + failedcode + "(" + serverErr(failedcode) + ")"); - Event.fireAll(EventOutTypes.onKicked, failedcode); - } - - /* - 登录到服务端,必须登录完成loginapp与网关(baseapp),登录流程才算完毕 - */ - public void login(string username, string password, byte[] datas) - { - KBEngineApp.app.username = username; - KBEngineApp.app.password = password; - KBEngineApp.app._clientdatas = datas; - - KBEngineApp.app.login_loginapp(true); - } - - /* - 登录到服务端(loginapp), 登录成功后还必须登录到网关(baseapp)登录流程才算完毕 - */ - public void login_loginapp(bool noconnect) - { - if(noconnect) - { - reset(); - _networkInterface.connectTo(_args.ip, _args.port, onConnectTo_loginapp_callback, null); - } - else - { - Dbg.DEBUG_MSG("KBEngine::login_loginapp(): send login! username=" + username); - Bundle bundle = Bundle.createObject(); - bundle.newMessage(Messages.messages["Loginapp_login"]); - bundle.writeInt8((sbyte)_args.clientType); - bundle.writeBlob(KBEngineApp.app._clientdatas); - bundle.writeString(username); - bundle.writeString(password); - bundle.send(_networkInterface); - } - } - - private void onConnectTo_loginapp_callback(string ip, int port, bool success, object userData) - { - _lastTickCBTime = System.DateTime.Now; - - if(!success) - { - Dbg.ERROR_MSG(string.Format("KBEngine::login_loginapp(): connect {0}:{1} error!", ip, port)); - return; - } - - currserver = "loginapp"; - currstate = "login"; - - Dbg.DEBUG_MSG(string.Format("KBEngine::login_loginapp(): connect {0}:{1} success!", ip, port)); - - hello(); - } - - private void onLogin_loginapp() - { - _lastTickCBTime = System.DateTime.Now; - login_loginapp(false); - } - - /* - 登录到服务端,登录到网关(baseapp) - */ - public void login_baseapp(bool noconnect) - { - if(noconnect) - { - Event.fireOut(EventOutTypes.onLoginBaseapp); - - _networkInterface.reset(); - - if(_args.forceDisableUDP || baseappUdpPort == 0) - { - _networkInterface = new NetworkInterfaceTCP(); - _networkInterface.connectTo(baseappIP, baseappTcpPort, onConnectTo_baseapp_callback, null); - } - else - { - _networkInterface = new NetworkInterfaceKCP(); - _networkInterface.connectTo(baseappIP, baseappUdpPort, onConnectTo_baseapp_callback, null); - } - } - else - { - Bundle bundle = Bundle.createObject(); - bundle.newMessage(Messages.messages["Baseapp_loginBaseapp"]); - bundle.writeString(username); - bundle.writeString(password); - bundle.send(_networkInterface); - } - } - - private void onConnectTo_baseapp_callback(string ip, int port, bool success, object userData) - { - _lastTickCBTime = System.DateTime.Now; - - if(!success) - { - Dbg.ERROR_MSG(string.Format("KBEngine::login_baseapp(): connect {0}:{1} error!", ip, port)); - return; - } - - currserver = "baseapp"; - currstate = ""; - - Dbg.DEBUG_MSG(string.Format("KBEngine::login_baseapp(): connect {0}:{1} success!", ip, port)); - - hello(); - } - - private void onLogin_baseapp() - { - _lastTickCBTime = System.DateTime.Now; - login_baseapp(false); - } - - /* - 重登录到网关(baseapp) - 一些移动类应用容易掉线,可以使用该功能快速的重新与服务端建立通信 - */ - public void reloginBaseapp() - { - _lastTickTime = System.DateTime.Now; - _lastTickCBTime = System.DateTime.Now; - - if(_networkInterface.valid()) - return; - - Event.fireAll(EventOutTypes.onReloginBaseapp); - - _networkInterface.reset(); - - if(_args.forceDisableUDP || baseappUdpPort == 0) - { - _networkInterface = new NetworkInterfaceTCP(); - _networkInterface.connectTo(baseappIP, baseappTcpPort, onReConnectTo_baseapp_callback, null); - } - else - { - _networkInterface = new NetworkInterfaceKCP(); - _networkInterface.connectTo(baseappIP, baseappUdpPort, onReConnectTo_baseapp_callback, null); - } - } - - private void onReConnectTo_baseapp_callback(string ip, int port, bool success, object userData) - { - if(!success) - { - Dbg.ERROR_MSG(string.Format("KBEngine::reloginBaseapp(): connect {0}:{1} error!", ip, port)); - return; - } - - Dbg.DEBUG_MSG(string.Format("KBEngine::relogin_baseapp(): connect {0}:{1} success!", ip, port)); - - Bundle bundle = Bundle.createObject(); - bundle.newMessage(Messages.messages["Baseapp_reloginBaseapp"]); - bundle.writeString(username); - bundle.writeString(password); - bundle.writeUint64(entity_uuid); - bundle.writeInt32(entity_id); - bundle.send(_networkInterface); - - _lastTickCBTime = System.DateTime.Now; - } - - /* - 登出baseapp - */ - public void logout() - { - Bundle bundle = Bundle.createObject(); - bundle.newMessage(Messages.messages["Baseapp_logoutBaseapp"]); - bundle.writeUint64(entity_uuid); - bundle.writeInt32(entity_id); - bundle.send(_networkInterface); - } - - /* - 通过错误id得到错误描述 - */ - public string serverErr(UInt16 id) - { - return _serverErrs.serverErrStr(id); - } - - public void onOpenLoginapp_resetpassword() - { - Dbg.DEBUG_MSG("KBEngine::onOpenLoginapp_resetpassword: successfully!"); - currserver = "loginapp"; - currstate = "resetpassword"; - _lastTickCBTime = System.DateTime.Now; - - resetpassword_loginapp(false); - } - - /* - 重置密码, 通过loginapp - */ - public void resetPassword(string username) - { - KBEngineApp.app.username = username; - resetpassword_loginapp(true); - } - - /* - 重置密码, 通过loginapp - */ - public void resetpassword_loginapp(bool noconnect) - { - if(noconnect) - { - reset(); - _networkInterface.connectTo(_args.ip, _args.port, onConnectTo_resetpassword_callback, null); - } - else - { - Bundle bundle = Bundle.createObject(); - bundle.newMessage(Messages.messages["Loginapp_reqAccountResetPassword"]); - bundle.writeString(username); - bundle.send(_networkInterface); - } - } - - private void onConnectTo_resetpassword_callback(string ip, int port, bool success, object userData) - { - _lastTickCBTime = System.DateTime.Now; - - if(!success) - { - Dbg.ERROR_MSG(string.Format("KBEngine::resetpassword_loginapp(): connect {0}:{1} error!", ip, port)); - return; - } - - Dbg.DEBUG_MSG(string.Format("KBEngine::resetpassword_loginapp(): connect {0}:{1} success!", ip, port)); - onOpenLoginapp_resetpassword(); - } - - public void Client_onReqAccountResetPasswordCB(UInt16 failcode) - { - if(failcode != 0) - { - Dbg.ERROR_MSG("KBEngine::Client_onReqAccountResetPasswordCB: " + username + " failed! code=" + failcode + "(" + serverErr(failcode) + ")!"); - return; - } - - Dbg.DEBUG_MSG("KBEngine::Client_onReqAccountResetPasswordCB: " + username + " success!"); - } - - /* - 绑定Email,通过baseapp - */ - public void bindAccountEmail(string emailAddress) - { - Bundle bundle = Bundle.createObject(); - bundle.newMessage(Messages.messages["Baseapp_reqAccountBindEmail"]); - bundle.writeInt32(entity_id); - bundle.writeString(password); - bundle.writeString(emailAddress); - bundle.send(_networkInterface); - } - - public void Client_onReqAccountBindEmailCB(UInt16 failcode) - { - if(failcode != 0) - { - Dbg.ERROR_MSG("KBEngine::Client_onReqAccountBindEmailCB: " + username + " failed! code=" + failcode + "(" + serverErr(failcode) + ")!"); - return; - } - - Dbg.DEBUG_MSG("KBEngine::Client_onReqAccountBindEmailCB: " + username + " success!"); - } - - /* - 设置新密码,通过baseapp, 必须玩家登录在线操作所以是baseapp。 - */ - public void newPassword(string old_password, string new_password) - { - Bundle bundle = Bundle.createObject(); - bundle.newMessage(Messages.messages["Baseapp_reqAccountNewPassword"]); - bundle.writeInt32(entity_id); - bundle.writeString(old_password); - bundle.writeString(new_password); - bundle.send(_networkInterface); - } - - public void Client_onReqAccountNewPasswordCB(UInt16 failcode) - { - if(failcode != 0) - { - Dbg.ERROR_MSG("KBEngine::Client_onReqAccountNewPasswordCB: " + username + " failed! code=" + failcode + "(" + serverErr(failcode) + ")!"); - return; - } - - Dbg.DEBUG_MSG("KBEngine::Client_onReqAccountNewPasswordCB: " + username + " success!"); - } - - public void createAccount(string username, string password, byte[] datas) - { - KBEngineApp.app.username = username; - KBEngineApp.app.password = password; - KBEngineApp.app._clientdatas = datas; - - KBEngineApp.app.createAccount_loginapp(true); - } - - /* - 创建账号,通过loginapp - */ - public void createAccount_loginapp(bool noconnect) - { - if(noconnect) - { - reset(); - _networkInterface.connectTo(_args.ip, _args.port, onConnectTo_createAccount_callback, null); - } - else - { - Bundle bundle = Bundle.createObject(); - bundle.newMessage(Messages.messages["Loginapp_reqCreateAccount"]); - bundle.writeString(username); - bundle.writeString(password); - bundle.writeBlob(KBEngineApp.app._clientdatas); - bundle.send(_networkInterface); - } - } - - public void onOpenLoginapp_createAccount() - { - Dbg.DEBUG_MSG("KBEngine::onOpenLoginapp_createAccount: successfully!"); - currserver = "loginapp"; - currstate = "createAccount"; - _lastTickCBTime = System.DateTime.Now; - - createAccount_loginapp(false); - } - - private void onConnectTo_createAccount_callback(string ip, int port, bool success, object userData) - { - _lastTickCBTime = System.DateTime.Now; - - if(!success) - { - Dbg.ERROR_MSG(string.Format("KBEngine::createAccount_loginapp(): connect {0}:{1} error!", ip, port)); - return; - } - - Dbg.DEBUG_MSG(string.Format("KBEngine::createAccount_loginapp(): connect {0}:{1} success!", ip, port)); - onOpenLoginapp_createAccount(); - } - - /* - 获得了服务端摘要信息, 摘要包括协议MD5, entitydefMD5 - */ - public void onServerDigest() - { - } - - /* - 登录loginapp失败了 - */ - public void Client_onLoginFailed(MemoryStream stream) - { - UInt16 failedcode = stream.readUint16(); - _serverdatas = stream.readBlob(); - Dbg.ERROR_MSG("KBEngine::Client_onLoginFailed: failedcode(" + failedcode + ":" + serverErr(failedcode) + "), datas(" + _serverdatas.Length + ")!"); - Event.fireAll(EventOutTypes.onLoginFailed, failedcode); - } - - /* - 登录loginapp成功了 - */ - public void Client_onLoginSuccessfully(MemoryStream stream) - { - var accountName = stream.readString(); - username = accountName; - baseappIP = stream.readString(); - baseappTcpPort = stream.readUint16(); - baseappUdpPort = stream.readUint16(); - _serverdatas = stream.readBlob(); - - Dbg.DEBUG_MSG("KBEngine::Client_onLoginSuccessfully: accountName(" + accountName + "), addr(" + - baseappIP + ":" + baseappTcpPort + "|" + baseappUdpPort + "), datas(" + _serverdatas.Length + ")!"); - - login_baseapp(true); - } - - /* - 登录baseapp失败了 - */ - public void Client_onLoginBaseappFailed(UInt16 failedcode) - { - Dbg.ERROR_MSG("KBEngine::Client_onLoginBaseappFailed: failedcode=" + failedcode + "("+ serverErr(failedcode) + ")!"); - Event.fireAll(EventOutTypes.onLoginBaseappFailed, failedcode); - } - - /* - 重登录baseapp失败了 - */ - public void Client_onReloginBaseappFailed(UInt16 failedcode) - { - Dbg.ERROR_MSG("KBEngine::Client_onReloginBaseappFailed: failedcode=" + failedcode + "(" + serverErr(failedcode) + ")!"); - Event.fireAll(EventOutTypes.onReloginBaseappFailed, failedcode); - } - - /* - 登录baseapp成功了 - */ - public void Client_onReloginBaseappSuccessfully(MemoryStream stream) - { - entity_uuid = stream.readUint64(); - Dbg.DEBUG_MSG("KBEngine::Client_onReloginBaseappSuccessfully: name(" + username + ")!"); - Event.fireAll(EventOutTypes.onReloginBaseappSuccessfully); - } - - /* - 服务端通知创建一个角色 - */ - public void Client_onCreatedProxies(UInt64 rndUUID, Int32 eid, string entityType) - { - Dbg.DEBUG_MSG("KBEngine::Client_onCreatedProxies: eid(" + eid + "), entityType(" + entityType + ")!"); - - entity_uuid = rndUUID; - entity_id = eid; - entity_type = entityType; - - if(!this.entities.ContainsKey(eid)) - { - ScriptModule module = null; - if(!EntityDef.moduledefs.TryGetValue(entityType, out module)) - { - Dbg.ERROR_MSG("KBEngine::Client_onCreatedProxies: not found module(" + entityType + ")!"); - return; - } - - Type runclass = module.entityScript; - if(runclass == null) - return; - - Entity entity = (Entity)Activator.CreateInstance(runclass); - entity.id = eid; - entity.className = entityType; - entity.onGetBase(); - - entities[eid] = entity; - - MemoryStream entityMessage = null; - _bufferedCreateEntityMessages.TryGetValue(eid, out entityMessage); - - if(entityMessage != null) - { - Client_onUpdatePropertys(entityMessage); - _bufferedCreateEntityMessages.Remove(eid); - entityMessage.reclaimObject(); - } - - entity.__init__(); - entity.attachComponents(); - entity.inited = true; - - if(_args.isOnInitCallPropertysSetMethods) - entity.callPropertysSetMethods(); - } - else - { - MemoryStream entityMessage = null; - _bufferedCreateEntityMessages.TryGetValue(eid, out entityMessage); - - if(entityMessage != null) - { - Client_onUpdatePropertys(entityMessage); - _bufferedCreateEntityMessages.Remove(eid); - entityMessage.reclaimObject(); - } - } - } - - public Entity findEntity(Int32 entityID) - { - Entity entity = null; - - if(!entities.TryGetValue(entityID, out entity)) - { - return null; - } - - return entity; - } - - /* - 通过流数据获得View实体的ID - */ - public Int32 getViewEntityIDFromStream(MemoryStream stream) - { - if (!_args.useAliasEntityID) - return stream.readInt32(); - - Int32 id = 0; - if(_entityIDAliasIDList.Count > 255) - { - id = stream.readInt32(); - } - else - { - byte aliasID = stream.readUint8(); - - // 如果为0且客户端上一步是重登陆或者重连操作并且服务端entity在断线期间一直处于在线状态 - // 则可以忽略这个错误, 因为cellapp可能一直在向baseapp发送同步消息, 当客户端重连上时未等 - // 服务端初始化步骤开始则收到同步信息, 此时这里就会出错。 - if(_entityIDAliasIDList.Count <= aliasID) - return 0; - - id = _entityIDAliasIDList[aliasID]; - } - - return id; - } - - /* - 服务端使用优化的方式更新实体属性数据 - */ - public void Client_onUpdatePropertysOptimized(MemoryStream stream) - { - Int32 eid = getViewEntityIDFromStream(stream); - onUpdatePropertys_(eid, stream); - } - - /* - 服务端更新实体属性数据 - */ - public void Client_onUpdatePropertys(MemoryStream stream) - { - Int32 eid = stream.readInt32(); - onUpdatePropertys_(eid, stream); - } - - public void onUpdatePropertys_(Int32 eid, MemoryStream stream) - { - Entity entity = null; - - if(!entities.TryGetValue(eid, out entity)) - { - MemoryStream entityMessage = null; - if(_bufferedCreateEntityMessages.TryGetValue(eid, out entityMessage)) - { - Dbg.ERROR_MSG("KBEngine::Client_onUpdatePropertys: entity(" + eid + ") not found!"); - return; - } - - MemoryStream stream1 = MemoryStream.createObject(); - stream1.wpos = stream.wpos; - stream1.rpos = stream.rpos - 4; - Array.Copy(stream.data(), stream1.data(), stream.wpos); - _bufferedCreateEntityMessages[eid] = stream1; - return; - } - - entity.onUpdatePropertys(stream); - } - - /* - 服务端使用优化的方式调用实体方法 - */ - public void Client_onRemoteMethodCallOptimized(MemoryStream stream) - { - Int32 eid = getViewEntityIDFromStream(stream); - onRemoteMethodCall_(eid, stream); - } - - /* - 服务端调用实体方法 - */ - public void Client_onRemoteMethodCall(MemoryStream stream) - { - Int32 eid = stream.readInt32(); - onRemoteMethodCall_(eid, stream); - } - - public void onRemoteMethodCall_(Int32 eid, MemoryStream stream) - { - Entity entity = null; - - if(!entities.TryGetValue(eid, out entity)) - { - Dbg.ERROR_MSG("KBEngine::Client_onRemoteMethodCall: entity(" + eid + ") not found!"); - return; - } - - entity.onRemoteMethodCall(stream); - } - - /* - 服务端通知一个实体进入了世界(如果实体是当前玩家则玩家第一次在一个space中创建了, 如果是其他实体则是其他实体进入了玩家的View) - */ - public void Client_onEntityEnterWorld(MemoryStream stream) - { - Int32 eid = stream.readInt32(); - if(entity_id > 0 && entity_id != eid) - _entityIDAliasIDList.Add(eid); - - UInt16 uentityType; - if(EntityDef.idmoduledefs.Count > 255) - uentityType = stream.readUint16(); - else - uentityType = stream.readUint8(); - - sbyte isOnGround = 1; - - if(stream.length() > 0) - isOnGround = stream.readInt8(); - - string entityType = EntityDef.idmoduledefs[uentityType].name; - // Dbg.DEBUG_MSG("KBEngine::Client_onEntityEnterWorld: " + entityType + "(" + eid + "), spaceID(" + KBEngineApp.app.spaceID + ")!"); - - Entity entity = null; - - if(!entities.TryGetValue(eid, out entity)) - { - MemoryStream entityMessage = null; - if(!_bufferedCreateEntityMessages.TryGetValue(eid, out entityMessage)) - { - Dbg.ERROR_MSG("KBEngine::Client_onEntityEnterWorld: entity(" + eid + ") not found!"); - return; - } - - ScriptModule module = null; - if(!EntityDef.moduledefs.TryGetValue(entityType, out module)) - { - Dbg.ERROR_MSG("KBEngine::Client_onEntityEnterWorld: not found module(" + entityType + ")!"); - } - - Type runclass = module.entityScript; - if(runclass == null) - return; - - entity = (Entity)Activator.CreateInstance(runclass); - entity.id = eid; - entity.className = entityType; - entity.onGetCell(); - - entities[eid] = entity; - - Client_onUpdatePropertys(entityMessage); - _bufferedCreateEntityMessages.Remove(eid); - entityMessage.reclaimObject(); - - entity.isOnGround = isOnGround > 0; - entity.onDirectionChanged(entity.direction); - entity.onPositionChanged(entity.position); - - entity.__init__(); - entity.attachComponents(); - entity.inited = true; - entity.inWorld = true; - entity.enterWorld(); - - if(_args.isOnInitCallPropertysSetMethods) - entity.callPropertysSetMethods(); - } - else - { - if(!entity.inWorld) - { - // 安全起见, 这里清空一下 - // 如果服务端上使用giveClientTo切换控制权 - // 之前的实体已经进入世界, 切换后的实体也进入世界, 这里可能会残留之前那个实体进入世界的信息 - _entityIDAliasIDList.Clear(); - clearEntities(false); - entities[entity.id] = entity; - - entity.onGetCell(); - - entity.onDirectionChanged(entity.direction); - entity.onPositionChanged(entity.position); - - _entityServerPos = entity.position; - entity.isOnGround = isOnGround > 0; - entity.inWorld = true; - entity.enterWorld(); - - if(_args.isOnInitCallPropertysSetMethods) - entity.callPropertysSetMethods(); - } - } - } - - /* - 服务端使用优化的方式通知一个实体离开了世界(如果实体是当前玩家则玩家离开了space, 如果是其他实体则是其他实体离开了玩家的View) - */ - public void Client_onEntityLeaveWorldOptimized(MemoryStream stream) - { - Int32 eid = getViewEntityIDFromStream(stream); - KBEngineApp.app.Client_onEntityLeaveWorld(eid); - } - - /* - 服务端通知一个实体离开了世界(如果实体是当前玩家则玩家离开了space, 如果是其他实体则是其他实体离开了玩家的View) - */ - public void Client_onEntityLeaveWorld(Int32 eid) - { - Entity entity = null; - - if(!entities.TryGetValue(eid, out entity)) - { - Dbg.ERROR_MSG("KBEngine::Client_onEntityLeaveWorld: entity(" + eid + ") not found!"); - return; - } - - if(entity.inWorld) - entity.leaveWorld(); - - if(entity_id == eid) - { - clearSpace(false); - entity.onLoseCell(); - } - else - { - if(_controlledEntities.Remove(entity)) - Event.fireOut(EventOutTypes.onLoseControlledEntity, entity); - - entities.Remove(eid); - entity.destroy(); - _entityIDAliasIDList.Remove(eid); - } - } - - /* - 服务端通知当前玩家进入了一个新的space - */ - public void Client_onEntityEnterSpace(MemoryStream stream) - { - Int32 eid = stream.readInt32(); - spaceID = stream.readUint32(); - - sbyte isOnGround = 1; - - if(stream.length() > 0) - isOnGround = stream.readInt8(); - - Entity entity = null; - - if(!entities.TryGetValue(eid, out entity)) - { - Dbg.ERROR_MSG("KBEngine::Client_onEntityEnterSpace: entity(" + eid + ") not found!"); - return; - } - - entity.isOnGround = isOnGround > 0; - _entityServerPos = entity.position; - entity.enterSpace(); - } - - /* - 服务端通知当前玩家离开了space - */ - public void Client_onEntityLeaveSpace(Int32 eid) - { - Entity entity = null; - - if(!entities.TryGetValue(eid, out entity)) - { - Dbg.ERROR_MSG("KBEngine::Client_onEntityLeaveSpace: entity(" + eid + ") not found!"); - return; - } - - entity.leaveSpace(); - clearSpace(false); - } - - /* - 账号创建返回结果 - */ - public void Client_onCreateAccountResult(MemoryStream stream) - { - UInt16 retcode = stream.readUint16(); - byte[] datas = stream.readBlob(); - - Event.fireOut(EventOutTypes.onCreateAccountResult, retcode, datas); - - if(retcode != 0) - { - Dbg.WARNING_MSG("KBEngine::Client_onCreateAccountResult: " + username + " create is failed! code=" + retcode + "(" + serverErr(retcode)+ ")!"); - return; - } - - Dbg.DEBUG_MSG("KBEngine::Client_onCreateAccountResult: " + username + " create is successfully!"); - } - - /* - 告诉客户端:你当前负责(或取消)控制谁的位移同步 - */ - public void Client_onControlEntity(Int32 eid, sbyte isControlled) - { - Entity entity = null; - - if (!entities.TryGetValue(eid, out entity)) - { - Dbg.ERROR_MSG("KBEngine::Client_onControlEntity: entity(" + eid + ") not found!"); - return; - } - - var isCont = isControlled != 0; - if (isCont) - { - // 如果被控制者是玩家自己,那表示玩家自己被其它人控制了 - // 所以玩家自己不应该进入这个被控制列表 - if (player().id != entity.id) - { - _controlledEntities.Add(entity); - } - } - else - { - _controlledEntities.Remove(entity); - } - - entity.isControlled = isCont; - - try - { - entity.onControlled(isCont); - Event.fireOut(EventOutTypes.onControlled, entity, isCont); - } - catch (Exception e) - { - Dbg.ERROR_MSG(string.Format("KBEngine::Client_onControlEntity: entity id = '{0}', is controlled = '{1}', error = '{1}'", eid, isCont, e)); - } - } - - /* - 更新当前玩家的位置与朝向到服务端, 可以通过开关_syncPlayerMS关闭这个机制 - */ - public void updatePlayerToServer() - { - if(_updatePlayerToServerPeroid <= 0.01f || spaceID == 0) - { - return; - } - - var now = DateTime.Now; - TimeSpan span = now - _lastUpdateToServerTime; - - if (span.Ticks < _updatePlayerToServerPeroid * _1MS_TO_100NS) - return; - - Entity playerEntity = player(); - if (playerEntity == null || playerEntity.inWorld == false || playerEntity.isControlled) - return; - - _lastUpdateToServerTime = now - (span - TimeSpan.FromTicks(Convert.ToInt64(_updatePlayerToServerPeroid * _1MS_TO_100NS))); - - Vector3 position = playerEntity.position; - Vector3 direction = playerEntity.direction; - - bool posHasChanged = Vector3.Distance(playerEntity._entityLastLocalPos, position) > 0.001f; - bool dirHasChanged = Vector3.Distance(playerEntity._entityLastLocalDir, direction) > 0.001f; - - if(posHasChanged || dirHasChanged) - { - playerEntity._entityLastLocalPos = position; - playerEntity._entityLastLocalDir = direction; - - Bundle bundle = Bundle.createObject(); - bundle.newMessage(Messages.messages["Baseapp_onUpdateDataFromClient"]); - bundle.writeFloat(position.x); - bundle.writeFloat(position.y); - bundle.writeFloat(position.z); - - double x = ((double)direction.x / 360 * (System.Math.PI * 2)); - double y = ((double)direction.y / 360 * (System.Math.PI * 2)); - double z = ((double)direction.z / 360 * (System.Math.PI * 2)); - - // 根据弧度转角度公式会出现负数 - // unity会自动转化到0~360度之间,这里需要做一个还原 - if(x - System.Math.PI > 0.0) - x -= System.Math.PI * 2; - - if(y - System.Math.PI > 0.0) - y -= System.Math.PI * 2; - - if(z - System.Math.PI > 0.0) - z -= System.Math.PI * 2; - - bundle.writeFloat((float)x); - bundle.writeFloat((float)y); - bundle.writeFloat((float)z); - bundle.writeUint8((Byte)(playerEntity.isOnGround == true ? 1 : 0)); - bundle.writeUint32(spaceID); - bundle.send(_networkInterface); - } - - // 开始同步所有被控制了的entity的位置 - for (int i = 0; i < _controlledEntities.Count; ++i) - { - var entity = _controlledEntities[i]; - position = entity.position; - direction = entity.direction; - - posHasChanged = Vector3.Distance(entity._entityLastLocalPos, position) > 0.001f; - dirHasChanged = Vector3.Distance(entity._entityLastLocalDir, direction) > 0.001f; - - if (posHasChanged || dirHasChanged) - { - entity._entityLastLocalPos = position; - entity._entityLastLocalDir = direction; - - Bundle bundle = Bundle.createObject(); - bundle.newMessage(Messages.messages["Baseapp_onUpdateDataFromClientForControlledEntity"]); - bundle.writeInt32(entity.id); - bundle.writeFloat(position.x); - bundle.writeFloat(position.y); - bundle.writeFloat(position.z); - - double x = ((double)direction.x / 360 * (System.Math.PI * 2)); - double y = ((double)direction.y / 360 * (System.Math.PI * 2)); - double z = ((double)direction.z / 360 * (System.Math.PI * 2)); - - // 根据弧度转角度公式会出现负数 - // unity会自动转化到0~360度之间,这里需要做一个还原 - if(x - System.Math.PI > 0.0) - x -= System.Math.PI * 2; - - if(y - System.Math.PI > 0.0) - y -= System.Math.PI * 2; - - if(z - System.Math.PI > 0.0) - z -= System.Math.PI * 2; - - bundle.writeFloat((float)x); - bundle.writeFloat((float)y); - bundle.writeFloat((float)z); - bundle.writeUint8((Byte)(entity.isOnGround == true ? 1 : 0)); - bundle.writeUint32(spaceID); - bundle.send(_networkInterface); - } - } - } - - /* - 当前space添加了关于几何等信息的映射资源 - 客户端可以通过这个资源信息来加载对应的场景 - */ - public void addSpaceGeometryMapping(UInt32 uspaceID, string respath) - { - Dbg.DEBUG_MSG("KBEngine::addSpaceGeometryMapping: spaceID(" + uspaceID + "), respath(" + respath + ")!"); - - isLoadedGeometry = true; - spaceID = uspaceID; - spaceResPath = respath; - Event.fireOut(EventOutTypes.addSpaceGeometryMapping, spaceResPath); - } - - public void clearSpace(bool isall) - { - _entityIDAliasIDList.Clear(); - _spacedatas.Clear(); - clearEntities(isall); - isLoadedGeometry = false; - spaceID = 0; - } - - public void clearEntities(bool isall) - { - _controlledEntities.Clear(); - - if (!isall) - { - Entity entity = player(); - - foreach (KeyValuePair dic in entities) - { - if(dic.Key == entity.id) - continue; - - if(dic.Value.inWorld) - dic.Value.leaveWorld(); - - dic.Value.destroy(); - } - - entities.Clear(); - entities[entity.id] = entity; - } - else - { - foreach (KeyValuePair dic in entities) - { - if(dic.Value.inWorld) - dic.Value.leaveWorld(); - - dic.Value.destroy(); - } - - entities.Clear(); - } - } - - /* - 服务端初始化客户端的spacedata, spacedata请参考API - */ - public void Client_initSpaceData(MemoryStream stream) - { - clearSpace(false); - spaceID = stream.readUint32(); - - while(stream.length() > 0) - { - string key = stream.readString(); - string val = stream.readString(); - Client_setSpaceData(spaceID, key, val); - } - - Dbg.DEBUG_MSG("KBEngine::Client_initSpaceData: spaceID(" + spaceID + "), size(" + _spacedatas.Count + ")!"); - } - - /* - 服务端设置客户端的spacedata, spacedata请参考API - */ - public void Client_setSpaceData(UInt32 spaceID, string key, string value) - { - Dbg.DEBUG_MSG("KBEngine::Client_setSpaceData: spaceID(" + spaceID + "), key(" + key + "), value(" + value + ")!"); - _spacedatas[key] = value; - - if(key == "_mapping") - addSpaceGeometryMapping(spaceID, value); - - Event.fireOut(EventOutTypes.onSetSpaceData, spaceID, key, value); - } - - /* - 服务端删除客户端的spacedata, spacedata请参考API - */ - public void Client_delSpaceData(UInt32 spaceID, string key) - { - Dbg.DEBUG_MSG("KBEngine::Client_delSpaceData: spaceID(" + spaceID + "), key(" + key + ")"); - _spacedatas.Remove(key); - Event.fireOut(EventOutTypes.onDelSpaceData, spaceID, key); - } - - public string getSpaceData(string key) - { - string val = ""; - - if(!_spacedatas.TryGetValue(key, out val)) - { - return ""; - } - - return val; - } - - /* - 服务端通知强制销毁一个实体 - */ - public void Client_onEntityDestroyed(Int32 eid) - { - Dbg.DEBUG_MSG("KBEngine::Client_onEntityDestroyed: entity(" + eid + ")"); - - Entity entity = null; - - if(!entities.TryGetValue(eid, out entity)) - { - Dbg.ERROR_MSG("KBEngine::Client_onEntityDestroyed: entity(" + eid + ") not found!"); - return; - } - - if(entity.inWorld) - { - if(entity_id == eid) - clearSpace(false); - - entity.leaveWorld(); - } - - if(_controlledEntities.Remove(entity)) - Event.fireOut(EventOutTypes.onLoseControlledEntity, entity); - - entities.Remove(eid); - entity.destroy(); - } - - /* - 服务端更新玩家的基础位置, 客户端以这个基础位置加上便宜值计算出玩家周围实体的坐标 - */ - public void Client_onUpdateBasePos(float x, float y, float z) - { - _entityServerPos.x = x; - _entityServerPos.y = y; - _entityServerPos.z = z; - - var entity = player(); - if (entity != null && entity.isControlled) - { - entity.position.Set(_entityServerPos.x, _entityServerPos.y, _entityServerPos.z); - Event.fireOut(EventOutTypes.updatePosition, entity); - entity.onUpdateVolatileData(); - } - } - - public void Client_onUpdateBasePosXZ(float x, float z) - { - _entityServerPos.x = x; - _entityServerPos.z = z; - - var entity = player(); - if (entity != null && entity.isControlled) - { - entity.position.x = _entityServerPos.x; - entity.position.z = _entityServerPos.z; - Event.fireOut(EventOutTypes.updatePosition, entity); - entity.onUpdateVolatileData(); - } - } - - public void Client_onUpdateBaseDir(MemoryStream stream) - { - float yaw, pitch, roll; - yaw = stream.readFloat() * 360 / ((float)System.Math.PI * 2); - pitch = stream.readFloat() * 360 / ((float)System.Math.PI * 2); - roll = stream.readFloat() * 360 / ((float)System.Math.PI * 2); - - var entity = player(); - if (entity != null && entity.isControlled) - { - entity.direction.Set(roll, pitch, yaw); - Event.fireOut(EventOutTypes.set_direction, entity); - entity.onUpdateVolatileData(); - } - } - - public void Client_onUpdateData(MemoryStream stream) - { - Int32 eid = getViewEntityIDFromStream(stream); - Entity entity = null; - - if(!entities.TryGetValue(eid, out entity)) - { - Dbg.ERROR_MSG("KBEngine::Client_onUpdateData: entity(" + eid + ") not found!"); - return; - } - } - - /* - 服务端强制设置了玩家的坐标 - 例如:在服务端使用avatar.position=(0,0,0), 或者玩家位置与速度异常时会强制拉回到一个位置 - */ - public void Client_onSetEntityPosAndDir(MemoryStream stream) - { - Int32 eid = stream.readInt32(); - Entity entity = null; - - if(!entities.TryGetValue(eid, out entity)) - { - Dbg.ERROR_MSG("KBEngine::Client_onSetEntityPosAndDir: entity(" + eid + ") not found!"); - return; - } - - Vector3 old_position = new Vector3(entity.position.x, entity.position.y, entity.position.z); - Vector3 old_direction = new Vector3(entity.direction.x, entity.direction.y, entity.direction.z); - - entity.position.x = stream.readFloat(); - entity.position.y = stream.readFloat(); - entity.position.z = stream.readFloat(); - - entity.direction.x = stream.readFloat(); - entity.direction.y = stream.readFloat(); - entity.direction.z = stream.readFloat(); - - entity._entityLastLocalPos = entity.position; - entity._entityLastLocalDir = entity.direction; - - entity.onDirectionChanged(old_direction); - entity.onPositionChanged(old_position); - } - - public void Client_onUpdateData_ypr(MemoryStream stream) - { - Int32 eid = getViewEntityIDFromStream(stream); - - float y = stream.readFloat(); - float p = stream.readFloat(); - float r = stream.readFloat(); - - _updateVolatileData(eid, KBEMath.KBE_FLT_MAX, KBEMath.KBE_FLT_MAX, KBEMath.KBE_FLT_MAX, y, p, r, -1, false); - } - - public void Client_onUpdateData_yp(MemoryStream stream) - { - Int32 eid = getViewEntityIDFromStream(stream); - - float y = stream.readFloat(); - float p = stream.readFloat(); - - _updateVolatileData(eid, KBEMath.KBE_FLT_MAX, KBEMath.KBE_FLT_MAX, KBEMath.KBE_FLT_MAX, y, p, KBEMath.KBE_FLT_MAX, -1, false); - } - - public void Client_onUpdateData_yr(MemoryStream stream) - { - Int32 eid = getViewEntityIDFromStream(stream); - - float y = stream.readFloat(); - float r = stream.readFloat(); - - _updateVolatileData(eid, KBEMath.KBE_FLT_MAX, KBEMath.KBE_FLT_MAX, KBEMath.KBE_FLT_MAX, y, KBEMath.KBE_FLT_MAX, r, -1, false); - } - - public void Client_onUpdateData_pr(MemoryStream stream) - { - Int32 eid = getViewEntityIDFromStream(stream); - - float p = stream.readFloat(); - float r = stream.readFloat(); - - _updateVolatileData(eid, KBEMath.KBE_FLT_MAX, KBEMath.KBE_FLT_MAX, KBEMath.KBE_FLT_MAX, KBEMath.KBE_FLT_MAX, p, r, -1, false); - } - - public void Client_onUpdateData_y(MemoryStream stream) - { - Int32 eid = getViewEntityIDFromStream(stream); - - float y = stream.readFloat(); - - _updateVolatileData(eid, KBEMath.KBE_FLT_MAX, KBEMath.KBE_FLT_MAX, KBEMath.KBE_FLT_MAX, y, KBEMath.KBE_FLT_MAX, KBEMath.KBE_FLT_MAX, -1, false); - } - - public void Client_onUpdateData_p(MemoryStream stream) - { - Int32 eid = getViewEntityIDFromStream(stream); - - float p = stream.readFloat(); - - _updateVolatileData(eid, KBEMath.KBE_FLT_MAX, KBEMath.KBE_FLT_MAX, KBEMath.KBE_FLT_MAX, KBEMath.KBE_FLT_MAX, p, KBEMath.KBE_FLT_MAX, -1, false); - } - - public void Client_onUpdateData_r(MemoryStream stream) - { - Int32 eid = getViewEntityIDFromStream(stream); - - float r = stream.readFloat(); - - _updateVolatileData(eid, KBEMath.KBE_FLT_MAX, KBEMath.KBE_FLT_MAX, KBEMath.KBE_FLT_MAX, KBEMath.KBE_FLT_MAX, KBEMath.KBE_FLT_MAX, r, -1, false); - } - - public void Client_onUpdateData_xz(MemoryStream stream) - { - Int32 eid = getViewEntityIDFromStream(stream); - - float x = stream.readFloat(); - float z = stream.readFloat(); - - _updateVolatileData(eid, x, KBEMath.KBE_FLT_MAX, z, KBEMath.KBE_FLT_MAX, KBEMath.KBE_FLT_MAX, KBEMath.KBE_FLT_MAX, 1, false); - } - - public void Client_onUpdateData_xz_ypr(MemoryStream stream) - { - Int32 eid = getViewEntityIDFromStream(stream); - - float x = stream.readFloat(); - float z = stream.readFloat(); - - float y = stream.readFloat(); - float p = stream.readFloat(); - float r = stream.readFloat(); - - _updateVolatileData(eid, x, KBEMath.KBE_FLT_MAX, z, y, p, r, 1, false); - } - - public void Client_onUpdateData_xz_yp(MemoryStream stream) - { - Int32 eid = getViewEntityIDFromStream(stream); - - float x = stream.readFloat(); - float z = stream.readFloat(); - - float y = stream.readFloat(); - float p = stream.readFloat(); - - _updateVolatileData(eid, x, KBEMath.KBE_FLT_MAX, z, y, p, KBEMath.KBE_FLT_MAX, 1, false); - } - - public void Client_onUpdateData_xz_yr(MemoryStream stream) - { - Int32 eid = getViewEntityIDFromStream(stream); - - float x = stream.readFloat(); - float z = stream.readFloat(); - - float y = stream.readFloat(); - float r = stream.readFloat(); - - _updateVolatileData(eid, x, KBEMath.KBE_FLT_MAX, z, y, KBEMath.KBE_FLT_MAX, r, 1, false); - } - - public void Client_onUpdateData_xz_pr(MemoryStream stream) - { - Int32 eid = getViewEntityIDFromStream(stream); - - float x = stream.readFloat(); - float z = stream.readFloat(); - - float p = stream.readFloat(); - float r = stream.readFloat(); - - _updateVolatileData(eid, x, KBEMath.KBE_FLT_MAX, z, KBEMath.KBE_FLT_MAX, p, r, 1, false); - } - - public void Client_onUpdateData_xz_y(MemoryStream stream) - { - Int32 eid = getViewEntityIDFromStream(stream); - - float x = stream.readFloat(); - float z = stream.readFloat(); - - float yaw = stream.readFloat(); - - _updateVolatileData(eid, x, KBEMath.KBE_FLT_MAX, z, yaw, KBEMath.KBE_FLT_MAX, KBEMath.KBE_FLT_MAX, 1, false); - } - - public void Client_onUpdateData_xz_p(MemoryStream stream) - { - Int32 eid = getViewEntityIDFromStream(stream); - - float x = stream.readFloat(); - float z = stream.readFloat(); - - float p = stream.readFloat(); - - _updateVolatileData(eid, x, KBEMath.KBE_FLT_MAX, z, KBEMath.KBE_FLT_MAX, p, KBEMath.KBE_FLT_MAX, 1, false); - } - - public void Client_onUpdateData_xz_r(MemoryStream stream) - { - Int32 eid = getViewEntityIDFromStream(stream); - - float x = stream.readFloat(); - float z = stream.readFloat(); - - float r = stream.readFloat(); - - _updateVolatileData(eid, x, KBEMath.KBE_FLT_MAX, z, KBEMath.KBE_FLT_MAX, KBEMath.KBE_FLT_MAX, r, 1, false); - } - - public void Client_onUpdateData_xyz(MemoryStream stream) - { - Int32 eid = getViewEntityIDFromStream(stream); - - float x = stream.readFloat(); - float y = stream.readFloat(); - float z = stream.readFloat(); - - _updateVolatileData(eid, x, y, z, KBEMath.KBE_FLT_MAX, KBEMath.KBE_FLT_MAX, KBEMath.KBE_FLT_MAX, 0, false); - } - - public void Client_onUpdateData_xyz_ypr(MemoryStream stream) - { - Int32 eid = getViewEntityIDFromStream(stream); - - float x = stream.readFloat(); - float y = stream.readFloat(); - float z = stream.readFloat(); - - float yaw = stream.readFloat(); - float p = stream.readFloat(); - float r = stream.readFloat(); - - _updateVolatileData(eid, x, y, z, yaw, p, r, 0, false); - } - - public void Client_onUpdateData_xyz_yp(MemoryStream stream) - { - Int32 eid = getViewEntityIDFromStream(stream); - - float x = stream.readFloat(); - float y = stream.readFloat(); - float z = stream.readFloat(); - - float yaw = stream.readFloat(); - float p = stream.readFloat(); - - _updateVolatileData(eid, x, y, z, yaw, p, KBEMath.KBE_FLT_MAX, 0, false); - } - - public void Client_onUpdateData_xyz_yr(MemoryStream stream) - { - Int32 eid = getViewEntityIDFromStream(stream); - - float x = stream.readFloat(); - float y = stream.readFloat(); - float z = stream.readFloat(); - - float yaw = stream.readFloat(); - float r = stream.readFloat(); - - _updateVolatileData(eid, x, y, z, yaw, KBEMath.KBE_FLT_MAX, r, 0, false); - } - - public void Client_onUpdateData_xyz_pr(MemoryStream stream) - { - Int32 eid = getViewEntityIDFromStream(stream); - - float x = stream.readFloat(); - float y = stream.readFloat(); - float z = stream.readFloat(); - - float p = stream.readFloat(); - float r = stream.readFloat(); - - _updateVolatileData(eid, x, y, z, KBEMath.KBE_FLT_MAX, p, r, 0, false); - } - - public void Client_onUpdateData_xyz_y(MemoryStream stream) - { - Int32 eid = getViewEntityIDFromStream(stream); - - float x = stream.readFloat(); - float y = stream.readFloat(); - float z = stream.readFloat(); - - float yaw = stream.readFloat(); - - _updateVolatileData(eid, x, y, z, yaw, KBEMath.KBE_FLT_MAX, KBEMath.KBE_FLT_MAX, 0, false); - } - - public void Client_onUpdateData_xyz_p(MemoryStream stream) - { - Int32 eid = getViewEntityIDFromStream(stream); - - float x = stream.readFloat(); - float y = stream.readFloat(); - float z = stream.readFloat(); - - float p = stream.readFloat(); - - _updateVolatileData(eid, x, y, z, KBEMath.KBE_FLT_MAX, p, KBEMath.KBE_FLT_MAX, 0, false); - } - - public void Client_onUpdateData_xyz_r(MemoryStream stream) - { - Int32 eid = getViewEntityIDFromStream(stream); - - float x = stream.readFloat(); - float y = stream.readFloat(); - float z = stream.readFloat(); - - float r = stream.readFloat(); - - _updateVolatileData(eid, x, y, z, KBEMath.KBE_FLT_MAX, KBEMath.KBE_FLT_MAX, r, 0, false); - } - - public void Client_onUpdateData_ypr_optimized(MemoryStream stream) - { - Int32 eid = getViewEntityIDFromStream(stream); - - SByte y = stream.readInt8(); - SByte p = stream.readInt8(); - SByte r = stream.readInt8(); - - _updateVolatileData(eid, KBEMath.KBE_FLT_MAX, KBEMath.KBE_FLT_MAX, KBEMath.KBE_FLT_MAX, y, p, r, -1, true); - } - - public void Client_onUpdateData_yp_optimized(MemoryStream stream) - { - Int32 eid = getViewEntityIDFromStream(stream); - - SByte y = stream.readInt8(); - SByte p = stream.readInt8(); - - _updateVolatileData(eid, KBEMath.KBE_FLT_MAX, KBEMath.KBE_FLT_MAX, KBEMath.KBE_FLT_MAX, y, p, KBEMath.KBE_FLT_MAX, -1, true); - } - - public void Client_onUpdateData_yr_optimized(MemoryStream stream) - { - Int32 eid = getViewEntityIDFromStream(stream); - - SByte y = stream.readInt8(); - SByte r = stream.readInt8(); - - _updateVolatileData(eid, KBEMath.KBE_FLT_MAX, KBEMath.KBE_FLT_MAX, KBEMath.KBE_FLT_MAX, y, KBEMath.KBE_FLT_MAX, r, -1, true); - } - - public void Client_onUpdateData_pr_optimized(MemoryStream stream) - { - Int32 eid = getViewEntityIDFromStream(stream); - - SByte p = stream.readInt8(); - SByte r = stream.readInt8(); - - _updateVolatileData(eid, KBEMath.KBE_FLT_MAX, KBEMath.KBE_FLT_MAX, KBEMath.KBE_FLT_MAX, KBEMath.KBE_FLT_MAX, p, r, -1, true); - } - - public void Client_onUpdateData_y_optimized(MemoryStream stream) - { - Int32 eid = getViewEntityIDFromStream(stream); - - SByte y = stream.readInt8(); - - _updateVolatileData(eid, KBEMath.KBE_FLT_MAX, KBEMath.KBE_FLT_MAX, KBEMath.KBE_FLT_MAX, y, KBEMath.KBE_FLT_MAX, KBEMath.KBE_FLT_MAX, -1, true); - } - - public void Client_onUpdateData_p_optimized(MemoryStream stream) - { - Int32 eid = getViewEntityIDFromStream(stream); - - SByte p = stream.readInt8(); - - _updateVolatileData(eid, KBEMath.KBE_FLT_MAX, KBEMath.KBE_FLT_MAX, KBEMath.KBE_FLT_MAX, KBEMath.KBE_FLT_MAX, p, KBEMath.KBE_FLT_MAX, -1, true); - } - - public void Client_onUpdateData_r_optimized(MemoryStream stream) - { - Int32 eid = getViewEntityIDFromStream(stream); - - SByte r = stream.readInt8(); - - _updateVolatileData(eid, KBEMath.KBE_FLT_MAX, KBEMath.KBE_FLT_MAX, KBEMath.KBE_FLT_MAX, KBEMath.KBE_FLT_MAX, KBEMath.KBE_FLT_MAX, r, -1, true); - } - - public void Client_onUpdateData_xz_optimized(MemoryStream stream) - { - Int32 eid = getViewEntityIDFromStream(stream); - - Vector2 xz = stream.readPackXZ(); - - _updateVolatileData(eid, xz[0], KBEMath.KBE_FLT_MAX, xz[1], KBEMath.KBE_FLT_MAX, KBEMath.KBE_FLT_MAX, KBEMath.KBE_FLT_MAX, 1, true); - } - - public void Client_onUpdateData_xz_ypr_optimized(MemoryStream stream) - { - Int32 eid = getViewEntityIDFromStream(stream); - - Vector2 xz = stream.readPackXZ(); - - SByte y = stream.readInt8(); - SByte p = stream.readInt8(); - SByte r = stream.readInt8(); - - _updateVolatileData(eid, xz[0], KBEMath.KBE_FLT_MAX, xz[1], y, p, r, 1, true); - } - - public void Client_onUpdateData_xz_yp_optimized(MemoryStream stream) - { - Int32 eid = getViewEntityIDFromStream(stream); - - Vector2 xz = stream.readPackXZ(); - - SByte y = stream.readInt8(); - SByte p = stream.readInt8(); - - _updateVolatileData(eid, xz[0], KBEMath.KBE_FLT_MAX, xz[1], y, p, KBEMath.KBE_FLT_MAX, 1, true); - } - - public void Client_onUpdateData_xz_yr_optimized(MemoryStream stream) - { - Int32 eid = getViewEntityIDFromStream(stream); - - Vector2 xz = stream.readPackXZ(); - - SByte y = stream.readInt8(); - SByte r = stream.readInt8(); - - _updateVolatileData(eid, xz[0], KBEMath.KBE_FLT_MAX, xz[1], y, KBEMath.KBE_FLT_MAX, r, 1, true); - } - - public void Client_onUpdateData_xz_pr_optimized(MemoryStream stream) - { - Int32 eid = getViewEntityIDFromStream(stream); - - Vector2 xz = stream.readPackXZ(); - - SByte p = stream.readInt8(); - SByte r = stream.readInt8(); - - _updateVolatileData(eid, xz[0], KBEMath.KBE_FLT_MAX, xz[1], KBEMath.KBE_FLT_MAX, p, r, 1, true); - } - - public void Client_onUpdateData_xz_y_optimized(MemoryStream stream) - { - Int32 eid = getViewEntityIDFromStream(stream); - Vector2 xz = stream.readPackXZ(); - SByte yaw = stream.readInt8(); - _updateVolatileData(eid, xz[0], KBEMath.KBE_FLT_MAX, xz[1], yaw, KBEMath.KBE_FLT_MAX, KBEMath.KBE_FLT_MAX, 1, true); - } - - public void Client_onUpdateData_xz_p_optimized(MemoryStream stream) - { - Int32 eid = getViewEntityIDFromStream(stream); - - Vector2 xz = stream.readPackXZ(); - - SByte p = stream.readInt8(); - - _updateVolatileData(eid, xz[0], KBEMath.KBE_FLT_MAX, xz[1], KBEMath.KBE_FLT_MAX, p, KBEMath.KBE_FLT_MAX, 1, true); - } - - public void Client_onUpdateData_xz_r_optimized(MemoryStream stream) - { - Int32 eid = getViewEntityIDFromStream(stream); - - Vector2 xz = stream.readPackXZ(); - - SByte r = stream.readInt8(); - - _updateVolatileData(eid, xz[0], KBEMath.KBE_FLT_MAX, xz[1], KBEMath.KBE_FLT_MAX, KBEMath.KBE_FLT_MAX, r, 1, true); - } - - public void Client_onUpdateData_xyz_optimized(MemoryStream stream) - { - Int32 eid = getViewEntityIDFromStream(stream); - - Vector2 xz = stream.readPackXZ(); - float y = stream.readPackY(); - - _updateVolatileData(eid, xz[0], y, xz[1], KBEMath.KBE_FLT_MAX, KBEMath.KBE_FLT_MAX, KBEMath.KBE_FLT_MAX, 0, true); - } - - public void Client_onUpdateData_xyz_ypr_optimized(MemoryStream stream) - { - Int32 eid = getViewEntityIDFromStream(stream); - - Vector2 xz = stream.readPackXZ(); - float y = stream.readPackY(); - - SByte yaw = stream.readInt8(); - SByte p = stream.readInt8(); - SByte r = stream.readInt8(); - - _updateVolatileData(eid, xz[0], y, xz[1], yaw, p, r, 0, true); - } - - public void Client_onUpdateData_xyz_yp_optimized(MemoryStream stream) - { - Int32 eid = getViewEntityIDFromStream(stream); - - Vector2 xz = stream.readPackXZ(); - float y = stream.readPackY(); - - SByte yaw = stream.readInt8(); - SByte p = stream.readInt8(); - - _updateVolatileData(eid, xz[0], y, xz[1], yaw, p, KBEMath.KBE_FLT_MAX, 0, true); - } - - public void Client_onUpdateData_xyz_yr_optimized(MemoryStream stream) - { - Int32 eid = getViewEntityIDFromStream(stream); - - Vector2 xz = stream.readPackXZ(); - float y = stream.readPackY(); - - SByte yaw = stream.readInt8(); - SByte r = stream.readInt8(); - - _updateVolatileData(eid, xz[0], y, xz[1], yaw, KBEMath.KBE_FLT_MAX, r, 0, true); - } - - public void Client_onUpdateData_xyz_pr_optimized(MemoryStream stream) - { - Int32 eid = getViewEntityIDFromStream(stream); - - Vector2 xz = stream.readPackXZ(); - float y = stream.readPackY(); - - SByte p = stream.readInt8(); - SByte r = stream.readInt8(); - - _updateVolatileData(eid, xz[0], y, xz[1], KBEMath.KBE_FLT_MAX, p, r, 0, true); - } - - public void Client_onUpdateData_xyz_y_optimized(MemoryStream stream) - { - Int32 eid = getViewEntityIDFromStream(stream); - - Vector2 xz = stream.readPackXZ(); - float y = stream.readPackY(); - - SByte yaw = stream.readInt8(); - _updateVolatileData(eid, xz[0], y, xz[1], yaw, KBEMath.KBE_FLT_MAX, KBEMath.KBE_FLT_MAX, 0, true); - } - - public void Client_onUpdateData_xyz_p_optimized(MemoryStream stream) - { - Int32 eid = getViewEntityIDFromStream(stream); - - Vector2 xz = stream.readPackXZ(); - float y = stream.readPackY(); - - SByte p = stream.readInt8(); - - _updateVolatileData(eid, xz[0], y, xz[1], KBEMath.KBE_FLT_MAX, p, KBEMath.KBE_FLT_MAX, 0, true); - } - - public void Client_onUpdateData_xyz_r_optimized(MemoryStream stream) - { - Int32 eid = getViewEntityIDFromStream(stream); - - Vector2 xz = stream.readPackXZ(); - float y = stream.readPackY(); - - SByte r = stream.readInt8(); - - _updateVolatileData(eid, xz[0], y, xz[1], KBEMath.KBE_FLT_MAX, KBEMath.KBE_FLT_MAX, r, 0, true); - } - - private void _updateVolatileData(Int32 entityID, float x, float y, float z, float yaw, float pitch, float roll, sbyte isOnGround, bool isOptimized) - { - Entity entity = null; - - if(!entities.TryGetValue(entityID, out entity)) - { - // 如果为0且客户端上一步是重登陆或者重连操作并且服务端entity在断线期间一直处于在线状态 - // 则可以忽略这个错误, 因为cellapp可能一直在向baseapp发送同步消息, 当客户端重连上时未等 - // 服务端初始化步骤开始则收到同步信息, 此时这里就会出错。 - Dbg.ERROR_MSG("KBEngine::_updateVolatileData: entity(" + entityID + ") not found!"); - return; - } - - // 小于0不设置 - if(isOnGround >= 0) - { - entity.isOnGround = (isOnGround > 0); - } - - bool changeDirection = false; - - if(roll != KBEMath.KBE_FLT_MAX) - { - changeDirection = true; - entity.direction.x = KBEMath.int82angle((SByte)roll, false) * 360 / ((float)System.Math.PI * 2); - } - - if(pitch != KBEMath.KBE_FLT_MAX) - { - changeDirection = true; - entity.direction.y = KBEMath.int82angle((SByte)pitch, false) * 360 / ((float)System.Math.PI * 2); - } - - if(yaw != KBEMath.KBE_FLT_MAX) - { - changeDirection = true; - entity.direction.z = KBEMath.int82angle((SByte)yaw, false) * 360 / ((float)System.Math.PI * 2); - } - - bool done = false; - if(changeDirection == true) - { - Event.fireOut(EventOutTypes.set_direction, entity); - done = true; - } - - bool positionChanged = x != KBEMath.KBE_FLT_MAX || y != KBEMath.KBE_FLT_MAX || z != KBEMath.KBE_FLT_MAX; - if (x == KBEMath.KBE_FLT_MAX) x = 0.0f; - if (y == KBEMath.KBE_FLT_MAX) y = 0.0f; - if (z == KBEMath.KBE_FLT_MAX) z = 0.0f; - - if(positionChanged) - { - Vector3 pos = isOptimized ? new Vector3(x + _entityServerPos.x, y + _entityServerPos.y, z + _entityServerPos.z) : new Vector3(x, y, z); - - entity.position = pos; - done = true; - Event.fireOut(EventOutTypes.updatePosition, entity); - } - - if(done) - entity.onUpdateVolatileData(); - } - - /* - 服务端通知流数据下载开始 - 请参考API手册关于onStreamDataStarted - */ - public void Client_onStreamDataStarted(Int16 id, UInt32 datasize, string descr) - { - Event.fireOut(EventOutTypes.onStreamDataStarted, id, datasize, descr); - } - - public void Client_onStreamDataRecv(MemoryStream stream) - { - Int16 resID = stream.readInt16(); - byte[] datas = stream.readBlob(); - Event.fireOut(EventOutTypes.onStreamDataRecv, resID, datas); - } - - public void Client_onStreamDataCompleted(Int16 id) - { - Event.fireOut(EventOutTypes.onStreamDataCompleted, id); - } - } - - - public class KBEngineAppThread : KBEngineApp - { - /* - KBEngine处理线程 - */ - public class KBEThread - { - - KBEngineApp app_; - public bool over = false; - - public KBEThread(KBEngineApp app) - { - this.app_ = app; - } - - public void run() - { - Dbg.INFO_MSG("KBEThread::run()"); - over = false; - - try - { - this.app_.process(); - } - catch (Exception e) - { - Dbg.ERROR_MSG(e.ToString()); - } - - over = true; - Dbg.INFO_MSG("KBEThread::end()"); - } - } - - private Thread _t = null; - public KBEThread kbethread = null; - - // 主循环频率 - public static int threadUpdateHZ = 10; - - // 主循环周期ms 优化去掉循环中做除法 - private static float threadUpdatePeriod = 1000f / threadUpdateHZ; - - // 插件是否退出 - private bool _isbreak = false; - - private System.DateTime _lasttime = System.DateTime.Now; - - public KBEngineAppThread(KBEngineArgs args) : - base(args) - { - } - - public override bool initialize(KBEngineArgs args) - { - base.initialize(args); - - KBEngineAppThread.threadUpdateHZ = args.threadUpdateHZ; - threadUpdatePeriod = 1000f / threadUpdateHZ; - - kbethread = new KBEThread(this); - _t = new Thread(new ThreadStart(kbethread.run)); - _t.Start(); - - return true; - } - - public override void reset() - { - _isbreak = false; - _lasttime = System.DateTime.Now; - - base.reset(); - } - - /* - 插件退出处理 - */ - public void breakProcess() - { - _isbreak = true; - } - - public bool isbreak() - { - return _isbreak; - } - - public override void process() - { - while(!isbreak()) - { - base.process(); - _thread_wait(); - } - - Dbg.WARNING_MSG("KBEngineAppThread::process(): break!"); - } - - /* - 防止占满CPU, 需要让线程等待一会 - */ - void _thread_wait() - { - TimeSpan span = DateTime.Now - _lasttime; - - int diff = (int)(threadUpdatePeriod - span.TotalMilliseconds); - - if(diff < 0) - diff = 0; - - System.Threading.Thread.Sleep(diff); - _lasttime = DateTime.Now; - } - - public override void destroy() - { - Dbg.WARNING_MSG("KBEngineAppThread::destroy()"); - breakProcess(); - - int i = 0; - while(!kbethread.over && i < 50) - { - Thread.Sleep(100); - i += 1; - } - - if(_t != null) - _t.Abort(); - - _t = null; - - base.destroy(); - } - } -} +namespace KBEngine +{ + using UnityEngine; + using System; + using System.Collections; + using System.Collections.Generic; + using System.Text; + using System.Threading; + using System.Text.RegularExpressions; + + using MessageID = System.UInt16; + using MessageLength = System.UInt16; + + /* + 这是KBEngine插件的核心模块 + 包括网络创建、持久化协议、entities的管理、以及引起对外可调用接口。 + + 一些可以参考的地方: + http://www.kbengine.org/docs/programming/clientsdkprogramming.html + http://www.kbengine.org/docs/programming/kbe_message_format.html + + http://www.kbengine.org/cn/docs/programming/clientsdkprogramming.html + http://www.kbengine.org/cn/docs/programming/kbe_message_format.html + */ + public class KBEngineApp + { + public static KBEngineApp app = null; + private NetworkInterfaceBase _networkInterface = null; + + KBEngineArgs _args = null; + + // 客户端的类别 + // http://www.kbengine.org/docs/programming/clientsdkprogramming.html + // http://www.kbengine.org/cn/docs/programming/clientsdkprogramming.html + public enum CLIENT_TYPE + { + // Mobile(Phone, Pad) + CLIENT_TYPE_MOBILE = 1, + + // Windows Application program + CLIENT_TYPE_WIN = 2, + + // Linux Application program + CLIENT_TYPE_LINUX = 3, + + // Mac Application program + CLIENT_TYPE_MAC = 4, + + // Web,HTML5,Flash + CLIENT_TYPE_BROWSER = 5, + + // bots + CLIENT_TYPE_BOTS = 6, + + // Mini-Client + CLIENT_TYPE_MINI = 7, + }; + + //加密通信类型 + public enum NETWORK_ENCRYPT_TYPE + { + //无加密 + ENCRYPT_TYPE_NONE = 0, + + //Blowfish + ENCRYPT_TYPE_BLOWFISH = 1, + }; + + public string username = "kbengine"; + public string password = "123456"; + + // 服务端分配的baseapp地址 + public string baseappIP = ""; + public UInt16 baseappTcpPort = 0; + public UInt16 baseappUdpPort = 0; + + // 当前状态 + public string currserver = ""; + public string currstate = ""; + + // 服务端下行以及客户端上行用于登录时处理的账号绑定的二进制信息 + // 该信息由用户自己进行扩展 + private byte[] _serverdatas = new byte[0]; + private byte[] _clientdatas = new byte[0]; + + // 通信协议加密,blowfish协议 + private byte[] _encryptedKey = new byte[0]; + + // 服务端与客户端的版本号以及协议MD5 + public string serverVersion = ""; + public string clientVersion = "2.4.5"; + public string serverScriptVersion = ""; + public string clientScriptVersion = "0.1.0"; + public string serverProtocolMD5 = "ACE55A2934030C0DA3446BA0E5FAB5DD"; + public string serverEntitydefMD5 = "46596D3750651E9F679C7775CD577E35"; + + // 当前玩家的实体id与实体类别 + public UInt64 entity_uuid = 0; + public Int32 entity_id = 0; + public string entity_type = ""; + + private List _controlledEntities = new List(); + + // 当前服务端最后一次同步过来的玩家位置 + private Vector3 _entityServerPos = new Vector3(0f, 0f, 0f); + + // space的数据,具体看API手册关于spaceData + // https://github.com/kbengine/kbengine/tree/master/docs/api + private Dictionary _spacedatas = new Dictionary(); + + // 所有实体都保存于这里, 请参看API手册关于entities部分 + // https://github.com/kbengine/kbengine/tree/master/docs/api + public Dictionary entities = new Dictionary(); + + // 在玩家View范围小于256个实体时我们可以通过一字节索引来找到entity + private List _entityIDAliasIDList = new List(); + private Dictionary _bufferedCreateEntityMessages = new Dictionary(); + + // 所有服务端错误码对应的错误描述 + private ServerErrorDescrs _serverErrs = new ServerErrorDescrs(); + + private System.DateTime _lastTickTime = System.DateTime.Now; + private System.DateTime _lastTickCBTime = System.DateTime.Now; + private System.DateTime _lastUpdateToServerTime = System.DateTime.Now; + + //上传玩家信息到服务器间隔,单位毫秒 + private float _updatePlayerToServerPeroid = 100.0f; + private const int _1MS_TO_100NS = 10000; + + //加密过滤器 + private EncryptionFilter _filter = null; + + // 玩家当前所在空间的id, 以及空间对应的资源 + public UInt32 spaceID = 0; + public string spaceResPath = ""; + public bool isLoadedGeometry = false; + + // 按照标准,每个客户端部分都应该包含这个属性 + public const string component = "client"; + + public KBEngineApp(KBEngineArgs args) + { + if (app != null) + throw new Exception("Only one instance of KBEngineApp!"); + + app = this; + Event.outEventsImmediately = !args.isMultiThreads; + + initialize(args); + } + + public static KBEngineApp getSingleton() + { + if(KBEngineApp.app == null) + { + throw new Exception("Please create KBEngineApp!"); + } + + return KBEngineApp.app; + } + + public virtual bool initialize(KBEngineArgs args) + { + _args = args; + _updatePlayerToServerPeroid = (float)_args.syncPlayerMS; + + EntityDef.init(); + + initNetwork(); + + // 注册事件 + installEvents(); + + return true; + } + + void initNetwork() + { + _filter = null; + Messages.init(); + _networkInterface = new NetworkInterfaceTCP(); + } + + void installEvents() + { + Event.registerIn(EventInTypes.createAccount, this, "createAccount"); + Event.registerIn(EventInTypes.login, this, "login"); + Event.registerIn(EventInTypes.logout, this, "logout"); + Event.registerIn(EventInTypes.reloginBaseapp, this, "reloginBaseapp"); + Event.registerIn(EventInTypes.resetPassword, this, "resetPassword"); + Event.registerIn(EventInTypes.bindAccountEmail, this, "bindAccountEmail"); + Event.registerIn(EventInTypes.newPassword, this, "newPassword"); + + // 内部事件 + Event.registerIn("_closeNetwork", this, "_closeNetwork"); + } + + public KBEngineArgs getInitArgs() + { + return _args; + } + + public virtual void destroy() + { + Dbg.WARNING_MSG("KBEngine::destroy()"); + + if(currserver == "baseapp") + logout(); + + reset(); + KBEngine.Event.deregisterIn(this); + resetMessages(); + + KBEngineApp.app = null; + } + + public NetworkInterfaceBase networkInterface() + { + return _networkInterface; + } + + public byte[] serverdatas() + { + return _serverdatas; + } + + public void entityServerPos(Vector3 pos) + { + _entityServerPos = pos; + } + + public void resetMessages() + { + _serverErrs.Clear(); + Messages.clear(); + EntityDef.reset(); + + Entity.clear(); + Dbg.DEBUG_MSG("KBEngine::resetMessages()"); + } + + public virtual void reset() + { + KBEngine.Event.clearFiredEvents(); + + clearEntities(true); + + currserver = ""; + currstate = ""; + _serverdatas = new byte[0]; + serverVersion = ""; + serverScriptVersion = ""; + + entity_uuid = 0; + entity_id = 0; + entity_type = ""; + + _entityIDAliasIDList.Clear(); + _bufferedCreateEntityMessages.Clear(); + + _lastTickTime = System.DateTime.Now; + _lastTickCBTime = System.DateTime.Now; + _lastUpdateToServerTime = System.DateTime.Now; + + spaceID = 0; + spaceResPath = ""; + isLoadedGeometry = false; + + if (_networkInterface != null) + _networkInterface.reset(); + + _filter = null; + _networkInterface = new NetworkInterfaceTCP(); + + _spacedatas.Clear(); + } + + public static bool validEmail(string strEmail) + { + return Regex.IsMatch(strEmail, @"^([\w-\.]+)@((\[[0-9]{1,3}\.[0-9]{1,3}\.[0-9]{1,3}\.) + |(([\w-]+\.)+))([a-zA-Z]{2,4}|[0-9]{1,3})(\]?)$"); + } + + /* + 插件的主循环处理函数 + */ + public virtual void process() + { + // 处理网络 + if (_networkInterface != null) + _networkInterface.process(); + + // 处理外层抛入的事件 + Event.processInEvents(); + + // 向服务端发送心跳以及同步角色信息到服务端 + sendTick(); + } + + /* + 当前玩家entity + */ + public Entity player() + { + Entity e; + if(entities.TryGetValue(entity_id, out e)) + return e; + + return null; + } + + public void _closeNetwork(NetworkInterfaceBase networkInterface) + { + networkInterface.close(); + } + + /* + 向服务端发送心跳以及同步角色信息到服务端 + */ + public void sendTick() + { + if(_networkInterface == null || _networkInterface.connected == false) + return; + + TimeSpan span = DateTime.Now - _lastTickTime; + + // 更新玩家的位置与朝向到服务端 + updatePlayerToServer(); + + if(_args.serverHeartbeatTick > 0 && span.Seconds > _args.serverHeartbeatTick) + { + span = _lastTickCBTime - _lastTickTime; + + // 如果心跳回调接收时间小于心跳发送时间,说明没有收到回调 + // 此时应该通知客户端掉线了 + if(span.Seconds < 0) + { + Dbg.ERROR_MSG("sendTick: Receive appTick timeout!"); + _networkInterface.close(); + return; + } + + Message Loginapp_onClientActiveTickMsg = null; + Message Baseapp_onClientActiveTickMsg = null; + + Messages.messages.TryGetValue("Loginapp_onClientActiveTick", out Loginapp_onClientActiveTickMsg); + Messages.messages.TryGetValue("Baseapp_onClientActiveTick", out Baseapp_onClientActiveTickMsg); + + if(currserver == "loginapp") + { + if(Loginapp_onClientActiveTickMsg != null) + { + Bundle bundle = Bundle.createObject(); + bundle.newMessage(Messages.messages["Loginapp_onClientActiveTick"]); + bundle.send(_networkInterface); + } + } + else + { + if(Baseapp_onClientActiveTickMsg != null) + { + Bundle bundle = Bundle.createObject(); + bundle.newMessage(Messages.messages["Baseapp_onClientActiveTick"]); + bundle.send(_networkInterface); + } + } + + _lastTickTime = System.DateTime.Now; + } + } + + /* + 服务器心跳回调 + */ + public void Client_onAppActiveTickCB() + { + _lastTickCBTime = System.DateTime.Now; + } + + /* + 与服务端握手,与任何一个进程连接之后应该第一时间进行握手 + */ + public void hello() + { + Bundle bundle = Bundle.createObject(); + if(currserver == "loginapp") + bundle.newMessage(Messages.messages["Loginapp_hello"]); + else + bundle.newMessage(Messages.messages["Baseapp_hello"]); + + _filter = null; + + if (_args.networkEncryptType == NETWORK_ENCRYPT_TYPE.ENCRYPT_TYPE_BLOWFISH) + { + _filter = new BlowfishFilter(); + _encryptedKey = ((BlowfishFilter)_filter).key(); + _networkInterface.setFilter(null); + } + + bundle.writeString(clientVersion); + bundle.writeString(clientScriptVersion); + bundle.writeBlob(_encryptedKey); + bundle.send(_networkInterface); + } + + /* + 握手之后服务端的回调 + */ + public void Client_onHelloCB(MemoryStream stream) + { + string str_serverVersion = stream.readString(); + serverScriptVersion = stream.readString(); + string currentServerProtocolMD5 = stream.readString(); + string currentServerEntitydefMD5 = stream.readString(); + Int32 ctype = stream.readInt32(); + + Dbg.DEBUG_MSG("KBEngine::Client_onHelloCB: verInfo(" + str_serverVersion + + "), scriptVersion("+ serverScriptVersion + "), srvProtocolMD5("+ serverProtocolMD5 + + "), srvEntitydefMD5("+ serverEntitydefMD5 + "), + ctype(" + ctype + ")!"); + + if(str_serverVersion != "Getting") + { + serverVersion = str_serverVersion; + + /* + if(serverProtocolMD5 != currentServerProtocolMD5) + { + Dbg.ERROR_MSG("Client_onHelloCB: digest not match! serverProtocolMD5=" + serverProtocolMD5 + "(server: " + currentServerProtocolMD5 + ")"); + Event.fireAll(EventOutTypes.onVersionNotMatch, clientVersion, serverVersion); + return; + } + */ + + if (serverEntitydefMD5 != currentServerEntitydefMD5) + { + Dbg.ERROR_MSG("Client_onHelloCB: digest not match! serverEntitydefMD5=" + serverEntitydefMD5 + "(server: " + currentServerEntitydefMD5 + ")"); + Event.fireAll(EventOutTypes.onVersionNotMatch, clientVersion, serverVersion); + return; + } + } + + if (_args.networkEncryptType == NETWORK_ENCRYPT_TYPE.ENCRYPT_TYPE_BLOWFISH) + { + _networkInterface.setFilter(_filter); + _filter = null; + } + + onServerDigest(); + + if(currserver == "baseapp") + { + onLogin_baseapp(); + } + else + { + onLogin_loginapp(); + } + } + + /* + 服务端错误描述导入了 + */ + public void Client_onImportServerErrorsDescr(MemoryStream stream) + { + // 无需实现,已由插件生成静态代码 + } + + /* + 从服务端返回的二进制流导入客户端消息协议 + */ + public void Client_onImportClientMessages(MemoryStream stream) + { + // 无需实现,已由插件生成静态代码 + } + + /* + 从服务端返回的二进制流导入客户端消息协议 + */ + public void Client_onImportClientEntityDef(MemoryStream stream) + { + // 无需实现,已由插件生成静态代码 + } + + public void Client_onImportClientSDK(MemoryStream stream) + { + int remainingFiles = 0; + remainingFiles = stream.readInt32(); + + string fileName; + fileName = stream.readString(); + + int fileSize = 0; + fileSize = stream.readInt32(); + + byte[] fileDatas = new byte[0]; + fileDatas = stream.readBlob(); + + Event.fireIn("onImportClientSDK", remainingFiles, fileName, fileSize, fileDatas); + } + + /* + 引擎版本不匹配 + */ + public void Client_onVersionNotMatch(MemoryStream stream) + { + serverVersion = stream.readString(); + + Dbg.ERROR_MSG("Client_onVersionNotMatch: verInfo=" + clientVersion + "(server: " + serverVersion + ")"); + Event.fireAll(EventOutTypes.onVersionNotMatch, clientVersion, serverVersion); + } + + /* + 脚本版本不匹配 + */ + public void Client_onScriptVersionNotMatch(MemoryStream stream) + { + serverScriptVersion = stream.readString(); + + Dbg.ERROR_MSG("Client_onScriptVersionNotMatch: verInfo=" + clientScriptVersion + "(server: " + serverScriptVersion + ")"); + Event.fireAll(EventOutTypes.onScriptVersionNotMatch, clientScriptVersion, serverScriptVersion); + } + + /* + 被服务端踢出 + */ + public void Client_onKicked(UInt16 failedcode) + { + Dbg.DEBUG_MSG("Client_onKicked: failedcode=" + failedcode + "(" + serverErr(failedcode) + ")"); + Event.fireAll(EventOutTypes.onKicked, failedcode); + } + + /* + 登录到服务端,必须登录完成loginapp与网关(baseapp),登录流程才算完毕 + */ + public void login(string username, string password, byte[] datas) + { + KBEngineApp.app.username = username; + KBEngineApp.app.password = password; + KBEngineApp.app._clientdatas = datas; + + KBEngineApp.app.login_loginapp(true); + } + + /* + 登录到服务端(loginapp), 登录成功后还必须登录到网关(baseapp)登录流程才算完毕 + */ + public void login_loginapp(bool noconnect) + { + if(noconnect) + { + reset(); + _networkInterface.connectTo(_args.ip, _args.port, onConnectTo_loginapp_callback, null); + } + else + { + Dbg.DEBUG_MSG("KBEngine::login_loginapp(): send login! username=" + username); + Bundle bundle = Bundle.createObject(); + bundle.newMessage(Messages.messages["Loginapp_login"]); + bundle.writeInt8((sbyte)_args.clientType); + bundle.writeBlob(KBEngineApp.app._clientdatas); + bundle.writeString(username); + bundle.writeString(password); + bundle.send(_networkInterface); + } + } + + private void onConnectTo_loginapp_callback(string ip, int port, bool success, object userData) + { + _lastTickCBTime = System.DateTime.Now; + + if(!success) + { + Dbg.ERROR_MSG(string.Format("KBEngine::login_loginapp(): connect {0}:{1} error!", ip, port)); + return; + } + + currserver = "loginapp"; + currstate = "login"; + + Dbg.DEBUG_MSG(string.Format("KBEngine::login_loginapp(): connect {0}:{1} success!", ip, port)); + + hello(); + } + + private void onLogin_loginapp() + { + _lastTickCBTime = System.DateTime.Now; + login_loginapp(false); + } + + /* + 登录到服务端,登录到网关(baseapp) + */ + public void login_baseapp(bool noconnect) + { + if(noconnect) + { + Event.fireOut(EventOutTypes.onLoginBaseapp); + + _networkInterface.reset(); + + if(_args.forceDisableUDP || baseappUdpPort == 0) + { + _networkInterface = new NetworkInterfaceTCP(); + _networkInterface.connectTo(baseappIP, baseappTcpPort, onConnectTo_baseapp_callback, null); + } + else + { + _networkInterface = new NetworkInterfaceKCP(); + _networkInterface.connectTo(baseappIP, baseappUdpPort, onConnectTo_baseapp_callback, null); + } + } + else + { + Bundle bundle = Bundle.createObject(); + bundle.newMessage(Messages.messages["Baseapp_loginBaseapp"]); + bundle.writeString(username); + bundle.writeString(password); + bundle.send(_networkInterface); + } + } + + private void onConnectTo_baseapp_callback(string ip, int port, bool success, object userData) + { + _lastTickCBTime = System.DateTime.Now; + + if(!success) + { + Dbg.ERROR_MSG(string.Format("KBEngine::login_baseapp(): connect {0}:{1} error!", ip, port)); + return; + } + + currserver = "baseapp"; + currstate = ""; + + Dbg.DEBUG_MSG(string.Format("KBEngine::login_baseapp(): connect {0}:{1} success!", ip, port)); + + hello(); + } + + private void onLogin_baseapp() + { + _lastTickCBTime = System.DateTime.Now; + login_baseapp(false); + } + + /* + 重登录到网关(baseapp) + 一些移动类应用容易掉线,可以使用该功能快速的重新与服务端建立通信 + */ + public void reloginBaseapp() + { + _lastTickTime = System.DateTime.Now; + _lastTickCBTime = System.DateTime.Now; + + if(_networkInterface.valid()) + return; + + Event.fireAll(EventOutTypes.onReloginBaseapp); + + _networkInterface.reset(); + + if(_args.forceDisableUDP || baseappUdpPort == 0) + { + _networkInterface = new NetworkInterfaceTCP(); + _networkInterface.connectTo(baseappIP, baseappTcpPort, onReConnectTo_baseapp_callback, null); + } + else + { + _networkInterface = new NetworkInterfaceKCP(); + _networkInterface.connectTo(baseappIP, baseappUdpPort, onReConnectTo_baseapp_callback, null); + } + } + + private void onReConnectTo_baseapp_callback(string ip, int port, bool success, object userData) + { + if(!success) + { + Dbg.ERROR_MSG(string.Format("KBEngine::reloginBaseapp(): connect {0}:{1} error!", ip, port)); + return; + } + + Dbg.DEBUG_MSG(string.Format("KBEngine::relogin_baseapp(): connect {0}:{1} success!", ip, port)); + + Bundle bundle = Bundle.createObject(); + bundle.newMessage(Messages.messages["Baseapp_reloginBaseapp"]); + bundle.writeString(username); + bundle.writeString(password); + bundle.writeUint64(entity_uuid); + bundle.writeInt32(entity_id); + bundle.send(_networkInterface); + + _lastTickCBTime = System.DateTime.Now; + } + + /* + 登出baseapp + */ + public void logout() + { + Bundle bundle = Bundle.createObject(); + bundle.newMessage(Messages.messages["Baseapp_logoutBaseapp"]); + bundle.writeUint64(entity_uuid); + bundle.writeInt32(entity_id); + bundle.send(_networkInterface); + } + + /* + 通过错误id得到错误描述 + */ + public string serverErr(UInt16 id) + { + return _serverErrs.serverErrStr(id); + } + + public void onOpenLoginapp_resetpassword() + { + Dbg.DEBUG_MSG("KBEngine::onOpenLoginapp_resetpassword: successfully!"); + currserver = "loginapp"; + currstate = "resetpassword"; + _lastTickCBTime = System.DateTime.Now; + + resetpassword_loginapp(false); + } + + /* + 重置密码, 通过loginapp + */ + public void resetPassword(string username) + { + KBEngineApp.app.username = username; + resetpassword_loginapp(true); + } + + /* + 重置密码, 通过loginapp + */ + public void resetpassword_loginapp(bool noconnect) + { + if(noconnect) + { + reset(); + _networkInterface.connectTo(_args.ip, _args.port, onConnectTo_resetpassword_callback, null); + } + else + { + Bundle bundle = Bundle.createObject(); + bundle.newMessage(Messages.messages["Loginapp_reqAccountResetPassword"]); + bundle.writeString(username); + bundle.send(_networkInterface); + } + } + + private void onConnectTo_resetpassword_callback(string ip, int port, bool success, object userData) + { + _lastTickCBTime = System.DateTime.Now; + + if(!success) + { + Dbg.ERROR_MSG(string.Format("KBEngine::resetpassword_loginapp(): connect {0}:{1} error!", ip, port)); + return; + } + + Dbg.DEBUG_MSG(string.Format("KBEngine::resetpassword_loginapp(): connect {0}:{1} success!", ip, port)); + onOpenLoginapp_resetpassword(); + } + + public void Client_onReqAccountResetPasswordCB(UInt16 failcode) + { + if(failcode != 0) + { + Dbg.ERROR_MSG("KBEngine::Client_onReqAccountResetPasswordCB: " + username + " failed! code=" + failcode + "(" + serverErr(failcode) + ")!"); + return; + } + + Dbg.DEBUG_MSG("KBEngine::Client_onReqAccountResetPasswordCB: " + username + " success!"); + } + + /* + 绑定Email,通过baseapp + */ + public void bindAccountEmail(string emailAddress) + { + Bundle bundle = Bundle.createObject(); + bundle.newMessage(Messages.messages["Baseapp_reqAccountBindEmail"]); + bundle.writeInt32(entity_id); + bundle.writeString(password); + bundle.writeString(emailAddress); + bundle.send(_networkInterface); + } + + public void Client_onReqAccountBindEmailCB(UInt16 failcode) + { + if(failcode != 0) + { + Dbg.ERROR_MSG("KBEngine::Client_onReqAccountBindEmailCB: " + username + " failed! code=" + failcode + "(" + serverErr(failcode) + ")!"); + return; + } + + Dbg.DEBUG_MSG("KBEngine::Client_onReqAccountBindEmailCB: " + username + " success!"); + } + + /* + 设置新密码,通过baseapp, 必须玩家登录在线操作所以是baseapp。 + */ + public void newPassword(string old_password, string new_password) + { + Bundle bundle = Bundle.createObject(); + bundle.newMessage(Messages.messages["Baseapp_reqAccountNewPassword"]); + bundle.writeInt32(entity_id); + bundle.writeString(old_password); + bundle.writeString(new_password); + bundle.send(_networkInterface); + } + + public void Client_onReqAccountNewPasswordCB(UInt16 failcode) + { + if(failcode != 0) + { + Dbg.ERROR_MSG("KBEngine::Client_onReqAccountNewPasswordCB: " + username + " failed! code=" + failcode + "(" + serverErr(failcode) + ")!"); + return; + } + + Dbg.DEBUG_MSG("KBEngine::Client_onReqAccountNewPasswordCB: " + username + " success!"); + } + + public void createAccount(string username, string password, byte[] datas) + { + KBEngineApp.app.username = username; + KBEngineApp.app.password = password; + KBEngineApp.app._clientdatas = datas; + + KBEngineApp.app.createAccount_loginapp(true); + } + + /* + 创建账号,通过loginapp + */ + public void createAccount_loginapp(bool noconnect) + { + if(noconnect) + { + reset(); + _networkInterface.connectTo(_args.ip, _args.port, onConnectTo_createAccount_callback, null); + } + else + { + Bundle bundle = Bundle.createObject(); + bundle.newMessage(Messages.messages["Loginapp_reqCreateAccount"]); + bundle.writeString(username); + bundle.writeString(password); + bundle.writeBlob(KBEngineApp.app._clientdatas); + bundle.send(_networkInterface); + } + } + + public void onOpenLoginapp_createAccount() + { + Dbg.DEBUG_MSG("KBEngine::onOpenLoginapp_createAccount: successfully!"); + currserver = "loginapp"; + currstate = "createAccount"; + _lastTickCBTime = System.DateTime.Now; + + createAccount_loginapp(false); + } + + private void onConnectTo_createAccount_callback(string ip, int port, bool success, object userData) + { + _lastTickCBTime = System.DateTime.Now; + + if(!success) + { + Dbg.ERROR_MSG(string.Format("KBEngine::createAccount_loginapp(): connect {0}:{1} error!", ip, port)); + return; + } + + Dbg.DEBUG_MSG(string.Format("KBEngine::createAccount_loginapp(): connect {0}:{1} success!", ip, port)); + onOpenLoginapp_createAccount(); + } + + /* + 获得了服务端摘要信息, 摘要包括协议MD5, entitydefMD5 + */ + public void onServerDigest() + { + } + + /* + 登录loginapp失败了 + */ + public void Client_onLoginFailed(MemoryStream stream) + { + UInt16 failedcode = stream.readUint16(); + _serverdatas = stream.readBlob(); + Dbg.ERROR_MSG("KBEngine::Client_onLoginFailed: failedcode(" + failedcode + ":" + serverErr(failedcode) + "), datas(" + _serverdatas.Length + ")!"); + Event.fireAll(EventOutTypes.onLoginFailed, failedcode); + } + + /* + 登录loginapp成功了 + */ + public void Client_onLoginSuccessfully(MemoryStream stream) + { + var accountName = stream.readString(); + username = accountName; + baseappIP = stream.readString(); + baseappTcpPort = stream.readUint16(); + baseappUdpPort = stream.readUint16(); + _serverdatas = stream.readBlob(); + + Dbg.DEBUG_MSG("KBEngine::Client_onLoginSuccessfully: accountName(" + accountName + "), addr(" + + baseappIP + ":" + baseappTcpPort + "|" + baseappUdpPort + "), datas(" + _serverdatas.Length + ")!"); + + login_baseapp(true); + } + + /* + 登录baseapp失败了 + */ + public void Client_onLoginBaseappFailed(UInt16 failedcode) + { + Dbg.ERROR_MSG("KBEngine::Client_onLoginBaseappFailed: failedcode=" + failedcode + "("+ serverErr(failedcode) + ")!"); + Event.fireAll(EventOutTypes.onLoginBaseappFailed, failedcode); + } + + /* + 重登录baseapp失败了 + */ + public void Client_onReloginBaseappFailed(UInt16 failedcode) + { + Dbg.ERROR_MSG("KBEngine::Client_onReloginBaseappFailed: failedcode=" + failedcode + "(" + serverErr(failedcode) + ")!"); + Event.fireAll(EventOutTypes.onReloginBaseappFailed, failedcode); + } + + /* + 登录baseapp成功了 + */ + public void Client_onReloginBaseappSuccessfully(MemoryStream stream) + { + entity_uuid = stream.readUint64(); + Dbg.DEBUG_MSG("KBEngine::Client_onReloginBaseappSuccessfully: name(" + username + ")!"); + Event.fireAll(EventOutTypes.onReloginBaseappSuccessfully); + } + + /* + 服务端通知创建一个角色 + */ + public void Client_onCreatedProxies(UInt64 rndUUID, Int32 eid, string entityType) + { + Dbg.DEBUG_MSG("KBEngine::Client_onCreatedProxies: eid(" + eid + "), entityType(" + entityType + ")!"); + + entity_uuid = rndUUID; + entity_id = eid; + entity_type = entityType; + + if(!this.entities.ContainsKey(eid)) + { + ScriptModule module = null; + if(!EntityDef.moduledefs.TryGetValue(entityType, out module)) + { + Dbg.ERROR_MSG("KBEngine::Client_onCreatedProxies: not found module(" + entityType + ")!"); + return; + } + + Type runclass = module.entityScript; + if(runclass == null) + return; + + Entity entity = (Entity)Activator.CreateInstance(runclass); + entity.id = eid; + entity.className = entityType; + entity.onGetBase(); + + entities[eid] = entity; + + MemoryStream entityMessage = null; + _bufferedCreateEntityMessages.TryGetValue(eid, out entityMessage); + + if(entityMessage != null) + { + Client_onUpdatePropertys(entityMessage); + _bufferedCreateEntityMessages.Remove(eid); + entityMessage.reclaimObject(); + } + + entity.__init__(); + entity.attachComponents(); + entity.inited = true; + + if(_args.isOnInitCallPropertysSetMethods) + entity.callPropertysSetMethods(); + } + else + { + MemoryStream entityMessage = null; + _bufferedCreateEntityMessages.TryGetValue(eid, out entityMessage); + + if(entityMessage != null) + { + Client_onUpdatePropertys(entityMessage); + _bufferedCreateEntityMessages.Remove(eid); + entityMessage.reclaimObject(); + } + } + } + + public Entity findEntity(Int32 entityID) + { + Entity entity = null; + + if(!entities.TryGetValue(entityID, out entity)) + { + return null; + } + + return entity; + } + + /* + 通过流数据获得View实体的ID + */ + public Int32 getViewEntityIDFromStream(MemoryStream stream) + { + if (!_args.useAliasEntityID) + return stream.readInt32(); + + Int32 id = 0; + if(_entityIDAliasIDList.Count > 255) + { + id = stream.readInt32(); + } + else + { + byte aliasID = stream.readUint8(); + + // 如果为0且客户端上一步是重登陆或者重连操作并且服务端entity在断线期间一直处于在线状态 + // 则可以忽略这个错误, 因为cellapp可能一直在向baseapp发送同步消息, 当客户端重连上时未等 + // 服务端初始化步骤开始则收到同步信息, 此时这里就会出错。 + if(_entityIDAliasIDList.Count <= aliasID) + return 0; + + id = _entityIDAliasIDList[aliasID]; + } + + return id; + } + + /* + 服务端使用优化的方式更新实体属性数据 + */ + public void Client_onUpdatePropertysOptimized(MemoryStream stream) + { + Int32 eid = getViewEntityIDFromStream(stream); + onUpdatePropertys_(eid, stream); + } + + /* + 服务端更新实体属性数据 + */ + public void Client_onUpdatePropertys(MemoryStream stream) + { + Int32 eid = stream.readInt32(); + onUpdatePropertys_(eid, stream); + } + + public void onUpdatePropertys_(Int32 eid, MemoryStream stream) + { + Entity entity = null; + + if(!entities.TryGetValue(eid, out entity)) + { + MemoryStream entityMessage = null; + if(_bufferedCreateEntityMessages.TryGetValue(eid, out entityMessage)) + { + Dbg.ERROR_MSG("KBEngine::Client_onUpdatePropertys: entity(" + eid + ") not found!"); + return; + } + + MemoryStream stream1 = MemoryStream.createObject(); + stream1.wpos = stream.wpos; + stream1.rpos = stream.rpos - 4; + Array.Copy(stream.data(), stream1.data(), stream.wpos); + _bufferedCreateEntityMessages[eid] = stream1; + return; + } + + entity.onUpdatePropertys(stream); + } + + /* + 服务端使用优化的方式调用实体方法 + */ + public void Client_onRemoteMethodCallOptimized(MemoryStream stream) + { + Int32 eid = getViewEntityIDFromStream(stream); + onRemoteMethodCall_(eid, stream); + } + + /* + 服务端调用实体方法 + */ + public void Client_onRemoteMethodCall(MemoryStream stream) + { + Int32 eid = stream.readInt32(); + onRemoteMethodCall_(eid, stream); + } + + public void onRemoteMethodCall_(Int32 eid, MemoryStream stream) + { + Entity entity = null; + + if(!entities.TryGetValue(eid, out entity)) + { + Dbg.ERROR_MSG("KBEngine::Client_onRemoteMethodCall: entity(" + eid + ") not found!"); + return; + } + + entity.onRemoteMethodCall(stream); + } + + /* + 服务端通知一个实体进入了世界(如果实体是当前玩家则玩家第一次在一个space中创建了, 如果是其他实体则是其他实体进入了玩家的View) + */ + public void Client_onEntityEnterWorld(MemoryStream stream) + { + Int32 eid = stream.readInt32(); + if(entity_id > 0 && entity_id != eid) + _entityIDAliasIDList.Add(eid); + + UInt16 uentityType; + if(EntityDef.idmoduledefs.Count > 255) + uentityType = stream.readUint16(); + else + uentityType = stream.readUint8(); + + sbyte isOnGround = 1; + + if(stream.length() > 0) + isOnGround = stream.readInt8(); + + string entityType = EntityDef.idmoduledefs[uentityType].name; + // Dbg.DEBUG_MSG("KBEngine::Client_onEntityEnterWorld: " + entityType + "(" + eid + "), spaceID(" + KBEngineApp.app.spaceID + ")!"); + + Entity entity = null; + + if(!entities.TryGetValue(eid, out entity)) + { + MemoryStream entityMessage = null; + if(!_bufferedCreateEntityMessages.TryGetValue(eid, out entityMessage)) + { + Dbg.ERROR_MSG("KBEngine::Client_onEntityEnterWorld: entity(" + eid + ") not found!"); + return; + } + + ScriptModule module = null; + if(!EntityDef.moduledefs.TryGetValue(entityType, out module)) + { + Dbg.ERROR_MSG("KBEngine::Client_onEntityEnterWorld: not found module(" + entityType + ")!"); + } + + Type runclass = module.entityScript; + if(runclass == null) + return; + + entity = (Entity)Activator.CreateInstance(runclass); + entity.id = eid; + entity.className = entityType; + entity.onGetCell(); + + entities[eid] = entity; + + Client_onUpdatePropertys(entityMessage); + _bufferedCreateEntityMessages.Remove(eid); + entityMessage.reclaimObject(); + + entity.isOnGround = isOnGround > 0; + entity.onDirectionChanged(entity.direction); + entity.onPositionChanged(entity.position); + + entity.__init__(); + entity.attachComponents(); + entity.inited = true; + entity.inWorld = true; + entity.enterWorld(); + + if(_args.isOnInitCallPropertysSetMethods) + entity.callPropertysSetMethods(); + } + else + { + if(!entity.inWorld) + { + // 安全起见, 这里清空一下 + // 如果服务端上使用giveClientTo切换控制权 + // 之前的实体已经进入世界, 切换后的实体也进入世界, 这里可能会残留之前那个实体进入世界的信息 + _entityIDAliasIDList.Clear(); + clearEntities(false); + entities[entity.id] = entity; + + entity.onGetCell(); + + entity.onDirectionChanged(entity.direction); + entity.onPositionChanged(entity.position); + + _entityServerPos = entity.position; + entity.isOnGround = isOnGround > 0; + entity.inWorld = true; + entity.enterWorld(); + + if(_args.isOnInitCallPropertysSetMethods) + entity.callPropertysSetMethods(); + } + } + } + + /* + 服务端使用优化的方式通知一个实体离开了世界(如果实体是当前玩家则玩家离开了space, 如果是其他实体则是其他实体离开了玩家的View) + */ + public void Client_onEntityLeaveWorldOptimized(MemoryStream stream) + { + Int32 eid = getViewEntityIDFromStream(stream); + KBEngineApp.app.Client_onEntityLeaveWorld(eid); + } + + /* + 服务端通知一个实体离开了世界(如果实体是当前玩家则玩家离开了space, 如果是其他实体则是其他实体离开了玩家的View) + */ + public void Client_onEntityLeaveWorld(Int32 eid) + { + Entity entity = null; + + if(!entities.TryGetValue(eid, out entity)) + { + Dbg.ERROR_MSG("KBEngine::Client_onEntityLeaveWorld: entity(" + eid + ") not found!"); + return; + } + + if(entity.inWorld) + entity.leaveWorld(); + + if(entity_id == eid) + { + clearSpace(false); + entity.onLoseCell(); + } + else + { + if(_controlledEntities.Remove(entity)) + Event.fireOut(EventOutTypes.onLoseControlledEntity, entity); + + entities.Remove(eid); + entity.destroy(); + _entityIDAliasIDList.Remove(eid); + } + } + + /* + 服务端通知当前玩家进入了一个新的space + */ + public void Client_onEntityEnterSpace(MemoryStream stream) + { + Int32 eid = stream.readInt32(); + spaceID = stream.readUint32(); + + sbyte isOnGround = 1; + + if(stream.length() > 0) + isOnGround = stream.readInt8(); + + Entity entity = null; + + if(!entities.TryGetValue(eid, out entity)) + { + Dbg.ERROR_MSG("KBEngine::Client_onEntityEnterSpace: entity(" + eid + ") not found!"); + return; + } + + entity.isOnGround = isOnGround > 0; + _entityServerPos = entity.position; + entity.enterSpace(); + } + + /* + 服务端通知当前玩家离开了space + */ + public void Client_onEntityLeaveSpace(Int32 eid) + { + Entity entity = null; + + if(!entities.TryGetValue(eid, out entity)) + { + Dbg.ERROR_MSG("KBEngine::Client_onEntityLeaveSpace: entity(" + eid + ") not found!"); + return; + } + + entity.leaveSpace(); + clearSpace(false); + } + + /* + 账号创建返回结果 + */ + public void Client_onCreateAccountResult(MemoryStream stream) + { + UInt16 retcode = stream.readUint16(); + byte[] datas = stream.readBlob(); + + Event.fireOut(EventOutTypes.onCreateAccountResult, retcode, datas); + + if(retcode != 0) + { + Dbg.WARNING_MSG("KBEngine::Client_onCreateAccountResult: " + username + " create is failed! code=" + retcode + "(" + serverErr(retcode)+ ")!"); + return; + } + + Dbg.DEBUG_MSG("KBEngine::Client_onCreateAccountResult: " + username + " create is successfully!"); + } + + /* + 告诉客户端:你当前负责(或取消)控制谁的位移同步 + */ + public void Client_onControlEntity(Int32 eid, sbyte isControlled) + { + Entity entity = null; + + if (!entities.TryGetValue(eid, out entity)) + { + Dbg.ERROR_MSG("KBEngine::Client_onControlEntity: entity(" + eid + ") not found!"); + return; + } + + var isCont = isControlled != 0; + if (isCont) + { + // 如果被控制者是玩家自己,那表示玩家自己被其它人控制了 + // 所以玩家自己不应该进入这个被控制列表 + if (player().id != entity.id) + { + _controlledEntities.Add(entity); + } + } + else + { + _controlledEntities.Remove(entity); + } + + entity.isControlled = isCont; + + try + { + entity.onControlled(isCont); + Event.fireOut(EventOutTypes.onControlled, entity, isCont); + } + catch (Exception e) + { + Dbg.ERROR_MSG(string.Format("KBEngine::Client_onControlEntity: entity id = '{0}', is controlled = '{1}', error = '{1}'", eid, isCont, e)); + } + } + + /* + 更新当前玩家的位置与朝向到服务端, 可以通过开关_syncPlayerMS关闭这个机制 + */ + public void updatePlayerToServer() + { + if(_updatePlayerToServerPeroid <= 0.01f || spaceID == 0) + { + return; + } + + var now = DateTime.Now; + TimeSpan span = now - _lastUpdateToServerTime; + + if (span.Ticks < _updatePlayerToServerPeroid * _1MS_TO_100NS) + return; + + Entity playerEntity = player(); + if (playerEntity == null || playerEntity.inWorld == false || playerEntity.isControlled) + return; + + _lastUpdateToServerTime = now - (span - TimeSpan.FromTicks(Convert.ToInt64(_updatePlayerToServerPeroid * _1MS_TO_100NS))); + + Vector3 position = playerEntity.position; + Vector3 direction = playerEntity.direction; + + bool posHasChanged = Vector3.Distance(playerEntity._entityLastLocalPos, position) > 0.001f; + bool dirHasChanged = Vector3.Distance(playerEntity._entityLastLocalDir, direction) > 0.001f; + + if(posHasChanged || dirHasChanged) + { + playerEntity._entityLastLocalPos = position; + playerEntity._entityLastLocalDir = direction; + + Bundle bundle = Bundle.createObject(); + bundle.newMessage(Messages.messages["Baseapp_onUpdateDataFromClient"]); + bundle.writeFloat(position.x); + bundle.writeFloat(position.y); + bundle.writeFloat(position.z); + + double x = ((double)direction.x / 360 * (System.Math.PI * 2)); + double y = ((double)direction.y / 360 * (System.Math.PI * 2)); + double z = ((double)direction.z / 360 * (System.Math.PI * 2)); + + // 根据弧度转角度公式会出现负数 + // unity会自动转化到0~360度之间,这里需要做一个还原 + if(x - System.Math.PI > 0.0) + x -= System.Math.PI * 2; + + if(y - System.Math.PI > 0.0) + y -= System.Math.PI * 2; + + if(z - System.Math.PI > 0.0) + z -= System.Math.PI * 2; + + bundle.writeFloat((float)x); + bundle.writeFloat((float)y); + bundle.writeFloat((float)z); + bundle.writeUint8((Byte)(playerEntity.isOnGround == true ? 1 : 0)); + bundle.writeUint32(spaceID); + bundle.send(_networkInterface); + } + + // 开始同步所有被控制了的entity的位置 + for (int i = 0; i < _controlledEntities.Count; ++i) + { + var entity = _controlledEntities[i]; + position = entity.position; + direction = entity.direction; + + posHasChanged = Vector3.Distance(entity._entityLastLocalPos, position) > 0.001f; + dirHasChanged = Vector3.Distance(entity._entityLastLocalDir, direction) > 0.001f; + + if (posHasChanged || dirHasChanged) + { + entity._entityLastLocalPos = position; + entity._entityLastLocalDir = direction; + + Bundle bundle = Bundle.createObject(); + bundle.newMessage(Messages.messages["Baseapp_onUpdateDataFromClientForControlledEntity"]); + bundle.writeInt32(entity.id); + bundle.writeFloat(position.x); + bundle.writeFloat(position.y); + bundle.writeFloat(position.z); + + double x = ((double)direction.x / 360 * (System.Math.PI * 2)); + double y = ((double)direction.y / 360 * (System.Math.PI * 2)); + double z = ((double)direction.z / 360 * (System.Math.PI * 2)); + + // 根据弧度转角度公式会出现负数 + // unity会自动转化到0~360度之间,这里需要做一个还原 + if(x - System.Math.PI > 0.0) + x -= System.Math.PI * 2; + + if(y - System.Math.PI > 0.0) + y -= System.Math.PI * 2; + + if(z - System.Math.PI > 0.0) + z -= System.Math.PI * 2; + + bundle.writeFloat((float)x); + bundle.writeFloat((float)y); + bundle.writeFloat((float)z); + bundle.writeUint8((Byte)(entity.isOnGround == true ? 1 : 0)); + bundle.writeUint32(spaceID); + bundle.send(_networkInterface); + } + } + } + + /* + 当前space添加了关于几何等信息的映射资源 + 客户端可以通过这个资源信息来加载对应的场景 + */ + public void addSpaceGeometryMapping(UInt32 uspaceID, string respath) + { + Dbg.DEBUG_MSG("KBEngine::addSpaceGeometryMapping: spaceID(" + uspaceID + "), respath(" + respath + ")!"); + + isLoadedGeometry = true; + spaceID = uspaceID; + spaceResPath = respath; + Event.fireOut(EventOutTypes.addSpaceGeometryMapping, spaceResPath); + } + + public void clearSpace(bool isall) + { + _entityIDAliasIDList.Clear(); + _spacedatas.Clear(); + clearEntities(isall); + isLoadedGeometry = false; + spaceID = 0; + } + + public void clearEntities(bool isall) + { + _controlledEntities.Clear(); + + if (!isall) + { + Entity entity = player(); + + foreach (KeyValuePair dic in entities) + { + if(dic.Key == entity.id) + continue; + + if(dic.Value.inWorld) + dic.Value.leaveWorld(); + + dic.Value.destroy(); + } + + entities.Clear(); + entities[entity.id] = entity; + } + else + { + foreach (KeyValuePair dic in entities) + { + if(dic.Value.inWorld) + dic.Value.leaveWorld(); + + dic.Value.destroy(); + } + + entities.Clear(); + } + } + + /* + 服务端初始化客户端的spacedata, spacedata请参考API + */ + public void Client_initSpaceData(MemoryStream stream) + { + clearSpace(false); + spaceID = stream.readUint32(); + + while(stream.length() > 0) + { + string key = stream.readString(); + string val = stream.readString(); + Client_setSpaceData(spaceID, key, val); + } + + Dbg.DEBUG_MSG("KBEngine::Client_initSpaceData: spaceID(" + spaceID + "), size(" + _spacedatas.Count + ")!"); + } + + /* + 服务端设置客户端的spacedata, spacedata请参考API + */ + public void Client_setSpaceData(UInt32 spaceID, string key, string value) + { + Dbg.DEBUG_MSG("KBEngine::Client_setSpaceData: spaceID(" + spaceID + "), key(" + key + "), value(" + value + ")!"); + _spacedatas[key] = value; + + if(key == "_mapping") + addSpaceGeometryMapping(spaceID, value); + + Event.fireOut(EventOutTypes.onSetSpaceData, spaceID, key, value); + } + + /* + 服务端删除客户端的spacedata, spacedata请参考API + */ + public void Client_delSpaceData(UInt32 spaceID, string key) + { + Dbg.DEBUG_MSG("KBEngine::Client_delSpaceData: spaceID(" + spaceID + "), key(" + key + ")"); + _spacedatas.Remove(key); + Event.fireOut(EventOutTypes.onDelSpaceData, spaceID, key); + } + + public string getSpaceData(string key) + { + string val = ""; + + if(!_spacedatas.TryGetValue(key, out val)) + { + return ""; + } + + return val; + } + + /* + 服务端通知强制销毁一个实体 + */ + public void Client_onEntityDestroyed(Int32 eid) + { + Dbg.DEBUG_MSG("KBEngine::Client_onEntityDestroyed: entity(" + eid + ")"); + + Entity entity = null; + + if(!entities.TryGetValue(eid, out entity)) + { + Dbg.ERROR_MSG("KBEngine::Client_onEntityDestroyed: entity(" + eid + ") not found!"); + return; + } + + if(entity.inWorld) + { + if(entity_id == eid) + clearSpace(false); + + entity.leaveWorld(); + } + + if(_controlledEntities.Remove(entity)) + Event.fireOut(EventOutTypes.onLoseControlledEntity, entity); + + entities.Remove(eid); + entity.destroy(); + } + + /* + 服务端更新玩家的基础位置, 客户端以这个基础位置加上便宜值计算出玩家周围实体的坐标 + */ + public void Client_onUpdateBasePos(float x, float y, float z) + { + _entityServerPos.x = x; + _entityServerPos.y = y; + _entityServerPos.z = z; + + var entity = player(); + if (entity != null && entity.isControlled) + { + entity.position.Set(_entityServerPos.x, _entityServerPos.y, _entityServerPos.z); + Event.fireOut(EventOutTypes.updatePosition, entity); + entity.onUpdateVolatileData(); + } + } + + public void Client_onUpdateBasePosXZ(float x, float z) + { + _entityServerPos.x = x; + _entityServerPos.z = z; + + var entity = player(); + if (entity != null && entity.isControlled) + { + entity.position.x = _entityServerPos.x; + entity.position.z = _entityServerPos.z; + Event.fireOut(EventOutTypes.updatePosition, entity); + entity.onUpdateVolatileData(); + } + } + + public void Client_onUpdateBaseDir(MemoryStream stream) + { + float yaw, pitch, roll; + yaw = stream.readFloat() * 360 / ((float)System.Math.PI * 2); + pitch = stream.readFloat() * 360 / ((float)System.Math.PI * 2); + roll = stream.readFloat() * 360 / ((float)System.Math.PI * 2); + + var entity = player(); + if (entity != null && entity.isControlled) + { + entity.direction.Set(roll, pitch, yaw); + Event.fireOut(EventOutTypes.set_direction, entity); + entity.onUpdateVolatileData(); + } + } + + public void Client_onUpdateData(MemoryStream stream) + { + Int32 eid = getViewEntityIDFromStream(stream); + Entity entity = null; + + if(!entities.TryGetValue(eid, out entity)) + { + Dbg.ERROR_MSG("KBEngine::Client_onUpdateData: entity(" + eid + ") not found!"); + return; + } + } + + /* + 服务端强制设置了玩家的坐标 + 例如:在服务端使用avatar.position=(0,0,0), 或者玩家位置与速度异常时会强制拉回到一个位置 + */ + public void Client_onSetEntityPosAndDir(MemoryStream stream) + { + Int32 eid = stream.readInt32(); + Entity entity = null; + + if(!entities.TryGetValue(eid, out entity)) + { + Dbg.ERROR_MSG("KBEngine::Client_onSetEntityPosAndDir: entity(" + eid + ") not found!"); + return; + } + + Vector3 old_position = new Vector3(entity.position.x, entity.position.y, entity.position.z); + Vector3 old_direction = new Vector3(entity.direction.x, entity.direction.y, entity.direction.z); + + entity.position.x = stream.readFloat(); + entity.position.y = stream.readFloat(); + entity.position.z = stream.readFloat(); + + entity.direction.x = stream.readFloat(); + entity.direction.y = stream.readFloat(); + entity.direction.z = stream.readFloat(); + + entity._entityLastLocalPos = entity.position; + entity._entityLastLocalDir = entity.direction; + + entity.onDirectionChanged(old_direction); + entity.onPositionChanged(old_position); + } + + public void Client_onUpdateData_ypr(MemoryStream stream) + { + Int32 eid = getViewEntityIDFromStream(stream); + + float y = stream.readFloat(); + float p = stream.readFloat(); + float r = stream.readFloat(); + + _updateVolatileData(eid, KBEMath.KBE_FLT_MAX, KBEMath.KBE_FLT_MAX, KBEMath.KBE_FLT_MAX, y, p, r, -1, false); + } + + public void Client_onUpdateData_yp(MemoryStream stream) + { + Int32 eid = getViewEntityIDFromStream(stream); + + float y = stream.readFloat(); + float p = stream.readFloat(); + + _updateVolatileData(eid, KBEMath.KBE_FLT_MAX, KBEMath.KBE_FLT_MAX, KBEMath.KBE_FLT_MAX, y, p, KBEMath.KBE_FLT_MAX, -1, false); + } + + public void Client_onUpdateData_yr(MemoryStream stream) + { + Int32 eid = getViewEntityIDFromStream(stream); + + float y = stream.readFloat(); + float r = stream.readFloat(); + + _updateVolatileData(eid, KBEMath.KBE_FLT_MAX, KBEMath.KBE_FLT_MAX, KBEMath.KBE_FLT_MAX, y, KBEMath.KBE_FLT_MAX, r, -1, false); + } + + public void Client_onUpdateData_pr(MemoryStream stream) + { + Int32 eid = getViewEntityIDFromStream(stream); + + float p = stream.readFloat(); + float r = stream.readFloat(); + + _updateVolatileData(eid, KBEMath.KBE_FLT_MAX, KBEMath.KBE_FLT_MAX, KBEMath.KBE_FLT_MAX, KBEMath.KBE_FLT_MAX, p, r, -1, false); + } + + public void Client_onUpdateData_y(MemoryStream stream) + { + Int32 eid = getViewEntityIDFromStream(stream); + + float y = stream.readFloat(); + + _updateVolatileData(eid, KBEMath.KBE_FLT_MAX, KBEMath.KBE_FLT_MAX, KBEMath.KBE_FLT_MAX, y, KBEMath.KBE_FLT_MAX, KBEMath.KBE_FLT_MAX, -1, false); + } + + public void Client_onUpdateData_p(MemoryStream stream) + { + Int32 eid = getViewEntityIDFromStream(stream); + + float p = stream.readFloat(); + + _updateVolatileData(eid, KBEMath.KBE_FLT_MAX, KBEMath.KBE_FLT_MAX, KBEMath.KBE_FLT_MAX, KBEMath.KBE_FLT_MAX, p, KBEMath.KBE_FLT_MAX, -1, false); + } + + public void Client_onUpdateData_r(MemoryStream stream) + { + Int32 eid = getViewEntityIDFromStream(stream); + + float r = stream.readFloat(); + + _updateVolatileData(eid, KBEMath.KBE_FLT_MAX, KBEMath.KBE_FLT_MAX, KBEMath.KBE_FLT_MAX, KBEMath.KBE_FLT_MAX, KBEMath.KBE_FLT_MAX, r, -1, false); + } + + public void Client_onUpdateData_xz(MemoryStream stream) + { + Int32 eid = getViewEntityIDFromStream(stream); + + float x = stream.readFloat(); + float z = stream.readFloat(); + + _updateVolatileData(eid, x, KBEMath.KBE_FLT_MAX, z, KBEMath.KBE_FLT_MAX, KBEMath.KBE_FLT_MAX, KBEMath.KBE_FLT_MAX, 1, false); + } + + public void Client_onUpdateData_xz_ypr(MemoryStream stream) + { + Int32 eid = getViewEntityIDFromStream(stream); + + float x = stream.readFloat(); + float z = stream.readFloat(); + + float y = stream.readFloat(); + float p = stream.readFloat(); + float r = stream.readFloat(); + + _updateVolatileData(eid, x, KBEMath.KBE_FLT_MAX, z, y, p, r, 1, false); + } + + public void Client_onUpdateData_xz_yp(MemoryStream stream) + { + Int32 eid = getViewEntityIDFromStream(stream); + + float x = stream.readFloat(); + float z = stream.readFloat(); + + float y = stream.readFloat(); + float p = stream.readFloat(); + + _updateVolatileData(eid, x, KBEMath.KBE_FLT_MAX, z, y, p, KBEMath.KBE_FLT_MAX, 1, false); + } + + public void Client_onUpdateData_xz_yr(MemoryStream stream) + { + Int32 eid = getViewEntityIDFromStream(stream); + + float x = stream.readFloat(); + float z = stream.readFloat(); + + float y = stream.readFloat(); + float r = stream.readFloat(); + + _updateVolatileData(eid, x, KBEMath.KBE_FLT_MAX, z, y, KBEMath.KBE_FLT_MAX, r, 1, false); + } + + public void Client_onUpdateData_xz_pr(MemoryStream stream) + { + Int32 eid = getViewEntityIDFromStream(stream); + + float x = stream.readFloat(); + float z = stream.readFloat(); + + float p = stream.readFloat(); + float r = stream.readFloat(); + + _updateVolatileData(eid, x, KBEMath.KBE_FLT_MAX, z, KBEMath.KBE_FLT_MAX, p, r, 1, false); + } + + public void Client_onUpdateData_xz_y(MemoryStream stream) + { + Int32 eid = getViewEntityIDFromStream(stream); + + float x = stream.readFloat(); + float z = stream.readFloat(); + + float yaw = stream.readFloat(); + + _updateVolatileData(eid, x, KBEMath.KBE_FLT_MAX, z, yaw, KBEMath.KBE_FLT_MAX, KBEMath.KBE_FLT_MAX, 1, false); + } + + public void Client_onUpdateData_xz_p(MemoryStream stream) + { + Int32 eid = getViewEntityIDFromStream(stream); + + float x = stream.readFloat(); + float z = stream.readFloat(); + + float p = stream.readFloat(); + + _updateVolatileData(eid, x, KBEMath.KBE_FLT_MAX, z, KBEMath.KBE_FLT_MAX, p, KBEMath.KBE_FLT_MAX, 1, false); + } + + public void Client_onUpdateData_xz_r(MemoryStream stream) + { + Int32 eid = getViewEntityIDFromStream(stream); + + float x = stream.readFloat(); + float z = stream.readFloat(); + + float r = stream.readFloat(); + + _updateVolatileData(eid, x, KBEMath.KBE_FLT_MAX, z, KBEMath.KBE_FLT_MAX, KBEMath.KBE_FLT_MAX, r, 1, false); + } + + public void Client_onUpdateData_xyz(MemoryStream stream) + { + Int32 eid = getViewEntityIDFromStream(stream); + + float x = stream.readFloat(); + float y = stream.readFloat(); + float z = stream.readFloat(); + + _updateVolatileData(eid, x, y, z, KBEMath.KBE_FLT_MAX, KBEMath.KBE_FLT_MAX, KBEMath.KBE_FLT_MAX, 0, false); + } + + public void Client_onUpdateData_xyz_ypr(MemoryStream stream) + { + Int32 eid = getViewEntityIDFromStream(stream); + + float x = stream.readFloat(); + float y = stream.readFloat(); + float z = stream.readFloat(); + + float yaw = stream.readFloat(); + float p = stream.readFloat(); + float r = stream.readFloat(); + + _updateVolatileData(eid, x, y, z, yaw, p, r, 0, false); + } + + public void Client_onUpdateData_xyz_yp(MemoryStream stream) + { + Int32 eid = getViewEntityIDFromStream(stream); + + float x = stream.readFloat(); + float y = stream.readFloat(); + float z = stream.readFloat(); + + float yaw = stream.readFloat(); + float p = stream.readFloat(); + + _updateVolatileData(eid, x, y, z, yaw, p, KBEMath.KBE_FLT_MAX, 0, false); + } + + public void Client_onUpdateData_xyz_yr(MemoryStream stream) + { + Int32 eid = getViewEntityIDFromStream(stream); + + float x = stream.readFloat(); + float y = stream.readFloat(); + float z = stream.readFloat(); + + float yaw = stream.readFloat(); + float r = stream.readFloat(); + + _updateVolatileData(eid, x, y, z, yaw, KBEMath.KBE_FLT_MAX, r, 0, false); + } + + public void Client_onUpdateData_xyz_pr(MemoryStream stream) + { + Int32 eid = getViewEntityIDFromStream(stream); + + float x = stream.readFloat(); + float y = stream.readFloat(); + float z = stream.readFloat(); + + float p = stream.readFloat(); + float r = stream.readFloat(); + + _updateVolatileData(eid, x, y, z, KBEMath.KBE_FLT_MAX, p, r, 0, false); + } + + public void Client_onUpdateData_xyz_y(MemoryStream stream) + { + Int32 eid = getViewEntityIDFromStream(stream); + + float x = stream.readFloat(); + float y = stream.readFloat(); + float z = stream.readFloat(); + + float yaw = stream.readFloat(); + + _updateVolatileData(eid, x, y, z, yaw, KBEMath.KBE_FLT_MAX, KBEMath.KBE_FLT_MAX, 0, false); + } + + public void Client_onUpdateData_xyz_p(MemoryStream stream) + { + Int32 eid = getViewEntityIDFromStream(stream); + + float x = stream.readFloat(); + float y = stream.readFloat(); + float z = stream.readFloat(); + + float p = stream.readFloat(); + + _updateVolatileData(eid, x, y, z, KBEMath.KBE_FLT_MAX, p, KBEMath.KBE_FLT_MAX, 0, false); + } + + public void Client_onUpdateData_xyz_r(MemoryStream stream) + { + Int32 eid = getViewEntityIDFromStream(stream); + + float x = stream.readFloat(); + float y = stream.readFloat(); + float z = stream.readFloat(); + + float r = stream.readFloat(); + + _updateVolatileData(eid, x, y, z, KBEMath.KBE_FLT_MAX, KBEMath.KBE_FLT_MAX, r, 0, false); + } + + public void Client_onUpdateData_ypr_optimized(MemoryStream stream) + { + Int32 eid = getViewEntityIDFromStream(stream); + + SByte y = stream.readInt8(); + SByte p = stream.readInt8(); + SByte r = stream.readInt8(); + + _updateVolatileData(eid, KBEMath.KBE_FLT_MAX, KBEMath.KBE_FLT_MAX, KBEMath.KBE_FLT_MAX, y, p, r, -1, true); + } + + public void Client_onUpdateData_yp_optimized(MemoryStream stream) + { + Int32 eid = getViewEntityIDFromStream(stream); + + SByte y = stream.readInt8(); + SByte p = stream.readInt8(); + + _updateVolatileData(eid, KBEMath.KBE_FLT_MAX, KBEMath.KBE_FLT_MAX, KBEMath.KBE_FLT_MAX, y, p, KBEMath.KBE_FLT_MAX, -1, true); + } + + public void Client_onUpdateData_yr_optimized(MemoryStream stream) + { + Int32 eid = getViewEntityIDFromStream(stream); + + SByte y = stream.readInt8(); + SByte r = stream.readInt8(); + + _updateVolatileData(eid, KBEMath.KBE_FLT_MAX, KBEMath.KBE_FLT_MAX, KBEMath.KBE_FLT_MAX, y, KBEMath.KBE_FLT_MAX, r, -1, true); + } + + public void Client_onUpdateData_pr_optimized(MemoryStream stream) + { + Int32 eid = getViewEntityIDFromStream(stream); + + SByte p = stream.readInt8(); + SByte r = stream.readInt8(); + + _updateVolatileData(eid, KBEMath.KBE_FLT_MAX, KBEMath.KBE_FLT_MAX, KBEMath.KBE_FLT_MAX, KBEMath.KBE_FLT_MAX, p, r, -1, true); + } + + public void Client_onUpdateData_y_optimized(MemoryStream stream) + { + Int32 eid = getViewEntityIDFromStream(stream); + + SByte y = stream.readInt8(); + + _updateVolatileData(eid, KBEMath.KBE_FLT_MAX, KBEMath.KBE_FLT_MAX, KBEMath.KBE_FLT_MAX, y, KBEMath.KBE_FLT_MAX, KBEMath.KBE_FLT_MAX, -1, true); + } + + public void Client_onUpdateData_p_optimized(MemoryStream stream) + { + Int32 eid = getViewEntityIDFromStream(stream); + + SByte p = stream.readInt8(); + + _updateVolatileData(eid, KBEMath.KBE_FLT_MAX, KBEMath.KBE_FLT_MAX, KBEMath.KBE_FLT_MAX, KBEMath.KBE_FLT_MAX, p, KBEMath.KBE_FLT_MAX, -1, true); + } + + public void Client_onUpdateData_r_optimized(MemoryStream stream) + { + Int32 eid = getViewEntityIDFromStream(stream); + + SByte r = stream.readInt8(); + + _updateVolatileData(eid, KBEMath.KBE_FLT_MAX, KBEMath.KBE_FLT_MAX, KBEMath.KBE_FLT_MAX, KBEMath.KBE_FLT_MAX, KBEMath.KBE_FLT_MAX, r, -1, true); + } + + public void Client_onUpdateData_xz_optimized(MemoryStream stream) + { + Int32 eid = getViewEntityIDFromStream(stream); + + Vector2 xz = stream.readPackXZ(); + + _updateVolatileData(eid, xz[0], KBEMath.KBE_FLT_MAX, xz[1], KBEMath.KBE_FLT_MAX, KBEMath.KBE_FLT_MAX, KBEMath.KBE_FLT_MAX, 1, true); + } + + public void Client_onUpdateData_xz_ypr_optimized(MemoryStream stream) + { + Int32 eid = getViewEntityIDFromStream(stream); + + Vector2 xz = stream.readPackXZ(); + + SByte y = stream.readInt8(); + SByte p = stream.readInt8(); + SByte r = stream.readInt8(); + + _updateVolatileData(eid, xz[0], KBEMath.KBE_FLT_MAX, xz[1], y, p, r, 1, true); + } + + public void Client_onUpdateData_xz_yp_optimized(MemoryStream stream) + { + Int32 eid = getViewEntityIDFromStream(stream); + + Vector2 xz = stream.readPackXZ(); + + SByte y = stream.readInt8(); + SByte p = stream.readInt8(); + + _updateVolatileData(eid, xz[0], KBEMath.KBE_FLT_MAX, xz[1], y, p, KBEMath.KBE_FLT_MAX, 1, true); + } + + public void Client_onUpdateData_xz_yr_optimized(MemoryStream stream) + { + Int32 eid = getViewEntityIDFromStream(stream); + + Vector2 xz = stream.readPackXZ(); + + SByte y = stream.readInt8(); + SByte r = stream.readInt8(); + + _updateVolatileData(eid, xz[0], KBEMath.KBE_FLT_MAX, xz[1], y, KBEMath.KBE_FLT_MAX, r, 1, true); + } + + public void Client_onUpdateData_xz_pr_optimized(MemoryStream stream) + { + Int32 eid = getViewEntityIDFromStream(stream); + + Vector2 xz = stream.readPackXZ(); + + SByte p = stream.readInt8(); + SByte r = stream.readInt8(); + + _updateVolatileData(eid, xz[0], KBEMath.KBE_FLT_MAX, xz[1], KBEMath.KBE_FLT_MAX, p, r, 1, true); + } + + public void Client_onUpdateData_xz_y_optimized(MemoryStream stream) + { + Int32 eid = getViewEntityIDFromStream(stream); + Vector2 xz = stream.readPackXZ(); + SByte yaw = stream.readInt8(); + _updateVolatileData(eid, xz[0], KBEMath.KBE_FLT_MAX, xz[1], yaw, KBEMath.KBE_FLT_MAX, KBEMath.KBE_FLT_MAX, 1, true); + } + + public void Client_onUpdateData_xz_p_optimized(MemoryStream stream) + { + Int32 eid = getViewEntityIDFromStream(stream); + + Vector2 xz = stream.readPackXZ(); + + SByte p = stream.readInt8(); + + _updateVolatileData(eid, xz[0], KBEMath.KBE_FLT_MAX, xz[1], KBEMath.KBE_FLT_MAX, p, KBEMath.KBE_FLT_MAX, 1, true); + } + + public void Client_onUpdateData_xz_r_optimized(MemoryStream stream) + { + Int32 eid = getViewEntityIDFromStream(stream); + + Vector2 xz = stream.readPackXZ(); + + SByte r = stream.readInt8(); + + _updateVolatileData(eid, xz[0], KBEMath.KBE_FLT_MAX, xz[1], KBEMath.KBE_FLT_MAX, KBEMath.KBE_FLT_MAX, r, 1, true); + } + + public void Client_onUpdateData_xyz_optimized(MemoryStream stream) + { + Int32 eid = getViewEntityIDFromStream(stream); + + Vector2 xz = stream.readPackXZ(); + float y = stream.readPackY(); + + _updateVolatileData(eid, xz[0], y, xz[1], KBEMath.KBE_FLT_MAX, KBEMath.KBE_FLT_MAX, KBEMath.KBE_FLT_MAX, 0, true); + } + + public void Client_onUpdateData_xyz_ypr_optimized(MemoryStream stream) + { + Int32 eid = getViewEntityIDFromStream(stream); + + Vector2 xz = stream.readPackXZ(); + float y = stream.readPackY(); + + SByte yaw = stream.readInt8(); + SByte p = stream.readInt8(); + SByte r = stream.readInt8(); + + _updateVolatileData(eid, xz[0], y, xz[1], yaw, p, r, 0, true); + } + + public void Client_onUpdateData_xyz_yp_optimized(MemoryStream stream) + { + Int32 eid = getViewEntityIDFromStream(stream); + + Vector2 xz = stream.readPackXZ(); + float y = stream.readPackY(); + + SByte yaw = stream.readInt8(); + SByte p = stream.readInt8(); + + _updateVolatileData(eid, xz[0], y, xz[1], yaw, p, KBEMath.KBE_FLT_MAX, 0, true); + } + + public void Client_onUpdateData_xyz_yr_optimized(MemoryStream stream) + { + Int32 eid = getViewEntityIDFromStream(stream); + + Vector2 xz = stream.readPackXZ(); + float y = stream.readPackY(); + + SByte yaw = stream.readInt8(); + SByte r = stream.readInt8(); + + _updateVolatileData(eid, xz[0], y, xz[1], yaw, KBEMath.KBE_FLT_MAX, r, 0, true); + } + + public void Client_onUpdateData_xyz_pr_optimized(MemoryStream stream) + { + Int32 eid = getViewEntityIDFromStream(stream); + + Vector2 xz = stream.readPackXZ(); + float y = stream.readPackY(); + + SByte p = stream.readInt8(); + SByte r = stream.readInt8(); + + _updateVolatileData(eid, xz[0], y, xz[1], KBEMath.KBE_FLT_MAX, p, r, 0, true); + } + + public void Client_onUpdateData_xyz_y_optimized(MemoryStream stream) + { + Int32 eid = getViewEntityIDFromStream(stream); + + Vector2 xz = stream.readPackXZ(); + float y = stream.readPackY(); + + SByte yaw = stream.readInt8(); + _updateVolatileData(eid, xz[0], y, xz[1], yaw, KBEMath.KBE_FLT_MAX, KBEMath.KBE_FLT_MAX, 0, true); + } + + public void Client_onUpdateData_xyz_p_optimized(MemoryStream stream) + { + Int32 eid = getViewEntityIDFromStream(stream); + + Vector2 xz = stream.readPackXZ(); + float y = stream.readPackY(); + + SByte p = stream.readInt8(); + + _updateVolatileData(eid, xz[0], y, xz[1], KBEMath.KBE_FLT_MAX, p, KBEMath.KBE_FLT_MAX, 0, true); + } + + public void Client_onUpdateData_xyz_r_optimized(MemoryStream stream) + { + Int32 eid = getViewEntityIDFromStream(stream); + + Vector2 xz = stream.readPackXZ(); + float y = stream.readPackY(); + + SByte r = stream.readInt8(); + + _updateVolatileData(eid, xz[0], y, xz[1], KBEMath.KBE_FLT_MAX, KBEMath.KBE_FLT_MAX, r, 0, true); + } + + private void _updateVolatileData(Int32 entityID, float x, float y, float z, float yaw, float pitch, float roll, sbyte isOnGround, bool isOptimized) + { + Entity entity = null; + + if(!entities.TryGetValue(entityID, out entity)) + { + // 如果为0且客户端上一步是重登陆或者重连操作并且服务端entity在断线期间一直处于在线状态 + // 则可以忽略这个错误, 因为cellapp可能一直在向baseapp发送同步消息, 当客户端重连上时未等 + // 服务端初始化步骤开始则收到同步信息, 此时这里就会出错。 + Dbg.ERROR_MSG("KBEngine::_updateVolatileData: entity(" + entityID + ") not found!"); + return; + } + + // 小于0不设置 + if(isOnGround >= 0) + { + entity.isOnGround = (isOnGround > 0); + } + + bool changeDirection = false; + + if(roll != KBEMath.KBE_FLT_MAX) + { + changeDirection = true; + entity.direction.x = KBEMath.int82angle((SByte)roll, false) * 360 / ((float)System.Math.PI * 2); + } + + if(pitch != KBEMath.KBE_FLT_MAX) + { + changeDirection = true; + entity.direction.y = KBEMath.int82angle((SByte)pitch, false) * 360 / ((float)System.Math.PI * 2); + } + + if(yaw != KBEMath.KBE_FLT_MAX) + { + changeDirection = true; + entity.direction.z = KBEMath.int82angle((SByte)yaw, false) * 360 / ((float)System.Math.PI * 2); + } + + bool done = false; + if(changeDirection == true) + { + Event.fireOut(EventOutTypes.set_direction, entity); + done = true; + } + + bool positionChanged = x != KBEMath.KBE_FLT_MAX || y != KBEMath.KBE_FLT_MAX || z != KBEMath.KBE_FLT_MAX; + if (x == KBEMath.KBE_FLT_MAX) x = 0.0f; + if (y == KBEMath.KBE_FLT_MAX) y = 0.0f; + if (z == KBEMath.KBE_FLT_MAX) z = 0.0f; + + if(positionChanged) + { + Vector3 pos = isOptimized ? new Vector3(x + _entityServerPos.x, y + _entityServerPos.y, z + _entityServerPos.z) : new Vector3(x, y, z); + + entity.position = pos; + done = true; + Event.fireOut(EventOutTypes.updatePosition, entity); + } + + if(done) + entity.onUpdateVolatileData(); + } + + /* + 服务端通知流数据下载开始 + 请参考API手册关于onStreamDataStarted + */ + public void Client_onStreamDataStarted(Int16 id, UInt32 datasize, string descr) + { + Event.fireOut(EventOutTypes.onStreamDataStarted, id, datasize, descr); + } + + public void Client_onStreamDataRecv(MemoryStream stream) + { + Int16 resID = stream.readInt16(); + byte[] datas = stream.readBlob(); + Event.fireOut(EventOutTypes.onStreamDataRecv, resID, datas); + } + + public void Client_onStreamDataCompleted(Int16 id) + { + Event.fireOut(EventOutTypes.onStreamDataCompleted, id); + } + } + + + public class KBEngineAppThread : KBEngineApp + { + /* + KBEngine处理线程 + */ + public class KBEThread + { + + KBEngineApp app_; + public bool over = false; + + public KBEThread(KBEngineApp app) + { + this.app_ = app; + } + + public void run() + { + Dbg.INFO_MSG("KBEThread::run()"); + over = false; + + try + { + this.app_.process(); + } + catch (Exception e) + { + Dbg.ERROR_MSG(e.ToString()); + } + + over = true; + Dbg.INFO_MSG("KBEThread::end()"); + } + } + + private Thread _t = null; + public KBEThread kbethread = null; + + // 主循环频率 + public static int threadUpdateHZ = 10; + + // 主循环周期ms 优化去掉循环中做除法 + private static float threadUpdatePeriod = 1000f / threadUpdateHZ; + + // 插件是否退出 + private bool _isbreak = false; + + private System.DateTime _lasttime = System.DateTime.Now; + + public KBEngineAppThread(KBEngineArgs args) : + base(args) + { + } + + public override bool initialize(KBEngineArgs args) + { + base.initialize(args); + + KBEngineAppThread.threadUpdateHZ = args.threadUpdateHZ; + threadUpdatePeriod = 1000f / threadUpdateHZ; + + kbethread = new KBEThread(this); + _t = new Thread(new ThreadStart(kbethread.run)); + _t.Start(); + + return true; + } + + public override void reset() + { + _isbreak = false; + _lasttime = System.DateTime.Now; + + base.reset(); + } + + /* + 插件退出处理 + */ + public void breakProcess() + { + _isbreak = true; + } + + public bool isbreak() + { + return _isbreak; + } + + public override void process() + { + while(!isbreak()) + { + base.process(); + _thread_wait(); + } + + Dbg.WARNING_MSG("KBEngineAppThread::process(): break!"); + } + + /* + 防止占满CPU, 需要让线程等待一会 + */ + void _thread_wait() + { + TimeSpan span = DateTime.Now - _lasttime; + + int diff = (int)(threadUpdatePeriod - span.TotalMilliseconds); + + if(diff < 0) + diff = 0; + + System.Threading.Thread.Sleep(diff); + _lasttime = DateTime.Now; + } + + public override void destroy() + { + Dbg.WARNING_MSG("KBEngineAppThread::destroy()"); + breakProcess(); + + int i = 0; + while(!kbethread.over && i < 50) + { + Thread.Sleep(100); + i += 1; + } + + if(_t != null) + _t.Abort(); + + _t = null; + + base.destroy(); + } + } +} diff --git a/Assets/Plugins/kbengine_unity3d_plugins/KBEngineArgs.cs b/Assets/Plugins/kbengine_unity3d_plugins/KBEngineArgs.cs index 336839c..f1e31fd 100644 --- a/Assets/Plugins/kbengine_unity3d_plugins/KBEngineArgs.cs +++ b/Assets/Plugins/kbengine_unity3d_plugins/KBEngineArgs.cs @@ -1,77 +1,77 @@ -namespace KBEngine -{ - using System; - - using MessageLengthEx = System.UInt32; - - /* - 初始化KBEngine的参数类 - */ - public class KBEngineArgs - { - // 登录ip和端口 - public string ip = "127.0.0.1"; - public int port = 20013; - - // 客户端类型 - // Reference: http://www.kbengine.org/docs/programming/clientsdkprogramming.html, client types - public KBEngineApp.CLIENT_TYPE clientType = KBEngineApp.CLIENT_TYPE.CLIENT_TYPE_MINI; - - //加密通信类型 - public KBEngineApp.NETWORK_ENCRYPT_TYPE networkEncryptType = KBEngineApp.NETWORK_ENCRYPT_TYPE.ENCRYPT_TYPE_NONE; - - // Allow synchronization role position information to the server - // 是否开启自动同步玩家信息到服务端,信息包括位置与方向,毫秒 - // 非高实时类游戏不需要开放这个选项 - public int syncPlayerMS = 100; - - // 是否使用别名机制 - // 这个参数的选择必须与kbengine_defs.xml::cellapp/aliasEntityID的参数保持一致 - public bool useAliasEntityID = true; - - // 在Entity初始化时是否触发属性的set_*事件(callPropertysSetMethods) - public bool isOnInitCallPropertysSetMethods = true; - - // 发送缓冲大小 - public MessageLengthEx TCP_SEND_BUFFER_MAX = NetworkInterfaceBase.TCP_PACKET_MAX; - public MessageLengthEx UDP_SEND_BUFFER_MAX = 128; - - // 接收缓冲区大小 - public MessageLengthEx TCP_RECV_BUFFER_MAX = NetworkInterfaceBase.TCP_PACKET_MAX; - public MessageLengthEx UDP_RECV_BUFFER_MAX = 128; - - // 是否多线程启动 - public bool isMultiThreads = false; - - // 只在多线程模式启用 - // 线程主循环处理频率 - public int threadUpdateHZ = 10; - - // 强制禁用UDP通讯 - public bool forceDisableUDP = false; - - // 心跳频率(tick数) - public int serverHeartbeatTick = 15; - - public int getTCPRecvBufferSize() - { - return (int)TCP_RECV_BUFFER_MAX; - } - - public int getTCPSendBufferSize() - { - return (int)TCP_SEND_BUFFER_MAX; - } - - public int getUDPRecvBufferSize() - { - return (int)UDP_RECV_BUFFER_MAX; - } - - public int getUDPSendBufferSize() - { - return (int)UDP_SEND_BUFFER_MAX; - } - } - -} +namespace KBEngine +{ + using System; + + using MessageLengthEx = System.UInt32; + + /* + 初始化KBEngine的参数类 + */ + public class KBEngineArgs + { + // 登录ip和端口 + public string ip = "127.0.0.1"; + public int port = 20013; + + // 客户端类型 + // Reference: http://www.kbengine.org/docs/programming/clientsdkprogramming.html, client types + public KBEngineApp.CLIENT_TYPE clientType = KBEngineApp.CLIENT_TYPE.CLIENT_TYPE_MINI; + + //加密通信类型 + public KBEngineApp.NETWORK_ENCRYPT_TYPE networkEncryptType = KBEngineApp.NETWORK_ENCRYPT_TYPE.ENCRYPT_TYPE_NONE; + + // Allow synchronization role position information to the server + // 是否开启自动同步玩家信息到服务端,信息包括位置与方向,毫秒 + // 非高实时类游戏不需要开放这个选项 + public int syncPlayerMS = 100; + + // 是否使用别名机制 + // 这个参数的选择必须与kbengine_defs.xml::cellapp/aliasEntityID的参数保持一致 + public bool useAliasEntityID = true; + + // 在Entity初始化时是否触发属性的set_*事件(callPropertysSetMethods) + public bool isOnInitCallPropertysSetMethods = true; + + // 发送缓冲大小 + public MessageLengthEx TCP_SEND_BUFFER_MAX = NetworkInterfaceBase.TCP_PACKET_MAX; + public MessageLengthEx UDP_SEND_BUFFER_MAX = 128; + + // 接收缓冲区大小 + public MessageLengthEx TCP_RECV_BUFFER_MAX = NetworkInterfaceBase.TCP_PACKET_MAX; + public MessageLengthEx UDP_RECV_BUFFER_MAX = 128; + + // 是否多线程启动 + public bool isMultiThreads = false; + + // 只在多线程模式启用 + // 线程主循环处理频率 + public int threadUpdateHZ = 10; + + // 强制禁用UDP通讯 + public bool forceDisableUDP = false; + + // 心跳频率(tick数) + public int serverHeartbeatTick = 15; + + public int getTCPRecvBufferSize() + { + return (int)TCP_RECV_BUFFER_MAX; + } + + public int getTCPSendBufferSize() + { + return (int)TCP_SEND_BUFFER_MAX; + } + + public int getUDPRecvBufferSize() + { + return (int)UDP_RECV_BUFFER_MAX; + } + + public int getUDPSendBufferSize() + { + return (int)UDP_SEND_BUFFER_MAX; + } + } + +} diff --git a/Assets/Plugins/kbengine_unity3d_plugins/Math.cs b/Assets/Plugins/kbengine_unity3d_plugins/Math.cs index a05c0f0..169fdd2 100644 --- a/Assets/Plugins/kbengine_unity3d_plugins/Math.cs +++ b/Assets/Plugins/kbengine_unity3d_plugins/Math.cs @@ -1,45 +1,45 @@ -using UnityEngine; -using KBEngine; -using System; -using System.Collections; - -namespace KBEngine -{ - -/* - KBEngine的数学相关模块 -*/ -public class KBEMath -{ - public static float KBE_FLT_MAX = float.MaxValue; - - public static float int82angle(SByte angle, bool half) - { - float halfv = 128f; - if(half == true) - halfv = 254f; - - halfv = ((float)angle) * ((float)System.Math.PI / halfv); - return halfv; - } - - public static bool almostEqual(float f1, float f2, float epsilon) - { - return Math.Abs( f1 - f2 ) < epsilon; - } - - public static bool isNumeric(object v) - { - return v is sbyte || v is byte || - v is short || v is ushort || - v is int || v is uint || - v is long || v is ulong || - v is char || v is decimal || v is float || - v is double || v is Int16 || v is Int64 || - v is UInt16 || v is UInt64 || - v is Boolean || v is bool; - } -} - - -} +using UnityEngine; +using KBEngine; +using System; +using System.Collections; + +namespace KBEngine +{ + +/* + KBEngine的数学相关模块 +*/ +public class KBEMath +{ + public static float KBE_FLT_MAX = float.MaxValue; + + public static float int82angle(SByte angle, bool half) + { + float halfv = 128f; + if(half == true) + halfv = 254f; + + halfv = ((float)angle) * ((float)System.Math.PI / halfv); + return halfv; + } + + public static bool almostEqual(float f1, float f2, float epsilon) + { + return Math.Abs( f1 - f2 ) < epsilon; + } + + public static bool isNumeric(object v) + { + return v is sbyte || v is byte || + v is short || v is ushort || + v is int || v is uint || + v is long || v is ulong || + v is char || v is decimal || v is float || + v is double || v is Int16 || v is Int64 || + v is UInt16 || v is UInt64 || + v is Boolean || v is bool; + } +} + + +} diff --git a/Assets/Plugins/kbengine_unity3d_plugins/MemoryStream.cs b/Assets/Plugins/kbengine_unity3d_plugins/MemoryStream.cs index 8c7742c..8c64b4b 100644 --- a/Assets/Plugins/kbengine_unity3d_plugins/MemoryStream.cs +++ b/Assets/Plugins/kbengine_unity3d_plugins/MemoryStream.cs @@ -1,472 +1,472 @@ -namespace KBEngine -{ - using UnityEngine; - using System; - using System.Net; - using System.Collections; - using System.Collections.Generic; - using System.Text; - using System.Threading; - using System.Runtime.InteropServices; - - /* - 二进制数据流模块 - 能够将一些基本类型序列化(writeXXX)成二进制流同时也提供了反序列化(readXXX)等操作 - */ - public class MemoryStream : ObjectPool - { - public const int BUFFER_MAX = 1460 * 4; - - public int rpos = 0; - public int wpos = 0; - private byte[] datas_ = new byte[BUFFER_MAX]; - - private static System.Text.ASCIIEncoding _converter = new System.Text.ASCIIEncoding(); - - [StructLayout(LayoutKind.Explicit, Size = 4)] - struct PackFloatXType - { - [FieldOffset(0)] - public float fv; - - [FieldOffset(0)] - public UInt32 uv; - - [FieldOffset(0)] - public Int32 iv; - } - - - public byte[] setBuffer(byte[] buffer) - { - byte[] outBuf = datas_; - datas_ = buffer; - return outBuf; - } - - public void swap(MemoryStream stream) - { - int t_rpos = rpos; - int t_wpos = wpos; - rpos = stream.rpos; - wpos = stream.wpos; - stream.rpos = t_rpos; - stream.wpos = t_wpos; - - datas_ = stream.setBuffer(datas_); - } - - /// - /// 把自己放回缓冲池 - /// - public void reclaimObject() - { - clear(); - reclaimObject(this); - } - - public byte[] data() - { - return datas_; - } - - public void setData(byte[] data) - { - datas_ = data; - } - - //--------------------------------------------------------------------------------- - public SByte readInt8() - { - return (SByte)datas_[rpos++]; - } - - public Int16 readInt16() - { - rpos += 2; - return BitConverter.ToInt16(datas_, rpos - 2); - } - - public Int32 readInt32() - { - rpos += 4; - return BitConverter.ToInt32(datas_, rpos - 4); - } - - public Int64 readInt64() - { - rpos += 8; - return BitConverter.ToInt64(datas_, rpos - 8); - } - - public Byte readUint8() - { - return datas_[rpos++]; - } - - public UInt16 readUint16() - { - rpos += 2; - return BitConverter.ToUInt16(datas_, rpos - 2); - } - - public UInt32 readUint32() - { - rpos += 4; - return BitConverter.ToUInt32(datas_, rpos - 4); - } - - public UInt64 readUint64() - { - rpos += 8; - return BitConverter.ToUInt64(datas_, rpos - 8); - } - - public float readFloat() - { - rpos += 4; - return BitConverter.ToSingle(datas_, rpos - 4); - } - - public double readDouble() - { - rpos += 8; - return BitConverter.ToDouble(datas_, rpos - 8); - } - - public string readString() - { - int offset = rpos; - while(datas_[rpos++] != 0) - { - } - - return _converter.GetString(datas_, offset, rpos - offset - 1); - } - - public string readUnicode() - { - return System.Text.Encoding.UTF8.GetString(readBlob()); - } - - public byte[] readBlob() - { - UInt32 size = readUint32(); - byte[] buf = new byte[size]; - - Array.Copy(datas_, rpos, buf, 0, size); - rpos += (int)size; - return buf; - } - - public byte[] readEntitycall() - { - readUint64(); - readInt32(); - readUint16(); - readUint16(); - return new byte[0]; - } - - public Vector2 readVector2() - { - float x = readFloat(); - float y = readFloat(); - return new Vector2(x, y); - } - - public Vector3 readVector3() - { - float x = readFloat(); - float y = readFloat(); - float z = readFloat(); - return new Vector3(x, y, z); - } - - public Vector4 readVector4() - { - float x = readFloat(); - float y = readFloat(); - float z = readFloat(); - float w = readFloat(); - return new Vector4(x, y, z, w); - } - - public byte[] readPython() - { - return readBlob(); - } - - public Vector2 readPackXZ() - { - PackFloatXType xPackData; - PackFloatXType zPackData; - - xPackData.fv = 0f; - zPackData.fv = 0f; - - xPackData.uv = 0x40000000; - zPackData.uv = 0x40000000; - - Byte v1 = readUint8(); - Byte v2 = readUint8(); - Byte v3 = readUint8(); - - UInt32 data = 0; - data |= ((UInt32)v1 << 16); - data |= ((UInt32)v2 << 8); - data |= (UInt32)v3; - - xPackData.uv |= (data & 0x7ff000) << 3; - zPackData.uv |= (data & 0x0007ff) << 15; - - xPackData.fv -= 2.0f; - zPackData.fv -= 2.0f; - - xPackData.uv |= (data & 0x800000) << 8; - zPackData.uv |= (data & 0x000800) << 20; - - Vector2 vec = new Vector2(xPackData.fv, zPackData.fv); - return vec; - } - - public float readPackY() - { - PackFloatXType yPackData; - yPackData.fv = 0f; - yPackData.uv = 0x40000000; - - UInt16 data = readUint16(); - - yPackData.uv |= ((UInt32)data & 0x7fff) << 12; - yPackData.fv -= 2f; - yPackData.uv |= ((UInt32)data & 0x8000) << 16; - - return yPackData.fv; - } - - //--------------------------------------------------------------------------------- - public void writeInt8(SByte v) - { - datas_[wpos++] = (Byte)v; - } - - public void writeInt16(Int16 v) - { - writeInt8((SByte)(v & 0xff)); - writeInt8((SByte)(v >> 8 & 0xff)); - } - - public void writeInt32(Int32 v) - { - for(int i=0; i<4; i++) - writeInt8((SByte)(v >> i * 8 & 0xff)); - } - - public void writeInt64(Int64 v) - { - byte[] getdata = BitConverter.GetBytes(v); - for(int i=0; i> 8 & 0xff)); - } - - public void writeUint32(UInt32 v) - { - for(int i=0; i<4; i++) - writeUint8((Byte)(v >> i * 8 & 0xff)); - } - - public void writeUint64(UInt64 v) - { - byte[] getdata = BitConverter.GetBytes(v); - for(int i=0; i space()) - { - Dbg.ERROR_MSG("memorystream::writeBlob: no free!"); - return; - } - - writeUint32(size); - - for(UInt32 i=0; i space()) - { - Dbg.ERROR_MSG("memorystream::writeString: no free!"); - return; - } - - byte[] getdata = System.Text.Encoding.ASCII.GetBytes(v); - for(int i=0; i BUFFER_MAX) - datas_ = new byte[BUFFER_MAX]; - } - - //--------------------------------------------------------------------------------- - public byte[] getbuffer() - { - byte[] buf = new byte[length()]; - Array.Copy(data(), rpos, buf, 0, length()); - return buf; - } - - //--------------------------------------------------------------------------------- - public string toString() - { - string s = ""; - int ii = 0; - byte[] buf = getbuffer(); - - for(int i=0; i= 200) - { - s = ""; - ii = 0; - } - - s += buf[i]; - s += " "; - } - - return s; - } - } - -} +namespace KBEngine +{ + using UnityEngine; + using System; + using System.Net; + using System.Collections; + using System.Collections.Generic; + using System.Text; + using System.Threading; + using System.Runtime.InteropServices; + + /* + 二进制数据流模块 + 能够将一些基本类型序列化(writeXXX)成二进制流同时也提供了反序列化(readXXX)等操作 + */ + public class MemoryStream : ObjectPool + { + public const int BUFFER_MAX = 1460 * 4; + + public int rpos = 0; + public int wpos = 0; + private byte[] datas_ = new byte[BUFFER_MAX]; + + private static System.Text.ASCIIEncoding _converter = new System.Text.ASCIIEncoding(); + + [StructLayout(LayoutKind.Explicit, Size = 4)] + struct PackFloatXType + { + [FieldOffset(0)] + public float fv; + + [FieldOffset(0)] + public UInt32 uv; + + [FieldOffset(0)] + public Int32 iv; + } + + + public byte[] setBuffer(byte[] buffer) + { + byte[] outBuf = datas_; + datas_ = buffer; + return outBuf; + } + + public void swap(MemoryStream stream) + { + int t_rpos = rpos; + int t_wpos = wpos; + rpos = stream.rpos; + wpos = stream.wpos; + stream.rpos = t_rpos; + stream.wpos = t_wpos; + + datas_ = stream.setBuffer(datas_); + } + + /// + /// 把自己放回缓冲池 + /// + public void reclaimObject() + { + clear(); + reclaimObject(this); + } + + public byte[] data() + { + return datas_; + } + + public void setData(byte[] data) + { + datas_ = data; + } + + //--------------------------------------------------------------------------------- + public SByte readInt8() + { + return (SByte)datas_[rpos++]; + } + + public Int16 readInt16() + { + rpos += 2; + return BitConverter.ToInt16(datas_, rpos - 2); + } + + public Int32 readInt32() + { + rpos += 4; + return BitConverter.ToInt32(datas_, rpos - 4); + } + + public Int64 readInt64() + { + rpos += 8; + return BitConverter.ToInt64(datas_, rpos - 8); + } + + public Byte readUint8() + { + return datas_[rpos++]; + } + + public UInt16 readUint16() + { + rpos += 2; + return BitConverter.ToUInt16(datas_, rpos - 2); + } + + public UInt32 readUint32() + { + rpos += 4; + return BitConverter.ToUInt32(datas_, rpos - 4); + } + + public UInt64 readUint64() + { + rpos += 8; + return BitConverter.ToUInt64(datas_, rpos - 8); + } + + public float readFloat() + { + rpos += 4; + return BitConverter.ToSingle(datas_, rpos - 4); + } + + public double readDouble() + { + rpos += 8; + return BitConverter.ToDouble(datas_, rpos - 8); + } + + public string readString() + { + int offset = rpos; + while(datas_[rpos++] != 0) + { + } + + return _converter.GetString(datas_, offset, rpos - offset - 1); + } + + public string readUnicode() + { + return System.Text.Encoding.UTF8.GetString(readBlob()); + } + + public byte[] readBlob() + { + UInt32 size = readUint32(); + byte[] buf = new byte[size]; + + Array.Copy(datas_, rpos, buf, 0, size); + rpos += (int)size; + return buf; + } + + public byte[] readEntitycall() + { + readUint64(); + readInt32(); + readUint16(); + readUint16(); + return new byte[0]; + } + + public Vector2 readVector2() + { + float x = readFloat(); + float y = readFloat(); + return new Vector2(x, y); + } + + public Vector3 readVector3() + { + float x = readFloat(); + float y = readFloat(); + float z = readFloat(); + return new Vector3(x, y, z); + } + + public Vector4 readVector4() + { + float x = readFloat(); + float y = readFloat(); + float z = readFloat(); + float w = readFloat(); + return new Vector4(x, y, z, w); + } + + public byte[] readPython() + { + return readBlob(); + } + + public Vector2 readPackXZ() + { + PackFloatXType xPackData; + PackFloatXType zPackData; + + xPackData.fv = 0f; + zPackData.fv = 0f; + + xPackData.uv = 0x40000000; + zPackData.uv = 0x40000000; + + Byte v1 = readUint8(); + Byte v2 = readUint8(); + Byte v3 = readUint8(); + + UInt32 data = 0; + data |= ((UInt32)v1 << 16); + data |= ((UInt32)v2 << 8); + data |= (UInt32)v3; + + xPackData.uv |= (data & 0x7ff000) << 3; + zPackData.uv |= (data & 0x0007ff) << 15; + + xPackData.fv -= 2.0f; + zPackData.fv -= 2.0f; + + xPackData.uv |= (data & 0x800000) << 8; + zPackData.uv |= (data & 0x000800) << 20; + + Vector2 vec = new Vector2(xPackData.fv, zPackData.fv); + return vec; + } + + public float readPackY() + { + PackFloatXType yPackData; + yPackData.fv = 0f; + yPackData.uv = 0x40000000; + + UInt16 data = readUint16(); + + yPackData.uv |= ((UInt32)data & 0x7fff) << 12; + yPackData.fv -= 2f; + yPackData.uv |= ((UInt32)data & 0x8000) << 16; + + return yPackData.fv; + } + + //--------------------------------------------------------------------------------- + public void writeInt8(SByte v) + { + datas_[wpos++] = (Byte)v; + } + + public void writeInt16(Int16 v) + { + writeInt8((SByte)(v & 0xff)); + writeInt8((SByte)(v >> 8 & 0xff)); + } + + public void writeInt32(Int32 v) + { + for(int i=0; i<4; i++) + writeInt8((SByte)(v >> i * 8 & 0xff)); + } + + public void writeInt64(Int64 v) + { + byte[] getdata = BitConverter.GetBytes(v); + for(int i=0; i> 8 & 0xff)); + } + + public void writeUint32(UInt32 v) + { + for(int i=0; i<4; i++) + writeUint8((Byte)(v >> i * 8 & 0xff)); + } + + public void writeUint64(UInt64 v) + { + byte[] getdata = BitConverter.GetBytes(v); + for(int i=0; i space()) + { + Dbg.ERROR_MSG("memorystream::writeBlob: no free!"); + return; + } + + writeUint32(size); + + for(UInt32 i=0; i space()) + { + Dbg.ERROR_MSG("memorystream::writeString: no free!"); + return; + } + + byte[] getdata = System.Text.Encoding.ASCII.GetBytes(v); + for(int i=0; i BUFFER_MAX) + datas_ = new byte[BUFFER_MAX]; + } + + //--------------------------------------------------------------------------------- + public byte[] getbuffer() + { + byte[] buf = new byte[length()]; + Array.Copy(data(), rpos, buf, 0, length()); + return buf; + } + + //--------------------------------------------------------------------------------- + public string toString() + { + string s = ""; + int ii = 0; + byte[] buf = getbuffer(); + + for(int i=0; i= 200) + { + s = ""; + ii = 0; + } + + s += buf[i]; + s += " "; + } + + return s; + } + } + +} diff --git a/Assets/Plugins/kbengine_unity3d_plugins/MessageReaderBase.cs b/Assets/Plugins/kbengine_unity3d_plugins/MessageReaderBase.cs index 7c88f4f..b40488d 100644 --- a/Assets/Plugins/kbengine_unity3d_plugins/MessageReaderBase.cs +++ b/Assets/Plugins/kbengine_unity3d_plugins/MessageReaderBase.cs @@ -1,18 +1,18 @@ -namespace KBEngine -{ - using UnityEngine; - using System; - - using MessageID = System.UInt16; - using MessageLength = System.UInt16; - using MessageLengthEx = System.UInt32; - - /* - 消息阅读模块 - 从数据包流中分析出所有的消息包并将其交给对应的消息处理函数 - */ - public abstract class MessageReaderBase - { - public abstract void process(byte[] datas, MessageLengthEx offset, MessageLengthEx length); - } -} +namespace KBEngine +{ + using UnityEngine; + using System; + + using MessageID = System.UInt16; + using MessageLength = System.UInt16; + using MessageLengthEx = System.UInt32; + + /* + 消息阅读模块 + 从数据包流中分析出所有的消息包并将其交给对应的消息处理函数 + */ + public abstract class MessageReaderBase + { + public abstract void process(byte[] datas, MessageLengthEx offset, MessageLengthEx length); + } +} diff --git a/Assets/Plugins/kbengine_unity3d_plugins/MessageReaderKCP.cs b/Assets/Plugins/kbengine_unity3d_plugins/MessageReaderKCP.cs index 26469a8..5f76598 100644 --- a/Assets/Plugins/kbengine_unity3d_plugins/MessageReaderKCP.cs +++ b/Assets/Plugins/kbengine_unity3d_plugins/MessageReaderKCP.cs @@ -1,18 +1,18 @@ -namespace KBEngine -{ - using UnityEngine; - using System; - - using MessageID = System.UInt16; - using MessageLength = System.UInt16; - using MessageLengthEx = System.UInt32; - - /* - 消息阅读模块 - 从数据包流中分析出所有的消息包并将其交给对应的消息处理函数 - 由于KCP是模拟的TCP流,一个UDP包中可能包含一个或者多个包,并且最后一个包可能是不完整的,因此直接继承MessageReaderTCP - */ - public class MessageReaderKCP : MessageReaderTCP - { - } -} +namespace KBEngine +{ + using UnityEngine; + using System; + + using MessageID = System.UInt16; + using MessageLength = System.UInt16; + using MessageLengthEx = System.UInt32; + + /* + 消息阅读模块 + 从数据包流中分析出所有的消息包并将其交给对应的消息处理函数 + 由于KCP是模拟的TCP流,一个UDP包中可能包含一个或者多个包,并且最后一个包可能是不完整的,因此直接继承MessageReaderTCP + */ + public class MessageReaderKCP : MessageReaderTCP + { + } +} diff --git a/Assets/Plugins/kbengine_unity3d_plugins/MessageReaderTCP.cs b/Assets/Plugins/kbengine_unity3d_plugins/MessageReaderTCP.cs index ae12f5c..5632726 100644 --- a/Assets/Plugins/kbengine_unity3d_plugins/MessageReaderTCP.cs +++ b/Assets/Plugins/kbengine_unity3d_plugins/MessageReaderTCP.cs @@ -1,185 +1,185 @@ -namespace KBEngine -{ - using UnityEngine; - using System; - - using MessageID = System.UInt16; - using MessageLength = System.UInt16; - using MessageLengthEx = System.UInt32; - - /* - 消息阅读模块 - 从数据包流中分析出所有的消息包并将其交给对应的消息处理函数 - */ - public class MessageReaderTCP : MessageReaderBase - { - enum READ_STATE - { - // 消息ID - READ_STATE_MSGID = 0, - - // 消息的长度65535以内 - READ_STATE_MSGLEN = 1, - - // 当上面的消息长度都无法到达要求时使用扩展长度 - // uint32 - READ_STATE_MSGLEN_EX = 2, - - // 消息的内容 - READ_STATE_BODY = 3 - } - - private MessageID msgid = 0; - private MessageLength msglen = 0; - private MessageLengthEx expectSize = 2; - private READ_STATE state = READ_STATE.READ_STATE_MSGID; - private MemoryStream stream = new MemoryStream(); - - public MessageReaderTCP() - { - } - - public override void process(byte[] datas, MessageLengthEx offset, MessageLengthEx length) - { - MessageLengthEx totallen = offset; - - while(length > 0 && expectSize > 0) - { - if(state == READ_STATE.READ_STATE_MSGID) - { - if(length >= expectSize) - { - Array.Copy(datas, totallen, stream.data(), stream.wpos, expectSize); - totallen += expectSize; - stream.wpos += (int)expectSize; - length -= expectSize; - msgid = stream.readUint16(); - stream.clear(); - - Message msg = Messages.clientMessages[msgid]; - - if(msg.msglen == -1) - { - state = READ_STATE.READ_STATE_MSGLEN; - expectSize = 2; - } - else if(msg.msglen == 0) - { - // 如果是0个参数的消息,那么没有后续内容可读了,处理本条消息并且直接跳到下一条消息 - #if UNITY_EDITOR - Dbg.profileStart(msg.name); - #endif - - msg.handleMessage(stream); - - #if UNITY_EDITOR - Dbg.profileEnd(msg.name); - #endif - - state = READ_STATE.READ_STATE_MSGID; - expectSize = 2; - } - else - { - expectSize = (MessageLengthEx)msg.msglen; - state = READ_STATE.READ_STATE_BODY; - } - } - else - { - Array.Copy(datas, totallen, stream.data(), stream.wpos, length); - stream.wpos += (int)length; - expectSize -= length; - break; - } - } - else if(state == READ_STATE.READ_STATE_MSGLEN) - { - if(length >= expectSize) - { - Array.Copy(datas, totallen, stream.data(), stream.wpos, expectSize); - totallen += expectSize; - stream.wpos += (int)expectSize; - length -= expectSize; - - msglen = stream.readUint16(); - stream.clear(); - - // 长度扩展 - if(msglen >= 65535) - { - state = READ_STATE.READ_STATE_MSGLEN_EX; - expectSize = 4; - } - else - { - state = READ_STATE.READ_STATE_BODY; - expectSize = msglen; - } - } - else - { - Array.Copy(datas, totallen, stream.data(), stream.wpos, length); - stream.wpos += (int)length; - expectSize -= length; - break; - } - } - else if(state == READ_STATE.READ_STATE_MSGLEN_EX) - { - if(length >= expectSize) - { - Array.Copy(datas, totallen, stream.data(), stream.wpos, expectSize); - totallen += expectSize; - stream.wpos += (int)expectSize; - length -= expectSize; - - expectSize = stream.readUint32(); - stream.clear(); - - state = READ_STATE.READ_STATE_BODY; - } - else - { - Array.Copy(datas, totallen, stream.data(), stream.wpos, length); - stream.wpos += (int)length; - expectSize -= length; - break; - } - } - else if(state == READ_STATE.READ_STATE_BODY) - { - if(length >= expectSize) - { - stream.append (datas, totallen, expectSize); - totallen += expectSize; - length -= expectSize; - - Message msg = Messages.clientMessages[msgid]; - -#if UNITY_EDITOR - Dbg.profileStart(msg.name); -#endif - - msg.handleMessage(stream); - -#if UNITY_EDITOR - Dbg.profileEnd(msg.name); -#endif - - stream.clear(); - - state = READ_STATE.READ_STATE_MSGID; - expectSize = 2; - } - else - { - stream.append (datas, totallen, length); - expectSize -= length; - break; - } - } - } - } - } -} +namespace KBEngine +{ + using UnityEngine; + using System; + + using MessageID = System.UInt16; + using MessageLength = System.UInt16; + using MessageLengthEx = System.UInt32; + + /* + 消息阅读模块 + 从数据包流中分析出所有的消息包并将其交给对应的消息处理函数 + */ + public class MessageReaderTCP : MessageReaderBase + { + enum READ_STATE + { + // 消息ID + READ_STATE_MSGID = 0, + + // 消息的长度65535以内 + READ_STATE_MSGLEN = 1, + + // 当上面的消息长度都无法到达要求时使用扩展长度 + // uint32 + READ_STATE_MSGLEN_EX = 2, + + // 消息的内容 + READ_STATE_BODY = 3 + } + + private MessageID msgid = 0; + private MessageLength msglen = 0; + private MessageLengthEx expectSize = 2; + private READ_STATE state = READ_STATE.READ_STATE_MSGID; + private MemoryStream stream = new MemoryStream(); + + public MessageReaderTCP() + { + } + + public override void process(byte[] datas, MessageLengthEx offset, MessageLengthEx length) + { + MessageLengthEx totallen = offset; + + while(length > 0 && expectSize > 0) + { + if(state == READ_STATE.READ_STATE_MSGID) + { + if(length >= expectSize) + { + Array.Copy(datas, totallen, stream.data(), stream.wpos, expectSize); + totallen += expectSize; + stream.wpos += (int)expectSize; + length -= expectSize; + msgid = stream.readUint16(); + stream.clear(); + + Message msg = Messages.clientMessages[msgid]; + + if(msg.msglen == -1) + { + state = READ_STATE.READ_STATE_MSGLEN; + expectSize = 2; + } + else if(msg.msglen == 0) + { + // 如果是0个参数的消息,那么没有后续内容可读了,处理本条消息并且直接跳到下一条消息 + #if UNITY_EDITOR + Dbg.profileStart(msg.name); + #endif + + msg.handleMessage(stream); + + #if UNITY_EDITOR + Dbg.profileEnd(msg.name); + #endif + + state = READ_STATE.READ_STATE_MSGID; + expectSize = 2; + } + else + { + expectSize = (MessageLengthEx)msg.msglen; + state = READ_STATE.READ_STATE_BODY; + } + } + else + { + Array.Copy(datas, totallen, stream.data(), stream.wpos, length); + stream.wpos += (int)length; + expectSize -= length; + break; + } + } + else if(state == READ_STATE.READ_STATE_MSGLEN) + { + if(length >= expectSize) + { + Array.Copy(datas, totallen, stream.data(), stream.wpos, expectSize); + totallen += expectSize; + stream.wpos += (int)expectSize; + length -= expectSize; + + msglen = stream.readUint16(); + stream.clear(); + + // 长度扩展 + if(msglen >= 65535) + { + state = READ_STATE.READ_STATE_MSGLEN_EX; + expectSize = 4; + } + else + { + state = READ_STATE.READ_STATE_BODY; + expectSize = msglen; + } + } + else + { + Array.Copy(datas, totallen, stream.data(), stream.wpos, length); + stream.wpos += (int)length; + expectSize -= length; + break; + } + } + else if(state == READ_STATE.READ_STATE_MSGLEN_EX) + { + if(length >= expectSize) + { + Array.Copy(datas, totallen, stream.data(), stream.wpos, expectSize); + totallen += expectSize; + stream.wpos += (int)expectSize; + length -= expectSize; + + expectSize = stream.readUint32(); + stream.clear(); + + state = READ_STATE.READ_STATE_BODY; + } + else + { + Array.Copy(datas, totallen, stream.data(), stream.wpos, length); + stream.wpos += (int)length; + expectSize -= length; + break; + } + } + else if(state == READ_STATE.READ_STATE_BODY) + { + if(length >= expectSize) + { + stream.append (datas, totallen, expectSize); + totallen += expectSize; + length -= expectSize; + + Message msg = Messages.clientMessages[msgid]; + +#if UNITY_EDITOR + Dbg.profileStart(msg.name); +#endif + + msg.handleMessage(stream); + +#if UNITY_EDITOR + Dbg.profileEnd(msg.name); +#endif + + stream.clear(); + + state = READ_STATE.READ_STATE_MSGID; + expectSize = 2; + } + else + { + stream.append (datas, totallen, length); + expectSize -= length; + break; + } + } + } + } + } +} diff --git a/Assets/Plugins/kbengine_unity3d_plugins/Messages.cs b/Assets/Plugins/kbengine_unity3d_plugins/Messages.cs index 65de5dc..03ec3d5 100644 --- a/Assets/Plugins/kbengine_unity3d_plugins/Messages.cs +++ b/Assets/Plugins/kbengine_unity3d_plugins/Messages.cs @@ -1,2141 +1,2141 @@ -/* - Generated by KBEngine! - Please do not modify this file! - tools = kbcmd -*/ - -namespace KBEngine -{ - using UnityEngine; - using System; - using System.Collections; - using System.Collections.Generic; - - using MessageID = System.UInt16; - - // engine-c++ messages - - public class Message - { - public MessageID id = 0; - public string name; - public Int16 msglen = -1; - public List argtypes = null; - public sbyte argsType = 0; - - public Message(MessageID msgid, string msgname, Int16 length, sbyte argstype, List msgargtypes) - { - id = msgid; - name = msgname; - msglen = length; - argsType = argstype; - - argtypes = msgargtypes; - // Dbg.DEBUG_MSG(string.Format("Message::Message() : ({ 0 } / {1} / {2})!", - // msgname, msgid, msglen)); - } - - public virtual void handleMessage(MemoryStream msgstream) - { - } - } - - public class Message_Client_onReloginBaseappFailed : Message - { - - public Message_Client_onReloginBaseappFailed(MessageID msgid, string msgname, Int16 length, sbyte argstype, List msgargtypes): - base(msgid, msgname, length, argstype, msgargtypes) - { - - } - - public override void handleMessage(MemoryStream msgstream) - { - UInt16 arg1 = msgstream.readUint16(); - KBEngineApp.app.Client_onReloginBaseappFailed(arg1); - } - } - - public class Message_Client_onEntityLeaveWorldOptimized : Message - { - - public Message_Client_onEntityLeaveWorldOptimized(MessageID msgid, string msgname, Int16 length, sbyte argstype, List msgargtypes): - base(msgid, msgname, length, argstype, msgargtypes) - { - - } - - public override void handleMessage(MemoryStream msgstream) - { - KBEngineApp.app.Client_onEntityLeaveWorldOptimized(msgstream); - } - } - - public class Message_Client_onRemoteMethodCallOptimized : Message - { - - public Message_Client_onRemoteMethodCallOptimized(MessageID msgid, string msgname, Int16 length, sbyte argstype, List msgargtypes): - base(msgid, msgname, length, argstype, msgargtypes) - { - - } - - public override void handleMessage(MemoryStream msgstream) - { - KBEngineApp.app.Client_onRemoteMethodCallOptimized(msgstream); - } - } - - public class Message_Client_onUpdatePropertysOptimized : Message - { - - public Message_Client_onUpdatePropertysOptimized(MessageID msgid, string msgname, Int16 length, sbyte argstype, List msgargtypes): - base(msgid, msgname, length, argstype, msgargtypes) - { - - } - - public override void handleMessage(MemoryStream msgstream) - { - KBEngineApp.app.Client_onUpdatePropertysOptimized(msgstream); - } - } - - public class Message_Client_onSetEntityPosAndDir : Message - { - - public Message_Client_onSetEntityPosAndDir(MessageID msgid, string msgname, Int16 length, sbyte argstype, List msgargtypes): - base(msgid, msgname, length, argstype, msgargtypes) - { - - } - - public override void handleMessage(MemoryStream msgstream) - { - KBEngineApp.app.Client_onSetEntityPosAndDir(msgstream); - } - } - - public class Message_Client_onUpdateBasePos : Message - { - - public Message_Client_onUpdateBasePos(MessageID msgid, string msgname, Int16 length, sbyte argstype, List msgargtypes): - base(msgid, msgname, length, argstype, msgargtypes) - { - - } - - public override void handleMessage(MemoryStream msgstream) - { - float arg1 = msgstream.readFloat(); - float arg2 = msgstream.readFloat(); - float arg3 = msgstream.readFloat(); - KBEngineApp.app.Client_onUpdateBasePos(arg1, arg2, arg3); - } - } - - public class Message_Client_onUpdateBaseDir : Message - { - - public Message_Client_onUpdateBaseDir(MessageID msgid, string msgname, Int16 length, sbyte argstype, List msgargtypes): - base(msgid, msgname, length, argstype, msgargtypes) - { - - } - - public override void handleMessage(MemoryStream msgstream) - { - KBEngineApp.app.Client_onUpdateBaseDir(msgstream); - } - } - - public class Message_Client_onUpdateBasePosXZ : Message - { - - public Message_Client_onUpdateBasePosXZ(MessageID msgid, string msgname, Int16 length, sbyte argstype, List msgargtypes): - base(msgid, msgname, length, argstype, msgargtypes) - { - - } - - public override void handleMessage(MemoryStream msgstream) - { - float arg1 = msgstream.readFloat(); - float arg2 = msgstream.readFloat(); - KBEngineApp.app.Client_onUpdateBasePosXZ(arg1, arg2); - } - } - - public class Message_Client_onUpdateData : Message - { - - public Message_Client_onUpdateData(MessageID msgid, string msgname, Int16 length, sbyte argstype, List msgargtypes): - base(msgid, msgname, length, argstype, msgargtypes) - { - - } - - public override void handleMessage(MemoryStream msgstream) - { - KBEngineApp.app.Client_onUpdateData(msgstream); - } - } - - public class Message_Client_onUpdateData_ypr : Message - { - - public Message_Client_onUpdateData_ypr(MessageID msgid, string msgname, Int16 length, sbyte argstype, List msgargtypes): - base(msgid, msgname, length, argstype, msgargtypes) - { - - } - - public override void handleMessage(MemoryStream msgstream) - { - KBEngineApp.app.Client_onUpdateData_ypr(msgstream); - } - } - - public class Message_Client_onUpdateData_yp : Message - { - - public Message_Client_onUpdateData_yp(MessageID msgid, string msgname, Int16 length, sbyte argstype, List msgargtypes): - base(msgid, msgname, length, argstype, msgargtypes) - { - - } - - public override void handleMessage(MemoryStream msgstream) - { - KBEngineApp.app.Client_onUpdateData_yp(msgstream); - } - } - - public class Message_Client_onUpdateData_yr : Message - { - - public Message_Client_onUpdateData_yr(MessageID msgid, string msgname, Int16 length, sbyte argstype, List msgargtypes): - base(msgid, msgname, length, argstype, msgargtypes) - { - - } - - public override void handleMessage(MemoryStream msgstream) - { - KBEngineApp.app.Client_onUpdateData_yr(msgstream); - } - } - - public class Message_Client_onUpdateData_pr : Message - { - - public Message_Client_onUpdateData_pr(MessageID msgid, string msgname, Int16 length, sbyte argstype, List msgargtypes): - base(msgid, msgname, length, argstype, msgargtypes) - { - - } - - public override void handleMessage(MemoryStream msgstream) - { - KBEngineApp.app.Client_onUpdateData_pr(msgstream); - } - } - - public class Message_Client_onUpdateData_y : Message - { - - public Message_Client_onUpdateData_y(MessageID msgid, string msgname, Int16 length, sbyte argstype, List msgargtypes): - base(msgid, msgname, length, argstype, msgargtypes) - { - - } - - public override void handleMessage(MemoryStream msgstream) - { - KBEngineApp.app.Client_onUpdateData_y(msgstream); - } - } - - public class Message_Client_onUpdateData_p : Message - { - - public Message_Client_onUpdateData_p(MessageID msgid, string msgname, Int16 length, sbyte argstype, List msgargtypes): - base(msgid, msgname, length, argstype, msgargtypes) - { - - } - - public override void handleMessage(MemoryStream msgstream) - { - KBEngineApp.app.Client_onUpdateData_p(msgstream); - } - } - - public class Message_Client_onUpdateData_r : Message - { - - public Message_Client_onUpdateData_r(MessageID msgid, string msgname, Int16 length, sbyte argstype, List msgargtypes): - base(msgid, msgname, length, argstype, msgargtypes) - { - - } - - public override void handleMessage(MemoryStream msgstream) - { - KBEngineApp.app.Client_onUpdateData_r(msgstream); - } - } - - public class Message_Client_onUpdateData_xz : Message - { - - public Message_Client_onUpdateData_xz(MessageID msgid, string msgname, Int16 length, sbyte argstype, List msgargtypes): - base(msgid, msgname, length, argstype, msgargtypes) - { - - } - - public override void handleMessage(MemoryStream msgstream) - { - KBEngineApp.app.Client_onUpdateData_xz(msgstream); - } - } - - public class Message_Client_onUpdateData_xz_ypr : Message - { - - public Message_Client_onUpdateData_xz_ypr(MessageID msgid, string msgname, Int16 length, sbyte argstype, List msgargtypes): - base(msgid, msgname, length, argstype, msgargtypes) - { - - } - - public override void handleMessage(MemoryStream msgstream) - { - KBEngineApp.app.Client_onUpdateData_xz_ypr(msgstream); - } - } - - public class Message_Client_onUpdateData_xz_yp : Message - { - - public Message_Client_onUpdateData_xz_yp(MessageID msgid, string msgname, Int16 length, sbyte argstype, List msgargtypes): - base(msgid, msgname, length, argstype, msgargtypes) - { - - } - - public override void handleMessage(MemoryStream msgstream) - { - KBEngineApp.app.Client_onUpdateData_xz_yp(msgstream); - } - } - - public class Message_Client_onUpdateData_xz_yr : Message - { - - public Message_Client_onUpdateData_xz_yr(MessageID msgid, string msgname, Int16 length, sbyte argstype, List msgargtypes): - base(msgid, msgname, length, argstype, msgargtypes) - { - - } - - public override void handleMessage(MemoryStream msgstream) - { - KBEngineApp.app.Client_onUpdateData_xz_yr(msgstream); - } - } - - public class Message_Client_onUpdateData_xz_pr : Message - { - - public Message_Client_onUpdateData_xz_pr(MessageID msgid, string msgname, Int16 length, sbyte argstype, List msgargtypes): - base(msgid, msgname, length, argstype, msgargtypes) - { - - } - - public override void handleMessage(MemoryStream msgstream) - { - KBEngineApp.app.Client_onUpdateData_xz_pr(msgstream); - } - } - - public class Message_Client_onUpdateData_xz_y : Message - { - - public Message_Client_onUpdateData_xz_y(MessageID msgid, string msgname, Int16 length, sbyte argstype, List msgargtypes): - base(msgid, msgname, length, argstype, msgargtypes) - { - - } - - public override void handleMessage(MemoryStream msgstream) - { - KBEngineApp.app.Client_onUpdateData_xz_y(msgstream); - } - } - - public class Message_Client_onUpdateData_xz_p : Message - { - - public Message_Client_onUpdateData_xz_p(MessageID msgid, string msgname, Int16 length, sbyte argstype, List msgargtypes): - base(msgid, msgname, length, argstype, msgargtypes) - { - - } - - public override void handleMessage(MemoryStream msgstream) - { - KBEngineApp.app.Client_onUpdateData_xz_p(msgstream); - } - } - - public class Message_Client_onUpdateData_xz_r : Message - { - - public Message_Client_onUpdateData_xz_r(MessageID msgid, string msgname, Int16 length, sbyte argstype, List msgargtypes): - base(msgid, msgname, length, argstype, msgargtypes) - { - - } - - public override void handleMessage(MemoryStream msgstream) - { - KBEngineApp.app.Client_onUpdateData_xz_r(msgstream); - } - } - - public class Message_Client_onUpdateData_xyz : Message - { - - public Message_Client_onUpdateData_xyz(MessageID msgid, string msgname, Int16 length, sbyte argstype, List msgargtypes): - base(msgid, msgname, length, argstype, msgargtypes) - { - - } - - public override void handleMessage(MemoryStream msgstream) - { - KBEngineApp.app.Client_onUpdateData_xyz(msgstream); - } - } - - public class Message_Client_onUpdateData_xyz_ypr : Message - { - - public Message_Client_onUpdateData_xyz_ypr(MessageID msgid, string msgname, Int16 length, sbyte argstype, List msgargtypes): - base(msgid, msgname, length, argstype, msgargtypes) - { - - } - - public override void handleMessage(MemoryStream msgstream) - { - KBEngineApp.app.Client_onUpdateData_xyz_ypr(msgstream); - } - } - - public class Message_Client_onUpdateData_xyz_yp : Message - { - - public Message_Client_onUpdateData_xyz_yp(MessageID msgid, string msgname, Int16 length, sbyte argstype, List msgargtypes): - base(msgid, msgname, length, argstype, msgargtypes) - { - - } - - public override void handleMessage(MemoryStream msgstream) - { - KBEngineApp.app.Client_onUpdateData_xyz_yp(msgstream); - } - } - - public class Message_Client_onUpdateData_xyz_yr : Message - { - - public Message_Client_onUpdateData_xyz_yr(MessageID msgid, string msgname, Int16 length, sbyte argstype, List msgargtypes): - base(msgid, msgname, length, argstype, msgargtypes) - { - - } - - public override void handleMessage(MemoryStream msgstream) - { - KBEngineApp.app.Client_onUpdateData_xyz_yr(msgstream); - } - } - - public class Message_Client_onUpdateData_xyz_pr : Message - { - - public Message_Client_onUpdateData_xyz_pr(MessageID msgid, string msgname, Int16 length, sbyte argstype, List msgargtypes): - base(msgid, msgname, length, argstype, msgargtypes) - { - - } - - public override void handleMessage(MemoryStream msgstream) - { - KBEngineApp.app.Client_onUpdateData_xyz_pr(msgstream); - } - } - - public class Message_Client_onUpdateData_xyz_y : Message - { - - public Message_Client_onUpdateData_xyz_y(MessageID msgid, string msgname, Int16 length, sbyte argstype, List msgargtypes): - base(msgid, msgname, length, argstype, msgargtypes) - { - - } - - public override void handleMessage(MemoryStream msgstream) - { - KBEngineApp.app.Client_onUpdateData_xyz_y(msgstream); - } - } - - public class Message_Client_onUpdateData_xyz_p : Message - { - - public Message_Client_onUpdateData_xyz_p(MessageID msgid, string msgname, Int16 length, sbyte argstype, List msgargtypes): - base(msgid, msgname, length, argstype, msgargtypes) - { - - } - - public override void handleMessage(MemoryStream msgstream) - { - KBEngineApp.app.Client_onUpdateData_xyz_p(msgstream); - } - } - - public class Message_Client_onUpdateData_xyz_r : Message - { - - public Message_Client_onUpdateData_xyz_r(MessageID msgid, string msgname, Int16 length, sbyte argstype, List msgargtypes): - base(msgid, msgname, length, argstype, msgargtypes) - { - - } - - public override void handleMessage(MemoryStream msgstream) - { - KBEngineApp.app.Client_onUpdateData_xyz_r(msgstream); - } - } - - public class Message_Client_onUpdateData_ypr_optimized : Message - { - - public Message_Client_onUpdateData_ypr_optimized(MessageID msgid, string msgname, Int16 length, sbyte argstype, List msgargtypes): - base(msgid, msgname, length, argstype, msgargtypes) - { - - } - - public override void handleMessage(MemoryStream msgstream) - { - KBEngineApp.app.Client_onUpdateData_ypr_optimized(msgstream); - } - } - - public class Message_Client_onUpdateData_yp_optimized : Message - { - - public Message_Client_onUpdateData_yp_optimized(MessageID msgid, string msgname, Int16 length, sbyte argstype, List msgargtypes): - base(msgid, msgname, length, argstype, msgargtypes) - { - - } - - public override void handleMessage(MemoryStream msgstream) - { - KBEngineApp.app.Client_onUpdateData_yp_optimized(msgstream); - } - } - - public class Message_Client_onUpdateData_yr_optimized : Message - { - - public Message_Client_onUpdateData_yr_optimized(MessageID msgid, string msgname, Int16 length, sbyte argstype, List msgargtypes): - base(msgid, msgname, length, argstype, msgargtypes) - { - - } - - public override void handleMessage(MemoryStream msgstream) - { - KBEngineApp.app.Client_onUpdateData_yr_optimized(msgstream); - } - } - - public class Message_Client_onUpdateData_pr_optimized : Message - { - - public Message_Client_onUpdateData_pr_optimized(MessageID msgid, string msgname, Int16 length, sbyte argstype, List msgargtypes): - base(msgid, msgname, length, argstype, msgargtypes) - { - - } - - public override void handleMessage(MemoryStream msgstream) - { - KBEngineApp.app.Client_onUpdateData_pr_optimized(msgstream); - } - } - - public class Message_Client_onUpdateData_y_optimized : Message - { - - public Message_Client_onUpdateData_y_optimized(MessageID msgid, string msgname, Int16 length, sbyte argstype, List msgargtypes): - base(msgid, msgname, length, argstype, msgargtypes) - { - - } - - public override void handleMessage(MemoryStream msgstream) - { - KBEngineApp.app.Client_onUpdateData_y_optimized(msgstream); - } - } - - public class Message_Client_onUpdateData_p_optimized : Message - { - - public Message_Client_onUpdateData_p_optimized(MessageID msgid, string msgname, Int16 length, sbyte argstype, List msgargtypes): - base(msgid, msgname, length, argstype, msgargtypes) - { - - } - - public override void handleMessage(MemoryStream msgstream) - { - KBEngineApp.app.Client_onUpdateData_p_optimized(msgstream); - } - } - - public class Message_Client_onUpdateData_r_optimized : Message - { - - public Message_Client_onUpdateData_r_optimized(MessageID msgid, string msgname, Int16 length, sbyte argstype, List msgargtypes): - base(msgid, msgname, length, argstype, msgargtypes) - { - - } - - public override void handleMessage(MemoryStream msgstream) - { - KBEngineApp.app.Client_onUpdateData_r_optimized(msgstream); - } - } - - public class Message_Client_onUpdateData_xz_optimized : Message - { - - public Message_Client_onUpdateData_xz_optimized(MessageID msgid, string msgname, Int16 length, sbyte argstype, List msgargtypes): - base(msgid, msgname, length, argstype, msgargtypes) - { - - } - - public override void handleMessage(MemoryStream msgstream) - { - KBEngineApp.app.Client_onUpdateData_xz_optimized(msgstream); - } - } - - public class Message_Client_onUpdateData_xz_ypr_optimized : Message - { - - public Message_Client_onUpdateData_xz_ypr_optimized(MessageID msgid, string msgname, Int16 length, sbyte argstype, List msgargtypes): - base(msgid, msgname, length, argstype, msgargtypes) - { - - } - - public override void handleMessage(MemoryStream msgstream) - { - KBEngineApp.app.Client_onUpdateData_xz_ypr_optimized(msgstream); - } - } - - public class Message_Client_onUpdateData_xz_yp_optimized : Message - { - - public Message_Client_onUpdateData_xz_yp_optimized(MessageID msgid, string msgname, Int16 length, sbyte argstype, List msgargtypes): - base(msgid, msgname, length, argstype, msgargtypes) - { - - } - - public override void handleMessage(MemoryStream msgstream) - { - KBEngineApp.app.Client_onUpdateData_xz_yp_optimized(msgstream); - } - } - - public class Message_Client_onUpdateData_xz_yr_optimized : Message - { - - public Message_Client_onUpdateData_xz_yr_optimized(MessageID msgid, string msgname, Int16 length, sbyte argstype, List msgargtypes): - base(msgid, msgname, length, argstype, msgargtypes) - { - - } - - public override void handleMessage(MemoryStream msgstream) - { - KBEngineApp.app.Client_onUpdateData_xz_yr_optimized(msgstream); - } - } - - public class Message_Client_onUpdateData_xz_pr_optimized : Message - { - - public Message_Client_onUpdateData_xz_pr_optimized(MessageID msgid, string msgname, Int16 length, sbyte argstype, List msgargtypes): - base(msgid, msgname, length, argstype, msgargtypes) - { - - } - - public override void handleMessage(MemoryStream msgstream) - { - KBEngineApp.app.Client_onUpdateData_xz_pr_optimized(msgstream); - } - } - - public class Message_Client_onUpdateData_xz_y_optimized : Message - { - - public Message_Client_onUpdateData_xz_y_optimized(MessageID msgid, string msgname, Int16 length, sbyte argstype, List msgargtypes): - base(msgid, msgname, length, argstype, msgargtypes) - { - - } - - public override void handleMessage(MemoryStream msgstream) - { - KBEngineApp.app.Client_onUpdateData_xz_y_optimized(msgstream); - } - } - - public class Message_Client_onUpdateData_xz_p_optimized : Message - { - - public Message_Client_onUpdateData_xz_p_optimized(MessageID msgid, string msgname, Int16 length, sbyte argstype, List msgargtypes): - base(msgid, msgname, length, argstype, msgargtypes) - { - - } - - public override void handleMessage(MemoryStream msgstream) - { - KBEngineApp.app.Client_onUpdateData_xz_p_optimized(msgstream); - } - } - - public class Message_Client_onUpdateData_xz_r_optimized : Message - { - - public Message_Client_onUpdateData_xz_r_optimized(MessageID msgid, string msgname, Int16 length, sbyte argstype, List msgargtypes): - base(msgid, msgname, length, argstype, msgargtypes) - { - - } - - public override void handleMessage(MemoryStream msgstream) - { - KBEngineApp.app.Client_onUpdateData_xz_r_optimized(msgstream); - } - } - - public class Message_Client_onUpdateData_xyz_optimized : Message - { - - public Message_Client_onUpdateData_xyz_optimized(MessageID msgid, string msgname, Int16 length, sbyte argstype, List msgargtypes): - base(msgid, msgname, length, argstype, msgargtypes) - { - - } - - public override void handleMessage(MemoryStream msgstream) - { - KBEngineApp.app.Client_onUpdateData_xyz_optimized(msgstream); - } - } - - public class Message_Client_onUpdateData_xyz_ypr_optimized : Message - { - - public Message_Client_onUpdateData_xyz_ypr_optimized(MessageID msgid, string msgname, Int16 length, sbyte argstype, List msgargtypes): - base(msgid, msgname, length, argstype, msgargtypes) - { - - } - - public override void handleMessage(MemoryStream msgstream) - { - KBEngineApp.app.Client_onUpdateData_xyz_ypr_optimized(msgstream); - } - } - - public class Message_Client_onUpdateData_xyz_yp_optimized : Message - { - - public Message_Client_onUpdateData_xyz_yp_optimized(MessageID msgid, string msgname, Int16 length, sbyte argstype, List msgargtypes): - base(msgid, msgname, length, argstype, msgargtypes) - { - - } - - public override void handleMessage(MemoryStream msgstream) - { - KBEngineApp.app.Client_onUpdateData_xyz_yp_optimized(msgstream); - } - } - - public class Message_Client_onUpdateData_xyz_yr_optimized : Message - { - - public Message_Client_onUpdateData_xyz_yr_optimized(MessageID msgid, string msgname, Int16 length, sbyte argstype, List msgargtypes): - base(msgid, msgname, length, argstype, msgargtypes) - { - - } - - public override void handleMessage(MemoryStream msgstream) - { - KBEngineApp.app.Client_onUpdateData_xyz_yr_optimized(msgstream); - } - } - - public class Message_Client_onUpdateData_xyz_pr_optimized : Message - { - - public Message_Client_onUpdateData_xyz_pr_optimized(MessageID msgid, string msgname, Int16 length, sbyte argstype, List msgargtypes): - base(msgid, msgname, length, argstype, msgargtypes) - { - - } - - public override void handleMessage(MemoryStream msgstream) - { - KBEngineApp.app.Client_onUpdateData_xyz_pr_optimized(msgstream); - } - } - - public class Message_Client_onUpdateData_xyz_y_optimized : Message - { - - public Message_Client_onUpdateData_xyz_y_optimized(MessageID msgid, string msgname, Int16 length, sbyte argstype, List msgargtypes): - base(msgid, msgname, length, argstype, msgargtypes) - { - - } - - public override void handleMessage(MemoryStream msgstream) - { - KBEngineApp.app.Client_onUpdateData_xyz_y_optimized(msgstream); - } - } - - public class Message_Client_onUpdateData_xyz_p_optimized : Message - { - - public Message_Client_onUpdateData_xyz_p_optimized(MessageID msgid, string msgname, Int16 length, sbyte argstype, List msgargtypes): - base(msgid, msgname, length, argstype, msgargtypes) - { - - } - - public override void handleMessage(MemoryStream msgstream) - { - KBEngineApp.app.Client_onUpdateData_xyz_p_optimized(msgstream); - } - } - - public class Message_Client_onUpdateData_xyz_r_optimized : Message - { - - public Message_Client_onUpdateData_xyz_r_optimized(MessageID msgid, string msgname, Int16 length, sbyte argstype, List msgargtypes): - base(msgid, msgname, length, argstype, msgargtypes) - { - - } - - public override void handleMessage(MemoryStream msgstream) - { - KBEngineApp.app.Client_onUpdateData_xyz_r_optimized(msgstream); - } - } - - public class Message_Client_onImportServerErrorsDescr : Message - { - - public Message_Client_onImportServerErrorsDescr(MessageID msgid, string msgname, Int16 length, sbyte argstype, List msgargtypes): - base(msgid, msgname, length, argstype, msgargtypes) - { - - } - - public override void handleMessage(MemoryStream msgstream) - { - KBEngineApp.app.Client_onImportServerErrorsDescr(msgstream); - } - } - - public class Message_Client_onImportClientSDK : Message - { - - public Message_Client_onImportClientSDK(MessageID msgid, string msgname, Int16 length, sbyte argstype, List msgargtypes): - base(msgid, msgname, length, argstype, msgargtypes) - { - - } - - public override void handleMessage(MemoryStream msgstream) - { - KBEngineApp.app.Client_onImportClientSDK(msgstream); - } - } - - public class Message_Client_initSpaceData : Message - { - - public Message_Client_initSpaceData(MessageID msgid, string msgname, Int16 length, sbyte argstype, List msgargtypes): - base(msgid, msgname, length, argstype, msgargtypes) - { - - } - - public override void handleMessage(MemoryStream msgstream) - { - KBEngineApp.app.Client_initSpaceData(msgstream); - } - } - - public class Message_Client_setSpaceData : Message - { - - public Message_Client_setSpaceData(MessageID msgid, string msgname, Int16 length, sbyte argstype, List msgargtypes): - base(msgid, msgname, length, argstype, msgargtypes) - { - - } - - public override void handleMessage(MemoryStream msgstream) - { - UInt32 arg1 = msgstream.readUint32(); - string arg2 = msgstream.readString(); - string arg3 = msgstream.readString(); - KBEngineApp.app.Client_setSpaceData(arg1, arg2, arg3); - } - } - - public class Message_Client_delSpaceData : Message - { - - public Message_Client_delSpaceData(MessageID msgid, string msgname, Int16 length, sbyte argstype, List msgargtypes): - base(msgid, msgname, length, argstype, msgargtypes) - { - - } - - public override void handleMessage(MemoryStream msgstream) - { - UInt32 arg1 = msgstream.readUint32(); - string arg2 = msgstream.readString(); - KBEngineApp.app.Client_delSpaceData(arg1, arg2); - } - } - - public class Message_Client_onReqAccountResetPasswordCB : Message - { - - public Message_Client_onReqAccountResetPasswordCB(MessageID msgid, string msgname, Int16 length, sbyte argstype, List msgargtypes): - base(msgid, msgname, length, argstype, msgargtypes) - { - - } - - public override void handleMessage(MemoryStream msgstream) - { - UInt16 arg1 = msgstream.readUint16(); - KBEngineApp.app.Client_onReqAccountResetPasswordCB(arg1); - } - } - - public class Message_Client_onReqAccountBindEmailCB : Message - { - - public Message_Client_onReqAccountBindEmailCB(MessageID msgid, string msgname, Int16 length, sbyte argstype, List msgargtypes): - base(msgid, msgname, length, argstype, msgargtypes) - { - - } - - public override void handleMessage(MemoryStream msgstream) - { - UInt16 arg1 = msgstream.readUint16(); - KBEngineApp.app.Client_onReqAccountBindEmailCB(arg1); - } - } - - public class Message_Client_onReqAccountNewPasswordCB : Message - { - - public Message_Client_onReqAccountNewPasswordCB(MessageID msgid, string msgname, Int16 length, sbyte argstype, List msgargtypes): - base(msgid, msgname, length, argstype, msgargtypes) - { - - } - - public override void handleMessage(MemoryStream msgstream) - { - UInt16 arg1 = msgstream.readUint16(); - KBEngineApp.app.Client_onReqAccountNewPasswordCB(arg1); - } - } - - public class Message_Client_onReloginBaseappSuccessfully : Message - { - - public Message_Client_onReloginBaseappSuccessfully(MessageID msgid, string msgname, Int16 length, sbyte argstype, List msgargtypes): - base(msgid, msgname, length, argstype, msgargtypes) - { - - } - - public override void handleMessage(MemoryStream msgstream) - { - KBEngineApp.app.Client_onReloginBaseappSuccessfully(msgstream); - } - } - - public class Message_Client_onAppActiveTickCB : Message - { - - public Message_Client_onAppActiveTickCB(MessageID msgid, string msgname, Int16 length, sbyte argstype, List msgargtypes): - base(msgid, msgname, length, argstype, msgargtypes) - { - - } - - public override void handleMessage(MemoryStream msgstream) - { - KBEngineApp.app.Client_onAppActiveTickCB(); - } - } - - public class Message_Client_onCreateAccountResult : Message - { - - public Message_Client_onCreateAccountResult(MessageID msgid, string msgname, Int16 length, sbyte argstype, List msgargtypes): - base(msgid, msgname, length, argstype, msgargtypes) - { - - } - - public override void handleMessage(MemoryStream msgstream) - { - KBEngineApp.app.Client_onCreateAccountResult(msgstream); - } - } - - public class Message_Client_onLoginSuccessfully : Message - { - - public Message_Client_onLoginSuccessfully(MessageID msgid, string msgname, Int16 length, sbyte argstype, List msgargtypes): - base(msgid, msgname, length, argstype, msgargtypes) - { - - } - - public override void handleMessage(MemoryStream msgstream) - { - KBEngineApp.app.Client_onLoginSuccessfully(msgstream); - } - } - - public class Message_Client_onLoginFailed : Message - { - - public Message_Client_onLoginFailed(MessageID msgid, string msgname, Int16 length, sbyte argstype, List msgargtypes): - base(msgid, msgname, length, argstype, msgargtypes) - { - - } - - public override void handleMessage(MemoryStream msgstream) - { - KBEngineApp.app.Client_onLoginFailed(msgstream); - } - } - - public class Message_Client_onCreatedProxies : Message - { - - public Message_Client_onCreatedProxies(MessageID msgid, string msgname, Int16 length, sbyte argstype, List msgargtypes): - base(msgid, msgname, length, argstype, msgargtypes) - { - - } - - public override void handleMessage(MemoryStream msgstream) - { - UInt64 arg1 = msgstream.readUint64(); - Int32 arg2 = msgstream.readInt32(); - string arg3 = msgstream.readString(); - KBEngineApp.app.Client_onCreatedProxies(arg1, arg2, arg3); - } - } - - public class Message_Client_onLoginBaseappFailed : Message - { - - public Message_Client_onLoginBaseappFailed(MessageID msgid, string msgname, Int16 length, sbyte argstype, List msgargtypes): - base(msgid, msgname, length, argstype, msgargtypes) - { - - } - - public override void handleMessage(MemoryStream msgstream) - { - UInt16 arg1 = msgstream.readUint16(); - KBEngineApp.app.Client_onLoginBaseappFailed(arg1); - } - } - - public class Message_Client_onRemoteMethodCall : Message - { - - public Message_Client_onRemoteMethodCall(MessageID msgid, string msgname, Int16 length, sbyte argstype, List msgargtypes): - base(msgid, msgname, length, argstype, msgargtypes) - { - - } - - public override void handleMessage(MemoryStream msgstream) - { - KBEngineApp.app.Client_onRemoteMethodCall(msgstream); - } - } - - public class Message_Client_onEntityEnterWorld : Message - { - - public Message_Client_onEntityEnterWorld(MessageID msgid, string msgname, Int16 length, sbyte argstype, List msgargtypes): - base(msgid, msgname, length, argstype, msgargtypes) - { - - } - - public override void handleMessage(MemoryStream msgstream) - { - KBEngineApp.app.Client_onEntityEnterWorld(msgstream); - } - } - - public class Message_Client_onEntityLeaveWorld : Message - { - - public Message_Client_onEntityLeaveWorld(MessageID msgid, string msgname, Int16 length, sbyte argstype, List msgargtypes): - base(msgid, msgname, length, argstype, msgargtypes) - { - - } - - public override void handleMessage(MemoryStream msgstream) - { - Int32 arg1 = msgstream.readInt32(); - KBEngineApp.app.Client_onEntityLeaveWorld(arg1); - } - } - - public class Message_Client_onEntityEnterSpace : Message - { - - public Message_Client_onEntityEnterSpace(MessageID msgid, string msgname, Int16 length, sbyte argstype, List msgargtypes): - base(msgid, msgname, length, argstype, msgargtypes) - { - - } - - public override void handleMessage(MemoryStream msgstream) - { - KBEngineApp.app.Client_onEntityEnterSpace(msgstream); - } - } - - public class Message_Client_onEntityLeaveSpace : Message - { - - public Message_Client_onEntityLeaveSpace(MessageID msgid, string msgname, Int16 length, sbyte argstype, List msgargtypes): - base(msgid, msgname, length, argstype, msgargtypes) - { - - } - - public override void handleMessage(MemoryStream msgstream) - { - Int32 arg1 = msgstream.readInt32(); - KBEngineApp.app.Client_onEntityLeaveSpace(arg1); - } - } - - public class Message_Client_onUpdatePropertys : Message - { - - public Message_Client_onUpdatePropertys(MessageID msgid, string msgname, Int16 length, sbyte argstype, List msgargtypes): - base(msgid, msgname, length, argstype, msgargtypes) - { - - } - - public override void handleMessage(MemoryStream msgstream) - { - KBEngineApp.app.Client_onUpdatePropertys(msgstream); - } - } - - public class Message_Client_onEntityDestroyed : Message - { - - public Message_Client_onEntityDestroyed(MessageID msgid, string msgname, Int16 length, sbyte argstype, List msgargtypes): - base(msgid, msgname, length, argstype, msgargtypes) - { - - } - - public override void handleMessage(MemoryStream msgstream) - { - Int32 arg1 = msgstream.readInt32(); - KBEngineApp.app.Client_onEntityDestroyed(arg1); - } - } - - public class Message_Client_onStreamDataStarted : Message - { - - public Message_Client_onStreamDataStarted(MessageID msgid, string msgname, Int16 length, sbyte argstype, List msgargtypes): - base(msgid, msgname, length, argstype, msgargtypes) - { - - } - - public override void handleMessage(MemoryStream msgstream) - { - Int16 arg1 = msgstream.readInt16(); - UInt32 arg2 = msgstream.readUint32(); - string arg3 = msgstream.readString(); - KBEngineApp.app.Client_onStreamDataStarted(arg1, arg2, arg3); - } - } - - public class Message_Client_onStreamDataRecv : Message - { - - public Message_Client_onStreamDataRecv(MessageID msgid, string msgname, Int16 length, sbyte argstype, List msgargtypes): - base(msgid, msgname, length, argstype, msgargtypes) - { - - } - - public override void handleMessage(MemoryStream msgstream) - { - KBEngineApp.app.Client_onStreamDataRecv(msgstream); - } - } - - public class Message_Client_onStreamDataCompleted : Message - { - - public Message_Client_onStreamDataCompleted(MessageID msgid, string msgname, Int16 length, sbyte argstype, List msgargtypes): - base(msgid, msgname, length, argstype, msgargtypes) - { - - } - - public override void handleMessage(MemoryStream msgstream) - { - Int16 arg1 = msgstream.readInt16(); - KBEngineApp.app.Client_onStreamDataCompleted(arg1); - } - } - - public class Message_Client_onKicked : Message - { - - public Message_Client_onKicked(MessageID msgid, string msgname, Int16 length, sbyte argstype, List msgargtypes): - base(msgid, msgname, length, argstype, msgargtypes) - { - - } - - public override void handleMessage(MemoryStream msgstream) - { - UInt16 arg1 = msgstream.readUint16(); - KBEngineApp.app.Client_onKicked(arg1); - } - } - - public class Message_Client_onImportClientMessages : Message - { - - public Message_Client_onImportClientMessages(MessageID msgid, string msgname, Int16 length, sbyte argstype, List msgargtypes): - base(msgid, msgname, length, argstype, msgargtypes) - { - - } - - public override void handleMessage(MemoryStream msgstream) - { - KBEngineApp.app.Client_onImportClientMessages(msgstream); - } - } - - public class Message_Client_onImportClientEntityDef : Message - { - - public Message_Client_onImportClientEntityDef(MessageID msgid, string msgname, Int16 length, sbyte argstype, List msgargtypes): - base(msgid, msgname, length, argstype, msgargtypes) - { - - } - - public override void handleMessage(MemoryStream msgstream) - { - KBEngineApp.app.Client_onImportClientEntityDef(msgstream); - } - } - - public class Message_Client_onHelloCB : Message - { - - public Message_Client_onHelloCB(MessageID msgid, string msgname, Int16 length, sbyte argstype, List msgargtypes): - base(msgid, msgname, length, argstype, msgargtypes) - { - - } - - public override void handleMessage(MemoryStream msgstream) - { - KBEngineApp.app.Client_onHelloCB(msgstream); - } - } - - public class Message_Client_onScriptVersionNotMatch : Message - { - - public Message_Client_onScriptVersionNotMatch(MessageID msgid, string msgname, Int16 length, sbyte argstype, List msgargtypes): - base(msgid, msgname, length, argstype, msgargtypes) - { - - } - - public override void handleMessage(MemoryStream msgstream) - { - KBEngineApp.app.Client_onScriptVersionNotMatch(msgstream); - } - } - - public class Message_Client_onVersionNotMatch : Message - { - - public Message_Client_onVersionNotMatch(MessageID msgid, string msgname, Int16 length, sbyte argstype, List msgargtypes): - base(msgid, msgname, length, argstype, msgargtypes) - { - - } - - public override void handleMessage(MemoryStream msgstream) - { - KBEngineApp.app.Client_onVersionNotMatch(msgstream); - } - } - - public class Message_Client_onControlEntity : Message - { - - public Message_Client_onControlEntity(MessageID msgid, string msgname, Int16 length, sbyte argstype, List msgargtypes): - base(msgid, msgname, length, argstype, msgargtypes) - { - - } - - public override void handleMessage(MemoryStream msgstream) - { - Int32 arg1 = msgstream.readInt32(); - SByte arg2 = msgstream.readInt8(); - KBEngineApp.app.Client_onControlEntity(arg1, arg2); - } - } - - public class Message_Loginapp_reqCreateAccount : Message - { - - public Message_Loginapp_reqCreateAccount(MessageID msgid, string msgname, Int16 length, sbyte argstype, List msgargtypes): - base(msgid, msgname, length, argstype, msgargtypes) - { - - } - - public override void handleMessage(MemoryStream msgstream) - { - } - } - - public class Message_Loginapp_login : Message - { - - public Message_Loginapp_login(MessageID msgid, string msgname, Int16 length, sbyte argstype, List msgargtypes): - base(msgid, msgname, length, argstype, msgargtypes) - { - - } - - public override void handleMessage(MemoryStream msgstream) - { - } - } - - public class Message_Loginapp_hello : Message - { - - public Message_Loginapp_hello(MessageID msgid, string msgname, Int16 length, sbyte argstype, List msgargtypes): - base(msgid, msgname, length, argstype, msgargtypes) - { - - } - - public override void handleMessage(MemoryStream msgstream) - { - } - } - - public class Message_Loginapp_importClientMessages : Message - { - - public Message_Loginapp_importClientMessages(MessageID msgid, string msgname, Int16 length, sbyte argstype, List msgargtypes): - base(msgid, msgname, length, argstype, msgargtypes) - { - - } - - public override void handleMessage(MemoryStream msgstream) - { - } - } - - public class Message_Loginapp_reqCreateMailAccount : Message - { - - public Message_Loginapp_reqCreateMailAccount(MessageID msgid, string msgname, Int16 length, sbyte argstype, List msgargtypes): - base(msgid, msgname, length, argstype, msgargtypes) - { - - } - - public override void handleMessage(MemoryStream msgstream) - { - } - } - - public class Message_Loginapp_importClientSDK : Message - { - - public Message_Loginapp_importClientSDK(MessageID msgid, string msgname, Int16 length, sbyte argstype, List msgargtypes): - base(msgid, msgname, length, argstype, msgargtypes) - { - - } - - public override void handleMessage(MemoryStream msgstream) - { - } - } - - public class Message_Loginapp_importServerErrorsDescr : Message - { - - public Message_Loginapp_importServerErrorsDescr(MessageID msgid, string msgname, Int16 length, sbyte argstype, List msgargtypes): - base(msgid, msgname, length, argstype, msgargtypes) - { - - } - - public override void handleMessage(MemoryStream msgstream) - { - } - } - - public class Message_Loginapp_onClientActiveTick : Message - { - - public Message_Loginapp_onClientActiveTick(MessageID msgid, string msgname, Int16 length, sbyte argstype, List msgargtypes): - base(msgid, msgname, length, argstype, msgargtypes) - { - - } - - public override void handleMessage(MemoryStream msgstream) - { - } - } - - public class Message_Loginapp_reqAccountResetPassword : Message - { - - public Message_Loginapp_reqAccountResetPassword(MessageID msgid, string msgname, Int16 length, sbyte argstype, List msgargtypes): - base(msgid, msgname, length, argstype, msgargtypes) - { - - } - - public override void handleMessage(MemoryStream msgstream) - { - } - } - - public class Message_Baseapp_logoutBaseapp : Message - { - - public Message_Baseapp_logoutBaseapp(MessageID msgid, string msgname, Int16 length, sbyte argstype, List msgargtypes): - base(msgid, msgname, length, argstype, msgargtypes) - { - - } - - public override void handleMessage(MemoryStream msgstream) - { - } - } - - public class Message_Baseapp_onUpdateDataFromClient : Message - { - - public Message_Baseapp_onUpdateDataFromClient(MessageID msgid, string msgname, Int16 length, sbyte argstype, List msgargtypes): - base(msgid, msgname, length, argstype, msgargtypes) - { - - } - - public override void handleMessage(MemoryStream msgstream) - { - } - } - - public class Message_Baseapp_onUpdateDataFromClientForControlledEntity : Message - { - - public Message_Baseapp_onUpdateDataFromClientForControlledEntity(MessageID msgid, string msgname, Int16 length, sbyte argstype, List msgargtypes): - base(msgid, msgname, length, argstype, msgargtypes) - { - - } - - public override void handleMessage(MemoryStream msgstream) - { - } - } - - public class Message_Baseapp_reqAccountBindEmail : Message - { - - public Message_Baseapp_reqAccountBindEmail(MessageID msgid, string msgname, Int16 length, sbyte argstype, List msgargtypes): - base(msgid, msgname, length, argstype, msgargtypes) - { - - } - - public override void handleMessage(MemoryStream msgstream) - { - } - } - - public class Message_Baseapp_reqAccountNewPassword : Message - { - - public Message_Baseapp_reqAccountNewPassword(MessageID msgid, string msgname, Int16 length, sbyte argstype, List msgargtypes): - base(msgid, msgname, length, argstype, msgargtypes) - { - - } - - public override void handleMessage(MemoryStream msgstream) - { - } - } - - public class Message_Entity_forwardEntityMessageToCellappFromClient : Message - { - - public Message_Entity_forwardEntityMessageToCellappFromClient(MessageID msgid, string msgname, Int16 length, sbyte argstype, List msgargtypes): - base(msgid, msgname, length, argstype, msgargtypes) - { - - } - - public override void handleMessage(MemoryStream msgstream) - { - } - } - - public class Message_Baseapp_hello : Message - { - - public Message_Baseapp_hello(MessageID msgid, string msgname, Int16 length, sbyte argstype, List msgargtypes): - base(msgid, msgname, length, argstype, msgargtypes) - { - - } - - public override void handleMessage(MemoryStream msgstream) - { - } - } - - public class Message_Baseapp_loginBaseapp : Message - { - - public Message_Baseapp_loginBaseapp(MessageID msgid, string msgname, Int16 length, sbyte argstype, List msgargtypes): - base(msgid, msgname, length, argstype, msgargtypes) - { - - } - - public override void handleMessage(MemoryStream msgstream) - { - } - } - - public class Message_Baseapp_reloginBaseapp : Message - { - - public Message_Baseapp_reloginBaseapp(MessageID msgid, string msgname, Int16 length, sbyte argstype, List msgargtypes): - base(msgid, msgname, length, argstype, msgargtypes) - { - - } - - public override void handleMessage(MemoryStream msgstream) - { - } - } - - public class Message_Baseapp_onRemoteCallCellMethodFromClient : Message - { - - public Message_Baseapp_onRemoteCallCellMethodFromClient(MessageID msgid, string msgname, Int16 length, sbyte argstype, List msgargtypes): - base(msgid, msgname, length, argstype, msgargtypes) - { - - } - - public override void handleMessage(MemoryStream msgstream) - { - } - } - - public class Message_Baseapp_onClientActiveTick : Message - { - - public Message_Baseapp_onClientActiveTick(MessageID msgid, string msgname, Int16 length, sbyte argstype, List msgargtypes): - base(msgid, msgname, length, argstype, msgargtypes) - { - - } - - public override void handleMessage(MemoryStream msgstream) - { - } - } - - public class Message_Baseapp_importClientMessages : Message - { - - public Message_Baseapp_importClientMessages(MessageID msgid, string msgname, Int16 length, sbyte argstype, List msgargtypes): - base(msgid, msgname, length, argstype, msgargtypes) - { - - } - - public override void handleMessage(MemoryStream msgstream) - { - } - } - - public class Message_Baseapp_importClientEntityDef : Message - { - - public Message_Baseapp_importClientEntityDef(MessageID msgid, string msgname, Int16 length, sbyte argstype, List msgargtypes): - base(msgid, msgname, length, argstype, msgargtypes) - { - - } - - public override void handleMessage(MemoryStream msgstream) - { - } - } - - public class Message_Entity_onRemoteMethodCall : Message - { - - public Message_Entity_onRemoteMethodCall(MessageID msgid, string msgname, Int16 length, sbyte argstype, List msgargtypes): - base(msgid, msgname, length, argstype, msgargtypes) - { - - } - - public override void handleMessage(MemoryStream msgstream) - { - } - } - - public class Messages - { - public static Dictionary loginappMessages = new Dictionary(); - public static Dictionary baseappMessages = new Dictionary(); - public static Dictionary clientMessages = new Dictionary(); - public static Dictionary messages = new Dictionary(); - - public static void clear() - { - loginappMessages = new Dictionary(); - baseappMessages = new Dictionary(); - clientMessages = new Dictionary(); - messages = new Dictionary(); - - init(); - } - - - public static bool init() - { - - List Client_onReloginBaseappFailed_argstypes = new List(); - Client_onReloginBaseappFailed_argstypes.Add(3); - Messages.messages["Client_onReloginBaseappFailed"] = new Message_Client_onReloginBaseappFailed(8, "Client_onReloginBaseappFailed", 2, 0, Client_onReloginBaseappFailed_argstypes); - Messages.clientMessages[8] = Messages.messages["Client_onReloginBaseappFailed"]; - - Messages.messages["Client_onEntityLeaveWorldOptimized"] = new Message_Client_onEntityLeaveWorldOptimized(9, "Client_onEntityLeaveWorldOptimized", -1, -1, new List()); - Messages.clientMessages[9] = Messages.messages["Client_onEntityLeaveWorldOptimized"]; - - Messages.messages["Client_onRemoteMethodCallOptimized"] = new Message_Client_onRemoteMethodCallOptimized(10, "Client_onRemoteMethodCallOptimized", -1, -1, new List()); - Messages.clientMessages[10] = Messages.messages["Client_onRemoteMethodCallOptimized"]; - - Messages.messages["Client_onUpdatePropertysOptimized"] = new Message_Client_onUpdatePropertysOptimized(11, "Client_onUpdatePropertysOptimized", -1, -1, new List()); - Messages.clientMessages[11] = Messages.messages["Client_onUpdatePropertysOptimized"]; - - Messages.messages["Client_onSetEntityPosAndDir"] = new Message_Client_onSetEntityPosAndDir(12, "Client_onSetEntityPosAndDir", -1, -1, new List()); - Messages.clientMessages[12] = Messages.messages["Client_onSetEntityPosAndDir"]; - - - List Client_onUpdateBasePos_argstypes = new List(); - Client_onUpdateBasePos_argstypes.Add(13); - Client_onUpdateBasePos_argstypes.Add(13); - Client_onUpdateBasePos_argstypes.Add(13); - Messages.messages["Client_onUpdateBasePos"] = new Message_Client_onUpdateBasePos(13, "Client_onUpdateBasePos", 12, 0, Client_onUpdateBasePos_argstypes); - Messages.clientMessages[13] = Messages.messages["Client_onUpdateBasePos"]; - - Messages.messages["Client_onUpdateBaseDir"] = new Message_Client_onUpdateBaseDir(14, "Client_onUpdateBaseDir", -1, -1, new List()); - Messages.clientMessages[14] = Messages.messages["Client_onUpdateBaseDir"]; - - - List Client_onUpdateBasePosXZ_argstypes = new List(); - Client_onUpdateBasePosXZ_argstypes.Add(13); - Client_onUpdateBasePosXZ_argstypes.Add(13); - Messages.messages["Client_onUpdateBasePosXZ"] = new Message_Client_onUpdateBasePosXZ(15, "Client_onUpdateBasePosXZ", 8, 0, Client_onUpdateBasePosXZ_argstypes); - Messages.clientMessages[15] = Messages.messages["Client_onUpdateBasePosXZ"]; - - Messages.messages["Client_onUpdateData"] = new Message_Client_onUpdateData(16, "Client_onUpdateData", -1, -1, new List()); - Messages.clientMessages[16] = Messages.messages["Client_onUpdateData"]; - - Messages.messages["Client_onUpdateData_ypr"] = new Message_Client_onUpdateData_ypr(17, "Client_onUpdateData_ypr", -1, -1, new List()); - Messages.clientMessages[17] = Messages.messages["Client_onUpdateData_ypr"]; - - Messages.messages["Client_onUpdateData_yp"] = new Message_Client_onUpdateData_yp(18, "Client_onUpdateData_yp", -1, -1, new List()); - Messages.clientMessages[18] = Messages.messages["Client_onUpdateData_yp"]; - - Messages.messages["Client_onUpdateData_yr"] = new Message_Client_onUpdateData_yr(19, "Client_onUpdateData_yr", -1, -1, new List()); - Messages.clientMessages[19] = Messages.messages["Client_onUpdateData_yr"]; - - Messages.messages["Client_onUpdateData_pr"] = new Message_Client_onUpdateData_pr(20, "Client_onUpdateData_pr", -1, -1, new List()); - Messages.clientMessages[20] = Messages.messages["Client_onUpdateData_pr"]; - - Messages.messages["Client_onUpdateData_y"] = new Message_Client_onUpdateData_y(21, "Client_onUpdateData_y", -1, -1, new List()); - Messages.clientMessages[21] = Messages.messages["Client_onUpdateData_y"]; - - Messages.messages["Client_onUpdateData_p"] = new Message_Client_onUpdateData_p(22, "Client_onUpdateData_p", -1, -1, new List()); - Messages.clientMessages[22] = Messages.messages["Client_onUpdateData_p"]; - - Messages.messages["Client_onUpdateData_r"] = new Message_Client_onUpdateData_r(23, "Client_onUpdateData_r", -1, -1, new List()); - Messages.clientMessages[23] = Messages.messages["Client_onUpdateData_r"]; - - Messages.messages["Client_onUpdateData_xz"] = new Message_Client_onUpdateData_xz(24, "Client_onUpdateData_xz", -1, -1, new List()); - Messages.clientMessages[24] = Messages.messages["Client_onUpdateData_xz"]; - - Messages.messages["Client_onUpdateData_xz_ypr"] = new Message_Client_onUpdateData_xz_ypr(25, "Client_onUpdateData_xz_ypr", -1, -1, new List()); - Messages.clientMessages[25] = Messages.messages["Client_onUpdateData_xz_ypr"]; - - Messages.messages["Client_onUpdateData_xz_yp"] = new Message_Client_onUpdateData_xz_yp(26, "Client_onUpdateData_xz_yp", -1, -1, new List()); - Messages.clientMessages[26] = Messages.messages["Client_onUpdateData_xz_yp"]; - - Messages.messages["Client_onUpdateData_xz_yr"] = new Message_Client_onUpdateData_xz_yr(27, "Client_onUpdateData_xz_yr", -1, -1, new List()); - Messages.clientMessages[27] = Messages.messages["Client_onUpdateData_xz_yr"]; - - Messages.messages["Client_onUpdateData_xz_pr"] = new Message_Client_onUpdateData_xz_pr(28, "Client_onUpdateData_xz_pr", -1, -1, new List()); - Messages.clientMessages[28] = Messages.messages["Client_onUpdateData_xz_pr"]; - - Messages.messages["Client_onUpdateData_xz_y"] = new Message_Client_onUpdateData_xz_y(29, "Client_onUpdateData_xz_y", -1, -1, new List()); - Messages.clientMessages[29] = Messages.messages["Client_onUpdateData_xz_y"]; - - Messages.messages["Client_onUpdateData_xz_p"] = new Message_Client_onUpdateData_xz_p(30, "Client_onUpdateData_xz_p", -1, -1, new List()); - Messages.clientMessages[30] = Messages.messages["Client_onUpdateData_xz_p"]; - - Messages.messages["Client_onUpdateData_xz_r"] = new Message_Client_onUpdateData_xz_r(31, "Client_onUpdateData_xz_r", -1, -1, new List()); - Messages.clientMessages[31] = Messages.messages["Client_onUpdateData_xz_r"]; - - Messages.messages["Client_onUpdateData_xyz"] = new Message_Client_onUpdateData_xyz(32, "Client_onUpdateData_xyz", -1, -1, new List()); - Messages.clientMessages[32] = Messages.messages["Client_onUpdateData_xyz"]; - - Messages.messages["Client_onUpdateData_xyz_ypr"] = new Message_Client_onUpdateData_xyz_ypr(33, "Client_onUpdateData_xyz_ypr", -1, -1, new List()); - Messages.clientMessages[33] = Messages.messages["Client_onUpdateData_xyz_ypr"]; - - Messages.messages["Client_onUpdateData_xyz_yp"] = new Message_Client_onUpdateData_xyz_yp(34, "Client_onUpdateData_xyz_yp", -1, -1, new List()); - Messages.clientMessages[34] = Messages.messages["Client_onUpdateData_xyz_yp"]; - - Messages.messages["Client_onUpdateData_xyz_yr"] = new Message_Client_onUpdateData_xyz_yr(35, "Client_onUpdateData_xyz_yr", -1, -1, new List()); - Messages.clientMessages[35] = Messages.messages["Client_onUpdateData_xyz_yr"]; - - Messages.messages["Client_onUpdateData_xyz_pr"] = new Message_Client_onUpdateData_xyz_pr(36, "Client_onUpdateData_xyz_pr", -1, -1, new List()); - Messages.clientMessages[36] = Messages.messages["Client_onUpdateData_xyz_pr"]; - - Messages.messages["Client_onUpdateData_xyz_y"] = new Message_Client_onUpdateData_xyz_y(37, "Client_onUpdateData_xyz_y", -1, -1, new List()); - Messages.clientMessages[37] = Messages.messages["Client_onUpdateData_xyz_y"]; - - Messages.messages["Client_onUpdateData_xyz_p"] = new Message_Client_onUpdateData_xyz_p(38, "Client_onUpdateData_xyz_p", -1, -1, new List()); - Messages.clientMessages[38] = Messages.messages["Client_onUpdateData_xyz_p"]; - - Messages.messages["Client_onUpdateData_xyz_r"] = new Message_Client_onUpdateData_xyz_r(39, "Client_onUpdateData_xyz_r", -1, -1, new List()); - Messages.clientMessages[39] = Messages.messages["Client_onUpdateData_xyz_r"]; - - Messages.messages["Client_onUpdateData_ypr_optimized"] = new Message_Client_onUpdateData_ypr_optimized(40, "Client_onUpdateData_ypr_optimized", -1, -1, new List()); - Messages.clientMessages[40] = Messages.messages["Client_onUpdateData_ypr_optimized"]; - - Messages.messages["Client_onUpdateData_yp_optimized"] = new Message_Client_onUpdateData_yp_optimized(41, "Client_onUpdateData_yp_optimized", -1, -1, new List()); - Messages.clientMessages[41] = Messages.messages["Client_onUpdateData_yp_optimized"]; - - Messages.messages["Client_onUpdateData_yr_optimized"] = new Message_Client_onUpdateData_yr_optimized(42, "Client_onUpdateData_yr_optimized", -1, -1, new List()); - Messages.clientMessages[42] = Messages.messages["Client_onUpdateData_yr_optimized"]; - - Messages.messages["Client_onUpdateData_pr_optimized"] = new Message_Client_onUpdateData_pr_optimized(43, "Client_onUpdateData_pr_optimized", -1, -1, new List()); - Messages.clientMessages[43] = Messages.messages["Client_onUpdateData_pr_optimized"]; - - Messages.messages["Client_onUpdateData_y_optimized"] = new Message_Client_onUpdateData_y_optimized(44, "Client_onUpdateData_y_optimized", -1, -1, new List()); - Messages.clientMessages[44] = Messages.messages["Client_onUpdateData_y_optimized"]; - - Messages.messages["Client_onUpdateData_p_optimized"] = new Message_Client_onUpdateData_p_optimized(45, "Client_onUpdateData_p_optimized", -1, -1, new List()); - Messages.clientMessages[45] = Messages.messages["Client_onUpdateData_p_optimized"]; - - Messages.messages["Client_onUpdateData_r_optimized"] = new Message_Client_onUpdateData_r_optimized(46, "Client_onUpdateData_r_optimized", -1, -1, new List()); - Messages.clientMessages[46] = Messages.messages["Client_onUpdateData_r_optimized"]; - - Messages.messages["Client_onUpdateData_xz_optimized"] = new Message_Client_onUpdateData_xz_optimized(47, "Client_onUpdateData_xz_optimized", -1, -1, new List()); - Messages.clientMessages[47] = Messages.messages["Client_onUpdateData_xz_optimized"]; - - Messages.messages["Client_onUpdateData_xz_ypr_optimized"] = new Message_Client_onUpdateData_xz_ypr_optimized(48, "Client_onUpdateData_xz_ypr_optimized", -1, -1, new List()); - Messages.clientMessages[48] = Messages.messages["Client_onUpdateData_xz_ypr_optimized"]; - - Messages.messages["Client_onUpdateData_xz_yp_optimized"] = new Message_Client_onUpdateData_xz_yp_optimized(49, "Client_onUpdateData_xz_yp_optimized", -1, -1, new List()); - Messages.clientMessages[49] = Messages.messages["Client_onUpdateData_xz_yp_optimized"]; - - Messages.messages["Client_onUpdateData_xz_yr_optimized"] = new Message_Client_onUpdateData_xz_yr_optimized(50, "Client_onUpdateData_xz_yr_optimized", -1, -1, new List()); - Messages.clientMessages[50] = Messages.messages["Client_onUpdateData_xz_yr_optimized"]; - - Messages.messages["Client_onUpdateData_xz_pr_optimized"] = new Message_Client_onUpdateData_xz_pr_optimized(51, "Client_onUpdateData_xz_pr_optimized", -1, -1, new List()); - Messages.clientMessages[51] = Messages.messages["Client_onUpdateData_xz_pr_optimized"]; - - Messages.messages["Client_onUpdateData_xz_y_optimized"] = new Message_Client_onUpdateData_xz_y_optimized(52, "Client_onUpdateData_xz_y_optimized", -1, -1, new List()); - Messages.clientMessages[52] = Messages.messages["Client_onUpdateData_xz_y_optimized"]; - - Messages.messages["Client_onUpdateData_xz_p_optimized"] = new Message_Client_onUpdateData_xz_p_optimized(53, "Client_onUpdateData_xz_p_optimized", -1, -1, new List()); - Messages.clientMessages[53] = Messages.messages["Client_onUpdateData_xz_p_optimized"]; - - Messages.messages["Client_onUpdateData_xz_r_optimized"] = new Message_Client_onUpdateData_xz_r_optimized(54, "Client_onUpdateData_xz_r_optimized", -1, -1, new List()); - Messages.clientMessages[54] = Messages.messages["Client_onUpdateData_xz_r_optimized"]; - - Messages.messages["Client_onUpdateData_xyz_optimized"] = new Message_Client_onUpdateData_xyz_optimized(55, "Client_onUpdateData_xyz_optimized", -1, -1, new List()); - Messages.clientMessages[55] = Messages.messages["Client_onUpdateData_xyz_optimized"]; - - Messages.messages["Client_onUpdateData_xyz_ypr_optimized"] = new Message_Client_onUpdateData_xyz_ypr_optimized(56, "Client_onUpdateData_xyz_ypr_optimized", -1, -1, new List()); - Messages.clientMessages[56] = Messages.messages["Client_onUpdateData_xyz_ypr_optimized"]; - - Messages.messages["Client_onUpdateData_xyz_yp_optimized"] = new Message_Client_onUpdateData_xyz_yp_optimized(57, "Client_onUpdateData_xyz_yp_optimized", -1, -1, new List()); - Messages.clientMessages[57] = Messages.messages["Client_onUpdateData_xyz_yp_optimized"]; - - Messages.messages["Client_onUpdateData_xyz_yr_optimized"] = new Message_Client_onUpdateData_xyz_yr_optimized(58, "Client_onUpdateData_xyz_yr_optimized", -1, -1, new List()); - Messages.clientMessages[58] = Messages.messages["Client_onUpdateData_xyz_yr_optimized"]; - - Messages.messages["Client_onUpdateData_xyz_pr_optimized"] = new Message_Client_onUpdateData_xyz_pr_optimized(59, "Client_onUpdateData_xyz_pr_optimized", -1, -1, new List()); - Messages.clientMessages[59] = Messages.messages["Client_onUpdateData_xyz_pr_optimized"]; - - Messages.messages["Client_onUpdateData_xyz_y_optimized"] = new Message_Client_onUpdateData_xyz_y_optimized(60, "Client_onUpdateData_xyz_y_optimized", -1, -1, new List()); - Messages.clientMessages[60] = Messages.messages["Client_onUpdateData_xyz_y_optimized"]; - - Messages.messages["Client_onUpdateData_xyz_p_optimized"] = new Message_Client_onUpdateData_xyz_p_optimized(61, "Client_onUpdateData_xyz_p_optimized", -1, -1, new List()); - Messages.clientMessages[61] = Messages.messages["Client_onUpdateData_xyz_p_optimized"]; - - Messages.messages["Client_onUpdateData_xyz_r_optimized"] = new Message_Client_onUpdateData_xyz_r_optimized(62, "Client_onUpdateData_xyz_r_optimized", -1, -1, new List()); - Messages.clientMessages[62] = Messages.messages["Client_onUpdateData_xyz_r_optimized"]; - - Messages.messages["Client_onImportServerErrorsDescr"] = new Message_Client_onImportServerErrorsDescr(63, "Client_onImportServerErrorsDescr", -1, -1, new List()); - Messages.clientMessages[63] = Messages.messages["Client_onImportServerErrorsDescr"]; - - Messages.messages["Client_onImportClientSDK"] = new Message_Client_onImportClientSDK(64, "Client_onImportClientSDK", -1, -1, new List()); - Messages.clientMessages[64] = Messages.messages["Client_onImportClientSDK"]; - - Messages.messages["Client_initSpaceData"] = new Message_Client_initSpaceData(65, "Client_initSpaceData", -1, -1, new List()); - Messages.clientMessages[65] = Messages.messages["Client_initSpaceData"]; - - - List Client_setSpaceData_argstypes = new List(); - Client_setSpaceData_argstypes.Add(4); - Client_setSpaceData_argstypes.Add(1); - Client_setSpaceData_argstypes.Add(1); - Messages.messages["Client_setSpaceData"] = new Message_Client_setSpaceData(66, "Client_setSpaceData", -1, 0, Client_setSpaceData_argstypes); - Messages.clientMessages[66] = Messages.messages["Client_setSpaceData"]; - - - List Client_delSpaceData_argstypes = new List(); - Client_delSpaceData_argstypes.Add(4); - Client_delSpaceData_argstypes.Add(1); - Messages.messages["Client_delSpaceData"] = new Message_Client_delSpaceData(67, "Client_delSpaceData", -1, 0, Client_delSpaceData_argstypes); - Messages.clientMessages[67] = Messages.messages["Client_delSpaceData"]; - - - List Client_onReqAccountResetPasswordCB_argstypes = new List(); - Client_onReqAccountResetPasswordCB_argstypes.Add(3); - Messages.messages["Client_onReqAccountResetPasswordCB"] = new Message_Client_onReqAccountResetPasswordCB(68, "Client_onReqAccountResetPasswordCB", 2, 0, Client_onReqAccountResetPasswordCB_argstypes); - Messages.clientMessages[68] = Messages.messages["Client_onReqAccountResetPasswordCB"]; - - - List Client_onReqAccountBindEmailCB_argstypes = new List(); - Client_onReqAccountBindEmailCB_argstypes.Add(3); - Messages.messages["Client_onReqAccountBindEmailCB"] = new Message_Client_onReqAccountBindEmailCB(69, "Client_onReqAccountBindEmailCB", 2, 0, Client_onReqAccountBindEmailCB_argstypes); - Messages.clientMessages[69] = Messages.messages["Client_onReqAccountBindEmailCB"]; - - - List Client_onReqAccountNewPasswordCB_argstypes = new List(); - Client_onReqAccountNewPasswordCB_argstypes.Add(3); - Messages.messages["Client_onReqAccountNewPasswordCB"] = new Message_Client_onReqAccountNewPasswordCB(70, "Client_onReqAccountNewPasswordCB", 2, 0, Client_onReqAccountNewPasswordCB_argstypes); - Messages.clientMessages[70] = Messages.messages["Client_onReqAccountNewPasswordCB"]; - - Messages.messages["Client_onReloginBaseappSuccessfully"] = new Message_Client_onReloginBaseappSuccessfully(71, "Client_onReloginBaseappSuccessfully", -1, -1, new List()); - Messages.clientMessages[71] = Messages.messages["Client_onReloginBaseappSuccessfully"]; - - Messages.messages["Client_onAppActiveTickCB"] = new Message_Client_onAppActiveTickCB(72, "Client_onAppActiveTickCB", 0, 0, new List()); - Messages.clientMessages[72] = Messages.messages["Client_onAppActiveTickCB"]; - - Messages.messages["Client_onCreateAccountResult"] = new Message_Client_onCreateAccountResult(501, "Client_onCreateAccountResult", -1, -1, new List()); - Messages.clientMessages[501] = Messages.messages["Client_onCreateAccountResult"]; - - Messages.messages["Client_onLoginSuccessfully"] = new Message_Client_onLoginSuccessfully(502, "Client_onLoginSuccessfully", -1, -1, new List()); - Messages.clientMessages[502] = Messages.messages["Client_onLoginSuccessfully"]; - - Messages.messages["Client_onLoginFailed"] = new Message_Client_onLoginFailed(503, "Client_onLoginFailed", -1, -1, new List()); - Messages.clientMessages[503] = Messages.messages["Client_onLoginFailed"]; - - - List Client_onCreatedProxies_argstypes = new List(); - Client_onCreatedProxies_argstypes.Add(5); - Client_onCreatedProxies_argstypes.Add(8); - Client_onCreatedProxies_argstypes.Add(1); - Messages.messages["Client_onCreatedProxies"] = new Message_Client_onCreatedProxies(504, "Client_onCreatedProxies", -1, 0, Client_onCreatedProxies_argstypes); - Messages.clientMessages[504] = Messages.messages["Client_onCreatedProxies"]; - - - List Client_onLoginBaseappFailed_argstypes = new List(); - Client_onLoginBaseappFailed_argstypes.Add(3); - Messages.messages["Client_onLoginBaseappFailed"] = new Message_Client_onLoginBaseappFailed(505, "Client_onLoginBaseappFailed", 2, 0, Client_onLoginBaseappFailed_argstypes); - Messages.clientMessages[505] = Messages.messages["Client_onLoginBaseappFailed"]; - - Messages.messages["Client_onRemoteMethodCall"] = new Message_Client_onRemoteMethodCall(506, "Client_onRemoteMethodCall", -1, -1, new List()); - Messages.clientMessages[506] = Messages.messages["Client_onRemoteMethodCall"]; - - Messages.messages["Client_onEntityEnterWorld"] = new Message_Client_onEntityEnterWorld(507, "Client_onEntityEnterWorld", -1, -1, new List()); - Messages.clientMessages[507] = Messages.messages["Client_onEntityEnterWorld"]; - - - List Client_onEntityLeaveWorld_argstypes = new List(); - Client_onEntityLeaveWorld_argstypes.Add(8); - Messages.messages["Client_onEntityLeaveWorld"] = new Message_Client_onEntityLeaveWorld(508, "Client_onEntityLeaveWorld", 4, 0, Client_onEntityLeaveWorld_argstypes); - Messages.clientMessages[508] = Messages.messages["Client_onEntityLeaveWorld"]; - - Messages.messages["Client_onEntityEnterSpace"] = new Message_Client_onEntityEnterSpace(509, "Client_onEntityEnterSpace", -1, -1, new List()); - Messages.clientMessages[509] = Messages.messages["Client_onEntityEnterSpace"]; - - - List Client_onEntityLeaveSpace_argstypes = new List(); - Client_onEntityLeaveSpace_argstypes.Add(8); - Messages.messages["Client_onEntityLeaveSpace"] = new Message_Client_onEntityLeaveSpace(510, "Client_onEntityLeaveSpace", 4, 0, Client_onEntityLeaveSpace_argstypes); - Messages.clientMessages[510] = Messages.messages["Client_onEntityLeaveSpace"]; - - Messages.messages["Client_onUpdatePropertys"] = new Message_Client_onUpdatePropertys(511, "Client_onUpdatePropertys", -1, -1, new List()); - Messages.clientMessages[511] = Messages.messages["Client_onUpdatePropertys"]; - - - List Client_onEntityDestroyed_argstypes = new List(); - Client_onEntityDestroyed_argstypes.Add(8); - Messages.messages["Client_onEntityDestroyed"] = new Message_Client_onEntityDestroyed(512, "Client_onEntityDestroyed", 4, 0, Client_onEntityDestroyed_argstypes); - Messages.clientMessages[512] = Messages.messages["Client_onEntityDestroyed"]; - - - List Client_onStreamDataStarted_argstypes = new List(); - Client_onStreamDataStarted_argstypes.Add(7); - Client_onStreamDataStarted_argstypes.Add(4); - Client_onStreamDataStarted_argstypes.Add(1); - Messages.messages["Client_onStreamDataStarted"] = new Message_Client_onStreamDataStarted(514, "Client_onStreamDataStarted", -1, 0, Client_onStreamDataStarted_argstypes); - Messages.clientMessages[514] = Messages.messages["Client_onStreamDataStarted"]; - - Messages.messages["Client_onStreamDataRecv"] = new Message_Client_onStreamDataRecv(515, "Client_onStreamDataRecv", -1, -1, new List()); - Messages.clientMessages[515] = Messages.messages["Client_onStreamDataRecv"]; - - - List Client_onStreamDataCompleted_argstypes = new List(); - Client_onStreamDataCompleted_argstypes.Add(7); - Messages.messages["Client_onStreamDataCompleted"] = new Message_Client_onStreamDataCompleted(516, "Client_onStreamDataCompleted", 2, 0, Client_onStreamDataCompleted_argstypes); - Messages.clientMessages[516] = Messages.messages["Client_onStreamDataCompleted"]; - - - List Client_onKicked_argstypes = new List(); - Client_onKicked_argstypes.Add(3); - Messages.messages["Client_onKicked"] = new Message_Client_onKicked(517, "Client_onKicked", 2, 0, Client_onKicked_argstypes); - Messages.clientMessages[517] = Messages.messages["Client_onKicked"]; - - Messages.messages["Client_onImportClientMessages"] = new Message_Client_onImportClientMessages(518, "Client_onImportClientMessages", -1, -1, new List()); - Messages.clientMessages[518] = Messages.messages["Client_onImportClientMessages"]; - - Messages.messages["Client_onImportClientEntityDef"] = new Message_Client_onImportClientEntityDef(519, "Client_onImportClientEntityDef", -1, -1, new List()); - Messages.clientMessages[519] = Messages.messages["Client_onImportClientEntityDef"]; - - Messages.messages["Client_onHelloCB"] = new Message_Client_onHelloCB(521, "Client_onHelloCB", -1, -1, new List()); - Messages.clientMessages[521] = Messages.messages["Client_onHelloCB"]; - - Messages.messages["Client_onScriptVersionNotMatch"] = new Message_Client_onScriptVersionNotMatch(522, "Client_onScriptVersionNotMatch", -1, -1, new List()); - Messages.clientMessages[522] = Messages.messages["Client_onScriptVersionNotMatch"]; - - Messages.messages["Client_onVersionNotMatch"] = new Message_Client_onVersionNotMatch(523, "Client_onVersionNotMatch", -1, -1, new List()); - Messages.clientMessages[523] = Messages.messages["Client_onVersionNotMatch"]; - - - List Client_onControlEntity_argstypes = new List(); - Client_onControlEntity_argstypes.Add(8); - Client_onControlEntity_argstypes.Add(6); - Messages.messages["Client_onControlEntity"] = new Message_Client_onControlEntity(524, "Client_onControlEntity", 5, 0, Client_onControlEntity_argstypes); - Messages.clientMessages[524] = Messages.messages["Client_onControlEntity"]; - - Messages.messages["Loginapp_reqCreateAccount"] = new Message_Loginapp_reqCreateAccount(2, "Loginapp_reqCreateAccount", -1, 0, new List()); - Messages.loginappMessages[2] = Messages.messages["Loginapp_reqCreateAccount"]; - - Messages.messages["Loginapp_login"] = new Message_Loginapp_login(3, "Loginapp_login", -1, 0, new List()); - Messages.loginappMessages[3] = Messages.messages["Loginapp_login"]; - - Messages.messages["Loginapp_hello"] = new Message_Loginapp_hello(4, "Loginapp_hello", -1, 0, new List()); - Messages.loginappMessages[4] = Messages.messages["Loginapp_hello"]; - - Messages.messages["Loginapp_importClientMessages"] = new Message_Loginapp_importClientMessages(5, "Loginapp_importClientMessages", 0, 0, new List()); - Messages.loginappMessages[5] = Messages.messages["Loginapp_importClientMessages"]; - - Messages.messages["Loginapp_reqCreateMailAccount"] = new Message_Loginapp_reqCreateMailAccount(6, "Loginapp_reqCreateMailAccount", -1, 0, new List()); - Messages.loginappMessages[6] = Messages.messages["Loginapp_reqCreateMailAccount"]; - - Messages.messages["Loginapp_importClientSDK"] = new Message_Loginapp_importClientSDK(7, "Loginapp_importClientSDK", -1, 0, new List()); - Messages.loginappMessages[7] = Messages.messages["Loginapp_importClientSDK"]; - - Messages.messages["Loginapp_importServerErrorsDescr"] = new Message_Loginapp_importServerErrorsDescr(8, "Loginapp_importServerErrorsDescr", 0, 0, new List()); - Messages.loginappMessages[8] = Messages.messages["Loginapp_importServerErrorsDescr"]; - - Messages.messages["Loginapp_onClientActiveTick"] = new Message_Loginapp_onClientActiveTick(11, "Loginapp_onClientActiveTick", 0, 0, new List()); - Messages.loginappMessages[11] = Messages.messages["Loginapp_onClientActiveTick"]; - - - List Loginapp_reqAccountResetPassword_argstypes = new List(); - Loginapp_reqAccountResetPassword_argstypes.Add(1); - Messages.messages["Loginapp_reqAccountResetPassword"] = new Message_Loginapp_reqAccountResetPassword(12, "Loginapp_reqAccountResetPassword", -1, 0, Loginapp_reqAccountResetPassword_argstypes); - Messages.loginappMessages[12] = Messages.messages["Loginapp_reqAccountResetPassword"]; - - - List Baseapp_logoutBaseapp_argstypes = new List(); - Baseapp_logoutBaseapp_argstypes.Add(5); - Baseapp_logoutBaseapp_argstypes.Add(8); - Messages.messages["Baseapp_logoutBaseapp"] = new Message_Baseapp_logoutBaseapp(24, "Baseapp_logoutBaseapp", 12, 0, Baseapp_logoutBaseapp_argstypes); - Messages.baseappMessages[24] = Messages.messages["Baseapp_logoutBaseapp"]; - - Messages.messages["Baseapp_onUpdateDataFromClient"] = new Message_Baseapp_onUpdateDataFromClient(27, "Baseapp_onUpdateDataFromClient", -1, -1, new List()); - Messages.baseappMessages[27] = Messages.messages["Baseapp_onUpdateDataFromClient"]; - - Messages.messages["Baseapp_onUpdateDataFromClientForControlledEntity"] = new Message_Baseapp_onUpdateDataFromClientForControlledEntity(28, "Baseapp_onUpdateDataFromClientForControlledEntity", -1, -1, new List()); - Messages.baseappMessages[28] = Messages.messages["Baseapp_onUpdateDataFromClientForControlledEntity"]; - - - List Baseapp_reqAccountBindEmail_argstypes = new List(); - Baseapp_reqAccountBindEmail_argstypes.Add(8); - Baseapp_reqAccountBindEmail_argstypes.Add(1); - Baseapp_reqAccountBindEmail_argstypes.Add(1); - Messages.messages["Baseapp_reqAccountBindEmail"] = new Message_Baseapp_reqAccountBindEmail(50, "Baseapp_reqAccountBindEmail", -1, 0, Baseapp_reqAccountBindEmail_argstypes); - Messages.baseappMessages[50] = Messages.messages["Baseapp_reqAccountBindEmail"]; - - - List Baseapp_reqAccountNewPassword_argstypes = new List(); - Baseapp_reqAccountNewPassword_argstypes.Add(8); - Baseapp_reqAccountNewPassword_argstypes.Add(1); - Baseapp_reqAccountNewPassword_argstypes.Add(1); - Messages.messages["Baseapp_reqAccountNewPassword"] = new Message_Baseapp_reqAccountNewPassword(53, "Baseapp_reqAccountNewPassword", -1, 0, Baseapp_reqAccountNewPassword_argstypes); - Messages.baseappMessages[53] = Messages.messages["Baseapp_reqAccountNewPassword"]; - - Messages.messages["Entity_forwardEntityMessageToCellappFromClient"] = new Message_Entity_forwardEntityMessageToCellappFromClient(57, "Entity_forwardEntityMessageToCellappFromClient", -1, -1, new List()); - Messages.baseappMessages[57] = Messages.messages["Entity_forwardEntityMessageToCellappFromClient"]; - - Messages.messages["Baseapp_hello"] = new Message_Baseapp_hello(200, "Baseapp_hello", -1, -1, new List()); - Messages.baseappMessages[200] = Messages.messages["Baseapp_hello"]; - - - List Baseapp_loginBaseapp_argstypes = new List(); - Baseapp_loginBaseapp_argstypes.Add(1); - Baseapp_loginBaseapp_argstypes.Add(1); - Messages.messages["Baseapp_loginBaseapp"] = new Message_Baseapp_loginBaseapp(202, "Baseapp_loginBaseapp", -1, 0, Baseapp_loginBaseapp_argstypes); - Messages.baseappMessages[202] = Messages.messages["Baseapp_loginBaseapp"]; - - - List Baseapp_reloginBaseapp_argstypes = new List(); - Baseapp_reloginBaseapp_argstypes.Add(1); - Baseapp_reloginBaseapp_argstypes.Add(1); - Baseapp_reloginBaseapp_argstypes.Add(5); - Baseapp_reloginBaseapp_argstypes.Add(8); - Messages.messages["Baseapp_reloginBaseapp"] = new Message_Baseapp_reloginBaseapp(204, "Baseapp_reloginBaseapp", -1, 0, Baseapp_reloginBaseapp_argstypes); - Messages.baseappMessages[204] = Messages.messages["Baseapp_reloginBaseapp"]; - - Messages.messages["Baseapp_onRemoteCallCellMethodFromClient"] = new Message_Baseapp_onRemoteCallCellMethodFromClient(205, "Baseapp_onRemoteCallCellMethodFromClient", -1, -1, new List()); - Messages.baseappMessages[205] = Messages.messages["Baseapp_onRemoteCallCellMethodFromClient"]; - - Messages.messages["Baseapp_onClientActiveTick"] = new Message_Baseapp_onClientActiveTick(206, "Baseapp_onClientActiveTick", 0, 0, new List()); - Messages.baseappMessages[206] = Messages.messages["Baseapp_onClientActiveTick"]; - - Messages.messages["Baseapp_importClientMessages"] = new Message_Baseapp_importClientMessages(207, "Baseapp_importClientMessages", 0, 0, new List()); - Messages.baseappMessages[207] = Messages.messages["Baseapp_importClientMessages"]; - - Messages.messages["Baseapp_importClientEntityDef"] = new Message_Baseapp_importClientEntityDef(208, "Baseapp_importClientEntityDef", 0, 0, new List()); - Messages.baseappMessages[208] = Messages.messages["Baseapp_importClientEntityDef"]; - - Messages.messages["Entity_onRemoteMethodCall"] = new Message_Entity_onRemoteMethodCall(302, "Entity_onRemoteMethodCall", -1, -1, new List()); - Messages.baseappMessages[302] = Messages.messages["Entity_onRemoteMethodCall"]; - - - return true; - } - } +/* + Generated by KBEngine! + Please do not modify this file! + tools = kbcmd +*/ + +namespace KBEngine +{ + using UnityEngine; + using System; + using System.Collections; + using System.Collections.Generic; + + using MessageID = System.UInt16; + + // engine-c++ messages + + public class Message + { + public MessageID id = 0; + public string name; + public Int16 msglen = -1; + public List argtypes = null; + public sbyte argsType = 0; + + public Message(MessageID msgid, string msgname, Int16 length, sbyte argstype, List msgargtypes) + { + id = msgid; + name = msgname; + msglen = length; + argsType = argstype; + + argtypes = msgargtypes; + // Dbg.DEBUG_MSG(string.Format("Message::Message() : ({ 0 } / {1} / {2})!", + // msgname, msgid, msglen)); + } + + public virtual void handleMessage(MemoryStream msgstream) + { + } + } + + public class Message_Client_onReloginBaseappFailed : Message + { + + public Message_Client_onReloginBaseappFailed(MessageID msgid, string msgname, Int16 length, sbyte argstype, List msgargtypes): + base(msgid, msgname, length, argstype, msgargtypes) + { + + } + + public override void handleMessage(MemoryStream msgstream) + { + UInt16 arg1 = msgstream.readUint16(); + KBEngineApp.app.Client_onReloginBaseappFailed(arg1); + } + } + + public class Message_Client_onEntityLeaveWorldOptimized : Message + { + + public Message_Client_onEntityLeaveWorldOptimized(MessageID msgid, string msgname, Int16 length, sbyte argstype, List msgargtypes): + base(msgid, msgname, length, argstype, msgargtypes) + { + + } + + public override void handleMessage(MemoryStream msgstream) + { + KBEngineApp.app.Client_onEntityLeaveWorldOptimized(msgstream); + } + } + + public class Message_Client_onRemoteMethodCallOptimized : Message + { + + public Message_Client_onRemoteMethodCallOptimized(MessageID msgid, string msgname, Int16 length, sbyte argstype, List msgargtypes): + base(msgid, msgname, length, argstype, msgargtypes) + { + + } + + public override void handleMessage(MemoryStream msgstream) + { + KBEngineApp.app.Client_onRemoteMethodCallOptimized(msgstream); + } + } + + public class Message_Client_onUpdatePropertysOptimized : Message + { + + public Message_Client_onUpdatePropertysOptimized(MessageID msgid, string msgname, Int16 length, sbyte argstype, List msgargtypes): + base(msgid, msgname, length, argstype, msgargtypes) + { + + } + + public override void handleMessage(MemoryStream msgstream) + { + KBEngineApp.app.Client_onUpdatePropertysOptimized(msgstream); + } + } + + public class Message_Client_onSetEntityPosAndDir : Message + { + + public Message_Client_onSetEntityPosAndDir(MessageID msgid, string msgname, Int16 length, sbyte argstype, List msgargtypes): + base(msgid, msgname, length, argstype, msgargtypes) + { + + } + + public override void handleMessage(MemoryStream msgstream) + { + KBEngineApp.app.Client_onSetEntityPosAndDir(msgstream); + } + } + + public class Message_Client_onUpdateBasePos : Message + { + + public Message_Client_onUpdateBasePos(MessageID msgid, string msgname, Int16 length, sbyte argstype, List msgargtypes): + base(msgid, msgname, length, argstype, msgargtypes) + { + + } + + public override void handleMessage(MemoryStream msgstream) + { + float arg1 = msgstream.readFloat(); + float arg2 = msgstream.readFloat(); + float arg3 = msgstream.readFloat(); + KBEngineApp.app.Client_onUpdateBasePos(arg1, arg2, arg3); + } + } + + public class Message_Client_onUpdateBaseDir : Message + { + + public Message_Client_onUpdateBaseDir(MessageID msgid, string msgname, Int16 length, sbyte argstype, List msgargtypes): + base(msgid, msgname, length, argstype, msgargtypes) + { + + } + + public override void handleMessage(MemoryStream msgstream) + { + KBEngineApp.app.Client_onUpdateBaseDir(msgstream); + } + } + + public class Message_Client_onUpdateBasePosXZ : Message + { + + public Message_Client_onUpdateBasePosXZ(MessageID msgid, string msgname, Int16 length, sbyte argstype, List msgargtypes): + base(msgid, msgname, length, argstype, msgargtypes) + { + + } + + public override void handleMessage(MemoryStream msgstream) + { + float arg1 = msgstream.readFloat(); + float arg2 = msgstream.readFloat(); + KBEngineApp.app.Client_onUpdateBasePosXZ(arg1, arg2); + } + } + + public class Message_Client_onUpdateData : Message + { + + public Message_Client_onUpdateData(MessageID msgid, string msgname, Int16 length, sbyte argstype, List msgargtypes): + base(msgid, msgname, length, argstype, msgargtypes) + { + + } + + public override void handleMessage(MemoryStream msgstream) + { + KBEngineApp.app.Client_onUpdateData(msgstream); + } + } + + public class Message_Client_onUpdateData_ypr : Message + { + + public Message_Client_onUpdateData_ypr(MessageID msgid, string msgname, Int16 length, sbyte argstype, List msgargtypes): + base(msgid, msgname, length, argstype, msgargtypes) + { + + } + + public override void handleMessage(MemoryStream msgstream) + { + KBEngineApp.app.Client_onUpdateData_ypr(msgstream); + } + } + + public class Message_Client_onUpdateData_yp : Message + { + + public Message_Client_onUpdateData_yp(MessageID msgid, string msgname, Int16 length, sbyte argstype, List msgargtypes): + base(msgid, msgname, length, argstype, msgargtypes) + { + + } + + public override void handleMessage(MemoryStream msgstream) + { + KBEngineApp.app.Client_onUpdateData_yp(msgstream); + } + } + + public class Message_Client_onUpdateData_yr : Message + { + + public Message_Client_onUpdateData_yr(MessageID msgid, string msgname, Int16 length, sbyte argstype, List msgargtypes): + base(msgid, msgname, length, argstype, msgargtypes) + { + + } + + public override void handleMessage(MemoryStream msgstream) + { + KBEngineApp.app.Client_onUpdateData_yr(msgstream); + } + } + + public class Message_Client_onUpdateData_pr : Message + { + + public Message_Client_onUpdateData_pr(MessageID msgid, string msgname, Int16 length, sbyte argstype, List msgargtypes): + base(msgid, msgname, length, argstype, msgargtypes) + { + + } + + public override void handleMessage(MemoryStream msgstream) + { + KBEngineApp.app.Client_onUpdateData_pr(msgstream); + } + } + + public class Message_Client_onUpdateData_y : Message + { + + public Message_Client_onUpdateData_y(MessageID msgid, string msgname, Int16 length, sbyte argstype, List msgargtypes): + base(msgid, msgname, length, argstype, msgargtypes) + { + + } + + public override void handleMessage(MemoryStream msgstream) + { + KBEngineApp.app.Client_onUpdateData_y(msgstream); + } + } + + public class Message_Client_onUpdateData_p : Message + { + + public Message_Client_onUpdateData_p(MessageID msgid, string msgname, Int16 length, sbyte argstype, List msgargtypes): + base(msgid, msgname, length, argstype, msgargtypes) + { + + } + + public override void handleMessage(MemoryStream msgstream) + { + KBEngineApp.app.Client_onUpdateData_p(msgstream); + } + } + + public class Message_Client_onUpdateData_r : Message + { + + public Message_Client_onUpdateData_r(MessageID msgid, string msgname, Int16 length, sbyte argstype, List msgargtypes): + base(msgid, msgname, length, argstype, msgargtypes) + { + + } + + public override void handleMessage(MemoryStream msgstream) + { + KBEngineApp.app.Client_onUpdateData_r(msgstream); + } + } + + public class Message_Client_onUpdateData_xz : Message + { + + public Message_Client_onUpdateData_xz(MessageID msgid, string msgname, Int16 length, sbyte argstype, List msgargtypes): + base(msgid, msgname, length, argstype, msgargtypes) + { + + } + + public override void handleMessage(MemoryStream msgstream) + { + KBEngineApp.app.Client_onUpdateData_xz(msgstream); + } + } + + public class Message_Client_onUpdateData_xz_ypr : Message + { + + public Message_Client_onUpdateData_xz_ypr(MessageID msgid, string msgname, Int16 length, sbyte argstype, List msgargtypes): + base(msgid, msgname, length, argstype, msgargtypes) + { + + } + + public override void handleMessage(MemoryStream msgstream) + { + KBEngineApp.app.Client_onUpdateData_xz_ypr(msgstream); + } + } + + public class Message_Client_onUpdateData_xz_yp : Message + { + + public Message_Client_onUpdateData_xz_yp(MessageID msgid, string msgname, Int16 length, sbyte argstype, List msgargtypes): + base(msgid, msgname, length, argstype, msgargtypes) + { + + } + + public override void handleMessage(MemoryStream msgstream) + { + KBEngineApp.app.Client_onUpdateData_xz_yp(msgstream); + } + } + + public class Message_Client_onUpdateData_xz_yr : Message + { + + public Message_Client_onUpdateData_xz_yr(MessageID msgid, string msgname, Int16 length, sbyte argstype, List msgargtypes): + base(msgid, msgname, length, argstype, msgargtypes) + { + + } + + public override void handleMessage(MemoryStream msgstream) + { + KBEngineApp.app.Client_onUpdateData_xz_yr(msgstream); + } + } + + public class Message_Client_onUpdateData_xz_pr : Message + { + + public Message_Client_onUpdateData_xz_pr(MessageID msgid, string msgname, Int16 length, sbyte argstype, List msgargtypes): + base(msgid, msgname, length, argstype, msgargtypes) + { + + } + + public override void handleMessage(MemoryStream msgstream) + { + KBEngineApp.app.Client_onUpdateData_xz_pr(msgstream); + } + } + + public class Message_Client_onUpdateData_xz_y : Message + { + + public Message_Client_onUpdateData_xz_y(MessageID msgid, string msgname, Int16 length, sbyte argstype, List msgargtypes): + base(msgid, msgname, length, argstype, msgargtypes) + { + + } + + public override void handleMessage(MemoryStream msgstream) + { + KBEngineApp.app.Client_onUpdateData_xz_y(msgstream); + } + } + + public class Message_Client_onUpdateData_xz_p : Message + { + + public Message_Client_onUpdateData_xz_p(MessageID msgid, string msgname, Int16 length, sbyte argstype, List msgargtypes): + base(msgid, msgname, length, argstype, msgargtypes) + { + + } + + public override void handleMessage(MemoryStream msgstream) + { + KBEngineApp.app.Client_onUpdateData_xz_p(msgstream); + } + } + + public class Message_Client_onUpdateData_xz_r : Message + { + + public Message_Client_onUpdateData_xz_r(MessageID msgid, string msgname, Int16 length, sbyte argstype, List msgargtypes): + base(msgid, msgname, length, argstype, msgargtypes) + { + + } + + public override void handleMessage(MemoryStream msgstream) + { + KBEngineApp.app.Client_onUpdateData_xz_r(msgstream); + } + } + + public class Message_Client_onUpdateData_xyz : Message + { + + public Message_Client_onUpdateData_xyz(MessageID msgid, string msgname, Int16 length, sbyte argstype, List msgargtypes): + base(msgid, msgname, length, argstype, msgargtypes) + { + + } + + public override void handleMessage(MemoryStream msgstream) + { + KBEngineApp.app.Client_onUpdateData_xyz(msgstream); + } + } + + public class Message_Client_onUpdateData_xyz_ypr : Message + { + + public Message_Client_onUpdateData_xyz_ypr(MessageID msgid, string msgname, Int16 length, sbyte argstype, List msgargtypes): + base(msgid, msgname, length, argstype, msgargtypes) + { + + } + + public override void handleMessage(MemoryStream msgstream) + { + KBEngineApp.app.Client_onUpdateData_xyz_ypr(msgstream); + } + } + + public class Message_Client_onUpdateData_xyz_yp : Message + { + + public Message_Client_onUpdateData_xyz_yp(MessageID msgid, string msgname, Int16 length, sbyte argstype, List msgargtypes): + base(msgid, msgname, length, argstype, msgargtypes) + { + + } + + public override void handleMessage(MemoryStream msgstream) + { + KBEngineApp.app.Client_onUpdateData_xyz_yp(msgstream); + } + } + + public class Message_Client_onUpdateData_xyz_yr : Message + { + + public Message_Client_onUpdateData_xyz_yr(MessageID msgid, string msgname, Int16 length, sbyte argstype, List msgargtypes): + base(msgid, msgname, length, argstype, msgargtypes) + { + + } + + public override void handleMessage(MemoryStream msgstream) + { + KBEngineApp.app.Client_onUpdateData_xyz_yr(msgstream); + } + } + + public class Message_Client_onUpdateData_xyz_pr : Message + { + + public Message_Client_onUpdateData_xyz_pr(MessageID msgid, string msgname, Int16 length, sbyte argstype, List msgargtypes): + base(msgid, msgname, length, argstype, msgargtypes) + { + + } + + public override void handleMessage(MemoryStream msgstream) + { + KBEngineApp.app.Client_onUpdateData_xyz_pr(msgstream); + } + } + + public class Message_Client_onUpdateData_xyz_y : Message + { + + public Message_Client_onUpdateData_xyz_y(MessageID msgid, string msgname, Int16 length, sbyte argstype, List msgargtypes): + base(msgid, msgname, length, argstype, msgargtypes) + { + + } + + public override void handleMessage(MemoryStream msgstream) + { + KBEngineApp.app.Client_onUpdateData_xyz_y(msgstream); + } + } + + public class Message_Client_onUpdateData_xyz_p : Message + { + + public Message_Client_onUpdateData_xyz_p(MessageID msgid, string msgname, Int16 length, sbyte argstype, List msgargtypes): + base(msgid, msgname, length, argstype, msgargtypes) + { + + } + + public override void handleMessage(MemoryStream msgstream) + { + KBEngineApp.app.Client_onUpdateData_xyz_p(msgstream); + } + } + + public class Message_Client_onUpdateData_xyz_r : Message + { + + public Message_Client_onUpdateData_xyz_r(MessageID msgid, string msgname, Int16 length, sbyte argstype, List msgargtypes): + base(msgid, msgname, length, argstype, msgargtypes) + { + + } + + public override void handleMessage(MemoryStream msgstream) + { + KBEngineApp.app.Client_onUpdateData_xyz_r(msgstream); + } + } + + public class Message_Client_onUpdateData_ypr_optimized : Message + { + + public Message_Client_onUpdateData_ypr_optimized(MessageID msgid, string msgname, Int16 length, sbyte argstype, List msgargtypes): + base(msgid, msgname, length, argstype, msgargtypes) + { + + } + + public override void handleMessage(MemoryStream msgstream) + { + KBEngineApp.app.Client_onUpdateData_ypr_optimized(msgstream); + } + } + + public class Message_Client_onUpdateData_yp_optimized : Message + { + + public Message_Client_onUpdateData_yp_optimized(MessageID msgid, string msgname, Int16 length, sbyte argstype, List msgargtypes): + base(msgid, msgname, length, argstype, msgargtypes) + { + + } + + public override void handleMessage(MemoryStream msgstream) + { + KBEngineApp.app.Client_onUpdateData_yp_optimized(msgstream); + } + } + + public class Message_Client_onUpdateData_yr_optimized : Message + { + + public Message_Client_onUpdateData_yr_optimized(MessageID msgid, string msgname, Int16 length, sbyte argstype, List msgargtypes): + base(msgid, msgname, length, argstype, msgargtypes) + { + + } + + public override void handleMessage(MemoryStream msgstream) + { + KBEngineApp.app.Client_onUpdateData_yr_optimized(msgstream); + } + } + + public class Message_Client_onUpdateData_pr_optimized : Message + { + + public Message_Client_onUpdateData_pr_optimized(MessageID msgid, string msgname, Int16 length, sbyte argstype, List msgargtypes): + base(msgid, msgname, length, argstype, msgargtypes) + { + + } + + public override void handleMessage(MemoryStream msgstream) + { + KBEngineApp.app.Client_onUpdateData_pr_optimized(msgstream); + } + } + + public class Message_Client_onUpdateData_y_optimized : Message + { + + public Message_Client_onUpdateData_y_optimized(MessageID msgid, string msgname, Int16 length, sbyte argstype, List msgargtypes): + base(msgid, msgname, length, argstype, msgargtypes) + { + + } + + public override void handleMessage(MemoryStream msgstream) + { + KBEngineApp.app.Client_onUpdateData_y_optimized(msgstream); + } + } + + public class Message_Client_onUpdateData_p_optimized : Message + { + + public Message_Client_onUpdateData_p_optimized(MessageID msgid, string msgname, Int16 length, sbyte argstype, List msgargtypes): + base(msgid, msgname, length, argstype, msgargtypes) + { + + } + + public override void handleMessage(MemoryStream msgstream) + { + KBEngineApp.app.Client_onUpdateData_p_optimized(msgstream); + } + } + + public class Message_Client_onUpdateData_r_optimized : Message + { + + public Message_Client_onUpdateData_r_optimized(MessageID msgid, string msgname, Int16 length, sbyte argstype, List msgargtypes): + base(msgid, msgname, length, argstype, msgargtypes) + { + + } + + public override void handleMessage(MemoryStream msgstream) + { + KBEngineApp.app.Client_onUpdateData_r_optimized(msgstream); + } + } + + public class Message_Client_onUpdateData_xz_optimized : Message + { + + public Message_Client_onUpdateData_xz_optimized(MessageID msgid, string msgname, Int16 length, sbyte argstype, List msgargtypes): + base(msgid, msgname, length, argstype, msgargtypes) + { + + } + + public override void handleMessage(MemoryStream msgstream) + { + KBEngineApp.app.Client_onUpdateData_xz_optimized(msgstream); + } + } + + public class Message_Client_onUpdateData_xz_ypr_optimized : Message + { + + public Message_Client_onUpdateData_xz_ypr_optimized(MessageID msgid, string msgname, Int16 length, sbyte argstype, List msgargtypes): + base(msgid, msgname, length, argstype, msgargtypes) + { + + } + + public override void handleMessage(MemoryStream msgstream) + { + KBEngineApp.app.Client_onUpdateData_xz_ypr_optimized(msgstream); + } + } + + public class Message_Client_onUpdateData_xz_yp_optimized : Message + { + + public Message_Client_onUpdateData_xz_yp_optimized(MessageID msgid, string msgname, Int16 length, sbyte argstype, List msgargtypes): + base(msgid, msgname, length, argstype, msgargtypes) + { + + } + + public override void handleMessage(MemoryStream msgstream) + { + KBEngineApp.app.Client_onUpdateData_xz_yp_optimized(msgstream); + } + } + + public class Message_Client_onUpdateData_xz_yr_optimized : Message + { + + public Message_Client_onUpdateData_xz_yr_optimized(MessageID msgid, string msgname, Int16 length, sbyte argstype, List msgargtypes): + base(msgid, msgname, length, argstype, msgargtypes) + { + + } + + public override void handleMessage(MemoryStream msgstream) + { + KBEngineApp.app.Client_onUpdateData_xz_yr_optimized(msgstream); + } + } + + public class Message_Client_onUpdateData_xz_pr_optimized : Message + { + + public Message_Client_onUpdateData_xz_pr_optimized(MessageID msgid, string msgname, Int16 length, sbyte argstype, List msgargtypes): + base(msgid, msgname, length, argstype, msgargtypes) + { + + } + + public override void handleMessage(MemoryStream msgstream) + { + KBEngineApp.app.Client_onUpdateData_xz_pr_optimized(msgstream); + } + } + + public class Message_Client_onUpdateData_xz_y_optimized : Message + { + + public Message_Client_onUpdateData_xz_y_optimized(MessageID msgid, string msgname, Int16 length, sbyte argstype, List msgargtypes): + base(msgid, msgname, length, argstype, msgargtypes) + { + + } + + public override void handleMessage(MemoryStream msgstream) + { + KBEngineApp.app.Client_onUpdateData_xz_y_optimized(msgstream); + } + } + + public class Message_Client_onUpdateData_xz_p_optimized : Message + { + + public Message_Client_onUpdateData_xz_p_optimized(MessageID msgid, string msgname, Int16 length, sbyte argstype, List msgargtypes): + base(msgid, msgname, length, argstype, msgargtypes) + { + + } + + public override void handleMessage(MemoryStream msgstream) + { + KBEngineApp.app.Client_onUpdateData_xz_p_optimized(msgstream); + } + } + + public class Message_Client_onUpdateData_xz_r_optimized : Message + { + + public Message_Client_onUpdateData_xz_r_optimized(MessageID msgid, string msgname, Int16 length, sbyte argstype, List msgargtypes): + base(msgid, msgname, length, argstype, msgargtypes) + { + + } + + public override void handleMessage(MemoryStream msgstream) + { + KBEngineApp.app.Client_onUpdateData_xz_r_optimized(msgstream); + } + } + + public class Message_Client_onUpdateData_xyz_optimized : Message + { + + public Message_Client_onUpdateData_xyz_optimized(MessageID msgid, string msgname, Int16 length, sbyte argstype, List msgargtypes): + base(msgid, msgname, length, argstype, msgargtypes) + { + + } + + public override void handleMessage(MemoryStream msgstream) + { + KBEngineApp.app.Client_onUpdateData_xyz_optimized(msgstream); + } + } + + public class Message_Client_onUpdateData_xyz_ypr_optimized : Message + { + + public Message_Client_onUpdateData_xyz_ypr_optimized(MessageID msgid, string msgname, Int16 length, sbyte argstype, List msgargtypes): + base(msgid, msgname, length, argstype, msgargtypes) + { + + } + + public override void handleMessage(MemoryStream msgstream) + { + KBEngineApp.app.Client_onUpdateData_xyz_ypr_optimized(msgstream); + } + } + + public class Message_Client_onUpdateData_xyz_yp_optimized : Message + { + + public Message_Client_onUpdateData_xyz_yp_optimized(MessageID msgid, string msgname, Int16 length, sbyte argstype, List msgargtypes): + base(msgid, msgname, length, argstype, msgargtypes) + { + + } + + public override void handleMessage(MemoryStream msgstream) + { + KBEngineApp.app.Client_onUpdateData_xyz_yp_optimized(msgstream); + } + } + + public class Message_Client_onUpdateData_xyz_yr_optimized : Message + { + + public Message_Client_onUpdateData_xyz_yr_optimized(MessageID msgid, string msgname, Int16 length, sbyte argstype, List msgargtypes): + base(msgid, msgname, length, argstype, msgargtypes) + { + + } + + public override void handleMessage(MemoryStream msgstream) + { + KBEngineApp.app.Client_onUpdateData_xyz_yr_optimized(msgstream); + } + } + + public class Message_Client_onUpdateData_xyz_pr_optimized : Message + { + + public Message_Client_onUpdateData_xyz_pr_optimized(MessageID msgid, string msgname, Int16 length, sbyte argstype, List msgargtypes): + base(msgid, msgname, length, argstype, msgargtypes) + { + + } + + public override void handleMessage(MemoryStream msgstream) + { + KBEngineApp.app.Client_onUpdateData_xyz_pr_optimized(msgstream); + } + } + + public class Message_Client_onUpdateData_xyz_y_optimized : Message + { + + public Message_Client_onUpdateData_xyz_y_optimized(MessageID msgid, string msgname, Int16 length, sbyte argstype, List msgargtypes): + base(msgid, msgname, length, argstype, msgargtypes) + { + + } + + public override void handleMessage(MemoryStream msgstream) + { + KBEngineApp.app.Client_onUpdateData_xyz_y_optimized(msgstream); + } + } + + public class Message_Client_onUpdateData_xyz_p_optimized : Message + { + + public Message_Client_onUpdateData_xyz_p_optimized(MessageID msgid, string msgname, Int16 length, sbyte argstype, List msgargtypes): + base(msgid, msgname, length, argstype, msgargtypes) + { + + } + + public override void handleMessage(MemoryStream msgstream) + { + KBEngineApp.app.Client_onUpdateData_xyz_p_optimized(msgstream); + } + } + + public class Message_Client_onUpdateData_xyz_r_optimized : Message + { + + public Message_Client_onUpdateData_xyz_r_optimized(MessageID msgid, string msgname, Int16 length, sbyte argstype, List msgargtypes): + base(msgid, msgname, length, argstype, msgargtypes) + { + + } + + public override void handleMessage(MemoryStream msgstream) + { + KBEngineApp.app.Client_onUpdateData_xyz_r_optimized(msgstream); + } + } + + public class Message_Client_onImportServerErrorsDescr : Message + { + + public Message_Client_onImportServerErrorsDescr(MessageID msgid, string msgname, Int16 length, sbyte argstype, List msgargtypes): + base(msgid, msgname, length, argstype, msgargtypes) + { + + } + + public override void handleMessage(MemoryStream msgstream) + { + KBEngineApp.app.Client_onImportServerErrorsDescr(msgstream); + } + } + + public class Message_Client_onImportClientSDK : Message + { + + public Message_Client_onImportClientSDK(MessageID msgid, string msgname, Int16 length, sbyte argstype, List msgargtypes): + base(msgid, msgname, length, argstype, msgargtypes) + { + + } + + public override void handleMessage(MemoryStream msgstream) + { + KBEngineApp.app.Client_onImportClientSDK(msgstream); + } + } + + public class Message_Client_initSpaceData : Message + { + + public Message_Client_initSpaceData(MessageID msgid, string msgname, Int16 length, sbyte argstype, List msgargtypes): + base(msgid, msgname, length, argstype, msgargtypes) + { + + } + + public override void handleMessage(MemoryStream msgstream) + { + KBEngineApp.app.Client_initSpaceData(msgstream); + } + } + + public class Message_Client_setSpaceData : Message + { + + public Message_Client_setSpaceData(MessageID msgid, string msgname, Int16 length, sbyte argstype, List msgargtypes): + base(msgid, msgname, length, argstype, msgargtypes) + { + + } + + public override void handleMessage(MemoryStream msgstream) + { + UInt32 arg1 = msgstream.readUint32(); + string arg2 = msgstream.readString(); + string arg3 = msgstream.readString(); + KBEngineApp.app.Client_setSpaceData(arg1, arg2, arg3); + } + } + + public class Message_Client_delSpaceData : Message + { + + public Message_Client_delSpaceData(MessageID msgid, string msgname, Int16 length, sbyte argstype, List msgargtypes): + base(msgid, msgname, length, argstype, msgargtypes) + { + + } + + public override void handleMessage(MemoryStream msgstream) + { + UInt32 arg1 = msgstream.readUint32(); + string arg2 = msgstream.readString(); + KBEngineApp.app.Client_delSpaceData(arg1, arg2); + } + } + + public class Message_Client_onReqAccountResetPasswordCB : Message + { + + public Message_Client_onReqAccountResetPasswordCB(MessageID msgid, string msgname, Int16 length, sbyte argstype, List msgargtypes): + base(msgid, msgname, length, argstype, msgargtypes) + { + + } + + public override void handleMessage(MemoryStream msgstream) + { + UInt16 arg1 = msgstream.readUint16(); + KBEngineApp.app.Client_onReqAccountResetPasswordCB(arg1); + } + } + + public class Message_Client_onReqAccountBindEmailCB : Message + { + + public Message_Client_onReqAccountBindEmailCB(MessageID msgid, string msgname, Int16 length, sbyte argstype, List msgargtypes): + base(msgid, msgname, length, argstype, msgargtypes) + { + + } + + public override void handleMessage(MemoryStream msgstream) + { + UInt16 arg1 = msgstream.readUint16(); + KBEngineApp.app.Client_onReqAccountBindEmailCB(arg1); + } + } + + public class Message_Client_onReqAccountNewPasswordCB : Message + { + + public Message_Client_onReqAccountNewPasswordCB(MessageID msgid, string msgname, Int16 length, sbyte argstype, List msgargtypes): + base(msgid, msgname, length, argstype, msgargtypes) + { + + } + + public override void handleMessage(MemoryStream msgstream) + { + UInt16 arg1 = msgstream.readUint16(); + KBEngineApp.app.Client_onReqAccountNewPasswordCB(arg1); + } + } + + public class Message_Client_onReloginBaseappSuccessfully : Message + { + + public Message_Client_onReloginBaseappSuccessfully(MessageID msgid, string msgname, Int16 length, sbyte argstype, List msgargtypes): + base(msgid, msgname, length, argstype, msgargtypes) + { + + } + + public override void handleMessage(MemoryStream msgstream) + { + KBEngineApp.app.Client_onReloginBaseappSuccessfully(msgstream); + } + } + + public class Message_Client_onAppActiveTickCB : Message + { + + public Message_Client_onAppActiveTickCB(MessageID msgid, string msgname, Int16 length, sbyte argstype, List msgargtypes): + base(msgid, msgname, length, argstype, msgargtypes) + { + + } + + public override void handleMessage(MemoryStream msgstream) + { + KBEngineApp.app.Client_onAppActiveTickCB(); + } + } + + public class Message_Client_onCreateAccountResult : Message + { + + public Message_Client_onCreateAccountResult(MessageID msgid, string msgname, Int16 length, sbyte argstype, List msgargtypes): + base(msgid, msgname, length, argstype, msgargtypes) + { + + } + + public override void handleMessage(MemoryStream msgstream) + { + KBEngineApp.app.Client_onCreateAccountResult(msgstream); + } + } + + public class Message_Client_onLoginSuccessfully : Message + { + + public Message_Client_onLoginSuccessfully(MessageID msgid, string msgname, Int16 length, sbyte argstype, List msgargtypes): + base(msgid, msgname, length, argstype, msgargtypes) + { + + } + + public override void handleMessage(MemoryStream msgstream) + { + KBEngineApp.app.Client_onLoginSuccessfully(msgstream); + } + } + + public class Message_Client_onLoginFailed : Message + { + + public Message_Client_onLoginFailed(MessageID msgid, string msgname, Int16 length, sbyte argstype, List msgargtypes): + base(msgid, msgname, length, argstype, msgargtypes) + { + + } + + public override void handleMessage(MemoryStream msgstream) + { + KBEngineApp.app.Client_onLoginFailed(msgstream); + } + } + + public class Message_Client_onCreatedProxies : Message + { + + public Message_Client_onCreatedProxies(MessageID msgid, string msgname, Int16 length, sbyte argstype, List msgargtypes): + base(msgid, msgname, length, argstype, msgargtypes) + { + + } + + public override void handleMessage(MemoryStream msgstream) + { + UInt64 arg1 = msgstream.readUint64(); + Int32 arg2 = msgstream.readInt32(); + string arg3 = msgstream.readString(); + KBEngineApp.app.Client_onCreatedProxies(arg1, arg2, arg3); + } + } + + public class Message_Client_onLoginBaseappFailed : Message + { + + public Message_Client_onLoginBaseappFailed(MessageID msgid, string msgname, Int16 length, sbyte argstype, List msgargtypes): + base(msgid, msgname, length, argstype, msgargtypes) + { + + } + + public override void handleMessage(MemoryStream msgstream) + { + UInt16 arg1 = msgstream.readUint16(); + KBEngineApp.app.Client_onLoginBaseappFailed(arg1); + } + } + + public class Message_Client_onRemoteMethodCall : Message + { + + public Message_Client_onRemoteMethodCall(MessageID msgid, string msgname, Int16 length, sbyte argstype, List msgargtypes): + base(msgid, msgname, length, argstype, msgargtypes) + { + + } + + public override void handleMessage(MemoryStream msgstream) + { + KBEngineApp.app.Client_onRemoteMethodCall(msgstream); + } + } + + public class Message_Client_onEntityEnterWorld : Message + { + + public Message_Client_onEntityEnterWorld(MessageID msgid, string msgname, Int16 length, sbyte argstype, List msgargtypes): + base(msgid, msgname, length, argstype, msgargtypes) + { + + } + + public override void handleMessage(MemoryStream msgstream) + { + KBEngineApp.app.Client_onEntityEnterWorld(msgstream); + } + } + + public class Message_Client_onEntityLeaveWorld : Message + { + + public Message_Client_onEntityLeaveWorld(MessageID msgid, string msgname, Int16 length, sbyte argstype, List msgargtypes): + base(msgid, msgname, length, argstype, msgargtypes) + { + + } + + public override void handleMessage(MemoryStream msgstream) + { + Int32 arg1 = msgstream.readInt32(); + KBEngineApp.app.Client_onEntityLeaveWorld(arg1); + } + } + + public class Message_Client_onEntityEnterSpace : Message + { + + public Message_Client_onEntityEnterSpace(MessageID msgid, string msgname, Int16 length, sbyte argstype, List msgargtypes): + base(msgid, msgname, length, argstype, msgargtypes) + { + + } + + public override void handleMessage(MemoryStream msgstream) + { + KBEngineApp.app.Client_onEntityEnterSpace(msgstream); + } + } + + public class Message_Client_onEntityLeaveSpace : Message + { + + public Message_Client_onEntityLeaveSpace(MessageID msgid, string msgname, Int16 length, sbyte argstype, List msgargtypes): + base(msgid, msgname, length, argstype, msgargtypes) + { + + } + + public override void handleMessage(MemoryStream msgstream) + { + Int32 arg1 = msgstream.readInt32(); + KBEngineApp.app.Client_onEntityLeaveSpace(arg1); + } + } + + public class Message_Client_onUpdatePropertys : Message + { + + public Message_Client_onUpdatePropertys(MessageID msgid, string msgname, Int16 length, sbyte argstype, List msgargtypes): + base(msgid, msgname, length, argstype, msgargtypes) + { + + } + + public override void handleMessage(MemoryStream msgstream) + { + KBEngineApp.app.Client_onUpdatePropertys(msgstream); + } + } + + public class Message_Client_onEntityDestroyed : Message + { + + public Message_Client_onEntityDestroyed(MessageID msgid, string msgname, Int16 length, sbyte argstype, List msgargtypes): + base(msgid, msgname, length, argstype, msgargtypes) + { + + } + + public override void handleMessage(MemoryStream msgstream) + { + Int32 arg1 = msgstream.readInt32(); + KBEngineApp.app.Client_onEntityDestroyed(arg1); + } + } + + public class Message_Client_onStreamDataStarted : Message + { + + public Message_Client_onStreamDataStarted(MessageID msgid, string msgname, Int16 length, sbyte argstype, List msgargtypes): + base(msgid, msgname, length, argstype, msgargtypes) + { + + } + + public override void handleMessage(MemoryStream msgstream) + { + Int16 arg1 = msgstream.readInt16(); + UInt32 arg2 = msgstream.readUint32(); + string arg3 = msgstream.readString(); + KBEngineApp.app.Client_onStreamDataStarted(arg1, arg2, arg3); + } + } + + public class Message_Client_onStreamDataRecv : Message + { + + public Message_Client_onStreamDataRecv(MessageID msgid, string msgname, Int16 length, sbyte argstype, List msgargtypes): + base(msgid, msgname, length, argstype, msgargtypes) + { + + } + + public override void handleMessage(MemoryStream msgstream) + { + KBEngineApp.app.Client_onStreamDataRecv(msgstream); + } + } + + public class Message_Client_onStreamDataCompleted : Message + { + + public Message_Client_onStreamDataCompleted(MessageID msgid, string msgname, Int16 length, sbyte argstype, List msgargtypes): + base(msgid, msgname, length, argstype, msgargtypes) + { + + } + + public override void handleMessage(MemoryStream msgstream) + { + Int16 arg1 = msgstream.readInt16(); + KBEngineApp.app.Client_onStreamDataCompleted(arg1); + } + } + + public class Message_Client_onKicked : Message + { + + public Message_Client_onKicked(MessageID msgid, string msgname, Int16 length, sbyte argstype, List msgargtypes): + base(msgid, msgname, length, argstype, msgargtypes) + { + + } + + public override void handleMessage(MemoryStream msgstream) + { + UInt16 arg1 = msgstream.readUint16(); + KBEngineApp.app.Client_onKicked(arg1); + } + } + + public class Message_Client_onImportClientMessages : Message + { + + public Message_Client_onImportClientMessages(MessageID msgid, string msgname, Int16 length, sbyte argstype, List msgargtypes): + base(msgid, msgname, length, argstype, msgargtypes) + { + + } + + public override void handleMessage(MemoryStream msgstream) + { + KBEngineApp.app.Client_onImportClientMessages(msgstream); + } + } + + public class Message_Client_onImportClientEntityDef : Message + { + + public Message_Client_onImportClientEntityDef(MessageID msgid, string msgname, Int16 length, sbyte argstype, List msgargtypes): + base(msgid, msgname, length, argstype, msgargtypes) + { + + } + + public override void handleMessage(MemoryStream msgstream) + { + KBEngineApp.app.Client_onImportClientEntityDef(msgstream); + } + } + + public class Message_Client_onHelloCB : Message + { + + public Message_Client_onHelloCB(MessageID msgid, string msgname, Int16 length, sbyte argstype, List msgargtypes): + base(msgid, msgname, length, argstype, msgargtypes) + { + + } + + public override void handleMessage(MemoryStream msgstream) + { + KBEngineApp.app.Client_onHelloCB(msgstream); + } + } + + public class Message_Client_onScriptVersionNotMatch : Message + { + + public Message_Client_onScriptVersionNotMatch(MessageID msgid, string msgname, Int16 length, sbyte argstype, List msgargtypes): + base(msgid, msgname, length, argstype, msgargtypes) + { + + } + + public override void handleMessage(MemoryStream msgstream) + { + KBEngineApp.app.Client_onScriptVersionNotMatch(msgstream); + } + } + + public class Message_Client_onVersionNotMatch : Message + { + + public Message_Client_onVersionNotMatch(MessageID msgid, string msgname, Int16 length, sbyte argstype, List msgargtypes): + base(msgid, msgname, length, argstype, msgargtypes) + { + + } + + public override void handleMessage(MemoryStream msgstream) + { + KBEngineApp.app.Client_onVersionNotMatch(msgstream); + } + } + + public class Message_Client_onControlEntity : Message + { + + public Message_Client_onControlEntity(MessageID msgid, string msgname, Int16 length, sbyte argstype, List msgargtypes): + base(msgid, msgname, length, argstype, msgargtypes) + { + + } + + public override void handleMessage(MemoryStream msgstream) + { + Int32 arg1 = msgstream.readInt32(); + SByte arg2 = msgstream.readInt8(); + KBEngineApp.app.Client_onControlEntity(arg1, arg2); + } + } + + public class Message_Loginapp_reqCreateAccount : Message + { + + public Message_Loginapp_reqCreateAccount(MessageID msgid, string msgname, Int16 length, sbyte argstype, List msgargtypes): + base(msgid, msgname, length, argstype, msgargtypes) + { + + } + + public override void handleMessage(MemoryStream msgstream) + { + } + } + + public class Message_Loginapp_login : Message + { + + public Message_Loginapp_login(MessageID msgid, string msgname, Int16 length, sbyte argstype, List msgargtypes): + base(msgid, msgname, length, argstype, msgargtypes) + { + + } + + public override void handleMessage(MemoryStream msgstream) + { + } + } + + public class Message_Loginapp_hello : Message + { + + public Message_Loginapp_hello(MessageID msgid, string msgname, Int16 length, sbyte argstype, List msgargtypes): + base(msgid, msgname, length, argstype, msgargtypes) + { + + } + + public override void handleMessage(MemoryStream msgstream) + { + } + } + + public class Message_Loginapp_importClientMessages : Message + { + + public Message_Loginapp_importClientMessages(MessageID msgid, string msgname, Int16 length, sbyte argstype, List msgargtypes): + base(msgid, msgname, length, argstype, msgargtypes) + { + + } + + public override void handleMessage(MemoryStream msgstream) + { + } + } + + public class Message_Loginapp_reqCreateMailAccount : Message + { + + public Message_Loginapp_reqCreateMailAccount(MessageID msgid, string msgname, Int16 length, sbyte argstype, List msgargtypes): + base(msgid, msgname, length, argstype, msgargtypes) + { + + } + + public override void handleMessage(MemoryStream msgstream) + { + } + } + + public class Message_Loginapp_importClientSDK : Message + { + + public Message_Loginapp_importClientSDK(MessageID msgid, string msgname, Int16 length, sbyte argstype, List msgargtypes): + base(msgid, msgname, length, argstype, msgargtypes) + { + + } + + public override void handleMessage(MemoryStream msgstream) + { + } + } + + public class Message_Loginapp_importServerErrorsDescr : Message + { + + public Message_Loginapp_importServerErrorsDescr(MessageID msgid, string msgname, Int16 length, sbyte argstype, List msgargtypes): + base(msgid, msgname, length, argstype, msgargtypes) + { + + } + + public override void handleMessage(MemoryStream msgstream) + { + } + } + + public class Message_Loginapp_onClientActiveTick : Message + { + + public Message_Loginapp_onClientActiveTick(MessageID msgid, string msgname, Int16 length, sbyte argstype, List msgargtypes): + base(msgid, msgname, length, argstype, msgargtypes) + { + + } + + public override void handleMessage(MemoryStream msgstream) + { + } + } + + public class Message_Loginapp_reqAccountResetPassword : Message + { + + public Message_Loginapp_reqAccountResetPassword(MessageID msgid, string msgname, Int16 length, sbyte argstype, List msgargtypes): + base(msgid, msgname, length, argstype, msgargtypes) + { + + } + + public override void handleMessage(MemoryStream msgstream) + { + } + } + + public class Message_Baseapp_logoutBaseapp : Message + { + + public Message_Baseapp_logoutBaseapp(MessageID msgid, string msgname, Int16 length, sbyte argstype, List msgargtypes): + base(msgid, msgname, length, argstype, msgargtypes) + { + + } + + public override void handleMessage(MemoryStream msgstream) + { + } + } + + public class Message_Baseapp_onUpdateDataFromClient : Message + { + + public Message_Baseapp_onUpdateDataFromClient(MessageID msgid, string msgname, Int16 length, sbyte argstype, List msgargtypes): + base(msgid, msgname, length, argstype, msgargtypes) + { + + } + + public override void handleMessage(MemoryStream msgstream) + { + } + } + + public class Message_Baseapp_onUpdateDataFromClientForControlledEntity : Message + { + + public Message_Baseapp_onUpdateDataFromClientForControlledEntity(MessageID msgid, string msgname, Int16 length, sbyte argstype, List msgargtypes): + base(msgid, msgname, length, argstype, msgargtypes) + { + + } + + public override void handleMessage(MemoryStream msgstream) + { + } + } + + public class Message_Baseapp_reqAccountBindEmail : Message + { + + public Message_Baseapp_reqAccountBindEmail(MessageID msgid, string msgname, Int16 length, sbyte argstype, List msgargtypes): + base(msgid, msgname, length, argstype, msgargtypes) + { + + } + + public override void handleMessage(MemoryStream msgstream) + { + } + } + + public class Message_Baseapp_reqAccountNewPassword : Message + { + + public Message_Baseapp_reqAccountNewPassword(MessageID msgid, string msgname, Int16 length, sbyte argstype, List msgargtypes): + base(msgid, msgname, length, argstype, msgargtypes) + { + + } + + public override void handleMessage(MemoryStream msgstream) + { + } + } + + public class Message_Entity_forwardEntityMessageToCellappFromClient : Message + { + + public Message_Entity_forwardEntityMessageToCellappFromClient(MessageID msgid, string msgname, Int16 length, sbyte argstype, List msgargtypes): + base(msgid, msgname, length, argstype, msgargtypes) + { + + } + + public override void handleMessage(MemoryStream msgstream) + { + } + } + + public class Message_Baseapp_hello : Message + { + + public Message_Baseapp_hello(MessageID msgid, string msgname, Int16 length, sbyte argstype, List msgargtypes): + base(msgid, msgname, length, argstype, msgargtypes) + { + + } + + public override void handleMessage(MemoryStream msgstream) + { + } + } + + public class Message_Baseapp_loginBaseapp : Message + { + + public Message_Baseapp_loginBaseapp(MessageID msgid, string msgname, Int16 length, sbyte argstype, List msgargtypes): + base(msgid, msgname, length, argstype, msgargtypes) + { + + } + + public override void handleMessage(MemoryStream msgstream) + { + } + } + + public class Message_Baseapp_reloginBaseapp : Message + { + + public Message_Baseapp_reloginBaseapp(MessageID msgid, string msgname, Int16 length, sbyte argstype, List msgargtypes): + base(msgid, msgname, length, argstype, msgargtypes) + { + + } + + public override void handleMessage(MemoryStream msgstream) + { + } + } + + public class Message_Baseapp_onRemoteCallCellMethodFromClient : Message + { + + public Message_Baseapp_onRemoteCallCellMethodFromClient(MessageID msgid, string msgname, Int16 length, sbyte argstype, List msgargtypes): + base(msgid, msgname, length, argstype, msgargtypes) + { + + } + + public override void handleMessage(MemoryStream msgstream) + { + } + } + + public class Message_Baseapp_onClientActiveTick : Message + { + + public Message_Baseapp_onClientActiveTick(MessageID msgid, string msgname, Int16 length, sbyte argstype, List msgargtypes): + base(msgid, msgname, length, argstype, msgargtypes) + { + + } + + public override void handleMessage(MemoryStream msgstream) + { + } + } + + public class Message_Baseapp_importClientMessages : Message + { + + public Message_Baseapp_importClientMessages(MessageID msgid, string msgname, Int16 length, sbyte argstype, List msgargtypes): + base(msgid, msgname, length, argstype, msgargtypes) + { + + } + + public override void handleMessage(MemoryStream msgstream) + { + } + } + + public class Message_Baseapp_importClientEntityDef : Message + { + + public Message_Baseapp_importClientEntityDef(MessageID msgid, string msgname, Int16 length, sbyte argstype, List msgargtypes): + base(msgid, msgname, length, argstype, msgargtypes) + { + + } + + public override void handleMessage(MemoryStream msgstream) + { + } + } + + public class Message_Entity_onRemoteMethodCall : Message + { + + public Message_Entity_onRemoteMethodCall(MessageID msgid, string msgname, Int16 length, sbyte argstype, List msgargtypes): + base(msgid, msgname, length, argstype, msgargtypes) + { + + } + + public override void handleMessage(MemoryStream msgstream) + { + } + } + + public class Messages + { + public static Dictionary loginappMessages = new Dictionary(); + public static Dictionary baseappMessages = new Dictionary(); + public static Dictionary clientMessages = new Dictionary(); + public static Dictionary messages = new Dictionary(); + + public static void clear() + { + loginappMessages = new Dictionary(); + baseappMessages = new Dictionary(); + clientMessages = new Dictionary(); + messages = new Dictionary(); + + init(); + } + + + public static bool init() + { + + List Client_onReloginBaseappFailed_argstypes = new List(); + Client_onReloginBaseappFailed_argstypes.Add(3); + Messages.messages["Client_onReloginBaseappFailed"] = new Message_Client_onReloginBaseappFailed(8, "Client_onReloginBaseappFailed", 2, 0, Client_onReloginBaseappFailed_argstypes); + Messages.clientMessages[8] = Messages.messages["Client_onReloginBaseappFailed"]; + + Messages.messages["Client_onEntityLeaveWorldOptimized"] = new Message_Client_onEntityLeaveWorldOptimized(9, "Client_onEntityLeaveWorldOptimized", -1, -1, new List()); + Messages.clientMessages[9] = Messages.messages["Client_onEntityLeaveWorldOptimized"]; + + Messages.messages["Client_onRemoteMethodCallOptimized"] = new Message_Client_onRemoteMethodCallOptimized(10, "Client_onRemoteMethodCallOptimized", -1, -1, new List()); + Messages.clientMessages[10] = Messages.messages["Client_onRemoteMethodCallOptimized"]; + + Messages.messages["Client_onUpdatePropertysOptimized"] = new Message_Client_onUpdatePropertysOptimized(11, "Client_onUpdatePropertysOptimized", -1, -1, new List()); + Messages.clientMessages[11] = Messages.messages["Client_onUpdatePropertysOptimized"]; + + Messages.messages["Client_onSetEntityPosAndDir"] = new Message_Client_onSetEntityPosAndDir(12, "Client_onSetEntityPosAndDir", -1, -1, new List()); + Messages.clientMessages[12] = Messages.messages["Client_onSetEntityPosAndDir"]; + + + List Client_onUpdateBasePos_argstypes = new List(); + Client_onUpdateBasePos_argstypes.Add(13); + Client_onUpdateBasePos_argstypes.Add(13); + Client_onUpdateBasePos_argstypes.Add(13); + Messages.messages["Client_onUpdateBasePos"] = new Message_Client_onUpdateBasePos(13, "Client_onUpdateBasePos", 12, 0, Client_onUpdateBasePos_argstypes); + Messages.clientMessages[13] = Messages.messages["Client_onUpdateBasePos"]; + + Messages.messages["Client_onUpdateBaseDir"] = new Message_Client_onUpdateBaseDir(14, "Client_onUpdateBaseDir", -1, -1, new List()); + Messages.clientMessages[14] = Messages.messages["Client_onUpdateBaseDir"]; + + + List Client_onUpdateBasePosXZ_argstypes = new List(); + Client_onUpdateBasePosXZ_argstypes.Add(13); + Client_onUpdateBasePosXZ_argstypes.Add(13); + Messages.messages["Client_onUpdateBasePosXZ"] = new Message_Client_onUpdateBasePosXZ(15, "Client_onUpdateBasePosXZ", 8, 0, Client_onUpdateBasePosXZ_argstypes); + Messages.clientMessages[15] = Messages.messages["Client_onUpdateBasePosXZ"]; + + Messages.messages["Client_onUpdateData"] = new Message_Client_onUpdateData(16, "Client_onUpdateData", -1, -1, new List()); + Messages.clientMessages[16] = Messages.messages["Client_onUpdateData"]; + + Messages.messages["Client_onUpdateData_ypr"] = new Message_Client_onUpdateData_ypr(17, "Client_onUpdateData_ypr", -1, -1, new List()); + Messages.clientMessages[17] = Messages.messages["Client_onUpdateData_ypr"]; + + Messages.messages["Client_onUpdateData_yp"] = new Message_Client_onUpdateData_yp(18, "Client_onUpdateData_yp", -1, -1, new List()); + Messages.clientMessages[18] = Messages.messages["Client_onUpdateData_yp"]; + + Messages.messages["Client_onUpdateData_yr"] = new Message_Client_onUpdateData_yr(19, "Client_onUpdateData_yr", -1, -1, new List()); + Messages.clientMessages[19] = Messages.messages["Client_onUpdateData_yr"]; + + Messages.messages["Client_onUpdateData_pr"] = new Message_Client_onUpdateData_pr(20, "Client_onUpdateData_pr", -1, -1, new List()); + Messages.clientMessages[20] = Messages.messages["Client_onUpdateData_pr"]; + + Messages.messages["Client_onUpdateData_y"] = new Message_Client_onUpdateData_y(21, "Client_onUpdateData_y", -1, -1, new List()); + Messages.clientMessages[21] = Messages.messages["Client_onUpdateData_y"]; + + Messages.messages["Client_onUpdateData_p"] = new Message_Client_onUpdateData_p(22, "Client_onUpdateData_p", -1, -1, new List()); + Messages.clientMessages[22] = Messages.messages["Client_onUpdateData_p"]; + + Messages.messages["Client_onUpdateData_r"] = new Message_Client_onUpdateData_r(23, "Client_onUpdateData_r", -1, -1, new List()); + Messages.clientMessages[23] = Messages.messages["Client_onUpdateData_r"]; + + Messages.messages["Client_onUpdateData_xz"] = new Message_Client_onUpdateData_xz(24, "Client_onUpdateData_xz", -1, -1, new List()); + Messages.clientMessages[24] = Messages.messages["Client_onUpdateData_xz"]; + + Messages.messages["Client_onUpdateData_xz_ypr"] = new Message_Client_onUpdateData_xz_ypr(25, "Client_onUpdateData_xz_ypr", -1, -1, new List()); + Messages.clientMessages[25] = Messages.messages["Client_onUpdateData_xz_ypr"]; + + Messages.messages["Client_onUpdateData_xz_yp"] = new Message_Client_onUpdateData_xz_yp(26, "Client_onUpdateData_xz_yp", -1, -1, new List()); + Messages.clientMessages[26] = Messages.messages["Client_onUpdateData_xz_yp"]; + + Messages.messages["Client_onUpdateData_xz_yr"] = new Message_Client_onUpdateData_xz_yr(27, "Client_onUpdateData_xz_yr", -1, -1, new List()); + Messages.clientMessages[27] = Messages.messages["Client_onUpdateData_xz_yr"]; + + Messages.messages["Client_onUpdateData_xz_pr"] = new Message_Client_onUpdateData_xz_pr(28, "Client_onUpdateData_xz_pr", -1, -1, new List()); + Messages.clientMessages[28] = Messages.messages["Client_onUpdateData_xz_pr"]; + + Messages.messages["Client_onUpdateData_xz_y"] = new Message_Client_onUpdateData_xz_y(29, "Client_onUpdateData_xz_y", -1, -1, new List()); + Messages.clientMessages[29] = Messages.messages["Client_onUpdateData_xz_y"]; + + Messages.messages["Client_onUpdateData_xz_p"] = new Message_Client_onUpdateData_xz_p(30, "Client_onUpdateData_xz_p", -1, -1, new List()); + Messages.clientMessages[30] = Messages.messages["Client_onUpdateData_xz_p"]; + + Messages.messages["Client_onUpdateData_xz_r"] = new Message_Client_onUpdateData_xz_r(31, "Client_onUpdateData_xz_r", -1, -1, new List()); + Messages.clientMessages[31] = Messages.messages["Client_onUpdateData_xz_r"]; + + Messages.messages["Client_onUpdateData_xyz"] = new Message_Client_onUpdateData_xyz(32, "Client_onUpdateData_xyz", -1, -1, new List()); + Messages.clientMessages[32] = Messages.messages["Client_onUpdateData_xyz"]; + + Messages.messages["Client_onUpdateData_xyz_ypr"] = new Message_Client_onUpdateData_xyz_ypr(33, "Client_onUpdateData_xyz_ypr", -1, -1, new List()); + Messages.clientMessages[33] = Messages.messages["Client_onUpdateData_xyz_ypr"]; + + Messages.messages["Client_onUpdateData_xyz_yp"] = new Message_Client_onUpdateData_xyz_yp(34, "Client_onUpdateData_xyz_yp", -1, -1, new List()); + Messages.clientMessages[34] = Messages.messages["Client_onUpdateData_xyz_yp"]; + + Messages.messages["Client_onUpdateData_xyz_yr"] = new Message_Client_onUpdateData_xyz_yr(35, "Client_onUpdateData_xyz_yr", -1, -1, new List()); + Messages.clientMessages[35] = Messages.messages["Client_onUpdateData_xyz_yr"]; + + Messages.messages["Client_onUpdateData_xyz_pr"] = new Message_Client_onUpdateData_xyz_pr(36, "Client_onUpdateData_xyz_pr", -1, -1, new List()); + Messages.clientMessages[36] = Messages.messages["Client_onUpdateData_xyz_pr"]; + + Messages.messages["Client_onUpdateData_xyz_y"] = new Message_Client_onUpdateData_xyz_y(37, "Client_onUpdateData_xyz_y", -1, -1, new List()); + Messages.clientMessages[37] = Messages.messages["Client_onUpdateData_xyz_y"]; + + Messages.messages["Client_onUpdateData_xyz_p"] = new Message_Client_onUpdateData_xyz_p(38, "Client_onUpdateData_xyz_p", -1, -1, new List()); + Messages.clientMessages[38] = Messages.messages["Client_onUpdateData_xyz_p"]; + + Messages.messages["Client_onUpdateData_xyz_r"] = new Message_Client_onUpdateData_xyz_r(39, "Client_onUpdateData_xyz_r", -1, -1, new List()); + Messages.clientMessages[39] = Messages.messages["Client_onUpdateData_xyz_r"]; + + Messages.messages["Client_onUpdateData_ypr_optimized"] = new Message_Client_onUpdateData_ypr_optimized(40, "Client_onUpdateData_ypr_optimized", -1, -1, new List()); + Messages.clientMessages[40] = Messages.messages["Client_onUpdateData_ypr_optimized"]; + + Messages.messages["Client_onUpdateData_yp_optimized"] = new Message_Client_onUpdateData_yp_optimized(41, "Client_onUpdateData_yp_optimized", -1, -1, new List()); + Messages.clientMessages[41] = Messages.messages["Client_onUpdateData_yp_optimized"]; + + Messages.messages["Client_onUpdateData_yr_optimized"] = new Message_Client_onUpdateData_yr_optimized(42, "Client_onUpdateData_yr_optimized", -1, -1, new List()); + Messages.clientMessages[42] = Messages.messages["Client_onUpdateData_yr_optimized"]; + + Messages.messages["Client_onUpdateData_pr_optimized"] = new Message_Client_onUpdateData_pr_optimized(43, "Client_onUpdateData_pr_optimized", -1, -1, new List()); + Messages.clientMessages[43] = Messages.messages["Client_onUpdateData_pr_optimized"]; + + Messages.messages["Client_onUpdateData_y_optimized"] = new Message_Client_onUpdateData_y_optimized(44, "Client_onUpdateData_y_optimized", -1, -1, new List()); + Messages.clientMessages[44] = Messages.messages["Client_onUpdateData_y_optimized"]; + + Messages.messages["Client_onUpdateData_p_optimized"] = new Message_Client_onUpdateData_p_optimized(45, "Client_onUpdateData_p_optimized", -1, -1, new List()); + Messages.clientMessages[45] = Messages.messages["Client_onUpdateData_p_optimized"]; + + Messages.messages["Client_onUpdateData_r_optimized"] = new Message_Client_onUpdateData_r_optimized(46, "Client_onUpdateData_r_optimized", -1, -1, new List()); + Messages.clientMessages[46] = Messages.messages["Client_onUpdateData_r_optimized"]; + + Messages.messages["Client_onUpdateData_xz_optimized"] = new Message_Client_onUpdateData_xz_optimized(47, "Client_onUpdateData_xz_optimized", -1, -1, new List()); + Messages.clientMessages[47] = Messages.messages["Client_onUpdateData_xz_optimized"]; + + Messages.messages["Client_onUpdateData_xz_ypr_optimized"] = new Message_Client_onUpdateData_xz_ypr_optimized(48, "Client_onUpdateData_xz_ypr_optimized", -1, -1, new List()); + Messages.clientMessages[48] = Messages.messages["Client_onUpdateData_xz_ypr_optimized"]; + + Messages.messages["Client_onUpdateData_xz_yp_optimized"] = new Message_Client_onUpdateData_xz_yp_optimized(49, "Client_onUpdateData_xz_yp_optimized", -1, -1, new List()); + Messages.clientMessages[49] = Messages.messages["Client_onUpdateData_xz_yp_optimized"]; + + Messages.messages["Client_onUpdateData_xz_yr_optimized"] = new Message_Client_onUpdateData_xz_yr_optimized(50, "Client_onUpdateData_xz_yr_optimized", -1, -1, new List()); + Messages.clientMessages[50] = Messages.messages["Client_onUpdateData_xz_yr_optimized"]; + + Messages.messages["Client_onUpdateData_xz_pr_optimized"] = new Message_Client_onUpdateData_xz_pr_optimized(51, "Client_onUpdateData_xz_pr_optimized", -1, -1, new List()); + Messages.clientMessages[51] = Messages.messages["Client_onUpdateData_xz_pr_optimized"]; + + Messages.messages["Client_onUpdateData_xz_y_optimized"] = new Message_Client_onUpdateData_xz_y_optimized(52, "Client_onUpdateData_xz_y_optimized", -1, -1, new List()); + Messages.clientMessages[52] = Messages.messages["Client_onUpdateData_xz_y_optimized"]; + + Messages.messages["Client_onUpdateData_xz_p_optimized"] = new Message_Client_onUpdateData_xz_p_optimized(53, "Client_onUpdateData_xz_p_optimized", -1, -1, new List()); + Messages.clientMessages[53] = Messages.messages["Client_onUpdateData_xz_p_optimized"]; + + Messages.messages["Client_onUpdateData_xz_r_optimized"] = new Message_Client_onUpdateData_xz_r_optimized(54, "Client_onUpdateData_xz_r_optimized", -1, -1, new List()); + Messages.clientMessages[54] = Messages.messages["Client_onUpdateData_xz_r_optimized"]; + + Messages.messages["Client_onUpdateData_xyz_optimized"] = new Message_Client_onUpdateData_xyz_optimized(55, "Client_onUpdateData_xyz_optimized", -1, -1, new List()); + Messages.clientMessages[55] = Messages.messages["Client_onUpdateData_xyz_optimized"]; + + Messages.messages["Client_onUpdateData_xyz_ypr_optimized"] = new Message_Client_onUpdateData_xyz_ypr_optimized(56, "Client_onUpdateData_xyz_ypr_optimized", -1, -1, new List()); + Messages.clientMessages[56] = Messages.messages["Client_onUpdateData_xyz_ypr_optimized"]; + + Messages.messages["Client_onUpdateData_xyz_yp_optimized"] = new Message_Client_onUpdateData_xyz_yp_optimized(57, "Client_onUpdateData_xyz_yp_optimized", -1, -1, new List()); + Messages.clientMessages[57] = Messages.messages["Client_onUpdateData_xyz_yp_optimized"]; + + Messages.messages["Client_onUpdateData_xyz_yr_optimized"] = new Message_Client_onUpdateData_xyz_yr_optimized(58, "Client_onUpdateData_xyz_yr_optimized", -1, -1, new List()); + Messages.clientMessages[58] = Messages.messages["Client_onUpdateData_xyz_yr_optimized"]; + + Messages.messages["Client_onUpdateData_xyz_pr_optimized"] = new Message_Client_onUpdateData_xyz_pr_optimized(59, "Client_onUpdateData_xyz_pr_optimized", -1, -1, new List()); + Messages.clientMessages[59] = Messages.messages["Client_onUpdateData_xyz_pr_optimized"]; + + Messages.messages["Client_onUpdateData_xyz_y_optimized"] = new Message_Client_onUpdateData_xyz_y_optimized(60, "Client_onUpdateData_xyz_y_optimized", -1, -1, new List()); + Messages.clientMessages[60] = Messages.messages["Client_onUpdateData_xyz_y_optimized"]; + + Messages.messages["Client_onUpdateData_xyz_p_optimized"] = new Message_Client_onUpdateData_xyz_p_optimized(61, "Client_onUpdateData_xyz_p_optimized", -1, -1, new List()); + Messages.clientMessages[61] = Messages.messages["Client_onUpdateData_xyz_p_optimized"]; + + Messages.messages["Client_onUpdateData_xyz_r_optimized"] = new Message_Client_onUpdateData_xyz_r_optimized(62, "Client_onUpdateData_xyz_r_optimized", -1, -1, new List()); + Messages.clientMessages[62] = Messages.messages["Client_onUpdateData_xyz_r_optimized"]; + + Messages.messages["Client_onImportServerErrorsDescr"] = new Message_Client_onImportServerErrorsDescr(63, "Client_onImportServerErrorsDescr", -1, -1, new List()); + Messages.clientMessages[63] = Messages.messages["Client_onImportServerErrorsDescr"]; + + Messages.messages["Client_onImportClientSDK"] = new Message_Client_onImportClientSDK(64, "Client_onImportClientSDK", -1, -1, new List()); + Messages.clientMessages[64] = Messages.messages["Client_onImportClientSDK"]; + + Messages.messages["Client_initSpaceData"] = new Message_Client_initSpaceData(65, "Client_initSpaceData", -1, -1, new List()); + Messages.clientMessages[65] = Messages.messages["Client_initSpaceData"]; + + + List Client_setSpaceData_argstypes = new List(); + Client_setSpaceData_argstypes.Add(4); + Client_setSpaceData_argstypes.Add(1); + Client_setSpaceData_argstypes.Add(1); + Messages.messages["Client_setSpaceData"] = new Message_Client_setSpaceData(66, "Client_setSpaceData", -1, 0, Client_setSpaceData_argstypes); + Messages.clientMessages[66] = Messages.messages["Client_setSpaceData"]; + + + List Client_delSpaceData_argstypes = new List(); + Client_delSpaceData_argstypes.Add(4); + Client_delSpaceData_argstypes.Add(1); + Messages.messages["Client_delSpaceData"] = new Message_Client_delSpaceData(67, "Client_delSpaceData", -1, 0, Client_delSpaceData_argstypes); + Messages.clientMessages[67] = Messages.messages["Client_delSpaceData"]; + + + List Client_onReqAccountResetPasswordCB_argstypes = new List(); + Client_onReqAccountResetPasswordCB_argstypes.Add(3); + Messages.messages["Client_onReqAccountResetPasswordCB"] = new Message_Client_onReqAccountResetPasswordCB(68, "Client_onReqAccountResetPasswordCB", 2, 0, Client_onReqAccountResetPasswordCB_argstypes); + Messages.clientMessages[68] = Messages.messages["Client_onReqAccountResetPasswordCB"]; + + + List Client_onReqAccountBindEmailCB_argstypes = new List(); + Client_onReqAccountBindEmailCB_argstypes.Add(3); + Messages.messages["Client_onReqAccountBindEmailCB"] = new Message_Client_onReqAccountBindEmailCB(69, "Client_onReqAccountBindEmailCB", 2, 0, Client_onReqAccountBindEmailCB_argstypes); + Messages.clientMessages[69] = Messages.messages["Client_onReqAccountBindEmailCB"]; + + + List Client_onReqAccountNewPasswordCB_argstypes = new List(); + Client_onReqAccountNewPasswordCB_argstypes.Add(3); + Messages.messages["Client_onReqAccountNewPasswordCB"] = new Message_Client_onReqAccountNewPasswordCB(70, "Client_onReqAccountNewPasswordCB", 2, 0, Client_onReqAccountNewPasswordCB_argstypes); + Messages.clientMessages[70] = Messages.messages["Client_onReqAccountNewPasswordCB"]; + + Messages.messages["Client_onReloginBaseappSuccessfully"] = new Message_Client_onReloginBaseappSuccessfully(71, "Client_onReloginBaseappSuccessfully", -1, -1, new List()); + Messages.clientMessages[71] = Messages.messages["Client_onReloginBaseappSuccessfully"]; + + Messages.messages["Client_onAppActiveTickCB"] = new Message_Client_onAppActiveTickCB(72, "Client_onAppActiveTickCB", 0, 0, new List()); + Messages.clientMessages[72] = Messages.messages["Client_onAppActiveTickCB"]; + + Messages.messages["Client_onCreateAccountResult"] = new Message_Client_onCreateAccountResult(501, "Client_onCreateAccountResult", -1, -1, new List()); + Messages.clientMessages[501] = Messages.messages["Client_onCreateAccountResult"]; + + Messages.messages["Client_onLoginSuccessfully"] = new Message_Client_onLoginSuccessfully(502, "Client_onLoginSuccessfully", -1, -1, new List()); + Messages.clientMessages[502] = Messages.messages["Client_onLoginSuccessfully"]; + + Messages.messages["Client_onLoginFailed"] = new Message_Client_onLoginFailed(503, "Client_onLoginFailed", -1, -1, new List()); + Messages.clientMessages[503] = Messages.messages["Client_onLoginFailed"]; + + + List Client_onCreatedProxies_argstypes = new List(); + Client_onCreatedProxies_argstypes.Add(5); + Client_onCreatedProxies_argstypes.Add(8); + Client_onCreatedProxies_argstypes.Add(1); + Messages.messages["Client_onCreatedProxies"] = new Message_Client_onCreatedProxies(504, "Client_onCreatedProxies", -1, 0, Client_onCreatedProxies_argstypes); + Messages.clientMessages[504] = Messages.messages["Client_onCreatedProxies"]; + + + List Client_onLoginBaseappFailed_argstypes = new List(); + Client_onLoginBaseappFailed_argstypes.Add(3); + Messages.messages["Client_onLoginBaseappFailed"] = new Message_Client_onLoginBaseappFailed(505, "Client_onLoginBaseappFailed", 2, 0, Client_onLoginBaseappFailed_argstypes); + Messages.clientMessages[505] = Messages.messages["Client_onLoginBaseappFailed"]; + + Messages.messages["Client_onRemoteMethodCall"] = new Message_Client_onRemoteMethodCall(506, "Client_onRemoteMethodCall", -1, -1, new List()); + Messages.clientMessages[506] = Messages.messages["Client_onRemoteMethodCall"]; + + Messages.messages["Client_onEntityEnterWorld"] = new Message_Client_onEntityEnterWorld(507, "Client_onEntityEnterWorld", -1, -1, new List()); + Messages.clientMessages[507] = Messages.messages["Client_onEntityEnterWorld"]; + + + List Client_onEntityLeaveWorld_argstypes = new List(); + Client_onEntityLeaveWorld_argstypes.Add(8); + Messages.messages["Client_onEntityLeaveWorld"] = new Message_Client_onEntityLeaveWorld(508, "Client_onEntityLeaveWorld", 4, 0, Client_onEntityLeaveWorld_argstypes); + Messages.clientMessages[508] = Messages.messages["Client_onEntityLeaveWorld"]; + + Messages.messages["Client_onEntityEnterSpace"] = new Message_Client_onEntityEnterSpace(509, "Client_onEntityEnterSpace", -1, -1, new List()); + Messages.clientMessages[509] = Messages.messages["Client_onEntityEnterSpace"]; + + + List Client_onEntityLeaveSpace_argstypes = new List(); + Client_onEntityLeaveSpace_argstypes.Add(8); + Messages.messages["Client_onEntityLeaveSpace"] = new Message_Client_onEntityLeaveSpace(510, "Client_onEntityLeaveSpace", 4, 0, Client_onEntityLeaveSpace_argstypes); + Messages.clientMessages[510] = Messages.messages["Client_onEntityLeaveSpace"]; + + Messages.messages["Client_onUpdatePropertys"] = new Message_Client_onUpdatePropertys(511, "Client_onUpdatePropertys", -1, -1, new List()); + Messages.clientMessages[511] = Messages.messages["Client_onUpdatePropertys"]; + + + List Client_onEntityDestroyed_argstypes = new List(); + Client_onEntityDestroyed_argstypes.Add(8); + Messages.messages["Client_onEntityDestroyed"] = new Message_Client_onEntityDestroyed(512, "Client_onEntityDestroyed", 4, 0, Client_onEntityDestroyed_argstypes); + Messages.clientMessages[512] = Messages.messages["Client_onEntityDestroyed"]; + + + List Client_onStreamDataStarted_argstypes = new List(); + Client_onStreamDataStarted_argstypes.Add(7); + Client_onStreamDataStarted_argstypes.Add(4); + Client_onStreamDataStarted_argstypes.Add(1); + Messages.messages["Client_onStreamDataStarted"] = new Message_Client_onStreamDataStarted(514, "Client_onStreamDataStarted", -1, 0, Client_onStreamDataStarted_argstypes); + Messages.clientMessages[514] = Messages.messages["Client_onStreamDataStarted"]; + + Messages.messages["Client_onStreamDataRecv"] = new Message_Client_onStreamDataRecv(515, "Client_onStreamDataRecv", -1, -1, new List()); + Messages.clientMessages[515] = Messages.messages["Client_onStreamDataRecv"]; + + + List Client_onStreamDataCompleted_argstypes = new List(); + Client_onStreamDataCompleted_argstypes.Add(7); + Messages.messages["Client_onStreamDataCompleted"] = new Message_Client_onStreamDataCompleted(516, "Client_onStreamDataCompleted", 2, 0, Client_onStreamDataCompleted_argstypes); + Messages.clientMessages[516] = Messages.messages["Client_onStreamDataCompleted"]; + + + List Client_onKicked_argstypes = new List(); + Client_onKicked_argstypes.Add(3); + Messages.messages["Client_onKicked"] = new Message_Client_onKicked(517, "Client_onKicked", 2, 0, Client_onKicked_argstypes); + Messages.clientMessages[517] = Messages.messages["Client_onKicked"]; + + Messages.messages["Client_onImportClientMessages"] = new Message_Client_onImportClientMessages(518, "Client_onImportClientMessages", -1, -1, new List()); + Messages.clientMessages[518] = Messages.messages["Client_onImportClientMessages"]; + + Messages.messages["Client_onImportClientEntityDef"] = new Message_Client_onImportClientEntityDef(519, "Client_onImportClientEntityDef", -1, -1, new List()); + Messages.clientMessages[519] = Messages.messages["Client_onImportClientEntityDef"]; + + Messages.messages["Client_onHelloCB"] = new Message_Client_onHelloCB(521, "Client_onHelloCB", -1, -1, new List()); + Messages.clientMessages[521] = Messages.messages["Client_onHelloCB"]; + + Messages.messages["Client_onScriptVersionNotMatch"] = new Message_Client_onScriptVersionNotMatch(522, "Client_onScriptVersionNotMatch", -1, -1, new List()); + Messages.clientMessages[522] = Messages.messages["Client_onScriptVersionNotMatch"]; + + Messages.messages["Client_onVersionNotMatch"] = new Message_Client_onVersionNotMatch(523, "Client_onVersionNotMatch", -1, -1, new List()); + Messages.clientMessages[523] = Messages.messages["Client_onVersionNotMatch"]; + + + List Client_onControlEntity_argstypes = new List(); + Client_onControlEntity_argstypes.Add(8); + Client_onControlEntity_argstypes.Add(6); + Messages.messages["Client_onControlEntity"] = new Message_Client_onControlEntity(524, "Client_onControlEntity", 5, 0, Client_onControlEntity_argstypes); + Messages.clientMessages[524] = Messages.messages["Client_onControlEntity"]; + + Messages.messages["Loginapp_reqCreateAccount"] = new Message_Loginapp_reqCreateAccount(2, "Loginapp_reqCreateAccount", -1, 0, new List()); + Messages.loginappMessages[2] = Messages.messages["Loginapp_reqCreateAccount"]; + + Messages.messages["Loginapp_login"] = new Message_Loginapp_login(3, "Loginapp_login", -1, 0, new List()); + Messages.loginappMessages[3] = Messages.messages["Loginapp_login"]; + + Messages.messages["Loginapp_hello"] = new Message_Loginapp_hello(4, "Loginapp_hello", -1, 0, new List()); + Messages.loginappMessages[4] = Messages.messages["Loginapp_hello"]; + + Messages.messages["Loginapp_importClientMessages"] = new Message_Loginapp_importClientMessages(5, "Loginapp_importClientMessages", 0, 0, new List()); + Messages.loginappMessages[5] = Messages.messages["Loginapp_importClientMessages"]; + + Messages.messages["Loginapp_reqCreateMailAccount"] = new Message_Loginapp_reqCreateMailAccount(6, "Loginapp_reqCreateMailAccount", -1, 0, new List()); + Messages.loginappMessages[6] = Messages.messages["Loginapp_reqCreateMailAccount"]; + + Messages.messages["Loginapp_importClientSDK"] = new Message_Loginapp_importClientSDK(7, "Loginapp_importClientSDK", -1, 0, new List()); + Messages.loginappMessages[7] = Messages.messages["Loginapp_importClientSDK"]; + + Messages.messages["Loginapp_importServerErrorsDescr"] = new Message_Loginapp_importServerErrorsDescr(8, "Loginapp_importServerErrorsDescr", 0, 0, new List()); + Messages.loginappMessages[8] = Messages.messages["Loginapp_importServerErrorsDescr"]; + + Messages.messages["Loginapp_onClientActiveTick"] = new Message_Loginapp_onClientActiveTick(11, "Loginapp_onClientActiveTick", 0, 0, new List()); + Messages.loginappMessages[11] = Messages.messages["Loginapp_onClientActiveTick"]; + + + List Loginapp_reqAccountResetPassword_argstypes = new List(); + Loginapp_reqAccountResetPassword_argstypes.Add(1); + Messages.messages["Loginapp_reqAccountResetPassword"] = new Message_Loginapp_reqAccountResetPassword(12, "Loginapp_reqAccountResetPassword", -1, 0, Loginapp_reqAccountResetPassword_argstypes); + Messages.loginappMessages[12] = Messages.messages["Loginapp_reqAccountResetPassword"]; + + + List Baseapp_logoutBaseapp_argstypes = new List(); + Baseapp_logoutBaseapp_argstypes.Add(5); + Baseapp_logoutBaseapp_argstypes.Add(8); + Messages.messages["Baseapp_logoutBaseapp"] = new Message_Baseapp_logoutBaseapp(24, "Baseapp_logoutBaseapp", 12, 0, Baseapp_logoutBaseapp_argstypes); + Messages.baseappMessages[24] = Messages.messages["Baseapp_logoutBaseapp"]; + + Messages.messages["Baseapp_onUpdateDataFromClient"] = new Message_Baseapp_onUpdateDataFromClient(27, "Baseapp_onUpdateDataFromClient", -1, -1, new List()); + Messages.baseappMessages[27] = Messages.messages["Baseapp_onUpdateDataFromClient"]; + + Messages.messages["Baseapp_onUpdateDataFromClientForControlledEntity"] = new Message_Baseapp_onUpdateDataFromClientForControlledEntity(28, "Baseapp_onUpdateDataFromClientForControlledEntity", -1, -1, new List()); + Messages.baseappMessages[28] = Messages.messages["Baseapp_onUpdateDataFromClientForControlledEntity"]; + + + List Baseapp_reqAccountBindEmail_argstypes = new List(); + Baseapp_reqAccountBindEmail_argstypes.Add(8); + Baseapp_reqAccountBindEmail_argstypes.Add(1); + Baseapp_reqAccountBindEmail_argstypes.Add(1); + Messages.messages["Baseapp_reqAccountBindEmail"] = new Message_Baseapp_reqAccountBindEmail(50, "Baseapp_reqAccountBindEmail", -1, 0, Baseapp_reqAccountBindEmail_argstypes); + Messages.baseappMessages[50] = Messages.messages["Baseapp_reqAccountBindEmail"]; + + + List Baseapp_reqAccountNewPassword_argstypes = new List(); + Baseapp_reqAccountNewPassword_argstypes.Add(8); + Baseapp_reqAccountNewPassword_argstypes.Add(1); + Baseapp_reqAccountNewPassword_argstypes.Add(1); + Messages.messages["Baseapp_reqAccountNewPassword"] = new Message_Baseapp_reqAccountNewPassword(53, "Baseapp_reqAccountNewPassword", -1, 0, Baseapp_reqAccountNewPassword_argstypes); + Messages.baseappMessages[53] = Messages.messages["Baseapp_reqAccountNewPassword"]; + + Messages.messages["Entity_forwardEntityMessageToCellappFromClient"] = new Message_Entity_forwardEntityMessageToCellappFromClient(57, "Entity_forwardEntityMessageToCellappFromClient", -1, -1, new List()); + Messages.baseappMessages[57] = Messages.messages["Entity_forwardEntityMessageToCellappFromClient"]; + + Messages.messages["Baseapp_hello"] = new Message_Baseapp_hello(200, "Baseapp_hello", -1, -1, new List()); + Messages.baseappMessages[200] = Messages.messages["Baseapp_hello"]; + + + List Baseapp_loginBaseapp_argstypes = new List(); + Baseapp_loginBaseapp_argstypes.Add(1); + Baseapp_loginBaseapp_argstypes.Add(1); + Messages.messages["Baseapp_loginBaseapp"] = new Message_Baseapp_loginBaseapp(202, "Baseapp_loginBaseapp", -1, 0, Baseapp_loginBaseapp_argstypes); + Messages.baseappMessages[202] = Messages.messages["Baseapp_loginBaseapp"]; + + + List Baseapp_reloginBaseapp_argstypes = new List(); + Baseapp_reloginBaseapp_argstypes.Add(1); + Baseapp_reloginBaseapp_argstypes.Add(1); + Baseapp_reloginBaseapp_argstypes.Add(5); + Baseapp_reloginBaseapp_argstypes.Add(8); + Messages.messages["Baseapp_reloginBaseapp"] = new Message_Baseapp_reloginBaseapp(204, "Baseapp_reloginBaseapp", -1, 0, Baseapp_reloginBaseapp_argstypes); + Messages.baseappMessages[204] = Messages.messages["Baseapp_reloginBaseapp"]; + + Messages.messages["Baseapp_onRemoteCallCellMethodFromClient"] = new Message_Baseapp_onRemoteCallCellMethodFromClient(205, "Baseapp_onRemoteCallCellMethodFromClient", -1, -1, new List()); + Messages.baseappMessages[205] = Messages.messages["Baseapp_onRemoteCallCellMethodFromClient"]; + + Messages.messages["Baseapp_onClientActiveTick"] = new Message_Baseapp_onClientActiveTick(206, "Baseapp_onClientActiveTick", 0, 0, new List()); + Messages.baseappMessages[206] = Messages.messages["Baseapp_onClientActiveTick"]; + + Messages.messages["Baseapp_importClientMessages"] = new Message_Baseapp_importClientMessages(207, "Baseapp_importClientMessages", 0, 0, new List()); + Messages.baseappMessages[207] = Messages.messages["Baseapp_importClientMessages"]; + + Messages.messages["Baseapp_importClientEntityDef"] = new Message_Baseapp_importClientEntityDef(208, "Baseapp_importClientEntityDef", 0, 0, new List()); + Messages.baseappMessages[208] = Messages.messages["Baseapp_importClientEntityDef"]; + + Messages.messages["Entity_onRemoteMethodCall"] = new Message_Entity_onRemoteMethodCall(302, "Entity_onRemoteMethodCall", -1, -1, new List()); + Messages.baseappMessages[302] = Messages.messages["Entity_onRemoteMethodCall"]; + + + return true; + } + } } \ No newline at end of file diff --git a/Assets/Plugins/kbengine_unity3d_plugins/Method.cs b/Assets/Plugins/kbengine_unity3d_plugins/Method.cs index cd3eb89..92167e9 100644 --- a/Assets/Plugins/kbengine_unity3d_plugins/Method.cs +++ b/Assets/Plugins/kbengine_unity3d_plugins/Method.cs @@ -1,26 +1,26 @@ -namespace KBEngine -{ - using UnityEngine; - using System; - using System.Collections; - using System.Collections.Generic; - - /* - 实体定义的方法模块 - 抽象出一个def文件中定义的方法,改模块类提供了该方法的相关描述信息 - 例如:方法的参数、方法的id、方法对应脚本的handler - */ - public class Method - { - public string name = ""; - public UInt16 methodUtype = 0; - public Int16 aliasID = -1; - public List args = null; - - public Method() - { - - } - } - -} +namespace KBEngine +{ + using UnityEngine; + using System; + using System.Collections; + using System.Collections.Generic; + + /* + 实体定义的方法模块 + 抽象出一个def文件中定义的方法,改模块类提供了该方法的相关描述信息 + 例如:方法的参数、方法的id、方法对应脚本的handler + */ + public class Method + { + public string name = ""; + public UInt16 methodUtype = 0; + public Int16 aliasID = -1; + public List args = null; + + public Method() + { + + } + } + +} diff --git a/Assets/Plugins/kbengine_unity3d_plugins/MonsterBase.cs b/Assets/Plugins/kbengine_unity3d_plugins/MonsterBase.cs index e3f3030..8ec4126 100644 --- a/Assets/Plugins/kbengine_unity3d_plugins/MonsterBase.cs +++ b/Assets/Plugins/kbengine_unity3d_plugins/MonsterBase.cs @@ -1,806 +1,806 @@ -/* - Generated by KBEngine! - Please do not modify this file! - Please inherit this module, such as: (class Monster : MonsterBase) - tools = kbcmd -*/ - -namespace KBEngine -{ - using UnityEngine; - using System; - using System.Collections; - using System.Collections.Generic; - - // defined in */scripts/entity_defs/Monster.def - // Please inherit and implement "class Monster : MonsterBase" - public abstract class MonsterBase : Entity - { - public EntityBaseEntityCall_MonsterBase baseEntityCall = null; - public EntityCellEntityCall_MonsterBase cellEntityCall = null; - - public Int32 HP = 0; - public virtual void onHPChanged(Int32 oldValue) {} - public Int32 HP_Max = 0; - public virtual void onHP_MaxChanged(Int32 oldValue) {} - public Int32 MP = 0; - public virtual void onMPChanged(Int32 oldValue) {} - public Int32 MP_Max = 0; - public virtual void onMP_MaxChanged(Int32 oldValue) {} - public UInt32 entityNO = 0; - public virtual void onEntityNOChanged(UInt32 oldValue) {} - public Int32 forbids = 0; - public virtual void onForbidsChanged(Int32 oldValue) {} - public UInt32 modelID = 0; - public virtual void onModelIDChanged(UInt32 oldValue) {} - public Byte modelScale = 30; - public virtual void onModelScaleChanged(Byte oldValue) {} - public Byte moveSpeed = 50; - public virtual void onMoveSpeedChanged(Byte oldValue) {} - public string name = ""; - public virtual void onNameChanged(string oldValue) {} - public SByte state = 0; - public virtual void onStateChanged(SByte oldValue) {} - public Byte subState = 0; - public virtual void onSubStateChanged(Byte oldValue) {} - public UInt32 uid = 0; - public virtual void onUidChanged(UInt32 oldValue) {} - public UInt32 utype = 0; - public virtual void onUtypeChanged(UInt32 oldValue) {} - - public abstract void recvDamage(Int32 arg1, Int32 arg2, Int32 arg3, Int32 arg4); - - public MonsterBase() - { - } - - public override void onComponentsEnterworld() - { - } - - public override void onComponentsLeaveworld() - { - } - - public override void onGetBase() - { - baseEntityCall = new EntityBaseEntityCall_MonsterBase(id, className); - } - - public override void onGetCell() - { - cellEntityCall = new EntityCellEntityCall_MonsterBase(id, className); - } - - public override void onLoseCell() - { - cellEntityCall = null; - } - - public override EntityCall getBaseEntityCall() - { - return baseEntityCall; - } - - public override EntityCall getCellEntityCall() - { - return cellEntityCall; - } - - public override void attachComponents() - { - } - - public override void detachComponents() - { - } - - public override void onRemoteMethodCall(MemoryStream stream) - { - ScriptModule sm = EntityDef.moduledefs["Monster"]; - - UInt16 methodUtype = 0; - UInt16 componentPropertyUType = 0; - - if(sm.usePropertyDescrAlias) - { - componentPropertyUType = stream.readUint8(); - } - else - { - componentPropertyUType = stream.readUint16(); - } - - if(sm.useMethodDescrAlias) - { - methodUtype = stream.readUint8(); - } - else - { - methodUtype = stream.readUint16(); - } - - Method method = null; - - if(componentPropertyUType == 0) - { - method = sm.idmethods[methodUtype]; - } - else - { - Property pComponentPropertyDescription = sm.idpropertys[componentPropertyUType]; - switch(pComponentPropertyDescription.properUtype) - { - default: - break; - } - - return; - } - - switch(method.methodUtype) - { - case 34: - Int32 recvDamage_arg1 = stream.readInt32(); - Int32 recvDamage_arg2 = stream.readInt32(); - Int32 recvDamage_arg3 = stream.readInt32(); - Int32 recvDamage_arg4 = stream.readInt32(); - recvDamage(recvDamage_arg1, recvDamage_arg2, recvDamage_arg3, recvDamage_arg4); - break; - default: - break; - }; - } - - public override void onUpdatePropertys(MemoryStream stream) - { - ScriptModule sm = EntityDef.moduledefs["Monster"]; - Dictionary pdatas = sm.idpropertys; - - while(stream.length() > 0) - { - UInt16 _t_utype = 0; - UInt16 _t_child_utype = 0; - - { - if(sm.usePropertyDescrAlias) - { - _t_utype = stream.readUint8(); - _t_child_utype = stream.readUint8(); - } - else - { - _t_utype = stream.readUint16(); - _t_child_utype = stream.readUint16(); - } - } - - Property prop = null; - - if(_t_utype == 0) - { - prop = pdatas[_t_child_utype]; - } - else - { - Property pComponentPropertyDescription = pdatas[_t_utype]; - switch(pComponentPropertyDescription.properUtype) - { - default: - break; - } - - return; - } - - switch(prop.properUtype) - { - case 47001: - Int32 oldval_HP = HP; - HP = stream.readInt32(); - - if(prop.isBase()) - { - if(inited) - onHPChanged(oldval_HP); - } - else - { - if(inWorld) - onHPChanged(oldval_HP); - } - - break; - case 47002: - Int32 oldval_HP_Max = HP_Max; - HP_Max = stream.readInt32(); - - if(prop.isBase()) - { - if(inited) - onHP_MaxChanged(oldval_HP_Max); - } - else - { - if(inWorld) - onHP_MaxChanged(oldval_HP_Max); - } - - break; - case 47003: - Int32 oldval_MP = MP; - MP = stream.readInt32(); - - if(prop.isBase()) - { - if(inited) - onMPChanged(oldval_MP); - } - else - { - if(inWorld) - onMPChanged(oldval_MP); - } - - break; - case 47004: - Int32 oldval_MP_Max = MP_Max; - MP_Max = stream.readInt32(); - - if(prop.isBase()) - { - if(inited) - onMP_MaxChanged(oldval_MP_Max); - } - else - { - if(inWorld) - onMP_MaxChanged(oldval_MP_Max); - } - - break; - case 40001: - Vector3 oldval_direction = direction; - direction = stream.readVector3(); - - if(prop.isBase()) - { - if(inited) - onDirectionChanged(oldval_direction); - } - else - { - if(inWorld) - onDirectionChanged(oldval_direction); - } - - break; - case 51007: - UInt32 oldval_entityNO = entityNO; - entityNO = stream.readUint32(); - - if(prop.isBase()) - { - if(inited) - onEntityNOChanged(oldval_entityNO); - } - else - { - if(inWorld) - onEntityNOChanged(oldval_entityNO); - } - - break; - case 47005: - Int32 oldval_forbids = forbids; - forbids = stream.readInt32(); - - if(prop.isBase()) - { - if(inited) - onForbidsChanged(oldval_forbids); - } - else - { - if(inWorld) - onForbidsChanged(oldval_forbids); - } - - break; - case 41006: - UInt32 oldval_modelID = modelID; - modelID = stream.readUint32(); - - if(prop.isBase()) - { - if(inited) - onModelIDChanged(oldval_modelID); - } - else - { - if(inWorld) - onModelIDChanged(oldval_modelID); - } - - break; - case 41007: - Byte oldval_modelScale = modelScale; - modelScale = stream.readUint8(); - - if(prop.isBase()) - { - if(inited) - onModelScaleChanged(oldval_modelScale); - } - else - { - if(inWorld) - onModelScaleChanged(oldval_modelScale); - } - - break; - case 32: - Byte oldval_moveSpeed = moveSpeed; - moveSpeed = stream.readUint8(); - - if(prop.isBase()) - { - if(inited) - onMoveSpeedChanged(oldval_moveSpeed); - } - else - { - if(inWorld) - onMoveSpeedChanged(oldval_moveSpeed); - } - - break; - case 41003: - string oldval_name = name; - name = stream.readUnicode(); - - if(prop.isBase()) - { - if(inited) - onNameChanged(oldval_name); - } - else - { - if(inWorld) - onNameChanged(oldval_name); - } - - break; - case 40000: - Vector3 oldval_position = position; - position = stream.readVector3(); - - if(prop.isBase()) - { - if(inited) - onPositionChanged(oldval_position); - } - else - { - if(inWorld) - onPositionChanged(oldval_position); - } - - break; - case 40002: - stream.readUint32(); - break; - case 47006: - SByte oldval_state = state; - state = stream.readInt8(); - - if(prop.isBase()) - { - if(inited) - onStateChanged(oldval_state); - } - else - { - if(inWorld) - onStateChanged(oldval_state); - } - - break; - case 47007: - Byte oldval_subState = subState; - subState = stream.readUint8(); - - if(prop.isBase()) - { - if(inited) - onSubStateChanged(oldval_subState); - } - else - { - if(inWorld) - onSubStateChanged(oldval_subState); - } - - break; - case 41004: - UInt32 oldval_uid = uid; - uid = stream.readUint32(); - - if(prop.isBase()) - { - if(inited) - onUidChanged(oldval_uid); - } - else - { - if(inWorld) - onUidChanged(oldval_uid); - } - - break; - case 41005: - UInt32 oldval_utype = utype; - utype = stream.readUint32(); - - if(prop.isBase()) - { - if(inited) - onUtypeChanged(oldval_utype); - } - else - { - if(inWorld) - onUtypeChanged(oldval_utype); - } - - break; - default: - break; - }; - } - } - - public override void callPropertysSetMethods() - { - ScriptModule sm = EntityDef.moduledefs["Monster"]; - Dictionary pdatas = sm.idpropertys; - - Int32 oldval_HP = HP; - Property prop_HP = pdatas[4]; - if(prop_HP.isBase()) - { - if(inited && !inWorld) - onHPChanged(oldval_HP); - } - else - { - if(inWorld) - { - if(prop_HP.isOwnerOnly() && !isPlayer()) - { - } - else - { - onHPChanged(oldval_HP); - } - } - } - - Int32 oldval_HP_Max = HP_Max; - Property prop_HP_Max = pdatas[5]; - if(prop_HP_Max.isBase()) - { - if(inited && !inWorld) - onHP_MaxChanged(oldval_HP_Max); - } - else - { - if(inWorld) - { - if(prop_HP_Max.isOwnerOnly() && !isPlayer()) - { - } - else - { - onHP_MaxChanged(oldval_HP_Max); - } - } - } - - Int32 oldval_MP = MP; - Property prop_MP = pdatas[6]; - if(prop_MP.isBase()) - { - if(inited && !inWorld) - onMPChanged(oldval_MP); - } - else - { - if(inWorld) - { - if(prop_MP.isOwnerOnly() && !isPlayer()) - { - } - else - { - onMPChanged(oldval_MP); - } - } - } - - Int32 oldval_MP_Max = MP_Max; - Property prop_MP_Max = pdatas[7]; - if(prop_MP_Max.isBase()) - { - if(inited && !inWorld) - onMP_MaxChanged(oldval_MP_Max); - } - else - { - if(inWorld) - { - if(prop_MP_Max.isOwnerOnly() && !isPlayer()) - { - } - else - { - onMP_MaxChanged(oldval_MP_Max); - } - } - } - - Vector3 oldval_direction = direction; - Property prop_direction = pdatas[2]; - if(prop_direction.isBase()) - { - if(inited && !inWorld) - onDirectionChanged(oldval_direction); - } - else - { - if(inWorld) - { - if(prop_direction.isOwnerOnly() && !isPlayer()) - { - } - else - { - onDirectionChanged(oldval_direction); - } - } - } - - UInt32 oldval_entityNO = entityNO; - Property prop_entityNO = pdatas[8]; - if(prop_entityNO.isBase()) - { - if(inited && !inWorld) - onEntityNOChanged(oldval_entityNO); - } - else - { - if(inWorld) - { - if(prop_entityNO.isOwnerOnly() && !isPlayer()) - { - } - else - { - onEntityNOChanged(oldval_entityNO); - } - } - } - - Int32 oldval_forbids = forbids; - Property prop_forbids = pdatas[9]; - if(prop_forbids.isBase()) - { - if(inited && !inWorld) - onForbidsChanged(oldval_forbids); - } - else - { - if(inWorld) - { - if(prop_forbids.isOwnerOnly() && !isPlayer()) - { - } - else - { - onForbidsChanged(oldval_forbids); - } - } - } - - UInt32 oldval_modelID = modelID; - Property prop_modelID = pdatas[10]; - if(prop_modelID.isBase()) - { - if(inited && !inWorld) - onModelIDChanged(oldval_modelID); - } - else - { - if(inWorld) - { - if(prop_modelID.isOwnerOnly() && !isPlayer()) - { - } - else - { - onModelIDChanged(oldval_modelID); - } - } - } - - Byte oldval_modelScale = modelScale; - Property prop_modelScale = pdatas[11]; - if(prop_modelScale.isBase()) - { - if(inited && !inWorld) - onModelScaleChanged(oldval_modelScale); - } - else - { - if(inWorld) - { - if(prop_modelScale.isOwnerOnly() && !isPlayer()) - { - } - else - { - onModelScaleChanged(oldval_modelScale); - } - } - } - - Byte oldval_moveSpeed = moveSpeed; - Property prop_moveSpeed = pdatas[12]; - if(prop_moveSpeed.isBase()) - { - if(inited && !inWorld) - onMoveSpeedChanged(oldval_moveSpeed); - } - else - { - if(inWorld) - { - if(prop_moveSpeed.isOwnerOnly() && !isPlayer()) - { - } - else - { - onMoveSpeedChanged(oldval_moveSpeed); - } - } - } - - string oldval_name = name; - Property prop_name = pdatas[13]; - if(prop_name.isBase()) - { - if(inited && !inWorld) - onNameChanged(oldval_name); - } - else - { - if(inWorld) - { - if(prop_name.isOwnerOnly() && !isPlayer()) - { - } - else - { - onNameChanged(oldval_name); - } - } - } - - Vector3 oldval_position = position; - Property prop_position = pdatas[1]; - if(prop_position.isBase()) - { - if(inited && !inWorld) - onPositionChanged(oldval_position); - } - else - { - if(inWorld) - { - if(prop_position.isOwnerOnly() && !isPlayer()) - { - } - else - { - onPositionChanged(oldval_position); - } - } - } - - SByte oldval_state = state; - Property prop_state = pdatas[14]; - if(prop_state.isBase()) - { - if(inited && !inWorld) - onStateChanged(oldval_state); - } - else - { - if(inWorld) - { - if(prop_state.isOwnerOnly() && !isPlayer()) - { - } - else - { - onStateChanged(oldval_state); - } - } - } - - Byte oldval_subState = subState; - Property prop_subState = pdatas[15]; - if(prop_subState.isBase()) - { - if(inited && !inWorld) - onSubStateChanged(oldval_subState); - } - else - { - if(inWorld) - { - if(prop_subState.isOwnerOnly() && !isPlayer()) - { - } - else - { - onSubStateChanged(oldval_subState); - } - } - } - - UInt32 oldval_uid = uid; - Property prop_uid = pdatas[16]; - if(prop_uid.isBase()) - { - if(inited && !inWorld) - onUidChanged(oldval_uid); - } - else - { - if(inWorld) - { - if(prop_uid.isOwnerOnly() && !isPlayer()) - { - } - else - { - onUidChanged(oldval_uid); - } - } - } - - UInt32 oldval_utype = utype; - Property prop_utype = pdatas[17]; - if(prop_utype.isBase()) - { - if(inited && !inWorld) - onUtypeChanged(oldval_utype); - } - else - { - if(inWorld) - { - if(prop_utype.isOwnerOnly() && !isPlayer()) - { - } - else - { - onUtypeChanged(oldval_utype); - } - } - } - - } - } +/* + Generated by KBEngine! + Please do not modify this file! + Please inherit this module, such as: (class Monster : MonsterBase) + tools = kbcmd +*/ + +namespace KBEngine +{ + using UnityEngine; + using System; + using System.Collections; + using System.Collections.Generic; + + // defined in */scripts/entity_defs/Monster.def + // Please inherit and implement "class Monster : MonsterBase" + public abstract class MonsterBase : Entity + { + public EntityBaseEntityCall_MonsterBase baseEntityCall = null; + public EntityCellEntityCall_MonsterBase cellEntityCall = null; + + public Int32 HP = 0; + public virtual void onHPChanged(Int32 oldValue) {} + public Int32 HP_Max = 0; + public virtual void onHP_MaxChanged(Int32 oldValue) {} + public Int32 MP = 0; + public virtual void onMPChanged(Int32 oldValue) {} + public Int32 MP_Max = 0; + public virtual void onMP_MaxChanged(Int32 oldValue) {} + public UInt32 entityNO = 0; + public virtual void onEntityNOChanged(UInt32 oldValue) {} + public Int32 forbids = 0; + public virtual void onForbidsChanged(Int32 oldValue) {} + public UInt32 modelID = 0; + public virtual void onModelIDChanged(UInt32 oldValue) {} + public Byte modelScale = 30; + public virtual void onModelScaleChanged(Byte oldValue) {} + public Byte moveSpeed = 50; + public virtual void onMoveSpeedChanged(Byte oldValue) {} + public string name = ""; + public virtual void onNameChanged(string oldValue) {} + public SByte state = 0; + public virtual void onStateChanged(SByte oldValue) {} + public Byte subState = 0; + public virtual void onSubStateChanged(Byte oldValue) {} + public UInt32 uid = 0; + public virtual void onUidChanged(UInt32 oldValue) {} + public UInt32 utype = 0; + public virtual void onUtypeChanged(UInt32 oldValue) {} + + public abstract void recvDamage(Int32 arg1, Int32 arg2, Int32 arg3, Int32 arg4); + + public MonsterBase() + { + } + + public override void onComponentsEnterworld() + { + } + + public override void onComponentsLeaveworld() + { + } + + public override void onGetBase() + { + baseEntityCall = new EntityBaseEntityCall_MonsterBase(id, className); + } + + public override void onGetCell() + { + cellEntityCall = new EntityCellEntityCall_MonsterBase(id, className); + } + + public override void onLoseCell() + { + cellEntityCall = null; + } + + public override EntityCall getBaseEntityCall() + { + return baseEntityCall; + } + + public override EntityCall getCellEntityCall() + { + return cellEntityCall; + } + + public override void attachComponents() + { + } + + public override void detachComponents() + { + } + + public override void onRemoteMethodCall(MemoryStream stream) + { + ScriptModule sm = EntityDef.moduledefs["Monster"]; + + UInt16 methodUtype = 0; + UInt16 componentPropertyUType = 0; + + if(sm.usePropertyDescrAlias) + { + componentPropertyUType = stream.readUint8(); + } + else + { + componentPropertyUType = stream.readUint16(); + } + + if(sm.useMethodDescrAlias) + { + methodUtype = stream.readUint8(); + } + else + { + methodUtype = stream.readUint16(); + } + + Method method = null; + + if(componentPropertyUType == 0) + { + method = sm.idmethods[methodUtype]; + } + else + { + Property pComponentPropertyDescription = sm.idpropertys[componentPropertyUType]; + switch(pComponentPropertyDescription.properUtype) + { + default: + break; + } + + return; + } + + switch(method.methodUtype) + { + case 34: + Int32 recvDamage_arg1 = stream.readInt32(); + Int32 recvDamage_arg2 = stream.readInt32(); + Int32 recvDamage_arg3 = stream.readInt32(); + Int32 recvDamage_arg4 = stream.readInt32(); + recvDamage(recvDamage_arg1, recvDamage_arg2, recvDamage_arg3, recvDamage_arg4); + break; + default: + break; + }; + } + + public override void onUpdatePropertys(MemoryStream stream) + { + ScriptModule sm = EntityDef.moduledefs["Monster"]; + Dictionary pdatas = sm.idpropertys; + + while(stream.length() > 0) + { + UInt16 _t_utype = 0; + UInt16 _t_child_utype = 0; + + { + if(sm.usePropertyDescrAlias) + { + _t_utype = stream.readUint8(); + _t_child_utype = stream.readUint8(); + } + else + { + _t_utype = stream.readUint16(); + _t_child_utype = stream.readUint16(); + } + } + + Property prop = null; + + if(_t_utype == 0) + { + prop = pdatas[_t_child_utype]; + } + else + { + Property pComponentPropertyDescription = pdatas[_t_utype]; + switch(pComponentPropertyDescription.properUtype) + { + default: + break; + } + + return; + } + + switch(prop.properUtype) + { + case 47001: + Int32 oldval_HP = HP; + HP = stream.readInt32(); + + if(prop.isBase()) + { + if(inited) + onHPChanged(oldval_HP); + } + else + { + if(inWorld) + onHPChanged(oldval_HP); + } + + break; + case 47002: + Int32 oldval_HP_Max = HP_Max; + HP_Max = stream.readInt32(); + + if(prop.isBase()) + { + if(inited) + onHP_MaxChanged(oldval_HP_Max); + } + else + { + if(inWorld) + onHP_MaxChanged(oldval_HP_Max); + } + + break; + case 47003: + Int32 oldval_MP = MP; + MP = stream.readInt32(); + + if(prop.isBase()) + { + if(inited) + onMPChanged(oldval_MP); + } + else + { + if(inWorld) + onMPChanged(oldval_MP); + } + + break; + case 47004: + Int32 oldval_MP_Max = MP_Max; + MP_Max = stream.readInt32(); + + if(prop.isBase()) + { + if(inited) + onMP_MaxChanged(oldval_MP_Max); + } + else + { + if(inWorld) + onMP_MaxChanged(oldval_MP_Max); + } + + break; + case 40001: + Vector3 oldval_direction = direction; + direction = stream.readVector3(); + + if(prop.isBase()) + { + if(inited) + onDirectionChanged(oldval_direction); + } + else + { + if(inWorld) + onDirectionChanged(oldval_direction); + } + + break; + case 51007: + UInt32 oldval_entityNO = entityNO; + entityNO = stream.readUint32(); + + if(prop.isBase()) + { + if(inited) + onEntityNOChanged(oldval_entityNO); + } + else + { + if(inWorld) + onEntityNOChanged(oldval_entityNO); + } + + break; + case 47005: + Int32 oldval_forbids = forbids; + forbids = stream.readInt32(); + + if(prop.isBase()) + { + if(inited) + onForbidsChanged(oldval_forbids); + } + else + { + if(inWorld) + onForbidsChanged(oldval_forbids); + } + + break; + case 41006: + UInt32 oldval_modelID = modelID; + modelID = stream.readUint32(); + + if(prop.isBase()) + { + if(inited) + onModelIDChanged(oldval_modelID); + } + else + { + if(inWorld) + onModelIDChanged(oldval_modelID); + } + + break; + case 41007: + Byte oldval_modelScale = modelScale; + modelScale = stream.readUint8(); + + if(prop.isBase()) + { + if(inited) + onModelScaleChanged(oldval_modelScale); + } + else + { + if(inWorld) + onModelScaleChanged(oldval_modelScale); + } + + break; + case 32: + Byte oldval_moveSpeed = moveSpeed; + moveSpeed = stream.readUint8(); + + if(prop.isBase()) + { + if(inited) + onMoveSpeedChanged(oldval_moveSpeed); + } + else + { + if(inWorld) + onMoveSpeedChanged(oldval_moveSpeed); + } + + break; + case 41003: + string oldval_name = name; + name = stream.readUnicode(); + + if(prop.isBase()) + { + if(inited) + onNameChanged(oldval_name); + } + else + { + if(inWorld) + onNameChanged(oldval_name); + } + + break; + case 40000: + Vector3 oldval_position = position; + position = stream.readVector3(); + + if(prop.isBase()) + { + if(inited) + onPositionChanged(oldval_position); + } + else + { + if(inWorld) + onPositionChanged(oldval_position); + } + + break; + case 40002: + stream.readUint32(); + break; + case 47006: + SByte oldval_state = state; + state = stream.readInt8(); + + if(prop.isBase()) + { + if(inited) + onStateChanged(oldval_state); + } + else + { + if(inWorld) + onStateChanged(oldval_state); + } + + break; + case 47007: + Byte oldval_subState = subState; + subState = stream.readUint8(); + + if(prop.isBase()) + { + if(inited) + onSubStateChanged(oldval_subState); + } + else + { + if(inWorld) + onSubStateChanged(oldval_subState); + } + + break; + case 41004: + UInt32 oldval_uid = uid; + uid = stream.readUint32(); + + if(prop.isBase()) + { + if(inited) + onUidChanged(oldval_uid); + } + else + { + if(inWorld) + onUidChanged(oldval_uid); + } + + break; + case 41005: + UInt32 oldval_utype = utype; + utype = stream.readUint32(); + + if(prop.isBase()) + { + if(inited) + onUtypeChanged(oldval_utype); + } + else + { + if(inWorld) + onUtypeChanged(oldval_utype); + } + + break; + default: + break; + }; + } + } + + public override void callPropertysSetMethods() + { + ScriptModule sm = EntityDef.moduledefs["Monster"]; + Dictionary pdatas = sm.idpropertys; + + Int32 oldval_HP = HP; + Property prop_HP = pdatas[4]; + if(prop_HP.isBase()) + { + if(inited && !inWorld) + onHPChanged(oldval_HP); + } + else + { + if(inWorld) + { + if(prop_HP.isOwnerOnly() && !isPlayer()) + { + } + else + { + onHPChanged(oldval_HP); + } + } + } + + Int32 oldval_HP_Max = HP_Max; + Property prop_HP_Max = pdatas[5]; + if(prop_HP_Max.isBase()) + { + if(inited && !inWorld) + onHP_MaxChanged(oldval_HP_Max); + } + else + { + if(inWorld) + { + if(prop_HP_Max.isOwnerOnly() && !isPlayer()) + { + } + else + { + onHP_MaxChanged(oldval_HP_Max); + } + } + } + + Int32 oldval_MP = MP; + Property prop_MP = pdatas[6]; + if(prop_MP.isBase()) + { + if(inited && !inWorld) + onMPChanged(oldval_MP); + } + else + { + if(inWorld) + { + if(prop_MP.isOwnerOnly() && !isPlayer()) + { + } + else + { + onMPChanged(oldval_MP); + } + } + } + + Int32 oldval_MP_Max = MP_Max; + Property prop_MP_Max = pdatas[7]; + if(prop_MP_Max.isBase()) + { + if(inited && !inWorld) + onMP_MaxChanged(oldval_MP_Max); + } + else + { + if(inWorld) + { + if(prop_MP_Max.isOwnerOnly() && !isPlayer()) + { + } + else + { + onMP_MaxChanged(oldval_MP_Max); + } + } + } + + Vector3 oldval_direction = direction; + Property prop_direction = pdatas[2]; + if(prop_direction.isBase()) + { + if(inited && !inWorld) + onDirectionChanged(oldval_direction); + } + else + { + if(inWorld) + { + if(prop_direction.isOwnerOnly() && !isPlayer()) + { + } + else + { + onDirectionChanged(oldval_direction); + } + } + } + + UInt32 oldval_entityNO = entityNO; + Property prop_entityNO = pdatas[8]; + if(prop_entityNO.isBase()) + { + if(inited && !inWorld) + onEntityNOChanged(oldval_entityNO); + } + else + { + if(inWorld) + { + if(prop_entityNO.isOwnerOnly() && !isPlayer()) + { + } + else + { + onEntityNOChanged(oldval_entityNO); + } + } + } + + Int32 oldval_forbids = forbids; + Property prop_forbids = pdatas[9]; + if(prop_forbids.isBase()) + { + if(inited && !inWorld) + onForbidsChanged(oldval_forbids); + } + else + { + if(inWorld) + { + if(prop_forbids.isOwnerOnly() && !isPlayer()) + { + } + else + { + onForbidsChanged(oldval_forbids); + } + } + } + + UInt32 oldval_modelID = modelID; + Property prop_modelID = pdatas[10]; + if(prop_modelID.isBase()) + { + if(inited && !inWorld) + onModelIDChanged(oldval_modelID); + } + else + { + if(inWorld) + { + if(prop_modelID.isOwnerOnly() && !isPlayer()) + { + } + else + { + onModelIDChanged(oldval_modelID); + } + } + } + + Byte oldval_modelScale = modelScale; + Property prop_modelScale = pdatas[11]; + if(prop_modelScale.isBase()) + { + if(inited && !inWorld) + onModelScaleChanged(oldval_modelScale); + } + else + { + if(inWorld) + { + if(prop_modelScale.isOwnerOnly() && !isPlayer()) + { + } + else + { + onModelScaleChanged(oldval_modelScale); + } + } + } + + Byte oldval_moveSpeed = moveSpeed; + Property prop_moveSpeed = pdatas[12]; + if(prop_moveSpeed.isBase()) + { + if(inited && !inWorld) + onMoveSpeedChanged(oldval_moveSpeed); + } + else + { + if(inWorld) + { + if(prop_moveSpeed.isOwnerOnly() && !isPlayer()) + { + } + else + { + onMoveSpeedChanged(oldval_moveSpeed); + } + } + } + + string oldval_name = name; + Property prop_name = pdatas[13]; + if(prop_name.isBase()) + { + if(inited && !inWorld) + onNameChanged(oldval_name); + } + else + { + if(inWorld) + { + if(prop_name.isOwnerOnly() && !isPlayer()) + { + } + else + { + onNameChanged(oldval_name); + } + } + } + + Vector3 oldval_position = position; + Property prop_position = pdatas[1]; + if(prop_position.isBase()) + { + if(inited && !inWorld) + onPositionChanged(oldval_position); + } + else + { + if(inWorld) + { + if(prop_position.isOwnerOnly() && !isPlayer()) + { + } + else + { + onPositionChanged(oldval_position); + } + } + } + + SByte oldval_state = state; + Property prop_state = pdatas[14]; + if(prop_state.isBase()) + { + if(inited && !inWorld) + onStateChanged(oldval_state); + } + else + { + if(inWorld) + { + if(prop_state.isOwnerOnly() && !isPlayer()) + { + } + else + { + onStateChanged(oldval_state); + } + } + } + + Byte oldval_subState = subState; + Property prop_subState = pdatas[15]; + if(prop_subState.isBase()) + { + if(inited && !inWorld) + onSubStateChanged(oldval_subState); + } + else + { + if(inWorld) + { + if(prop_subState.isOwnerOnly() && !isPlayer()) + { + } + else + { + onSubStateChanged(oldval_subState); + } + } + } + + UInt32 oldval_uid = uid; + Property prop_uid = pdatas[16]; + if(prop_uid.isBase()) + { + if(inited && !inWorld) + onUidChanged(oldval_uid); + } + else + { + if(inWorld) + { + if(prop_uid.isOwnerOnly() && !isPlayer()) + { + } + else + { + onUidChanged(oldval_uid); + } + } + } + + UInt32 oldval_utype = utype; + Property prop_utype = pdatas[17]; + if(prop_utype.isBase()) + { + if(inited && !inWorld) + onUtypeChanged(oldval_utype); + } + else + { + if(inWorld) + { + if(prop_utype.isOwnerOnly() && !isPlayer()) + { + } + else + { + onUtypeChanged(oldval_utype); + } + } + } + + } + } } \ No newline at end of file diff --git a/Assets/Plugins/kbengine_unity3d_plugins/NPCBase.cs b/Assets/Plugins/kbengine_unity3d_plugins/NPCBase.cs index 135c352..75f016b 100644 --- a/Assets/Plugins/kbengine_unity3d_plugins/NPCBase.cs +++ b/Assets/Plugins/kbengine_unity3d_plugins/NPCBase.cs @@ -1,525 +1,525 @@ -/* - Generated by KBEngine! - Please do not modify this file! - Please inherit this module, such as: (class NPC : NPCBase) - tools = kbcmd -*/ - -namespace KBEngine -{ - using UnityEngine; - using System; - using System.Collections; - using System.Collections.Generic; - - // defined in */scripts/entity_defs/NPC.def - // Please inherit and implement "class NPC : NPCBase" - public abstract class NPCBase : Entity - { - public EntityBaseEntityCall_NPCBase baseEntityCall = null; - public EntityCellEntityCall_NPCBase cellEntityCall = null; - - public UInt32 entityNO = 0; - public virtual void onEntityNOChanged(UInt32 oldValue) {} - public UInt32 modelID = 0; - public virtual void onModelIDChanged(UInt32 oldValue) {} - public Byte modelScale = 30; - public virtual void onModelScaleChanged(Byte oldValue) {} - public Byte moveSpeed = 50; - public virtual void onMoveSpeedChanged(Byte oldValue) {} - public string name = ""; - public virtual void onNameChanged(string oldValue) {} - public UInt32 uid = 0; - public virtual void onUidChanged(UInt32 oldValue) {} - public UInt32 utype = 0; - public virtual void onUtypeChanged(UInt32 oldValue) {} - - - public NPCBase() - { - } - - public override void onComponentsEnterworld() - { - } - - public override void onComponentsLeaveworld() - { - } - - public override void onGetBase() - { - baseEntityCall = new EntityBaseEntityCall_NPCBase(id, className); - } - - public override void onGetCell() - { - cellEntityCall = new EntityCellEntityCall_NPCBase(id, className); - } - - public override void onLoseCell() - { - cellEntityCall = null; - } - - public override EntityCall getBaseEntityCall() - { - return baseEntityCall; - } - - public override EntityCall getCellEntityCall() - { - return cellEntityCall; - } - - public override void attachComponents() - { - } - - public override void detachComponents() - { - } - - public override void onRemoteMethodCall(MemoryStream stream) - { - ScriptModule sm = EntityDef.moduledefs["NPC"]; - - UInt16 methodUtype = 0; - UInt16 componentPropertyUType = 0; - - if(sm.usePropertyDescrAlias) - { - componentPropertyUType = stream.readUint8(); - } - else - { - componentPropertyUType = stream.readUint16(); - } - - if(sm.useMethodDescrAlias) - { - methodUtype = stream.readUint8(); - } - else - { - methodUtype = stream.readUint16(); - } - - Method method = null; - - if(componentPropertyUType == 0) - { - method = sm.idmethods[methodUtype]; - } - else - { - Property pComponentPropertyDescription = sm.idpropertys[componentPropertyUType]; - switch(pComponentPropertyDescription.properUtype) - { - default: - break; - } - - return; - } - - switch(method.methodUtype) - { - default: - break; - }; - } - - public override void onUpdatePropertys(MemoryStream stream) - { - ScriptModule sm = EntityDef.moduledefs["NPC"]; - Dictionary pdatas = sm.idpropertys; - - while(stream.length() > 0) - { - UInt16 _t_utype = 0; - UInt16 _t_child_utype = 0; - - { - if(sm.usePropertyDescrAlias) - { - _t_utype = stream.readUint8(); - _t_child_utype = stream.readUint8(); - } - else - { - _t_utype = stream.readUint16(); - _t_child_utype = stream.readUint16(); - } - } - - Property prop = null; - - if(_t_utype == 0) - { - prop = pdatas[_t_child_utype]; - } - else - { - Property pComponentPropertyDescription = pdatas[_t_utype]; - switch(pComponentPropertyDescription.properUtype) - { - default: - break; - } - - return; - } - - switch(prop.properUtype) - { - case 40001: - Vector3 oldval_direction = direction; - direction = stream.readVector3(); - - if(prop.isBase()) - { - if(inited) - onDirectionChanged(oldval_direction); - } - else - { - if(inWorld) - onDirectionChanged(oldval_direction); - } - - break; - case 51007: - UInt32 oldval_entityNO = entityNO; - entityNO = stream.readUint32(); - - if(prop.isBase()) - { - if(inited) - onEntityNOChanged(oldval_entityNO); - } - else - { - if(inWorld) - onEntityNOChanged(oldval_entityNO); - } - - break; - case 41006: - UInt32 oldval_modelID = modelID; - modelID = stream.readUint32(); - - if(prop.isBase()) - { - if(inited) - onModelIDChanged(oldval_modelID); - } - else - { - if(inWorld) - onModelIDChanged(oldval_modelID); - } - - break; - case 41007: - Byte oldval_modelScale = modelScale; - modelScale = stream.readUint8(); - - if(prop.isBase()) - { - if(inited) - onModelScaleChanged(oldval_modelScale); - } - else - { - if(inWorld) - onModelScaleChanged(oldval_modelScale); - } - - break; - case 43: - Byte oldval_moveSpeed = moveSpeed; - moveSpeed = stream.readUint8(); - - if(prop.isBase()) - { - if(inited) - onMoveSpeedChanged(oldval_moveSpeed); - } - else - { - if(inWorld) - onMoveSpeedChanged(oldval_moveSpeed); - } - - break; - case 41003: - string oldval_name = name; - name = stream.readUnicode(); - - if(prop.isBase()) - { - if(inited) - onNameChanged(oldval_name); - } - else - { - if(inWorld) - onNameChanged(oldval_name); - } - - break; - case 40000: - Vector3 oldval_position = position; - position = stream.readVector3(); - - if(prop.isBase()) - { - if(inited) - onPositionChanged(oldval_position); - } - else - { - if(inWorld) - onPositionChanged(oldval_position); - } - - break; - case 40002: - stream.readUint32(); - break; - case 41004: - UInt32 oldval_uid = uid; - uid = stream.readUint32(); - - if(prop.isBase()) - { - if(inited) - onUidChanged(oldval_uid); - } - else - { - if(inWorld) - onUidChanged(oldval_uid); - } - - break; - case 41005: - UInt32 oldval_utype = utype; - utype = stream.readUint32(); - - if(prop.isBase()) - { - if(inited) - onUtypeChanged(oldval_utype); - } - else - { - if(inWorld) - onUtypeChanged(oldval_utype); - } - - break; - default: - break; - }; - } - } - - public override void callPropertysSetMethods() - { - ScriptModule sm = EntityDef.moduledefs["NPC"]; - Dictionary pdatas = sm.idpropertys; - - Vector3 oldval_direction = direction; - Property prop_direction = pdatas[2]; - if(prop_direction.isBase()) - { - if(inited && !inWorld) - onDirectionChanged(oldval_direction); - } - else - { - if(inWorld) - { - if(prop_direction.isOwnerOnly() && !isPlayer()) - { - } - else - { - onDirectionChanged(oldval_direction); - } - } - } - - UInt32 oldval_entityNO = entityNO; - Property prop_entityNO = pdatas[4]; - if(prop_entityNO.isBase()) - { - if(inited && !inWorld) - onEntityNOChanged(oldval_entityNO); - } - else - { - if(inWorld) - { - if(prop_entityNO.isOwnerOnly() && !isPlayer()) - { - } - else - { - onEntityNOChanged(oldval_entityNO); - } - } - } - - UInt32 oldval_modelID = modelID; - Property prop_modelID = pdatas[5]; - if(prop_modelID.isBase()) - { - if(inited && !inWorld) - onModelIDChanged(oldval_modelID); - } - else - { - if(inWorld) - { - if(prop_modelID.isOwnerOnly() && !isPlayer()) - { - } - else - { - onModelIDChanged(oldval_modelID); - } - } - } - - Byte oldval_modelScale = modelScale; - Property prop_modelScale = pdatas[6]; - if(prop_modelScale.isBase()) - { - if(inited && !inWorld) - onModelScaleChanged(oldval_modelScale); - } - else - { - if(inWorld) - { - if(prop_modelScale.isOwnerOnly() && !isPlayer()) - { - } - else - { - onModelScaleChanged(oldval_modelScale); - } - } - } - - Byte oldval_moveSpeed = moveSpeed; - Property prop_moveSpeed = pdatas[7]; - if(prop_moveSpeed.isBase()) - { - if(inited && !inWorld) - onMoveSpeedChanged(oldval_moveSpeed); - } - else - { - if(inWorld) - { - if(prop_moveSpeed.isOwnerOnly() && !isPlayer()) - { - } - else - { - onMoveSpeedChanged(oldval_moveSpeed); - } - } - } - - string oldval_name = name; - Property prop_name = pdatas[8]; - if(prop_name.isBase()) - { - if(inited && !inWorld) - onNameChanged(oldval_name); - } - else - { - if(inWorld) - { - if(prop_name.isOwnerOnly() && !isPlayer()) - { - } - else - { - onNameChanged(oldval_name); - } - } - } - - Vector3 oldval_position = position; - Property prop_position = pdatas[1]; - if(prop_position.isBase()) - { - if(inited && !inWorld) - onPositionChanged(oldval_position); - } - else - { - if(inWorld) - { - if(prop_position.isOwnerOnly() && !isPlayer()) - { - } - else - { - onPositionChanged(oldval_position); - } - } - } - - UInt32 oldval_uid = uid; - Property prop_uid = pdatas[9]; - if(prop_uid.isBase()) - { - if(inited && !inWorld) - onUidChanged(oldval_uid); - } - else - { - if(inWorld) - { - if(prop_uid.isOwnerOnly() && !isPlayer()) - { - } - else - { - onUidChanged(oldval_uid); - } - } - } - - UInt32 oldval_utype = utype; - Property prop_utype = pdatas[10]; - if(prop_utype.isBase()) - { - if(inited && !inWorld) - onUtypeChanged(oldval_utype); - } - else - { - if(inWorld) - { - if(prop_utype.isOwnerOnly() && !isPlayer()) - { - } - else - { - onUtypeChanged(oldval_utype); - } - } - } - - } - } +/* + Generated by KBEngine! + Please do not modify this file! + Please inherit this module, such as: (class NPC : NPCBase) + tools = kbcmd +*/ + +namespace KBEngine +{ + using UnityEngine; + using System; + using System.Collections; + using System.Collections.Generic; + + // defined in */scripts/entity_defs/NPC.def + // Please inherit and implement "class NPC : NPCBase" + public abstract class NPCBase : Entity + { + public EntityBaseEntityCall_NPCBase baseEntityCall = null; + public EntityCellEntityCall_NPCBase cellEntityCall = null; + + public UInt32 entityNO = 0; + public virtual void onEntityNOChanged(UInt32 oldValue) {} + public UInt32 modelID = 0; + public virtual void onModelIDChanged(UInt32 oldValue) {} + public Byte modelScale = 30; + public virtual void onModelScaleChanged(Byte oldValue) {} + public Byte moveSpeed = 50; + public virtual void onMoveSpeedChanged(Byte oldValue) {} + public string name = ""; + public virtual void onNameChanged(string oldValue) {} + public UInt32 uid = 0; + public virtual void onUidChanged(UInt32 oldValue) {} + public UInt32 utype = 0; + public virtual void onUtypeChanged(UInt32 oldValue) {} + + + public NPCBase() + { + } + + public override void onComponentsEnterworld() + { + } + + public override void onComponentsLeaveworld() + { + } + + public override void onGetBase() + { + baseEntityCall = new EntityBaseEntityCall_NPCBase(id, className); + } + + public override void onGetCell() + { + cellEntityCall = new EntityCellEntityCall_NPCBase(id, className); + } + + public override void onLoseCell() + { + cellEntityCall = null; + } + + public override EntityCall getBaseEntityCall() + { + return baseEntityCall; + } + + public override EntityCall getCellEntityCall() + { + return cellEntityCall; + } + + public override void attachComponents() + { + } + + public override void detachComponents() + { + } + + public override void onRemoteMethodCall(MemoryStream stream) + { + ScriptModule sm = EntityDef.moduledefs["NPC"]; + + UInt16 methodUtype = 0; + UInt16 componentPropertyUType = 0; + + if(sm.usePropertyDescrAlias) + { + componentPropertyUType = stream.readUint8(); + } + else + { + componentPropertyUType = stream.readUint16(); + } + + if(sm.useMethodDescrAlias) + { + methodUtype = stream.readUint8(); + } + else + { + methodUtype = stream.readUint16(); + } + + Method method = null; + + if(componentPropertyUType == 0) + { + method = sm.idmethods[methodUtype]; + } + else + { + Property pComponentPropertyDescription = sm.idpropertys[componentPropertyUType]; + switch(pComponentPropertyDescription.properUtype) + { + default: + break; + } + + return; + } + + switch(method.methodUtype) + { + default: + break; + }; + } + + public override void onUpdatePropertys(MemoryStream stream) + { + ScriptModule sm = EntityDef.moduledefs["NPC"]; + Dictionary pdatas = sm.idpropertys; + + while(stream.length() > 0) + { + UInt16 _t_utype = 0; + UInt16 _t_child_utype = 0; + + { + if(sm.usePropertyDescrAlias) + { + _t_utype = stream.readUint8(); + _t_child_utype = stream.readUint8(); + } + else + { + _t_utype = stream.readUint16(); + _t_child_utype = stream.readUint16(); + } + } + + Property prop = null; + + if(_t_utype == 0) + { + prop = pdatas[_t_child_utype]; + } + else + { + Property pComponentPropertyDescription = pdatas[_t_utype]; + switch(pComponentPropertyDescription.properUtype) + { + default: + break; + } + + return; + } + + switch(prop.properUtype) + { + case 40001: + Vector3 oldval_direction = direction; + direction = stream.readVector3(); + + if(prop.isBase()) + { + if(inited) + onDirectionChanged(oldval_direction); + } + else + { + if(inWorld) + onDirectionChanged(oldval_direction); + } + + break; + case 51007: + UInt32 oldval_entityNO = entityNO; + entityNO = stream.readUint32(); + + if(prop.isBase()) + { + if(inited) + onEntityNOChanged(oldval_entityNO); + } + else + { + if(inWorld) + onEntityNOChanged(oldval_entityNO); + } + + break; + case 41006: + UInt32 oldval_modelID = modelID; + modelID = stream.readUint32(); + + if(prop.isBase()) + { + if(inited) + onModelIDChanged(oldval_modelID); + } + else + { + if(inWorld) + onModelIDChanged(oldval_modelID); + } + + break; + case 41007: + Byte oldval_modelScale = modelScale; + modelScale = stream.readUint8(); + + if(prop.isBase()) + { + if(inited) + onModelScaleChanged(oldval_modelScale); + } + else + { + if(inWorld) + onModelScaleChanged(oldval_modelScale); + } + + break; + case 43: + Byte oldval_moveSpeed = moveSpeed; + moveSpeed = stream.readUint8(); + + if(prop.isBase()) + { + if(inited) + onMoveSpeedChanged(oldval_moveSpeed); + } + else + { + if(inWorld) + onMoveSpeedChanged(oldval_moveSpeed); + } + + break; + case 41003: + string oldval_name = name; + name = stream.readUnicode(); + + if(prop.isBase()) + { + if(inited) + onNameChanged(oldval_name); + } + else + { + if(inWorld) + onNameChanged(oldval_name); + } + + break; + case 40000: + Vector3 oldval_position = position; + position = stream.readVector3(); + + if(prop.isBase()) + { + if(inited) + onPositionChanged(oldval_position); + } + else + { + if(inWorld) + onPositionChanged(oldval_position); + } + + break; + case 40002: + stream.readUint32(); + break; + case 41004: + UInt32 oldval_uid = uid; + uid = stream.readUint32(); + + if(prop.isBase()) + { + if(inited) + onUidChanged(oldval_uid); + } + else + { + if(inWorld) + onUidChanged(oldval_uid); + } + + break; + case 41005: + UInt32 oldval_utype = utype; + utype = stream.readUint32(); + + if(prop.isBase()) + { + if(inited) + onUtypeChanged(oldval_utype); + } + else + { + if(inWorld) + onUtypeChanged(oldval_utype); + } + + break; + default: + break; + }; + } + } + + public override void callPropertysSetMethods() + { + ScriptModule sm = EntityDef.moduledefs["NPC"]; + Dictionary pdatas = sm.idpropertys; + + Vector3 oldval_direction = direction; + Property prop_direction = pdatas[2]; + if(prop_direction.isBase()) + { + if(inited && !inWorld) + onDirectionChanged(oldval_direction); + } + else + { + if(inWorld) + { + if(prop_direction.isOwnerOnly() && !isPlayer()) + { + } + else + { + onDirectionChanged(oldval_direction); + } + } + } + + UInt32 oldval_entityNO = entityNO; + Property prop_entityNO = pdatas[4]; + if(prop_entityNO.isBase()) + { + if(inited && !inWorld) + onEntityNOChanged(oldval_entityNO); + } + else + { + if(inWorld) + { + if(prop_entityNO.isOwnerOnly() && !isPlayer()) + { + } + else + { + onEntityNOChanged(oldval_entityNO); + } + } + } + + UInt32 oldval_modelID = modelID; + Property prop_modelID = pdatas[5]; + if(prop_modelID.isBase()) + { + if(inited && !inWorld) + onModelIDChanged(oldval_modelID); + } + else + { + if(inWorld) + { + if(prop_modelID.isOwnerOnly() && !isPlayer()) + { + } + else + { + onModelIDChanged(oldval_modelID); + } + } + } + + Byte oldval_modelScale = modelScale; + Property prop_modelScale = pdatas[6]; + if(prop_modelScale.isBase()) + { + if(inited && !inWorld) + onModelScaleChanged(oldval_modelScale); + } + else + { + if(inWorld) + { + if(prop_modelScale.isOwnerOnly() && !isPlayer()) + { + } + else + { + onModelScaleChanged(oldval_modelScale); + } + } + } + + Byte oldval_moveSpeed = moveSpeed; + Property prop_moveSpeed = pdatas[7]; + if(prop_moveSpeed.isBase()) + { + if(inited && !inWorld) + onMoveSpeedChanged(oldval_moveSpeed); + } + else + { + if(inWorld) + { + if(prop_moveSpeed.isOwnerOnly() && !isPlayer()) + { + } + else + { + onMoveSpeedChanged(oldval_moveSpeed); + } + } + } + + string oldval_name = name; + Property prop_name = pdatas[8]; + if(prop_name.isBase()) + { + if(inited && !inWorld) + onNameChanged(oldval_name); + } + else + { + if(inWorld) + { + if(prop_name.isOwnerOnly() && !isPlayer()) + { + } + else + { + onNameChanged(oldval_name); + } + } + } + + Vector3 oldval_position = position; + Property prop_position = pdatas[1]; + if(prop_position.isBase()) + { + if(inited && !inWorld) + onPositionChanged(oldval_position); + } + else + { + if(inWorld) + { + if(prop_position.isOwnerOnly() && !isPlayer()) + { + } + else + { + onPositionChanged(oldval_position); + } + } + } + + UInt32 oldval_uid = uid; + Property prop_uid = pdatas[9]; + if(prop_uid.isBase()) + { + if(inited && !inWorld) + onUidChanged(oldval_uid); + } + else + { + if(inWorld) + { + if(prop_uid.isOwnerOnly() && !isPlayer()) + { + } + else + { + onUidChanged(oldval_uid); + } + } + } + + UInt32 oldval_utype = utype; + Property prop_utype = pdatas[10]; + if(prop_utype.isBase()) + { + if(inited && !inWorld) + onUtypeChanged(oldval_utype); + } + else + { + if(inWorld) + { + if(prop_utype.isOwnerOnly() && !isPlayer()) + { + } + else + { + onUtypeChanged(oldval_utype); + } + } + } + + } + } } \ No newline at end of file diff --git a/Assets/Plugins/kbengine_unity3d_plugins/NetworkInterfaceBase.cs b/Assets/Plugins/kbengine_unity3d_plugins/NetworkInterfaceBase.cs index db41140..2231908 100644 --- a/Assets/Plugins/kbengine_unity3d_plugins/NetworkInterfaceBase.cs +++ b/Assets/Plugins/kbengine_unity3d_plugins/NetworkInterfaceBase.cs @@ -1,267 +1,267 @@ -namespace KBEngine -{ - using UnityEngine; - using System; - using System.Net.Sockets; - using System.Net; - using System.Collections; - using System.Collections.Generic; - using System.Text; - using System.Text.RegularExpressions; - using System.Threading; - using System.Runtime.Remoting.Messaging; - - using MessageID = System.UInt16; - using MessageLength = System.UInt16; - - /// - /// 网络模块 - /// 处理连接、收发数据 - /// - public abstract class NetworkInterfaceBase - { - public const int TCP_PACKET_MAX = 1460; - public const int UDP_PACKET_MAX = 1472; - public const string UDP_HELLO = "62a559f3fa7748bc22f8e0766019d498"; - public const string UDP_HELLO_ACK = "1432ad7c829170a76dd31982c3501eca"; - - public delegate void AsyncConnectMethod(ConnectState state); - public delegate void ConnectCallback(string ip, int port, bool success, object userData); - - protected Socket _socket = null; - protected PacketReceiverBase _packetReceiver = null; - protected PacketSenderBase _packetSender = null; - protected EncryptionFilter _filter = null; - - public bool connected = false; - - public class ConnectState - { - // for connect - public string connectIP = ""; - public int connectPort = 0; - public ConnectCallback connectCB = null; - public object userData = null; - public Socket socket = null; - public NetworkInterfaceBase networkInterface = null; - public string error = ""; - } - - public NetworkInterfaceBase() - { - reset(); - } - - ~NetworkInterfaceBase() - { - Dbg.DEBUG_MSG("NetworkInterfaceBase::~NetworkInterfaceBase(), destructed!!!"); - reset(); - } - - public virtual Socket sock() - { - return _socket; - } - - public virtual void reset() - { - _packetReceiver = null; - _packetSender = null; - _filter = null; - connected = false; - - if(_socket != null) - { - try - { - if(_socket.RemoteEndPoint != null) - Dbg.DEBUG_MSG(string.Format("NetworkInterfaceBase::reset(), close socket from '{0}'", _socket.RemoteEndPoint.ToString())); - } - catch (Exception e) - { - - } - - _socket.Close(0); - _socket = null; - } - } - - - public virtual void close() - { - if(_socket != null) - { - _socket.Close(0); - _socket = null; - Event.fireAll(EventOutTypes.onDisconnected); - } - - _socket = null; - connected = false; - } - - protected abstract PacketReceiverBase createPacketReceiver(); - protected abstract PacketSenderBase createPacketSender(); - protected abstract Socket createSocket(); - protected abstract void onAsyncConnect(ConnectState state); - - public virtual PacketReceiverBase packetReceiver() - { - return _packetReceiver; - } - - public virtual PacketSenderBase PacketSender() - { - return _packetSender; - } - - public virtual bool valid() - { - return ((_socket != null) && (_socket.Connected == true)); - } - - public void _onConnectionState(ConnectState state) - { - KBEngine.Event.deregisterIn(this); - - bool success = (state.error == "" && valid()); - if (success) - { - Dbg.DEBUG_MSG(string.Format("NetworkInterfaceBase::_onConnectionState(), connect to {0}:{1} is success!", state.connectIP, state.connectPort)); - _packetReceiver = createPacketReceiver(); - _packetReceiver.startRecv(); - connected = true; - } - else - { - reset(); - Dbg.ERROR_MSG(string.Format("NetworkInterfaceBase::_onConnectionState(), connect error! ip: {0}:{1}, err: {2}", state.connectIP, state.connectPort, state.error)); - } - - Event.fireAll(EventOutTypes.onConnectionState, success); - - if (state.connectCB != null) - state.connectCB(state.connectIP, state.connectPort, success, state.userData); - } - - private static void connectCB(IAsyncResult ar) - { - ConnectState state = null; - - try - { - // Retrieve the socket from the state object. - state = (ConnectState) ar.AsyncState; - - // Complete the connection. - state.socket.EndConnect(ar); - - Event.fireIn("_onConnectionState", new object[] { state }); - } - catch (Exception e) - { - state.error = e.ToString(); - Event.fireIn("_onConnectionState", new object[] { state }); - } - } - - /// - /// 在非主线程执行:连接服务器 - /// - private void _asyncConnect(ConnectState state) - { - Dbg.DEBUG_MSG(string.Format("NetworkInterfaceBase::_asyncConnect(), will connect to '{0}:{1}' ...", state.connectIP, state.connectPort)); - onAsyncConnect(state); - } - - protected virtual void onAsyncConnectCB(ConnectState state) - { - - } - - /// - /// 在非主线程执行:连接服务器结果回调 - /// - private void _asyncConnectCB(IAsyncResult ar) - { - ConnectState state = (ConnectState)ar.AsyncState; - AsyncResult result = (AsyncResult)ar; - AsyncConnectMethod caller = (AsyncConnectMethod)result.AsyncDelegate; - onAsyncConnectCB(state); - - Dbg.DEBUG_MSG(string.Format("NetworkInterfaceBase::_asyncConnectCB(), connect to '{0}:{1}' finish. error = '{2}'", state.connectIP, state.connectPort, state.error)); - - // Call EndInvoke to retrieve the results. - caller.EndInvoke(ar); - Event.fireIn("_onConnectionState", new object[] { state }); - } - - public void connectTo(string ip, int port, ConnectCallback callback, object userData) - { - if (valid()) - throw new InvalidOperationException("Have already connected!"); - - if (!(new Regex(@"((?:(?:25[0-5]|2[0-4]\d|((1\d{2})|([1-9]?\d)))\.){3}(?:25[0-5]|2[0-4]\d|((1\d{2})|([1-9]?\d))))")).IsMatch(ip)) - { - IPHostEntry ipHost = Dns.GetHostEntry(ip); - ip = ipHost.AddressList[0].ToString(); - } - - _socket = createSocket(); - - ConnectState state = new ConnectState(); - state.connectIP = ip; - state.connectPort = port; - state.connectCB = callback; - state.userData = userData; - state.socket = _socket; - state.networkInterface = this; - - Dbg.DEBUG_MSG("connect to " + ip + ":" + port + " ..."); - connected = false; - - // 先注册一个事件回调,该事件在当前线程触发 - Event.registerIn("_onConnectionState", this, "_onConnectionState"); - - var v = new AsyncConnectMethod(this._asyncConnect); - v.BeginInvoke(state, new AsyncCallback(this._asyncConnectCB), state); - } - - public virtual bool send(MemoryStream stream) - { - if (!valid()) - { - throw new ArgumentException("invalid socket!"); - } - - if (_packetSender == null) - _packetSender = createPacketSender(); - - if (_filter != null) - return _filter.send(_packetSender, stream); - - return _packetSender.send(stream); - } - - public virtual void process() - { - if (!valid()) - return; - - if (_packetReceiver != null) - _packetReceiver.process(); - } - - - public EncryptionFilter fileter() - { - return _filter; - } - - public void setFilter(EncryptionFilter filter) - { - _filter = filter; - } - } -} +namespace KBEngine +{ + using UnityEngine; + using System; + using System.Net.Sockets; + using System.Net; + using System.Collections; + using System.Collections.Generic; + using System.Text; + using System.Text.RegularExpressions; + using System.Threading; + using System.Runtime.Remoting.Messaging; + + using MessageID = System.UInt16; + using MessageLength = System.UInt16; + + /// + /// 网络模块 + /// 处理连接、收发数据 + /// + public abstract class NetworkInterfaceBase + { + public const int TCP_PACKET_MAX = 1460; + public const int UDP_PACKET_MAX = 1472; + public const string UDP_HELLO = "62a559f3fa7748bc22f8e0766019d498"; + public const string UDP_HELLO_ACK = "1432ad7c829170a76dd31982c3501eca"; + + public delegate void AsyncConnectMethod(ConnectState state); + public delegate void ConnectCallback(string ip, int port, bool success, object userData); + + protected Socket _socket = null; + protected PacketReceiverBase _packetReceiver = null; + protected PacketSenderBase _packetSender = null; + protected EncryptionFilter _filter = null; + + public bool connected = false; + + public class ConnectState + { + // for connect + public string connectIP = ""; + public int connectPort = 0; + public ConnectCallback connectCB = null; + public object userData = null; + public Socket socket = null; + public NetworkInterfaceBase networkInterface = null; + public string error = ""; + } + + public NetworkInterfaceBase() + { + reset(); + } + + ~NetworkInterfaceBase() + { + Dbg.DEBUG_MSG("NetworkInterfaceBase::~NetworkInterfaceBase(), destructed!!!"); + reset(); + } + + public virtual Socket sock() + { + return _socket; + } + + public virtual void reset() + { + _packetReceiver = null; + _packetSender = null; + _filter = null; + connected = false; + + if(_socket != null) + { + try + { + if(_socket.RemoteEndPoint != null) + Dbg.DEBUG_MSG(string.Format("NetworkInterfaceBase::reset(), close socket from '{0}'", _socket.RemoteEndPoint.ToString())); + } + catch (Exception e) + { + + } + + _socket.Close(0); + _socket = null; + } + } + + + public virtual void close() + { + if(_socket != null) + { + _socket.Close(0); + _socket = null; + Event.fireAll(EventOutTypes.onDisconnected); + } + + _socket = null; + connected = false; + } + + protected abstract PacketReceiverBase createPacketReceiver(); + protected abstract PacketSenderBase createPacketSender(); + protected abstract Socket createSocket(); + protected abstract void onAsyncConnect(ConnectState state); + + public virtual PacketReceiverBase packetReceiver() + { + return _packetReceiver; + } + + public virtual PacketSenderBase PacketSender() + { + return _packetSender; + } + + public virtual bool valid() + { + return ((_socket != null) && (_socket.Connected == true)); + } + + public void _onConnectionState(ConnectState state) + { + KBEngine.Event.deregisterIn(this); + + bool success = (state.error == "" && valid()); + if (success) + { + Dbg.DEBUG_MSG(string.Format("NetworkInterfaceBase::_onConnectionState(), connect to {0}:{1} is success!", state.connectIP, state.connectPort)); + _packetReceiver = createPacketReceiver(); + _packetReceiver.startRecv(); + connected = true; + } + else + { + reset(); + Dbg.ERROR_MSG(string.Format("NetworkInterfaceBase::_onConnectionState(), connect error! ip: {0}:{1}, err: {2}", state.connectIP, state.connectPort, state.error)); + } + + Event.fireAll(EventOutTypes.onConnectionState, success); + + if (state.connectCB != null) + state.connectCB(state.connectIP, state.connectPort, success, state.userData); + } + + private static void connectCB(IAsyncResult ar) + { + ConnectState state = null; + + try + { + // Retrieve the socket from the state object. + state = (ConnectState) ar.AsyncState; + + // Complete the connection. + state.socket.EndConnect(ar); + + Event.fireIn("_onConnectionState", new object[] { state }); + } + catch (Exception e) + { + state.error = e.ToString(); + Event.fireIn("_onConnectionState", new object[] { state }); + } + } + + /// + /// 在非主线程执行:连接服务器 + /// + private void _asyncConnect(ConnectState state) + { + Dbg.DEBUG_MSG(string.Format("NetworkInterfaceBase::_asyncConnect(), will connect to '{0}:{1}' ...", state.connectIP, state.connectPort)); + onAsyncConnect(state); + } + + protected virtual void onAsyncConnectCB(ConnectState state) + { + + } + + /// + /// 在非主线程执行:连接服务器结果回调 + /// + private void _asyncConnectCB(IAsyncResult ar) + { + ConnectState state = (ConnectState)ar.AsyncState; + AsyncResult result = (AsyncResult)ar; + AsyncConnectMethod caller = (AsyncConnectMethod)result.AsyncDelegate; + onAsyncConnectCB(state); + + Dbg.DEBUG_MSG(string.Format("NetworkInterfaceBase::_asyncConnectCB(), connect to '{0}:{1}' finish. error = '{2}'", state.connectIP, state.connectPort, state.error)); + + // Call EndInvoke to retrieve the results. + caller.EndInvoke(ar); + Event.fireIn("_onConnectionState", new object[] { state }); + } + + public void connectTo(string ip, int port, ConnectCallback callback, object userData) + { + if (valid()) + throw new InvalidOperationException("Have already connected!"); + + if (!(new Regex(@"((?:(?:25[0-5]|2[0-4]\d|((1\d{2})|([1-9]?\d)))\.){3}(?:25[0-5]|2[0-4]\d|((1\d{2})|([1-9]?\d))))")).IsMatch(ip)) + { + IPHostEntry ipHost = Dns.GetHostEntry(ip); + ip = ipHost.AddressList[0].ToString(); + } + + _socket = createSocket(); + + ConnectState state = new ConnectState(); + state.connectIP = ip; + state.connectPort = port; + state.connectCB = callback; + state.userData = userData; + state.socket = _socket; + state.networkInterface = this; + + Dbg.DEBUG_MSG("connect to " + ip + ":" + port + " ..."); + connected = false; + + // 先注册一个事件回调,该事件在当前线程触发 + Event.registerIn("_onConnectionState", this, "_onConnectionState"); + + var v = new AsyncConnectMethod(this._asyncConnect); + v.BeginInvoke(state, new AsyncCallback(this._asyncConnectCB), state); + } + + public virtual bool send(MemoryStream stream) + { + if (!valid()) + { + throw new ArgumentException("invalid socket!"); + } + + if (_packetSender == null) + _packetSender = createPacketSender(); + + if (_filter != null) + return _filter.send(_packetSender, stream); + + return _packetSender.send(stream); + } + + public virtual void process() + { + if (!valid()) + return; + + if (_packetReceiver != null) + _packetReceiver.process(); + } + + + public EncryptionFilter fileter() + { + return _filter; + } + + public void setFilter(EncryptionFilter filter) + { + _filter = filter; + } + } +} diff --git a/Assets/Plugins/kbengine_unity3d_plugins/NetworkInterfaceKCP.cs b/Assets/Plugins/kbengine_unity3d_plugins/NetworkInterfaceKCP.cs index f41b10f..3757687 100644 --- a/Assets/Plugins/kbengine_unity3d_plugins/NetworkInterfaceKCP.cs +++ b/Assets/Plugins/kbengine_unity3d_plugins/NetworkInterfaceKCP.cs @@ -1,219 +1,219 @@ -namespace KBEngine -{ - using UnityEngine; - using System; - using System.Net.Sockets; - using System.Net; - using System.Collections; - using System.Collections.Generic; - using System.Text; - using System.Text.RegularExpressions; - using System.Threading; - using System.Runtime.Remoting.Messaging; - - using MessageID = System.UInt16; - using MessageLength = System.UInt16; - - /// - /// 网络模块 - /// 处理连接、收发数据 - /// - public class NetworkInterfaceKCP : NetworkInterfaceBase - { - private Deps.KCP kcp_ = null; - public UInt32 connID; - public UInt32 nextTickKcpUpdate = 0; - public EndPoint remoteEndPint = null; - - protected override Socket createSocket() - { - Socket pSocket = new Socket(AddressFamily.InterNetwork, SocketType.Dgram, ProtocolType.Udp); - return pSocket; - } - - protected override PacketReceiverBase createPacketReceiver() - { - return new PacketReceiverKCP(this); - } - - protected override PacketSenderBase createPacketSender() - { - return new PacketSenderKCP(this); - } - - public override void reset() - { - finiKCP(); - base.reset(); - } - - public override void close() - { - finiKCP(); - base.close(); - } - - public override bool valid() - { - return ((kcp_ != null) && (_socket != null) && connected); - } - - protected void outputKCP(byte[] data, int size, object userData) - { - if (!valid()) - { - throw new ArgumentException("invalid socket!"); - } - - if (_packetSender == null) - _packetSender = createPacketSender(); - - ((PacketSenderKCP)_packetSender).sendto(data, size); - } - - bool initKCP() - { - kcp_ = new Deps.KCP(connID, this); - kcp_.SetOutput(outputKCP); - - kcp_.SetMTU(1400); - kcp_.WndSize(KBEngineApp.app.getInitArgs().getUDPSendBufferSize(), KBEngineApp.app.getInitArgs().getUDPRecvBufferSize()); - kcp_.NoDelay(1, 10, 2, 1); - kcp_.SetMinRTO(10); - - nextTickKcpUpdate = 0; - return true; - } - - bool finiKCP() - { - if(kcp_ != null) - { - kcp_.SetOutput(null); - kcp_.Release(); - kcp_ = null; - } - - remoteEndPint = null; - connID = 0; - nextTickKcpUpdate = 0; - return true; - } - - public Deps.KCP kcp() - { - return kcp_; - } - - public override bool send(MemoryStream stream) - { - if (!valid()) - { - throw new ArgumentException("invalid socket!"); - } - - if(_filter != null) - { - _filter.encrypt(stream); - } - - nextTickKcpUpdate = 0; - return kcp_.Send(stream.data(), stream.rpos, (int)stream.length()) >= 0; - } - - public override void process() - { - if (!valid()) - return; - - uint current = Deps.KCP.TimeUtils.iclock(); - if(current >= nextTickKcpUpdate) - { - kcp_.Update(current); - nextTickKcpUpdate = kcp_.Check(current); - } - - if (_packetReceiver != null) - _packetReceiver.process(); - } - - protected override void onAsyncConnectCB(ConnectState state) - { - if(state.error.Length > 0 || !initKCP()) - return; - - connected = true; - remoteEndPint = new IPEndPoint(IPAddress.Parse(state.connectIP), state.connectPort); - } - - protected override void onAsyncConnect(ConnectState state) - { - try - { - //state.socket.Connect(state.connectIP, state.connectPort); - - byte[] helloPacket = System.Text.Encoding.ASCII.GetBytes(UDP_HELLO); - state.socket.SendTo(helloPacket, helloPacket.Length, SocketFlags.None, new IPEndPoint(IPAddress.Parse(state.connectIP), state.connectPort)); - - ArrayList readList = new ArrayList(); - readList.Add(state.socket); - Socket.Select(readList, null, null, 3000000); - - if(readList.Count > 0) - { - byte[] buffer = new byte[UDP_PACKET_MAX]; - int length = state.socket.Receive(buffer); - - if (length <= 0) - { - Dbg.ERROR_MSG(string.Format("NetworkInterfaceKCP::_asyncConnect(), failed to connect to '{0}:{1}'! receive hello-ack error!", state.connectIP, state.connectPort)); - state.error = "receive hello-ack error!"; - } - else - { - MemoryStream stream = new MemoryStream(); - Array.Copy(buffer, 0, stream.data(), stream.wpos, length); - stream.wpos = length; - string helloAck = stream.readString(); - string versionString = stream.readString(); - uint conv = stream.readUint32(); - - if (helloAck != UDP_HELLO_ACK) - { - Dbg.ERROR_MSG(string.Format("NetworkInterfaceKCP::_asyncConnect(), failed to connect to '{0}:{1}'! receive hello-ack({2}!={3}) mismatch!", - state.connectIP, state.connectPort, helloAck, UDP_HELLO_ACK)); - - state.error = "hello-ack mismatch!"; - } - else if(KBEngineApp.app.serverVersion != versionString) - { - Dbg.ERROR_MSG(string.Format("NetworkInterfaceKCP::_asyncConnect(), failed to connect to '{0}:{1}'! version({2}!={3}) mismatch!", - state.connectIP, state.connectPort, versionString, KBEngineApp.app.serverVersion)); - - state.error = "version mismatch!"; - } - else if(conv == 0) - { - Dbg.ERROR_MSG(string.Format("NetworkInterfaceKCP::_asyncConnect(), failed to connect to '{0}:{1}'! conv is 0!", - state.connectIP, state.connectPort)); - - state.error = "kcp conv error!"; - } - - ((NetworkInterfaceKCP)state.networkInterface).connID = conv; - } - } - else - { - Dbg.ERROR_MSG(string.Format("NetworkInterfaceKCP::_asyncConnect(), connect to '{0}:{1}' timeout!'", state.connectIP, state.connectPort)); - state.error = "timeout!"; - } - } - catch (Exception e) - { - Dbg.ERROR_MSG(string.Format("NetworkInterfaceKCP::_asyncConnect(), connect to '{0}:{1}' fault! error = '{2}'", state.connectIP, state.connectPort, e)); - state.error = e.ToString(); - } - } - } -} +namespace KBEngine +{ + using UnityEngine; + using System; + using System.Net.Sockets; + using System.Net; + using System.Collections; + using System.Collections.Generic; + using System.Text; + using System.Text.RegularExpressions; + using System.Threading; + using System.Runtime.Remoting.Messaging; + + using MessageID = System.UInt16; + using MessageLength = System.UInt16; + + /// + /// 网络模块 + /// 处理连接、收发数据 + /// + public class NetworkInterfaceKCP : NetworkInterfaceBase + { + private Deps.KCP kcp_ = null; + public UInt32 connID; + public UInt32 nextTickKcpUpdate = 0; + public EndPoint remoteEndPint = null; + + protected override Socket createSocket() + { + Socket pSocket = new Socket(AddressFamily.InterNetwork, SocketType.Dgram, ProtocolType.Udp); + return pSocket; + } + + protected override PacketReceiverBase createPacketReceiver() + { + return new PacketReceiverKCP(this); + } + + protected override PacketSenderBase createPacketSender() + { + return new PacketSenderKCP(this); + } + + public override void reset() + { + finiKCP(); + base.reset(); + } + + public override void close() + { + finiKCP(); + base.close(); + } + + public override bool valid() + { + return ((kcp_ != null) && (_socket != null) && connected); + } + + protected void outputKCP(byte[] data, int size, object userData) + { + if (!valid()) + { + throw new ArgumentException("invalid socket!"); + } + + if (_packetSender == null) + _packetSender = createPacketSender(); + + ((PacketSenderKCP)_packetSender).sendto(data, size); + } + + bool initKCP() + { + kcp_ = new Deps.KCP(connID, this); + kcp_.SetOutput(outputKCP); + + kcp_.SetMTU(1400); + kcp_.WndSize(KBEngineApp.app.getInitArgs().getUDPSendBufferSize(), KBEngineApp.app.getInitArgs().getUDPRecvBufferSize()); + kcp_.NoDelay(1, 10, 2, 1); + kcp_.SetMinRTO(10); + + nextTickKcpUpdate = 0; + return true; + } + + bool finiKCP() + { + if(kcp_ != null) + { + kcp_.SetOutput(null); + kcp_.Release(); + kcp_ = null; + } + + remoteEndPint = null; + connID = 0; + nextTickKcpUpdate = 0; + return true; + } + + public Deps.KCP kcp() + { + return kcp_; + } + + public override bool send(MemoryStream stream) + { + if (!valid()) + { + throw new ArgumentException("invalid socket!"); + } + + if(_filter != null) + { + _filter.encrypt(stream); + } + + nextTickKcpUpdate = 0; + return kcp_.Send(stream.data(), stream.rpos, (int)stream.length()) >= 0; + } + + public override void process() + { + if (!valid()) + return; + + uint current = Deps.KCP.TimeUtils.iclock(); + if(current >= nextTickKcpUpdate) + { + kcp_.Update(current); + nextTickKcpUpdate = kcp_.Check(current); + } + + if (_packetReceiver != null) + _packetReceiver.process(); + } + + protected override void onAsyncConnectCB(ConnectState state) + { + if(state.error.Length > 0 || !initKCP()) + return; + + connected = true; + remoteEndPint = new IPEndPoint(IPAddress.Parse(state.connectIP), state.connectPort); + } + + protected override void onAsyncConnect(ConnectState state) + { + try + { + //state.socket.Connect(state.connectIP, state.connectPort); + + byte[] helloPacket = System.Text.Encoding.ASCII.GetBytes(UDP_HELLO); + state.socket.SendTo(helloPacket, helloPacket.Length, SocketFlags.None, new IPEndPoint(IPAddress.Parse(state.connectIP), state.connectPort)); + + ArrayList readList = new ArrayList(); + readList.Add(state.socket); + Socket.Select(readList, null, null, 3000000); + + if(readList.Count > 0) + { + byte[] buffer = new byte[UDP_PACKET_MAX]; + int length = state.socket.Receive(buffer); + + if (length <= 0) + { + Dbg.ERROR_MSG(string.Format("NetworkInterfaceKCP::_asyncConnect(), failed to connect to '{0}:{1}'! receive hello-ack error!", state.connectIP, state.connectPort)); + state.error = "receive hello-ack error!"; + } + else + { + MemoryStream stream = new MemoryStream(); + Array.Copy(buffer, 0, stream.data(), stream.wpos, length); + stream.wpos = length; + string helloAck = stream.readString(); + string versionString = stream.readString(); + uint conv = stream.readUint32(); + + if (helloAck != UDP_HELLO_ACK) + { + Dbg.ERROR_MSG(string.Format("NetworkInterfaceKCP::_asyncConnect(), failed to connect to '{0}:{1}'! receive hello-ack({2}!={3}) mismatch!", + state.connectIP, state.connectPort, helloAck, UDP_HELLO_ACK)); + + state.error = "hello-ack mismatch!"; + } + else if(KBEngineApp.app.serverVersion != versionString) + { + Dbg.ERROR_MSG(string.Format("NetworkInterfaceKCP::_asyncConnect(), failed to connect to '{0}:{1}'! version({2}!={3}) mismatch!", + state.connectIP, state.connectPort, versionString, KBEngineApp.app.serverVersion)); + + state.error = "version mismatch!"; + } + else if(conv == 0) + { + Dbg.ERROR_MSG(string.Format("NetworkInterfaceKCP::_asyncConnect(), failed to connect to '{0}:{1}'! conv is 0!", + state.connectIP, state.connectPort)); + + state.error = "kcp conv error!"; + } + + ((NetworkInterfaceKCP)state.networkInterface).connID = conv; + } + } + else + { + Dbg.ERROR_MSG(string.Format("NetworkInterfaceKCP::_asyncConnect(), connect to '{0}:{1}' timeout!'", state.connectIP, state.connectPort)); + state.error = "timeout!"; + } + } + catch (Exception e) + { + Dbg.ERROR_MSG(string.Format("NetworkInterfaceKCP::_asyncConnect(), connect to '{0}:{1}' fault! error = '{2}'", state.connectIP, state.connectPort, e)); + state.error = e.ToString(); + } + } + } +} diff --git a/Assets/Plugins/kbengine_unity3d_plugins/NetworkInterfaceTCP.cs b/Assets/Plugins/kbengine_unity3d_plugins/NetworkInterfaceTCP.cs index 3b2f1c6..ae89d85 100644 --- a/Assets/Plugins/kbengine_unity3d_plugins/NetworkInterfaceTCP.cs +++ b/Assets/Plugins/kbengine_unity3d_plugins/NetworkInterfaceTCP.cs @@ -1,62 +1,62 @@ -namespace KBEngine -{ - using UnityEngine; - using System; - using System.Net.Sockets; - using System.Net; - using System.Collections; - using System.Collections.Generic; - using System.Text; - using System.Text.RegularExpressions; - using System.Threading; - using System.Runtime.Remoting.Messaging; - - using MessageID = System.UInt16; - using MessageLength = System.UInt16; - - /// - /// 网络模块 - /// 处理连接、收发数据 - /// - public class NetworkInterfaceTCP : NetworkInterfaceBase - { - public override bool valid() - { - return ((_socket != null) && (_socket.Connected == true)); - } - - protected override Socket createSocket() - { - // Security.PrefetchSocketPolicy(ip, 843); - Socket pSocket = new Socket(AddressFamily.InterNetwork, SocketType.Stream, ProtocolType.Tcp); - pSocket.SetSocketOption(System.Net.Sockets.SocketOptionLevel.Socket, SocketOptionName.ReceiveBuffer, KBEngineApp.app.getInitArgs().getTCPRecvBufferSize() * 2); - pSocket.SetSocketOption(System.Net.Sockets.SocketOptionLevel.Socket, SocketOptionName.SendBuffer, KBEngineApp.app.getInitArgs().getTCPSendBufferSize() * 2); - pSocket.NoDelay = true; - //pSocket.Blocking = false; - return pSocket; - } - - protected override PacketReceiverBase createPacketReceiver() - { - return new PacketReceiverTCP(this); - } - - protected override PacketSenderBase createPacketSender() - { - return new PacketSenderTCP(this); - } - - protected override void onAsyncConnect(ConnectState state) - { - try - { - state.socket.Connect(state.connectIP, state.connectPort); - } - catch (Exception e) - { - Dbg.ERROR_MSG(string.Format("NetworkInterfaceTCP::_asyncConnect(), connect to '{0}:{1}' fault! error = '{2}'", state.connectIP, state.connectPort, e)); - state.error = e.ToString(); - } - } - } -} +namespace KBEngine +{ + using UnityEngine; + using System; + using System.Net.Sockets; + using System.Net; + using System.Collections; + using System.Collections.Generic; + using System.Text; + using System.Text.RegularExpressions; + using System.Threading; + using System.Runtime.Remoting.Messaging; + + using MessageID = System.UInt16; + using MessageLength = System.UInt16; + + /// + /// 网络模块 + /// 处理连接、收发数据 + /// + public class NetworkInterfaceTCP : NetworkInterfaceBase + { + public override bool valid() + { + return ((_socket != null) && (_socket.Connected == true)); + } + + protected override Socket createSocket() + { + // Security.PrefetchSocketPolicy(ip, 843); + Socket pSocket = new Socket(AddressFamily.InterNetwork, SocketType.Stream, ProtocolType.Tcp); + pSocket.SetSocketOption(System.Net.Sockets.SocketOptionLevel.Socket, SocketOptionName.ReceiveBuffer, KBEngineApp.app.getInitArgs().getTCPRecvBufferSize() * 2); + pSocket.SetSocketOption(System.Net.Sockets.SocketOptionLevel.Socket, SocketOptionName.SendBuffer, KBEngineApp.app.getInitArgs().getTCPSendBufferSize() * 2); + pSocket.NoDelay = true; + //pSocket.Blocking = false; + return pSocket; + } + + protected override PacketReceiverBase createPacketReceiver() + { + return new PacketReceiverTCP(this); + } + + protected override PacketSenderBase createPacketSender() + { + return new PacketSenderTCP(this); + } + + protected override void onAsyncConnect(ConnectState state) + { + try + { + state.socket.Connect(state.connectIP, state.connectPort); + } + catch (Exception e) + { + Dbg.ERROR_MSG(string.Format("NetworkInterfaceTCP::_asyncConnect(), connect to '{0}:{1}' fault! error = '{2}'", state.connectIP, state.connectPort, e)); + state.error = e.ToString(); + } + } + } +} diff --git a/Assets/Plugins/kbengine_unity3d_plugins/ObjectPool.cs b/Assets/Plugins/kbengine_unity3d_plugins/ObjectPool.cs index d7c8b06..9d77e7e 100644 --- a/Assets/Plugins/kbengine_unity3d_plugins/ObjectPool.cs +++ b/Assets/Plugins/kbengine_unity3d_plugins/ObjectPool.cs @@ -1,44 +1,44 @@ -using UnityEngine; -using System; -using System.Collections; -using System.Collections.Generic; -using System.Threading; - - -namespace KBEngine -{ - /// - /// 简单的对象池 - /// - /// 对象类型 - public class ObjectPool where T : new() - { - private static Stack _objects = new Stack(); - private static T v; - - public static T createObject() - { - lock (_objects) - { - if (_objects.Count > 0) - { - v = _objects.Pop(); - return v; - } - else - { - return new T(); - } - } - } - - public static void reclaimObject(T item) - { - lock (_objects) - { - _objects.Push(item); - } - } - } - -} +using UnityEngine; +using System; +using System.Collections; +using System.Collections.Generic; +using System.Threading; + + +namespace KBEngine +{ + /// + /// 简单的对象池 + /// + /// 对象类型 + public class ObjectPool where T : new() + { + private static Stack _objects = new Stack(); + private static T v; + + public static T createObject() + { + lock (_objects) + { + if (_objects.Count > 0) + { + v = _objects.Pop(); + return v; + } + else + { + return new T(); + } + } + } + + public static void reclaimObject(T item) + { + lock (_objects) + { + _objects.Push(item); + } + } + } + +} diff --git a/Assets/Plugins/kbengine_unity3d_plugins/PacketReceiverBase.cs b/Assets/Plugins/kbengine_unity3d_plugins/PacketReceiverBase.cs index 604dc75..695b6a0 100644 --- a/Assets/Plugins/kbengine_unity3d_plugins/PacketReceiverBase.cs +++ b/Assets/Plugins/kbengine_unity3d_plugins/PacketReceiverBase.cs @@ -1,57 +1,57 @@ -namespace KBEngine -{ - using System; - using System.Net.Sockets; - using System.Net; - using System.Collections; - using System.Collections.Generic; - using System.Text; - using System.Text.RegularExpressions; - using System.Threading; - using System.Runtime.Remoting.Messaging; - - using MessageID = System.UInt16; - using MessageLength = System.UInt16; - - /* - 包接收模块(与服务端网络部分的名称对应) - 处理网络数据的接收 - */ - public abstract class PacketReceiverBase - { - protected delegate void AsyncReceiveMethod(); - protected MessageReaderBase _messageReader = null; - protected NetworkInterfaceBase _networkInterface = null; - - public PacketReceiverBase(NetworkInterfaceBase networkInterface) - { - _networkInterface = networkInterface; - } - - ~PacketReceiverBase() - { - } - - public NetworkInterfaceBase networkInterface() - { - return _networkInterface; - } - - public abstract void process(); - - public virtual void startRecv() - { - var v = new AsyncReceiveMethod(this._asyncReceive); - v.BeginInvoke(new AsyncCallback(_onRecv), null); - } - - protected abstract void _asyncReceive(); - - private void _onRecv(IAsyncResult ar) - { - AsyncResult result = (AsyncResult)ar; - AsyncReceiveMethod caller = (AsyncReceiveMethod)result.AsyncDelegate; - caller.EndInvoke(ar); - } - } -} +namespace KBEngine +{ + using System; + using System.Net.Sockets; + using System.Net; + using System.Collections; + using System.Collections.Generic; + using System.Text; + using System.Text.RegularExpressions; + using System.Threading; + using System.Runtime.Remoting.Messaging; + + using MessageID = System.UInt16; + using MessageLength = System.UInt16; + + /* + 包接收模块(与服务端网络部分的名称对应) + 处理网络数据的接收 + */ + public abstract class PacketReceiverBase + { + protected delegate void AsyncReceiveMethod(); + protected MessageReaderBase _messageReader = null; + protected NetworkInterfaceBase _networkInterface = null; + + public PacketReceiverBase(NetworkInterfaceBase networkInterface) + { + _networkInterface = networkInterface; + } + + ~PacketReceiverBase() + { + } + + public NetworkInterfaceBase networkInterface() + { + return _networkInterface; + } + + public abstract void process(); + + public virtual void startRecv() + { + var v = new AsyncReceiveMethod(this._asyncReceive); + v.BeginInvoke(new AsyncCallback(_onRecv), null); + } + + protected abstract void _asyncReceive(); + + private void _onRecv(IAsyncResult ar) + { + AsyncResult result = (AsyncResult)ar; + AsyncReceiveMethod caller = (AsyncReceiveMethod)result.AsyncDelegate; + caller.EndInvoke(ar); + } + } +} diff --git a/Assets/Plugins/kbengine_unity3d_plugins/PacketReceiverKCP.cs b/Assets/Plugins/kbengine_unity3d_plugins/PacketReceiverKCP.cs index 2acd5f0..157c26c 100644 --- a/Assets/Plugins/kbengine_unity3d_plugins/PacketReceiverKCP.cs +++ b/Assets/Plugins/kbengine_unity3d_plugins/PacketReceiverKCP.cs @@ -1,102 +1,102 @@ -namespace KBEngine -{ - using System; - using System.Net.Sockets; - using System.Net; - using System.Collections; - using System.Collections.Generic; - using System.Text; - using System.Text.RegularExpressions; - using System.Threading; - using System.Runtime.Remoting.Messaging; - - using MessageID = System.UInt16; - using MessageLength = System.UInt16; - using MessageLengthEx = System.UInt32; - - /* - 包接收模块(与服务端网络部分的名称对应) - 处理网络数据的接收 - */ - public class PacketReceiverKCP : PacketReceiverBase - { - private byte[] _buffer; - private Deps.KCP kcp_ = null; - - public PacketReceiverKCP(NetworkInterfaceBase networkInterface) : base(networkInterface) - { - _buffer = new byte[MessageLength.MaxValue + (Deps.KCP.IKCP_OVERHEAD * 2)]; - _messageReader = new MessageReaderKCP(); - - kcp_ = ((NetworkInterfaceKCP)networkInterface).kcp(); - } - - ~PacketReceiverKCP() - { - kcp_ = null; - Dbg.DEBUG_MSG("PacketReceiverKCP::~PacketReceiverKCP(), destroyed!"); - } - - public override void process() - { - Socket socket = _networkInterface.sock(); - - while (socket.Available > 0) - { - int length = 0; - - try - { - length = socket.Receive(_buffer); - } - catch (Exception e) - { - Dbg.ERROR_MSG("PacketReceiverKCP::process: " + e.ToString()); - Event.fireIn("_closeNetwork", new object[] { _networkInterface }); - return; - } - - if (length <= 0) - { - Dbg.WARNING_MSG("PacketReceiverKCP::_asyncReceive(): KCP Receive <= 0!"); - return; - } - - ((NetworkInterfaceKCP)_networkInterface).nextTickKcpUpdate = 0; - if(kcp_.Input(_buffer, 0, length) < 0) - { - Dbg.WARNING_MSG(string.Format("PacketReceiverKCP::_asyncReceive(): KCP Input get {0}!", length)); - return; - } - - while (true) - { - length = kcp_.Recv(_buffer, 0, _buffer.Length); - if (length < 0) - { - break; - } - - if (_networkInterface.fileter() != null) - { - _networkInterface.fileter().recv(_messageReader, _buffer, 0, (MessageLengthEx)length); - } - else - { - _messageReader.process(_buffer, 0, (MessageLengthEx)length); - } - } - } - } - - public override void startRecv() - { - //var v = new AsyncReceiveMethod(this._asyncReceive); - //v.BeginInvoke(new AsyncCallback(_onRecv), null); - } - - protected override void _asyncReceive() - { - } - } -} +namespace KBEngine +{ + using System; + using System.Net.Sockets; + using System.Net; + using System.Collections; + using System.Collections.Generic; + using System.Text; + using System.Text.RegularExpressions; + using System.Threading; + using System.Runtime.Remoting.Messaging; + + using MessageID = System.UInt16; + using MessageLength = System.UInt16; + using MessageLengthEx = System.UInt32; + + /* + 包接收模块(与服务端网络部分的名称对应) + 处理网络数据的接收 + */ + public class PacketReceiverKCP : PacketReceiverBase + { + private byte[] _buffer; + private Deps.KCP kcp_ = null; + + public PacketReceiverKCP(NetworkInterfaceBase networkInterface) : base(networkInterface) + { + _buffer = new byte[MessageLength.MaxValue + (Deps.KCP.IKCP_OVERHEAD * 2)]; + _messageReader = new MessageReaderKCP(); + + kcp_ = ((NetworkInterfaceKCP)networkInterface).kcp(); + } + + ~PacketReceiverKCP() + { + kcp_ = null; + Dbg.DEBUG_MSG("PacketReceiverKCP::~PacketReceiverKCP(), destroyed!"); + } + + public override void process() + { + Socket socket = _networkInterface.sock(); + + while (socket.Available > 0) + { + int length = 0; + + try + { + length = socket.Receive(_buffer); + } + catch (Exception e) + { + Dbg.ERROR_MSG("PacketReceiverKCP::process: " + e.ToString()); + Event.fireIn("_closeNetwork", new object[] { _networkInterface }); + return; + } + + if (length <= 0) + { + Dbg.WARNING_MSG("PacketReceiverKCP::_asyncReceive(): KCP Receive <= 0!"); + return; + } + + ((NetworkInterfaceKCP)_networkInterface).nextTickKcpUpdate = 0; + if(kcp_.Input(_buffer, 0, length) < 0) + { + Dbg.WARNING_MSG(string.Format("PacketReceiverKCP::_asyncReceive(): KCP Input get {0}!", length)); + return; + } + + while (true) + { + length = kcp_.Recv(_buffer, 0, _buffer.Length); + if (length < 0) + { + break; + } + + if (_networkInterface.fileter() != null) + { + _networkInterface.fileter().recv(_messageReader, _buffer, 0, (MessageLengthEx)length); + } + else + { + _messageReader.process(_buffer, 0, (MessageLengthEx)length); + } + } + } + } + + public override void startRecv() + { + //var v = new AsyncReceiveMethod(this._asyncReceive); + //v.BeginInvoke(new AsyncCallback(_onRecv), null); + } + + protected override void _asyncReceive() + { + } + } +} diff --git a/Assets/Plugins/kbengine_unity3d_plugins/PacketReceiverTCP.cs b/Assets/Plugins/kbengine_unity3d_plugins/PacketReceiverTCP.cs index e942a7b..b4d0e38 100644 --- a/Assets/Plugins/kbengine_unity3d_plugins/PacketReceiverTCP.cs +++ b/Assets/Plugins/kbengine_unity3d_plugins/PacketReceiverTCP.cs @@ -1,162 +1,162 @@ -namespace KBEngine -{ - using System; - using System.Net.Sockets; - using System.Net; - using System.Collections; - using System.Collections.Generic; - using System.Text; - using System.Text.RegularExpressions; - using System.Threading; - using System.Runtime.Remoting.Messaging; - - using MessageID = System.UInt16; - using MessageLength = System.UInt16; - - /* - 包接收模块(与服务端网络部分的名称对应) - 处理网络数据的接收 - */ - public class PacketReceiverTCP : PacketReceiverBase - { - private byte[] _buffer; - - // socket向缓冲区写的起始位置 - int _wpos = 0; - - // 主线程读取数据的起始位置 - int _rpos = 0; - - public PacketReceiverTCP(NetworkInterfaceBase networkInterface) : base(networkInterface) - { - _buffer = new byte[KBEngineApp.app.getInitArgs().TCP_RECV_BUFFER_MAX]; - _messageReader = new MessageReaderTCP(); - } - - ~PacketReceiverTCP() - { - Dbg.DEBUG_MSG("PacketReceiverTCP::~PacketReceiverTCP(), destroyed!"); - } - - public override void process() - { - int t_wpos = Interlocked.Add(ref _wpos, 0); - - if (_rpos < t_wpos) - { - if (_networkInterface.fileter() != null) - { - _networkInterface.fileter().recv(_messageReader, _buffer, (UInt32)_rpos, (UInt32)(t_wpos - _rpos)); - } - else - { - _messageReader.process(_buffer, (UInt32)_rpos, (UInt32)(t_wpos - _rpos)); - } - - Interlocked.Exchange(ref _rpos, t_wpos); - } - else if (t_wpos < _rpos) - { - if (_networkInterface.fileter() != null) - { - _networkInterface.fileter().recv(_messageReader, _buffer, (UInt32)_rpos, (UInt32)(_buffer.Length - _rpos)); - _networkInterface.fileter().recv(_messageReader, _buffer, (UInt32)0, (UInt32)t_wpos); - } - else - { - _messageReader.process(_buffer, (UInt32)_rpos, (UInt32)(_buffer.Length - _rpos)); - _messageReader.process(_buffer, (UInt32)0, (UInt32)t_wpos); - } - - Interlocked.Exchange(ref _rpos, t_wpos); - } - else - { - // 没有可读数据 - } - } - - int _free() - { - int t_rpos = Interlocked.Add(ref _rpos, 0); - - if (_wpos == _buffer.Length) - { - if (t_rpos == 0) - { - return 0; - } - - Interlocked.Exchange(ref _wpos, 0); - } - - if (t_rpos <= _wpos) - { - return _buffer.Length - _wpos; - } - - return t_rpos - _wpos - 1; - } - - protected override void _asyncReceive() - { - if (_networkInterface == null || !_networkInterface.valid()) - { - Dbg.WARNING_MSG("PacketReceiverTCP::_asyncReceive(): network interface invalid!"); - return; - } - - var socket = _networkInterface.sock(); - - while (true) - { - // 必须有空间可写,否则我们阻塞在线程中直到有空间为止 - int first = 0; - int space = _free(); - - while (space == 0) - { - if (first > 0) - { - if (first > 1000) - { - Dbg.ERROR_MSG("PacketReceiverTCP::_asyncReceive(): no space!"); - Event.fireIn("_closeNetwork", new object[] { _networkInterface }); - return; - } - - Dbg.WARNING_MSG("PacketReceiverTCP::_asyncReceive(): waiting for space, Please adjust 'RECV_BUFFER_MAX'! retries=" + first); - System.Threading.Thread.Sleep(5); - } - - first += 1; - space = _free(); - } - - int bytesRead = 0; - try - { - bytesRead = socket.Receive(_buffer, _wpos, space, 0); - } - catch (SocketException se) - { - Dbg.ERROR_MSG(string.Format("PacketReceiverTCP::_asyncReceive(): receive error, disconnect from '{0}'! error = '{1}'", socket.RemoteEndPoint, se)); - Event.fireIn("_closeNetwork", new object[] { _networkInterface }); - return; - } - - if (bytesRead > 0) - { - // 更新写位置 - Interlocked.Add(ref _wpos, bytesRead); - } - else - { - Dbg.WARNING_MSG(string.Format("PacketReceiverTCP::_asyncReceive(): receive 0 bytes, disconnect from '{0}'!", socket.RemoteEndPoint)); - Event.fireIn("_closeNetwork", new object[] { _networkInterface }); - return; - } - } - } - } -} +namespace KBEngine +{ + using System; + using System.Net.Sockets; + using System.Net; + using System.Collections; + using System.Collections.Generic; + using System.Text; + using System.Text.RegularExpressions; + using System.Threading; + using System.Runtime.Remoting.Messaging; + + using MessageID = System.UInt16; + using MessageLength = System.UInt16; + + /* + 包接收模块(与服务端网络部分的名称对应) + 处理网络数据的接收 + */ + public class PacketReceiverTCP : PacketReceiverBase + { + private byte[] _buffer; + + // socket向缓冲区写的起始位置 + int _wpos = 0; + + // 主线程读取数据的起始位置 + int _rpos = 0; + + public PacketReceiverTCP(NetworkInterfaceBase networkInterface) : base(networkInterface) + { + _buffer = new byte[KBEngineApp.app.getInitArgs().TCP_RECV_BUFFER_MAX]; + _messageReader = new MessageReaderTCP(); + } + + ~PacketReceiverTCP() + { + Dbg.DEBUG_MSG("PacketReceiverTCP::~PacketReceiverTCP(), destroyed!"); + } + + public override void process() + { + int t_wpos = Interlocked.Add(ref _wpos, 0); + + if (_rpos < t_wpos) + { + if (_networkInterface.fileter() != null) + { + _networkInterface.fileter().recv(_messageReader, _buffer, (UInt32)_rpos, (UInt32)(t_wpos - _rpos)); + } + else + { + _messageReader.process(_buffer, (UInt32)_rpos, (UInt32)(t_wpos - _rpos)); + } + + Interlocked.Exchange(ref _rpos, t_wpos); + } + else if (t_wpos < _rpos) + { + if (_networkInterface.fileter() != null) + { + _networkInterface.fileter().recv(_messageReader, _buffer, (UInt32)_rpos, (UInt32)(_buffer.Length - _rpos)); + _networkInterface.fileter().recv(_messageReader, _buffer, (UInt32)0, (UInt32)t_wpos); + } + else + { + _messageReader.process(_buffer, (UInt32)_rpos, (UInt32)(_buffer.Length - _rpos)); + _messageReader.process(_buffer, (UInt32)0, (UInt32)t_wpos); + } + + Interlocked.Exchange(ref _rpos, t_wpos); + } + else + { + // 没有可读数据 + } + } + + int _free() + { + int t_rpos = Interlocked.Add(ref _rpos, 0); + + if (_wpos == _buffer.Length) + { + if (t_rpos == 0) + { + return 0; + } + + Interlocked.Exchange(ref _wpos, 0); + } + + if (t_rpos <= _wpos) + { + return _buffer.Length - _wpos; + } + + return t_rpos - _wpos - 1; + } + + protected override void _asyncReceive() + { + if (_networkInterface == null || !_networkInterface.valid()) + { + Dbg.WARNING_MSG("PacketReceiverTCP::_asyncReceive(): network interface invalid!"); + return; + } + + var socket = _networkInterface.sock(); + + while (true) + { + // 必须有空间可写,否则我们阻塞在线程中直到有空间为止 + int first = 0; + int space = _free(); + + while (space == 0) + { + if (first > 0) + { + if (first > 1000) + { + Dbg.ERROR_MSG("PacketReceiverTCP::_asyncReceive(): no space!"); + Event.fireIn("_closeNetwork", new object[] { _networkInterface }); + return; + } + + Dbg.WARNING_MSG("PacketReceiverTCP::_asyncReceive(): waiting for space, Please adjust 'RECV_BUFFER_MAX'! retries=" + first); + System.Threading.Thread.Sleep(5); + } + + first += 1; + space = _free(); + } + + int bytesRead = 0; + try + { + bytesRead = socket.Receive(_buffer, _wpos, space, 0); + } + catch (SocketException se) + { + Dbg.ERROR_MSG(string.Format("PacketReceiverTCP::_asyncReceive(): receive error, disconnect from '{0}'! error = '{1}'", socket.RemoteEndPoint, se)); + Event.fireIn("_closeNetwork", new object[] { _networkInterface }); + return; + } + + if (bytesRead > 0) + { + // 更新写位置 + Interlocked.Add(ref _wpos, bytesRead); + } + else + { + Dbg.WARNING_MSG(string.Format("PacketReceiverTCP::_asyncReceive(): receive 0 bytes, disconnect from '{0}'!", socket.RemoteEndPoint)); + Event.fireIn("_closeNetwork", new object[] { _networkInterface }); + return; + } + } + } + } +} diff --git a/Assets/Plugins/kbengine_unity3d_plugins/PacketSenderBase.cs b/Assets/Plugins/kbengine_unity3d_plugins/PacketSenderBase.cs index b51777e..15e48ba 100644 --- a/Assets/Plugins/kbengine_unity3d_plugins/PacketSenderBase.cs +++ b/Assets/Plugins/kbengine_unity3d_plugins/PacketSenderBase.cs @@ -1,62 +1,62 @@ -namespace KBEngine -{ - using System; - using System.Net.Sockets; - using System.Net; - using System.Collections; - using System.Collections.Generic; - using System.Text; - using System.Text.RegularExpressions; - using System.Threading; - using System.Runtime.Remoting.Messaging; - - using MessageID = System.UInt16; - using MessageLength = System.UInt16; - - /* - 包发送模块(与服务端网络部分的名称对应) - 处理网络数据的发送 - */ - public abstract class PacketSenderBase - { - public delegate void AsyncSendMethod(); - - protected NetworkInterfaceBase _networkInterface = null; - AsyncCallback _asyncCallback = null; - AsyncSendMethod _asyncSendMethod; - - public PacketSenderBase(NetworkInterfaceBase networkInterface) - { - _networkInterface = networkInterface; - _asyncSendMethod = new AsyncSendMethod(this._asyncSend); - _asyncCallback = new AsyncCallback(_onSent); - } - - ~PacketSenderBase() - { - } - - public NetworkInterfaceBase networkInterface() - { - return _networkInterface; - } - - public abstract bool send(MemoryStream stream); - - protected void _startSend() - { - // 由于socket用的是非阻塞式,因此在这里不能直接使用socket.send()方法 - // 必须放到另一个线程中去做 - _asyncSendMethod.BeginInvoke(_asyncCallback, null); - } - - protected abstract void _asyncSend(); - - protected static void _onSent(IAsyncResult ar) - { - AsyncResult result = (AsyncResult)ar; - AsyncSendMethod caller = (AsyncSendMethod)result.AsyncDelegate; - caller.EndInvoke(ar); - } - } -} +namespace KBEngine +{ + using System; + using System.Net.Sockets; + using System.Net; + using System.Collections; + using System.Collections.Generic; + using System.Text; + using System.Text.RegularExpressions; + using System.Threading; + using System.Runtime.Remoting.Messaging; + + using MessageID = System.UInt16; + using MessageLength = System.UInt16; + + /* + 包发送模块(与服务端网络部分的名称对应) + 处理网络数据的发送 + */ + public abstract class PacketSenderBase + { + public delegate void AsyncSendMethod(); + + protected NetworkInterfaceBase _networkInterface = null; + AsyncCallback _asyncCallback = null; + AsyncSendMethod _asyncSendMethod; + + public PacketSenderBase(NetworkInterfaceBase networkInterface) + { + _networkInterface = networkInterface; + _asyncSendMethod = new AsyncSendMethod(this._asyncSend); + _asyncCallback = new AsyncCallback(_onSent); + } + + ~PacketSenderBase() + { + } + + public NetworkInterfaceBase networkInterface() + { + return _networkInterface; + } + + public abstract bool send(MemoryStream stream); + + protected void _startSend() + { + // 由于socket用的是非阻塞式,因此在这里不能直接使用socket.send()方法 + // 必须放到另一个线程中去做 + _asyncSendMethod.BeginInvoke(_asyncCallback, null); + } + + protected abstract void _asyncSend(); + + protected static void _onSent(IAsyncResult ar) + { + AsyncResult result = (AsyncResult)ar; + AsyncSendMethod caller = (AsyncSendMethod)result.AsyncDelegate; + caller.EndInvoke(ar); + } + } +} diff --git a/Assets/Plugins/kbengine_unity3d_plugins/PacketSenderKCP.cs b/Assets/Plugins/kbengine_unity3d_plugins/PacketSenderKCP.cs index f49ee45..28f0839 100644 --- a/Assets/Plugins/kbengine_unity3d_plugins/PacketSenderKCP.cs +++ b/Assets/Plugins/kbengine_unity3d_plugins/PacketSenderKCP.cs @@ -1,78 +1,78 @@ -namespace KBEngine -{ - using System; - using System.Net.Sockets; - using System.Net; - using System.Collections; - using System.Collections.Generic; - using System.Text; - using System.Text.RegularExpressions; - using System.Threading; - using System.Runtime.Remoting.Messaging; - - using MessageID = System.UInt16; - using MessageLength = System.UInt16; - - /* - 包发送模块(与服务端网络部分的名称对应) - 处理网络数据的发送 - */ - public class PacketSenderKCP : PacketSenderBase - { - Socket socket_; - EndPoint remoteEndPint_; - - public PacketSenderKCP(NetworkInterfaceBase networkInterface) : base(networkInterface) - { - socket_ = _networkInterface.sock(); - remoteEndPint_ = ((NetworkInterfaceKCP)_networkInterface).remoteEndPint; - } - - ~PacketSenderKCP() - { - Dbg.DEBUG_MSG("PacketSenderKCP::~PacketSenderKCP(), destroyed!"); - } - - public override bool send(MemoryStream stream) - { - //MemoryStream udpPacket = MemoryStream.createObject(); - //udpPacket.swap(stream); - return true; - } - - public bool sendto(byte[] packet, int size) - { - try - { - socket_.SendTo(packet, size, SocketFlags.None, remoteEndPint_); - } - catch (SocketException se) - { - Dbg.ERROR_MSG(string.Format("PacketSenderKCP::sendto(): send data error, disconnect from '{0}'! error = '{1}'", socket_.RemoteEndPoint, se)); - Event.fireIn("_closeNetwork", new object[] { _networkInterface }); - return false; - } - - return true; - } - - protected override void _asyncSend() - { - /* - if (_networkInterface == null || !_networkInterface.valid()) - { - Dbg.WARNING_MSG("PacketSenderKCP::_asyncSend(): network interface invalid!"); - return; - } - - var socket = _networkInterface.sock(); - EndPoint remoteEndPint = ((NetworkInterfaceKCP)_networkInterface).remoteEndPint; - - while (true) - { - socket.SendTo(data, size, SocketFlags.None, remoteEndPint); - } - */ - } - } -} +namespace KBEngine +{ + using System; + using System.Net.Sockets; + using System.Net; + using System.Collections; + using System.Collections.Generic; + using System.Text; + using System.Text.RegularExpressions; + using System.Threading; + using System.Runtime.Remoting.Messaging; + + using MessageID = System.UInt16; + using MessageLength = System.UInt16; + + /* + 包发送模块(与服务端网络部分的名称对应) + 处理网络数据的发送 + */ + public class PacketSenderKCP : PacketSenderBase + { + Socket socket_; + EndPoint remoteEndPint_; + + public PacketSenderKCP(NetworkInterfaceBase networkInterface) : base(networkInterface) + { + socket_ = _networkInterface.sock(); + remoteEndPint_ = ((NetworkInterfaceKCP)_networkInterface).remoteEndPint; + } + + ~PacketSenderKCP() + { + Dbg.DEBUG_MSG("PacketSenderKCP::~PacketSenderKCP(), destroyed!"); + } + + public override bool send(MemoryStream stream) + { + //MemoryStream udpPacket = MemoryStream.createObject(); + //udpPacket.swap(stream); + return true; + } + + public bool sendto(byte[] packet, int size) + { + try + { + socket_.SendTo(packet, size, SocketFlags.None, remoteEndPint_); + } + catch (SocketException se) + { + Dbg.ERROR_MSG(string.Format("PacketSenderKCP::sendto(): send data error, disconnect from '{0}'! error = '{1}'", socket_.RemoteEndPoint, se)); + Event.fireIn("_closeNetwork", new object[] { _networkInterface }); + return false; + } + + return true; + } + + protected override void _asyncSend() + { + /* + if (_networkInterface == null || !_networkInterface.valid()) + { + Dbg.WARNING_MSG("PacketSenderKCP::_asyncSend(): network interface invalid!"); + return; + } + + var socket = _networkInterface.sock(); + EndPoint remoteEndPint = ((NetworkInterfaceKCP)_networkInterface).remoteEndPint; + + while (true) + { + socket.SendTo(data, size, SocketFlags.None, remoteEndPint); + } + */ + } + } +} diff --git a/Assets/Plugins/kbengine_unity3d_plugins/PacketSenderTCP.cs b/Assets/Plugins/kbengine_unity3d_plugins/PacketSenderTCP.cs index 7f7cf62..3ac513f 100644 --- a/Assets/Plugins/kbengine_unity3d_plugins/PacketSenderTCP.cs +++ b/Assets/Plugins/kbengine_unity3d_plugins/PacketSenderTCP.cs @@ -17,22 +17,24 @@ 包发送模块(与服务端网络部分的名称对应) 处理网络数据的发送 */ - public class PacketSenderTCP : PacketSenderBase - { + public class PacketSenderTCP : PacketSenderBase + { private byte[] _buffer; int _wpos = 0; // 写入的数据位置 int _spos = 0; // 发送完毕的数据位置 - int _sending = 0; + + object _sendingObj = new object(); + Boolean _sending = false; - public PacketSenderTCP(NetworkInterfaceBase networkInterface) : base(networkInterface) - { - _buffer = new byte[KBEngineApp.app.getInitArgs().TCP_SEND_BUFFER_MAX]; + public PacketSenderTCP(NetworkInterfaceBase networkInterface) : base(networkInterface) + { + _buffer = new byte[KBEngineApp.app.getInitArgs().TCP_SEND_BUFFER_MAX]; _wpos = 0; _spos = 0; - _sending = 0; - } + _sending = false; + } ~PacketSenderTCP() { @@ -45,7 +47,8 @@ public override bool send(MemoryStream stream) if (dataLength <= 0) return true; - if (0 == Interlocked.Add(ref _sending, 0)) + Monitor.Enter(_sendingObj); + if (!_sending) { if (_wpos == _spos) { @@ -54,7 +57,7 @@ public override bool send(MemoryStream stream) } } - int t_spos = Interlocked.Add(ref _spos, 0); + int t_spos =_spos; int space = 0; int tt_wpos = _wpos % _buffer.Length; int tt_spos = t_spos % _buffer.Length; @@ -84,12 +87,19 @@ public override bool send(MemoryStream stream) Array.Copy(stream.data(), stream.rpos + remain, _buffer, 0, expect_total - _buffer.Length); } - Interlocked.Add(ref _wpos, dataLength); + _wpos += dataLength; - if (Interlocked.CompareExchange(ref _sending, 1, 0) == 0) + if (!_sending) { + _sending = true; + Monitor.Exit(_sendingObj); + _startSend(); } + else + { + Monitor.Exit(_sendingObj); + } return true; } @@ -106,7 +116,9 @@ protected override void _asyncSend() while (true) { - int sendSize = Interlocked.Add(ref _wpos, 0) - _spos; + Monitor.Enter(_sendingObj); + + int sendSize = _wpos - _spos; int t_spos = _spos % _buffer.Length; if (t_spos == 0) t_spos = sendSize; @@ -123,17 +135,22 @@ protected override void _asyncSend() { Dbg.ERROR_MSG(string.Format("PacketSenderTCP::_asyncSend(): send data error, disconnect from '{0}'! error = '{1}'", socket.RemoteEndPoint, se)); Event.fireIn("_closeNetwork", new object[] { _networkInterface }); + + Monitor.Exit(_sendingObj); return; } - int spos = Interlocked.Add(ref _spos, bytesSent); + _spos += bytesSent; // 所有数据发送完毕了 - if (spos == Interlocked.Add(ref _wpos, 0)) + if (_spos == _wpos) { - Interlocked.Exchange(ref _sending, 0); + _sending = false; + Monitor.Exit(_sendingObj); return; } + + Monitor.Exit(_sendingObj); } } } diff --git a/Assets/Plugins/kbengine_unity3d_plugins/Profile.cs b/Assets/Plugins/kbengine_unity3d_plugins/Profile.cs index 243a760..9f2e417 100644 --- a/Assets/Plugins/kbengine_unity3d_plugins/Profile.cs +++ b/Assets/Plugins/kbengine_unity3d_plugins/Profile.cs @@ -1,39 +1,39 @@ -using System; -using System.Net.Sockets; -using System.Net; -using System.Collections; -using System.Collections.Generic; -using System.Text; -using System.Text.RegularExpressions; -using System.Threading; - -namespace KBEngine -{ - public class Profile - { - System.DateTime startTime; - string _name = ""; - - public Profile(string name) - { - _name = name; - } - - ~Profile() - { - } - - public void start() - { - startTime = System.DateTime.Now; - } - - public void end() - { - System.TimeSpan time = System.DateTime.Now - startTime; - - if(time.TotalMilliseconds >= 100) - Dbg.WARNING_MSG("Profile::profile(): '" + _name + "' took " + time.TotalMilliseconds + " ms"); - } - } -} +using System; +using System.Net.Sockets; +using System.Net; +using System.Collections; +using System.Collections.Generic; +using System.Text; +using System.Text.RegularExpressions; +using System.Threading; + +namespace KBEngine +{ + public class Profile + { + System.DateTime startTime; + string _name = ""; + + public Profile(string name) + { + _name = name; + } + + ~Profile() + { + } + + public void start() + { + startTime = System.DateTime.Now; + } + + public void end() + { + System.TimeSpan time = System.DateTime.Now - startTime; + + if(time.TotalMilliseconds >= 100) + Dbg.WARNING_MSG("Profile::profile(): '" + _name + "' took " + time.TotalMilliseconds + " ms"); + } + } +} diff --git a/Assets/Plugins/kbengine_unity3d_plugins/Property.cs b/Assets/Plugins/kbengine_unity3d_plugins/Property.cs index 199baef..499781d 100644 --- a/Assets/Plugins/kbengine_unity3d_plugins/Property.cs +++ b/Assets/Plugins/kbengine_unity3d_plugins/Property.cs @@ -1,55 +1,55 @@ -namespace KBEngine -{ - using UnityEngine; - using System; - - /* - 抽象出一个entitydef中定义的属性 - 该模块描述了属性的id以及数据类型等信息 - */ - public class Property - { - public enum EntityDataFlags - { - ED_FLAG_UNKOWN = 0x00000000, // 未定义 - ED_FLAG_CELL_PUBLIC = 0x00000001, // 相关所有cell广播 - ED_FLAG_CELL_PRIVATE = 0x00000002, // 当前cell - ED_FLAG_ALL_CLIENTS = 0x00000004, // cell广播与所有客户端 - ED_FLAG_CELL_PUBLIC_AND_OWN = 0x00000008, // cell广播与自己的客户端 - ED_FLAG_OWN_CLIENT = 0x00000010, // 当前cell和客户端 - ED_FLAG_BASE_AND_CLIENT = 0x00000020, // base和客户端 - ED_FLAG_BASE = 0x00000040, // 当前base - ED_FLAG_OTHER_CLIENTS = 0x00000080, // cell广播和其他客户端 - }; - - public string name = ""; - public UInt16 properUtype = 0; - public UInt32 properFlags = 0; - public Int16 aliasID = -1; - public object defaultVal = null; - - public Property() - { - - } - - public bool isBase() - { - return properFlags == (UInt32)EntityDataFlags.ED_FLAG_BASE_AND_CLIENT || - properFlags == (UInt32)EntityDataFlags.ED_FLAG_BASE; - } - - public bool isOwnerOnly() - { - return properFlags == (UInt32)EntityDataFlags.ED_FLAG_CELL_PUBLIC_AND_OWN || - properFlags == (UInt32)EntityDataFlags.ED_FLAG_OWN_CLIENT; - } - - public bool isOtherOnly() - { - return properFlags == (UInt32)EntityDataFlags.ED_FLAG_OTHER_CLIENTS || - properFlags == (UInt32)EntityDataFlags.ED_FLAG_OTHER_CLIENTS; - } - } - -} +namespace KBEngine +{ + using UnityEngine; + using System; + + /* + 抽象出一个entitydef中定义的属性 + 该模块描述了属性的id以及数据类型等信息 + */ + public class Property + { + public enum EntityDataFlags + { + ED_FLAG_UNKOWN = 0x00000000, // 未定义 + ED_FLAG_CELL_PUBLIC = 0x00000001, // 相关所有cell广播 + ED_FLAG_CELL_PRIVATE = 0x00000002, // 当前cell + ED_FLAG_ALL_CLIENTS = 0x00000004, // cell广播与所有客户端 + ED_FLAG_CELL_PUBLIC_AND_OWN = 0x00000008, // cell广播与自己的客户端 + ED_FLAG_OWN_CLIENT = 0x00000010, // 当前cell和客户端 + ED_FLAG_BASE_AND_CLIENT = 0x00000020, // base和客户端 + ED_FLAG_BASE = 0x00000040, // 当前base + ED_FLAG_OTHER_CLIENTS = 0x00000080, // cell广播和其他客户端 + }; + + public string name = ""; + public UInt16 properUtype = 0; + public UInt32 properFlags = 0; + public Int16 aliasID = -1; + public object defaultVal = null; + + public Property() + { + + } + + public bool isBase() + { + return properFlags == (UInt32)EntityDataFlags.ED_FLAG_BASE_AND_CLIENT || + properFlags == (UInt32)EntityDataFlags.ED_FLAG_BASE; + } + + public bool isOwnerOnly() + { + return properFlags == (UInt32)EntityDataFlags.ED_FLAG_CELL_PUBLIC_AND_OWN || + properFlags == (UInt32)EntityDataFlags.ED_FLAG_OWN_CLIENT; + } + + public bool isOtherOnly() + { + return properFlags == (UInt32)EntityDataFlags.ED_FLAG_OTHER_CLIENTS || + properFlags == (UInt32)EntityDataFlags.ED_FLAG_OTHER_CLIENTS; + } + } + +} diff --git a/Assets/Plugins/kbengine_unity3d_plugins/README.md b/Assets/Plugins/kbengine_unity3d_plugins/README.md index d657fe1..a20eba6 100644 --- a/Assets/Plugins/kbengine_unity3d_plugins/README.md +++ b/Assets/Plugins/kbengine_unity3d_plugins/README.md @@ -1,364 +1,364 @@ -kbengine_unity3d_plugins -======================== - -Usage ---------------------- - - 1: Generate client plugins through projects - 1: Double click to run kbengine\*assets\gensdk.bat - 2: Copy kbengine_unity3d_plugins to {UnityProjectName}\Assets\Plugins - - 2: Create clientapp.cs - using KBEngine; - public class clientapp : KBEMain - { - } - - 3: Implment the KBE defined entity (including the client part) - See: kbengine\kbengine_demos_assets\scripts\entities.xml->hasClient="true" need to implment - - - - - - public class Account : AccountBase - { - // entity initialization - public override void __init__() - { - } - } - - Call entity server method - Account.cs: baseEntityCall.reqAvatarList(); - Avatar.cs: cellEntityCall.relive(reliveType); - - Reference: https://github.com/kbengine/kbengine/issues/532 - - 4: Monitor KBE-plugins event - For example: - public class UI : MonoBehaviour - { - void Start () - { - KBEngine.Event.registerOut("onConnectionState", this, "onConnectionState"); - } - - public void onConnectionState(bool success) - { - // KBE-plugins event fired - } - } - - 5: Fire events to the KBE-plugins - For example: - KBEngine.Event.fireIn("login", "stringAccount", "stringPasswd", System.Text.Encoding.UTF8.GetBytes("kbengine_unity3d_demo")); - - - -KBE-Plugin fire-out events(KBE => Unity): ---------------------- - - Entity events: - onEnterWorld - Description: - Entity enter the client-world. - - Event-datas: - Enity - - - onLeaveWorld - Description: - Entity leave the client-world. - - Event-datas: - Enity - - onEnterSpace - Description: - Player enter the new space. - - Event-datas: - Enity - - onLeaveSpace - Description: - Player enter the space. - - Event-datas: - Enity - - onCreateAccountResult - Description: - Create account feedback results. - - Event-datas: - uint16: retcode - http://kbengine.org/docs/configuration/server_errors.html - - bytes: datas - If you use third-party account system, the system may fill some of the third-party additional datas. - - onControlled - Description: - Triggered when the entity is controlled or out of control. - - Event-datas: - Enity - bool: isControlled - - onLoseControlledEntity - Description: - Lose controlled entity. - - Event-datas: - Enity - - set_position - Description: - Sets the current position of the entity. - - Event-datas: - Enity - - set_direction - Description: - Sets the current direction of the entity. - - Event-datas: - Enity - - updatePosition - Description: - The entity position is updated, you can smooth the moving entity to new location. - - Event-datas: - Enity - - Protocol events: - onVersionNotMatch - Description: - Engine version mismatch. - - Event-datas: - string: clientVersion - string: serverVersion - - onScriptVersionNotMatch - Description: - script version mismatch. - - Event-datas: - string: clientScriptVersion - string: serverScriptVersion - - Loginapp_importClientMessages - Description: - Importing the message protocol for loginapp and client. - - Event-datas: - No datas. - - Baseapp_importClientMessages - Description: - Importing the message protocol for baseapp and client. - - Event-datas: - No datas. - - Baseapp_importClientEntityDef - Description: - Protocol description for importing entities. - - Event-datas: - No datas. - - Login and Logout status: - onLoginBaseapp - Description: - Login to baseapp. - - Event-datas: - No datas. - - onReloginBaseapp - Description: - Relogin to baseapp. - - Event-datas: - No datas. - - onKicked - Description: - Kicked of the current server. - - Event-datas: - uint16: retcode - http://kbengine.org/docs/configuration/server_errors.html - - onLoginFailed - Description: - Login failed. - - Event-datas: - uint16: retcode - http://kbengine.org/docs/configuration/server_errors.html - - onLoginBaseappFailed - Description: - Login baseapp failed. - - Event-datas: - uint16: retcode - http://kbengine.org/docs/configuration/server_errors.html - - onReloginBaseappFailed - Description: - Relogin baseapp failed. - - Event-datas: - uint16: retcode - http://kbengine.org/docs/configuration/server_errors.html - - onReloginBaseappSuccessfully - Description: - Relogin baseapp success. - - Event-datas: - No datas. - - Space events: - addSpaceGeometryMapping - Description: - The current space is specified by the geometry mapping. - Popular said is to load the specified Map Resources. - - Event-datas: - string: resPath - - onSetSpaceData - Description: - Server spaceData set data. - - Event-datas: - int32: spaceID - string: key - string value - - onDelSpaceData - Description: - Server spaceData delete data. - - Event-datas: - int32: spaceID - string: key - - Network events: - onConnectionState - Description: - Status of connection server. - - Event-datas: - bool: success or fail - - onDisconnected - Description: - Status of connection server. - - Event-datas: - No datas. - - Download events: - onStreamDataStarted - Description: - Start downloading data. - - Event-datas: - uint16: resouce id - uint32: data size - string: description - - onStreamDataRecv - Description: - Receive data. - - Event-datas: - uint16: resouce id - bytes: datas - - onStreamDataCompleted - Description: - The downloaded data is completed. - - Event-datas: - uint16: resouce id - - - -KBE-Plugin fire-in events(Unity => KBE): ---------------------- - - createAccount - Description: - Create new account. - - Event-datas: - string: accountName - string: password - bytes: datas - Datas by user defined. - Data will be recorded into the KBE account database, you can access the datas through the script layer. - If you use third-party account system, datas will be submitted to the third-party system. - - login - Description: - Login to server. - - Event-datas: - string: accountName - string: password - bytes: datas - Datas by user defined. - Data will be recorded into the KBE account database, you can access the datas through the script layer. - If you use third-party account system, datas will be submitted to the third-party system. - - logout - Description: - Logout to baseapp, called when exiting the client. - - Event-datas: - No datas. - - reloginBaseapp - Description: - Relogin to baseapp. - - Event-datas: - No datas. - - resetPassword - Description: - Reset password. - - Event-datas: - string: accountName - - newPassword - Description: - Request to set up a new password for the account. - Note: account must be online - - Event-datas: - string: old_password - string: new_password - - bindAccountEmail - Description: - Request server binding account Email. - Note: account must be online - - Event-datas: - string: emailAddress - - +kbengine_unity3d_plugins +======================== + +Usage +--------------------- + + 1: Generate client plugins through projects + 1: Double click to run kbengine\*assets\gensdk.bat + 2: Copy kbengine_unity3d_plugins to {UnityProjectName}\Assets\Plugins + + 2: Create clientapp.cs + using KBEngine; + public class clientapp : KBEMain + { + } + + 3: Implment the KBE defined entity (including the client part) + See: kbengine\kbengine_demos_assets\scripts\entities.xml->hasClient="true" need to implment + + + + + + public class Account : AccountBase + { + // entity initialization + public override void __init__() + { + } + } + + Call entity server method + Account.cs: baseEntityCall.reqAvatarList(); + Avatar.cs: cellEntityCall.relive(reliveType); + + Reference: https://github.com/kbengine/kbengine/issues/532 + + 4: Monitor KBE-plugins event + For example: + public class UI : MonoBehaviour + { + void Start () + { + KBEngine.Event.registerOut("onConnectionState", this, "onConnectionState"); + } + + public void onConnectionState(bool success) + { + // KBE-plugins event fired + } + } + + 5: Fire events to the KBE-plugins + For example: + KBEngine.Event.fireIn("login", "stringAccount", "stringPasswd", System.Text.Encoding.UTF8.GetBytes("kbengine_unity3d_demo")); + + + +KBE-Plugin fire-out events(KBE => Unity): +--------------------- + + Entity events: + onEnterWorld + Description: + Entity enter the client-world. + + Event-datas: + Enity + + + onLeaveWorld + Description: + Entity leave the client-world. + + Event-datas: + Enity + + onEnterSpace + Description: + Player enter the new space. + + Event-datas: + Enity + + onLeaveSpace + Description: + Player enter the space. + + Event-datas: + Enity + + onCreateAccountResult + Description: + Create account feedback results. + + Event-datas: + uint16: retcode + http://kbengine.org/docs/configuration/server_errors.html + + bytes: datas + If you use third-party account system, the system may fill some of the third-party additional datas. + + onControlled + Description: + Triggered when the entity is controlled or out of control. + + Event-datas: + Enity + bool: isControlled + + onLoseControlledEntity + Description: + Lose controlled entity. + + Event-datas: + Enity + + set_position + Description: + Sets the current position of the entity. + + Event-datas: + Enity + + set_direction + Description: + Sets the current direction of the entity. + + Event-datas: + Enity + + updatePosition + Description: + The entity position is updated, you can smooth the moving entity to new location. + + Event-datas: + Enity + + Protocol events: + onVersionNotMatch + Description: + Engine version mismatch. + + Event-datas: + string: clientVersion + string: serverVersion + + onScriptVersionNotMatch + Description: + script version mismatch. + + Event-datas: + string: clientScriptVersion + string: serverScriptVersion + + Loginapp_importClientMessages + Description: + Importing the message protocol for loginapp and client. + + Event-datas: + No datas. + + Baseapp_importClientMessages + Description: + Importing the message protocol for baseapp and client. + + Event-datas: + No datas. + + Baseapp_importClientEntityDef + Description: + Protocol description for importing entities. + + Event-datas: + No datas. + + Login and Logout status: + onLoginBaseapp + Description: + Login to baseapp. + + Event-datas: + No datas. + + onReloginBaseapp + Description: + Relogin to baseapp. + + Event-datas: + No datas. + + onKicked + Description: + Kicked of the current server. + + Event-datas: + uint16: retcode + http://kbengine.org/docs/configuration/server_errors.html + + onLoginFailed + Description: + Login failed. + + Event-datas: + uint16: retcode + http://kbengine.org/docs/configuration/server_errors.html + + onLoginBaseappFailed + Description: + Login baseapp failed. + + Event-datas: + uint16: retcode + http://kbengine.org/docs/configuration/server_errors.html + + onReloginBaseappFailed + Description: + Relogin baseapp failed. + + Event-datas: + uint16: retcode + http://kbengine.org/docs/configuration/server_errors.html + + onReloginBaseappSuccessfully + Description: + Relogin baseapp success. + + Event-datas: + No datas. + + Space events: + addSpaceGeometryMapping + Description: + The current space is specified by the geometry mapping. + Popular said is to load the specified Map Resources. + + Event-datas: + string: resPath + + onSetSpaceData + Description: + Server spaceData set data. + + Event-datas: + int32: spaceID + string: key + string value + + onDelSpaceData + Description: + Server spaceData delete data. + + Event-datas: + int32: spaceID + string: key + + Network events: + onConnectionState + Description: + Status of connection server. + + Event-datas: + bool: success or fail + + onDisconnected + Description: + Status of connection server. + + Event-datas: + No datas. + + Download events: + onStreamDataStarted + Description: + Start downloading data. + + Event-datas: + uint16: resouce id + uint32: data size + string: description + + onStreamDataRecv + Description: + Receive data. + + Event-datas: + uint16: resouce id + bytes: datas + + onStreamDataCompleted + Description: + The downloaded data is completed. + + Event-datas: + uint16: resouce id + + + +KBE-Plugin fire-in events(Unity => KBE): +--------------------- + + createAccount + Description: + Create new account. + + Event-datas: + string: accountName + string: password + bytes: datas + Datas by user defined. + Data will be recorded into the KBE account database, you can access the datas through the script layer. + If you use third-party account system, datas will be submitted to the third-party system. + + login + Description: + Login to server. + + Event-datas: + string: accountName + string: password + bytes: datas + Datas by user defined. + Data will be recorded into the KBE account database, you can access the datas through the script layer. + If you use third-party account system, datas will be submitted to the third-party system. + + logout + Description: + Logout to baseapp, called when exiting the client. + + Event-datas: + No datas. + + reloginBaseapp + Description: + Relogin to baseapp. + + Event-datas: + No datas. + + resetPassword + Description: + Reset password. + + Event-datas: + string: accountName + + newPassword + Description: + Request to set up a new password for the account. + Note: account must be online + + Event-datas: + string: old_password + string: new_password + + bindAccountEmail + Description: + Request server binding account Email. + Note: account must be online + + Event-datas: + string: emailAddress + + diff --git a/Assets/Plugins/kbengine_unity3d_plugins/ScriptModule.cs b/Assets/Plugins/kbengine_unity3d_plugins/ScriptModule.cs index 588f86e..d193165 100644 --- a/Assets/Plugins/kbengine_unity3d_plugins/ScriptModule.cs +++ b/Assets/Plugins/kbengine_unity3d_plugins/ScriptModule.cs @@ -1,56 +1,56 @@ -namespace KBEngine -{ - using UnityEngine; - using System; - using System.Collections; - using System.Collections.Generic; - using System.Reflection; - - /* - 一个entitydef中定义的脚本模块的描述类 - 包含了某个entity定义的属性与方法以及该entity脚本模块的名称与模块ID - */ - public class ScriptModule - { - public string name; - public bool usePropertyDescrAlias; - public bool useMethodDescrAlias; - - public Dictionary propertys = new Dictionary(); - public Dictionary idpropertys = new Dictionary(); - - public Dictionary methods = new Dictionary(); - public Dictionary base_methods = new Dictionary(); - public Dictionary cell_methods = new Dictionary(); - - public Dictionary idmethods = new Dictionary(); - public Dictionary idbase_methods = new Dictionary(); - public Dictionary idcell_methods = new Dictionary(); - - public Type entityScript = null; - - public ScriptModule(string modulename) - { - name = modulename; - - foreach (System.Reflection.Assembly ass in AppDomain.CurrentDomain.GetAssemblies()) - { - entityScript = ass.GetType("KBEngine." + modulename); - if(entityScript == null) - { - entityScript = ass.GetType(modulename); - } - - if(entityScript != null) - break; - } - - usePropertyDescrAlias = false; - useMethodDescrAlias = false; - - if(entityScript == null) - Dbg.ERROR_MSG("can't load(KBEngine." + modulename + ")!"); - } - } - -} +namespace KBEngine +{ + using UnityEngine; + using System; + using System.Collections; + using System.Collections.Generic; + using System.Reflection; + + /* + 一个entitydef中定义的脚本模块的描述类 + 包含了某个entity定义的属性与方法以及该entity脚本模块的名称与模块ID + */ + public class ScriptModule + { + public string name; + public bool usePropertyDescrAlias; + public bool useMethodDescrAlias; + + public Dictionary propertys = new Dictionary(); + public Dictionary idpropertys = new Dictionary(); + + public Dictionary methods = new Dictionary(); + public Dictionary base_methods = new Dictionary(); + public Dictionary cell_methods = new Dictionary(); + + public Dictionary idmethods = new Dictionary(); + public Dictionary idbase_methods = new Dictionary(); + public Dictionary idcell_methods = new Dictionary(); + + public Type entityScript = null; + + public ScriptModule(string modulename) + { + name = modulename; + + foreach (System.Reflection.Assembly ass in AppDomain.CurrentDomain.GetAssemblies()) + { + entityScript = ass.GetType("KBEngine." + modulename); + if(entityScript == null) + { + entityScript = ass.GetType(modulename); + } + + if(entityScript != null) + break; + } + + usePropertyDescrAlias = false; + useMethodDescrAlias = false; + + if(entityScript == null) + Dbg.ERROR_MSG("can't load(KBEngine." + modulename + ")!"); + } + } + +} diff --git a/Assets/Plugins/kbengine_unity3d_plugins/ServerErrorDescrs.cs b/Assets/Plugins/kbengine_unity3d_plugins/ServerErrorDescrs.cs index 4fce984..75092d2 100644 --- a/Assets/Plugins/kbengine_unity3d_plugins/ServerErrorDescrs.cs +++ b/Assets/Plugins/kbengine_unity3d_plugins/ServerErrorDescrs.cs @@ -1,401 +1,401 @@ -/* - Generated by KBEngine! - Please do not modify this file! - tools = kbcmd -*/ - -namespace KBEngine -{ - using UnityEngine; - using System; - using System.Collections; - using System.Collections.Generic; - - public struct ServerErr - { - public string name; - public string descr; - public UInt16 id; - } - - // defined in */res/server/server_errors.xml - - public class ServerErrorDescrs - { - public static Dictionary serverErrs = new Dictionary(); - - public ServerErrorDescrs() - { - { - ServerErr e; - e.id = 0; - e.name = "SUCCESS"; - e.descr = "成功。"; - - serverErrs.Add(e.id, e); - } - - { - ServerErr e; - e.id = 1; - e.name = "SERVER_ERR_SRV_NO_READY"; - e.descr = "服务器没有准备好。"; - - serverErrs.Add(e.id, e); - } - - { - ServerErr e; - e.id = 2; - e.name = "SERVER_ERR_SRV_OVERLOAD"; - e.descr = "服务器负载过重。"; - - serverErrs.Add(e.id, e); - } - - { - ServerErr e; - e.id = 3; - e.name = "SERVER_ERR_ILLEGAL_LOGIN"; - e.descr = "非法登录。"; - - serverErrs.Add(e.id, e); - } - - { - ServerErr e; - e.id = 4; - e.name = "SERVER_ERR_NAME_PASSWORD"; - e.descr = "用户名或者密码不正确。"; - - serverErrs.Add(e.id, e); - } - - { - ServerErr e; - e.id = 5; - e.name = "SERVER_ERR_NAME"; - e.descr = "用户名不正确。"; - - serverErrs.Add(e.id, e); - } - - { - ServerErr e; - e.id = 6; - e.name = "SERVER_ERR_PASSWORD"; - e.descr = "密码不正确。"; - - serverErrs.Add(e.id, e); - } - - { - ServerErr e; - e.id = 7; - e.name = "SERVER_ERR_ACCOUNT_CREATE_FAILED"; - e.descr = "创建账号失败(已经存在一个相同的账号)。"; - - serverErrs.Add(e.id, e); - } - - { - ServerErr e; - e.id = 8; - e.name = "SERVER_ERR_BUSY"; - e.descr = "操作过于繁忙(例如:在服务器前一次请求未执行完毕的情况下连续N次创建账号)。"; - - serverErrs.Add(e.id, e); - } - - { - ServerErr e; - e.id = 9; - e.name = "SERVER_ERR_ACCOUNT_LOGIN_ANOTHER"; - e.descr = "当前账号在另一处登录了。"; - - serverErrs.Add(e.id, e); - } - - { - ServerErr e; - e.id = 10; - e.name = "SERVER_ERR_ACCOUNT_IS_ONLINE"; - e.descr = "账号已登陆。"; - - serverErrs.Add(e.id, e); - } - - { - ServerErr e; - e.id = 11; - e.name = "SERVER_ERR_PROXY_DESTROYED"; - e.descr = "与客户端关联的proxy在服务器上已经销毁。"; - - serverErrs.Add(e.id, e); - } - - { - ServerErr e; - e.id = 12; - e.name = "SERVER_ERR_ENTITYDEFS_NOT_MATCH"; - e.descr = "EntityDefs不匹配。"; - - serverErrs.Add(e.id, e); - } - - { - ServerErr e; - e.id = 13; - e.name = "SERVER_ERR_SERVER_IN_SHUTTINGDOWN"; - e.descr = "服务器正在关闭中。"; - - serverErrs.Add(e.id, e); - } - - { - ServerErr e; - e.id = 14; - e.name = "SERVER_ERR_NAME_MAIL"; - e.descr = "Email地址错误。"; - - serverErrs.Add(e.id, e); - } - - { - ServerErr e; - e.id = 15; - e.name = "SERVER_ERR_ACCOUNT_LOCK"; - e.descr = "账号被冻结。"; - - serverErrs.Add(e.id, e); - } - - { - ServerErr e; - e.id = 16; - e.name = "SERVER_ERR_ACCOUNT_DEADLINE"; - e.descr = "账号已过期。"; - - serverErrs.Add(e.id, e); - } - - { - ServerErr e; - e.id = 17; - e.name = "SERVER_ERR_ACCOUNT_NOT_ACTIVATED"; - e.descr = "账号未激活。"; - - serverErrs.Add(e.id, e); - } - - { - ServerErr e; - e.id = 18; - e.name = "SERVER_ERR_VERSION_NOT_MATCH"; - e.descr = "与服务端的版本不匹配。"; - - serverErrs.Add(e.id, e); - } - - { - ServerErr e; - e.id = 19; - e.name = "SERVER_ERR_OP_FAILED"; - e.descr = "操作失败。"; - - serverErrs.Add(e.id, e); - } - - { - ServerErr e; - e.id = 20; - e.name = "SERVER_ERR_SRV_STARTING"; - e.descr = "服务器正在启动中。"; - - serverErrs.Add(e.id, e); - } - - { - ServerErr e; - e.id = 21; - e.name = "SERVER_ERR_ACCOUNT_REGISTER_NOT_AVAILABLE"; - e.descr = "未开放账号注册功能。"; - - serverErrs.Add(e.id, e); - } - - { - ServerErr e; - e.id = 22; - e.name = "SERVER_ERR_CANNOT_USE_MAIL"; - e.descr = "不能使用email地址。"; - - serverErrs.Add(e.id, e); - } - - { - ServerErr e; - e.id = 23; - e.name = "SERVER_ERR_NOT_FOUND_ACCOUNT"; - e.descr = "找不到此账号。"; - - serverErrs.Add(e.id, e); - } - - { - ServerErr e; - e.id = 24; - e.name = "SERVER_ERR_DB"; - e.descr = "数据库错误(请检查dbmgr日志和DB)。"; - - serverErrs.Add(e.id, e); - } - - { - ServerErr e; - e.id = 25; - e.name = "SERVER_ERR_USER1"; - e.descr = "用户自定义错误码1。"; - - serverErrs.Add(e.id, e); - } - - { - ServerErr e; - e.id = 26; - e.name = "SERVER_ERR_USER2"; - e.descr = "用户自定义错误码2。"; - - serverErrs.Add(e.id, e); - } - - { - ServerErr e; - e.id = 27; - e.name = "SERVER_ERR_USER3"; - e.descr = "用户自定义错误码3。"; - - serverErrs.Add(e.id, e); - } - - { - ServerErr e; - e.id = 28; - e.name = "SERVER_ERR_USER4"; - e.descr = "用户自定义错误码4。"; - - serverErrs.Add(e.id, e); - } - - { - ServerErr e; - e.id = 29; - e.name = "SERVER_ERR_USER5"; - e.descr = "用户自定义错误码5。"; - - serverErrs.Add(e.id, e); - } - - { - ServerErr e; - e.id = 30; - e.name = "SERVER_ERR_USER6"; - e.descr = "用户自定义错误码6。"; - - serverErrs.Add(e.id, e); - } - - { - ServerErr e; - e.id = 31; - e.name = "SERVER_ERR_USER7"; - e.descr = "用户自定义错误码7。"; - - serverErrs.Add(e.id, e); - } - - { - ServerErr e; - e.id = 32; - e.name = "SERVER_ERR_USER8"; - e.descr = "用户自定义错误码8。"; - - serverErrs.Add(e.id, e); - } - - { - ServerErr e; - e.id = 33; - e.name = "SERVER_ERR_USER9"; - e.descr = "用户自定义错误码9。"; - - serverErrs.Add(e.id, e); - } - - { - ServerErr e; - e.id = 34; - e.name = "SERVER_ERR_USER10"; - e.descr = "用户自定义错误码10。"; - - serverErrs.Add(e.id, e); - } - - { - ServerErr e; - e.id = 35; - e.name = "SERVER_ERR_LOCAL_PROCESSING"; - e.descr = "本地处理,通常为某件事情不由第三方处理而是由KBE服务器处理。"; - - serverErrs.Add(e.id, e); - } - - { - ServerErr e; - e.id = 36; - e.name = "SERVER_ERR_ACCOUNT_RESET_PASSWORD_NOT_AVAILABLE"; - e.descr = "未开放账号重置密码功能。"; - - serverErrs.Add(e.id, e); - } - - { - ServerErr e; - e.id = 37; - e.name = "SERVER_ERR_ACCOUNT_LOGIN_ANOTHER_SERVER"; - e.descr = "当前账号在其他服务器登陆了。"; - - serverErrs.Add(e.id, e); - } - - - } - - public void Clear() - { - serverErrs.Clear(); - } - - public string serverErrStr(UInt16 id) - { - ServerErr e; - if(!serverErrs.TryGetValue(id, out e)) - { - return ""; - } - - return e.name + "[" + e.descr + "]"; - } - - public ServerErr serverErr(UInt16 id) - { - ServerErr e; - serverErrs.TryGetValue(id, out e); - return e; - } - - - - - } +/* + Generated by KBEngine! + Please do not modify this file! + tools = kbcmd +*/ + +namespace KBEngine +{ + using UnityEngine; + using System; + using System.Collections; + using System.Collections.Generic; + + public struct ServerErr + { + public string name; + public string descr; + public UInt16 id; + } + + // defined in */res/server/server_errors.xml + + public class ServerErrorDescrs + { + public static Dictionary serverErrs = new Dictionary(); + + public ServerErrorDescrs() + { + { + ServerErr e; + e.id = 0; + e.name = "SUCCESS"; + e.descr = "成功。"; + + serverErrs.Add(e.id, e); + } + + { + ServerErr e; + e.id = 1; + e.name = "SERVER_ERR_SRV_NO_READY"; + e.descr = "服务器没有准备好。"; + + serverErrs.Add(e.id, e); + } + + { + ServerErr e; + e.id = 2; + e.name = "SERVER_ERR_SRV_OVERLOAD"; + e.descr = "服务器负载过重。"; + + serverErrs.Add(e.id, e); + } + + { + ServerErr e; + e.id = 3; + e.name = "SERVER_ERR_ILLEGAL_LOGIN"; + e.descr = "非法登录。"; + + serverErrs.Add(e.id, e); + } + + { + ServerErr e; + e.id = 4; + e.name = "SERVER_ERR_NAME_PASSWORD"; + e.descr = "用户名或者密码不正确。"; + + serverErrs.Add(e.id, e); + } + + { + ServerErr e; + e.id = 5; + e.name = "SERVER_ERR_NAME"; + e.descr = "用户名不正确。"; + + serverErrs.Add(e.id, e); + } + + { + ServerErr e; + e.id = 6; + e.name = "SERVER_ERR_PASSWORD"; + e.descr = "密码不正确。"; + + serverErrs.Add(e.id, e); + } + + { + ServerErr e; + e.id = 7; + e.name = "SERVER_ERR_ACCOUNT_CREATE_FAILED"; + e.descr = "创建账号失败。"; + + serverErrs.Add(e.id, e); + } + + { + ServerErr e; + e.id = 8; + e.name = "SERVER_ERR_BUSY"; + e.descr = "操作过于繁忙(例如:在服务器前一次请求未执行完毕的情况下连续N次创建账号)。"; + + serverErrs.Add(e.id, e); + } + + { + ServerErr e; + e.id = 9; + e.name = "SERVER_ERR_ACCOUNT_LOGIN_ANOTHER"; + e.descr = "当前账号在另一处登录了。"; + + serverErrs.Add(e.id, e); + } + + { + ServerErr e; + e.id = 10; + e.name = "SERVER_ERR_ACCOUNT_IS_ONLINE"; + e.descr = "账号已登陆。"; + + serverErrs.Add(e.id, e); + } + + { + ServerErr e; + e.id = 11; + e.name = "SERVER_ERR_PROXY_DESTROYED"; + e.descr = "与客户端关联的proxy在服务器上已经销毁。"; + + serverErrs.Add(e.id, e); + } + + { + ServerErr e; + e.id = 12; + e.name = "SERVER_ERR_ENTITYDEFS_NOT_MATCH"; + e.descr = "EntityDefs不匹配。"; + + serverErrs.Add(e.id, e); + } + + { + ServerErr e; + e.id = 13; + e.name = "SERVER_ERR_SERVER_IN_SHUTTINGDOWN"; + e.descr = "服务器正在关闭中。"; + + serverErrs.Add(e.id, e); + } + + { + ServerErr e; + e.id = 14; + e.name = "SERVER_ERR_NAME_MAIL"; + e.descr = "Email地址错误。"; + + serverErrs.Add(e.id, e); + } + + { + ServerErr e; + e.id = 15; + e.name = "SERVER_ERR_ACCOUNT_LOCK"; + e.descr = "账号被冻结。"; + + serverErrs.Add(e.id, e); + } + + { + ServerErr e; + e.id = 16; + e.name = "SERVER_ERR_ACCOUNT_DEADLINE"; + e.descr = "账号已过期。"; + + serverErrs.Add(e.id, e); + } + + { + ServerErr e; + e.id = 17; + e.name = "SERVER_ERR_ACCOUNT_NOT_ACTIVATED"; + e.descr = "账号未激活。"; + + serverErrs.Add(e.id, e); + } + + { + ServerErr e; + e.id = 18; + e.name = "SERVER_ERR_VERSION_NOT_MATCH"; + e.descr = "与服务端的版本不匹配。"; + + serverErrs.Add(e.id, e); + } + + { + ServerErr e; + e.id = 19; + e.name = "SERVER_ERR_OP_FAILED"; + e.descr = "操作失败。"; + + serverErrs.Add(e.id, e); + } + + { + ServerErr e; + e.id = 20; + e.name = "SERVER_ERR_SRV_STARTING"; + e.descr = "服务器正在启动中。"; + + serverErrs.Add(e.id, e); + } + + { + ServerErr e; + e.id = 21; + e.name = "SERVER_ERR_ACCOUNT_REGISTER_NOT_AVAILABLE"; + e.descr = "未开放账号注册功能。"; + + serverErrs.Add(e.id, e); + } + + { + ServerErr e; + e.id = 22; + e.name = "SERVER_ERR_CANNOT_USE_MAIL"; + e.descr = "不能使用email地址。"; + + serverErrs.Add(e.id, e); + } + + { + ServerErr e; + e.id = 23; + e.name = "SERVER_ERR_NOT_FOUND_ACCOUNT"; + e.descr = "找不到此账号。"; + + serverErrs.Add(e.id, e); + } + + { + ServerErr e; + e.id = 24; + e.name = "SERVER_ERR_DB"; + e.descr = "数据库错误(请检查dbmgr日志和DB)。"; + + serverErrs.Add(e.id, e); + } + + { + ServerErr e; + e.id = 25; + e.name = "SERVER_ERR_USER1"; + e.descr = "用户自定义错误码1。"; + + serverErrs.Add(e.id, e); + } + + { + ServerErr e; + e.id = 26; + e.name = "SERVER_ERR_USER2"; + e.descr = "用户自定义错误码2。"; + + serverErrs.Add(e.id, e); + } + + { + ServerErr e; + e.id = 27; + e.name = "SERVER_ERR_USER3"; + e.descr = "用户自定义错误码3。"; + + serverErrs.Add(e.id, e); + } + + { + ServerErr e; + e.id = 28; + e.name = "SERVER_ERR_USER4"; + e.descr = "用户自定义错误码4。"; + + serverErrs.Add(e.id, e); + } + + { + ServerErr e; + e.id = 29; + e.name = "SERVER_ERR_USER5"; + e.descr = "用户自定义错误码5。"; + + serverErrs.Add(e.id, e); + } + + { + ServerErr e; + e.id = 30; + e.name = "SERVER_ERR_USER6"; + e.descr = "用户自定义错误码6。"; + + serverErrs.Add(e.id, e); + } + + { + ServerErr e; + e.id = 31; + e.name = "SERVER_ERR_USER7"; + e.descr = "用户自定义错误码7。"; + + serverErrs.Add(e.id, e); + } + + { + ServerErr e; + e.id = 32; + e.name = "SERVER_ERR_USER8"; + e.descr = "用户自定义错误码8。"; + + serverErrs.Add(e.id, e); + } + + { + ServerErr e; + e.id = 33; + e.name = "SERVER_ERR_USER9"; + e.descr = "用户自定义错误码9。"; + + serverErrs.Add(e.id, e); + } + + { + ServerErr e; + e.id = 34; + e.name = "SERVER_ERR_USER10"; + e.descr = "用户自定义错误码10。"; + + serverErrs.Add(e.id, e); + } + + { + ServerErr e; + e.id = 35; + e.name = "SERVER_ERR_LOCAL_PROCESSING"; + e.descr = "本地处理,通常为某件事情不由第三方处理而是由KBE服务器处理。"; + + serverErrs.Add(e.id, e); + } + + { + ServerErr e; + e.id = 36; + e.name = "SERVER_ERR_ACCOUNT_RESET_PASSWORD_NOT_AVAILABLE"; + e.descr = "未开放账号重置密码功能。"; + + serverErrs.Add(e.id, e); + } + + { + ServerErr e; + e.id = 37; + e.name = "SERVER_ERR_ACCOUNT_LOGIN_ANOTHER_SERVER"; + e.descr = "当前账号在其他服务器登陆了。"; + + serverErrs.Add(e.id, e); + } + + + } + + public void Clear() + { + serverErrs.Clear(); + } + + public string serverErrStr(UInt16 id) + { + ServerErr e; + if(!serverErrs.TryGetValue(id, out e)) + { + return ""; + } + + return e.name + "[" + e.descr + "]"; + } + + public ServerErr serverErr(UInt16 id) + { + ServerErr e; + serverErrs.TryGetValue(id, out e); + return e; + } + + + + + } } \ No newline at end of file diff --git a/Assets/Plugins/kbengine_unity3d_plugins/SpaceBase.cs b/Assets/Plugins/kbengine_unity3d_plugins/SpaceBase.cs index e8e9603..329ae9a 100644 --- a/Assets/Plugins/kbengine_unity3d_plugins/SpaceBase.cs +++ b/Assets/Plugins/kbengine_unity3d_plugins/SpaceBase.cs @@ -1,447 +1,447 @@ -/* - Generated by KBEngine! - Please do not modify this file! - Please inherit this module, such as: (class Space : SpaceBase) - tools = kbcmd -*/ - -namespace KBEngine -{ - using UnityEngine; - using System; - using System.Collections; - using System.Collections.Generic; - - // defined in */scripts/entity_defs/Space.def - // Please inherit and implement "class Space : SpaceBase" - public abstract class SpaceBase : Entity - { - public EntityBaseEntityCall_SpaceBase baseEntityCall = null; - public EntityCellEntityCall_SpaceBase cellEntityCall = null; - - public UInt32 modelID = 0; - public virtual void onModelIDChanged(UInt32 oldValue) {} - public Byte modelScale = 30; - public virtual void onModelScaleChanged(Byte oldValue) {} - public string name = ""; - public virtual void onNameChanged(string oldValue) {} - public UInt32 uid = 0; - public virtual void onUidChanged(UInt32 oldValue) {} - public UInt32 utype = 0; - public virtual void onUtypeChanged(UInt32 oldValue) {} - - - public SpaceBase() - { - } - - public override void onComponentsEnterworld() - { - } - - public override void onComponentsLeaveworld() - { - } - - public override void onGetBase() - { - baseEntityCall = new EntityBaseEntityCall_SpaceBase(id, className); - } - - public override void onGetCell() - { - cellEntityCall = new EntityCellEntityCall_SpaceBase(id, className); - } - - public override void onLoseCell() - { - cellEntityCall = null; - } - - public override EntityCall getBaseEntityCall() - { - return baseEntityCall; - } - - public override EntityCall getCellEntityCall() - { - return cellEntityCall; - } - - public override void attachComponents() - { - } - - public override void detachComponents() - { - } - - public override void onRemoteMethodCall(MemoryStream stream) - { - ScriptModule sm = EntityDef.moduledefs["Space"]; - - UInt16 methodUtype = 0; - UInt16 componentPropertyUType = 0; - - if(sm.usePropertyDescrAlias) - { - componentPropertyUType = stream.readUint8(); - } - else - { - componentPropertyUType = stream.readUint16(); - } - - if(sm.useMethodDescrAlias) - { - methodUtype = stream.readUint8(); - } - else - { - methodUtype = stream.readUint16(); - } - - Method method = null; - - if(componentPropertyUType == 0) - { - method = sm.idmethods[methodUtype]; - } - else - { - Property pComponentPropertyDescription = sm.idpropertys[componentPropertyUType]; - switch(pComponentPropertyDescription.properUtype) - { - default: - break; - } - - return; - } - - switch(method.methodUtype) - { - default: - break; - }; - } - - public override void onUpdatePropertys(MemoryStream stream) - { - ScriptModule sm = EntityDef.moduledefs["Space"]; - Dictionary pdatas = sm.idpropertys; - - while(stream.length() > 0) - { - UInt16 _t_utype = 0; - UInt16 _t_child_utype = 0; - - { - if(sm.usePropertyDescrAlias) - { - _t_utype = stream.readUint8(); - _t_child_utype = stream.readUint8(); - } - else - { - _t_utype = stream.readUint16(); - _t_child_utype = stream.readUint16(); - } - } - - Property prop = null; - - if(_t_utype == 0) - { - prop = pdatas[_t_child_utype]; - } - else - { - Property pComponentPropertyDescription = pdatas[_t_utype]; - switch(pComponentPropertyDescription.properUtype) - { - default: - break; - } - - return; - } - - switch(prop.properUtype) - { - case 40001: - Vector3 oldval_direction = direction; - direction = stream.readVector3(); - - if(prop.isBase()) - { - if(inited) - onDirectionChanged(oldval_direction); - } - else - { - if(inWorld) - onDirectionChanged(oldval_direction); - } - - break; - case 41006: - UInt32 oldval_modelID = modelID; - modelID = stream.readUint32(); - - if(prop.isBase()) - { - if(inited) - onModelIDChanged(oldval_modelID); - } - else - { - if(inWorld) - onModelIDChanged(oldval_modelID); - } - - break; - case 41007: - Byte oldval_modelScale = modelScale; - modelScale = stream.readUint8(); - - if(prop.isBase()) - { - if(inited) - onModelScaleChanged(oldval_modelScale); - } - else - { - if(inWorld) - onModelScaleChanged(oldval_modelScale); - } - - break; - case 41003: - string oldval_name = name; - name = stream.readUnicode(); - - if(prop.isBase()) - { - if(inited) - onNameChanged(oldval_name); - } - else - { - if(inWorld) - onNameChanged(oldval_name); - } - - break; - case 40000: - Vector3 oldval_position = position; - position = stream.readVector3(); - - if(prop.isBase()) - { - if(inited) - onPositionChanged(oldval_position); - } - else - { - if(inWorld) - onPositionChanged(oldval_position); - } - - break; - case 40002: - stream.readUint32(); - break; - case 41004: - UInt32 oldval_uid = uid; - uid = stream.readUint32(); - - if(prop.isBase()) - { - if(inited) - onUidChanged(oldval_uid); - } - else - { - if(inWorld) - onUidChanged(oldval_uid); - } - - break; - case 41005: - UInt32 oldval_utype = utype; - utype = stream.readUint32(); - - if(prop.isBase()) - { - if(inited) - onUtypeChanged(oldval_utype); - } - else - { - if(inWorld) - onUtypeChanged(oldval_utype); - } - - break; - default: - break; - }; - } - } - - public override void callPropertysSetMethods() - { - ScriptModule sm = EntityDef.moduledefs["Space"]; - Dictionary pdatas = sm.idpropertys; - - Vector3 oldval_direction = direction; - Property prop_direction = pdatas[2]; - if(prop_direction.isBase()) - { - if(inited && !inWorld) - onDirectionChanged(oldval_direction); - } - else - { - if(inWorld) - { - if(prop_direction.isOwnerOnly() && !isPlayer()) - { - } - else - { - onDirectionChanged(oldval_direction); - } - } - } - - UInt32 oldval_modelID = modelID; - Property prop_modelID = pdatas[4]; - if(prop_modelID.isBase()) - { - if(inited && !inWorld) - onModelIDChanged(oldval_modelID); - } - else - { - if(inWorld) - { - if(prop_modelID.isOwnerOnly() && !isPlayer()) - { - } - else - { - onModelIDChanged(oldval_modelID); - } - } - } - - Byte oldval_modelScale = modelScale; - Property prop_modelScale = pdatas[5]; - if(prop_modelScale.isBase()) - { - if(inited && !inWorld) - onModelScaleChanged(oldval_modelScale); - } - else - { - if(inWorld) - { - if(prop_modelScale.isOwnerOnly() && !isPlayer()) - { - } - else - { - onModelScaleChanged(oldval_modelScale); - } - } - } - - string oldval_name = name; - Property prop_name = pdatas[6]; - if(prop_name.isBase()) - { - if(inited && !inWorld) - onNameChanged(oldval_name); - } - else - { - if(inWorld) - { - if(prop_name.isOwnerOnly() && !isPlayer()) - { - } - else - { - onNameChanged(oldval_name); - } - } - } - - Vector3 oldval_position = position; - Property prop_position = pdatas[1]; - if(prop_position.isBase()) - { - if(inited && !inWorld) - onPositionChanged(oldval_position); - } - else - { - if(inWorld) - { - if(prop_position.isOwnerOnly() && !isPlayer()) - { - } - else - { - onPositionChanged(oldval_position); - } - } - } - - UInt32 oldval_uid = uid; - Property prop_uid = pdatas[7]; - if(prop_uid.isBase()) - { - if(inited && !inWorld) - onUidChanged(oldval_uid); - } - else - { - if(inWorld) - { - if(prop_uid.isOwnerOnly() && !isPlayer()) - { - } - else - { - onUidChanged(oldval_uid); - } - } - } - - UInt32 oldval_utype = utype; - Property prop_utype = pdatas[8]; - if(prop_utype.isBase()) - { - if(inited && !inWorld) - onUtypeChanged(oldval_utype); - } - else - { - if(inWorld) - { - if(prop_utype.isOwnerOnly() && !isPlayer()) - { - } - else - { - onUtypeChanged(oldval_utype); - } - } - } - - } - } +/* + Generated by KBEngine! + Please do not modify this file! + Please inherit this module, such as: (class Space : SpaceBase) + tools = kbcmd +*/ + +namespace KBEngine +{ + using UnityEngine; + using System; + using System.Collections; + using System.Collections.Generic; + + // defined in */scripts/entity_defs/Space.def + // Please inherit and implement "class Space : SpaceBase" + public abstract class SpaceBase : Entity + { + public EntityBaseEntityCall_SpaceBase baseEntityCall = null; + public EntityCellEntityCall_SpaceBase cellEntityCall = null; + + public UInt32 modelID = 0; + public virtual void onModelIDChanged(UInt32 oldValue) {} + public Byte modelScale = 30; + public virtual void onModelScaleChanged(Byte oldValue) {} + public string name = ""; + public virtual void onNameChanged(string oldValue) {} + public UInt32 uid = 0; + public virtual void onUidChanged(UInt32 oldValue) {} + public UInt32 utype = 0; + public virtual void onUtypeChanged(UInt32 oldValue) {} + + + public SpaceBase() + { + } + + public override void onComponentsEnterworld() + { + } + + public override void onComponentsLeaveworld() + { + } + + public override void onGetBase() + { + baseEntityCall = new EntityBaseEntityCall_SpaceBase(id, className); + } + + public override void onGetCell() + { + cellEntityCall = new EntityCellEntityCall_SpaceBase(id, className); + } + + public override void onLoseCell() + { + cellEntityCall = null; + } + + public override EntityCall getBaseEntityCall() + { + return baseEntityCall; + } + + public override EntityCall getCellEntityCall() + { + return cellEntityCall; + } + + public override void attachComponents() + { + } + + public override void detachComponents() + { + } + + public override void onRemoteMethodCall(MemoryStream stream) + { + ScriptModule sm = EntityDef.moduledefs["Space"]; + + UInt16 methodUtype = 0; + UInt16 componentPropertyUType = 0; + + if(sm.usePropertyDescrAlias) + { + componentPropertyUType = stream.readUint8(); + } + else + { + componentPropertyUType = stream.readUint16(); + } + + if(sm.useMethodDescrAlias) + { + methodUtype = stream.readUint8(); + } + else + { + methodUtype = stream.readUint16(); + } + + Method method = null; + + if(componentPropertyUType == 0) + { + method = sm.idmethods[methodUtype]; + } + else + { + Property pComponentPropertyDescription = sm.idpropertys[componentPropertyUType]; + switch(pComponentPropertyDescription.properUtype) + { + default: + break; + } + + return; + } + + switch(method.methodUtype) + { + default: + break; + }; + } + + public override void onUpdatePropertys(MemoryStream stream) + { + ScriptModule sm = EntityDef.moduledefs["Space"]; + Dictionary pdatas = sm.idpropertys; + + while(stream.length() > 0) + { + UInt16 _t_utype = 0; + UInt16 _t_child_utype = 0; + + { + if(sm.usePropertyDescrAlias) + { + _t_utype = stream.readUint8(); + _t_child_utype = stream.readUint8(); + } + else + { + _t_utype = stream.readUint16(); + _t_child_utype = stream.readUint16(); + } + } + + Property prop = null; + + if(_t_utype == 0) + { + prop = pdatas[_t_child_utype]; + } + else + { + Property pComponentPropertyDescription = pdatas[_t_utype]; + switch(pComponentPropertyDescription.properUtype) + { + default: + break; + } + + return; + } + + switch(prop.properUtype) + { + case 40001: + Vector3 oldval_direction = direction; + direction = stream.readVector3(); + + if(prop.isBase()) + { + if(inited) + onDirectionChanged(oldval_direction); + } + else + { + if(inWorld) + onDirectionChanged(oldval_direction); + } + + break; + case 41006: + UInt32 oldval_modelID = modelID; + modelID = stream.readUint32(); + + if(prop.isBase()) + { + if(inited) + onModelIDChanged(oldval_modelID); + } + else + { + if(inWorld) + onModelIDChanged(oldval_modelID); + } + + break; + case 41007: + Byte oldval_modelScale = modelScale; + modelScale = stream.readUint8(); + + if(prop.isBase()) + { + if(inited) + onModelScaleChanged(oldval_modelScale); + } + else + { + if(inWorld) + onModelScaleChanged(oldval_modelScale); + } + + break; + case 41003: + string oldval_name = name; + name = stream.readUnicode(); + + if(prop.isBase()) + { + if(inited) + onNameChanged(oldval_name); + } + else + { + if(inWorld) + onNameChanged(oldval_name); + } + + break; + case 40000: + Vector3 oldval_position = position; + position = stream.readVector3(); + + if(prop.isBase()) + { + if(inited) + onPositionChanged(oldval_position); + } + else + { + if(inWorld) + onPositionChanged(oldval_position); + } + + break; + case 40002: + stream.readUint32(); + break; + case 41004: + UInt32 oldval_uid = uid; + uid = stream.readUint32(); + + if(prop.isBase()) + { + if(inited) + onUidChanged(oldval_uid); + } + else + { + if(inWorld) + onUidChanged(oldval_uid); + } + + break; + case 41005: + UInt32 oldval_utype = utype; + utype = stream.readUint32(); + + if(prop.isBase()) + { + if(inited) + onUtypeChanged(oldval_utype); + } + else + { + if(inWorld) + onUtypeChanged(oldval_utype); + } + + break; + default: + break; + }; + } + } + + public override void callPropertysSetMethods() + { + ScriptModule sm = EntityDef.moduledefs["Space"]; + Dictionary pdatas = sm.idpropertys; + + Vector3 oldval_direction = direction; + Property prop_direction = pdatas[2]; + if(prop_direction.isBase()) + { + if(inited && !inWorld) + onDirectionChanged(oldval_direction); + } + else + { + if(inWorld) + { + if(prop_direction.isOwnerOnly() && !isPlayer()) + { + } + else + { + onDirectionChanged(oldval_direction); + } + } + } + + UInt32 oldval_modelID = modelID; + Property prop_modelID = pdatas[4]; + if(prop_modelID.isBase()) + { + if(inited && !inWorld) + onModelIDChanged(oldval_modelID); + } + else + { + if(inWorld) + { + if(prop_modelID.isOwnerOnly() && !isPlayer()) + { + } + else + { + onModelIDChanged(oldval_modelID); + } + } + } + + Byte oldval_modelScale = modelScale; + Property prop_modelScale = pdatas[5]; + if(prop_modelScale.isBase()) + { + if(inited && !inWorld) + onModelScaleChanged(oldval_modelScale); + } + else + { + if(inWorld) + { + if(prop_modelScale.isOwnerOnly() && !isPlayer()) + { + } + else + { + onModelScaleChanged(oldval_modelScale); + } + } + } + + string oldval_name = name; + Property prop_name = pdatas[6]; + if(prop_name.isBase()) + { + if(inited && !inWorld) + onNameChanged(oldval_name); + } + else + { + if(inWorld) + { + if(prop_name.isOwnerOnly() && !isPlayer()) + { + } + else + { + onNameChanged(oldval_name); + } + } + } + + Vector3 oldval_position = position; + Property prop_position = pdatas[1]; + if(prop_position.isBase()) + { + if(inited && !inWorld) + onPositionChanged(oldval_position); + } + else + { + if(inWorld) + { + if(prop_position.isOwnerOnly() && !isPlayer()) + { + } + else + { + onPositionChanged(oldval_position); + } + } + } + + UInt32 oldval_uid = uid; + Property prop_uid = pdatas[7]; + if(prop_uid.isBase()) + { + if(inited && !inWorld) + onUidChanged(oldval_uid); + } + else + { + if(inWorld) + { + if(prop_uid.isOwnerOnly() && !isPlayer()) + { + } + else + { + onUidChanged(oldval_uid); + } + } + } + + UInt32 oldval_utype = utype; + Property prop_utype = pdatas[8]; + if(prop_utype.isBase()) + { + if(inited && !inWorld) + onUtypeChanged(oldval_utype); + } + else + { + if(inWorld) + { + if(prop_utype.isOwnerOnly() && !isPlayer()) + { + } + else + { + onUtypeChanged(oldval_utype); + } + } + } + + } + } } \ No newline at end of file diff --git a/Assets/Plugins/kbengine_unity3d_plugins/SpaceDuplicateBase.cs b/Assets/Plugins/kbengine_unity3d_plugins/SpaceDuplicateBase.cs index fe4b831..7336104 100644 --- a/Assets/Plugins/kbengine_unity3d_plugins/SpaceDuplicateBase.cs +++ b/Assets/Plugins/kbengine_unity3d_plugins/SpaceDuplicateBase.cs @@ -1,447 +1,447 @@ -/* - Generated by KBEngine! - Please do not modify this file! - Please inherit this module, such as: (class SpaceDuplicate : SpaceDuplicateBase) - tools = kbcmd -*/ - -namespace KBEngine -{ - using UnityEngine; - using System; - using System.Collections; - using System.Collections.Generic; - - // defined in */scripts/entity_defs/SpaceDuplicate.def - // Please inherit and implement "class SpaceDuplicate : SpaceDuplicateBase" - public abstract class SpaceDuplicateBase : Entity - { - public EntityBaseEntityCall_SpaceDuplicateBase baseEntityCall = null; - public EntityCellEntityCall_SpaceDuplicateBase cellEntityCall = null; - - public UInt32 modelID = 0; - public virtual void onModelIDChanged(UInt32 oldValue) {} - public Byte modelScale = 30; - public virtual void onModelScaleChanged(Byte oldValue) {} - public string name = ""; - public virtual void onNameChanged(string oldValue) {} - public UInt32 uid = 0; - public virtual void onUidChanged(UInt32 oldValue) {} - public UInt32 utype = 0; - public virtual void onUtypeChanged(UInt32 oldValue) {} - - - public SpaceDuplicateBase() - { - } - - public override void onComponentsEnterworld() - { - } - - public override void onComponentsLeaveworld() - { - } - - public override void onGetBase() - { - baseEntityCall = new EntityBaseEntityCall_SpaceDuplicateBase(id, className); - } - - public override void onGetCell() - { - cellEntityCall = new EntityCellEntityCall_SpaceDuplicateBase(id, className); - } - - public override void onLoseCell() - { - cellEntityCall = null; - } - - public override EntityCall getBaseEntityCall() - { - return baseEntityCall; - } - - public override EntityCall getCellEntityCall() - { - return cellEntityCall; - } - - public override void attachComponents() - { - } - - public override void detachComponents() - { - } - - public override void onRemoteMethodCall(MemoryStream stream) - { - ScriptModule sm = EntityDef.moduledefs["SpaceDuplicate"]; - - UInt16 methodUtype = 0; - UInt16 componentPropertyUType = 0; - - if(sm.usePropertyDescrAlias) - { - componentPropertyUType = stream.readUint8(); - } - else - { - componentPropertyUType = stream.readUint16(); - } - - if(sm.useMethodDescrAlias) - { - methodUtype = stream.readUint8(); - } - else - { - methodUtype = stream.readUint16(); - } - - Method method = null; - - if(componentPropertyUType == 0) - { - method = sm.idmethods[methodUtype]; - } - else - { - Property pComponentPropertyDescription = sm.idpropertys[componentPropertyUType]; - switch(pComponentPropertyDescription.properUtype) - { - default: - break; - } - - return; - } - - switch(method.methodUtype) - { - default: - break; - }; - } - - public override void onUpdatePropertys(MemoryStream stream) - { - ScriptModule sm = EntityDef.moduledefs["SpaceDuplicate"]; - Dictionary pdatas = sm.idpropertys; - - while(stream.length() > 0) - { - UInt16 _t_utype = 0; - UInt16 _t_child_utype = 0; - - { - if(sm.usePropertyDescrAlias) - { - _t_utype = stream.readUint8(); - _t_child_utype = stream.readUint8(); - } - else - { - _t_utype = stream.readUint16(); - _t_child_utype = stream.readUint16(); - } - } - - Property prop = null; - - if(_t_utype == 0) - { - prop = pdatas[_t_child_utype]; - } - else - { - Property pComponentPropertyDescription = pdatas[_t_utype]; - switch(pComponentPropertyDescription.properUtype) - { - default: - break; - } - - return; - } - - switch(prop.properUtype) - { - case 40001: - Vector3 oldval_direction = direction; - direction = stream.readVector3(); - - if(prop.isBase()) - { - if(inited) - onDirectionChanged(oldval_direction); - } - else - { - if(inWorld) - onDirectionChanged(oldval_direction); - } - - break; - case 41006: - UInt32 oldval_modelID = modelID; - modelID = stream.readUint32(); - - if(prop.isBase()) - { - if(inited) - onModelIDChanged(oldval_modelID); - } - else - { - if(inWorld) - onModelIDChanged(oldval_modelID); - } - - break; - case 41007: - Byte oldval_modelScale = modelScale; - modelScale = stream.readUint8(); - - if(prop.isBase()) - { - if(inited) - onModelScaleChanged(oldval_modelScale); - } - else - { - if(inWorld) - onModelScaleChanged(oldval_modelScale); - } - - break; - case 41003: - string oldval_name = name; - name = stream.readUnicode(); - - if(prop.isBase()) - { - if(inited) - onNameChanged(oldval_name); - } - else - { - if(inWorld) - onNameChanged(oldval_name); - } - - break; - case 40000: - Vector3 oldval_position = position; - position = stream.readVector3(); - - if(prop.isBase()) - { - if(inited) - onPositionChanged(oldval_position); - } - else - { - if(inWorld) - onPositionChanged(oldval_position); - } - - break; - case 40002: - stream.readUint32(); - break; - case 41004: - UInt32 oldval_uid = uid; - uid = stream.readUint32(); - - if(prop.isBase()) - { - if(inited) - onUidChanged(oldval_uid); - } - else - { - if(inWorld) - onUidChanged(oldval_uid); - } - - break; - case 41005: - UInt32 oldval_utype = utype; - utype = stream.readUint32(); - - if(prop.isBase()) - { - if(inited) - onUtypeChanged(oldval_utype); - } - else - { - if(inWorld) - onUtypeChanged(oldval_utype); - } - - break; - default: - break; - }; - } - } - - public override void callPropertysSetMethods() - { - ScriptModule sm = EntityDef.moduledefs["SpaceDuplicate"]; - Dictionary pdatas = sm.idpropertys; - - Vector3 oldval_direction = direction; - Property prop_direction = pdatas[2]; - if(prop_direction.isBase()) - { - if(inited && !inWorld) - onDirectionChanged(oldval_direction); - } - else - { - if(inWorld) - { - if(prop_direction.isOwnerOnly() && !isPlayer()) - { - } - else - { - onDirectionChanged(oldval_direction); - } - } - } - - UInt32 oldval_modelID = modelID; - Property prop_modelID = pdatas[4]; - if(prop_modelID.isBase()) - { - if(inited && !inWorld) - onModelIDChanged(oldval_modelID); - } - else - { - if(inWorld) - { - if(prop_modelID.isOwnerOnly() && !isPlayer()) - { - } - else - { - onModelIDChanged(oldval_modelID); - } - } - } - - Byte oldval_modelScale = modelScale; - Property prop_modelScale = pdatas[5]; - if(prop_modelScale.isBase()) - { - if(inited && !inWorld) - onModelScaleChanged(oldval_modelScale); - } - else - { - if(inWorld) - { - if(prop_modelScale.isOwnerOnly() && !isPlayer()) - { - } - else - { - onModelScaleChanged(oldval_modelScale); - } - } - } - - string oldval_name = name; - Property prop_name = pdatas[6]; - if(prop_name.isBase()) - { - if(inited && !inWorld) - onNameChanged(oldval_name); - } - else - { - if(inWorld) - { - if(prop_name.isOwnerOnly() && !isPlayer()) - { - } - else - { - onNameChanged(oldval_name); - } - } - } - - Vector3 oldval_position = position; - Property prop_position = pdatas[1]; - if(prop_position.isBase()) - { - if(inited && !inWorld) - onPositionChanged(oldval_position); - } - else - { - if(inWorld) - { - if(prop_position.isOwnerOnly() && !isPlayer()) - { - } - else - { - onPositionChanged(oldval_position); - } - } - } - - UInt32 oldval_uid = uid; - Property prop_uid = pdatas[7]; - if(prop_uid.isBase()) - { - if(inited && !inWorld) - onUidChanged(oldval_uid); - } - else - { - if(inWorld) - { - if(prop_uid.isOwnerOnly() && !isPlayer()) - { - } - else - { - onUidChanged(oldval_uid); - } - } - } - - UInt32 oldval_utype = utype; - Property prop_utype = pdatas[8]; - if(prop_utype.isBase()) - { - if(inited && !inWorld) - onUtypeChanged(oldval_utype); - } - else - { - if(inWorld) - { - if(prop_utype.isOwnerOnly() && !isPlayer()) - { - } - else - { - onUtypeChanged(oldval_utype); - } - } - } - - } - } +/* + Generated by KBEngine! + Please do not modify this file! + Please inherit this module, such as: (class SpaceDuplicate : SpaceDuplicateBase) + tools = kbcmd +*/ + +namespace KBEngine +{ + using UnityEngine; + using System; + using System.Collections; + using System.Collections.Generic; + + // defined in */scripts/entity_defs/SpaceDuplicate.def + // Please inherit and implement "class SpaceDuplicate : SpaceDuplicateBase" + public abstract class SpaceDuplicateBase : Entity + { + public EntityBaseEntityCall_SpaceDuplicateBase baseEntityCall = null; + public EntityCellEntityCall_SpaceDuplicateBase cellEntityCall = null; + + public UInt32 modelID = 0; + public virtual void onModelIDChanged(UInt32 oldValue) {} + public Byte modelScale = 30; + public virtual void onModelScaleChanged(Byte oldValue) {} + public string name = ""; + public virtual void onNameChanged(string oldValue) {} + public UInt32 uid = 0; + public virtual void onUidChanged(UInt32 oldValue) {} + public UInt32 utype = 0; + public virtual void onUtypeChanged(UInt32 oldValue) {} + + + public SpaceDuplicateBase() + { + } + + public override void onComponentsEnterworld() + { + } + + public override void onComponentsLeaveworld() + { + } + + public override void onGetBase() + { + baseEntityCall = new EntityBaseEntityCall_SpaceDuplicateBase(id, className); + } + + public override void onGetCell() + { + cellEntityCall = new EntityCellEntityCall_SpaceDuplicateBase(id, className); + } + + public override void onLoseCell() + { + cellEntityCall = null; + } + + public override EntityCall getBaseEntityCall() + { + return baseEntityCall; + } + + public override EntityCall getCellEntityCall() + { + return cellEntityCall; + } + + public override void attachComponents() + { + } + + public override void detachComponents() + { + } + + public override void onRemoteMethodCall(MemoryStream stream) + { + ScriptModule sm = EntityDef.moduledefs["SpaceDuplicate"]; + + UInt16 methodUtype = 0; + UInt16 componentPropertyUType = 0; + + if(sm.usePropertyDescrAlias) + { + componentPropertyUType = stream.readUint8(); + } + else + { + componentPropertyUType = stream.readUint16(); + } + + if(sm.useMethodDescrAlias) + { + methodUtype = stream.readUint8(); + } + else + { + methodUtype = stream.readUint16(); + } + + Method method = null; + + if(componentPropertyUType == 0) + { + method = sm.idmethods[methodUtype]; + } + else + { + Property pComponentPropertyDescription = sm.idpropertys[componentPropertyUType]; + switch(pComponentPropertyDescription.properUtype) + { + default: + break; + } + + return; + } + + switch(method.methodUtype) + { + default: + break; + }; + } + + public override void onUpdatePropertys(MemoryStream stream) + { + ScriptModule sm = EntityDef.moduledefs["SpaceDuplicate"]; + Dictionary pdatas = sm.idpropertys; + + while(stream.length() > 0) + { + UInt16 _t_utype = 0; + UInt16 _t_child_utype = 0; + + { + if(sm.usePropertyDescrAlias) + { + _t_utype = stream.readUint8(); + _t_child_utype = stream.readUint8(); + } + else + { + _t_utype = stream.readUint16(); + _t_child_utype = stream.readUint16(); + } + } + + Property prop = null; + + if(_t_utype == 0) + { + prop = pdatas[_t_child_utype]; + } + else + { + Property pComponentPropertyDescription = pdatas[_t_utype]; + switch(pComponentPropertyDescription.properUtype) + { + default: + break; + } + + return; + } + + switch(prop.properUtype) + { + case 40001: + Vector3 oldval_direction = direction; + direction = stream.readVector3(); + + if(prop.isBase()) + { + if(inited) + onDirectionChanged(oldval_direction); + } + else + { + if(inWorld) + onDirectionChanged(oldval_direction); + } + + break; + case 41006: + UInt32 oldval_modelID = modelID; + modelID = stream.readUint32(); + + if(prop.isBase()) + { + if(inited) + onModelIDChanged(oldval_modelID); + } + else + { + if(inWorld) + onModelIDChanged(oldval_modelID); + } + + break; + case 41007: + Byte oldval_modelScale = modelScale; + modelScale = stream.readUint8(); + + if(prop.isBase()) + { + if(inited) + onModelScaleChanged(oldval_modelScale); + } + else + { + if(inWorld) + onModelScaleChanged(oldval_modelScale); + } + + break; + case 41003: + string oldval_name = name; + name = stream.readUnicode(); + + if(prop.isBase()) + { + if(inited) + onNameChanged(oldval_name); + } + else + { + if(inWorld) + onNameChanged(oldval_name); + } + + break; + case 40000: + Vector3 oldval_position = position; + position = stream.readVector3(); + + if(prop.isBase()) + { + if(inited) + onPositionChanged(oldval_position); + } + else + { + if(inWorld) + onPositionChanged(oldval_position); + } + + break; + case 40002: + stream.readUint32(); + break; + case 41004: + UInt32 oldval_uid = uid; + uid = stream.readUint32(); + + if(prop.isBase()) + { + if(inited) + onUidChanged(oldval_uid); + } + else + { + if(inWorld) + onUidChanged(oldval_uid); + } + + break; + case 41005: + UInt32 oldval_utype = utype; + utype = stream.readUint32(); + + if(prop.isBase()) + { + if(inited) + onUtypeChanged(oldval_utype); + } + else + { + if(inWorld) + onUtypeChanged(oldval_utype); + } + + break; + default: + break; + }; + } + } + + public override void callPropertysSetMethods() + { + ScriptModule sm = EntityDef.moduledefs["SpaceDuplicate"]; + Dictionary pdatas = sm.idpropertys; + + Vector3 oldval_direction = direction; + Property prop_direction = pdatas[2]; + if(prop_direction.isBase()) + { + if(inited && !inWorld) + onDirectionChanged(oldval_direction); + } + else + { + if(inWorld) + { + if(prop_direction.isOwnerOnly() && !isPlayer()) + { + } + else + { + onDirectionChanged(oldval_direction); + } + } + } + + UInt32 oldval_modelID = modelID; + Property prop_modelID = pdatas[4]; + if(prop_modelID.isBase()) + { + if(inited && !inWorld) + onModelIDChanged(oldval_modelID); + } + else + { + if(inWorld) + { + if(prop_modelID.isOwnerOnly() && !isPlayer()) + { + } + else + { + onModelIDChanged(oldval_modelID); + } + } + } + + Byte oldval_modelScale = modelScale; + Property prop_modelScale = pdatas[5]; + if(prop_modelScale.isBase()) + { + if(inited && !inWorld) + onModelScaleChanged(oldval_modelScale); + } + else + { + if(inWorld) + { + if(prop_modelScale.isOwnerOnly() && !isPlayer()) + { + } + else + { + onModelScaleChanged(oldval_modelScale); + } + } + } + + string oldval_name = name; + Property prop_name = pdatas[6]; + if(prop_name.isBase()) + { + if(inited && !inWorld) + onNameChanged(oldval_name); + } + else + { + if(inWorld) + { + if(prop_name.isOwnerOnly() && !isPlayer()) + { + } + else + { + onNameChanged(oldval_name); + } + } + } + + Vector3 oldval_position = position; + Property prop_position = pdatas[1]; + if(prop_position.isBase()) + { + if(inited && !inWorld) + onPositionChanged(oldval_position); + } + else + { + if(inWorld) + { + if(prop_position.isOwnerOnly() && !isPlayer()) + { + } + else + { + onPositionChanged(oldval_position); + } + } + } + + UInt32 oldval_uid = uid; + Property prop_uid = pdatas[7]; + if(prop_uid.isBase()) + { + if(inited && !inWorld) + onUidChanged(oldval_uid); + } + else + { + if(inWorld) + { + if(prop_uid.isOwnerOnly() && !isPlayer()) + { + } + else + { + onUidChanged(oldval_uid); + } + } + } + + UInt32 oldval_utype = utype; + Property prop_utype = pdatas[8]; + if(prop_utype.isBase()) + { + if(inited && !inWorld) + onUtypeChanged(oldval_utype); + } + else + { + if(inWorld) + { + if(prop_utype.isOwnerOnly() && !isPlayer()) + { + } + else + { + onUtypeChanged(oldval_utype); + } + } + } + + } + } } \ No newline at end of file diff --git a/Assets/Plugins/kbengine_unity3d_plugins/SpacesBase.cs b/Assets/Plugins/kbengine_unity3d_plugins/SpacesBase.cs index 84f8e09..51da96c 100644 --- a/Assets/Plugins/kbengine_unity3d_plugins/SpacesBase.cs +++ b/Assets/Plugins/kbengine_unity3d_plugins/SpacesBase.cs @@ -1,447 +1,447 @@ -/* - Generated by KBEngine! - Please do not modify this file! - Please inherit this module, such as: (class Spaces : SpacesBase) - tools = kbcmd -*/ - -namespace KBEngine -{ - using UnityEngine; - using System; - using System.Collections; - using System.Collections.Generic; - - // defined in */scripts/entity_defs/Spaces.def - // Please inherit and implement "class Spaces : SpacesBase" - public abstract class SpacesBase : Entity - { - public EntityBaseEntityCall_SpacesBase baseEntityCall = null; - public EntityCellEntityCall_SpacesBase cellEntityCall = null; - - public UInt32 modelID = 0; - public virtual void onModelIDChanged(UInt32 oldValue) {} - public Byte modelScale = 30; - public virtual void onModelScaleChanged(Byte oldValue) {} - public string name = ""; - public virtual void onNameChanged(string oldValue) {} - public UInt32 uid = 0; - public virtual void onUidChanged(UInt32 oldValue) {} - public UInt32 utype = 0; - public virtual void onUtypeChanged(UInt32 oldValue) {} - - - public SpacesBase() - { - } - - public override void onComponentsEnterworld() - { - } - - public override void onComponentsLeaveworld() - { - } - - public override void onGetBase() - { - baseEntityCall = new EntityBaseEntityCall_SpacesBase(id, className); - } - - public override void onGetCell() - { - cellEntityCall = new EntityCellEntityCall_SpacesBase(id, className); - } - - public override void onLoseCell() - { - cellEntityCall = null; - } - - public override EntityCall getBaseEntityCall() - { - return baseEntityCall; - } - - public override EntityCall getCellEntityCall() - { - return cellEntityCall; - } - - public override void attachComponents() - { - } - - public override void detachComponents() - { - } - - public override void onRemoteMethodCall(MemoryStream stream) - { - ScriptModule sm = EntityDef.moduledefs["Spaces"]; - - UInt16 methodUtype = 0; - UInt16 componentPropertyUType = 0; - - if(sm.usePropertyDescrAlias) - { - componentPropertyUType = stream.readUint8(); - } - else - { - componentPropertyUType = stream.readUint16(); - } - - if(sm.useMethodDescrAlias) - { - methodUtype = stream.readUint8(); - } - else - { - methodUtype = stream.readUint16(); - } - - Method method = null; - - if(componentPropertyUType == 0) - { - method = sm.idmethods[methodUtype]; - } - else - { - Property pComponentPropertyDescription = sm.idpropertys[componentPropertyUType]; - switch(pComponentPropertyDescription.properUtype) - { - default: - break; - } - - return; - } - - switch(method.methodUtype) - { - default: - break; - }; - } - - public override void onUpdatePropertys(MemoryStream stream) - { - ScriptModule sm = EntityDef.moduledefs["Spaces"]; - Dictionary pdatas = sm.idpropertys; - - while(stream.length() > 0) - { - UInt16 _t_utype = 0; - UInt16 _t_child_utype = 0; - - { - if(sm.usePropertyDescrAlias) - { - _t_utype = stream.readUint8(); - _t_child_utype = stream.readUint8(); - } - else - { - _t_utype = stream.readUint16(); - _t_child_utype = stream.readUint16(); - } - } - - Property prop = null; - - if(_t_utype == 0) - { - prop = pdatas[_t_child_utype]; - } - else - { - Property pComponentPropertyDescription = pdatas[_t_utype]; - switch(pComponentPropertyDescription.properUtype) - { - default: - break; - } - - return; - } - - switch(prop.properUtype) - { - case 40001: - Vector3 oldval_direction = direction; - direction = stream.readVector3(); - - if(prop.isBase()) - { - if(inited) - onDirectionChanged(oldval_direction); - } - else - { - if(inWorld) - onDirectionChanged(oldval_direction); - } - - break; - case 41006: - UInt32 oldval_modelID = modelID; - modelID = stream.readUint32(); - - if(prop.isBase()) - { - if(inited) - onModelIDChanged(oldval_modelID); - } - else - { - if(inWorld) - onModelIDChanged(oldval_modelID); - } - - break; - case 41007: - Byte oldval_modelScale = modelScale; - modelScale = stream.readUint8(); - - if(prop.isBase()) - { - if(inited) - onModelScaleChanged(oldval_modelScale); - } - else - { - if(inWorld) - onModelScaleChanged(oldval_modelScale); - } - - break; - case 41003: - string oldval_name = name; - name = stream.readUnicode(); - - if(prop.isBase()) - { - if(inited) - onNameChanged(oldval_name); - } - else - { - if(inWorld) - onNameChanged(oldval_name); - } - - break; - case 40000: - Vector3 oldval_position = position; - position = stream.readVector3(); - - if(prop.isBase()) - { - if(inited) - onPositionChanged(oldval_position); - } - else - { - if(inWorld) - onPositionChanged(oldval_position); - } - - break; - case 40002: - stream.readUint32(); - break; - case 41004: - UInt32 oldval_uid = uid; - uid = stream.readUint32(); - - if(prop.isBase()) - { - if(inited) - onUidChanged(oldval_uid); - } - else - { - if(inWorld) - onUidChanged(oldval_uid); - } - - break; - case 41005: - UInt32 oldval_utype = utype; - utype = stream.readUint32(); - - if(prop.isBase()) - { - if(inited) - onUtypeChanged(oldval_utype); - } - else - { - if(inWorld) - onUtypeChanged(oldval_utype); - } - - break; - default: - break; - }; - } - } - - public override void callPropertysSetMethods() - { - ScriptModule sm = EntityDef.moduledefs["Spaces"]; - Dictionary pdatas = sm.idpropertys; - - Vector3 oldval_direction = direction; - Property prop_direction = pdatas[2]; - if(prop_direction.isBase()) - { - if(inited && !inWorld) - onDirectionChanged(oldval_direction); - } - else - { - if(inWorld) - { - if(prop_direction.isOwnerOnly() && !isPlayer()) - { - } - else - { - onDirectionChanged(oldval_direction); - } - } - } - - UInt32 oldval_modelID = modelID; - Property prop_modelID = pdatas[4]; - if(prop_modelID.isBase()) - { - if(inited && !inWorld) - onModelIDChanged(oldval_modelID); - } - else - { - if(inWorld) - { - if(prop_modelID.isOwnerOnly() && !isPlayer()) - { - } - else - { - onModelIDChanged(oldval_modelID); - } - } - } - - Byte oldval_modelScale = modelScale; - Property prop_modelScale = pdatas[5]; - if(prop_modelScale.isBase()) - { - if(inited && !inWorld) - onModelScaleChanged(oldval_modelScale); - } - else - { - if(inWorld) - { - if(prop_modelScale.isOwnerOnly() && !isPlayer()) - { - } - else - { - onModelScaleChanged(oldval_modelScale); - } - } - } - - string oldval_name = name; - Property prop_name = pdatas[6]; - if(prop_name.isBase()) - { - if(inited && !inWorld) - onNameChanged(oldval_name); - } - else - { - if(inWorld) - { - if(prop_name.isOwnerOnly() && !isPlayer()) - { - } - else - { - onNameChanged(oldval_name); - } - } - } - - Vector3 oldval_position = position; - Property prop_position = pdatas[1]; - if(prop_position.isBase()) - { - if(inited && !inWorld) - onPositionChanged(oldval_position); - } - else - { - if(inWorld) - { - if(prop_position.isOwnerOnly() && !isPlayer()) - { - } - else - { - onPositionChanged(oldval_position); - } - } - } - - UInt32 oldval_uid = uid; - Property prop_uid = pdatas[7]; - if(prop_uid.isBase()) - { - if(inited && !inWorld) - onUidChanged(oldval_uid); - } - else - { - if(inWorld) - { - if(prop_uid.isOwnerOnly() && !isPlayer()) - { - } - else - { - onUidChanged(oldval_uid); - } - } - } - - UInt32 oldval_utype = utype; - Property prop_utype = pdatas[8]; - if(prop_utype.isBase()) - { - if(inited && !inWorld) - onUtypeChanged(oldval_utype); - } - else - { - if(inWorld) - { - if(prop_utype.isOwnerOnly() && !isPlayer()) - { - } - else - { - onUtypeChanged(oldval_utype); - } - } - } - - } - } +/* + Generated by KBEngine! + Please do not modify this file! + Please inherit this module, such as: (class Spaces : SpacesBase) + tools = kbcmd +*/ + +namespace KBEngine +{ + using UnityEngine; + using System; + using System.Collections; + using System.Collections.Generic; + + // defined in */scripts/entity_defs/Spaces.def + // Please inherit and implement "class Spaces : SpacesBase" + public abstract class SpacesBase : Entity + { + public EntityBaseEntityCall_SpacesBase baseEntityCall = null; + public EntityCellEntityCall_SpacesBase cellEntityCall = null; + + public UInt32 modelID = 0; + public virtual void onModelIDChanged(UInt32 oldValue) {} + public Byte modelScale = 30; + public virtual void onModelScaleChanged(Byte oldValue) {} + public string name = ""; + public virtual void onNameChanged(string oldValue) {} + public UInt32 uid = 0; + public virtual void onUidChanged(UInt32 oldValue) {} + public UInt32 utype = 0; + public virtual void onUtypeChanged(UInt32 oldValue) {} + + + public SpacesBase() + { + } + + public override void onComponentsEnterworld() + { + } + + public override void onComponentsLeaveworld() + { + } + + public override void onGetBase() + { + baseEntityCall = new EntityBaseEntityCall_SpacesBase(id, className); + } + + public override void onGetCell() + { + cellEntityCall = new EntityCellEntityCall_SpacesBase(id, className); + } + + public override void onLoseCell() + { + cellEntityCall = null; + } + + public override EntityCall getBaseEntityCall() + { + return baseEntityCall; + } + + public override EntityCall getCellEntityCall() + { + return cellEntityCall; + } + + public override void attachComponents() + { + } + + public override void detachComponents() + { + } + + public override void onRemoteMethodCall(MemoryStream stream) + { + ScriptModule sm = EntityDef.moduledefs["Spaces"]; + + UInt16 methodUtype = 0; + UInt16 componentPropertyUType = 0; + + if(sm.usePropertyDescrAlias) + { + componentPropertyUType = stream.readUint8(); + } + else + { + componentPropertyUType = stream.readUint16(); + } + + if(sm.useMethodDescrAlias) + { + methodUtype = stream.readUint8(); + } + else + { + methodUtype = stream.readUint16(); + } + + Method method = null; + + if(componentPropertyUType == 0) + { + method = sm.idmethods[methodUtype]; + } + else + { + Property pComponentPropertyDescription = sm.idpropertys[componentPropertyUType]; + switch(pComponentPropertyDescription.properUtype) + { + default: + break; + } + + return; + } + + switch(method.methodUtype) + { + default: + break; + }; + } + + public override void onUpdatePropertys(MemoryStream stream) + { + ScriptModule sm = EntityDef.moduledefs["Spaces"]; + Dictionary pdatas = sm.idpropertys; + + while(stream.length() > 0) + { + UInt16 _t_utype = 0; + UInt16 _t_child_utype = 0; + + { + if(sm.usePropertyDescrAlias) + { + _t_utype = stream.readUint8(); + _t_child_utype = stream.readUint8(); + } + else + { + _t_utype = stream.readUint16(); + _t_child_utype = stream.readUint16(); + } + } + + Property prop = null; + + if(_t_utype == 0) + { + prop = pdatas[_t_child_utype]; + } + else + { + Property pComponentPropertyDescription = pdatas[_t_utype]; + switch(pComponentPropertyDescription.properUtype) + { + default: + break; + } + + return; + } + + switch(prop.properUtype) + { + case 40001: + Vector3 oldval_direction = direction; + direction = stream.readVector3(); + + if(prop.isBase()) + { + if(inited) + onDirectionChanged(oldval_direction); + } + else + { + if(inWorld) + onDirectionChanged(oldval_direction); + } + + break; + case 41006: + UInt32 oldval_modelID = modelID; + modelID = stream.readUint32(); + + if(prop.isBase()) + { + if(inited) + onModelIDChanged(oldval_modelID); + } + else + { + if(inWorld) + onModelIDChanged(oldval_modelID); + } + + break; + case 41007: + Byte oldval_modelScale = modelScale; + modelScale = stream.readUint8(); + + if(prop.isBase()) + { + if(inited) + onModelScaleChanged(oldval_modelScale); + } + else + { + if(inWorld) + onModelScaleChanged(oldval_modelScale); + } + + break; + case 41003: + string oldval_name = name; + name = stream.readUnicode(); + + if(prop.isBase()) + { + if(inited) + onNameChanged(oldval_name); + } + else + { + if(inWorld) + onNameChanged(oldval_name); + } + + break; + case 40000: + Vector3 oldval_position = position; + position = stream.readVector3(); + + if(prop.isBase()) + { + if(inited) + onPositionChanged(oldval_position); + } + else + { + if(inWorld) + onPositionChanged(oldval_position); + } + + break; + case 40002: + stream.readUint32(); + break; + case 41004: + UInt32 oldval_uid = uid; + uid = stream.readUint32(); + + if(prop.isBase()) + { + if(inited) + onUidChanged(oldval_uid); + } + else + { + if(inWorld) + onUidChanged(oldval_uid); + } + + break; + case 41005: + UInt32 oldval_utype = utype; + utype = stream.readUint32(); + + if(prop.isBase()) + { + if(inited) + onUtypeChanged(oldval_utype); + } + else + { + if(inWorld) + onUtypeChanged(oldval_utype); + } + + break; + default: + break; + }; + } + } + + public override void callPropertysSetMethods() + { + ScriptModule sm = EntityDef.moduledefs["Spaces"]; + Dictionary pdatas = sm.idpropertys; + + Vector3 oldval_direction = direction; + Property prop_direction = pdatas[2]; + if(prop_direction.isBase()) + { + if(inited && !inWorld) + onDirectionChanged(oldval_direction); + } + else + { + if(inWorld) + { + if(prop_direction.isOwnerOnly() && !isPlayer()) + { + } + else + { + onDirectionChanged(oldval_direction); + } + } + } + + UInt32 oldval_modelID = modelID; + Property prop_modelID = pdatas[4]; + if(prop_modelID.isBase()) + { + if(inited && !inWorld) + onModelIDChanged(oldval_modelID); + } + else + { + if(inWorld) + { + if(prop_modelID.isOwnerOnly() && !isPlayer()) + { + } + else + { + onModelIDChanged(oldval_modelID); + } + } + } + + Byte oldval_modelScale = modelScale; + Property prop_modelScale = pdatas[5]; + if(prop_modelScale.isBase()) + { + if(inited && !inWorld) + onModelScaleChanged(oldval_modelScale); + } + else + { + if(inWorld) + { + if(prop_modelScale.isOwnerOnly() && !isPlayer()) + { + } + else + { + onModelScaleChanged(oldval_modelScale); + } + } + } + + string oldval_name = name; + Property prop_name = pdatas[6]; + if(prop_name.isBase()) + { + if(inited && !inWorld) + onNameChanged(oldval_name); + } + else + { + if(inWorld) + { + if(prop_name.isOwnerOnly() && !isPlayer()) + { + } + else + { + onNameChanged(oldval_name); + } + } + } + + Vector3 oldval_position = position; + Property prop_position = pdatas[1]; + if(prop_position.isBase()) + { + if(inited && !inWorld) + onPositionChanged(oldval_position); + } + else + { + if(inWorld) + { + if(prop_position.isOwnerOnly() && !isPlayer()) + { + } + else + { + onPositionChanged(oldval_position); + } + } + } + + UInt32 oldval_uid = uid; + Property prop_uid = pdatas[7]; + if(prop_uid.isBase()) + { + if(inited && !inWorld) + onUidChanged(oldval_uid); + } + else + { + if(inWorld) + { + if(prop_uid.isOwnerOnly() && !isPlayer()) + { + } + else + { + onUidChanged(oldval_uid); + } + } + } + + UInt32 oldval_utype = utype; + Property prop_utype = pdatas[8]; + if(prop_utype.isBase()) + { + if(inited && !inWorld) + onUtypeChanged(oldval_utype); + } + else + { + if(inWorld) + { + if(prop_utype.isOwnerOnly() && !isPlayer()) + { + } + else + { + onUtypeChanged(oldval_utype); + } + } + } + + } + } } \ No newline at end of file diff --git a/Assets/Plugins/kbengine_unity3d_plugins/SpawnPointBase.cs b/Assets/Plugins/kbengine_unity3d_plugins/SpawnPointBase.cs index 63a9b71..8206c57 100644 --- a/Assets/Plugins/kbengine_unity3d_plugins/SpawnPointBase.cs +++ b/Assets/Plugins/kbengine_unity3d_plugins/SpawnPointBase.cs @@ -1,447 +1,447 @@ -/* - Generated by KBEngine! - Please do not modify this file! - Please inherit this module, such as: (class SpawnPoint : SpawnPointBase) - tools = kbcmd -*/ - -namespace KBEngine -{ - using UnityEngine; - using System; - using System.Collections; - using System.Collections.Generic; - - // defined in */scripts/entity_defs/SpawnPoint.def - // Please inherit and implement "class SpawnPoint : SpawnPointBase" - public abstract class SpawnPointBase : Entity - { - public EntityBaseEntityCall_SpawnPointBase baseEntityCall = null; - public EntityCellEntityCall_SpawnPointBase cellEntityCall = null; - - public UInt32 modelID = 0; - public virtual void onModelIDChanged(UInt32 oldValue) {} - public Byte modelScale = 30; - public virtual void onModelScaleChanged(Byte oldValue) {} - public string name = ""; - public virtual void onNameChanged(string oldValue) {} - public UInt32 uid = 0; - public virtual void onUidChanged(UInt32 oldValue) {} - public UInt32 utype = 0; - public virtual void onUtypeChanged(UInt32 oldValue) {} - - - public SpawnPointBase() - { - } - - public override void onComponentsEnterworld() - { - } - - public override void onComponentsLeaveworld() - { - } - - public override void onGetBase() - { - baseEntityCall = new EntityBaseEntityCall_SpawnPointBase(id, className); - } - - public override void onGetCell() - { - cellEntityCall = new EntityCellEntityCall_SpawnPointBase(id, className); - } - - public override void onLoseCell() - { - cellEntityCall = null; - } - - public override EntityCall getBaseEntityCall() - { - return baseEntityCall; - } - - public override EntityCall getCellEntityCall() - { - return cellEntityCall; - } - - public override void attachComponents() - { - } - - public override void detachComponents() - { - } - - public override void onRemoteMethodCall(MemoryStream stream) - { - ScriptModule sm = EntityDef.moduledefs["SpawnPoint"]; - - UInt16 methodUtype = 0; - UInt16 componentPropertyUType = 0; - - if(sm.usePropertyDescrAlias) - { - componentPropertyUType = stream.readUint8(); - } - else - { - componentPropertyUType = stream.readUint16(); - } - - if(sm.useMethodDescrAlias) - { - methodUtype = stream.readUint8(); - } - else - { - methodUtype = stream.readUint16(); - } - - Method method = null; - - if(componentPropertyUType == 0) - { - method = sm.idmethods[methodUtype]; - } - else - { - Property pComponentPropertyDescription = sm.idpropertys[componentPropertyUType]; - switch(pComponentPropertyDescription.properUtype) - { - default: - break; - } - - return; - } - - switch(method.methodUtype) - { - default: - break; - }; - } - - public override void onUpdatePropertys(MemoryStream stream) - { - ScriptModule sm = EntityDef.moduledefs["SpawnPoint"]; - Dictionary pdatas = sm.idpropertys; - - while(stream.length() > 0) - { - UInt16 _t_utype = 0; - UInt16 _t_child_utype = 0; - - { - if(sm.usePropertyDescrAlias) - { - _t_utype = stream.readUint8(); - _t_child_utype = stream.readUint8(); - } - else - { - _t_utype = stream.readUint16(); - _t_child_utype = stream.readUint16(); - } - } - - Property prop = null; - - if(_t_utype == 0) - { - prop = pdatas[_t_child_utype]; - } - else - { - Property pComponentPropertyDescription = pdatas[_t_utype]; - switch(pComponentPropertyDescription.properUtype) - { - default: - break; - } - - return; - } - - switch(prop.properUtype) - { - case 40001: - Vector3 oldval_direction = direction; - direction = stream.readVector3(); - - if(prop.isBase()) - { - if(inited) - onDirectionChanged(oldval_direction); - } - else - { - if(inWorld) - onDirectionChanged(oldval_direction); - } - - break; - case 41006: - UInt32 oldval_modelID = modelID; - modelID = stream.readUint32(); - - if(prop.isBase()) - { - if(inited) - onModelIDChanged(oldval_modelID); - } - else - { - if(inWorld) - onModelIDChanged(oldval_modelID); - } - - break; - case 41007: - Byte oldval_modelScale = modelScale; - modelScale = stream.readUint8(); - - if(prop.isBase()) - { - if(inited) - onModelScaleChanged(oldval_modelScale); - } - else - { - if(inWorld) - onModelScaleChanged(oldval_modelScale); - } - - break; - case 41003: - string oldval_name = name; - name = stream.readUnicode(); - - if(prop.isBase()) - { - if(inited) - onNameChanged(oldval_name); - } - else - { - if(inWorld) - onNameChanged(oldval_name); - } - - break; - case 40000: - Vector3 oldval_position = position; - position = stream.readVector3(); - - if(prop.isBase()) - { - if(inited) - onPositionChanged(oldval_position); - } - else - { - if(inWorld) - onPositionChanged(oldval_position); - } - - break; - case 40002: - stream.readUint32(); - break; - case 41004: - UInt32 oldval_uid = uid; - uid = stream.readUint32(); - - if(prop.isBase()) - { - if(inited) - onUidChanged(oldval_uid); - } - else - { - if(inWorld) - onUidChanged(oldval_uid); - } - - break; - case 41005: - UInt32 oldval_utype = utype; - utype = stream.readUint32(); - - if(prop.isBase()) - { - if(inited) - onUtypeChanged(oldval_utype); - } - else - { - if(inWorld) - onUtypeChanged(oldval_utype); - } - - break; - default: - break; - }; - } - } - - public override void callPropertysSetMethods() - { - ScriptModule sm = EntityDef.moduledefs["SpawnPoint"]; - Dictionary pdatas = sm.idpropertys; - - Vector3 oldval_direction = direction; - Property prop_direction = pdatas[2]; - if(prop_direction.isBase()) - { - if(inited && !inWorld) - onDirectionChanged(oldval_direction); - } - else - { - if(inWorld) - { - if(prop_direction.isOwnerOnly() && !isPlayer()) - { - } - else - { - onDirectionChanged(oldval_direction); - } - } - } - - UInt32 oldval_modelID = modelID; - Property prop_modelID = pdatas[4]; - if(prop_modelID.isBase()) - { - if(inited && !inWorld) - onModelIDChanged(oldval_modelID); - } - else - { - if(inWorld) - { - if(prop_modelID.isOwnerOnly() && !isPlayer()) - { - } - else - { - onModelIDChanged(oldval_modelID); - } - } - } - - Byte oldval_modelScale = modelScale; - Property prop_modelScale = pdatas[5]; - if(prop_modelScale.isBase()) - { - if(inited && !inWorld) - onModelScaleChanged(oldval_modelScale); - } - else - { - if(inWorld) - { - if(prop_modelScale.isOwnerOnly() && !isPlayer()) - { - } - else - { - onModelScaleChanged(oldval_modelScale); - } - } - } - - string oldval_name = name; - Property prop_name = pdatas[6]; - if(prop_name.isBase()) - { - if(inited && !inWorld) - onNameChanged(oldval_name); - } - else - { - if(inWorld) - { - if(prop_name.isOwnerOnly() && !isPlayer()) - { - } - else - { - onNameChanged(oldval_name); - } - } - } - - Vector3 oldval_position = position; - Property prop_position = pdatas[1]; - if(prop_position.isBase()) - { - if(inited && !inWorld) - onPositionChanged(oldval_position); - } - else - { - if(inWorld) - { - if(prop_position.isOwnerOnly() && !isPlayer()) - { - } - else - { - onPositionChanged(oldval_position); - } - } - } - - UInt32 oldval_uid = uid; - Property prop_uid = pdatas[7]; - if(prop_uid.isBase()) - { - if(inited && !inWorld) - onUidChanged(oldval_uid); - } - else - { - if(inWorld) - { - if(prop_uid.isOwnerOnly() && !isPlayer()) - { - } - else - { - onUidChanged(oldval_uid); - } - } - } - - UInt32 oldval_utype = utype; - Property prop_utype = pdatas[8]; - if(prop_utype.isBase()) - { - if(inited && !inWorld) - onUtypeChanged(oldval_utype); - } - else - { - if(inWorld) - { - if(prop_utype.isOwnerOnly() && !isPlayer()) - { - } - else - { - onUtypeChanged(oldval_utype); - } - } - } - - } - } +/* + Generated by KBEngine! + Please do not modify this file! + Please inherit this module, such as: (class SpawnPoint : SpawnPointBase) + tools = kbcmd +*/ + +namespace KBEngine +{ + using UnityEngine; + using System; + using System.Collections; + using System.Collections.Generic; + + // defined in */scripts/entity_defs/SpawnPoint.def + // Please inherit and implement "class SpawnPoint : SpawnPointBase" + public abstract class SpawnPointBase : Entity + { + public EntityBaseEntityCall_SpawnPointBase baseEntityCall = null; + public EntityCellEntityCall_SpawnPointBase cellEntityCall = null; + + public UInt32 modelID = 0; + public virtual void onModelIDChanged(UInt32 oldValue) {} + public Byte modelScale = 30; + public virtual void onModelScaleChanged(Byte oldValue) {} + public string name = ""; + public virtual void onNameChanged(string oldValue) {} + public UInt32 uid = 0; + public virtual void onUidChanged(UInt32 oldValue) {} + public UInt32 utype = 0; + public virtual void onUtypeChanged(UInt32 oldValue) {} + + + public SpawnPointBase() + { + } + + public override void onComponentsEnterworld() + { + } + + public override void onComponentsLeaveworld() + { + } + + public override void onGetBase() + { + baseEntityCall = new EntityBaseEntityCall_SpawnPointBase(id, className); + } + + public override void onGetCell() + { + cellEntityCall = new EntityCellEntityCall_SpawnPointBase(id, className); + } + + public override void onLoseCell() + { + cellEntityCall = null; + } + + public override EntityCall getBaseEntityCall() + { + return baseEntityCall; + } + + public override EntityCall getCellEntityCall() + { + return cellEntityCall; + } + + public override void attachComponents() + { + } + + public override void detachComponents() + { + } + + public override void onRemoteMethodCall(MemoryStream stream) + { + ScriptModule sm = EntityDef.moduledefs["SpawnPoint"]; + + UInt16 methodUtype = 0; + UInt16 componentPropertyUType = 0; + + if(sm.usePropertyDescrAlias) + { + componentPropertyUType = stream.readUint8(); + } + else + { + componentPropertyUType = stream.readUint16(); + } + + if(sm.useMethodDescrAlias) + { + methodUtype = stream.readUint8(); + } + else + { + methodUtype = stream.readUint16(); + } + + Method method = null; + + if(componentPropertyUType == 0) + { + method = sm.idmethods[methodUtype]; + } + else + { + Property pComponentPropertyDescription = sm.idpropertys[componentPropertyUType]; + switch(pComponentPropertyDescription.properUtype) + { + default: + break; + } + + return; + } + + switch(method.methodUtype) + { + default: + break; + }; + } + + public override void onUpdatePropertys(MemoryStream stream) + { + ScriptModule sm = EntityDef.moduledefs["SpawnPoint"]; + Dictionary pdatas = sm.idpropertys; + + while(stream.length() > 0) + { + UInt16 _t_utype = 0; + UInt16 _t_child_utype = 0; + + { + if(sm.usePropertyDescrAlias) + { + _t_utype = stream.readUint8(); + _t_child_utype = stream.readUint8(); + } + else + { + _t_utype = stream.readUint16(); + _t_child_utype = stream.readUint16(); + } + } + + Property prop = null; + + if(_t_utype == 0) + { + prop = pdatas[_t_child_utype]; + } + else + { + Property pComponentPropertyDescription = pdatas[_t_utype]; + switch(pComponentPropertyDescription.properUtype) + { + default: + break; + } + + return; + } + + switch(prop.properUtype) + { + case 40001: + Vector3 oldval_direction = direction; + direction = stream.readVector3(); + + if(prop.isBase()) + { + if(inited) + onDirectionChanged(oldval_direction); + } + else + { + if(inWorld) + onDirectionChanged(oldval_direction); + } + + break; + case 41006: + UInt32 oldval_modelID = modelID; + modelID = stream.readUint32(); + + if(prop.isBase()) + { + if(inited) + onModelIDChanged(oldval_modelID); + } + else + { + if(inWorld) + onModelIDChanged(oldval_modelID); + } + + break; + case 41007: + Byte oldval_modelScale = modelScale; + modelScale = stream.readUint8(); + + if(prop.isBase()) + { + if(inited) + onModelScaleChanged(oldval_modelScale); + } + else + { + if(inWorld) + onModelScaleChanged(oldval_modelScale); + } + + break; + case 41003: + string oldval_name = name; + name = stream.readUnicode(); + + if(prop.isBase()) + { + if(inited) + onNameChanged(oldval_name); + } + else + { + if(inWorld) + onNameChanged(oldval_name); + } + + break; + case 40000: + Vector3 oldval_position = position; + position = stream.readVector3(); + + if(prop.isBase()) + { + if(inited) + onPositionChanged(oldval_position); + } + else + { + if(inWorld) + onPositionChanged(oldval_position); + } + + break; + case 40002: + stream.readUint32(); + break; + case 41004: + UInt32 oldval_uid = uid; + uid = stream.readUint32(); + + if(prop.isBase()) + { + if(inited) + onUidChanged(oldval_uid); + } + else + { + if(inWorld) + onUidChanged(oldval_uid); + } + + break; + case 41005: + UInt32 oldval_utype = utype; + utype = stream.readUint32(); + + if(prop.isBase()) + { + if(inited) + onUtypeChanged(oldval_utype); + } + else + { + if(inWorld) + onUtypeChanged(oldval_utype); + } + + break; + default: + break; + }; + } + } + + public override void callPropertysSetMethods() + { + ScriptModule sm = EntityDef.moduledefs["SpawnPoint"]; + Dictionary pdatas = sm.idpropertys; + + Vector3 oldval_direction = direction; + Property prop_direction = pdatas[2]; + if(prop_direction.isBase()) + { + if(inited && !inWorld) + onDirectionChanged(oldval_direction); + } + else + { + if(inWorld) + { + if(prop_direction.isOwnerOnly() && !isPlayer()) + { + } + else + { + onDirectionChanged(oldval_direction); + } + } + } + + UInt32 oldval_modelID = modelID; + Property prop_modelID = pdatas[4]; + if(prop_modelID.isBase()) + { + if(inited && !inWorld) + onModelIDChanged(oldval_modelID); + } + else + { + if(inWorld) + { + if(prop_modelID.isOwnerOnly() && !isPlayer()) + { + } + else + { + onModelIDChanged(oldval_modelID); + } + } + } + + Byte oldval_modelScale = modelScale; + Property prop_modelScale = pdatas[5]; + if(prop_modelScale.isBase()) + { + if(inited && !inWorld) + onModelScaleChanged(oldval_modelScale); + } + else + { + if(inWorld) + { + if(prop_modelScale.isOwnerOnly() && !isPlayer()) + { + } + else + { + onModelScaleChanged(oldval_modelScale); + } + } + } + + string oldval_name = name; + Property prop_name = pdatas[6]; + if(prop_name.isBase()) + { + if(inited && !inWorld) + onNameChanged(oldval_name); + } + else + { + if(inWorld) + { + if(prop_name.isOwnerOnly() && !isPlayer()) + { + } + else + { + onNameChanged(oldval_name); + } + } + } + + Vector3 oldval_position = position; + Property prop_position = pdatas[1]; + if(prop_position.isBase()) + { + if(inited && !inWorld) + onPositionChanged(oldval_position); + } + else + { + if(inWorld) + { + if(prop_position.isOwnerOnly() && !isPlayer()) + { + } + else + { + onPositionChanged(oldval_position); + } + } + } + + UInt32 oldval_uid = uid; + Property prop_uid = pdatas[7]; + if(prop_uid.isBase()) + { + if(inited && !inWorld) + onUidChanged(oldval_uid); + } + else + { + if(inWorld) + { + if(prop_uid.isOwnerOnly() && !isPlayer()) + { + } + else + { + onUidChanged(oldval_uid); + } + } + } + + UInt32 oldval_utype = utype; + Property prop_utype = pdatas[8]; + if(prop_utype.isBase()) + { + if(inited && !inWorld) + onUtypeChanged(oldval_utype); + } + else + { + if(inWorld) + { + if(prop_utype.isOwnerOnly() && !isPlayer()) + { + } + else + { + onUtypeChanged(oldval_utype); + } + } + } + + } + } } \ No newline at end of file diff --git a/Assets/Plugins/kbengine_unity3d_plugins/TestBase.cs b/Assets/Plugins/kbengine_unity3d_plugins/TestBase.cs index e864b78..99aab5d 100644 --- a/Assets/Plugins/kbengine_unity3d_plugins/TestBase.cs +++ b/Assets/Plugins/kbengine_unity3d_plugins/TestBase.cs @@ -1,173 +1,173 @@ -/* - Generated by KBEngine! - Please do not modify this file! - Please inherit this module, such as: (class Test : TestBase) - tools = kbcmd -*/ - -namespace KBEngine -{ - using UnityEngine; - using System; - using System.Collections; - using System.Collections.Generic; - - // defined in */scripts/entity_defs/Test.def - public abstract class TestBase : EntityComponent - { - public EntityBaseEntityCall_TestBase baseEntityCall = null; - public EntityCellEntityCall_TestBase cellEntityCall = null; - - public Int32 own = 1001; - public virtual void onOwnChanged(Int32 oldValue) {} - public Int32 state = 100; - public virtual void onStateChanged(Int32 oldValue) {} - - public abstract void helloCB(Int32 arg1); - - public override void createFromStream(MemoryStream stream) - { - base.createFromStream(stream); - baseEntityCall = new EntityBaseEntityCall_TestBase(entityComponentPropertyID, ownerID); - cellEntityCall = new EntityCellEntityCall_TestBase(entityComponentPropertyID, ownerID); - } - - public override ScriptModule getScriptModule() - { - return EntityDef.moduledefs["Test"]; - } - - public override void onRemoteMethodCall(UInt16 methodUtype, MemoryStream stream) - { - ScriptModule sm = EntityDef.moduledefs["Test"]; - - Method method = sm.idmethods[methodUtype]; - switch(method.methodUtype) - { - case 28: - Int32 helloCB_arg1 = stream.readInt32(); - helloCB(helloCB_arg1); - break; - default: - break; - }; - } - - public override void onUpdatePropertys(UInt16 propUtype, MemoryStream stream, int maxCount) - { - ScriptModule sm = EntityDef.moduledefs["Test"]; - Dictionary pdatas = sm.idpropertys; - - while(stream.length() > 0 && maxCount-- != 0) - { - UInt16 _t_utype = 0; - UInt16 _t_child_utype = propUtype; - - if(_t_child_utype == 0) - { - if(sm.usePropertyDescrAlias) - { - _t_utype = stream.readUint8(); - _t_child_utype = stream.readUint8(); - } - else - { - _t_utype = stream.readUint16(); - _t_child_utype = stream.readUint16(); - } - } - - Property prop = null; - - prop = pdatas[_t_child_utype]; - - switch(prop.properUtype) - { - case 18: - Int32 oldval_own = own; - own = stream.readInt32(); - - if(prop.isBase()) - { - if(owner.inited) - onOwnChanged(oldval_own); - } - else - { - if(owner.inWorld) - onOwnChanged(oldval_own); - } - - break; - case 17: - Int32 oldval_state = state; - state = stream.readInt32(); - - if(prop.isBase()) - { - if(owner.inited) - onStateChanged(oldval_state); - } - else - { - if(owner.inWorld) - onStateChanged(oldval_state); - } - - break; - default: - break; - }; - } - } - - public override void callPropertysSetMethods() - { - ScriptModule sm = EntityDef.moduledefs["Test"]; - Dictionary pdatas = sm.idpropertys; - - Int32 oldval_own = own; - Property prop_own = pdatas[4]; - if(prop_own.isBase()) - { - if(owner.inited && !owner.inWorld) - onOwnChanged(oldval_own); - } - else - { - if(owner.inWorld) - { - if(prop_own.isOwnerOnly() && !owner.isPlayer()) - { - } - else - { - onOwnChanged(oldval_own); - } - } - } - - Int32 oldval_state = state; - Property prop_state = pdatas[5]; - if(prop_state.isBase()) - { - if(owner.inited && !owner.inWorld) - onStateChanged(oldval_state); - } - else - { - if(owner.inWorld) - { - if(prop_state.isOwnerOnly() && !owner.isPlayer()) - { - } - else - { - onStateChanged(oldval_state); - } - } - } - - } - } +/* + Generated by KBEngine! + Please do not modify this file! + Please inherit this module, such as: (class Test : TestBase) + tools = kbcmd +*/ + +namespace KBEngine +{ + using UnityEngine; + using System; + using System.Collections; + using System.Collections.Generic; + + // defined in */scripts/entity_defs/Test.def + public abstract class TestBase : EntityComponent + { + public EntityBaseEntityCall_TestBase baseEntityCall = null; + public EntityCellEntityCall_TestBase cellEntityCall = null; + + public Int32 own = 1001; + public virtual void onOwnChanged(Int32 oldValue) {} + public Int32 state = 100; + public virtual void onStateChanged(Int32 oldValue) {} + + public abstract void helloCB(Int32 arg1); + + public override void createFromStream(MemoryStream stream) + { + base.createFromStream(stream); + baseEntityCall = new EntityBaseEntityCall_TestBase(entityComponentPropertyID, ownerID); + cellEntityCall = new EntityCellEntityCall_TestBase(entityComponentPropertyID, ownerID); + } + + public override ScriptModule getScriptModule() + { + return EntityDef.moduledefs["Test"]; + } + + public override void onRemoteMethodCall(UInt16 methodUtype, MemoryStream stream) + { + ScriptModule sm = EntityDef.moduledefs["Test"]; + + Method method = sm.idmethods[methodUtype]; + switch(method.methodUtype) + { + case 28: + Int32 helloCB_arg1 = stream.readInt32(); + helloCB(helloCB_arg1); + break; + default: + break; + }; + } + + public override void onUpdatePropertys(UInt16 propUtype, MemoryStream stream, int maxCount) + { + ScriptModule sm = EntityDef.moduledefs["Test"]; + Dictionary pdatas = sm.idpropertys; + + while(stream.length() > 0 && maxCount-- != 0) + { + UInt16 _t_utype = 0; + UInt16 _t_child_utype = propUtype; + + if(_t_child_utype == 0) + { + if(sm.usePropertyDescrAlias) + { + _t_utype = stream.readUint8(); + _t_child_utype = stream.readUint8(); + } + else + { + _t_utype = stream.readUint16(); + _t_child_utype = stream.readUint16(); + } + } + + Property prop = null; + + prop = pdatas[_t_child_utype]; + + switch(prop.properUtype) + { + case 18: + Int32 oldval_own = own; + own = stream.readInt32(); + + if(prop.isBase()) + { + if(owner.inited) + onOwnChanged(oldval_own); + } + else + { + if(owner.inWorld) + onOwnChanged(oldval_own); + } + + break; + case 17: + Int32 oldval_state = state; + state = stream.readInt32(); + + if(prop.isBase()) + { + if(owner.inited) + onStateChanged(oldval_state); + } + else + { + if(owner.inWorld) + onStateChanged(oldval_state); + } + + break; + default: + break; + }; + } + } + + public override void callPropertysSetMethods() + { + ScriptModule sm = EntityDef.moduledefs["Test"]; + Dictionary pdatas = sm.idpropertys; + + Int32 oldval_own = own; + Property prop_own = pdatas[4]; + if(prop_own.isBase()) + { + if(owner.inited && !owner.inWorld) + onOwnChanged(oldval_own); + } + else + { + if(owner.inWorld) + { + if(prop_own.isOwnerOnly() && !owner.isPlayer()) + { + } + else + { + onOwnChanged(oldval_own); + } + } + } + + Int32 oldval_state = state; + Property prop_state = pdatas[5]; + if(prop_state.isBase()) + { + if(owner.inited && !owner.inWorld) + onStateChanged(oldval_state); + } + else + { + if(owner.inWorld) + { + if(prop_state.isOwnerOnly() && !owner.isPlayer()) + { + } + else + { + onStateChanged(oldval_state); + } + } + } + + } + } } \ No newline at end of file diff --git a/Assets/Plugins/kbengine_unity3d_plugins/TestNoBaseBase.cs b/Assets/Plugins/kbengine_unity3d_plugins/TestNoBaseBase.cs index 5be568c..6cfd4fa 100644 --- a/Assets/Plugins/kbengine_unity3d_plugins/TestNoBaseBase.cs +++ b/Assets/Plugins/kbengine_unity3d_plugins/TestNoBaseBase.cs @@ -1,173 +1,173 @@ -/* - Generated by KBEngine! - Please do not modify this file! - Please inherit this module, such as: (class TestNoBase : TestNoBaseBase) - tools = kbcmd -*/ - -namespace KBEngine -{ - using UnityEngine; - using System; - using System.Collections; - using System.Collections.Generic; - - // defined in */scripts/entity_defs/TestNoBase.def - public abstract class TestNoBaseBase : EntityComponent - { - public EntityBaseEntityCall_TestNoBaseBase baseEntityCall = null; - public EntityCellEntityCall_TestNoBaseBase cellEntityCall = null; - - public Int32 own = 1001; - public virtual void onOwnChanged(Int32 oldValue) {} - public Int32 state = 100; - public virtual void onStateChanged(Int32 oldValue) {} - - public abstract void helloCB(Int32 arg1); - - public override void createFromStream(MemoryStream stream) - { - base.createFromStream(stream); - baseEntityCall = new EntityBaseEntityCall_TestNoBaseBase(entityComponentPropertyID, ownerID); - cellEntityCall = new EntityCellEntityCall_TestNoBaseBase(entityComponentPropertyID, ownerID); - } - - public override ScriptModule getScriptModule() - { - return EntityDef.moduledefs["TestNoBase"]; - } - - public override void onRemoteMethodCall(UInt16 methodUtype, MemoryStream stream) - { - ScriptModule sm = EntityDef.moduledefs["TestNoBase"]; - - Method method = sm.idmethods[methodUtype]; - switch(method.methodUtype) - { - case 30: - Int32 helloCB_arg1 = stream.readInt32(); - helloCB(helloCB_arg1); - break; - default: - break; - }; - } - - public override void onUpdatePropertys(UInt16 propUtype, MemoryStream stream, int maxCount) - { - ScriptModule sm = EntityDef.moduledefs["TestNoBase"]; - Dictionary pdatas = sm.idpropertys; - - while(stream.length() > 0 && maxCount-- != 0) - { - UInt16 _t_utype = 0; - UInt16 _t_child_utype = propUtype; - - if(_t_child_utype == 0) - { - if(sm.usePropertyDescrAlias) - { - _t_utype = stream.readUint8(); - _t_child_utype = stream.readUint8(); - } - else - { - _t_utype = stream.readUint16(); - _t_child_utype = stream.readUint16(); - } - } - - Property prop = null; - - prop = pdatas[_t_child_utype]; - - switch(prop.properUtype) - { - case 24: - Int32 oldval_own = own; - own = stream.readInt32(); - - if(prop.isBase()) - { - if(owner.inited) - onOwnChanged(oldval_own); - } - else - { - if(owner.inWorld) - onOwnChanged(oldval_own); - } - - break; - case 23: - Int32 oldval_state = state; - state = stream.readInt32(); - - if(prop.isBase()) - { - if(owner.inited) - onStateChanged(oldval_state); - } - else - { - if(owner.inWorld) - onStateChanged(oldval_state); - } - - break; - default: - break; - }; - } - } - - public override void callPropertysSetMethods() - { - ScriptModule sm = EntityDef.moduledefs["TestNoBase"]; - Dictionary pdatas = sm.idpropertys; - - Int32 oldval_own = own; - Property prop_own = pdatas[4]; - if(prop_own.isBase()) - { - if(owner.inited && !owner.inWorld) - onOwnChanged(oldval_own); - } - else - { - if(owner.inWorld) - { - if(prop_own.isOwnerOnly() && !owner.isPlayer()) - { - } - else - { - onOwnChanged(oldval_own); - } - } - } - - Int32 oldval_state = state; - Property prop_state = pdatas[5]; - if(prop_state.isBase()) - { - if(owner.inited && !owner.inWorld) - onStateChanged(oldval_state); - } - else - { - if(owner.inWorld) - { - if(prop_state.isOwnerOnly() && !owner.isPlayer()) - { - } - else - { - onStateChanged(oldval_state); - } - } - } - - } - } +/* + Generated by KBEngine! + Please do not modify this file! + Please inherit this module, such as: (class TestNoBase : TestNoBaseBase) + tools = kbcmd +*/ + +namespace KBEngine +{ + using UnityEngine; + using System; + using System.Collections; + using System.Collections.Generic; + + // defined in */scripts/entity_defs/TestNoBase.def + public abstract class TestNoBaseBase : EntityComponent + { + public EntityBaseEntityCall_TestNoBaseBase baseEntityCall = null; + public EntityCellEntityCall_TestNoBaseBase cellEntityCall = null; + + public Int32 own = 1001; + public virtual void onOwnChanged(Int32 oldValue) {} + public Int32 state = 100; + public virtual void onStateChanged(Int32 oldValue) {} + + public abstract void helloCB(Int32 arg1); + + public override void createFromStream(MemoryStream stream) + { + base.createFromStream(stream); + baseEntityCall = new EntityBaseEntityCall_TestNoBaseBase(entityComponentPropertyID, ownerID); + cellEntityCall = new EntityCellEntityCall_TestNoBaseBase(entityComponentPropertyID, ownerID); + } + + public override ScriptModule getScriptModule() + { + return EntityDef.moduledefs["TestNoBase"]; + } + + public override void onRemoteMethodCall(UInt16 methodUtype, MemoryStream stream) + { + ScriptModule sm = EntityDef.moduledefs["TestNoBase"]; + + Method method = sm.idmethods[methodUtype]; + switch(method.methodUtype) + { + case 30: + Int32 helloCB_arg1 = stream.readInt32(); + helloCB(helloCB_arg1); + break; + default: + break; + }; + } + + public override void onUpdatePropertys(UInt16 propUtype, MemoryStream stream, int maxCount) + { + ScriptModule sm = EntityDef.moduledefs["TestNoBase"]; + Dictionary pdatas = sm.idpropertys; + + while(stream.length() > 0 && maxCount-- != 0) + { + UInt16 _t_utype = 0; + UInt16 _t_child_utype = propUtype; + + if(_t_child_utype == 0) + { + if(sm.usePropertyDescrAlias) + { + _t_utype = stream.readUint8(); + _t_child_utype = stream.readUint8(); + } + else + { + _t_utype = stream.readUint16(); + _t_child_utype = stream.readUint16(); + } + } + + Property prop = null; + + prop = pdatas[_t_child_utype]; + + switch(prop.properUtype) + { + case 24: + Int32 oldval_own = own; + own = stream.readInt32(); + + if(prop.isBase()) + { + if(owner.inited) + onOwnChanged(oldval_own); + } + else + { + if(owner.inWorld) + onOwnChanged(oldval_own); + } + + break; + case 23: + Int32 oldval_state = state; + state = stream.readInt32(); + + if(prop.isBase()) + { + if(owner.inited) + onStateChanged(oldval_state); + } + else + { + if(owner.inWorld) + onStateChanged(oldval_state); + } + + break; + default: + break; + }; + } + } + + public override void callPropertysSetMethods() + { + ScriptModule sm = EntityDef.moduledefs["TestNoBase"]; + Dictionary pdatas = sm.idpropertys; + + Int32 oldval_own = own; + Property prop_own = pdatas[4]; + if(prop_own.isBase()) + { + if(owner.inited && !owner.inWorld) + onOwnChanged(oldval_own); + } + else + { + if(owner.inWorld) + { + if(prop_own.isOwnerOnly() && !owner.isPlayer()) + { + } + else + { + onOwnChanged(oldval_own); + } + } + } + + Int32 oldval_state = state; + Property prop_state = pdatas[5]; + if(prop_state.isBase()) + { + if(owner.inited && !owner.inWorld) + onStateChanged(oldval_state); + } + else + { + if(owner.inWorld) + { + if(prop_state.isOwnerOnly() && !owner.isPlayer()) + { + } + else + { + onStateChanged(oldval_state); + } + } + } + + } + } } \ No newline at end of file diff --git a/Assets/Plugins/kbengine_unity3d_plugins/deps/KCP.cs b/Assets/Plugins/kbengine_unity3d_plugins/deps/KCP.cs index e859a01..0d0895d 100644 --- a/Assets/Plugins/kbengine_unity3d_plugins/deps/KCP.cs +++ b/Assets/Plugins/kbengine_unity3d_plugins/deps/KCP.cs @@ -1,1166 +1,1166 @@ -// Copyright (C) 2017 ichenq@outlook.com. All rights reserved. -// Distributed under the terms and conditions of the MIT License. -// See accompanying files LICENSE. - -using System; -using System.Diagnostics; -using System.Collections.Generic; - -namespace Deps -{ - public class KCP - { - public class TimeUtils - { - private static readonly DateTime epoch = new DateTime(1970, 1, 1); - private static readonly DateTime twepoch = new DateTime(2000, 1, 1); - - public static UInt32 iclock() - { - var now = Convert.ToInt64(DateTime.Now.Subtract(twepoch).TotalMilliseconds); - return (UInt32)(now & 0xFFFFFFFF); - } - - public static Int64 LocalUnixTime() - { - return Convert.ToInt64(DateTime.Now.Subtract(epoch).TotalMilliseconds); - } - - // local datetime to unix timestamp - public static Int64 ToUnixTimestamp(DateTime t) - { - var timespan = t.ToUniversalTime().Subtract(epoch); - return (Int64)Math.Truncate(timespan.TotalSeconds); - } - } - - public const int IKCP_RTO_NDL = 30; // no delay min rto - public const int IKCP_RTO_MIN = 100; // normal min rto - public const int IKCP_RTO_DEF = 200; - public const int IKCP_RTO_MAX = 60000; - public const int IKCP_CMD_PUSH = 81; // cmd: push data - public const int IKCP_CMD_ACK = 82; // cmd: ack - public const int IKCP_CMD_WASK = 83; // cmd: window probe (ask) - public const int IKCP_CMD_WINS = 84; // cmd: window size (tell) - public const int IKCP_ASK_SEND = 1; // need to send IKCP_CMD_WASK - public const int IKCP_ASK_TELL = 2; // need to send IKCP_CMD_WINS - public const int IKCP_WND_SND = 32; - public const int IKCP_WND_RCV = 32; - public const int IKCP_MTU_DEF = 1400; - public const int IKCP_ACK_FAST = 3; - public const int IKCP_INTERVAL = 100; - public const int IKCP_OVERHEAD = 24; - public const int IKCP_DEADLINK = 20; - public const int IKCP_THRESH_INIT = 2; - public const int IKCP_THRESH_MIN = 2; - public const int IKCP_PROBE_INIT = 7000; // 7 secs to probe window size - public const int IKCP_PROBE_LIMIT = 120000; // up to 120 secs to probe window - - public const int IKCP_LOG_OUTPUT = 0x1; - public const int IKCP_LOG_INPUT = 0x2; - public const int IKCP_LOG_SEND = 0x4; - public const int IKCP_LOG_RECV = 0x8; - public const int IKCP_LOG_IN_DATA = 0x10; - public const int IKCP_LOG_IN_ACK = 0x20; - public const int IKCP_LOG_IN_PROBE = 0x40; - public const int IKCP_LOG_IN_WINS = 0x80; - public const int IKCP_LOG_OUT_DATA = 0x100; - public const int IKCP_LOG_OUT_ACK = 0x200; - public const int IKCP_LOG_OUT_PROBE = 0x400; - public const int IKCP_LOG_OUT_WINS = 0x800; - - - // encode 8 bits unsigned int - public static void ikcp_encode8u(byte[] p, int offset, byte c) - { - p[offset] = c; - } - - // decode 8 bits unsigned int - public static byte ikcp_decode8u(byte[] p, ref int offset) - { - return p[offset++]; - } - - // encode 16 bits unsigned int (lsb) - public static void ikcp_encode16u(byte[] p, int offset, UInt16 v) - { - p[offset] = (byte)(v & 0xFF); - p[offset + 1] = (byte)(v >> 8); - } - - // decode 16 bits unsigned int (lsb) - public static UInt16 ikcp_decode16u(byte[] p, ref int offset) - { - int pos = offset; - offset += 2; - return (UInt16)((UInt16)p[pos] | (UInt16)(p[pos + 1] << 8)); - } - - // encode 32 bits unsigned int (lsb) - public static void ikcp_encode32u(byte[] p, int offset, UInt32 l) - { - p[offset] = (byte)(l & 0xFF); - p[offset + 1] = (byte)(l >> 8); - p[offset + 2] = (byte)(l >> 16); - p[offset + 3] = (byte)(l >> 24); - } - - // decode 32 bits unsigned int (lsb) - public static UInt32 ikcp_decode32u(byte[] p, ref int offset) - { - int pos = offset; - offset += 4; - return ((UInt32)p[pos] | (UInt32)(p[pos + 1] << 8) - | (UInt32)(p[pos + 2] << 16) | (UInt32)(p[pos + 3] << 24)); - } - - public static UInt32 _imin_(UInt32 a, UInt32 b) - { - return a <= b ? a : b; - } - - public static UInt32 _imax_(UInt32 a, UInt32 b) - { - return a >= b ? a : b; - } - - public static UInt32 _ibound_(UInt32 lower, UInt32 middle, UInt32 upper) - { - return _imin_(_imax_(lower, middle), upper); - } - - public static Int32 _itimediff(UInt32 later, UInt32 earlier) - { - return (Int32)(later - earlier); - } - - internal class Segment - { - internal UInt32 conv = 0; - internal UInt32 cmd = 0; - internal UInt32 frg = 0; - internal UInt32 wnd = 0; - internal UInt32 ts = 0; - internal UInt32 sn = 0; - internal UInt32 una = 0; - internal UInt32 resendts = 0; - internal UInt32 rto = 0; - internal UInt32 faskack = 0; - internal UInt32 xmit = 0; - internal byte[] data; - - internal Segment(int size = 0) - { - data = new byte[size]; - } - - internal void Encode(byte[] ptr, ref int offset) - { - UInt32 len = (UInt32)data.Length; - ikcp_encode32u(ptr, offset, conv); - ikcp_encode8u(ptr, offset + 4, (byte)cmd); - ikcp_encode8u(ptr, offset + 5, (byte)frg); - ikcp_encode16u(ptr, offset + 6, (UInt16)wnd); - ikcp_encode32u(ptr, offset + 8, ts); - ikcp_encode32u(ptr, offset + 12, sn); - ikcp_encode32u(ptr, offset + 16, una); - ikcp_encode32u(ptr, offset + 20, len); - offset += IKCP_OVERHEAD; - } - - } - - UInt32 conv_ = 0; - UInt32 mtu_ = 0; - UInt32 mss_ = 0; - UInt32 state_ = 0; - - UInt32 snd_una_ = 0; - UInt32 snd_nxt_ = 0; - UInt32 rcv_nxt_ = 0; - - //UInt32 ts_recent_ = 0; - //UInt32 ts_lastack_ = 0; - UInt32 ssthresh_ = 0; - - Int32 rx_rttval_ = 0; - Int32 rx_srtt_ = 0; - Int32 rx_rto_ = 0; - Int32 rx_minrto_ = 0; - - UInt32 snd_wnd_ = 0; - UInt32 rcv_wnd_ = 0; - UInt32 rmt_wnd_ = 0; - UInt32 cwnd_ = 0; - UInt32 probe_ = 0; - - UInt32 current_ = 0; - UInt32 interval_ = 0; - UInt32 ts_flush_ = 0; - UInt32 xmit_ = 0; - - UInt32 nrcv_buf_ = 0; - UInt32 nsnd_buf_ = 0; - UInt32 nrcv_que_ = 0; - UInt32 nsnd_que_ = 0; - - UInt32 nodelay_ = 0; - UInt32 updated_ = 0; - UInt32 ts_probe_ = 0; - UInt32 probe_wait_ = 0; - UInt32 dead_link_ = 0; - UInt32 incr_ = 0; - - LinkedList snd_queue_; - LinkedList rcv_queue_; - LinkedList snd_buf_; - LinkedList rcv_buf_; - - UInt32[] acklist_; - UInt32 ackcount_ = 0; - UInt32 ackblock_ = 0; - - byte[] buffer_; - object user_; - - Int32 fastresend_ = 0; - Int32 nocwnd_ = 0; - - public delegate void OutputDelegate(byte[] data, int size, object user); - OutputDelegate output_; - - // create a new kcp control object, 'conv' must equal in two endpoint - // from the same connection. 'user' will be passed to the output callback - // output callback can be setup like this: 'kcp->output = my_udp_output' - public KCP(UInt32 conv, object user) - { - Debug.Assert(BitConverter.IsLittleEndian); // we only support little endian device - - user_ = user; - conv_ = conv; - snd_wnd_ = IKCP_WND_SND; - rcv_wnd_ = IKCP_WND_RCV; - rmt_wnd_ = IKCP_WND_RCV; - mtu_ = IKCP_MTU_DEF; - mss_ = mtu_ - IKCP_OVERHEAD; - rx_rto_ = IKCP_RTO_DEF; - rx_minrto_ = IKCP_RTO_MIN; - interval_ = IKCP_INTERVAL; - ts_flush_ = IKCP_INTERVAL; - ssthresh_ = IKCP_THRESH_INIT; - dead_link_ = IKCP_DEADLINK; - buffer_ = new byte[(mtu_ + IKCP_OVERHEAD) * 3]; - snd_queue_ = new LinkedList(); - rcv_queue_ = new LinkedList(); - snd_buf_ = new LinkedList(); - rcv_buf_ = new LinkedList(); - } - - // release kcp control object - public void Release() - { - snd_buf_.Clear(); - rcv_buf_.Clear(); - snd_queue_.Clear(); - rcv_queue_.Clear(); - nrcv_buf_ = 0; - nsnd_buf_ = 0; - nrcv_que_ = 0; - nsnd_que_ = 0; - ackblock_ = 0; - ackcount_ = 0; - buffer_ = null; - acklist_ = null; - } - - // set output callback, which will be invoked by kcp - public void SetOutput(OutputDelegate output) - { - output_ = output; - } - - // user/upper level recv: returns size, returns below zero for EAGAIN - public int Recv(byte[] buffer, int offset, int len) - { - int ispeek = (len < 0 ? 1 : 0); - int recover = 0; - - if (rcv_queue_.Count == 0) - return -1; - - if (len < 0) - len = -len; - - int peeksize = PeekSize(); - if (peeksize < 0) - return -2; - - if (peeksize > len) - return -3; - - if (nrcv_que_ >= rcv_wnd_) - recover = 1; - - // merge fragment - len = 0; - LinkedListNode next = null; - for (var node = rcv_queue_.First; node != null; node = next) - { - int fragment = 0; - var seg = node.Value; - next = node.Next; - - if (buffer != null) - { - Buffer.BlockCopy(seg.data, 0, buffer, offset, seg.data.Length); - offset += seg.data.Length; - } - len += seg.data.Length; - fragment = (int)seg.frg; - - Log(IKCP_LOG_RECV, "recv sn={0}", seg.sn); - - if (ispeek == 0) - { - rcv_queue_.Remove(node); - nrcv_que_--; - } - - if (fragment == 0) - break; - } - - Debug.Assert(len == peeksize); - - // move available data from rcv_buf -> rcv_queue - while (rcv_buf_.Count > 0) - { - var node = rcv_buf_.First; - var seg = node.Value; - if (seg.sn == rcv_nxt_ && nrcv_que_ < rcv_wnd_) - { - rcv_buf_.Remove(node); - nrcv_buf_--; - rcv_queue_.AddLast(node); - nrcv_que_++; - rcv_nxt_++; - } - else - { - break; - } - } - - // fast recover - if (nrcv_que_ < rcv_wnd_ && recover != 0) - { - // ready to send back IKCP_CMD_WINS in ikcp_flush - // tell remote my window size - probe_ |= IKCP_ASK_TELL; - } - - return len; - } - - // check the size of next message in the recv queue - public int PeekSize() - { - if (rcv_queue_.Count == 0) - return -1; - - var node = rcv_queue_.First; - var seg = node.Value; - if (seg.frg == 0) - return seg.data.Length; - - if (nrcv_que_ < seg.frg + 1) - return -1; - - int length = 0; - for (node = rcv_queue_.First; node != null; node = node.Next) - { - seg = node.Value; - length += seg.data.Length; - if (seg.frg == 0) - break; - } - return length; - } - - // user/upper level send, returns below zero for error - public int Send(byte[] buffer, int offset, int len) - { - Debug.Assert(mss_ > 0); - if (len < 0) - return -1; - - // - // not implement streaming mode here as ikcp.c - // - - int count = 0; - if (len <= (int)mss_) - count = 1; - else - count = (len + (int)mss_ - 1) / (int)mss_; - - if (count > 255) // maximum value `frg` can present - return -2; - - if (count == 0) - count = 1; - - // fragment - for (int i = 0; i < count; i++) - { - int size = len > (int)mss_ ? (int)mss_ : len; - var seg = new Segment(size); - if (buffer != null && len > 0) - { - Buffer.BlockCopy(buffer, offset, seg.data, 0, size); - offset += size; - } - seg.frg = (UInt32)(count - i - 1); - snd_queue_.AddLast(seg); - nsnd_que_++; - len -= size; - } - return 0; - } - - // parse ack - void UpdateACK(Int32 rtt) - { - if (rx_srtt_ == 0) - { - rx_srtt_ = rtt; - rx_rttval_ = rtt / 2; - } - else - { - Int32 delta = rtt - rx_srtt_; - if (delta < 0) - delta = -delta; - - rx_rttval_ = (3 * rx_rttval_ + delta) / 4; - rx_srtt_ = (7 * rx_srtt_ + rtt) / 8; - if (rx_srtt_ < 1) - rx_srtt_ = 1; - } - - var rto = rx_srtt_ + _imax_(interval_, (UInt32)(4 * rx_rttval_)); - rx_rto_ = (Int32)_ibound_((UInt32)rx_minrto_, (UInt32)rto, IKCP_RTO_MAX); - } - - void ShrinkBuf() - { - var node = snd_buf_.First; - if (node != null) - { - var seg = node.Value; - snd_una_ = seg.sn; - } - else - { - snd_una_ = snd_nxt_; - } - } - - void ParseACK(UInt32 sn) - { - if (_itimediff(sn, snd_una_) < 0 || _itimediff(sn, snd_nxt_) >= 0) - return; - - LinkedListNode next = null; - for (var node = snd_buf_.First; node != null; node = next) - { - var seg = node.Value; - next = node.Next; - if (sn == seg.sn) - { - snd_buf_.Remove(node); - nsnd_buf_--; - break; - } - if (_itimediff(sn, seg.sn) < 0) - break; - } - } - - void ParseUNA(UInt32 una) - { - LinkedListNode next = null; - for (var node = snd_buf_.First; node != null; node = next) - { - var seg = node.Value; - next = node.Next; - if (_itimediff(una, seg.sn) > 0) - { - snd_buf_.Remove(node); - nsnd_buf_--; - } - else - { - break; - } - } - } - - void ParseFastACK(UInt32 sn) - { - if (_itimediff(sn, snd_una_) < 0 || _itimediff(sn, snd_nxt_) >= 0) - return; - - LinkedListNode next = null; - for (var node = snd_buf_.First; node != null; node = next) - { - var seg = node.Value; - next = node.Next; - if (_itimediff(sn, seg.sn) < 0) - { - break; - } - else if (sn != seg.sn) - { - seg.faskack++; - } - } - } - - // ack append - void ACKPush(UInt32 sn, UInt32 ts) - { - var newsize = ackcount_ + 1; - if (newsize > ackblock_) - { - UInt32 newblock = 8; - for (; newblock < newsize; newblock <<= 1) - ; - - var acklist = new UInt32[newblock * 2]; - if (acklist_ != null) - { - for (var i = 0; i < ackcount_; i++) - { - acklist[i * 2] = acklist_[i * 2]; - acklist[i * 2 + 1] = acklist_[i * 2 + 1]; - } - } - acklist_ = acklist; - ackblock_ = newblock; - } - acklist_[ackcount_ * 2] = sn; - acklist_[ackcount_ * 2 + 1] = ts; - ackcount_++; - } - - void ACKGet(int pos, ref UInt32 sn, ref UInt32 ts) - { - sn = acklist_[pos * 2]; - ts = acklist_[pos * 2 + 1]; - } - - // parse data - void ParseData(Segment newseg) - { - UInt32 sn = newseg.sn; - int repeat = 0; - - if (_itimediff(sn, rcv_nxt_ + rcv_wnd_) >= 0 || - _itimediff(sn, rcv_nxt_) < 0) - { - return; - } - - LinkedListNode node = null; - LinkedListNode prev = null; - for (node = rcv_buf_.Last; node != null; node = prev) - { - var seg = node.Value; - prev = node.Previous; - if (seg.sn == sn) - { - repeat = 1; - break; - } - if (_itimediff(sn, seg.sn) > 0) - { - break; - } - } - if (repeat == 0) - { - if (node != null) - { - rcv_buf_.AddAfter(node, newseg); - } - else - { - rcv_buf_.AddFirst(newseg); - } - nrcv_buf_++; - } - - // move available data from rcv_buf -> rcv_queue - while (rcv_buf_.Count > 0) - { - node = rcv_buf_.First; - var seg = node.Value; - if (seg.sn == rcv_nxt_ && nrcv_que_ < rcv_wnd_) - { - rcv_buf_.Remove(node); - nrcv_buf_--; - rcv_queue_.AddLast(node); - nrcv_que_++; - rcv_nxt_++; - } - else - { - break; - } - } - } - - // when you received a low level packet (eg. UDP packet), call it - public int Input(byte[] data, int offset, int size) - { - UInt32 maxack = 0; - int flag = 0; - - Log(IKCP_LOG_INPUT, "[RI] {0} bytes", size); - - if (data == null || size < IKCP_OVERHEAD) - return -1; - - while (true) - { - if (size < IKCP_OVERHEAD) - break; - - UInt32 conv = ikcp_decode32u(data, ref offset); - if (conv_ != conv) - return -1; - UInt32 cmd = ikcp_decode8u(data, ref offset); - UInt32 frg = ikcp_decode8u(data, ref offset); - UInt32 wnd = ikcp_decode16u(data, ref offset); - UInt32 ts = ikcp_decode32u(data, ref offset); - UInt32 sn = ikcp_decode32u(data, ref offset); - UInt32 una = ikcp_decode32u(data, ref offset); - UInt32 len = ikcp_decode32u(data, ref offset); - - size -= IKCP_OVERHEAD; - if (size < len) - return -2; - - if (cmd != IKCP_CMD_PUSH && cmd != IKCP_CMD_ACK && - cmd != IKCP_CMD_WASK && cmd != IKCP_CMD_WINS) - return -3; - - rmt_wnd_ = wnd; - ParseUNA(una); - ShrinkBuf(); - - if (cmd == IKCP_CMD_ACK) - { - if (_itimediff(current_, ts) >= 0) - { - UpdateACK(_itimediff(current_, ts)); - } - ParseACK(sn); - ShrinkBuf(); - if (flag == 0) - { - flag = 1; - maxack = sn; - } - else - { - if (_itimediff(sn, maxack) > 0) - { - maxack = sn; - } - } - Log(IKCP_LOG_IN_DATA, "input ack: sn={0} rtt={1} rto={2}", - sn, _itimediff(current_, ts), rx_rto_); - } - else if (cmd == IKCP_CMD_PUSH) - { - Log(IKCP_LOG_IN_DATA, "input psh: sn={0} ts={1}", sn, ts); - if (_itimediff(sn, rcv_nxt_ + rcv_wnd_) < 0) - { - ACKPush(sn, ts); - if (_itimediff(sn, rcv_nxt_) >= 0) - { - var seg = new Segment((int)len); - seg.conv = conv; - seg.cmd = cmd; - seg.frg = frg; - seg.wnd = wnd; - seg.ts = ts; - seg.sn = sn; - seg.una = una; - if (len > 0) - { - Buffer.BlockCopy(data, offset, seg.data, 0, (int)len); - } - ParseData(seg); - } - } - } - else if (cmd == IKCP_CMD_WASK) - { - // ready to send back IKCP_CMD_WINS in ikcp_flush - // tell remote my window size - probe_ |= IKCP_ASK_TELL; - Log(IKCP_LOG_IN_PROBE, "input probe"); - } - else if (cmd == IKCP_CMD_WINS) - { - // do nothing - Log(IKCP_LOG_IN_WINS, "input wins: {0}", wnd); - } - else - { - return -3; - } - - offset += (int)len; - size -= (int)len; - } - - if (flag != 0) - { - ParseFastACK(maxack); - } - - UInt32 unack = snd_una_; - if (_itimediff(snd_una_, unack) > 0) - { - if (cwnd_ < rmt_wnd_) - { - if (cwnd_ < ssthresh_) - { - cwnd_++; - incr_ += mss_; - } - else - { - if (incr_ < mss_) - incr_ = mss_; - incr_ += (mss_ * mss_) / incr_ + (mss_ / 16); - if ((cwnd_ + 1) * mss_ <= incr_) - cwnd_++; - } - if (cwnd_ > rmt_wnd_) - { - cwnd_ = rmt_wnd_; - incr_ = rmt_wnd_ * mss_; - } - } - } - - return 0; - } - - int WndUnused() - { - if (nrcv_que_ < rcv_wnd_) - return (int)(rcv_wnd_ - nrcv_que_); - return 0; - } - - // flush pending data - void Flush() - { - int change = 0; - int lost = 0; - int offset = 0; - - // 'ikcp_update' haven't been called. - if (updated_ == 0) - return; - - var seg = new Segment - { - conv = conv_, - cmd = IKCP_CMD_ACK, - wnd = (UInt32)WndUnused(), - una = rcv_nxt_, - }; - - // flush acknowledges - int count = (int)ackcount_; - for (int i = 0; i < count; i++) - { - if ((offset + IKCP_OVERHEAD) > mtu_) - { - output_(buffer_, offset, user_); - offset = 0; - } - ACKGet(i, ref seg.sn, ref seg.ts); - seg.Encode(buffer_, ref offset); - } - - ackcount_ = 0; - - // probe window size (if remote window size equals zero) - if (rmt_wnd_ == 0) - { - if (probe_wait_ == 0) - { - probe_wait_ = IKCP_PROBE_INIT; - ts_probe_ = current_ + probe_wait_; - } - else - { - if (_itimediff(current_, ts_probe_) >= 0) - { - if (probe_wait_ < IKCP_PROBE_INIT) - probe_wait_ = IKCP_PROBE_INIT; - probe_wait_ += probe_wait_ / 2; - if (probe_wait_ > IKCP_PROBE_LIMIT) - probe_wait_ = IKCP_PROBE_LIMIT; - ts_probe_ = current_ + probe_wait_; - probe_ |= IKCP_ASK_SEND; - } - } - } - else - { - ts_probe_ = 0; - probe_wait_ = 0; - } - - // flush window probing commands - if ((probe_ & IKCP_ASK_SEND) > 0) - { - seg.cmd = IKCP_CMD_WASK; - if ((offset + IKCP_OVERHEAD) > mtu_) - { - output_(buffer_, offset, user_); - offset = 0; - } - seg.Encode(buffer_, ref offset); - } - - // flush window probing commands - if ((probe_ & IKCP_ASK_TELL) > 0) - { - seg.cmd = IKCP_CMD_WINS; - if ((offset + IKCP_OVERHEAD) > mtu_) - { - output_(buffer_, offset, user_); - offset = 0; - } - seg.Encode(buffer_, ref offset); - } - - probe_ = 0; - - // calculate window size - UInt32 cwnd = _imin_(snd_wnd_, rmt_wnd_); - if (nocwnd_ == 0) - cwnd = _imin_(cwnd_, cwnd); - - // move data from snd_queue to snd_buf - while (_itimediff(snd_nxt_, snd_una_ + cwnd) < 0) - { - if (snd_queue_.Count == 0) - break; - - var node = snd_queue_.First; - var newseg = node.Value; - snd_queue_.Remove(node); - snd_buf_.AddLast(node); - nsnd_que_--; - nsnd_buf_++; - - newseg.conv = conv_; - newseg.cmd = IKCP_CMD_PUSH; - newseg.wnd = seg.wnd; - newseg.ts = current_; - newseg.sn = snd_nxt_++; - newseg.una = rcv_nxt_; - newseg.resendts = current_; - newseg.rto = (UInt32)rx_rto_; - newseg.faskack = 0; - newseg.xmit = 0; - } - - // calculate resent - UInt32 resent = (fastresend_ > 0 ? (UInt32)fastresend_ : 0xffffffff); - UInt32 rtomin = (nodelay_ == 0 ? (UInt32)(rx_rto_ >> 3) : 0); - - // flush data segments - for (var node = snd_buf_.First; node != null; node = node.Next) - { - var segment = node.Value; - int needsend = 0; - if (segment.xmit == 0) - { - needsend = 1; - segment.xmit++; - segment.rto = (UInt32)rx_rto_; - segment.resendts = current_ + segment.rto + rtomin; - } - else if (_itimediff(current_, segment.resendts) >= 0) - { - needsend = 1; - segment.xmit++; - xmit_++; - if (nodelay_ == 0) - segment.rto += (UInt32)rx_rto_; - else - segment.rto += (UInt32)rx_rto_ / 2; - segment.resendts = current_ + segment.rto; - lost = 1; - } - else if (segment.faskack >= resent) - { - needsend = 1; - segment.xmit++; - segment.faskack = 0; - segment.resendts = current_ + segment.rto; - change++; - } - - if (needsend > 0) - { - segment.ts = current_; - segment.wnd = seg.wnd; - segment.una = rcv_nxt_; - - int need = IKCP_OVERHEAD; - if (segment.data != null) - need += segment.data.Length; - - if (offset + need > mtu_) - { - output_(buffer_, offset, user_); - offset = 0; - } - segment.Encode(buffer_, ref offset); - if (segment.data.Length > 0) - { - Buffer.BlockCopy(segment.data, 0, buffer_, offset, segment.data.Length); - offset += segment.data.Length; - } - if (segment.xmit >= dead_link_) - state_ = 0xffffffff; - } - } - - // flush remain segments - if (offset > 0) - { - output_(buffer_, offset, user_); - offset = 0; - } - - // update ssthresh - if (change > 0) - { - UInt32 inflight = snd_nxt_ - snd_una_; - ssthresh_ = inflight / 2; - if (ssthresh_ < IKCP_THRESH_MIN) - ssthresh_ = IKCP_THRESH_MIN; - cwnd_ = ssthresh_ + resent; - incr_ = cwnd_ * mss_; - } - - if (lost > 0) - { - ssthresh_ = cwnd / 2; - if (ssthresh_ < IKCP_THRESH_MIN) - ssthresh_ = IKCP_THRESH_MIN; - cwnd_ = 1; - incr_ = mss_; - } - - if (cwnd_ < 1) - { - cwnd_ = 1; - incr_ = mss_; - } - } - - // update state (call it repeatedly, every 10ms-100ms), or you can ask - // ikcp_check when to call it again (without ikcp_input/_send calling). - // 'current' - current timestamp in millisec. - public void Update(UInt32 current) - { - current_ = current; - if (updated_ == 0) - { - updated_ = 1; - ts_flush_ = current; - } - - Int32 slap = _itimediff(current_, ts_flush_); - if (slap >= 10000 || slap < -10000) - { - ts_flush_ = current; - slap = 0; - } - - if (slap >= 0) - { - ts_flush_ += interval_; - if (_itimediff(current_, ts_flush_) >= 0) - ts_flush_ = current_ + interval_; - - Flush(); - } - } - - // Determine when should you invoke ikcp_update: - // returns when you should invoke ikcp_update in millisec, if there - // is no ikcp_input/_send calling. you can call ikcp_update in that - // time, instead of call update repeatly. - // Important to reduce unnacessary ikcp_update invoking. use it to - // schedule ikcp_update (eg. implementing an epoll-like mechanism, - // or optimize ikcp_update when handling massive kcp connections) - public UInt32 Check(UInt32 current) - { - UInt32 ts_flush = ts_flush_; - Int32 tm_flush = 0x7fffffff; - Int32 tm_packet = 0x7fffffff; - - if (updated_ == 0) - return current; - - if (_itimediff(current, ts_flush) >= 10000 || - _itimediff(current, ts_flush) < -10000) - { - ts_flush = current; - } - - if (_itimediff(current, ts_flush) >= 0) - return current; - - tm_flush = _itimediff(ts_flush, current); - - for (var node = snd_buf_.First; node != null; node = node.Next) - { - var seg = node.Value; - Int32 diff = _itimediff(seg.resendts, current); - if (diff <= 0) - return current; - - if (diff < tm_packet) - tm_packet = diff; - } - - UInt32 minimal = (UInt32)(tm_packet < tm_flush ? tm_packet : tm_flush); - if (minimal >= interval_) - minimal = interval_; - - return current + minimal; - } - - // change MTU size, default is 1400 - public int SetMTU(int mtu) - { - if (mtu < 50 || mtu < IKCP_OVERHEAD) - return -1; - - var buffer = new byte[(mtu + IKCP_OVERHEAD) * 3]; - mtu_ = (UInt32)mtu; - mss_ = mtu_ - IKCP_OVERHEAD; - buffer_ = buffer; - return 0; - } - - public int Interval(int interval) - { - if (interval > 5000) - interval = 5000; - else if (interval < 10) - interval = 10; - - interval_ = (UInt32)interval; - return 0; - } - - // fastest: ikcp_nodelay(kcp, 1, 20, 2, 1) - // nodelay: 0:disable(default), 1:enable - // interval: internal update timer interval in millisec, default is 100ms - // resend: 0:disable fast resend(default), 1:enable fast resend - // nc: 0:normal congestion control(default), 1:disable congestion control - public int NoDelay(int nodelay, int interval, int resend, int nc) - { - if (nodelay >= 0) - { - nodelay_ = (UInt32)nodelay; - if (nodelay > 0) - { - rx_minrto_ = IKCP_RTO_NDL; - } - else - { - rx_minrto_ = IKCP_RTO_MIN; - } - } - if (interval >= 0) - { - if (interval > 5000) - interval = 5000; - else if (interval < 10) - interval = 10; - - interval_ = (UInt32)interval; - } - - if (resend >= 0) - fastresend_ = resend; - - if (nc >= 0) - nocwnd_ = nc; - - return 0; - } - - // set maximum window size: sndwnd=32, rcvwnd=32 by default - public int WndSize(int sndwnd, int rcvwnd) - { - if (sndwnd > 0) - snd_wnd_ = (UInt32)sndwnd; - if (rcvwnd > 0) - rcv_wnd_ = (UInt32)rcvwnd; - return 0; - } - - // get how many packet is waiting to be sent - public int WaitSnd() - { - return (int)(nsnd_buf_ + nsnd_que_); - } - - // read conv - public UInt32 GetConv() - { - return conv_; - } - - public UInt32 GetState() - { - return state_; - } - - public void SetMinRTO(int minrto) - { - rx_minrto_ = minrto; - } - - public void SetFastResend(int resend) - { - fastresend_ = resend; - } - - void Log(int mask, string format, params object[] args) - { - // Console.WriteLine(mask + String.Format(format, args)); - } - } -} +// Copyright (C) 2017 ichenq@outlook.com. All rights reserved. +// Distributed under the terms and conditions of the MIT License. +// See accompanying files LICENSE. + +using System; +using System.Diagnostics; +using System.Collections.Generic; + +namespace Deps +{ + public class KCP + { + public class TimeUtils + { + private static readonly DateTime epoch = new DateTime(1970, 1, 1); + private static readonly DateTime twepoch = new DateTime(2000, 1, 1); + + public static UInt32 iclock() + { + var now = Convert.ToInt64(DateTime.Now.Subtract(twepoch).TotalMilliseconds); + return (UInt32)(now & 0xFFFFFFFF); + } + + public static Int64 LocalUnixTime() + { + return Convert.ToInt64(DateTime.Now.Subtract(epoch).TotalMilliseconds); + } + + // local datetime to unix timestamp + public static Int64 ToUnixTimestamp(DateTime t) + { + var timespan = t.ToUniversalTime().Subtract(epoch); + return (Int64)Math.Truncate(timespan.TotalSeconds); + } + } + + public const int IKCP_RTO_NDL = 30; // no delay min rto + public const int IKCP_RTO_MIN = 100; // normal min rto + public const int IKCP_RTO_DEF = 200; + public const int IKCP_RTO_MAX = 60000; + public const int IKCP_CMD_PUSH = 81; // cmd: push data + public const int IKCP_CMD_ACK = 82; // cmd: ack + public const int IKCP_CMD_WASK = 83; // cmd: window probe (ask) + public const int IKCP_CMD_WINS = 84; // cmd: window size (tell) + public const int IKCP_ASK_SEND = 1; // need to send IKCP_CMD_WASK + public const int IKCP_ASK_TELL = 2; // need to send IKCP_CMD_WINS + public const int IKCP_WND_SND = 32; + public const int IKCP_WND_RCV = 32; + public const int IKCP_MTU_DEF = 1400; + public const int IKCP_ACK_FAST = 3; + public const int IKCP_INTERVAL = 100; + public const int IKCP_OVERHEAD = 24; + public const int IKCP_DEADLINK = 20; + public const int IKCP_THRESH_INIT = 2; + public const int IKCP_THRESH_MIN = 2; + public const int IKCP_PROBE_INIT = 7000; // 7 secs to probe window size + public const int IKCP_PROBE_LIMIT = 120000; // up to 120 secs to probe window + + public const int IKCP_LOG_OUTPUT = 0x1; + public const int IKCP_LOG_INPUT = 0x2; + public const int IKCP_LOG_SEND = 0x4; + public const int IKCP_LOG_RECV = 0x8; + public const int IKCP_LOG_IN_DATA = 0x10; + public const int IKCP_LOG_IN_ACK = 0x20; + public const int IKCP_LOG_IN_PROBE = 0x40; + public const int IKCP_LOG_IN_WINS = 0x80; + public const int IKCP_LOG_OUT_DATA = 0x100; + public const int IKCP_LOG_OUT_ACK = 0x200; + public const int IKCP_LOG_OUT_PROBE = 0x400; + public const int IKCP_LOG_OUT_WINS = 0x800; + + + // encode 8 bits unsigned int + public static void ikcp_encode8u(byte[] p, int offset, byte c) + { + p[offset] = c; + } + + // decode 8 bits unsigned int + public static byte ikcp_decode8u(byte[] p, ref int offset) + { + return p[offset++]; + } + + // encode 16 bits unsigned int (lsb) + public static void ikcp_encode16u(byte[] p, int offset, UInt16 v) + { + p[offset] = (byte)(v & 0xFF); + p[offset + 1] = (byte)(v >> 8); + } + + // decode 16 bits unsigned int (lsb) + public static UInt16 ikcp_decode16u(byte[] p, ref int offset) + { + int pos = offset; + offset += 2; + return (UInt16)((UInt16)p[pos] | (UInt16)(p[pos + 1] << 8)); + } + + // encode 32 bits unsigned int (lsb) + public static void ikcp_encode32u(byte[] p, int offset, UInt32 l) + { + p[offset] = (byte)(l & 0xFF); + p[offset + 1] = (byte)(l >> 8); + p[offset + 2] = (byte)(l >> 16); + p[offset + 3] = (byte)(l >> 24); + } + + // decode 32 bits unsigned int (lsb) + public static UInt32 ikcp_decode32u(byte[] p, ref int offset) + { + int pos = offset; + offset += 4; + return ((UInt32)p[pos] | (UInt32)(p[pos + 1] << 8) + | (UInt32)(p[pos + 2] << 16) | (UInt32)(p[pos + 3] << 24)); + } + + public static UInt32 _imin_(UInt32 a, UInt32 b) + { + return a <= b ? a : b; + } + + public static UInt32 _imax_(UInt32 a, UInt32 b) + { + return a >= b ? a : b; + } + + public static UInt32 _ibound_(UInt32 lower, UInt32 middle, UInt32 upper) + { + return _imin_(_imax_(lower, middle), upper); + } + + public static Int32 _itimediff(UInt32 later, UInt32 earlier) + { + return (Int32)(later - earlier); + } + + internal class Segment + { + internal UInt32 conv = 0; + internal UInt32 cmd = 0; + internal UInt32 frg = 0; + internal UInt32 wnd = 0; + internal UInt32 ts = 0; + internal UInt32 sn = 0; + internal UInt32 una = 0; + internal UInt32 resendts = 0; + internal UInt32 rto = 0; + internal UInt32 faskack = 0; + internal UInt32 xmit = 0; + internal byte[] data; + + internal Segment(int size = 0) + { + data = new byte[size]; + } + + internal void Encode(byte[] ptr, ref int offset) + { + UInt32 len = (UInt32)data.Length; + ikcp_encode32u(ptr, offset, conv); + ikcp_encode8u(ptr, offset + 4, (byte)cmd); + ikcp_encode8u(ptr, offset + 5, (byte)frg); + ikcp_encode16u(ptr, offset + 6, (UInt16)wnd); + ikcp_encode32u(ptr, offset + 8, ts); + ikcp_encode32u(ptr, offset + 12, sn); + ikcp_encode32u(ptr, offset + 16, una); + ikcp_encode32u(ptr, offset + 20, len); + offset += IKCP_OVERHEAD; + } + + } + + UInt32 conv_ = 0; + UInt32 mtu_ = 0; + UInt32 mss_ = 0; + UInt32 state_ = 0; + + UInt32 snd_una_ = 0; + UInt32 snd_nxt_ = 0; + UInt32 rcv_nxt_ = 0; + + //UInt32 ts_recent_ = 0; + //UInt32 ts_lastack_ = 0; + UInt32 ssthresh_ = 0; + + Int32 rx_rttval_ = 0; + Int32 rx_srtt_ = 0; + Int32 rx_rto_ = 0; + Int32 rx_minrto_ = 0; + + UInt32 snd_wnd_ = 0; + UInt32 rcv_wnd_ = 0; + UInt32 rmt_wnd_ = 0; + UInt32 cwnd_ = 0; + UInt32 probe_ = 0; + + UInt32 current_ = 0; + UInt32 interval_ = 0; + UInt32 ts_flush_ = 0; + UInt32 xmit_ = 0; + + UInt32 nrcv_buf_ = 0; + UInt32 nsnd_buf_ = 0; + UInt32 nrcv_que_ = 0; + UInt32 nsnd_que_ = 0; + + UInt32 nodelay_ = 0; + UInt32 updated_ = 0; + UInt32 ts_probe_ = 0; + UInt32 probe_wait_ = 0; + UInt32 dead_link_ = 0; + UInt32 incr_ = 0; + + LinkedList snd_queue_; + LinkedList rcv_queue_; + LinkedList snd_buf_; + LinkedList rcv_buf_; + + UInt32[] acklist_; + UInt32 ackcount_ = 0; + UInt32 ackblock_ = 0; + + byte[] buffer_; + object user_; + + Int32 fastresend_ = 0; + Int32 nocwnd_ = 0; + + public delegate void OutputDelegate(byte[] data, int size, object user); + OutputDelegate output_; + + // create a new kcp control object, 'conv' must equal in two endpoint + // from the same connection. 'user' will be passed to the output callback + // output callback can be setup like this: 'kcp->output = my_udp_output' + public KCP(UInt32 conv, object user) + { + Debug.Assert(BitConverter.IsLittleEndian); // we only support little endian device + + user_ = user; + conv_ = conv; + snd_wnd_ = IKCP_WND_SND; + rcv_wnd_ = IKCP_WND_RCV; + rmt_wnd_ = IKCP_WND_RCV; + mtu_ = IKCP_MTU_DEF; + mss_ = mtu_ - IKCP_OVERHEAD; + rx_rto_ = IKCP_RTO_DEF; + rx_minrto_ = IKCP_RTO_MIN; + interval_ = IKCP_INTERVAL; + ts_flush_ = IKCP_INTERVAL; + ssthresh_ = IKCP_THRESH_INIT; + dead_link_ = IKCP_DEADLINK; + buffer_ = new byte[(mtu_ + IKCP_OVERHEAD) * 3]; + snd_queue_ = new LinkedList(); + rcv_queue_ = new LinkedList(); + snd_buf_ = new LinkedList(); + rcv_buf_ = new LinkedList(); + } + + // release kcp control object + public void Release() + { + snd_buf_.Clear(); + rcv_buf_.Clear(); + snd_queue_.Clear(); + rcv_queue_.Clear(); + nrcv_buf_ = 0; + nsnd_buf_ = 0; + nrcv_que_ = 0; + nsnd_que_ = 0; + ackblock_ = 0; + ackcount_ = 0; + buffer_ = null; + acklist_ = null; + } + + // set output callback, which will be invoked by kcp + public void SetOutput(OutputDelegate output) + { + output_ = output; + } + + // user/upper level recv: returns size, returns below zero for EAGAIN + public int Recv(byte[] buffer, int offset, int len) + { + int ispeek = (len < 0 ? 1 : 0); + int recover = 0; + + if (rcv_queue_.Count == 0) + return -1; + + if (len < 0) + len = -len; + + int peeksize = PeekSize(); + if (peeksize < 0) + return -2; + + if (peeksize > len) + return -3; + + if (nrcv_que_ >= rcv_wnd_) + recover = 1; + + // merge fragment + len = 0; + LinkedListNode next = null; + for (var node = rcv_queue_.First; node != null; node = next) + { + int fragment = 0; + var seg = node.Value; + next = node.Next; + + if (buffer != null) + { + Buffer.BlockCopy(seg.data, 0, buffer, offset, seg.data.Length); + offset += seg.data.Length; + } + len += seg.data.Length; + fragment = (int)seg.frg; + + Log(IKCP_LOG_RECV, "recv sn={0}", seg.sn); + + if (ispeek == 0) + { + rcv_queue_.Remove(node); + nrcv_que_--; + } + + if (fragment == 0) + break; + } + + Debug.Assert(len == peeksize); + + // move available data from rcv_buf -> rcv_queue + while (rcv_buf_.Count > 0) + { + var node = rcv_buf_.First; + var seg = node.Value; + if (seg.sn == rcv_nxt_ && nrcv_que_ < rcv_wnd_) + { + rcv_buf_.Remove(node); + nrcv_buf_--; + rcv_queue_.AddLast(node); + nrcv_que_++; + rcv_nxt_++; + } + else + { + break; + } + } + + // fast recover + if (nrcv_que_ < rcv_wnd_ && recover != 0) + { + // ready to send back IKCP_CMD_WINS in ikcp_flush + // tell remote my window size + probe_ |= IKCP_ASK_TELL; + } + + return len; + } + + // check the size of next message in the recv queue + public int PeekSize() + { + if (rcv_queue_.Count == 0) + return -1; + + var node = rcv_queue_.First; + var seg = node.Value; + if (seg.frg == 0) + return seg.data.Length; + + if (nrcv_que_ < seg.frg + 1) + return -1; + + int length = 0; + for (node = rcv_queue_.First; node != null; node = node.Next) + { + seg = node.Value; + length += seg.data.Length; + if (seg.frg == 0) + break; + } + return length; + } + + // user/upper level send, returns below zero for error + public int Send(byte[] buffer, int offset, int len) + { + Debug.Assert(mss_ > 0); + if (len < 0) + return -1; + + // + // not implement streaming mode here as ikcp.c + // + + int count = 0; + if (len <= (int)mss_) + count = 1; + else + count = (len + (int)mss_ - 1) / (int)mss_; + + if (count > 255) // maximum value `frg` can present + return -2; + + if (count == 0) + count = 1; + + // fragment + for (int i = 0; i < count; i++) + { + int size = len > (int)mss_ ? (int)mss_ : len; + var seg = new Segment(size); + if (buffer != null && len > 0) + { + Buffer.BlockCopy(buffer, offset, seg.data, 0, size); + offset += size; + } + seg.frg = (UInt32)(count - i - 1); + snd_queue_.AddLast(seg); + nsnd_que_++; + len -= size; + } + return 0; + } + + // parse ack + void UpdateACK(Int32 rtt) + { + if (rx_srtt_ == 0) + { + rx_srtt_ = rtt; + rx_rttval_ = rtt / 2; + } + else + { + Int32 delta = rtt - rx_srtt_; + if (delta < 0) + delta = -delta; + + rx_rttval_ = (3 * rx_rttval_ + delta) / 4; + rx_srtt_ = (7 * rx_srtt_ + rtt) / 8; + if (rx_srtt_ < 1) + rx_srtt_ = 1; + } + + var rto = rx_srtt_ + _imax_(interval_, (UInt32)(4 * rx_rttval_)); + rx_rto_ = (Int32)_ibound_((UInt32)rx_minrto_, (UInt32)rto, IKCP_RTO_MAX); + } + + void ShrinkBuf() + { + var node = snd_buf_.First; + if (node != null) + { + var seg = node.Value; + snd_una_ = seg.sn; + } + else + { + snd_una_ = snd_nxt_; + } + } + + void ParseACK(UInt32 sn) + { + if (_itimediff(sn, snd_una_) < 0 || _itimediff(sn, snd_nxt_) >= 0) + return; + + LinkedListNode next = null; + for (var node = snd_buf_.First; node != null; node = next) + { + var seg = node.Value; + next = node.Next; + if (sn == seg.sn) + { + snd_buf_.Remove(node); + nsnd_buf_--; + break; + } + if (_itimediff(sn, seg.sn) < 0) + break; + } + } + + void ParseUNA(UInt32 una) + { + LinkedListNode next = null; + for (var node = snd_buf_.First; node != null; node = next) + { + var seg = node.Value; + next = node.Next; + if (_itimediff(una, seg.sn) > 0) + { + snd_buf_.Remove(node); + nsnd_buf_--; + } + else + { + break; + } + } + } + + void ParseFastACK(UInt32 sn) + { + if (_itimediff(sn, snd_una_) < 0 || _itimediff(sn, snd_nxt_) >= 0) + return; + + LinkedListNode next = null; + for (var node = snd_buf_.First; node != null; node = next) + { + var seg = node.Value; + next = node.Next; + if (_itimediff(sn, seg.sn) < 0) + { + break; + } + else if (sn != seg.sn) + { + seg.faskack++; + } + } + } + + // ack append + void ACKPush(UInt32 sn, UInt32 ts) + { + var newsize = ackcount_ + 1; + if (newsize > ackblock_) + { + UInt32 newblock = 8; + for (; newblock < newsize; newblock <<= 1) + ; + + var acklist = new UInt32[newblock * 2]; + if (acklist_ != null) + { + for (var i = 0; i < ackcount_; i++) + { + acklist[i * 2] = acklist_[i * 2]; + acklist[i * 2 + 1] = acklist_[i * 2 + 1]; + } + } + acklist_ = acklist; + ackblock_ = newblock; + } + acklist_[ackcount_ * 2] = sn; + acklist_[ackcount_ * 2 + 1] = ts; + ackcount_++; + } + + void ACKGet(int pos, ref UInt32 sn, ref UInt32 ts) + { + sn = acklist_[pos * 2]; + ts = acklist_[pos * 2 + 1]; + } + + // parse data + void ParseData(Segment newseg) + { + UInt32 sn = newseg.sn; + int repeat = 0; + + if (_itimediff(sn, rcv_nxt_ + rcv_wnd_) >= 0 || + _itimediff(sn, rcv_nxt_) < 0) + { + return; + } + + LinkedListNode node = null; + LinkedListNode prev = null; + for (node = rcv_buf_.Last; node != null; node = prev) + { + var seg = node.Value; + prev = node.Previous; + if (seg.sn == sn) + { + repeat = 1; + break; + } + if (_itimediff(sn, seg.sn) > 0) + { + break; + } + } + if (repeat == 0) + { + if (node != null) + { + rcv_buf_.AddAfter(node, newseg); + } + else + { + rcv_buf_.AddFirst(newseg); + } + nrcv_buf_++; + } + + // move available data from rcv_buf -> rcv_queue + while (rcv_buf_.Count > 0) + { + node = rcv_buf_.First; + var seg = node.Value; + if (seg.sn == rcv_nxt_ && nrcv_que_ < rcv_wnd_) + { + rcv_buf_.Remove(node); + nrcv_buf_--; + rcv_queue_.AddLast(node); + nrcv_que_++; + rcv_nxt_++; + } + else + { + break; + } + } + } + + // when you received a low level packet (eg. UDP packet), call it + public int Input(byte[] data, int offset, int size) + { + UInt32 maxack = 0; + int flag = 0; + + Log(IKCP_LOG_INPUT, "[RI] {0} bytes", size); + + if (data == null || size < IKCP_OVERHEAD) + return -1; + + while (true) + { + if (size < IKCP_OVERHEAD) + break; + + UInt32 conv = ikcp_decode32u(data, ref offset); + if (conv_ != conv) + return -1; + UInt32 cmd = ikcp_decode8u(data, ref offset); + UInt32 frg = ikcp_decode8u(data, ref offset); + UInt32 wnd = ikcp_decode16u(data, ref offset); + UInt32 ts = ikcp_decode32u(data, ref offset); + UInt32 sn = ikcp_decode32u(data, ref offset); + UInt32 una = ikcp_decode32u(data, ref offset); + UInt32 len = ikcp_decode32u(data, ref offset); + + size -= IKCP_OVERHEAD; + if (size < len) + return -2; + + if (cmd != IKCP_CMD_PUSH && cmd != IKCP_CMD_ACK && + cmd != IKCP_CMD_WASK && cmd != IKCP_CMD_WINS) + return -3; + + rmt_wnd_ = wnd; + ParseUNA(una); + ShrinkBuf(); + + if (cmd == IKCP_CMD_ACK) + { + if (_itimediff(current_, ts) >= 0) + { + UpdateACK(_itimediff(current_, ts)); + } + ParseACK(sn); + ShrinkBuf(); + if (flag == 0) + { + flag = 1; + maxack = sn; + } + else + { + if (_itimediff(sn, maxack) > 0) + { + maxack = sn; + } + } + Log(IKCP_LOG_IN_DATA, "input ack: sn={0} rtt={1} rto={2}", + sn, _itimediff(current_, ts), rx_rto_); + } + else if (cmd == IKCP_CMD_PUSH) + { + Log(IKCP_LOG_IN_DATA, "input psh: sn={0} ts={1}", sn, ts); + if (_itimediff(sn, rcv_nxt_ + rcv_wnd_) < 0) + { + ACKPush(sn, ts); + if (_itimediff(sn, rcv_nxt_) >= 0) + { + var seg = new Segment((int)len); + seg.conv = conv; + seg.cmd = cmd; + seg.frg = frg; + seg.wnd = wnd; + seg.ts = ts; + seg.sn = sn; + seg.una = una; + if (len > 0) + { + Buffer.BlockCopy(data, offset, seg.data, 0, (int)len); + } + ParseData(seg); + } + } + } + else if (cmd == IKCP_CMD_WASK) + { + // ready to send back IKCP_CMD_WINS in ikcp_flush + // tell remote my window size + probe_ |= IKCP_ASK_TELL; + Log(IKCP_LOG_IN_PROBE, "input probe"); + } + else if (cmd == IKCP_CMD_WINS) + { + // do nothing + Log(IKCP_LOG_IN_WINS, "input wins: {0}", wnd); + } + else + { + return -3; + } + + offset += (int)len; + size -= (int)len; + } + + if (flag != 0) + { + ParseFastACK(maxack); + } + + UInt32 unack = snd_una_; + if (_itimediff(snd_una_, unack) > 0) + { + if (cwnd_ < rmt_wnd_) + { + if (cwnd_ < ssthresh_) + { + cwnd_++; + incr_ += mss_; + } + else + { + if (incr_ < mss_) + incr_ = mss_; + incr_ += (mss_ * mss_) / incr_ + (mss_ / 16); + if ((cwnd_ + 1) * mss_ <= incr_) + cwnd_++; + } + if (cwnd_ > rmt_wnd_) + { + cwnd_ = rmt_wnd_; + incr_ = rmt_wnd_ * mss_; + } + } + } + + return 0; + } + + int WndUnused() + { + if (nrcv_que_ < rcv_wnd_) + return (int)(rcv_wnd_ - nrcv_que_); + return 0; + } + + // flush pending data + void Flush() + { + int change = 0; + int lost = 0; + int offset = 0; + + // 'ikcp_update' haven't been called. + if (updated_ == 0) + return; + + var seg = new Segment + { + conv = conv_, + cmd = IKCP_CMD_ACK, + wnd = (UInt32)WndUnused(), + una = rcv_nxt_, + }; + + // flush acknowledges + int count = (int)ackcount_; + for (int i = 0; i < count; i++) + { + if ((offset + IKCP_OVERHEAD) > mtu_) + { + output_(buffer_, offset, user_); + offset = 0; + } + ACKGet(i, ref seg.sn, ref seg.ts); + seg.Encode(buffer_, ref offset); + } + + ackcount_ = 0; + + // probe window size (if remote window size equals zero) + if (rmt_wnd_ == 0) + { + if (probe_wait_ == 0) + { + probe_wait_ = IKCP_PROBE_INIT; + ts_probe_ = current_ + probe_wait_; + } + else + { + if (_itimediff(current_, ts_probe_) >= 0) + { + if (probe_wait_ < IKCP_PROBE_INIT) + probe_wait_ = IKCP_PROBE_INIT; + probe_wait_ += probe_wait_ / 2; + if (probe_wait_ > IKCP_PROBE_LIMIT) + probe_wait_ = IKCP_PROBE_LIMIT; + ts_probe_ = current_ + probe_wait_; + probe_ |= IKCP_ASK_SEND; + } + } + } + else + { + ts_probe_ = 0; + probe_wait_ = 0; + } + + // flush window probing commands + if ((probe_ & IKCP_ASK_SEND) > 0) + { + seg.cmd = IKCP_CMD_WASK; + if ((offset + IKCP_OVERHEAD) > mtu_) + { + output_(buffer_, offset, user_); + offset = 0; + } + seg.Encode(buffer_, ref offset); + } + + // flush window probing commands + if ((probe_ & IKCP_ASK_TELL) > 0) + { + seg.cmd = IKCP_CMD_WINS; + if ((offset + IKCP_OVERHEAD) > mtu_) + { + output_(buffer_, offset, user_); + offset = 0; + } + seg.Encode(buffer_, ref offset); + } + + probe_ = 0; + + // calculate window size + UInt32 cwnd = _imin_(snd_wnd_, rmt_wnd_); + if (nocwnd_ == 0) + cwnd = _imin_(cwnd_, cwnd); + + // move data from snd_queue to snd_buf + while (_itimediff(snd_nxt_, snd_una_ + cwnd) < 0) + { + if (snd_queue_.Count == 0) + break; + + var node = snd_queue_.First; + var newseg = node.Value; + snd_queue_.Remove(node); + snd_buf_.AddLast(node); + nsnd_que_--; + nsnd_buf_++; + + newseg.conv = conv_; + newseg.cmd = IKCP_CMD_PUSH; + newseg.wnd = seg.wnd; + newseg.ts = current_; + newseg.sn = snd_nxt_++; + newseg.una = rcv_nxt_; + newseg.resendts = current_; + newseg.rto = (UInt32)rx_rto_; + newseg.faskack = 0; + newseg.xmit = 0; + } + + // calculate resent + UInt32 resent = (fastresend_ > 0 ? (UInt32)fastresend_ : 0xffffffff); + UInt32 rtomin = (nodelay_ == 0 ? (UInt32)(rx_rto_ >> 3) : 0); + + // flush data segments + for (var node = snd_buf_.First; node != null; node = node.Next) + { + var segment = node.Value; + int needsend = 0; + if (segment.xmit == 0) + { + needsend = 1; + segment.xmit++; + segment.rto = (UInt32)rx_rto_; + segment.resendts = current_ + segment.rto + rtomin; + } + else if (_itimediff(current_, segment.resendts) >= 0) + { + needsend = 1; + segment.xmit++; + xmit_++; + if (nodelay_ == 0) + segment.rto += (UInt32)rx_rto_; + else + segment.rto += (UInt32)rx_rto_ / 2; + segment.resendts = current_ + segment.rto; + lost = 1; + } + else if (segment.faskack >= resent) + { + needsend = 1; + segment.xmit++; + segment.faskack = 0; + segment.resendts = current_ + segment.rto; + change++; + } + + if (needsend > 0) + { + segment.ts = current_; + segment.wnd = seg.wnd; + segment.una = rcv_nxt_; + + int need = IKCP_OVERHEAD; + if (segment.data != null) + need += segment.data.Length; + + if (offset + need > mtu_) + { + output_(buffer_, offset, user_); + offset = 0; + } + segment.Encode(buffer_, ref offset); + if (segment.data.Length > 0) + { + Buffer.BlockCopy(segment.data, 0, buffer_, offset, segment.data.Length); + offset += segment.data.Length; + } + if (segment.xmit >= dead_link_) + state_ = 0xffffffff; + } + } + + // flush remain segments + if (offset > 0) + { + output_(buffer_, offset, user_); + offset = 0; + } + + // update ssthresh + if (change > 0) + { + UInt32 inflight = snd_nxt_ - snd_una_; + ssthresh_ = inflight / 2; + if (ssthresh_ < IKCP_THRESH_MIN) + ssthresh_ = IKCP_THRESH_MIN; + cwnd_ = ssthresh_ + resent; + incr_ = cwnd_ * mss_; + } + + if (lost > 0) + { + ssthresh_ = cwnd / 2; + if (ssthresh_ < IKCP_THRESH_MIN) + ssthresh_ = IKCP_THRESH_MIN; + cwnd_ = 1; + incr_ = mss_; + } + + if (cwnd_ < 1) + { + cwnd_ = 1; + incr_ = mss_; + } + } + + // update state (call it repeatedly, every 10ms-100ms), or you can ask + // ikcp_check when to call it again (without ikcp_input/_send calling). + // 'current' - current timestamp in millisec. + public void Update(UInt32 current) + { + current_ = current; + if (updated_ == 0) + { + updated_ = 1; + ts_flush_ = current; + } + + Int32 slap = _itimediff(current_, ts_flush_); + if (slap >= 10000 || slap < -10000) + { + ts_flush_ = current; + slap = 0; + } + + if (slap >= 0) + { + ts_flush_ += interval_; + if (_itimediff(current_, ts_flush_) >= 0) + ts_flush_ = current_ + interval_; + + Flush(); + } + } + + // Determine when should you invoke ikcp_update: + // returns when you should invoke ikcp_update in millisec, if there + // is no ikcp_input/_send calling. you can call ikcp_update in that + // time, instead of call update repeatly. + // Important to reduce unnacessary ikcp_update invoking. use it to + // schedule ikcp_update (eg. implementing an epoll-like mechanism, + // or optimize ikcp_update when handling massive kcp connections) + public UInt32 Check(UInt32 current) + { + UInt32 ts_flush = ts_flush_; + Int32 tm_flush = 0x7fffffff; + Int32 tm_packet = 0x7fffffff; + + if (updated_ == 0) + return current; + + if (_itimediff(current, ts_flush) >= 10000 || + _itimediff(current, ts_flush) < -10000) + { + ts_flush = current; + } + + if (_itimediff(current, ts_flush) >= 0) + return current; + + tm_flush = _itimediff(ts_flush, current); + + for (var node = snd_buf_.First; node != null; node = node.Next) + { + var seg = node.Value; + Int32 diff = _itimediff(seg.resendts, current); + if (diff <= 0) + return current; + + if (diff < tm_packet) + tm_packet = diff; + } + + UInt32 minimal = (UInt32)(tm_packet < tm_flush ? tm_packet : tm_flush); + if (minimal >= interval_) + minimal = interval_; + + return current + minimal; + } + + // change MTU size, default is 1400 + public int SetMTU(int mtu) + { + if (mtu < 50 || mtu < IKCP_OVERHEAD) + return -1; + + var buffer = new byte[(mtu + IKCP_OVERHEAD) * 3]; + mtu_ = (UInt32)mtu; + mss_ = mtu_ - IKCP_OVERHEAD; + buffer_ = buffer; + return 0; + } + + public int Interval(int interval) + { + if (interval > 5000) + interval = 5000; + else if (interval < 10) + interval = 10; + + interval_ = (UInt32)interval; + return 0; + } + + // fastest: ikcp_nodelay(kcp, 1, 20, 2, 1) + // nodelay: 0:disable(default), 1:enable + // interval: internal update timer interval in millisec, default is 100ms + // resend: 0:disable fast resend(default), 1:enable fast resend + // nc: 0:normal congestion control(default), 1:disable congestion control + public int NoDelay(int nodelay, int interval, int resend, int nc) + { + if (nodelay >= 0) + { + nodelay_ = (UInt32)nodelay; + if (nodelay > 0) + { + rx_minrto_ = IKCP_RTO_NDL; + } + else + { + rx_minrto_ = IKCP_RTO_MIN; + } + } + if (interval >= 0) + { + if (interval > 5000) + interval = 5000; + else if (interval < 10) + interval = 10; + + interval_ = (UInt32)interval; + } + + if (resend >= 0) + fastresend_ = resend; + + if (nc >= 0) + nocwnd_ = nc; + + return 0; + } + + // set maximum window size: sndwnd=32, rcvwnd=32 by default + public int WndSize(int sndwnd, int rcvwnd) + { + if (sndwnd > 0) + snd_wnd_ = (UInt32)sndwnd; + if (rcvwnd > 0) + rcv_wnd_ = (UInt32)rcvwnd; + return 0; + } + + // get how many packet is waiting to be sent + public int WaitSnd() + { + return (int)(nsnd_buf_ + nsnd_que_); + } + + // read conv + public UInt32 GetConv() + { + return conv_; + } + + public UInt32 GetState() + { + return state_; + } + + public void SetMinRTO(int minrto) + { + rx_minrto_ = minrto; + } + + public void SetFastResend(int resend) + { + fastresend_ = resend; + } + + void Log(int mask, string format, params object[] args) + { + // Console.WriteLine(mask + String.Format(format, args)); + } + } +} diff --git a/kbengine_demos_assets b/kbengine_demos_assets index 32e92f0..1ac8fcb 160000 --- a/kbengine_demos_assets +++ b/kbengine_demos_assets @@ -1 +1 @@ -Subproject commit 32e92f0b3604b4b1180c4f6982eb9f8199010a06 +Subproject commit 1ac8fcb5b3ee8412d37be4d9c3b113a809fd8c0d