network fixes, documentation, etc
This commit is contained in:
parent
a30ac75573
commit
4ae09e7afb
@ -13,34 +13,41 @@
|
|||||||
"messageTypes" : [
|
"messageTypes" : [
|
||||||
{
|
{
|
||||||
"messageName" : "RequestCharacterList",
|
"messageName" : "RequestCharacterList",
|
||||||
|
"description" : "Requests the list of characters from the server for the logged in user account",
|
||||||
"data" : []
|
"data" : []
|
||||||
},
|
},
|
||||||
{
|
{
|
||||||
"messageName" : "ResponseCharacterList",
|
"messageName" : "ResponseCharacterList",
|
||||||
|
"description" : "Gives the client the list of characters available to it",
|
||||||
"data" : [
|
"data" : [
|
||||||
"data"
|
"data"
|
||||||
]
|
]
|
||||||
},
|
},
|
||||||
{
|
{
|
||||||
"messageName" : "RequestCreateCharacter",
|
"messageName" : "RequestCreateCharacter",
|
||||||
|
"description" : "Requests that the server create a new character with the data provided",
|
||||||
"data" : [
|
"data" : [
|
||||||
"data"
|
"data"
|
||||||
]
|
]
|
||||||
},
|
},
|
||||||
{
|
{
|
||||||
"messageName" : "ResponseCreateCharacterSuccess",
|
"messageName" : "ResponseCreateCharacterSuccess",
|
||||||
|
"description" : "Tells the client that it successfully created a character",
|
||||||
"data" : []
|
"data" : []
|
||||||
},
|
},
|
||||||
{
|
{
|
||||||
"messageName" : "ResponseCreateCharacterFailure",
|
"messageName" : "ResponseCreateCharacterFailure",
|
||||||
|
"description" : "Tells the client that it failed to create a character",
|
||||||
"data" : []
|
"data" : []
|
||||||
},
|
},
|
||||||
{
|
{
|
||||||
"messageName" : "RequestSpawnCharacter",
|
"messageName" : "RequestSpawnCharacter",
|
||||||
|
"description" : "Requests that the server spawn the client in as a given character",
|
||||||
"data" : []
|
"data" : []
|
||||||
},
|
},
|
||||||
{
|
{
|
||||||
"messageName" : "ResponseSpawnCharacter",
|
"messageName" : "ResponseSpawnCharacter",
|
||||||
|
"description" : "Deprecated - Unused",
|
||||||
"data" : [
|
"data" : [
|
||||||
"data"
|
"data"
|
||||||
]
|
]
|
||||||
|
|||||||
105
net/entity.json
105
net/entity.json
@ -117,6 +117,7 @@
|
|||||||
"messageTypes" : [
|
"messageTypes" : [
|
||||||
{
|
{
|
||||||
"messageName" : "Create",
|
"messageName" : "Create",
|
||||||
|
"description" : "Spawns an empty entity on the client",
|
||||||
"data" : [
|
"data" : [
|
||||||
"entityID",
|
"entityID",
|
||||||
"entityCategory",
|
"entityCategory",
|
||||||
@ -128,6 +129,7 @@
|
|||||||
},
|
},
|
||||||
{
|
{
|
||||||
"messageName" : "SpawnCreature",
|
"messageName" : "SpawnCreature",
|
||||||
|
"description" : "Spawns a creature on the client",
|
||||||
"data" : [
|
"data" : [
|
||||||
"entityID",
|
"entityID",
|
||||||
"creatureTemplate",
|
"creatureTemplate",
|
||||||
@ -138,6 +140,7 @@
|
|||||||
},
|
},
|
||||||
{
|
{
|
||||||
"messageName" : "SpawnItem",
|
"messageName" : "SpawnItem",
|
||||||
|
"description" : "Spawns an item on the client",
|
||||||
"data" : [
|
"data" : [
|
||||||
"entityID",
|
"entityID",
|
||||||
"creatureTemplate",
|
"creatureTemplate",
|
||||||
@ -146,28 +149,9 @@
|
|||||||
"positionZ"
|
"positionZ"
|
||||||
]
|
]
|
||||||
},
|
},
|
||||||
{
|
|
||||||
"messageName" : "SetPosition",
|
|
||||||
"data" : [
|
|
||||||
"entityID",
|
|
||||||
"time",
|
|
||||||
"positionX",
|
|
||||||
"positionY",
|
|
||||||
"positionZ"
|
|
||||||
]
|
|
||||||
},
|
|
||||||
{
|
|
||||||
"messageName" : "setFacing",
|
|
||||||
"data" : [
|
|
||||||
"entityID",
|
|
||||||
"time",
|
|
||||||
"rotationX",
|
|
||||||
"rotationY",
|
|
||||||
"rotationZ"
|
|
||||||
]
|
|
||||||
},
|
|
||||||
{
|
{
|
||||||
"messageName" : "moveUpdate",
|
"messageName" : "moveUpdate",
|
||||||
|
"description" : "Updates a client on the move state of an entity",
|
||||||
"data" : [
|
"data" : [
|
||||||
"entityID",
|
"entityID",
|
||||||
"time",
|
"time",
|
||||||
@ -179,11 +163,13 @@
|
|||||||
"rotationZ",
|
"rotationZ",
|
||||||
"rotationW",
|
"rotationW",
|
||||||
"velocity",
|
"velocity",
|
||||||
|
"propertyValueInt",
|
||||||
"treeState"
|
"treeState"
|
||||||
]
|
]
|
||||||
},
|
},
|
||||||
{
|
{
|
||||||
"messageName" : "attackUpdate",
|
"messageName" : "attackUpdate",
|
||||||
|
"description" : "Updates the client on the status of a given attack",
|
||||||
"data" : [
|
"data" : [
|
||||||
"entityID",
|
"entityID",
|
||||||
"time",
|
"time",
|
||||||
@ -199,20 +185,12 @@
|
|||||||
},
|
},
|
||||||
{
|
{
|
||||||
"messageName" : "startAttack",
|
"messageName" : "startAttack",
|
||||||
|
"description" : "Alerts the server that the client wants to start attacking",
|
||||||
"data" : []
|
"data" : []
|
||||||
},
|
},
|
||||||
{
|
|
||||||
"messageName" : "Move",
|
|
||||||
"data" : [
|
|
||||||
"entityID",
|
|
||||||
"time",
|
|
||||||
"positionX",
|
|
||||||
"positionY",
|
|
||||||
"positionZ"
|
|
||||||
]
|
|
||||||
},
|
|
||||||
{
|
{
|
||||||
"messageName" : "Kill",
|
"messageName" : "Kill",
|
||||||
|
"description" : "Kills an entity (ie plays death animation, creates effects, etc -- does not actually delete the entity from data/scene)",
|
||||||
"data" : [
|
"data" : [
|
||||||
"time",
|
"time",
|
||||||
"entityID"
|
"entityID"
|
||||||
@ -220,21 +198,14 @@
|
|||||||
},
|
},
|
||||||
{
|
{
|
||||||
"messageName" : "Destroy",
|
"messageName" : "Destroy",
|
||||||
|
"description" : "Destroys an entity, clearing it from the client scene",
|
||||||
"data" : [
|
"data" : [
|
||||||
"entityID"
|
"entityID"
|
||||||
]
|
]
|
||||||
},
|
},
|
||||||
{
|
|
||||||
"messageName" : "SetBehaviorTree",
|
|
||||||
"data" : [
|
|
||||||
"entityID",
|
|
||||||
"time",
|
|
||||||
"treeType",
|
|
||||||
"treeStatus"
|
|
||||||
]
|
|
||||||
},
|
|
||||||
{
|
{
|
||||||
"messageName" : "setProperty",
|
"messageName" : "setProperty",
|
||||||
|
"description" : "Sets a property on an entity (old method user to set the player's entity)",
|
||||||
"data" : [
|
"data" : [
|
||||||
"entityID",
|
"entityID",
|
||||||
"time",
|
"time",
|
||||||
@ -242,58 +213,9 @@
|
|||||||
"propertyValue"
|
"propertyValue"
|
||||||
]
|
]
|
||||||
},
|
},
|
||||||
{
|
|
||||||
"messageName": "setBTreePropertyInt",
|
|
||||||
"data" : [
|
|
||||||
"entityID",
|
|
||||||
"time",
|
|
||||||
"bTreeID",
|
|
||||||
"propertyID",
|
|
||||||
"propertyValueInt"
|
|
||||||
]
|
|
||||||
},
|
|
||||||
{
|
|
||||||
"messageName": "setBTreePropertyFloat",
|
|
||||||
"data" : [
|
|
||||||
"entityID",
|
|
||||||
"time",
|
|
||||||
"bTreeID",
|
|
||||||
"propertyID",
|
|
||||||
"propertyValueFloat"
|
|
||||||
]
|
|
||||||
},
|
|
||||||
{
|
|
||||||
"messageName": "setBTreePropertyDouble",
|
|
||||||
"data" : [
|
|
||||||
"entityID",
|
|
||||||
"time",
|
|
||||||
"bTreeID",
|
|
||||||
"propertyID",
|
|
||||||
"propertyValueDouble"
|
|
||||||
]
|
|
||||||
},
|
|
||||||
{
|
|
||||||
"messageName": "setBTreePropertyString",
|
|
||||||
"data" : [
|
|
||||||
"entityID",
|
|
||||||
"time",
|
|
||||||
"bTreeID",
|
|
||||||
"propertyID",
|
|
||||||
"propertyValueString"
|
|
||||||
]
|
|
||||||
},
|
|
||||||
{
|
|
||||||
"messageName": "setBTreePropertyEnum",
|
|
||||||
"data" : [
|
|
||||||
"entityID",
|
|
||||||
"time",
|
|
||||||
"bTreeID",
|
|
||||||
"propertyID",
|
|
||||||
"propertyValueInt"
|
|
||||||
]
|
|
||||||
},
|
|
||||||
{
|
{
|
||||||
"messageName" : "attachEntityToEntity",
|
"messageName" : "attachEntityToEntity",
|
||||||
|
"description" : "Tells the client to attach an entity to another entity",
|
||||||
"data" : [
|
"data" : [
|
||||||
"entityID",
|
"entityID",
|
||||||
"bone",
|
"bone",
|
||||||
@ -302,6 +224,7 @@
|
|||||||
},
|
},
|
||||||
{
|
{
|
||||||
"messageName" : "SpawnFoliageSeed",
|
"messageName" : "SpawnFoliageSeed",
|
||||||
|
"description" : "Spawns a foliage object on the client with a given seed value",
|
||||||
"data" : [
|
"data" : [
|
||||||
"entityID",
|
"entityID",
|
||||||
"creatureTemplate",
|
"creatureTemplate",
|
||||||
@ -313,13 +236,13 @@
|
|||||||
},
|
},
|
||||||
{
|
{
|
||||||
"messageName" : "updateEntityViewDir",
|
"messageName" : "updateEntityViewDir",
|
||||||
|
"description" : "Updates the server's value for where the player is looking",
|
||||||
"data" : [
|
"data" : [
|
||||||
"entityID",
|
"entityID",
|
||||||
"time",
|
"time",
|
||||||
"positionX",
|
"positionX",
|
||||||
"positionY",
|
"positionY",
|
||||||
"positionZ",
|
"positionZ"
|
||||||
"propertyValueInt"
|
|
||||||
]
|
]
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|||||||
@ -42,6 +42,7 @@
|
|||||||
},
|
},
|
||||||
{
|
{
|
||||||
"messageName" : "clientRequestEquipItem",
|
"messageName" : "clientRequestEquipItem",
|
||||||
|
"description" : "Requests that the server equip an item to the player's entity",
|
||||||
"data" : [
|
"data" : [
|
||||||
"equipPointId",
|
"equipPointId",
|
||||||
"entityId"
|
"entityId"
|
||||||
@ -49,6 +50,7 @@
|
|||||||
},
|
},
|
||||||
{
|
{
|
||||||
"messageName" : "serverCommandMoveItemContainer",
|
"messageName" : "serverCommandMoveItemContainer",
|
||||||
|
"description" : "Instructs the client to move an item to a container",
|
||||||
"data" : [
|
"data" : [
|
||||||
"entityId",
|
"entityId",
|
||||||
"containerType",
|
"containerType",
|
||||||
@ -57,6 +59,7 @@
|
|||||||
},
|
},
|
||||||
{
|
{
|
||||||
"messageName" : "serverCommandEquipItem",
|
"messageName" : "serverCommandEquipItem",
|
||||||
|
"description" : "Instructs the client to equip an item to an entity",
|
||||||
"data" : [
|
"data" : [
|
||||||
"equipperId",
|
"equipperId",
|
||||||
"equipPointId",
|
"equipPointId",
|
||||||
@ -66,6 +69,7 @@
|
|||||||
},
|
},
|
||||||
{
|
{
|
||||||
"messageName" : "serverCommandUnequipItem",
|
"messageName" : "serverCommandUnequipItem",
|
||||||
|
"description" : "Instructs the client to unequip an item",
|
||||||
"data" : [
|
"data" : [
|
||||||
"equipperId",
|
"equipperId",
|
||||||
"equipPointId"
|
"equipPointId"
|
||||||
@ -73,6 +77,7 @@
|
|||||||
},
|
},
|
||||||
{
|
{
|
||||||
"messageName" : "clientRequestUnequipItem",
|
"messageName" : "clientRequestUnequipItem",
|
||||||
|
"description" : "Requests that the server unequip an item from the client's entity",
|
||||||
"data" : [
|
"data" : [
|
||||||
"equipPointId"
|
"equipPointId"
|
||||||
]
|
]
|
||||||
|
|||||||
@ -13,32 +13,12 @@
|
|||||||
"messageTypes" : [
|
"messageTypes" : [
|
||||||
{
|
{
|
||||||
"messageName" : "RequestRaces",
|
"messageName" : "RequestRaces",
|
||||||
|
"description" : "Requests the data for all races available to the character to play",
|
||||||
"data" : []
|
"data" : []
|
||||||
},
|
},
|
||||||
{
|
{
|
||||||
"messageName" : "ResponseRaces",
|
"messageName" : "ResponseRaces",
|
||||||
"data" : [
|
"description" : "Responds with the data on all races available for play",
|
||||||
"data"
|
|
||||||
]
|
|
||||||
},
|
|
||||||
{
|
|
||||||
"messageName" : "RequestRaceData",
|
|
||||||
"data" : []
|
|
||||||
},
|
|
||||||
{
|
|
||||||
"messageName" : "ResponseRaceData",
|
|
||||||
"data" : [
|
|
||||||
"data"
|
|
||||||
]
|
|
||||||
},
|
|
||||||
{
|
|
||||||
"messageName" : "RequestData",
|
|
||||||
"data" : [
|
|
||||||
"data"
|
|
||||||
]
|
|
||||||
},
|
|
||||||
{
|
|
||||||
"messageName" : "ResponseData",
|
|
||||||
"data" : [
|
"data" : [
|
||||||
"data"
|
"data"
|
||||||
]
|
]
|
||||||
|
|||||||
@ -25,12 +25,14 @@
|
|||||||
"messageTypes" : [
|
"messageTypes" : [
|
||||||
{
|
{
|
||||||
"messageName" : "Set_ID",
|
"messageName" : "Set_ID",
|
||||||
|
"description" : "Provides the server's id for the player",
|
||||||
"data" : [
|
"data" : [
|
||||||
"playerID"
|
"playerID"
|
||||||
]
|
]
|
||||||
},
|
},
|
||||||
{
|
{
|
||||||
"messageName" : "SetInitialDiscretePosition",
|
"messageName" : "SetInitialDiscretePosition",
|
||||||
|
"description" : "Tells the client the initial position of the player entity",
|
||||||
"data" : [
|
"data" : [
|
||||||
"initialDiscretePositionX",
|
"initialDiscretePositionX",
|
||||||
"initialDiscretePositionY",
|
"initialDiscretePositionY",
|
||||||
|
|||||||
@ -10,10 +10,12 @@
|
|||||||
"messageTypes" : [
|
"messageTypes" : [
|
||||||
{
|
{
|
||||||
"messageName" : "Ping",
|
"messageName" : "Ping",
|
||||||
|
"description" : "Pings the other side of the socket",
|
||||||
"data" : []
|
"data" : []
|
||||||
},
|
},
|
||||||
{
|
{
|
||||||
"messageName" : "Pong",
|
"messageName" : "Pong",
|
||||||
|
"description" : "Replies to a ping from the other side of the socket",
|
||||||
"data" : []
|
"data" : []
|
||||||
}
|
}
|
||||||
]
|
]
|
||||||
@ -35,10 +37,12 @@
|
|||||||
"messageTypes" : [
|
"messageTypes" : [
|
||||||
{
|
{
|
||||||
"messageName" : "AuthRequest",
|
"messageName" : "AuthRequest",
|
||||||
|
"description" : "Requests authorization from the client",
|
||||||
"data" : []
|
"data" : []
|
||||||
},
|
},
|
||||||
{
|
{
|
||||||
"messageName" : "AuthDetails",
|
"messageName" : "AuthDetails",
|
||||||
|
"description" : "Tells the server the auth details of this client",
|
||||||
"data" : [
|
"data" : [
|
||||||
"user",
|
"user",
|
||||||
"pass"
|
"pass"
|
||||||
@ -46,10 +50,12 @@
|
|||||||
},
|
},
|
||||||
{
|
{
|
||||||
"messageName" : "AuthSuccess",
|
"messageName" : "AuthSuccess",
|
||||||
|
"description" : "Tells the client it successfully logged in",
|
||||||
"data" : []
|
"data" : []
|
||||||
},
|
},
|
||||||
{
|
{
|
||||||
"messageName" : "AuthFailure",
|
"messageName" : "AuthFailure",
|
||||||
|
"description" : "Tells the client it failed to log in",
|
||||||
"data" : []
|
"data" : []
|
||||||
}
|
}
|
||||||
]
|
]
|
||||||
|
|||||||
@ -30,6 +30,7 @@
|
|||||||
"messageTypes" : [
|
"messageTypes" : [
|
||||||
{
|
{
|
||||||
"messageName" : "UpdateClientState",
|
"messageName" : "UpdateClientState",
|
||||||
|
"description" : "Updates an integer on the client",
|
||||||
"data" : [
|
"data" : [
|
||||||
"entityId",
|
"entityId",
|
||||||
"bTreeId",
|
"bTreeId",
|
||||||
@ -39,6 +40,7 @@
|
|||||||
},
|
},
|
||||||
{
|
{
|
||||||
"messageName" : "UpdateClientStringState",
|
"messageName" : "UpdateClientStringState",
|
||||||
|
"description" : "Updates a string on the client",
|
||||||
"data" : [
|
"data" : [
|
||||||
"entityId",
|
"entityId",
|
||||||
"bTreeId",
|
"bTreeId",
|
||||||
@ -48,6 +50,7 @@
|
|||||||
},
|
},
|
||||||
{
|
{
|
||||||
"messageName" : "AttachTree",
|
"messageName" : "AttachTree",
|
||||||
|
"description" : "Attaches a btree to an entity on the client",
|
||||||
"data" : [
|
"data" : [
|
||||||
"entityId",
|
"entityId",
|
||||||
"bTreeId"
|
"bTreeId"
|
||||||
@ -55,6 +58,7 @@
|
|||||||
},
|
},
|
||||||
{
|
{
|
||||||
"messageName" : "DetatchTree",
|
"messageName" : "DetatchTree",
|
||||||
|
"description" : "Detatches a btree from an entity on the client",
|
||||||
"data" : [
|
"data" : [
|
||||||
"entityId",
|
"entityId",
|
||||||
"bTreeId"
|
"bTreeId"
|
||||||
|
|||||||
@ -102,10 +102,12 @@
|
|||||||
"messageTypes" : [
|
"messageTypes" : [
|
||||||
{
|
{
|
||||||
"messageName" : "RequestMetadata",
|
"messageName" : "RequestMetadata",
|
||||||
|
"description" : "Requests terrain metadata from the server",
|
||||||
"data" : []
|
"data" : []
|
||||||
},
|
},
|
||||||
{
|
{
|
||||||
"messageName" : "ResponseMetadata",
|
"messageName" : "ResponseMetadata",
|
||||||
|
"description" : "Tell the client the terrain metadata",
|
||||||
"data" : [
|
"data" : [
|
||||||
"worldSizeDiscrete",
|
"worldSizeDiscrete",
|
||||||
"dynamicInterpolationRatio",
|
"dynamicInterpolationRatio",
|
||||||
@ -116,15 +118,9 @@
|
|||||||
"worldMaxY"
|
"worldMaxY"
|
||||||
]
|
]
|
||||||
},
|
},
|
||||||
{
|
|
||||||
"messageName" : "RequestChunk",
|
|
||||||
"data" : [
|
|
||||||
"worldX",
|
|
||||||
"worldY"
|
|
||||||
]
|
|
||||||
},
|
|
||||||
{
|
{
|
||||||
"messageName" : "RequestEditVoxel",
|
"messageName" : "RequestEditVoxel",
|
||||||
|
"description" : "Requests that a voxel be edited on the server",
|
||||||
"data" : [
|
"data" : [
|
||||||
"worldX",
|
"worldX",
|
||||||
"worldY",
|
"worldY",
|
||||||
@ -138,6 +134,7 @@
|
|||||||
},
|
},
|
||||||
{
|
{
|
||||||
"messageName" : "UpdateVoxel",
|
"messageName" : "UpdateVoxel",
|
||||||
|
"description" : "Tells the client to update a voxel's value",
|
||||||
"data" : [
|
"data" : [
|
||||||
"worldX",
|
"worldX",
|
||||||
"worldY",
|
"worldY",
|
||||||
@ -151,6 +148,7 @@
|
|||||||
},
|
},
|
||||||
{
|
{
|
||||||
"messageName" : "RequestUseTerrainPalette",
|
"messageName" : "RequestUseTerrainPalette",
|
||||||
|
"description" : "Requests that the current player entity use a given terrain palette",
|
||||||
"data" : [
|
"data" : [
|
||||||
"realLocationX",
|
"realLocationX",
|
||||||
"realLocationY",
|
"realLocationY",
|
||||||
@ -162,6 +160,7 @@
|
|||||||
},
|
},
|
||||||
{
|
{
|
||||||
"messageName" : "SpawnPosition",
|
"messageName" : "SpawnPosition",
|
||||||
|
"description" : "Sets the spawn position of the client",
|
||||||
"data" : [
|
"data" : [
|
||||||
"realLocationX",
|
"realLocationX",
|
||||||
"realLocationY",
|
"realLocationY",
|
||||||
@ -170,6 +169,7 @@
|
|||||||
},
|
},
|
||||||
{
|
{
|
||||||
"messageName" : "RequestChunkData",
|
"messageName" : "RequestChunkData",
|
||||||
|
"description" : "Requests chunk data from the server",
|
||||||
"data" : [
|
"data" : [
|
||||||
"worldX",
|
"worldX",
|
||||||
"worldY",
|
"worldY",
|
||||||
@ -178,6 +178,7 @@
|
|||||||
},
|
},
|
||||||
{
|
{
|
||||||
"messageName" : "sendChunkData",
|
"messageName" : "sendChunkData",
|
||||||
|
"description" : "Sends chunk data to the client",
|
||||||
"data" : [
|
"data" : [
|
||||||
"worldX",
|
"worldX",
|
||||||
"worldY",
|
"worldY",
|
||||||
@ -187,6 +188,7 @@
|
|||||||
},
|
},
|
||||||
{
|
{
|
||||||
"messageName" : "RequestFluidData",
|
"messageName" : "RequestFluidData",
|
||||||
|
"description" : "Requests a fluid data from the server",
|
||||||
"data" : [
|
"data" : [
|
||||||
"worldX",
|
"worldX",
|
||||||
"worldY",
|
"worldY",
|
||||||
@ -195,6 +197,7 @@
|
|||||||
},
|
},
|
||||||
{
|
{
|
||||||
"messageName" : "sendFluidData",
|
"messageName" : "sendFluidData",
|
||||||
|
"description" : "Sends fluid data to the client",
|
||||||
"data" : [
|
"data" : [
|
||||||
"worldX",
|
"worldX",
|
||||||
"worldY",
|
"worldY",
|
||||||
@ -204,6 +207,7 @@
|
|||||||
},
|
},
|
||||||
{
|
{
|
||||||
"messageName" : "updateFluidData",
|
"messageName" : "updateFluidData",
|
||||||
|
"description" : "Updates fluid data on the client",
|
||||||
"data" : [
|
"data" : [
|
||||||
"worldX",
|
"worldX",
|
||||||
"worldY",
|
"worldY",
|
||||||
|
|||||||
@ -10,6 +10,7 @@ import electrosphere.server.datacell.Realm;
|
|||||||
import electrosphere.server.datacell.ServerDataCell;
|
import electrosphere.server.datacell.ServerDataCell;
|
||||||
import electrosphere.server.datacell.utils.EntityLookupUtils;
|
import electrosphere.server.datacell.utils.EntityLookupUtils;
|
||||||
import electrosphere.server.datacell.utils.ServerBehaviorTreeUtils;
|
import electrosphere.server.datacell.utils.ServerBehaviorTreeUtils;
|
||||||
|
import electrosphere.server.datacell.utils.ServerEntityTagUtils;
|
||||||
import electrosphere.server.poseactor.PoseActorUtils;
|
import electrosphere.server.poseactor.PoseActorUtils;
|
||||||
|
|
||||||
public class EntityCreationUtils {
|
public class EntityCreationUtils {
|
||||||
@ -86,6 +87,7 @@ public class EntityCreationUtils {
|
|||||||
entity.putData(EntityDataStrings.DATA_STRING_SCALE, new Vector3f(1,1,1));
|
entity.putData(EntityDataStrings.DATA_STRING_SCALE, new Vector3f(1,1,1));
|
||||||
entity.putData(EntityDataStrings.DATA_STRING_DRAW, true);
|
entity.putData(EntityDataStrings.DATA_STRING_DRAW, true);
|
||||||
entity.putData(EntityDataStrings.DRAW_SOLID_PASS, true);
|
entity.putData(EntityDataStrings.DRAW_SOLID_PASS, true);
|
||||||
|
ServerEntityTagUtils.attachTagToEntity(entity, EntityTags.POSEABLE);
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
||||||
@ -101,7 +103,6 @@ public class EntityCreationUtils {
|
|||||||
entity.putData(EntityDataStrings.DATA_STRING_SCALE, new Vector3f(1,1,1));
|
entity.putData(EntityDataStrings.DATA_STRING_SCALE, new Vector3f(1,1,1));
|
||||||
entity.putData(EntityDataStrings.DATA_STRING_DRAW, true);
|
entity.putData(EntityDataStrings.DATA_STRING_DRAW, true);
|
||||||
entity.putData(EntityDataStrings.DRAW_SOLID_PASS, true);
|
entity.putData(EntityDataStrings.DRAW_SOLID_PASS, true);
|
||||||
Globals.clientScene.registerEntity(entity);
|
|
||||||
Globals.clientScene.registerEntityToTag(entity, EntityTags.DRAWABLE);
|
Globals.clientScene.registerEntityToTag(entity, EntityTags.DRAWABLE);
|
||||||
}
|
}
|
||||||
|
|
||||||
@ -117,7 +118,6 @@ public class EntityCreationUtils {
|
|||||||
entity.putData(EntityDataStrings.DATA_STRING_SCALE, new Vector3f(1,1,1));
|
entity.putData(EntityDataStrings.DATA_STRING_SCALE, new Vector3f(1,1,1));
|
||||||
entity.putData(EntityDataStrings.DATA_STRING_DRAW, true);
|
entity.putData(EntityDataStrings.DATA_STRING_DRAW, true);
|
||||||
entity.putData(EntityDataStrings.DRAW_SOLID_PASS, true);
|
entity.putData(EntityDataStrings.DRAW_SOLID_PASS, true);
|
||||||
Globals.clientScene.registerEntity(entity);
|
|
||||||
Globals.clientScene.registerEntityToTag(entity, EntityTags.DRAWABLE);
|
Globals.clientScene.registerEntityToTag(entity, EntityTags.DRAWABLE);
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|||||||
@ -19,6 +19,7 @@ public class EntityTags {
|
|||||||
public static final String DRAWABLE = "drawable"; //is it drawable
|
public static final String DRAWABLE = "drawable"; //is it drawable
|
||||||
public static final String DRAW_INSTANCED = "drawInstanced"; //if it's instanced, but not necessarily managed by a service (ie a tree branch)
|
public static final String DRAW_INSTANCED = "drawInstanced"; //if it's instanced, but not necessarily managed by a service (ie a tree branch)
|
||||||
public static final String DRAW_INSTANCED_MANAGED = "drawInstancedManaged"; //if it's managed by a service (ie foliage manager)
|
public static final String DRAW_INSTANCED_MANAGED = "drawInstancedManaged"; //if it's managed by a service (ie foliage manager)
|
||||||
|
public static final String POSEABLE = "poseable"; //is it poseable on server
|
||||||
public static final String LIGHT = "light";
|
public static final String LIGHT = "light";
|
||||||
public static final String ITEM = "item";
|
public static final String ITEM = "item";
|
||||||
public static final String GRAVITY = "gravity";
|
public static final String GRAVITY = "gravity";
|
||||||
|
|||||||
@ -17,9 +17,7 @@ import electrosphere.entity.types.attach.AttachUtils;
|
|||||||
import electrosphere.entity.types.collision.CollisionObjUtils;
|
import electrosphere.entity.types.collision.CollisionObjUtils;
|
||||||
import electrosphere.entity.types.creature.CreatureUtils;
|
import electrosphere.entity.types.creature.CreatureUtils;
|
||||||
import electrosphere.entity.types.item.ItemUtils;
|
import electrosphere.entity.types.item.ItemUtils;
|
||||||
import electrosphere.entity.types.projectile.ProjectileUtils;
|
|
||||||
import electrosphere.game.data.creature.type.attack.AttackMove;
|
import electrosphere.game.data.creature.type.attack.AttackMove;
|
||||||
import electrosphere.game.data.creature.type.equip.EquipPoint;
|
|
||||||
import electrosphere.net.parser.net.message.EntityMessage;
|
import electrosphere.net.parser.net.message.EntityMessage;
|
||||||
import electrosphere.net.synchronization.annotation.SyncedField;
|
import electrosphere.net.synchronization.annotation.SyncedField;
|
||||||
import electrosphere.net.synchronization.annotation.SynchronizableEnum;
|
import electrosphere.net.synchronization.annotation.SynchronizableEnum;
|
||||||
@ -29,9 +27,7 @@ import electrosphere.renderer.actor.Actor;
|
|||||||
import java.util.List;
|
import java.util.List;
|
||||||
import java.util.concurrent.CopyOnWriteArrayList;
|
import java.util.concurrent.CopyOnWriteArrayList;
|
||||||
|
|
||||||
import org.joml.Quaterniond;
|
|
||||||
import org.joml.Vector3d;
|
import org.joml.Vector3d;
|
||||||
import org.joml.Vector3f;
|
|
||||||
|
|
||||||
@SynchronizedBehaviorTree(name = "clientAttackTree", isServer = false, correspondingTree="serverAttackTree")
|
@SynchronizedBehaviorTree(name = "clientAttackTree", isServer = false, correspondingTree="serverAttackTree")
|
||||||
/**
|
/**
|
||||||
@ -152,16 +148,20 @@ public class ClientAttackTree implements BehaviorTree {
|
|||||||
@Override
|
@Override
|
||||||
public void simulate(float deltaTime){
|
public void simulate(float deltaTime){
|
||||||
frameCurrent = frameCurrent + (float)Globals.timekeeper.getDeltaFrames();
|
frameCurrent = frameCurrent + (float)Globals.timekeeper.getDeltaFrames();
|
||||||
float velocity = CreatureUtils.getVelocity(parent);
|
|
||||||
Actor entityActor = EntityUtils.getActor(parent);
|
Actor entityActor = EntityUtils.getActor(parent);
|
||||||
Vector3d position = EntityUtils.getPosition(parent);
|
|
||||||
Vector3d movementVector = CreatureUtils.getFacingVector(parent);
|
Vector3d movementVector = CreatureUtils.getFacingVector(parent);
|
||||||
|
|
||||||
|
//
|
||||||
//synchronize move from server
|
//synchronize move from server
|
||||||
if(this.currentMoveset == null){
|
if(this.currentMoveset == null){
|
||||||
this.currentMoveset = getMoveset(getAttackType());
|
this.currentMoveset = getMoveset(getAttackType());
|
||||||
}
|
}
|
||||||
if(this.currentMove == null && this.currentMoveId != null && this.currentMoveset != null){
|
if(
|
||||||
|
this.currentMoveset != null &&
|
||||||
|
(this.currentMove == null && this.currentMoveId != null)
|
||||||
|
||
|
||||||
|
(this.currentMove != null && this.currentMove.getAttackMoveId() != this.currentMoveId)
|
||||||
|
){
|
||||||
for(AttackMove move : currentMoveset){
|
for(AttackMove move : currentMoveset){
|
||||||
if(move.getAttackMoveId().equals(currentMoveId)){
|
if(move.getAttackMoveId().equals(currentMoveId)){
|
||||||
currentMove = move;
|
currentMove = move;
|
||||||
@ -169,6 +169,7 @@ public class ClientAttackTree implements BehaviorTree {
|
|||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
//
|
||||||
//parse attached network messages
|
//parse attached network messages
|
||||||
for(EntityMessage message : networkMessageQueue){
|
for(EntityMessage message : networkMessageQueue){
|
||||||
networkMessageQueue.remove(message);
|
networkMessageQueue.remove(message);
|
||||||
@ -204,17 +205,7 @@ public class ClientAttackTree implements BehaviorTree {
|
|||||||
EntityUtils.getPosition(parent).set(message.getpositionX(),message.getpositionY(),message.getpositionZ());
|
EntityUtils.getPosition(parent).set(message.getpositionX(),message.getpositionY(),message.getpositionZ());
|
||||||
CreatureUtils.setFacingVector(parent, new Vector3d(message.getrotationX(),message.getrotationY(),message.getrotationZ()));
|
CreatureUtils.setFacingVector(parent, new Vector3d(message.getrotationX(),message.getrotationY(),message.getrotationZ()));
|
||||||
break;
|
break;
|
||||||
case ATTACHENTITYTOENTITY:
|
default:
|
||||||
case CREATE:
|
|
||||||
case DESTROY:
|
|
||||||
case MOVE:
|
|
||||||
case MOVEUPDATE:
|
|
||||||
case SETBEHAVIORTREE:
|
|
||||||
case SETFACING:
|
|
||||||
case SETPOSITION:
|
|
||||||
case SETPROPERTY:
|
|
||||||
case KILL:
|
|
||||||
case SPAWNCREATURE:
|
|
||||||
//silently ignore
|
//silently ignore
|
||||||
break;
|
break;
|
||||||
}
|
}
|
||||||
@ -246,7 +237,7 @@ public class ClientAttackTree implements BehaviorTree {
|
|||||||
if(parent.containsKey(EntityDataStrings.CLIENT_ROTATOR_TREE)){
|
if(parent.containsKey(EntityDataStrings.CLIENT_ROTATOR_TREE)){
|
||||||
RotatorTree.getClientRotatorTree(parent).setActive(true);
|
RotatorTree.getClientRotatorTree(parent).setActive(true);
|
||||||
}
|
}
|
||||||
if(currentMove != null && frameCurrent > currentMove.getWindupFrames()){
|
if(currentMove != null){
|
||||||
if(entityActor != null){
|
if(entityActor != null){
|
||||||
if(!entityActor.isPlayingAnimation() || !entityActor.isPlayingAnimation(currentMove.getWindupAnimationName())){
|
if(!entityActor.isPlayingAnimation() || !entityActor.isPlayingAnimation(currentMove.getWindupAnimationName())){
|
||||||
entityActor.playAnimation(currentMove.getWindupAnimationName(),1);
|
entityActor.playAnimation(currentMove.getWindupAnimationName(),1);
|
||||||
@ -281,39 +272,6 @@ public class ClientAttackTree implements BehaviorTree {
|
|||||||
currentState.setActive(true);
|
currentState.setActive(true);
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
if(firesProjectile && projectileToFire != null){
|
|
||||||
//spawn projectile
|
|
||||||
//TODO: solve spawnPosition, initialVector
|
|
||||||
Vector3d spawnPosition = new Vector3d(0,0,0);
|
|
||||||
Quaterniond arrowRotation = new Quaterniond();
|
|
||||||
String targetBone = null;
|
|
||||||
ClientEquipState equipState = ClientEquipState.getEquipState(parent);
|
|
||||||
EquipPoint weaponPoint = null;
|
|
||||||
if((weaponPoint = equipState.getEquipPoint(attackingPoint)) != null){
|
|
||||||
targetBone = weaponPoint.getBone();
|
|
||||||
}
|
|
||||||
if(targetBone != null){
|
|
||||||
Actor parentActor = EntityUtils.getActor(parent);
|
|
||||||
//transform bone space
|
|
||||||
spawnPosition = new Vector3d(parentActor.getBonePosition(targetBone));
|
|
||||||
spawnPosition = spawnPosition.mul(((Vector3f)EntityUtils.getScale(parent)));
|
|
||||||
Quaterniond rotation = EntityUtils.getRotation(parent);
|
|
||||||
spawnPosition = spawnPosition.rotate(new Quaterniond(rotation.x,rotation.y,rotation.z,rotation.w));
|
|
||||||
//transform worldspace
|
|
||||||
spawnPosition.add(new Vector3d(EntityUtils.getPosition(parent)));
|
|
||||||
//set
|
|
||||||
// EntityUtils.getPosition(currentEntity).set(position);
|
|
||||||
//set rotation
|
|
||||||
// Quaternionf rotation = parentActor.getBoneRotation(targetBone);
|
|
||||||
// EntityUtils.getRotation(currentEntity).set(rotation).normalize();
|
|
||||||
// Vector3d facingAngle = CreatureUtils.getFacingVector(parent);
|
|
||||||
arrowRotation = parentActor.getBoneRotation(targetBone);
|
|
||||||
// EntityUtils.getRotation(currentEntity).rotationTo(new Vector3f(0,0,1), new Vector3f((float)facingAngle.x,(float)facingAngle.y,(float)facingAngle.z)).mul(parentActor.getBoneRotation(targetBone)).normalize();
|
|
||||||
}
|
|
||||||
Vector3f initialVector = new Vector3f((float)movementVector.x,(float)movementVector.y,(float)movementVector.z).normalize();
|
|
||||||
ProjectileUtils.clientSpawnBasicProjectile(projectileToFire, spawnPosition, arrowRotation, 750, initialVector, 0.03f);
|
|
||||||
projectileToFire = null;
|
|
||||||
}
|
|
||||||
} break;
|
} break;
|
||||||
case COOLDOWN: {
|
case COOLDOWN: {
|
||||||
//deactive hitboxes
|
//deactive hitboxes
|
||||||
@ -385,7 +343,7 @@ public class ClientAttackTree implements BehaviorTree {
|
|||||||
}
|
}
|
||||||
} else {
|
} else {
|
||||||
if(ClientEquipState.hasEquipState(parent)){
|
if(ClientEquipState.hasEquipState(parent)){
|
||||||
ClientEquipState equipState = ClientEquipState.getEquipState(parent);
|
// ClientEquipState equipState = ClientEquipState.getEquipState(parent);
|
||||||
// if(equipState.hasEquipPrimary()){
|
// if(equipState.hasEquipPrimary()){
|
||||||
// switch(attackType){
|
// switch(attackType){
|
||||||
// case EntityDataStrings.ATTACK_MOVE_TYPE_MELEE_SWING_ONE_HAND:
|
// case EntityDataStrings.ATTACK_MOVE_TYPE_MELEE_SWING_ONE_HAND:
|
||||||
@ -409,6 +367,12 @@ public class ClientAttackTree implements BehaviorTree {
|
|||||||
return rVal;
|
return rVal;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
/**
|
||||||
|
* Gets the object for next move in the current attack chain
|
||||||
|
* @param moveset The moveset to search
|
||||||
|
* @param nextMoveId The id of the next move
|
||||||
|
* @return The object that corresponds to the id if it exists, otherwise false
|
||||||
|
*/
|
||||||
AttackMove getNextMove(List<AttackMove> moveset, String nextMoveId){
|
AttackMove getNextMove(List<AttackMove> moveset, String nextMoveId){
|
||||||
AttackMove rVal = null;
|
AttackMove rVal = null;
|
||||||
for(AttackMove move : moveset){
|
for(AttackMove move : moveset){
|
||||||
|
|||||||
@ -9,7 +9,6 @@ import electrosphere.net.parser.net.message.SynchronizationMessage;
|
|||||||
|
|
||||||
import electrosphere.server.datacell.utils.DataCellSearchUtils;
|
import electrosphere.server.datacell.utils.DataCellSearchUtils;
|
||||||
|
|
||||||
import electrosphere.collision.hitbox.HitboxUtils;
|
|
||||||
import electrosphere.engine.Globals;
|
import electrosphere.engine.Globals;
|
||||||
import electrosphere.entity.Entity;
|
import electrosphere.entity.Entity;
|
||||||
import electrosphere.entity.EntityDataStrings;
|
import electrosphere.entity.EntityDataStrings;
|
||||||
@ -72,8 +71,8 @@ public class ServerAttackTree implements BehaviorTree {
|
|||||||
|
|
||||||
List<AttackMove> currentMoveset = null;
|
List<AttackMove> currentMoveset = null;
|
||||||
@SyncedField
|
@SyncedField
|
||||||
String currentMoveId = null;
|
String currentMoveId = null; //the id of the current move -- used to synchronize the move to client
|
||||||
AttackMove currentMove = null;
|
AttackMove currentMove = null; //the actual current move object
|
||||||
Entity currentWeapon = null;
|
Entity currentWeapon = null;
|
||||||
boolean currentMoveHasWindup;
|
boolean currentMoveHasWindup;
|
||||||
boolean currentMoveCanHold;
|
boolean currentMoveCanHold;
|
||||||
@ -141,7 +140,7 @@ public class ServerAttackTree implements BehaviorTree {
|
|||||||
}
|
}
|
||||||
Vector3d movementVector = CreatureUtils.getFacingVector(parent);
|
Vector3d movementVector = CreatureUtils.getFacingVector(parent);
|
||||||
EntityUtils.getRotation(parent).rotationTo(new Vector3d(0,0,1), new Vector3d(movementVector.x,movementVector.y,movementVector.z));
|
EntityUtils.getRotation(parent).rotationTo(new Vector3d(0,0,1), new Vector3d(movementVector.x,movementVector.y,movementVector.z));
|
||||||
//set initial stuff
|
//set initial stuff (this alerts the client as well)
|
||||||
setCurrentMoveId(currentMove.getAttackMoveId());
|
setCurrentMoveId(currentMove.getAttackMoveId());
|
||||||
setState(AttackTreeState.WINDUP);
|
setState(AttackTreeState.WINDUP);
|
||||||
frameCurrent = 0;
|
frameCurrent = 0;
|
||||||
@ -175,37 +174,9 @@ public class ServerAttackTree implements BehaviorTree {
|
|||||||
//parse attached network messages
|
//parse attached network messages
|
||||||
for(EntityMessage message : networkMessageQueue){
|
for(EntityMessage message : networkMessageQueue){
|
||||||
networkMessageQueue.remove(message);
|
networkMessageQueue.remove(message);
|
||||||
// System.out.println("MOVE to " + message.getX() + " " + message.getY() + " " + message.getZ());
|
|
||||||
long updateTime = message.gettime();
|
|
||||||
switch(message.getMessageSubtype()){
|
switch(message.getMessageSubtype()){
|
||||||
case ATTACKUPDATE:
|
case ATTACKUPDATE:
|
||||||
if(updateTime > lastUpdateTime){
|
|
||||||
lastUpdateTime = updateTime;
|
|
||||||
switch(message.gettreeState()){
|
|
||||||
case 0:
|
|
||||||
setState(AttackTreeState.WINDUP);
|
|
||||||
frameCurrent = 0;
|
|
||||||
// System.out.println("Set state STARTUP");
|
|
||||||
break;
|
|
||||||
case 1:
|
|
||||||
frameCurrent = currentMove.getWindupFrames()+1;
|
|
||||||
setState(AttackTreeState.ATTACK);
|
|
||||||
// System.out.println("Set state MOVE");
|
|
||||||
break;
|
|
||||||
case 2:
|
|
||||||
frameCurrent = currentMove.getWindupFrames()+currentMove.getAttackFrames()+1;
|
|
||||||
setState(AttackTreeState.COOLDOWN);
|
|
||||||
// System.out.println("Set state SLOWDOWN");
|
|
||||||
break;
|
|
||||||
case 3:
|
|
||||||
frameCurrent = 60;
|
|
||||||
setState(AttackTreeState.IDLE);
|
|
||||||
// System.out.println("Set state IDLE");
|
|
||||||
break;
|
|
||||||
}
|
|
||||||
}
|
|
||||||
EntityUtils.getPosition(parent).set(message.getpositionX(),message.getpositionY(),message.getpositionZ());
|
EntityUtils.getPosition(parent).set(message.getpositionX(),message.getpositionY(),message.getpositionZ());
|
||||||
CreatureUtils.setFacingVector(parent, new Vector3d(message.getrotationX(),message.getrotationY(),message.getrotationZ()));
|
|
||||||
break;
|
break;
|
||||||
case STARTATTACK: {
|
case STARTATTACK: {
|
||||||
start();
|
start();
|
||||||
@ -418,6 +389,11 @@ public class ServerAttackTree implements BehaviorTree {
|
|||||||
return rVal;
|
return rVal;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
/**
|
||||||
|
* Checks whether the entity can attack or not
|
||||||
|
* @param attackType The type of attack to perform
|
||||||
|
* @return true if it can attack, false otherwise
|
||||||
|
*/
|
||||||
boolean canAttack(String attackType){
|
boolean canAttack(String attackType){
|
||||||
boolean rVal = true;
|
boolean rVal = true;
|
||||||
if(attackType == null){
|
if(attackType == null){
|
||||||
@ -433,7 +409,7 @@ public class ServerAttackTree implements BehaviorTree {
|
|||||||
}
|
}
|
||||||
} else {
|
} else {
|
||||||
if(ServerEquipState.hasEquipState(parent)){
|
if(ServerEquipState.hasEquipState(parent)){
|
||||||
ServerEquipState equipState = ServerEquipState.getEquipState(parent);
|
// ServerEquipState equipState = ServerEquipState.getEquipState(parent);
|
||||||
// if(equipState.hasEquipPrimary()){
|
// if(equipState.hasEquipPrimary()){
|
||||||
// switch(attackType){
|
// switch(attackType){
|
||||||
// case EntityDataStrings.ATTACK_MOVE_TYPE_MELEE_SWING_ONE_HAND:
|
// case EntityDataStrings.ATTACK_MOVE_TYPE_MELEE_SWING_ONE_HAND:
|
||||||
|
|||||||
@ -148,16 +148,7 @@ public class LifeState implements BehaviorTree {
|
|||||||
deathFrameCurrent = frameskip;
|
deathFrameCurrent = frameskip;
|
||||||
}
|
}
|
||||||
break;
|
break;
|
||||||
case ATTACHENTITYTOENTITY:
|
default:
|
||||||
case ATTACKUPDATE:
|
|
||||||
case CREATE:
|
|
||||||
case DESTROY:
|
|
||||||
case SETBEHAVIORTREE:
|
|
||||||
case SETPOSITION:
|
|
||||||
case SETPROPERTY:
|
|
||||||
case MOVE:
|
|
||||||
case SETFACING:
|
|
||||||
case MOVEUPDATE:
|
|
||||||
//silently ignore
|
//silently ignore
|
||||||
break;
|
break;
|
||||||
}
|
}
|
||||||
|
|||||||
@ -21,6 +21,7 @@ import electrosphere.renderer.actor.Actor;
|
|||||||
import electrosphere.renderer.anim.Animation;
|
import electrosphere.renderer.anim.Animation;
|
||||||
import electrosphere.server.datacell.utils.DataCellSearchUtils;
|
import electrosphere.server.datacell.utils.DataCellSearchUtils;
|
||||||
|
|
||||||
|
@Deprecated
|
||||||
public class AirplaneMovementTree implements BehaviorTree {
|
public class AirplaneMovementTree implements BehaviorTree {
|
||||||
|
|
||||||
public static enum AirplaneMovementTreeState {
|
public static enum AirplaneMovementTreeState {
|
||||||
@ -91,11 +92,6 @@ public class AirplaneMovementTree implements BehaviorTree {
|
|||||||
networkMessageQueue.remove(message);
|
networkMessageQueue.remove(message);
|
||||||
long updateTime = message.gettime();
|
long updateTime = message.gettime();
|
||||||
switch(message.getMessageSubtype()){
|
switch(message.getMessageSubtype()){
|
||||||
case MOVE: {
|
|
||||||
if(Globals.RUN_CLIENT){
|
|
||||||
position.set(message.getpositionX(), message.getpositionY(), message.getpositionZ());
|
|
||||||
}
|
|
||||||
} break;
|
|
||||||
//received a message to update the tree
|
//received a message to update the tree
|
||||||
case MOVEUPDATE: {
|
case MOVEUPDATE: {
|
||||||
if(updateTime > lastUpdateTime){
|
if(updateTime > lastUpdateTime){
|
||||||
@ -120,15 +116,6 @@ public class AirplaneMovementTree implements BehaviorTree {
|
|||||||
//we want to always update the server facing vector with where the client says they're facing
|
//we want to always update the server facing vector with where the client says they're facing
|
||||||
CreatureUtils.setFacingVector(parent, new Vector3d(message.getrotationX(),message.getrotationY(),message.getrotationZ()));
|
CreatureUtils.setFacingVector(parent, new Vector3d(message.getrotationX(),message.getrotationY(),message.getrotationZ()));
|
||||||
}
|
}
|
||||||
} break;
|
|
||||||
case SETBEHAVIORTREE: {
|
|
||||||
|
|
||||||
} break;
|
|
||||||
case SETFACING: {
|
|
||||||
|
|
||||||
} break;
|
|
||||||
case SETPOSITION: {
|
|
||||||
|
|
||||||
} break;
|
} break;
|
||||||
case ATTACHENTITYTOENTITY:
|
case ATTACHENTITYTOENTITY:
|
||||||
case ATTACKUPDATE:
|
case ATTACKUPDATE:
|
||||||
@ -257,6 +244,7 @@ public class AirplaneMovementTree implements BehaviorTree {
|
|||||||
rotation.z,
|
rotation.z,
|
||||||
rotation.w,
|
rotation.w,
|
||||||
velocity,
|
velocity,
|
||||||
|
0,
|
||||||
stateNumber
|
stateNumber
|
||||||
)
|
)
|
||||||
);
|
);
|
||||||
|
|||||||
@ -68,8 +68,10 @@ public class ClientGroundMovementTree implements BehaviorTree {
|
|||||||
}
|
}
|
||||||
|
|
||||||
static final double STATE_DIFFERENCE_HARD_UPDATE_THRESHOLD = 1.0;
|
static final double STATE_DIFFERENCE_HARD_UPDATE_THRESHOLD = 1.0;
|
||||||
static final double STATE_DIFFERENCE_SOFT_UPDATE_THRESHOLD = 0.2;
|
static final double STATE_DIFFERENCE_SOFT_UPDATE_THRESHOLD = 0.1;
|
||||||
static final double SOFT_UPDATE_MULTIPLIER = 0.1;
|
static final double SOFT_UPDATE_MULTIPLIER = 0.3;
|
||||||
|
static final double STATE_DIFFERENCE_CREEP_MULTIPLIER = 0.001; //while the movement tree is idle, slowly creep the position of the entity towards the true server position by this amount
|
||||||
|
static final double STATE_DIFFERENCE_CREEP_CUTOFF = 0.01; //the cutoff for creep when we say it's "close enough"
|
||||||
|
|
||||||
String animationStartUp = Animation.ANIMATION_MOVEMENT_STARTUP;
|
String animationStartUp = Animation.ANIMATION_MOVEMENT_STARTUP;
|
||||||
String animationMain = Animation.ANIMATION_MOVEMENT_MOVE;
|
String animationMain = Animation.ANIMATION_MOVEMENT_MOVE;
|
||||||
@ -94,18 +96,32 @@ public class ClientGroundMovementTree implements BehaviorTree {
|
|||||||
|
|
||||||
CopyOnWriteArrayList<EntityMessage> networkMessageQueue = new CopyOnWriteArrayList<EntityMessage>();
|
CopyOnWriteArrayList<EntityMessage> networkMessageQueue = new CopyOnWriteArrayList<EntityMessage>();
|
||||||
|
|
||||||
|
//the last frame we got an update on true position from the server
|
||||||
long lastUpdateTime = 0;
|
long lastUpdateTime = 0;
|
||||||
|
//the last position reported by the server
|
||||||
|
Vector3d lastServerPosition = null;
|
||||||
|
|
||||||
|
/**
|
||||||
|
* Constructor
|
||||||
|
* @param e The parent entity
|
||||||
|
*/
|
||||||
private ClientGroundMovementTree(Entity e){
|
private ClientGroundMovementTree(Entity e){
|
||||||
state = MovementTreeState.IDLE;
|
state = MovementTreeState.IDLE;
|
||||||
parent = e;
|
parent = e;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
/**
|
||||||
|
* Gets the state of the tree
|
||||||
|
* @return The state
|
||||||
|
*/
|
||||||
public MovementTreeState getState(){
|
public MovementTreeState getState(){
|
||||||
return state;
|
return state;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
/**
|
||||||
|
* Requests to the server that the entity start moving
|
||||||
|
* @param facing The facing relative to the view direction that the entity should move in (ie strafe right vs walk straight forward)
|
||||||
|
*/
|
||||||
public void start(MovementRelativeFacing facing){
|
public void start(MovementRelativeFacing facing){
|
||||||
if(canStartMoving()){
|
if(canStartMoving()){
|
||||||
setFacing(facing);
|
setFacing(facing);
|
||||||
@ -126,17 +142,16 @@ public class ClientGroundMovementTree implements BehaviorTree {
|
|||||||
rotation.z,
|
rotation.z,
|
||||||
rotation.w,
|
rotation.w,
|
||||||
velocity,
|
velocity,
|
||||||
|
ClientGroundMovementTree.getMovementRelativeFacingEnumAsShort(facing),
|
||||||
0 //magic number corresponding to state startup
|
0 //magic number corresponding to state startup
|
||||||
)
|
)
|
||||||
);
|
);
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
public void interrupt(){
|
/**
|
||||||
state = MovementTreeState.IDLE;
|
* Requests to the server that the movetree stop
|
||||||
CreatureUtils.setVelocity(parent, 0);
|
*/
|
||||||
}
|
|
||||||
|
|
||||||
public void slowdown(){
|
public void slowdown(){
|
||||||
state = MovementTreeState.SLOWDOWN;
|
state = MovementTreeState.SLOWDOWN;
|
||||||
//if we aren't the server, alert the server we intend to slow down
|
//if we aren't the server, alert the server we intend to slow down
|
||||||
@ -155,11 +170,13 @@ public class ClientGroundMovementTree implements BehaviorTree {
|
|||||||
rotation.z,
|
rotation.z,
|
||||||
rotation.w,
|
rotation.w,
|
||||||
velocity,
|
velocity,
|
||||||
|
ClientGroundMovementTree.getMovementRelativeFacingEnumAsShort(facing),
|
||||||
2 //magic number corresponding to state slowdown
|
2 //magic number corresponding to state slowdown
|
||||||
)
|
)
|
||||||
);
|
);
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@Override
|
||||||
public void simulate(float deltaTime){
|
public void simulate(float deltaTime){
|
||||||
float velocity = CreatureUtils.getVelocity(parent);
|
float velocity = CreatureUtils.getVelocity(parent);
|
||||||
float acceleration = CreatureUtils.getAcceleration(parent);
|
float acceleration = CreatureUtils.getAcceleration(parent);
|
||||||
@ -214,11 +231,6 @@ public class ClientGroundMovementTree implements BehaviorTree {
|
|||||||
long updateTime = message.gettime();
|
long updateTime = message.gettime();
|
||||||
// System.out.println("MOVE to " + message.getX() + " " + message.getY() + " " + message.getZ());
|
// System.out.println("MOVE to " + message.getX() + " " + message.getY() + " " + message.getZ());
|
||||||
switch(message.getMessageSubtype()){
|
switch(message.getMessageSubtype()){
|
||||||
case MOVE:
|
|
||||||
position.set(message.getpositionX(), message.getpositionY(), message.getpositionZ());
|
|
||||||
break;
|
|
||||||
case SETFACING:
|
|
||||||
break;
|
|
||||||
case MOVEUPDATE:
|
case MOVEUPDATE:
|
||||||
if(updateTime > lastUpdateTime){
|
if(updateTime > lastUpdateTime){
|
||||||
lastUpdateTime = updateTime;
|
lastUpdateTime = updateTime;
|
||||||
@ -243,14 +255,14 @@ public class ClientGroundMovementTree implements BehaviorTree {
|
|||||||
// System.out.println("Set state IDLE");
|
// System.out.println("Set state IDLE");
|
||||||
break;
|
break;
|
||||||
}
|
}
|
||||||
// System.out.println(EntityUtils.getEntityPosition(parent));
|
|
||||||
// System.out.println(message.getpositionX() + " " + message.getpositionY() + " " + message.getpositionZ());
|
|
||||||
//this should only fire on the client, we don't want the server snap updating due to client position reporting
|
//this should only fire on the client, we don't want the server snap updating due to client position reporting
|
||||||
// if(position.distance(message.getpositionX(),message.getpositionY(),message.getpositionZ()) > STATE_DIFFERENCE_HARD_UPDATE_THRESHOLD){
|
lastServerPosition = new Vector3d(message.getpositionX(),message.getpositionY(),message.getpositionZ());
|
||||||
// EntityUtils.getPosition(parent).set(message.getpositionX(),message.getpositionY(),message.getpositionZ());
|
if(position.distance(lastServerPosition) > STATE_DIFFERENCE_HARD_UPDATE_THRESHOLD){
|
||||||
// } else if(position.distance(message.getpositionX(),message.getpositionY(),message.getpositionZ()) > STATE_DIFFERENCE_SOFT_UPDATE_THRESHOLD){
|
System.out.println(position + " - " + lastServerPosition);
|
||||||
// EntityUtils.getPosition(parent).add(new Vector3d(message.getpositionX(),message.getpositionY(),message.getpositionZ()).mul(SOFT_UPDATE_MULTIPLIER));
|
EntityUtils.getPosition(parent).set(lastServerPosition);
|
||||||
// }
|
} else if(position.distance(lastServerPosition) > STATE_DIFFERENCE_SOFT_UPDATE_THRESHOLD){
|
||||||
|
EntityUtils.getPosition(parent).lerp(lastServerPosition,SOFT_UPDATE_MULTIPLIER);
|
||||||
|
}
|
||||||
//we want to always update the server facing vector with where the client says they're facing
|
//we want to always update the server facing vector with where the client says they're facing
|
||||||
EntityUtils.getRotation(parent).set(message.getrotationX(),message.getrotationY(),message.getrotationZ(),message.getrotationW());
|
EntityUtils.getRotation(parent).set(message.getrotationX(),message.getrotationY(),message.getrotationZ(),message.getrotationW());
|
||||||
CollisionObjUtils.clientPositionCharacter(parent, position);
|
CollisionObjUtils.clientPositionCharacter(parent, position);
|
||||||
@ -267,7 +279,7 @@ public class ClientGroundMovementTree implements BehaviorTree {
|
|||||||
|
|
||||||
//state machine
|
//state machine
|
||||||
switch(state){
|
switch(state){
|
||||||
case STARTUP:
|
case STARTUP: {
|
||||||
if(entityActor != null){
|
if(entityActor != null){
|
||||||
String animationToPlay = determineCorrectAnimation();
|
String animationToPlay = determineCorrectAnimation();
|
||||||
if(
|
if(
|
||||||
@ -298,9 +310,8 @@ public class ClientGroundMovementTree implements BehaviorTree {
|
|||||||
rotation.set(movementQuaternion);
|
rotation.set(movementQuaternion);
|
||||||
|
|
||||||
GravityUtils.clientAttemptActivateGravity(parent);
|
GravityUtils.clientAttemptActivateGravity(parent);
|
||||||
|
} break;
|
||||||
break;
|
case MOVE: {
|
||||||
case MOVE:
|
|
||||||
//check if can restart animation
|
//check if can restart animation
|
||||||
//if yes, restart animation
|
//if yes, restart animation
|
||||||
if(entityActor != null){
|
if(entityActor != null){
|
||||||
@ -328,9 +339,8 @@ public class ClientGroundMovementTree implements BehaviorTree {
|
|||||||
rotation.set(movementQuaternion);
|
rotation.set(movementQuaternion);
|
||||||
|
|
||||||
GravityUtils.clientAttemptActivateGravity(parent);
|
GravityUtils.clientAttemptActivateGravity(parent);
|
||||||
|
} break;
|
||||||
break;
|
case SLOWDOWN: {
|
||||||
case SLOWDOWN:
|
|
||||||
//run slowdown code
|
//run slowdown code
|
||||||
if(entityActor != null){
|
if(entityActor != null){
|
||||||
String animationToPlay = determineCorrectAnimation();
|
String animationToPlay = determineCorrectAnimation();
|
||||||
@ -367,10 +377,13 @@ public class ClientGroundMovementTree implements BehaviorTree {
|
|||||||
rotation.set(movementQuaternion);
|
rotation.set(movementQuaternion);
|
||||||
|
|
||||||
GravityUtils.clientAttemptActivateGravity(parent);
|
GravityUtils.clientAttemptActivateGravity(parent);
|
||||||
|
} break;
|
||||||
break;
|
case IDLE: {
|
||||||
case IDLE:
|
Vector3d playerPos = EntityUtils.getPosition(parent);
|
||||||
break;
|
if(lastServerPosition != null && lastServerPosition.distance(playerPos) > STATE_DIFFERENCE_CREEP_CUTOFF){
|
||||||
|
playerPos.lerp(lastServerPosition,STATE_DIFFERENCE_CREEP_MULTIPLIER);
|
||||||
|
}
|
||||||
|
} break;
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
@ -695,4 +708,74 @@ public class ClientGroundMovementTree implements BehaviorTree {
|
|||||||
return (ClientGroundMovementTree)entity.getData(EntityDataStrings.TREE_CLIENTGROUNDMOVEMENTTREE);
|
return (ClientGroundMovementTree)entity.getData(EntityDataStrings.TREE_CLIENTGROUNDMOVEMENTTREE);
|
||||||
}
|
}
|
||||||
|
|
||||||
|
/**
|
||||||
|
* <p>
|
||||||
|
* Gets the ClientGroundMovementTree of the entity
|
||||||
|
* </p>
|
||||||
|
* @param entity the entity
|
||||||
|
* @return The ClientGroundMovementTree
|
||||||
|
*/
|
||||||
|
public static ClientGroundMovementTree getClientGroundMovementTree(Entity entity){
|
||||||
|
return (ClientGroundMovementTree)entity.getData(EntityDataStrings.TREE_CLIENTGROUNDMOVEMENTTREE);
|
||||||
|
}
|
||||||
|
/**
|
||||||
|
* <p> Automatically generated </p>
|
||||||
|
* <p>
|
||||||
|
* Converts this enum type to an equivalent short value
|
||||||
|
* </p>
|
||||||
|
* @param enumVal The enum value
|
||||||
|
* @return The short value
|
||||||
|
*/
|
||||||
|
public static short getMovementRelativeFacingEnumAsShort(MovementRelativeFacing enumVal){
|
||||||
|
switch(enumVal){
|
||||||
|
case FORWARD:
|
||||||
|
return 0;
|
||||||
|
case LEFT:
|
||||||
|
return 1;
|
||||||
|
case RIGHT:
|
||||||
|
return 2;
|
||||||
|
case BACKWARD:
|
||||||
|
return 3;
|
||||||
|
case FORWARD_LEFT:
|
||||||
|
return 4;
|
||||||
|
case FORWARD_RIGHT:
|
||||||
|
return 5;
|
||||||
|
case BACKWARD_LEFT:
|
||||||
|
return 6;
|
||||||
|
case BACKWARD_RIGHT:
|
||||||
|
return 7;
|
||||||
|
default:
|
||||||
|
return 0;
|
||||||
|
}
|
||||||
|
}
|
||||||
|
/**
|
||||||
|
* <p> Automatically generated </p>
|
||||||
|
* <p>
|
||||||
|
* Converts a short to the equivalent enum value
|
||||||
|
* </p>
|
||||||
|
* @param shortVal The short value
|
||||||
|
* @return The enum value
|
||||||
|
*/
|
||||||
|
public static MovementRelativeFacing getMovementRelativeFacingShortAsEnum(short shortVal){
|
||||||
|
switch(shortVal){
|
||||||
|
case 0:
|
||||||
|
return MovementRelativeFacing.FORWARD;
|
||||||
|
case 1:
|
||||||
|
return MovementRelativeFacing.LEFT;
|
||||||
|
case 2:
|
||||||
|
return MovementRelativeFacing.RIGHT;
|
||||||
|
case 3:
|
||||||
|
return MovementRelativeFacing.BACKWARD;
|
||||||
|
case 4:
|
||||||
|
return MovementRelativeFacing.FORWARD_LEFT;
|
||||||
|
case 5:
|
||||||
|
return MovementRelativeFacing.FORWARD_RIGHT;
|
||||||
|
case 6:
|
||||||
|
return MovementRelativeFacing.BACKWARD_LEFT;
|
||||||
|
case 7:
|
||||||
|
return MovementRelativeFacing.BACKWARD_RIGHT;
|
||||||
|
default:
|
||||||
|
return MovementRelativeFacing.FORWARD;
|
||||||
|
}
|
||||||
|
}
|
||||||
}
|
}
|
||||||
|
|||||||
@ -1,6 +1,8 @@
|
|||||||
package electrosphere.entity.state.movement.groundmove;
|
package electrosphere.entity.state.movement.groundmove;
|
||||||
|
|
||||||
|
|
||||||
|
import electrosphere.net.parser.net.message.SynchronizationMessage;
|
||||||
|
|
||||||
import electrosphere.net.synchronization.BehaviorTreeIdEnums;
|
import electrosphere.net.synchronization.BehaviorTreeIdEnums;
|
||||||
|
|
||||||
import electrosphere.entity.state.gravity.GravityUtils;
|
import electrosphere.entity.state.gravity.GravityUtils;
|
||||||
@ -41,10 +43,6 @@ Behavior tree for movement in an entity
|
|||||||
public class ServerGroundMovementTree implements BehaviorTree {
|
public class ServerGroundMovementTree implements BehaviorTree {
|
||||||
|
|
||||||
|
|
||||||
static final double STATE_DIFFERENCE_HARD_UPDATE_THRESHOLD = 1.0;
|
|
||||||
static final double STATE_DIFFERENCE_SOFT_UPDATE_THRESHOLD = 0.2;
|
|
||||||
static final double SOFT_UPDATE_MULTIPLIER = 0.1;
|
|
||||||
|
|
||||||
String animationStartUp = Animation.ANIMATION_MOVEMENT_STARTUP;
|
String animationStartUp = Animation.ANIMATION_MOVEMENT_STARTUP;
|
||||||
String animationMain = Animation.ANIMATION_MOVEMENT_MOVE;
|
String animationMain = Animation.ANIMATION_MOVEMENT_MOVE;
|
||||||
String animationSlowDown = Animation.ANIMATION_MOVEMENT_MOVE;
|
String animationSlowDown = Animation.ANIMATION_MOVEMENT_MOVE;
|
||||||
@ -69,7 +67,7 @@ public class ServerGroundMovementTree implements BehaviorTree {
|
|||||||
long lastUpdateTime = 0;
|
long lastUpdateTime = 0;
|
||||||
|
|
||||||
|
|
||||||
public ServerGroundMovementTree(Entity e){
|
private ServerGroundMovementTree(Entity e){
|
||||||
state = MovementTreeState.IDLE;
|
state = MovementTreeState.IDLE;
|
||||||
facing = MovementRelativeFacing.FORWARD;
|
facing = MovementRelativeFacing.FORWARD;
|
||||||
parent = e;
|
parent = e;
|
||||||
@ -103,17 +101,24 @@ public class ServerGroundMovementTree implements BehaviorTree {
|
|||||||
rotation.z,
|
rotation.z,
|
||||||
rotation.w,
|
rotation.w,
|
||||||
velocity,
|
velocity,
|
||||||
|
ClientGroundMovementTree.getMovementRelativeFacingEnumAsShort(facing),
|
||||||
0 //magic number corresponding to state startup
|
0 //magic number corresponding to state startup
|
||||||
)
|
)
|
||||||
);
|
);
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
/**
|
||||||
|
* Interrupts the tree
|
||||||
|
*/
|
||||||
public void interrupt(){
|
public void interrupt(){
|
||||||
state = MovementTreeState.IDLE;
|
state = MovementTreeState.IDLE;
|
||||||
CreatureUtils.setVelocity(parent, 0);
|
CreatureUtils.setVelocity(parent, 0);
|
||||||
}
|
}
|
||||||
|
|
||||||
|
/**
|
||||||
|
* Triggers the move tree to slow down
|
||||||
|
*/
|
||||||
public void slowdown(){
|
public void slowdown(){
|
||||||
state = MovementTreeState.SLOWDOWN;
|
state = MovementTreeState.SLOWDOWN;
|
||||||
//if we aren't the server, alert the server we intend to slow down
|
//if we aren't the server, alert the server we intend to slow down
|
||||||
@ -132,11 +137,13 @@ public class ServerGroundMovementTree implements BehaviorTree {
|
|||||||
rotation.z,
|
rotation.z,
|
||||||
rotation.w,
|
rotation.w,
|
||||||
velocity,
|
velocity,
|
||||||
|
ClientGroundMovementTree.getMovementRelativeFacingEnumAsShort(facing),
|
||||||
2 //magic number corresponding to state slowdown
|
2 //magic number corresponding to state slowdown
|
||||||
)
|
)
|
||||||
);
|
);
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@Override
|
||||||
public void simulate(float deltaTime){
|
public void simulate(float deltaTime){
|
||||||
float velocity = 0;
|
float velocity = 0;
|
||||||
float acceleration = 0;
|
float acceleration = 0;
|
||||||
@ -196,17 +203,13 @@ public class ServerGroundMovementTree implements BehaviorTree {
|
|||||||
long updateTime = message.gettime();
|
long updateTime = message.gettime();
|
||||||
// System.out.println("MOVE to " + message.getX() + " " + message.getY() + " " + message.getZ());
|
// System.out.println("MOVE to " + message.getX() + " " + message.getY() + " " + message.getZ());
|
||||||
switch(message.getMessageSubtype()){
|
switch(message.getMessageSubtype()){
|
||||||
case MOVE: {
|
|
||||||
} break;
|
|
||||||
case SETFACING:
|
|
||||||
break;
|
|
||||||
case MOVEUPDATE: {
|
case MOVEUPDATE: {
|
||||||
if(updateTime >= lastUpdateTime){
|
if(updateTime >= lastUpdateTime){
|
||||||
lastUpdateTime = updateTime;
|
lastUpdateTime = updateTime;
|
||||||
switch(message.gettreeState()){
|
switch(message.gettreeState()){
|
||||||
//0 is startup
|
//0 is startup
|
||||||
case 0: {
|
case 0: {
|
||||||
start(MovementRelativeFacing.FORWARD);
|
start(ClientGroundMovementTree.getMovementRelativeFacingShortAsEnum((short)message.getpropertyValueInt()));
|
||||||
} break;
|
} break;
|
||||||
case 2: {
|
case 2: {
|
||||||
slowdown();
|
slowdown();
|
||||||
@ -229,7 +232,7 @@ public class ServerGroundMovementTree implements BehaviorTree {
|
|||||||
|
|
||||||
//state machine
|
//state machine
|
||||||
switch(state){
|
switch(state){
|
||||||
case STARTUP:
|
case STARTUP: {
|
||||||
if(entityPoseActor != null){
|
if(entityPoseActor != null){
|
||||||
String animationToPlay = determineCorrectAnimation();
|
String animationToPlay = determineCorrectAnimation();
|
||||||
if(
|
if(
|
||||||
@ -267,22 +270,23 @@ public class ServerGroundMovementTree implements BehaviorTree {
|
|||||||
GravityUtils.serverAttemptActivateGravity(parent);
|
GravityUtils.serverAttemptActivateGravity(parent);
|
||||||
|
|
||||||
DataCellSearchUtils.getEntityDataCell(parent).broadcastNetworkMessage(
|
DataCellSearchUtils.getEntityDataCell(parent).broadcastNetworkMessage(
|
||||||
EntityMessage.constructmoveUpdateMessage(
|
EntityMessage.constructmoveUpdateMessage(
|
||||||
parent.getId(),
|
parent.getId(),
|
||||||
Globals.timekeeper.getNumberOfSimFramesElapsed(),
|
Globals.timekeeper.getNumberOfSimFramesElapsed(),
|
||||||
position.x,
|
position.x,
|
||||||
position.y,
|
position.y,
|
||||||
position.z,
|
position.z,
|
||||||
rotation.x,
|
rotation.x,
|
||||||
rotation.y,
|
rotation.y,
|
||||||
rotation.z,
|
rotation.z,
|
||||||
rotation.w,
|
rotation.w,
|
||||||
velocity,
|
velocity,
|
||||||
0
|
ClientGroundMovementTree.getMovementRelativeFacingEnumAsShort(facing),
|
||||||
)
|
0
|
||||||
|
)
|
||||||
);
|
);
|
||||||
break;
|
} break;
|
||||||
case MOVE:
|
case MOVE: {
|
||||||
//check if can restart animation
|
//check if can restart animation
|
||||||
//if yes, restart animation
|
//if yes, restart animation
|
||||||
if(entityPoseActor != null){
|
if(entityPoseActor != null){
|
||||||
@ -317,22 +321,23 @@ public class ServerGroundMovementTree implements BehaviorTree {
|
|||||||
GravityUtils.serverAttemptActivateGravity(parent);
|
GravityUtils.serverAttemptActivateGravity(parent);
|
||||||
|
|
||||||
DataCellSearchUtils.getEntityDataCell(parent).broadcastNetworkMessage(
|
DataCellSearchUtils.getEntityDataCell(parent).broadcastNetworkMessage(
|
||||||
EntityMessage.constructmoveUpdateMessage(
|
EntityMessage.constructmoveUpdateMessage(
|
||||||
parent.getId(),
|
parent.getId(),
|
||||||
Globals.timekeeper.getNumberOfSimFramesElapsed(),
|
Globals.timekeeper.getNumberOfSimFramesElapsed(),
|
||||||
position.x,
|
position.x,
|
||||||
position.y,
|
position.y,
|
||||||
position.z,
|
position.z,
|
||||||
rotation.x,
|
rotation.x,
|
||||||
rotation.y,
|
rotation.y,
|
||||||
rotation.z,
|
rotation.z,
|
||||||
rotation.w,
|
rotation.w,
|
||||||
velocity,
|
velocity,
|
||||||
1
|
ClientGroundMovementTree.getMovementRelativeFacingEnumAsShort(facing),
|
||||||
)
|
1
|
||||||
|
)
|
||||||
);
|
);
|
||||||
break;
|
} break;
|
||||||
case SLOWDOWN:
|
case SLOWDOWN: {
|
||||||
//run slowdown code
|
//run slowdown code
|
||||||
if(entityPoseActor != null){
|
if(entityPoseActor != null){
|
||||||
String animationToPlay = determineCorrectAnimation();
|
String animationToPlay = determineCorrectAnimation();
|
||||||
@ -376,23 +381,24 @@ public class ServerGroundMovementTree implements BehaviorTree {
|
|||||||
GravityUtils.serverAttemptActivateGravity(parent);
|
GravityUtils.serverAttemptActivateGravity(parent);
|
||||||
|
|
||||||
DataCellSearchUtils.getEntityDataCell(parent).broadcastNetworkMessage(
|
DataCellSearchUtils.getEntityDataCell(parent).broadcastNetworkMessage(
|
||||||
EntityMessage.constructmoveUpdateMessage(
|
EntityMessage.constructmoveUpdateMessage(
|
||||||
parent.getId(),
|
parent.getId(),
|
||||||
Globals.timekeeper.getNumberOfSimFramesElapsed(),
|
Globals.timekeeper.getNumberOfSimFramesElapsed(),
|
||||||
position.x,
|
position.x,
|
||||||
position.y,
|
position.y,
|
||||||
position.z,
|
position.z,
|
||||||
rotation.x,
|
rotation.x,
|
||||||
rotation.y,
|
rotation.y,
|
||||||
rotation.z,
|
rotation.z,
|
||||||
rotation.w,
|
rotation.w,
|
||||||
velocity,
|
velocity,
|
||||||
2
|
ClientGroundMovementTree.getMovementRelativeFacingEnumAsShort(facing),
|
||||||
)
|
2
|
||||||
|
)
|
||||||
);
|
);
|
||||||
break;
|
} break;
|
||||||
case IDLE:
|
case IDLE: {
|
||||||
break;
|
} break;
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
@ -668,6 +674,8 @@ public class ServerGroundMovementTree implements BehaviorTree {
|
|||||||
*/
|
*/
|
||||||
public void setFacing(MovementRelativeFacing facing){
|
public void setFacing(MovementRelativeFacing facing){
|
||||||
this.facing = facing;
|
this.facing = facing;
|
||||||
|
int value = ClientGroundMovementTree.getMovementRelativeFacingEnumAsShort(facing);
|
||||||
|
DataCellSearchUtils.getEntityDataCell(parent).broadcastNetworkMessage(SynchronizationMessage.constructUpdateClientStateMessage(parent.getId(), 9, 11, value));
|
||||||
}
|
}
|
||||||
|
|
||||||
/**
|
/**
|
||||||
|
|||||||
@ -40,6 +40,7 @@ import electrosphere.renderer.actor.ActorUtils;
|
|||||||
import electrosphere.server.datacell.Realm;
|
import electrosphere.server.datacell.Realm;
|
||||||
import electrosphere.server.datacell.utils.ServerBehaviorTreeUtils;
|
import electrosphere.server.datacell.utils.ServerBehaviorTreeUtils;
|
||||||
import electrosphere.server.datacell.utils.ServerEntityTagUtils;
|
import electrosphere.server.datacell.utils.ServerEntityTagUtils;
|
||||||
|
import electrosphere.server.poseactor.PoseActor;
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* Utilities for working with items
|
* Utilities for working with items
|
||||||
@ -222,6 +223,10 @@ public class ItemUtils {
|
|||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
/**
|
||||||
|
* Updates an item to play its idle animation
|
||||||
|
* @param item THe item entity
|
||||||
|
*/
|
||||||
public static void updateItemActorAnimation(Entity item){
|
public static void updateItemActorAnimation(Entity item){
|
||||||
Actor actor = EntityUtils.getActor(item);
|
Actor actor = EntityUtils.getActor(item);
|
||||||
if(actor != null && item.getData(EntityDataStrings.ANIM_IDLE) != null){
|
if(actor != null && item.getData(EntityDataStrings.ANIM_IDLE) != null){
|
||||||
@ -232,6 +237,20 @@ public class ItemUtils {
|
|||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
/**
|
||||||
|
* Updates the item's pose actor to play its idle animation on the server
|
||||||
|
* @param item The item entity
|
||||||
|
*/
|
||||||
|
public static void updateItemPoseActorAnimation(Entity item){
|
||||||
|
PoseActor actor = EntityUtils.getPoseActor(item);
|
||||||
|
if(actor != null && item.getData(EntityDataStrings.ANIM_IDLE) != null){
|
||||||
|
String idleAnim = (String)item.getData(EntityDataStrings.ANIM_IDLE);
|
||||||
|
if(!actor.isPlayingAnimation(idleAnim)){
|
||||||
|
actor.playAnimation(idleAnim,1);
|
||||||
|
}
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
public static void sendEntityToPlayer(Player player, Entity item){
|
public static void sendEntityToPlayer(Player player, Entity item){
|
||||||
int id = item.getId();
|
int id = item.getId();
|
||||||
String type = ItemUtils.getType(item);
|
String type = ItemUtils.getType(item);
|
||||||
|
|||||||
@ -11,7 +11,6 @@ import electrosphere.entity.EntityDataStrings;
|
|||||||
import electrosphere.entity.EntityTags;
|
import electrosphere.entity.EntityTags;
|
||||||
import electrosphere.entity.EntityUtils;
|
import electrosphere.entity.EntityUtils;
|
||||||
import electrosphere.entity.state.attack.ClientAttackTree;
|
import electrosphere.entity.state.attack.ClientAttackTree;
|
||||||
import electrosphere.entity.state.attack.ServerAttackTree;
|
|
||||||
import electrosphere.entity.state.client.firstPerson.FirstPersonTree;
|
import electrosphere.entity.state.client.firstPerson.FirstPersonTree;
|
||||||
import electrosphere.entity.types.attach.AttachUtils;
|
import electrosphere.entity.types.attach.AttachUtils;
|
||||||
import electrosphere.entity.types.creature.CreatureTemplate;
|
import electrosphere.entity.types.creature.CreatureTemplate;
|
||||||
@ -96,13 +95,6 @@ public class EntityProtocol {
|
|||||||
// UPDATING PROPERTIES
|
// UPDATING PROPERTIES
|
||||||
//
|
//
|
||||||
//
|
//
|
||||||
case MOVE: {
|
|
||||||
Entity target = Globals.clientSceneWrapper.getEntityFromServerId(message.getentityID());
|
|
||||||
LoggerInterface.loggerNetworking.DEBUG("ID: " + message.getentityID());
|
|
||||||
if(target != null){
|
|
||||||
EntityUtils.getPosition(target).set(message.getpositionX(),message.getpositionY(),message.getpositionZ());
|
|
||||||
}
|
|
||||||
} break;
|
|
||||||
case SETPROPERTY: {
|
case SETPROPERTY: {
|
||||||
if(Globals.clientSceneWrapper.serverToClientMapContainsId(message.getentityID())){
|
if(Globals.clientSceneWrapper.serverToClientMapContainsId(message.getentityID())){
|
||||||
if(message.getpropertyType() == 0){
|
if(message.getpropertyType() == 0){
|
||||||
@ -145,17 +137,9 @@ public class EntityProtocol {
|
|||||||
//
|
//
|
||||||
case UPDATEENTITYVIEWDIR:
|
case UPDATEENTITYVIEWDIR:
|
||||||
case KILL:
|
case KILL:
|
||||||
case SETPOSITION:
|
|
||||||
case SETFACING:
|
|
||||||
//to be implemented
|
//to be implemented
|
||||||
throw new UnsupportedOperationException();
|
throw new UnsupportedOperationException();
|
||||||
|
default:
|
||||||
case SETBEHAVIORTREE:
|
|
||||||
case SETBTREEPROPERTYDOUBLE:
|
|
||||||
case SETBTREEPROPERTYENUM:
|
|
||||||
case SETBTREEPROPERTYFLOAT:
|
|
||||||
case SETBTREEPROPERTYINT:
|
|
||||||
case SETBTREEPROPERTYSTRING:
|
|
||||||
//unused
|
//unused
|
||||||
break;
|
break;
|
||||||
}
|
}
|
||||||
|
|||||||
@ -11,18 +11,11 @@ public class LoreProtocol {
|
|||||||
|
|
||||||
protected static void handleLoreMessage(LoreMessage message){
|
protected static void handleLoreMessage(LoreMessage message){
|
||||||
switch(message.getMessageSubtype()){
|
switch(message.getMessageSubtype()){
|
||||||
case RESPONSEDATA:
|
|
||||||
break;
|
|
||||||
case RESPONSERACES:
|
case RESPONSERACES:
|
||||||
//we get back the race list as a json array, deserialize, and push into type loader
|
//we get back the race list as a json array, deserialize, and push into type loader
|
||||||
List<String> playableRaces = new Gson().fromJson(message.getdata(), List.class);
|
List<String> playableRaces = new Gson().fromJson(message.getdata(), List.class);
|
||||||
Globals.gameConfigCurrent.getCreatureTypeLoader().loadPlayableRaces(playableRaces);
|
Globals.gameConfigCurrent.getCreatureTypeLoader().loadPlayableRaces(playableRaces);
|
||||||
break;
|
break;
|
||||||
case RESPONSERACEDATA:
|
|
||||||
break;
|
|
||||||
|
|
||||||
case REQUESTDATA:
|
|
||||||
case REQUESTRACEDATA:
|
|
||||||
case REQUESTRACES:
|
case REQUESTRACES:
|
||||||
//silently ignore
|
//silently ignore
|
||||||
break;
|
break;
|
||||||
|
|||||||
@ -11,21 +11,12 @@ public class EntityMessage extends NetworkMessage {
|
|||||||
CREATE,
|
CREATE,
|
||||||
SPAWNCREATURE,
|
SPAWNCREATURE,
|
||||||
SPAWNITEM,
|
SPAWNITEM,
|
||||||
SETPOSITION,
|
|
||||||
SETFACING,
|
|
||||||
MOVEUPDATE,
|
MOVEUPDATE,
|
||||||
ATTACKUPDATE,
|
ATTACKUPDATE,
|
||||||
STARTATTACK,
|
STARTATTACK,
|
||||||
MOVE,
|
|
||||||
KILL,
|
KILL,
|
||||||
DESTROY,
|
DESTROY,
|
||||||
SETBEHAVIORTREE,
|
|
||||||
SETPROPERTY,
|
SETPROPERTY,
|
||||||
SETBTREEPROPERTYINT,
|
|
||||||
SETBTREEPROPERTYFLOAT,
|
|
||||||
SETBTREEPROPERTYDOUBLE,
|
|
||||||
SETBTREEPROPERTYSTRING,
|
|
||||||
SETBTREEPROPERTYENUM,
|
|
||||||
ATTACHENTITYTOENTITY,
|
ATTACHENTITYTOENTITY,
|
||||||
SPAWNFOLIAGESEED,
|
SPAWNFOLIAGESEED,
|
||||||
UPDATEENTITYVIEWDIR,
|
UPDATEENTITYVIEWDIR,
|
||||||
@ -297,18 +288,6 @@ public class EntityMessage extends NetworkMessage {
|
|||||||
return EntityMessage.canParseSpawnCreatureMessage(byteBuffer);
|
return EntityMessage.canParseSpawnCreatureMessage(byteBuffer);
|
||||||
case TypeBytes.ENTITY_MESSAGE_TYPE_SPAWNITEM:
|
case TypeBytes.ENTITY_MESSAGE_TYPE_SPAWNITEM:
|
||||||
return EntityMessage.canParseSpawnItemMessage(byteBuffer);
|
return EntityMessage.canParseSpawnItemMessage(byteBuffer);
|
||||||
case TypeBytes.ENTITY_MESSAGE_TYPE_SETPOSITION:
|
|
||||||
if(byteBuffer.getRemaining() >= TypeBytes.ENTITY_MESSAGE_TYPE_SETPOSITION_SIZE){
|
|
||||||
return true;
|
|
||||||
} else {
|
|
||||||
return false;
|
|
||||||
}
|
|
||||||
case TypeBytes.ENTITY_MESSAGE_TYPE_SETFACING:
|
|
||||||
if(byteBuffer.getRemaining() >= TypeBytes.ENTITY_MESSAGE_TYPE_SETFACING_SIZE){
|
|
||||||
return true;
|
|
||||||
} else {
|
|
||||||
return false;
|
|
||||||
}
|
|
||||||
case TypeBytes.ENTITY_MESSAGE_TYPE_MOVEUPDATE:
|
case TypeBytes.ENTITY_MESSAGE_TYPE_MOVEUPDATE:
|
||||||
if(byteBuffer.getRemaining() >= TypeBytes.ENTITY_MESSAGE_TYPE_MOVEUPDATE_SIZE){
|
if(byteBuffer.getRemaining() >= TypeBytes.ENTITY_MESSAGE_TYPE_MOVEUPDATE_SIZE){
|
||||||
return true;
|
return true;
|
||||||
@ -327,12 +306,6 @@ public class EntityMessage extends NetworkMessage {
|
|||||||
} else {
|
} else {
|
||||||
return false;
|
return false;
|
||||||
}
|
}
|
||||||
case TypeBytes.ENTITY_MESSAGE_TYPE_MOVE:
|
|
||||||
if(byteBuffer.getRemaining() >= TypeBytes.ENTITY_MESSAGE_TYPE_MOVE_SIZE){
|
|
||||||
return true;
|
|
||||||
} else {
|
|
||||||
return false;
|
|
||||||
}
|
|
||||||
case TypeBytes.ENTITY_MESSAGE_TYPE_KILL:
|
case TypeBytes.ENTITY_MESSAGE_TYPE_KILL:
|
||||||
if(byteBuffer.getRemaining() >= TypeBytes.ENTITY_MESSAGE_TYPE_KILL_SIZE){
|
if(byteBuffer.getRemaining() >= TypeBytes.ENTITY_MESSAGE_TYPE_KILL_SIZE){
|
||||||
return true;
|
return true;
|
||||||
@ -345,44 +318,12 @@ public class EntityMessage extends NetworkMessage {
|
|||||||
} else {
|
} else {
|
||||||
return false;
|
return false;
|
||||||
}
|
}
|
||||||
case TypeBytes.ENTITY_MESSAGE_TYPE_SETBEHAVIORTREE:
|
|
||||||
if(byteBuffer.getRemaining() >= TypeBytes.ENTITY_MESSAGE_TYPE_SETBEHAVIORTREE_SIZE){
|
|
||||||
return true;
|
|
||||||
} else {
|
|
||||||
return false;
|
|
||||||
}
|
|
||||||
case TypeBytes.ENTITY_MESSAGE_TYPE_SETPROPERTY:
|
case TypeBytes.ENTITY_MESSAGE_TYPE_SETPROPERTY:
|
||||||
if(byteBuffer.getRemaining() >= TypeBytes.ENTITY_MESSAGE_TYPE_SETPROPERTY_SIZE){
|
if(byteBuffer.getRemaining() >= TypeBytes.ENTITY_MESSAGE_TYPE_SETPROPERTY_SIZE){
|
||||||
return true;
|
return true;
|
||||||
} else {
|
} else {
|
||||||
return false;
|
return false;
|
||||||
}
|
}
|
||||||
case TypeBytes.ENTITY_MESSAGE_TYPE_SETBTREEPROPERTYINT:
|
|
||||||
if(byteBuffer.getRemaining() >= TypeBytes.ENTITY_MESSAGE_TYPE_SETBTREEPROPERTYINT_SIZE){
|
|
||||||
return true;
|
|
||||||
} else {
|
|
||||||
return false;
|
|
||||||
}
|
|
||||||
case TypeBytes.ENTITY_MESSAGE_TYPE_SETBTREEPROPERTYFLOAT:
|
|
||||||
if(byteBuffer.getRemaining() >= TypeBytes.ENTITY_MESSAGE_TYPE_SETBTREEPROPERTYFLOAT_SIZE){
|
|
||||||
return true;
|
|
||||||
} else {
|
|
||||||
return false;
|
|
||||||
}
|
|
||||||
case TypeBytes.ENTITY_MESSAGE_TYPE_SETBTREEPROPERTYDOUBLE:
|
|
||||||
if(byteBuffer.getRemaining() >= TypeBytes.ENTITY_MESSAGE_TYPE_SETBTREEPROPERTYDOUBLE_SIZE){
|
|
||||||
return true;
|
|
||||||
} else {
|
|
||||||
return false;
|
|
||||||
}
|
|
||||||
case TypeBytes.ENTITY_MESSAGE_TYPE_SETBTREEPROPERTYSTRING:
|
|
||||||
return EntityMessage.canParsesetBTreePropertyStringMessage(byteBuffer);
|
|
||||||
case TypeBytes.ENTITY_MESSAGE_TYPE_SETBTREEPROPERTYENUM:
|
|
||||||
if(byteBuffer.getRemaining() >= TypeBytes.ENTITY_MESSAGE_TYPE_SETBTREEPROPERTYENUM_SIZE){
|
|
||||||
return true;
|
|
||||||
} else {
|
|
||||||
return false;
|
|
||||||
}
|
|
||||||
case TypeBytes.ENTITY_MESSAGE_TYPE_ATTACHENTITYTOENTITY:
|
case TypeBytes.ENTITY_MESSAGE_TYPE_ATTACHENTITYTOENTITY:
|
||||||
return EntityMessage.canParseattachEntityToEntityMessage(byteBuffer);
|
return EntityMessage.canParseattachEntityToEntityMessage(byteBuffer);
|
||||||
case TypeBytes.ENTITY_MESSAGE_TYPE_SPAWNFOLIAGESEED:
|
case TypeBytes.ENTITY_MESSAGE_TYPE_SPAWNFOLIAGESEED:
|
||||||
@ -561,50 +502,6 @@ public class EntityMessage extends NetworkMessage {
|
|||||||
return rVal;
|
return rVal;
|
||||||
}
|
}
|
||||||
|
|
||||||
public static EntityMessage parseSetPositionMessage(CircularByteBuffer byteBuffer){
|
|
||||||
EntityMessage rVal = new EntityMessage(EntityMessageType.SETPOSITION);
|
|
||||||
stripPacketHeader(byteBuffer);
|
|
||||||
rVal.setentityID(ByteStreamUtils.popIntFromByteQueue(byteBuffer));
|
|
||||||
rVal.settime(ByteStreamUtils.popLongFromByteQueue(byteBuffer));
|
|
||||||
rVal.setpositionX(ByteStreamUtils.popDoubleFromByteQueue(byteBuffer));
|
|
||||||
rVal.setpositionY(ByteStreamUtils.popDoubleFromByteQueue(byteBuffer));
|
|
||||||
rVal.setpositionZ(ByteStreamUtils.popDoubleFromByteQueue(byteBuffer));
|
|
||||||
return rVal;
|
|
||||||
}
|
|
||||||
|
|
||||||
public static EntityMessage constructSetPositionMessage(int entityID,long time,double positionX,double positionY,double positionZ){
|
|
||||||
EntityMessage rVal = new EntityMessage(EntityMessageType.SETPOSITION);
|
|
||||||
rVal.setentityID(entityID);
|
|
||||||
rVal.settime(time);
|
|
||||||
rVal.setpositionX(positionX);
|
|
||||||
rVal.setpositionY(positionY);
|
|
||||||
rVal.setpositionZ(positionZ);
|
|
||||||
rVal.serialize();
|
|
||||||
return rVal;
|
|
||||||
}
|
|
||||||
|
|
||||||
public static EntityMessage parsesetFacingMessage(CircularByteBuffer byteBuffer){
|
|
||||||
EntityMessage rVal = new EntityMessage(EntityMessageType.SETFACING);
|
|
||||||
stripPacketHeader(byteBuffer);
|
|
||||||
rVal.setentityID(ByteStreamUtils.popIntFromByteQueue(byteBuffer));
|
|
||||||
rVal.settime(ByteStreamUtils.popLongFromByteQueue(byteBuffer));
|
|
||||||
rVal.setrotationX(ByteStreamUtils.popDoubleFromByteQueue(byteBuffer));
|
|
||||||
rVal.setrotationY(ByteStreamUtils.popDoubleFromByteQueue(byteBuffer));
|
|
||||||
rVal.setrotationZ(ByteStreamUtils.popDoubleFromByteQueue(byteBuffer));
|
|
||||||
return rVal;
|
|
||||||
}
|
|
||||||
|
|
||||||
public static EntityMessage constructsetFacingMessage(int entityID,long time,double rotationX,double rotationY,double rotationZ){
|
|
||||||
EntityMessage rVal = new EntityMessage(EntityMessageType.SETFACING);
|
|
||||||
rVal.setentityID(entityID);
|
|
||||||
rVal.settime(time);
|
|
||||||
rVal.setrotationX(rotationX);
|
|
||||||
rVal.setrotationY(rotationY);
|
|
||||||
rVal.setrotationZ(rotationZ);
|
|
||||||
rVal.serialize();
|
|
||||||
return rVal;
|
|
||||||
}
|
|
||||||
|
|
||||||
public static EntityMessage parsemoveUpdateMessage(CircularByteBuffer byteBuffer){
|
public static EntityMessage parsemoveUpdateMessage(CircularByteBuffer byteBuffer){
|
||||||
EntityMessage rVal = new EntityMessage(EntityMessageType.MOVEUPDATE);
|
EntityMessage rVal = new EntityMessage(EntityMessageType.MOVEUPDATE);
|
||||||
stripPacketHeader(byteBuffer);
|
stripPacketHeader(byteBuffer);
|
||||||
@ -618,11 +515,12 @@ public class EntityMessage extends NetworkMessage {
|
|||||||
rVal.setrotationZ(ByteStreamUtils.popDoubleFromByteQueue(byteBuffer));
|
rVal.setrotationZ(ByteStreamUtils.popDoubleFromByteQueue(byteBuffer));
|
||||||
rVal.setrotationW(ByteStreamUtils.popDoubleFromByteQueue(byteBuffer));
|
rVal.setrotationW(ByteStreamUtils.popDoubleFromByteQueue(byteBuffer));
|
||||||
rVal.setvelocity(ByteStreamUtils.popDoubleFromByteQueue(byteBuffer));
|
rVal.setvelocity(ByteStreamUtils.popDoubleFromByteQueue(byteBuffer));
|
||||||
|
rVal.setpropertyValueInt(ByteStreamUtils.popIntFromByteQueue(byteBuffer));
|
||||||
rVal.settreeState(ByteStreamUtils.popIntFromByteQueue(byteBuffer));
|
rVal.settreeState(ByteStreamUtils.popIntFromByteQueue(byteBuffer));
|
||||||
return rVal;
|
return rVal;
|
||||||
}
|
}
|
||||||
|
|
||||||
public static EntityMessage constructmoveUpdateMessage(int entityID,long time,double positionX,double positionY,double positionZ,double rotationX,double rotationY,double rotationZ,double rotationW,double velocity,int treeState){
|
public static EntityMessage constructmoveUpdateMessage(int entityID,long time,double positionX,double positionY,double positionZ,double rotationX,double rotationY,double rotationZ,double rotationW,double velocity,int propertyValueInt,int treeState){
|
||||||
EntityMessage rVal = new EntityMessage(EntityMessageType.MOVEUPDATE);
|
EntityMessage rVal = new EntityMessage(EntityMessageType.MOVEUPDATE);
|
||||||
rVal.setentityID(entityID);
|
rVal.setentityID(entityID);
|
||||||
rVal.settime(time);
|
rVal.settime(time);
|
||||||
@ -634,6 +532,7 @@ public class EntityMessage extends NetworkMessage {
|
|||||||
rVal.setrotationZ(rotationZ);
|
rVal.setrotationZ(rotationZ);
|
||||||
rVal.setrotationW(rotationW);
|
rVal.setrotationW(rotationW);
|
||||||
rVal.setvelocity(velocity);
|
rVal.setvelocity(velocity);
|
||||||
|
rVal.setpropertyValueInt(propertyValueInt);
|
||||||
rVal.settreeState(treeState);
|
rVal.settreeState(treeState);
|
||||||
rVal.serialize();
|
rVal.serialize();
|
||||||
return rVal;
|
return rVal;
|
||||||
@ -683,28 +582,6 @@ public class EntityMessage extends NetworkMessage {
|
|||||||
return rVal;
|
return rVal;
|
||||||
}
|
}
|
||||||
|
|
||||||
public static EntityMessage parseMoveMessage(CircularByteBuffer byteBuffer){
|
|
||||||
EntityMessage rVal = new EntityMessage(EntityMessageType.MOVE);
|
|
||||||
stripPacketHeader(byteBuffer);
|
|
||||||
rVal.setentityID(ByteStreamUtils.popIntFromByteQueue(byteBuffer));
|
|
||||||
rVal.settime(ByteStreamUtils.popLongFromByteQueue(byteBuffer));
|
|
||||||
rVal.setpositionX(ByteStreamUtils.popDoubleFromByteQueue(byteBuffer));
|
|
||||||
rVal.setpositionY(ByteStreamUtils.popDoubleFromByteQueue(byteBuffer));
|
|
||||||
rVal.setpositionZ(ByteStreamUtils.popDoubleFromByteQueue(byteBuffer));
|
|
||||||
return rVal;
|
|
||||||
}
|
|
||||||
|
|
||||||
public static EntityMessage constructMoveMessage(int entityID,long time,double positionX,double positionY,double positionZ){
|
|
||||||
EntityMessage rVal = new EntityMessage(EntityMessageType.MOVE);
|
|
||||||
rVal.setentityID(entityID);
|
|
||||||
rVal.settime(time);
|
|
||||||
rVal.setpositionX(positionX);
|
|
||||||
rVal.setpositionY(positionY);
|
|
||||||
rVal.setpositionZ(positionZ);
|
|
||||||
rVal.serialize();
|
|
||||||
return rVal;
|
|
||||||
}
|
|
||||||
|
|
||||||
public static EntityMessage parseKillMessage(CircularByteBuffer byteBuffer){
|
public static EntityMessage parseKillMessage(CircularByteBuffer byteBuffer){
|
||||||
EntityMessage rVal = new EntityMessage(EntityMessageType.KILL);
|
EntityMessage rVal = new EntityMessage(EntityMessageType.KILL);
|
||||||
stripPacketHeader(byteBuffer);
|
stripPacketHeader(byteBuffer);
|
||||||
@ -735,26 +612,6 @@ public class EntityMessage extends NetworkMessage {
|
|||||||
return rVal;
|
return rVal;
|
||||||
}
|
}
|
||||||
|
|
||||||
public static EntityMessage parseSetBehaviorTreeMessage(CircularByteBuffer byteBuffer){
|
|
||||||
EntityMessage rVal = new EntityMessage(EntityMessageType.SETBEHAVIORTREE);
|
|
||||||
stripPacketHeader(byteBuffer);
|
|
||||||
rVal.setentityID(ByteStreamUtils.popIntFromByteQueue(byteBuffer));
|
|
||||||
rVal.settime(ByteStreamUtils.popLongFromByteQueue(byteBuffer));
|
|
||||||
rVal.settreeType(ByteStreamUtils.popIntFromByteQueue(byteBuffer));
|
|
||||||
rVal.settreeStatus(ByteStreamUtils.popIntFromByteQueue(byteBuffer));
|
|
||||||
return rVal;
|
|
||||||
}
|
|
||||||
|
|
||||||
public static EntityMessage constructSetBehaviorTreeMessage(int entityID,long time,int treeType,int treeStatus){
|
|
||||||
EntityMessage rVal = new EntityMessage(EntityMessageType.SETBEHAVIORTREE);
|
|
||||||
rVal.setentityID(entityID);
|
|
||||||
rVal.settime(time);
|
|
||||||
rVal.settreeType(treeType);
|
|
||||||
rVal.settreeStatus(treeStatus);
|
|
||||||
rVal.serialize();
|
|
||||||
return rVal;
|
|
||||||
}
|
|
||||||
|
|
||||||
public static EntityMessage parsesetPropertyMessage(CircularByteBuffer byteBuffer){
|
public static EntityMessage parsesetPropertyMessage(CircularByteBuffer byteBuffer){
|
||||||
EntityMessage rVal = new EntityMessage(EntityMessageType.SETPROPERTY);
|
EntityMessage rVal = new EntityMessage(EntityMessageType.SETPROPERTY);
|
||||||
stripPacketHeader(byteBuffer);
|
stripPacketHeader(byteBuffer);
|
||||||
@ -775,147 +632,6 @@ public class EntityMessage extends NetworkMessage {
|
|||||||
return rVal;
|
return rVal;
|
||||||
}
|
}
|
||||||
|
|
||||||
public static EntityMessage parsesetBTreePropertyIntMessage(CircularByteBuffer byteBuffer){
|
|
||||||
EntityMessage rVal = new EntityMessage(EntityMessageType.SETBTREEPROPERTYINT);
|
|
||||||
stripPacketHeader(byteBuffer);
|
|
||||||
rVal.setentityID(ByteStreamUtils.popIntFromByteQueue(byteBuffer));
|
|
||||||
rVal.settime(ByteStreamUtils.popLongFromByteQueue(byteBuffer));
|
|
||||||
rVal.setbTreeID(ByteStreamUtils.popIntFromByteQueue(byteBuffer));
|
|
||||||
rVal.setpropertyID(ByteStreamUtils.popIntFromByteQueue(byteBuffer));
|
|
||||||
rVal.setpropertyValueInt(ByteStreamUtils.popIntFromByteQueue(byteBuffer));
|
|
||||||
return rVal;
|
|
||||||
}
|
|
||||||
|
|
||||||
public static EntityMessage constructsetBTreePropertyIntMessage(int entityID,long time,int bTreeID,int propertyID,int propertyValueInt){
|
|
||||||
EntityMessage rVal = new EntityMessage(EntityMessageType.SETBTREEPROPERTYINT);
|
|
||||||
rVal.setentityID(entityID);
|
|
||||||
rVal.settime(time);
|
|
||||||
rVal.setbTreeID(bTreeID);
|
|
||||||
rVal.setpropertyID(propertyID);
|
|
||||||
rVal.setpropertyValueInt(propertyValueInt);
|
|
||||||
rVal.serialize();
|
|
||||||
return rVal;
|
|
||||||
}
|
|
||||||
|
|
||||||
public static EntityMessage parsesetBTreePropertyFloatMessage(CircularByteBuffer byteBuffer){
|
|
||||||
EntityMessage rVal = new EntityMessage(EntityMessageType.SETBTREEPROPERTYFLOAT);
|
|
||||||
stripPacketHeader(byteBuffer);
|
|
||||||
rVal.setentityID(ByteStreamUtils.popIntFromByteQueue(byteBuffer));
|
|
||||||
rVal.settime(ByteStreamUtils.popLongFromByteQueue(byteBuffer));
|
|
||||||
rVal.setbTreeID(ByteStreamUtils.popIntFromByteQueue(byteBuffer));
|
|
||||||
rVal.setpropertyID(ByteStreamUtils.popIntFromByteQueue(byteBuffer));
|
|
||||||
rVal.setpropertyValueFloat(ByteStreamUtils.popFloatFromByteQueue(byteBuffer));
|
|
||||||
return rVal;
|
|
||||||
}
|
|
||||||
|
|
||||||
public static EntityMessage constructsetBTreePropertyFloatMessage(int entityID,long time,int bTreeID,int propertyID,float propertyValueFloat){
|
|
||||||
EntityMessage rVal = new EntityMessage(EntityMessageType.SETBTREEPROPERTYFLOAT);
|
|
||||||
rVal.setentityID(entityID);
|
|
||||||
rVal.settime(time);
|
|
||||||
rVal.setbTreeID(bTreeID);
|
|
||||||
rVal.setpropertyID(propertyID);
|
|
||||||
rVal.setpropertyValueFloat(propertyValueFloat);
|
|
||||||
rVal.serialize();
|
|
||||||
return rVal;
|
|
||||||
}
|
|
||||||
|
|
||||||
public static EntityMessage parsesetBTreePropertyDoubleMessage(CircularByteBuffer byteBuffer){
|
|
||||||
EntityMessage rVal = new EntityMessage(EntityMessageType.SETBTREEPROPERTYDOUBLE);
|
|
||||||
stripPacketHeader(byteBuffer);
|
|
||||||
rVal.setentityID(ByteStreamUtils.popIntFromByteQueue(byteBuffer));
|
|
||||||
rVal.settime(ByteStreamUtils.popLongFromByteQueue(byteBuffer));
|
|
||||||
rVal.setbTreeID(ByteStreamUtils.popIntFromByteQueue(byteBuffer));
|
|
||||||
rVal.setpropertyID(ByteStreamUtils.popIntFromByteQueue(byteBuffer));
|
|
||||||
rVal.setpropertyValueDouble(ByteStreamUtils.popDoubleFromByteQueue(byteBuffer));
|
|
||||||
return rVal;
|
|
||||||
}
|
|
||||||
|
|
||||||
public static EntityMessage constructsetBTreePropertyDoubleMessage(int entityID,long time,int bTreeID,int propertyID,double propertyValueDouble){
|
|
||||||
EntityMessage rVal = new EntityMessage(EntityMessageType.SETBTREEPROPERTYDOUBLE);
|
|
||||||
rVal.setentityID(entityID);
|
|
||||||
rVal.settime(time);
|
|
||||||
rVal.setbTreeID(bTreeID);
|
|
||||||
rVal.setpropertyID(propertyID);
|
|
||||||
rVal.setpropertyValueDouble(propertyValueDouble);
|
|
||||||
rVal.serialize();
|
|
||||||
return rVal;
|
|
||||||
}
|
|
||||||
|
|
||||||
public static boolean canParsesetBTreePropertyStringMessage(CircularByteBuffer byteBuffer){
|
|
||||||
int currentStreamLength = byteBuffer.getRemaining();
|
|
||||||
List<Byte> temporaryByteQueue = new LinkedList();
|
|
||||||
if(currentStreamLength < 6){
|
|
||||||
return false;
|
|
||||||
}
|
|
||||||
if(currentStreamLength < 14){
|
|
||||||
return false;
|
|
||||||
}
|
|
||||||
if(currentStreamLength < 18){
|
|
||||||
return false;
|
|
||||||
}
|
|
||||||
if(currentStreamLength < 22){
|
|
||||||
return false;
|
|
||||||
}
|
|
||||||
int propertyValueStringSize = 0;
|
|
||||||
if(currentStreamLength < 26){
|
|
||||||
return false;
|
|
||||||
} else {
|
|
||||||
temporaryByteQueue.add(byteBuffer.peek(22 + 0));
|
|
||||||
temporaryByteQueue.add(byteBuffer.peek(22 + 1));
|
|
||||||
temporaryByteQueue.add(byteBuffer.peek(22 + 2));
|
|
||||||
temporaryByteQueue.add(byteBuffer.peek(22 + 3));
|
|
||||||
propertyValueStringSize = ByteStreamUtils.popIntFromByteQueue(temporaryByteQueue);
|
|
||||||
}
|
|
||||||
if(currentStreamLength < 26 + propertyValueStringSize){
|
|
||||||
return false;
|
|
||||||
}
|
|
||||||
return true;
|
|
||||||
}
|
|
||||||
|
|
||||||
public static EntityMessage parsesetBTreePropertyStringMessage(CircularByteBuffer byteBuffer){
|
|
||||||
EntityMessage rVal = new EntityMessage(EntityMessageType.SETBTREEPROPERTYSTRING);
|
|
||||||
stripPacketHeader(byteBuffer);
|
|
||||||
rVal.setentityID(ByteStreamUtils.popIntFromByteQueue(byteBuffer));
|
|
||||||
rVal.settime(ByteStreamUtils.popLongFromByteQueue(byteBuffer));
|
|
||||||
rVal.setbTreeID(ByteStreamUtils.popIntFromByteQueue(byteBuffer));
|
|
||||||
rVal.setpropertyID(ByteStreamUtils.popIntFromByteQueue(byteBuffer));
|
|
||||||
rVal.setpropertyValueString(ByteStreamUtils.popStringFromByteQueue(byteBuffer));
|
|
||||||
return rVal;
|
|
||||||
}
|
|
||||||
|
|
||||||
public static EntityMessage constructsetBTreePropertyStringMessage(int entityID,long time,int bTreeID,int propertyID,String propertyValueString){
|
|
||||||
EntityMessage rVal = new EntityMessage(EntityMessageType.SETBTREEPROPERTYSTRING);
|
|
||||||
rVal.setentityID(entityID);
|
|
||||||
rVal.settime(time);
|
|
||||||
rVal.setbTreeID(bTreeID);
|
|
||||||
rVal.setpropertyID(propertyID);
|
|
||||||
rVal.setpropertyValueString(propertyValueString);
|
|
||||||
rVal.serialize();
|
|
||||||
return rVal;
|
|
||||||
}
|
|
||||||
|
|
||||||
public static EntityMessage parsesetBTreePropertyEnumMessage(CircularByteBuffer byteBuffer){
|
|
||||||
EntityMessage rVal = new EntityMessage(EntityMessageType.SETBTREEPROPERTYENUM);
|
|
||||||
stripPacketHeader(byteBuffer);
|
|
||||||
rVal.setentityID(ByteStreamUtils.popIntFromByteQueue(byteBuffer));
|
|
||||||
rVal.settime(ByteStreamUtils.popLongFromByteQueue(byteBuffer));
|
|
||||||
rVal.setbTreeID(ByteStreamUtils.popIntFromByteQueue(byteBuffer));
|
|
||||||
rVal.setpropertyID(ByteStreamUtils.popIntFromByteQueue(byteBuffer));
|
|
||||||
rVal.setpropertyValueInt(ByteStreamUtils.popIntFromByteQueue(byteBuffer));
|
|
||||||
return rVal;
|
|
||||||
}
|
|
||||||
|
|
||||||
public static EntityMessage constructsetBTreePropertyEnumMessage(int entityID,long time,int bTreeID,int propertyID,int propertyValueInt){
|
|
||||||
EntityMessage rVal = new EntityMessage(EntityMessageType.SETBTREEPROPERTYENUM);
|
|
||||||
rVal.setentityID(entityID);
|
|
||||||
rVal.settime(time);
|
|
||||||
rVal.setbTreeID(bTreeID);
|
|
||||||
rVal.setpropertyID(propertyID);
|
|
||||||
rVal.setpropertyValueInt(propertyValueInt);
|
|
||||||
rVal.serialize();
|
|
||||||
return rVal;
|
|
||||||
}
|
|
||||||
|
|
||||||
public static boolean canParseattachEntityToEntityMessage(CircularByteBuffer byteBuffer){
|
public static boolean canParseattachEntityToEntityMessage(CircularByteBuffer byteBuffer){
|
||||||
int currentStreamLength = byteBuffer.getRemaining();
|
int currentStreamLength = byteBuffer.getRemaining();
|
||||||
List<Byte> temporaryByteQueue = new LinkedList();
|
List<Byte> temporaryByteQueue = new LinkedList();
|
||||||
@ -1141,62 +857,8 @@ public class EntityMessage extends NetworkMessage {
|
|||||||
rawBytes[26+creatureTemplate.length()+i] = intValues[i];
|
rawBytes[26+creatureTemplate.length()+i] = intValues[i];
|
||||||
}
|
}
|
||||||
break;
|
break;
|
||||||
case SETPOSITION:
|
|
||||||
rawBytes = new byte[2+4+8+8+8+8];
|
|
||||||
//message header
|
|
||||||
rawBytes[0] = TypeBytes.MESSAGE_TYPE_ENTITY;
|
|
||||||
//entity messaage header
|
|
||||||
rawBytes[1] = TypeBytes.ENTITY_MESSAGE_TYPE_SETPOSITION;
|
|
||||||
intValues = ByteStreamUtils.serializeIntToBytes(entityID);
|
|
||||||
for(int i = 0; i < 4; i++){
|
|
||||||
rawBytes[2+i] = intValues[i];
|
|
||||||
}
|
|
||||||
intValues = ByteStreamUtils.serializeLongToBytes(time);
|
|
||||||
for(int i = 0; i < 8; i++){
|
|
||||||
rawBytes[6+i] = intValues[i];
|
|
||||||
}
|
|
||||||
intValues = ByteStreamUtils.serializeDoubleToBytes(positionX);
|
|
||||||
for(int i = 0; i < 8; i++){
|
|
||||||
rawBytes[14+i] = intValues[i];
|
|
||||||
}
|
|
||||||
intValues = ByteStreamUtils.serializeDoubleToBytes(positionY);
|
|
||||||
for(int i = 0; i < 8; i++){
|
|
||||||
rawBytes[22+i] = intValues[i];
|
|
||||||
}
|
|
||||||
intValues = ByteStreamUtils.serializeDoubleToBytes(positionZ);
|
|
||||||
for(int i = 0; i < 8; i++){
|
|
||||||
rawBytes[30+i] = intValues[i];
|
|
||||||
}
|
|
||||||
break;
|
|
||||||
case SETFACING:
|
|
||||||
rawBytes = new byte[2+4+8+8+8+8];
|
|
||||||
//message header
|
|
||||||
rawBytes[0] = TypeBytes.MESSAGE_TYPE_ENTITY;
|
|
||||||
//entity messaage header
|
|
||||||
rawBytes[1] = TypeBytes.ENTITY_MESSAGE_TYPE_SETFACING;
|
|
||||||
intValues = ByteStreamUtils.serializeIntToBytes(entityID);
|
|
||||||
for(int i = 0; i < 4; i++){
|
|
||||||
rawBytes[2+i] = intValues[i];
|
|
||||||
}
|
|
||||||
intValues = ByteStreamUtils.serializeLongToBytes(time);
|
|
||||||
for(int i = 0; i < 8; i++){
|
|
||||||
rawBytes[6+i] = intValues[i];
|
|
||||||
}
|
|
||||||
intValues = ByteStreamUtils.serializeDoubleToBytes(rotationX);
|
|
||||||
for(int i = 0; i < 8; i++){
|
|
||||||
rawBytes[14+i] = intValues[i];
|
|
||||||
}
|
|
||||||
intValues = ByteStreamUtils.serializeDoubleToBytes(rotationY);
|
|
||||||
for(int i = 0; i < 8; i++){
|
|
||||||
rawBytes[22+i] = intValues[i];
|
|
||||||
}
|
|
||||||
intValues = ByteStreamUtils.serializeDoubleToBytes(rotationZ);
|
|
||||||
for(int i = 0; i < 8; i++){
|
|
||||||
rawBytes[30+i] = intValues[i];
|
|
||||||
}
|
|
||||||
break;
|
|
||||||
case MOVEUPDATE:
|
case MOVEUPDATE:
|
||||||
rawBytes = new byte[2+4+8+8+8+8+8+8+8+8+8+4];
|
rawBytes = new byte[2+4+8+8+8+8+8+8+8+8+8+4+4];
|
||||||
//message header
|
//message header
|
||||||
rawBytes[0] = TypeBytes.MESSAGE_TYPE_ENTITY;
|
rawBytes[0] = TypeBytes.MESSAGE_TYPE_ENTITY;
|
||||||
//entity messaage header
|
//entity messaage header
|
||||||
@ -1241,10 +903,14 @@ public class EntityMessage extends NetworkMessage {
|
|||||||
for(int i = 0; i < 8; i++){
|
for(int i = 0; i < 8; i++){
|
||||||
rawBytes[70+i] = intValues[i];
|
rawBytes[70+i] = intValues[i];
|
||||||
}
|
}
|
||||||
intValues = ByteStreamUtils.serializeIntToBytes(treeState);
|
intValues = ByteStreamUtils.serializeIntToBytes(propertyValueInt);
|
||||||
for(int i = 0; i < 4; i++){
|
for(int i = 0; i < 4; i++){
|
||||||
rawBytes[78+i] = intValues[i];
|
rawBytes[78+i] = intValues[i];
|
||||||
}
|
}
|
||||||
|
intValues = ByteStreamUtils.serializeIntToBytes(treeState);
|
||||||
|
for(int i = 0; i < 4; i++){
|
||||||
|
rawBytes[82+i] = intValues[i];
|
||||||
|
}
|
||||||
break;
|
break;
|
||||||
case ATTACKUPDATE:
|
case ATTACKUPDATE:
|
||||||
rawBytes = new byte[2+4+8+8+8+8+8+8+8+8+4];
|
rawBytes = new byte[2+4+8+8+8+8+8+8+8+8+4];
|
||||||
@ -1300,33 +966,6 @@ public class EntityMessage extends NetworkMessage {
|
|||||||
//entity messaage header
|
//entity messaage header
|
||||||
rawBytes[1] = TypeBytes.ENTITY_MESSAGE_TYPE_STARTATTACK;
|
rawBytes[1] = TypeBytes.ENTITY_MESSAGE_TYPE_STARTATTACK;
|
||||||
break;
|
break;
|
||||||
case MOVE:
|
|
||||||
rawBytes = new byte[2+4+8+8+8+8];
|
|
||||||
//message header
|
|
||||||
rawBytes[0] = TypeBytes.MESSAGE_TYPE_ENTITY;
|
|
||||||
//entity messaage header
|
|
||||||
rawBytes[1] = TypeBytes.ENTITY_MESSAGE_TYPE_MOVE;
|
|
||||||
intValues = ByteStreamUtils.serializeIntToBytes(entityID);
|
|
||||||
for(int i = 0; i < 4; i++){
|
|
||||||
rawBytes[2+i] = intValues[i];
|
|
||||||
}
|
|
||||||
intValues = ByteStreamUtils.serializeLongToBytes(time);
|
|
||||||
for(int i = 0; i < 8; i++){
|
|
||||||
rawBytes[6+i] = intValues[i];
|
|
||||||
}
|
|
||||||
intValues = ByteStreamUtils.serializeDoubleToBytes(positionX);
|
|
||||||
for(int i = 0; i < 8; i++){
|
|
||||||
rawBytes[14+i] = intValues[i];
|
|
||||||
}
|
|
||||||
intValues = ByteStreamUtils.serializeDoubleToBytes(positionY);
|
|
||||||
for(int i = 0; i < 8; i++){
|
|
||||||
rawBytes[22+i] = intValues[i];
|
|
||||||
}
|
|
||||||
intValues = ByteStreamUtils.serializeDoubleToBytes(positionZ);
|
|
||||||
for(int i = 0; i < 8; i++){
|
|
||||||
rawBytes[30+i] = intValues[i];
|
|
||||||
}
|
|
||||||
break;
|
|
||||||
case KILL:
|
case KILL:
|
||||||
rawBytes = new byte[2+8+4];
|
rawBytes = new byte[2+8+4];
|
||||||
//message header
|
//message header
|
||||||
@ -1353,29 +992,6 @@ public class EntityMessage extends NetworkMessage {
|
|||||||
rawBytes[2+i] = intValues[i];
|
rawBytes[2+i] = intValues[i];
|
||||||
}
|
}
|
||||||
break;
|
break;
|
||||||
case SETBEHAVIORTREE:
|
|
||||||
rawBytes = new byte[2+4+8+4+4];
|
|
||||||
//message header
|
|
||||||
rawBytes[0] = TypeBytes.MESSAGE_TYPE_ENTITY;
|
|
||||||
//entity messaage header
|
|
||||||
rawBytes[1] = TypeBytes.ENTITY_MESSAGE_TYPE_SETBEHAVIORTREE;
|
|
||||||
intValues = ByteStreamUtils.serializeIntToBytes(entityID);
|
|
||||||
for(int i = 0; i < 4; i++){
|
|
||||||
rawBytes[2+i] = intValues[i];
|
|
||||||
}
|
|
||||||
intValues = ByteStreamUtils.serializeLongToBytes(time);
|
|
||||||
for(int i = 0; i < 8; i++){
|
|
||||||
rawBytes[6+i] = intValues[i];
|
|
||||||
}
|
|
||||||
intValues = ByteStreamUtils.serializeIntToBytes(treeType);
|
|
||||||
for(int i = 0; i < 4; i++){
|
|
||||||
rawBytes[14+i] = intValues[i];
|
|
||||||
}
|
|
||||||
intValues = ByteStreamUtils.serializeIntToBytes(treeStatus);
|
|
||||||
for(int i = 0; i < 4; i++){
|
|
||||||
rawBytes[18+i] = intValues[i];
|
|
||||||
}
|
|
||||||
break;
|
|
||||||
case SETPROPERTY:
|
case SETPROPERTY:
|
||||||
rawBytes = new byte[2+4+8+4+4];
|
rawBytes = new byte[2+4+8+4+4];
|
||||||
//message header
|
//message header
|
||||||
@ -1399,144 +1015,6 @@ public class EntityMessage extends NetworkMessage {
|
|||||||
rawBytes[18+i] = intValues[i];
|
rawBytes[18+i] = intValues[i];
|
||||||
}
|
}
|
||||||
break;
|
break;
|
||||||
case SETBTREEPROPERTYINT:
|
|
||||||
rawBytes = new byte[2+4+8+4+4+4];
|
|
||||||
//message header
|
|
||||||
rawBytes[0] = TypeBytes.MESSAGE_TYPE_ENTITY;
|
|
||||||
//entity messaage header
|
|
||||||
rawBytes[1] = TypeBytes.ENTITY_MESSAGE_TYPE_SETBTREEPROPERTYINT;
|
|
||||||
intValues = ByteStreamUtils.serializeIntToBytes(entityID);
|
|
||||||
for(int i = 0; i < 4; i++){
|
|
||||||
rawBytes[2+i] = intValues[i];
|
|
||||||
}
|
|
||||||
intValues = ByteStreamUtils.serializeLongToBytes(time);
|
|
||||||
for(int i = 0; i < 8; i++){
|
|
||||||
rawBytes[6+i] = intValues[i];
|
|
||||||
}
|
|
||||||
intValues = ByteStreamUtils.serializeIntToBytes(bTreeID);
|
|
||||||
for(int i = 0; i < 4; i++){
|
|
||||||
rawBytes[14+i] = intValues[i];
|
|
||||||
}
|
|
||||||
intValues = ByteStreamUtils.serializeIntToBytes(propertyID);
|
|
||||||
for(int i = 0; i < 4; i++){
|
|
||||||
rawBytes[18+i] = intValues[i];
|
|
||||||
}
|
|
||||||
intValues = ByteStreamUtils.serializeIntToBytes(propertyValueInt);
|
|
||||||
for(int i = 0; i < 4; i++){
|
|
||||||
rawBytes[22+i] = intValues[i];
|
|
||||||
}
|
|
||||||
break;
|
|
||||||
case SETBTREEPROPERTYFLOAT:
|
|
||||||
rawBytes = new byte[2+4+8+4+4+4];
|
|
||||||
//message header
|
|
||||||
rawBytes[0] = TypeBytes.MESSAGE_TYPE_ENTITY;
|
|
||||||
//entity messaage header
|
|
||||||
rawBytes[1] = TypeBytes.ENTITY_MESSAGE_TYPE_SETBTREEPROPERTYFLOAT;
|
|
||||||
intValues = ByteStreamUtils.serializeIntToBytes(entityID);
|
|
||||||
for(int i = 0; i < 4; i++){
|
|
||||||
rawBytes[2+i] = intValues[i];
|
|
||||||
}
|
|
||||||
intValues = ByteStreamUtils.serializeLongToBytes(time);
|
|
||||||
for(int i = 0; i < 8; i++){
|
|
||||||
rawBytes[6+i] = intValues[i];
|
|
||||||
}
|
|
||||||
intValues = ByteStreamUtils.serializeIntToBytes(bTreeID);
|
|
||||||
for(int i = 0; i < 4; i++){
|
|
||||||
rawBytes[14+i] = intValues[i];
|
|
||||||
}
|
|
||||||
intValues = ByteStreamUtils.serializeIntToBytes(propertyID);
|
|
||||||
for(int i = 0; i < 4; i++){
|
|
||||||
rawBytes[18+i] = intValues[i];
|
|
||||||
}
|
|
||||||
intValues = ByteStreamUtils.serializeFloatToBytes(propertyValueFloat);
|
|
||||||
for(int i = 0; i < 4; i++){
|
|
||||||
rawBytes[22+i] = intValues[i];
|
|
||||||
} break;
|
|
||||||
case SETBTREEPROPERTYDOUBLE:
|
|
||||||
rawBytes = new byte[2+4+8+4+4+8];
|
|
||||||
//message header
|
|
||||||
rawBytes[0] = TypeBytes.MESSAGE_TYPE_ENTITY;
|
|
||||||
//entity messaage header
|
|
||||||
rawBytes[1] = TypeBytes.ENTITY_MESSAGE_TYPE_SETBTREEPROPERTYDOUBLE;
|
|
||||||
intValues = ByteStreamUtils.serializeIntToBytes(entityID);
|
|
||||||
for(int i = 0; i < 4; i++){
|
|
||||||
rawBytes[2+i] = intValues[i];
|
|
||||||
}
|
|
||||||
intValues = ByteStreamUtils.serializeLongToBytes(time);
|
|
||||||
for(int i = 0; i < 8; i++){
|
|
||||||
rawBytes[6+i] = intValues[i];
|
|
||||||
}
|
|
||||||
intValues = ByteStreamUtils.serializeIntToBytes(bTreeID);
|
|
||||||
for(int i = 0; i < 4; i++){
|
|
||||||
rawBytes[14+i] = intValues[i];
|
|
||||||
}
|
|
||||||
intValues = ByteStreamUtils.serializeIntToBytes(propertyID);
|
|
||||||
for(int i = 0; i < 4; i++){
|
|
||||||
rawBytes[18+i] = intValues[i];
|
|
||||||
}
|
|
||||||
intValues = ByteStreamUtils.serializeDoubleToBytes(propertyValueDouble);
|
|
||||||
for(int i = 0; i < 8; i++){
|
|
||||||
rawBytes[22+i] = intValues[i];
|
|
||||||
}
|
|
||||||
break;
|
|
||||||
case SETBTREEPROPERTYSTRING:
|
|
||||||
rawBytes = new byte[2+4+8+4+4+4+propertyValueString.length()];
|
|
||||||
//message header
|
|
||||||
rawBytes[0] = TypeBytes.MESSAGE_TYPE_ENTITY;
|
|
||||||
//entity messaage header
|
|
||||||
rawBytes[1] = TypeBytes.ENTITY_MESSAGE_TYPE_SETBTREEPROPERTYSTRING;
|
|
||||||
intValues = ByteStreamUtils.serializeIntToBytes(entityID);
|
|
||||||
for(int i = 0; i < 4; i++){
|
|
||||||
rawBytes[2+i] = intValues[i];
|
|
||||||
}
|
|
||||||
intValues = ByteStreamUtils.serializeLongToBytes(time);
|
|
||||||
for(int i = 0; i < 8; i++){
|
|
||||||
rawBytes[6+i] = intValues[i];
|
|
||||||
}
|
|
||||||
intValues = ByteStreamUtils.serializeIntToBytes(bTreeID);
|
|
||||||
for(int i = 0; i < 4; i++){
|
|
||||||
rawBytes[14+i] = intValues[i];
|
|
||||||
}
|
|
||||||
intValues = ByteStreamUtils.serializeIntToBytes(propertyID);
|
|
||||||
for(int i = 0; i < 4; i++){
|
|
||||||
rawBytes[18+i] = intValues[i];
|
|
||||||
}
|
|
||||||
intValues = ByteStreamUtils.serializeIntToBytes(propertyValueString.length());
|
|
||||||
for(int i = 0; i < 4; i++){
|
|
||||||
rawBytes[22+i] = intValues[i];
|
|
||||||
}
|
|
||||||
stringBytes = propertyValueString.getBytes();
|
|
||||||
for(int i = 0; i < propertyValueString.length(); i++){
|
|
||||||
rawBytes[26+i] = stringBytes[i];
|
|
||||||
}
|
|
||||||
break;
|
|
||||||
case SETBTREEPROPERTYENUM:
|
|
||||||
rawBytes = new byte[2+4+8+4+4+4];
|
|
||||||
//message header
|
|
||||||
rawBytes[0] = TypeBytes.MESSAGE_TYPE_ENTITY;
|
|
||||||
//entity messaage header
|
|
||||||
rawBytes[1] = TypeBytes.ENTITY_MESSAGE_TYPE_SETBTREEPROPERTYENUM;
|
|
||||||
intValues = ByteStreamUtils.serializeIntToBytes(entityID);
|
|
||||||
for(int i = 0; i < 4; i++){
|
|
||||||
rawBytes[2+i] = intValues[i];
|
|
||||||
}
|
|
||||||
intValues = ByteStreamUtils.serializeLongToBytes(time);
|
|
||||||
for(int i = 0; i < 8; i++){
|
|
||||||
rawBytes[6+i] = intValues[i];
|
|
||||||
}
|
|
||||||
intValues = ByteStreamUtils.serializeIntToBytes(bTreeID);
|
|
||||||
for(int i = 0; i < 4; i++){
|
|
||||||
rawBytes[14+i] = intValues[i];
|
|
||||||
}
|
|
||||||
intValues = ByteStreamUtils.serializeIntToBytes(propertyID);
|
|
||||||
for(int i = 0; i < 4; i++){
|
|
||||||
rawBytes[18+i] = intValues[i];
|
|
||||||
}
|
|
||||||
intValues = ByteStreamUtils.serializeIntToBytes(propertyValueInt);
|
|
||||||
for(int i = 0; i < 4; i++){
|
|
||||||
rawBytes[22+i] = intValues[i];
|
|
||||||
}
|
|
||||||
break;
|
|
||||||
case ATTACHENTITYTOENTITY:
|
case ATTACHENTITYTOENTITY:
|
||||||
rawBytes = new byte[2+4+4+bone.length()+4];
|
rawBytes = new byte[2+4+4+bone.length()+4];
|
||||||
//message header
|
//message header
|
||||||
|
|||||||
@ -10,10 +10,6 @@ public class LoreMessage extends NetworkMessage {
|
|||||||
public enum LoreMessageType {
|
public enum LoreMessageType {
|
||||||
REQUESTRACES,
|
REQUESTRACES,
|
||||||
RESPONSERACES,
|
RESPONSERACES,
|
||||||
REQUESTRACEDATA,
|
|
||||||
RESPONSERACEDATA,
|
|
||||||
REQUESTDATA,
|
|
||||||
RESPONSEDATA,
|
|
||||||
}
|
}
|
||||||
|
|
||||||
LoreMessageType messageType;
|
LoreMessageType messageType;
|
||||||
@ -50,18 +46,6 @@ public class LoreMessage extends NetworkMessage {
|
|||||||
}
|
}
|
||||||
case TypeBytes.LORE_MESSAGE_TYPE_RESPONSERACES:
|
case TypeBytes.LORE_MESSAGE_TYPE_RESPONSERACES:
|
||||||
return LoreMessage.canParseResponseRacesMessage(byteBuffer);
|
return LoreMessage.canParseResponseRacesMessage(byteBuffer);
|
||||||
case TypeBytes.LORE_MESSAGE_TYPE_REQUESTRACEDATA:
|
|
||||||
if(byteBuffer.getRemaining() >= TypeBytes.LORE_MESSAGE_TYPE_REQUESTRACEDATA_SIZE){
|
|
||||||
return true;
|
|
||||||
} else {
|
|
||||||
return false;
|
|
||||||
}
|
|
||||||
case TypeBytes.LORE_MESSAGE_TYPE_RESPONSERACEDATA:
|
|
||||||
return LoreMessage.canParseResponseRaceDataMessage(byteBuffer);
|
|
||||||
case TypeBytes.LORE_MESSAGE_TYPE_REQUESTDATA:
|
|
||||||
return LoreMessage.canParseRequestDataMessage(byteBuffer);
|
|
||||||
case TypeBytes.LORE_MESSAGE_TYPE_RESPONSEDATA:
|
|
||||||
return LoreMessage.canParseResponseDataMessage(byteBuffer);
|
|
||||||
}
|
}
|
||||||
return false;
|
return false;
|
||||||
}
|
}
|
||||||
@ -111,117 +95,6 @@ public class LoreMessage extends NetworkMessage {
|
|||||||
return rVal;
|
return rVal;
|
||||||
}
|
}
|
||||||
|
|
||||||
public static LoreMessage parseRequestRaceDataMessage(CircularByteBuffer byteBuffer){
|
|
||||||
LoreMessage rVal = new LoreMessage(LoreMessageType.REQUESTRACEDATA);
|
|
||||||
stripPacketHeader(byteBuffer);
|
|
||||||
return rVal;
|
|
||||||
}
|
|
||||||
|
|
||||||
public static LoreMessage constructRequestRaceDataMessage(){
|
|
||||||
LoreMessage rVal = new LoreMessage(LoreMessageType.REQUESTRACEDATA);
|
|
||||||
rVal.serialize();
|
|
||||||
return rVal;
|
|
||||||
}
|
|
||||||
|
|
||||||
public static boolean canParseResponseRaceDataMessage(CircularByteBuffer byteBuffer){
|
|
||||||
int currentStreamLength = byteBuffer.getRemaining();
|
|
||||||
List<Byte> temporaryByteQueue = new LinkedList();
|
|
||||||
int dataSize = 0;
|
|
||||||
if(currentStreamLength < 6){
|
|
||||||
return false;
|
|
||||||
} else {
|
|
||||||
temporaryByteQueue.add(byteBuffer.peek(2 + 0));
|
|
||||||
temporaryByteQueue.add(byteBuffer.peek(2 + 1));
|
|
||||||
temporaryByteQueue.add(byteBuffer.peek(2 + 2));
|
|
||||||
temporaryByteQueue.add(byteBuffer.peek(2 + 3));
|
|
||||||
dataSize = ByteStreamUtils.popIntFromByteQueue(temporaryByteQueue);
|
|
||||||
}
|
|
||||||
if(currentStreamLength < 6 + dataSize){
|
|
||||||
return false;
|
|
||||||
}
|
|
||||||
return true;
|
|
||||||
}
|
|
||||||
|
|
||||||
public static LoreMessage parseResponseRaceDataMessage(CircularByteBuffer byteBuffer){
|
|
||||||
LoreMessage rVal = new LoreMessage(LoreMessageType.RESPONSERACEDATA);
|
|
||||||
stripPacketHeader(byteBuffer);
|
|
||||||
rVal.setdata(ByteStreamUtils.popStringFromByteQueue(byteBuffer));
|
|
||||||
return rVal;
|
|
||||||
}
|
|
||||||
|
|
||||||
public static LoreMessage constructResponseRaceDataMessage(String data){
|
|
||||||
LoreMessage rVal = new LoreMessage(LoreMessageType.RESPONSERACEDATA);
|
|
||||||
rVal.setdata(data);
|
|
||||||
rVal.serialize();
|
|
||||||
return rVal;
|
|
||||||
}
|
|
||||||
|
|
||||||
public static boolean canParseRequestDataMessage(CircularByteBuffer byteBuffer){
|
|
||||||
int currentStreamLength = byteBuffer.getRemaining();
|
|
||||||
List<Byte> temporaryByteQueue = new LinkedList();
|
|
||||||
int dataSize = 0;
|
|
||||||
if(currentStreamLength < 6){
|
|
||||||
return false;
|
|
||||||
} else {
|
|
||||||
temporaryByteQueue.add(byteBuffer.peek(2 + 0));
|
|
||||||
temporaryByteQueue.add(byteBuffer.peek(2 + 1));
|
|
||||||
temporaryByteQueue.add(byteBuffer.peek(2 + 2));
|
|
||||||
temporaryByteQueue.add(byteBuffer.peek(2 + 3));
|
|
||||||
dataSize = ByteStreamUtils.popIntFromByteQueue(temporaryByteQueue);
|
|
||||||
}
|
|
||||||
if(currentStreamLength < 6 + dataSize){
|
|
||||||
return false;
|
|
||||||
}
|
|
||||||
return true;
|
|
||||||
}
|
|
||||||
|
|
||||||
public static LoreMessage parseRequestDataMessage(CircularByteBuffer byteBuffer){
|
|
||||||
LoreMessage rVal = new LoreMessage(LoreMessageType.REQUESTDATA);
|
|
||||||
stripPacketHeader(byteBuffer);
|
|
||||||
rVal.setdata(ByteStreamUtils.popStringFromByteQueue(byteBuffer));
|
|
||||||
return rVal;
|
|
||||||
}
|
|
||||||
|
|
||||||
public static LoreMessage constructRequestDataMessage(String data){
|
|
||||||
LoreMessage rVal = new LoreMessage(LoreMessageType.REQUESTDATA);
|
|
||||||
rVal.setdata(data);
|
|
||||||
rVal.serialize();
|
|
||||||
return rVal;
|
|
||||||
}
|
|
||||||
|
|
||||||
public static boolean canParseResponseDataMessage(CircularByteBuffer byteBuffer){
|
|
||||||
int currentStreamLength = byteBuffer.getRemaining();
|
|
||||||
List<Byte> temporaryByteQueue = new LinkedList();
|
|
||||||
int dataSize = 0;
|
|
||||||
if(currentStreamLength < 6){
|
|
||||||
return false;
|
|
||||||
} else {
|
|
||||||
temporaryByteQueue.add(byteBuffer.peek(2 + 0));
|
|
||||||
temporaryByteQueue.add(byteBuffer.peek(2 + 1));
|
|
||||||
temporaryByteQueue.add(byteBuffer.peek(2 + 2));
|
|
||||||
temporaryByteQueue.add(byteBuffer.peek(2 + 3));
|
|
||||||
dataSize = ByteStreamUtils.popIntFromByteQueue(temporaryByteQueue);
|
|
||||||
}
|
|
||||||
if(currentStreamLength < 6 + dataSize){
|
|
||||||
return false;
|
|
||||||
}
|
|
||||||
return true;
|
|
||||||
}
|
|
||||||
|
|
||||||
public static LoreMessage parseResponseDataMessage(CircularByteBuffer byteBuffer){
|
|
||||||
LoreMessage rVal = new LoreMessage(LoreMessageType.RESPONSEDATA);
|
|
||||||
stripPacketHeader(byteBuffer);
|
|
||||||
rVal.setdata(ByteStreamUtils.popStringFromByteQueue(byteBuffer));
|
|
||||||
return rVal;
|
|
||||||
}
|
|
||||||
|
|
||||||
public static LoreMessage constructResponseDataMessage(String data){
|
|
||||||
LoreMessage rVal = new LoreMessage(LoreMessageType.RESPONSEDATA);
|
|
||||||
rVal.setdata(data);
|
|
||||||
rVal.serialize();
|
|
||||||
return rVal;
|
|
||||||
}
|
|
||||||
|
|
||||||
@Override
|
@Override
|
||||||
void serialize(){
|
void serialize(){
|
||||||
byte[] intValues = new byte[8];
|
byte[] intValues = new byte[8];
|
||||||
@ -249,58 +122,6 @@ public class LoreMessage extends NetworkMessage {
|
|||||||
rawBytes[6+i] = stringBytes[i];
|
rawBytes[6+i] = stringBytes[i];
|
||||||
}
|
}
|
||||||
break;
|
break;
|
||||||
case REQUESTRACEDATA:
|
|
||||||
rawBytes = new byte[2];
|
|
||||||
//message header
|
|
||||||
rawBytes[0] = TypeBytes.MESSAGE_TYPE_LORE;
|
|
||||||
//entity messaage header
|
|
||||||
rawBytes[1] = TypeBytes.LORE_MESSAGE_TYPE_REQUESTRACEDATA;
|
|
||||||
break;
|
|
||||||
case RESPONSERACEDATA:
|
|
||||||
rawBytes = new byte[2+4+data.length()];
|
|
||||||
//message header
|
|
||||||
rawBytes[0] = TypeBytes.MESSAGE_TYPE_LORE;
|
|
||||||
//entity messaage header
|
|
||||||
rawBytes[1] = TypeBytes.LORE_MESSAGE_TYPE_RESPONSERACEDATA;
|
|
||||||
intValues = ByteStreamUtils.serializeIntToBytes(data.length());
|
|
||||||
for(int i = 0; i < 4; i++){
|
|
||||||
rawBytes[2+i] = intValues[i];
|
|
||||||
}
|
|
||||||
stringBytes = data.getBytes();
|
|
||||||
for(int i = 0; i < data.length(); i++){
|
|
||||||
rawBytes[6+i] = stringBytes[i];
|
|
||||||
}
|
|
||||||
break;
|
|
||||||
case REQUESTDATA:
|
|
||||||
rawBytes = new byte[2+4+data.length()];
|
|
||||||
//message header
|
|
||||||
rawBytes[0] = TypeBytes.MESSAGE_TYPE_LORE;
|
|
||||||
//entity messaage header
|
|
||||||
rawBytes[1] = TypeBytes.LORE_MESSAGE_TYPE_REQUESTDATA;
|
|
||||||
intValues = ByteStreamUtils.serializeIntToBytes(data.length());
|
|
||||||
for(int i = 0; i < 4; i++){
|
|
||||||
rawBytes[2+i] = intValues[i];
|
|
||||||
}
|
|
||||||
stringBytes = data.getBytes();
|
|
||||||
for(int i = 0; i < data.length(); i++){
|
|
||||||
rawBytes[6+i] = stringBytes[i];
|
|
||||||
}
|
|
||||||
break;
|
|
||||||
case RESPONSEDATA:
|
|
||||||
rawBytes = new byte[2+4+data.length()];
|
|
||||||
//message header
|
|
||||||
rawBytes[0] = TypeBytes.MESSAGE_TYPE_LORE;
|
|
||||||
//entity messaage header
|
|
||||||
rawBytes[1] = TypeBytes.LORE_MESSAGE_TYPE_RESPONSEDATA;
|
|
||||||
intValues = ByteStreamUtils.serializeIntToBytes(data.length());
|
|
||||||
for(int i = 0; i < 4; i++){
|
|
||||||
rawBytes[2+i] = intValues[i];
|
|
||||||
}
|
|
||||||
stringBytes = data.getBytes();
|
|
||||||
for(int i = 0; i < data.length(); i++){
|
|
||||||
rawBytes[6+i] = stringBytes[i];
|
|
||||||
}
|
|
||||||
break;
|
|
||||||
}
|
}
|
||||||
serialized = true;
|
serialized = true;
|
||||||
}
|
}
|
||||||
|
|||||||
@ -56,16 +56,6 @@ SYNCHRONIZATION_MESSAGE,
|
|||||||
rVal = EntityMessage.parseSpawnItemMessage(byteBuffer);
|
rVal = EntityMessage.parseSpawnItemMessage(byteBuffer);
|
||||||
}
|
}
|
||||||
break;
|
break;
|
||||||
case TypeBytes.ENTITY_MESSAGE_TYPE_SETPOSITION:
|
|
||||||
if(EntityMessage.canParseMessage(byteBuffer,secondByte)){
|
|
||||||
rVal = EntityMessage.parseSetPositionMessage(byteBuffer);
|
|
||||||
}
|
|
||||||
break;
|
|
||||||
case TypeBytes.ENTITY_MESSAGE_TYPE_SETFACING:
|
|
||||||
if(EntityMessage.canParseMessage(byteBuffer,secondByte)){
|
|
||||||
rVal = EntityMessage.parsesetFacingMessage(byteBuffer);
|
|
||||||
}
|
|
||||||
break;
|
|
||||||
case TypeBytes.ENTITY_MESSAGE_TYPE_MOVEUPDATE:
|
case TypeBytes.ENTITY_MESSAGE_TYPE_MOVEUPDATE:
|
||||||
if(EntityMessage.canParseMessage(byteBuffer,secondByte)){
|
if(EntityMessage.canParseMessage(byteBuffer,secondByte)){
|
||||||
rVal = EntityMessage.parsemoveUpdateMessage(byteBuffer);
|
rVal = EntityMessage.parsemoveUpdateMessage(byteBuffer);
|
||||||
@ -81,11 +71,6 @@ SYNCHRONIZATION_MESSAGE,
|
|||||||
rVal = EntityMessage.parsestartAttackMessage(byteBuffer);
|
rVal = EntityMessage.parsestartAttackMessage(byteBuffer);
|
||||||
}
|
}
|
||||||
break;
|
break;
|
||||||
case TypeBytes.ENTITY_MESSAGE_TYPE_MOVE:
|
|
||||||
if(EntityMessage.canParseMessage(byteBuffer,secondByte)){
|
|
||||||
rVal = EntityMessage.parseMoveMessage(byteBuffer);
|
|
||||||
}
|
|
||||||
break;
|
|
||||||
case TypeBytes.ENTITY_MESSAGE_TYPE_KILL:
|
case TypeBytes.ENTITY_MESSAGE_TYPE_KILL:
|
||||||
if(EntityMessage.canParseMessage(byteBuffer,secondByte)){
|
if(EntityMessage.canParseMessage(byteBuffer,secondByte)){
|
||||||
rVal = EntityMessage.parseKillMessage(byteBuffer);
|
rVal = EntityMessage.parseKillMessage(byteBuffer);
|
||||||
@ -96,41 +81,11 @@ SYNCHRONIZATION_MESSAGE,
|
|||||||
rVal = EntityMessage.parseDestroyMessage(byteBuffer);
|
rVal = EntityMessage.parseDestroyMessage(byteBuffer);
|
||||||
}
|
}
|
||||||
break;
|
break;
|
||||||
case TypeBytes.ENTITY_MESSAGE_TYPE_SETBEHAVIORTREE:
|
|
||||||
if(EntityMessage.canParseMessage(byteBuffer,secondByte)){
|
|
||||||
rVal = EntityMessage.parseSetBehaviorTreeMessage(byteBuffer);
|
|
||||||
}
|
|
||||||
break;
|
|
||||||
case TypeBytes.ENTITY_MESSAGE_TYPE_SETPROPERTY:
|
case TypeBytes.ENTITY_MESSAGE_TYPE_SETPROPERTY:
|
||||||
if(EntityMessage.canParseMessage(byteBuffer,secondByte)){
|
if(EntityMessage.canParseMessage(byteBuffer,secondByte)){
|
||||||
rVal = EntityMessage.parsesetPropertyMessage(byteBuffer);
|
rVal = EntityMessage.parsesetPropertyMessage(byteBuffer);
|
||||||
}
|
}
|
||||||
break;
|
break;
|
||||||
case TypeBytes.ENTITY_MESSAGE_TYPE_SETBTREEPROPERTYINT:
|
|
||||||
if(EntityMessage.canParseMessage(byteBuffer,secondByte)){
|
|
||||||
rVal = EntityMessage.parsesetBTreePropertyIntMessage(byteBuffer);
|
|
||||||
}
|
|
||||||
break;
|
|
||||||
case TypeBytes.ENTITY_MESSAGE_TYPE_SETBTREEPROPERTYFLOAT:
|
|
||||||
if(EntityMessage.canParseMessage(byteBuffer,secondByte)){
|
|
||||||
rVal = EntityMessage.parsesetBTreePropertyFloatMessage(byteBuffer);
|
|
||||||
}
|
|
||||||
break;
|
|
||||||
case TypeBytes.ENTITY_MESSAGE_TYPE_SETBTREEPROPERTYDOUBLE:
|
|
||||||
if(EntityMessage.canParseMessage(byteBuffer,secondByte)){
|
|
||||||
rVal = EntityMessage.parsesetBTreePropertyDoubleMessage(byteBuffer);
|
|
||||||
}
|
|
||||||
break;
|
|
||||||
case TypeBytes.ENTITY_MESSAGE_TYPE_SETBTREEPROPERTYSTRING:
|
|
||||||
if(EntityMessage.canParseMessage(byteBuffer,secondByte)){
|
|
||||||
rVal = EntityMessage.parsesetBTreePropertyStringMessage(byteBuffer);
|
|
||||||
}
|
|
||||||
break;
|
|
||||||
case TypeBytes.ENTITY_MESSAGE_TYPE_SETBTREEPROPERTYENUM:
|
|
||||||
if(EntityMessage.canParseMessage(byteBuffer,secondByte)){
|
|
||||||
rVal = EntityMessage.parsesetBTreePropertyEnumMessage(byteBuffer);
|
|
||||||
}
|
|
||||||
break;
|
|
||||||
case TypeBytes.ENTITY_MESSAGE_TYPE_ATTACHENTITYTOENTITY:
|
case TypeBytes.ENTITY_MESSAGE_TYPE_ATTACHENTITYTOENTITY:
|
||||||
if(EntityMessage.canParseMessage(byteBuffer,secondByte)){
|
if(EntityMessage.canParseMessage(byteBuffer,secondByte)){
|
||||||
rVal = EntityMessage.parseattachEntityToEntityMessage(byteBuffer);
|
rVal = EntityMessage.parseattachEntityToEntityMessage(byteBuffer);
|
||||||
@ -161,26 +116,6 @@ SYNCHRONIZATION_MESSAGE,
|
|||||||
rVal = LoreMessage.parseResponseRacesMessage(byteBuffer);
|
rVal = LoreMessage.parseResponseRacesMessage(byteBuffer);
|
||||||
}
|
}
|
||||||
break;
|
break;
|
||||||
case TypeBytes.LORE_MESSAGE_TYPE_REQUESTRACEDATA:
|
|
||||||
if(LoreMessage.canParseMessage(byteBuffer,secondByte)){
|
|
||||||
rVal = LoreMessage.parseRequestRaceDataMessage(byteBuffer);
|
|
||||||
}
|
|
||||||
break;
|
|
||||||
case TypeBytes.LORE_MESSAGE_TYPE_RESPONSERACEDATA:
|
|
||||||
if(LoreMessage.canParseMessage(byteBuffer,secondByte)){
|
|
||||||
rVal = LoreMessage.parseResponseRaceDataMessage(byteBuffer);
|
|
||||||
}
|
|
||||||
break;
|
|
||||||
case TypeBytes.LORE_MESSAGE_TYPE_REQUESTDATA:
|
|
||||||
if(LoreMessage.canParseMessage(byteBuffer,secondByte)){
|
|
||||||
rVal = LoreMessage.parseRequestDataMessage(byteBuffer);
|
|
||||||
}
|
|
||||||
break;
|
|
||||||
case TypeBytes.LORE_MESSAGE_TYPE_RESPONSEDATA:
|
|
||||||
if(LoreMessage.canParseMessage(byteBuffer,secondByte)){
|
|
||||||
rVal = LoreMessage.parseResponseDataMessage(byteBuffer);
|
|
||||||
}
|
|
||||||
break;
|
|
||||||
}
|
}
|
||||||
break;
|
break;
|
||||||
case TypeBytes.MESSAGE_TYPE_PLAYER:
|
case TypeBytes.MESSAGE_TYPE_PLAYER:
|
||||||
@ -211,11 +146,6 @@ SYNCHRONIZATION_MESSAGE,
|
|||||||
rVal = TerrainMessage.parseResponseMetadataMessage(byteBuffer);
|
rVal = TerrainMessage.parseResponseMetadataMessage(byteBuffer);
|
||||||
}
|
}
|
||||||
break;
|
break;
|
||||||
case TypeBytes.TERRAIN_MESSAGE_TYPE_REQUESTCHUNK:
|
|
||||||
if(TerrainMessage.canParseMessage(byteBuffer,secondByte)){
|
|
||||||
rVal = TerrainMessage.parseRequestChunkMessage(byteBuffer);
|
|
||||||
}
|
|
||||||
break;
|
|
||||||
case TypeBytes.TERRAIN_MESSAGE_TYPE_REQUESTEDITVOXEL:
|
case TypeBytes.TERRAIN_MESSAGE_TYPE_REQUESTEDITVOXEL:
|
||||||
if(TerrainMessage.canParseMessage(byteBuffer,secondByte)){
|
if(TerrainMessage.canParseMessage(byteBuffer,secondByte)){
|
||||||
rVal = TerrainMessage.parseRequestEditVoxelMessage(byteBuffer);
|
rVal = TerrainMessage.parseRequestEditVoxelMessage(byteBuffer);
|
||||||
|
|||||||
@ -10,7 +10,6 @@ public class TerrainMessage extends NetworkMessage {
|
|||||||
public enum TerrainMessageType {
|
public enum TerrainMessageType {
|
||||||
REQUESTMETADATA,
|
REQUESTMETADATA,
|
||||||
RESPONSEMETADATA,
|
RESPONSEMETADATA,
|
||||||
REQUESTCHUNK,
|
|
||||||
REQUESTEDITVOXEL,
|
REQUESTEDITVOXEL,
|
||||||
UPDATEVOXEL,
|
UPDATEVOXEL,
|
||||||
REQUESTUSETERRAINPALETTE,
|
REQUESTUSETERRAINPALETTE,
|
||||||
@ -231,12 +230,6 @@ public class TerrainMessage extends NetworkMessage {
|
|||||||
} else {
|
} else {
|
||||||
return false;
|
return false;
|
||||||
}
|
}
|
||||||
case TypeBytes.TERRAIN_MESSAGE_TYPE_REQUESTCHUNK:
|
|
||||||
if(byteBuffer.getRemaining() >= TypeBytes.TERRAIN_MESSAGE_TYPE_REQUESTCHUNK_SIZE){
|
|
||||||
return true;
|
|
||||||
} else {
|
|
||||||
return false;
|
|
||||||
}
|
|
||||||
case TypeBytes.TERRAIN_MESSAGE_TYPE_REQUESTEDITVOXEL:
|
case TypeBytes.TERRAIN_MESSAGE_TYPE_REQUESTEDITVOXEL:
|
||||||
if(byteBuffer.getRemaining() >= TypeBytes.TERRAIN_MESSAGE_TYPE_REQUESTEDITVOXEL_SIZE){
|
if(byteBuffer.getRemaining() >= TypeBytes.TERRAIN_MESSAGE_TYPE_REQUESTEDITVOXEL_SIZE){
|
||||||
return true;
|
return true;
|
||||||
@ -321,22 +314,6 @@ public class TerrainMessage extends NetworkMessage {
|
|||||||
return rVal;
|
return rVal;
|
||||||
}
|
}
|
||||||
|
|
||||||
public static TerrainMessage parseRequestChunkMessage(CircularByteBuffer byteBuffer){
|
|
||||||
TerrainMessage rVal = new TerrainMessage(TerrainMessageType.REQUESTCHUNK);
|
|
||||||
stripPacketHeader(byteBuffer);
|
|
||||||
rVal.setworldX(ByteStreamUtils.popIntFromByteQueue(byteBuffer));
|
|
||||||
rVal.setworldY(ByteStreamUtils.popIntFromByteQueue(byteBuffer));
|
|
||||||
return rVal;
|
|
||||||
}
|
|
||||||
|
|
||||||
public static TerrainMessage constructRequestChunkMessage(int worldX,int worldY){
|
|
||||||
TerrainMessage rVal = new TerrainMessage(TerrainMessageType.REQUESTCHUNK);
|
|
||||||
rVal.setworldX(worldX);
|
|
||||||
rVal.setworldY(worldY);
|
|
||||||
rVal.serialize();
|
|
||||||
return rVal;
|
|
||||||
}
|
|
||||||
|
|
||||||
public static TerrainMessage parseRequestEditVoxelMessage(CircularByteBuffer byteBuffer){
|
public static TerrainMessage parseRequestEditVoxelMessage(CircularByteBuffer byteBuffer){
|
||||||
TerrainMessage rVal = new TerrainMessage(TerrainMessageType.REQUESTEDITVOXEL);
|
TerrainMessage rVal = new TerrainMessage(TerrainMessageType.REQUESTEDITVOXEL);
|
||||||
stripPacketHeader(byteBuffer);
|
stripPacketHeader(byteBuffer);
|
||||||
@ -661,21 +638,6 @@ public class TerrainMessage extends NetworkMessage {
|
|||||||
rawBytes[26+i] = intValues[i];
|
rawBytes[26+i] = intValues[i];
|
||||||
}
|
}
|
||||||
break;
|
break;
|
||||||
case REQUESTCHUNK:
|
|
||||||
rawBytes = new byte[2+4+4];
|
|
||||||
//message header
|
|
||||||
rawBytes[0] = TypeBytes.MESSAGE_TYPE_TERRAIN;
|
|
||||||
//entity messaage header
|
|
||||||
rawBytes[1] = TypeBytes.TERRAIN_MESSAGE_TYPE_REQUESTCHUNK;
|
|
||||||
intValues = ByteStreamUtils.serializeIntToBytes(worldX);
|
|
||||||
for(int i = 0; i < 4; i++){
|
|
||||||
rawBytes[2+i] = intValues[i];
|
|
||||||
}
|
|
||||||
intValues = ByteStreamUtils.serializeIntToBytes(worldY);
|
|
||||||
for(int i = 0; i < 4; i++){
|
|
||||||
rawBytes[6+i] = intValues[i];
|
|
||||||
}
|
|
||||||
break;
|
|
||||||
case REQUESTEDITVOXEL:
|
case REQUESTEDITVOXEL:
|
||||||
rawBytes = new byte[2+4+4+4+4+4+4+4+4];
|
rawBytes = new byte[2+4+4+4+4+4+4+4+4];
|
||||||
//message header
|
//message header
|
||||||
|
|||||||
@ -20,56 +20,34 @@ Message categories
|
|||||||
public static final byte ENTITY_MESSAGE_TYPE_CREATE = 0;
|
public static final byte ENTITY_MESSAGE_TYPE_CREATE = 0;
|
||||||
public static final byte ENTITY_MESSAGE_TYPE_SPAWNCREATURE = 1;
|
public static final byte ENTITY_MESSAGE_TYPE_SPAWNCREATURE = 1;
|
||||||
public static final byte ENTITY_MESSAGE_TYPE_SPAWNITEM = 2;
|
public static final byte ENTITY_MESSAGE_TYPE_SPAWNITEM = 2;
|
||||||
public static final byte ENTITY_MESSAGE_TYPE_SETPOSITION = 3;
|
public static final byte ENTITY_MESSAGE_TYPE_MOVEUPDATE = 3;
|
||||||
public static final byte ENTITY_MESSAGE_TYPE_SETFACING = 4;
|
public static final byte ENTITY_MESSAGE_TYPE_ATTACKUPDATE = 4;
|
||||||
public static final byte ENTITY_MESSAGE_TYPE_MOVEUPDATE = 5;
|
public static final byte ENTITY_MESSAGE_TYPE_STARTATTACK = 5;
|
||||||
public static final byte ENTITY_MESSAGE_TYPE_ATTACKUPDATE = 6;
|
public static final byte ENTITY_MESSAGE_TYPE_KILL = 6;
|
||||||
public static final byte ENTITY_MESSAGE_TYPE_STARTATTACK = 7;
|
public static final byte ENTITY_MESSAGE_TYPE_DESTROY = 7;
|
||||||
public static final byte ENTITY_MESSAGE_TYPE_MOVE = 8;
|
public static final byte ENTITY_MESSAGE_TYPE_SETPROPERTY = 8;
|
||||||
public static final byte ENTITY_MESSAGE_TYPE_KILL = 9;
|
public static final byte ENTITY_MESSAGE_TYPE_ATTACHENTITYTOENTITY = 9;
|
||||||
public static final byte ENTITY_MESSAGE_TYPE_DESTROY = 10;
|
public static final byte ENTITY_MESSAGE_TYPE_SPAWNFOLIAGESEED = 10;
|
||||||
public static final byte ENTITY_MESSAGE_TYPE_SETBEHAVIORTREE = 11;
|
public static final byte ENTITY_MESSAGE_TYPE_UPDATEENTITYVIEWDIR = 11;
|
||||||
public static final byte ENTITY_MESSAGE_TYPE_SETPROPERTY = 12;
|
|
||||||
public static final byte ENTITY_MESSAGE_TYPE_SETBTREEPROPERTYINT = 13;
|
|
||||||
public static final byte ENTITY_MESSAGE_TYPE_SETBTREEPROPERTYFLOAT = 14;
|
|
||||||
public static final byte ENTITY_MESSAGE_TYPE_SETBTREEPROPERTYDOUBLE = 15;
|
|
||||||
public static final byte ENTITY_MESSAGE_TYPE_SETBTREEPROPERTYSTRING = 16;
|
|
||||||
public static final byte ENTITY_MESSAGE_TYPE_SETBTREEPROPERTYENUM = 17;
|
|
||||||
public static final byte ENTITY_MESSAGE_TYPE_ATTACHENTITYTOENTITY = 18;
|
|
||||||
public static final byte ENTITY_MESSAGE_TYPE_SPAWNFOLIAGESEED = 19;
|
|
||||||
public static final byte ENTITY_MESSAGE_TYPE_UPDATEENTITYVIEWDIR = 20;
|
|
||||||
/*
|
/*
|
||||||
Entity packet sizes
|
Entity packet sizes
|
||||||
*/
|
*/
|
||||||
public static final byte ENTITY_MESSAGE_TYPE_SETPOSITION_SIZE = 38;
|
public static final byte ENTITY_MESSAGE_TYPE_MOVEUPDATE_SIZE = 86;
|
||||||
public static final byte ENTITY_MESSAGE_TYPE_SETFACING_SIZE = 38;
|
|
||||||
public static final byte ENTITY_MESSAGE_TYPE_MOVEUPDATE_SIZE = 82;
|
|
||||||
public static final byte ENTITY_MESSAGE_TYPE_ATTACKUPDATE_SIZE = 74;
|
public static final byte ENTITY_MESSAGE_TYPE_ATTACKUPDATE_SIZE = 74;
|
||||||
public static final byte ENTITY_MESSAGE_TYPE_STARTATTACK_SIZE = 2;
|
public static final byte ENTITY_MESSAGE_TYPE_STARTATTACK_SIZE = 2;
|
||||||
public static final byte ENTITY_MESSAGE_TYPE_MOVE_SIZE = 38;
|
|
||||||
public static final byte ENTITY_MESSAGE_TYPE_KILL_SIZE = 14;
|
public static final byte ENTITY_MESSAGE_TYPE_KILL_SIZE = 14;
|
||||||
public static final byte ENTITY_MESSAGE_TYPE_DESTROY_SIZE = 6;
|
public static final byte ENTITY_MESSAGE_TYPE_DESTROY_SIZE = 6;
|
||||||
public static final byte ENTITY_MESSAGE_TYPE_SETBEHAVIORTREE_SIZE = 22;
|
|
||||||
public static final byte ENTITY_MESSAGE_TYPE_SETPROPERTY_SIZE = 22;
|
public static final byte ENTITY_MESSAGE_TYPE_SETPROPERTY_SIZE = 22;
|
||||||
public static final byte ENTITY_MESSAGE_TYPE_SETBTREEPROPERTYINT_SIZE = 26;
|
|
||||||
public static final byte ENTITY_MESSAGE_TYPE_SETBTREEPROPERTYFLOAT_SIZE = 26;
|
|
||||||
public static final byte ENTITY_MESSAGE_TYPE_SETBTREEPROPERTYDOUBLE_SIZE = 30;
|
|
||||||
public static final byte ENTITY_MESSAGE_TYPE_SETBTREEPROPERTYENUM_SIZE = 26;
|
|
||||||
public static final byte ENTITY_MESSAGE_TYPE_UPDATEENTITYVIEWDIR_SIZE = 38;
|
public static final byte ENTITY_MESSAGE_TYPE_UPDATEENTITYVIEWDIR_SIZE = 38;
|
||||||
/*
|
/*
|
||||||
Lore subcategories
|
Lore subcategories
|
||||||
*/
|
*/
|
||||||
public static final byte LORE_MESSAGE_TYPE_REQUESTRACES = 0;
|
public static final byte LORE_MESSAGE_TYPE_REQUESTRACES = 0;
|
||||||
public static final byte LORE_MESSAGE_TYPE_RESPONSERACES = 1;
|
public static final byte LORE_MESSAGE_TYPE_RESPONSERACES = 1;
|
||||||
public static final byte LORE_MESSAGE_TYPE_REQUESTRACEDATA = 2;
|
|
||||||
public static final byte LORE_MESSAGE_TYPE_RESPONSERACEDATA = 3;
|
|
||||||
public static final byte LORE_MESSAGE_TYPE_REQUESTDATA = 4;
|
|
||||||
public static final byte LORE_MESSAGE_TYPE_RESPONSEDATA = 5;
|
|
||||||
/*
|
/*
|
||||||
Lore packet sizes
|
Lore packet sizes
|
||||||
*/
|
*/
|
||||||
public static final byte LORE_MESSAGE_TYPE_REQUESTRACES_SIZE = 2;
|
public static final byte LORE_MESSAGE_TYPE_REQUESTRACES_SIZE = 2;
|
||||||
public static final byte LORE_MESSAGE_TYPE_REQUESTRACEDATA_SIZE = 2;
|
|
||||||
/*
|
/*
|
||||||
Player subcategories
|
Player subcategories
|
||||||
*/
|
*/
|
||||||
@ -85,22 +63,20 @@ Message categories
|
|||||||
*/
|
*/
|
||||||
public static final byte TERRAIN_MESSAGE_TYPE_REQUESTMETADATA = 0;
|
public static final byte TERRAIN_MESSAGE_TYPE_REQUESTMETADATA = 0;
|
||||||
public static final byte TERRAIN_MESSAGE_TYPE_RESPONSEMETADATA = 1;
|
public static final byte TERRAIN_MESSAGE_TYPE_RESPONSEMETADATA = 1;
|
||||||
public static final byte TERRAIN_MESSAGE_TYPE_REQUESTCHUNK = 2;
|
public static final byte TERRAIN_MESSAGE_TYPE_REQUESTEDITVOXEL = 2;
|
||||||
public static final byte TERRAIN_MESSAGE_TYPE_REQUESTEDITVOXEL = 3;
|
public static final byte TERRAIN_MESSAGE_TYPE_UPDATEVOXEL = 3;
|
||||||
public static final byte TERRAIN_MESSAGE_TYPE_UPDATEVOXEL = 4;
|
public static final byte TERRAIN_MESSAGE_TYPE_REQUESTUSETERRAINPALETTE = 4;
|
||||||
public static final byte TERRAIN_MESSAGE_TYPE_REQUESTUSETERRAINPALETTE = 5;
|
public static final byte TERRAIN_MESSAGE_TYPE_SPAWNPOSITION = 5;
|
||||||
public static final byte TERRAIN_MESSAGE_TYPE_SPAWNPOSITION = 6;
|
public static final byte TERRAIN_MESSAGE_TYPE_REQUESTCHUNKDATA = 6;
|
||||||
public static final byte TERRAIN_MESSAGE_TYPE_REQUESTCHUNKDATA = 7;
|
public static final byte TERRAIN_MESSAGE_TYPE_SENDCHUNKDATA = 7;
|
||||||
public static final byte TERRAIN_MESSAGE_TYPE_SENDCHUNKDATA = 8;
|
public static final byte TERRAIN_MESSAGE_TYPE_REQUESTFLUIDDATA = 8;
|
||||||
public static final byte TERRAIN_MESSAGE_TYPE_REQUESTFLUIDDATA = 9;
|
public static final byte TERRAIN_MESSAGE_TYPE_SENDFLUIDDATA = 9;
|
||||||
public static final byte TERRAIN_MESSAGE_TYPE_SENDFLUIDDATA = 10;
|
public static final byte TERRAIN_MESSAGE_TYPE_UPDATEFLUIDDATA = 10;
|
||||||
public static final byte TERRAIN_MESSAGE_TYPE_UPDATEFLUIDDATA = 11;
|
|
||||||
/*
|
/*
|
||||||
Terrain packet sizes
|
Terrain packet sizes
|
||||||
*/
|
*/
|
||||||
public static final byte TERRAIN_MESSAGE_TYPE_REQUESTMETADATA_SIZE = 2;
|
public static final byte TERRAIN_MESSAGE_TYPE_REQUESTMETADATA_SIZE = 2;
|
||||||
public static final byte TERRAIN_MESSAGE_TYPE_RESPONSEMETADATA_SIZE = 30;
|
public static final byte TERRAIN_MESSAGE_TYPE_RESPONSEMETADATA_SIZE = 30;
|
||||||
public static final byte TERRAIN_MESSAGE_TYPE_REQUESTCHUNK_SIZE = 10;
|
|
||||||
public static final byte TERRAIN_MESSAGE_TYPE_REQUESTEDITVOXEL_SIZE = 34;
|
public static final byte TERRAIN_MESSAGE_TYPE_REQUESTEDITVOXEL_SIZE = 34;
|
||||||
public static final byte TERRAIN_MESSAGE_TYPE_UPDATEVOXEL_SIZE = 34;
|
public static final byte TERRAIN_MESSAGE_TYPE_UPDATEVOXEL_SIZE = 34;
|
||||||
public static final byte TERRAIN_MESSAGE_TYPE_REQUESTUSETERRAINPALETTE_SIZE = 38;
|
public static final byte TERRAIN_MESSAGE_TYPE_REQUESTUSETERRAINPALETTE_SIZE = 38;
|
||||||
|
|||||||
@ -15,14 +15,6 @@ public class EntityProtocol {
|
|||||||
protected static void handleEntityMessage(ServerConnectionHandler connectionHandler, EntityMessage message){
|
protected static void handleEntityMessage(ServerConnectionHandler connectionHandler, EntityMessage message){
|
||||||
Entity targetEntity;
|
Entity targetEntity;
|
||||||
switch(message.getMessageSubtype()){
|
switch(message.getMessageSubtype()){
|
||||||
case MOVE:
|
|
||||||
targetEntity = EntityLookupUtils.getEntityById(message.getentityID());
|
|
||||||
if(targetEntity != null){
|
|
||||||
CreatureUtils.serverAttachEntityMessageToMovementTree(targetEntity,message);
|
|
||||||
}
|
|
||||||
break;
|
|
||||||
case SETBEHAVIORTREE:
|
|
||||||
break;
|
|
||||||
case MOVEUPDATE:
|
case MOVEUPDATE:
|
||||||
targetEntity = EntityLookupUtils.getEntityById(message.getentityID());
|
targetEntity = EntityLookupUtils.getEntityById(message.getentityID());
|
||||||
if(targetEntity != null){
|
if(targetEntity != null){
|
||||||
@ -53,14 +45,7 @@ public class EntityProtocol {
|
|||||||
case DESTROY:
|
case DESTROY:
|
||||||
case CREATE:
|
case CREATE:
|
||||||
case ATTACHENTITYTOENTITY:
|
case ATTACHENTITYTOENTITY:
|
||||||
case SETFACING:
|
|
||||||
case SETPOSITION:
|
|
||||||
case SETPROPERTY:
|
case SETPROPERTY:
|
||||||
case SETBTREEPROPERTYDOUBLE:
|
|
||||||
case SETBTREEPROPERTYENUM:
|
|
||||||
case SETBTREEPROPERTYFLOAT:
|
|
||||||
case SETBTREEPROPERTYINT:
|
|
||||||
case SETBTREEPROPERTYSTRING:
|
|
||||||
case SPAWNFOLIAGESEED:
|
case SPAWNFOLIAGESEED:
|
||||||
case SPAWNITEM:
|
case SPAWNITEM:
|
||||||
//silently ignore
|
//silently ignore
|
||||||
|
|||||||
@ -11,21 +11,13 @@ public class LoreProtocol {
|
|||||||
|
|
||||||
protected static void handleLoreMessage(ServerConnectionHandler connectionHandler, LoreMessage message){
|
protected static void handleLoreMessage(ServerConnectionHandler connectionHandler, LoreMessage message){
|
||||||
switch(message.getMessageSubtype()){
|
switch(message.getMessageSubtype()){
|
||||||
case REQUESTDATA:
|
|
||||||
//TODO
|
|
||||||
break;
|
|
||||||
case REQUESTRACEDATA:
|
|
||||||
//TODO
|
|
||||||
break;
|
|
||||||
case REQUESTRACES:
|
case REQUESTRACES:
|
||||||
List<String> playableRaces = Globals.gameConfigCurrent.getCreatureTypeLoader().getPlayableRaces();
|
List<String> playableRaces = Globals.gameConfigCurrent.getCreatureTypeLoader().getPlayableRaces();
|
||||||
String returnData = Utilities.stringify(playableRaces);
|
String returnData = Utilities.stringify(playableRaces);
|
||||||
connectionHandler.addMessagetoOutgoingQueue(LoreMessage.constructResponseRacesMessage(returnData));
|
connectionHandler.addMessagetoOutgoingQueue(LoreMessage.constructResponseRacesMessage(returnData));
|
||||||
break;
|
break;
|
||||||
|
|
||||||
case RESPONSEDATA:
|
|
||||||
case RESPONSERACES:
|
case RESPONSERACES:
|
||||||
case RESPONSERACEDATA:
|
|
||||||
//silently ignore
|
//silently ignore
|
||||||
break;
|
break;
|
||||||
}
|
}
|
||||||
|
|||||||
@ -22,9 +22,6 @@ public class TerrainProtocol {
|
|||||||
|
|
||||||
protected static void handleTerrainMessage(ServerConnectionHandler connectionHandler, TerrainMessage message){
|
protected static void handleTerrainMessage(ServerConnectionHandler connectionHandler, TerrainMessage message){
|
||||||
switch(message.getMessageSubtype()){
|
switch(message.getMessageSubtype()){
|
||||||
case REQUESTCHUNK:
|
|
||||||
// sendWorldChunk(connectionHandler, message.getworldX(), message.getworldY());
|
|
||||||
break;
|
|
||||||
case REQUESTMETADATA:
|
case REQUESTMETADATA:
|
||||||
sendWorldMetadata(connectionHandler);
|
sendWorldMetadata(connectionHandler);
|
||||||
break;
|
break;
|
||||||
|
|||||||
@ -1,6 +1,12 @@
|
|||||||
package electrosphere.net.synchronization;
|
package electrosphere.net.synchronization;
|
||||||
|
|
||||||
|
|
||||||
|
import electrosphere.entity.state.movement.groundmove.ClientGroundMovementTree;
|
||||||
|
|
||||||
|
import electrosphere.entity.state.movement.groundmove.ServerGroundMovementTree;
|
||||||
|
|
||||||
|
import electrosphere.entity.state.equip.ClientEquipState;
|
||||||
|
|
||||||
import electrosphere.entity.state.attack.ClientAttackTree;
|
import electrosphere.entity.state.attack.ClientAttackTree;
|
||||||
import electrosphere.entity.state.attack.ServerAttackTree;
|
import electrosphere.entity.state.attack.ServerAttackTree;
|
||||||
|
|
||||||
@ -122,6 +128,14 @@ public class ClientSynchronizationManager {
|
|||||||
} break;
|
} break;
|
||||||
}
|
}
|
||||||
} break;
|
} break;
|
||||||
|
case BehaviorTreeIdEnums.BTREE_SERVERGROUNDMOVEMENTTREE_ID: {
|
||||||
|
switch(message.getfieldId()){
|
||||||
|
case 11:{
|
||||||
|
ClientGroundMovementTree tree = ClientGroundMovementTree.getClientGroundMovementTree(entity);
|
||||||
|
tree.setFacing(ClientGroundMovementTree.getMovementRelativeFacingShortAsEnum((short)message.getbTreeValue()));
|
||||||
|
} break;
|
||||||
|
}
|
||||||
|
} break;
|
||||||
|
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|||||||
@ -2,7 +2,6 @@ package electrosphere.server.datacell;
|
|||||||
|
|
||||||
import java.util.HashMap;
|
import java.util.HashMap;
|
||||||
import java.util.HashSet;
|
import java.util.HashSet;
|
||||||
import java.util.List;
|
|
||||||
import java.util.Map;
|
import java.util.Map;
|
||||||
import java.util.Set;
|
import java.util.Set;
|
||||||
import java.util.concurrent.CopyOnWriteArraySet;
|
import java.util.concurrent.CopyOnWriteArraySet;
|
||||||
@ -25,7 +24,6 @@ import electrosphere.server.datacell.interfaces.VoxelCellManager;
|
|||||||
import electrosphere.server.datacell.physics.PhysicsDataCell;
|
import electrosphere.server.datacell.physics.PhysicsDataCell;
|
||||||
import electrosphere.server.fluid.manager.ServerFluidChunk;
|
import electrosphere.server.fluid.manager.ServerFluidChunk;
|
||||||
import electrosphere.server.fluid.manager.ServerFluidManager;
|
import electrosphere.server.fluid.manager.ServerFluidManager;
|
||||||
import electrosphere.server.saves.SaveUtils;
|
|
||||||
import electrosphere.server.terrain.manager.ServerTerrainManager;
|
import electrosphere.server.terrain.manager.ServerTerrainManager;
|
||||||
import electrosphere.server.terrain.manager.ServerTerrainChunk;
|
import electrosphere.server.terrain.manager.ServerTerrainChunk;
|
||||||
|
|
||||||
@ -132,8 +130,8 @@ public class GriddedDataCellManager implements DataCellManager, VoxelCellManager
|
|||||||
Vector3i oldPosition = player.getWorldPos();
|
Vector3i oldPosition = player.getWorldPos();
|
||||||
player.setWorldPos(newPosition);
|
player.setWorldPos(newPosition);
|
||||||
// System.out.println("=======" + "SET" + newX + " " + newY + " FROM " + oldX + " " + oldY + "========");
|
// System.out.println("=======" + "SET" + newX + " " + newY + " FROM " + oldX + " " + oldY + "========");
|
||||||
int removals = 0;
|
// int removals = 0;
|
||||||
int additions = 0;
|
// int additions = 0;
|
||||||
for(int x = oldPosition.x - playerSimulationRadius; x < oldPosition.x + playerSimulationRadius + 1; x++){
|
for(int x = oldPosition.x - playerSimulationRadius; x < oldPosition.x + playerSimulationRadius + 1; x++){
|
||||||
for(int y = oldPosition.y - playerSimulationRadius; y < oldPosition.y + playerSimulationRadius + 1; y++){
|
for(int y = oldPosition.y - playerSimulationRadius; y < oldPosition.y + playerSimulationRadius + 1; y++){
|
||||||
for(int z = oldPosition.z - playerSimulationRadius; z < oldPosition.z + playerSimulationRadius + 1; z++){
|
for(int z = oldPosition.z - playerSimulationRadius; z < oldPosition.z + playerSimulationRadius + 1; z++){
|
||||||
@ -357,7 +355,7 @@ public class GriddedDataCellManager implements DataCellManager, VoxelCellManager
|
|||||||
public void simulate(){
|
public void simulate(){
|
||||||
loadedCellsLock.acquireUninterruptibly();
|
loadedCellsLock.acquireUninterruptibly();
|
||||||
for(ServerDataCell cell : loadedCells){
|
for(ServerDataCell cell : loadedCells){
|
||||||
Globals.microSimulation.simulate(cell, parent.getHitboxManager());
|
Globals.microSimulation.simulate(cell);
|
||||||
|
|
||||||
//simulate fluid
|
//simulate fluid
|
||||||
Vector3i cellPos = this.getCellWorldPosition(cell);
|
Vector3i cellPos = this.getCellWorldPosition(cell);
|
||||||
|
|||||||
@ -18,7 +18,6 @@ import electrosphere.entity.types.attach.AttachUtils;
|
|||||||
import electrosphere.entity.types.creature.CreatureUtils;
|
import electrosphere.entity.types.creature.CreatureUtils;
|
||||||
import electrosphere.entity.types.item.ItemUtils;
|
import electrosphere.entity.types.item.ItemUtils;
|
||||||
import electrosphere.server.datacell.Realm;
|
import electrosphere.server.datacell.Realm;
|
||||||
import electrosphere.server.datacell.utils.DataCellSearchUtils;
|
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* Callback for managing collisions on the server
|
* Callback for managing collisions on the server
|
||||||
@ -42,8 +41,6 @@ public class ServerHitboxResolutionCallback implements CollisionResolutionCallba
|
|||||||
boolean isDamageEvent =
|
boolean isDamageEvent =
|
||||||
impactorShapeStatus != null &&
|
impactorShapeStatus != null &&
|
||||||
receiverShapeStatus != null &&
|
receiverShapeStatus != null &&
|
||||||
impactorShapeStatus.isActive() &&
|
|
||||||
receiverShapeStatus.isActive() &&
|
|
||||||
impactorShapeStatus.getType() == HitboxType.HIT &&
|
impactorShapeStatus.getType() == HitboxType.HIT &&
|
||||||
receiverShapeStatus.getType() == HitboxType.HURT &&
|
receiverShapeStatus.getType() == HitboxType.HURT &&
|
||||||
AttachUtils.getParent(impactorParent) != receiverParent
|
AttachUtils.getParent(impactorParent) != receiverParent
|
||||||
|
|||||||
@ -1,7 +1,6 @@
|
|||||||
package electrosphere.server.datacell.utils;
|
package electrosphere.server.datacell.utils;
|
||||||
|
|
||||||
import electrosphere.entity.Entity;
|
import electrosphere.entity.Entity;
|
||||||
import electrosphere.logger.LoggerInterface;
|
|
||||||
import electrosphere.server.datacell.ServerDataCell;
|
import electrosphere.server.datacell.ServerDataCell;
|
||||||
|
|
||||||
/**
|
/**
|
||||||
|
|||||||
@ -1,7 +1,9 @@
|
|||||||
package electrosphere.server.simulation;
|
package electrosphere.server.simulation;
|
||||||
|
|
||||||
import electrosphere.entity.types.attach.AttachUtils;
|
import electrosphere.entity.types.attach.AttachUtils;
|
||||||
import electrosphere.collision.hitbox.HitboxManager;
|
|
||||||
|
import java.util.Set;
|
||||||
|
|
||||||
import electrosphere.engine.Globals;
|
import electrosphere.engine.Globals;
|
||||||
import electrosphere.engine.Main;
|
import electrosphere.engine.Main;
|
||||||
import electrosphere.entity.Entity;
|
import electrosphere.entity.Entity;
|
||||||
@ -10,8 +12,8 @@ import electrosphere.entity.EntityUtils;
|
|||||||
import electrosphere.entity.state.collidable.ServerCollidableTree;
|
import electrosphere.entity.state.collidable.ServerCollidableTree;
|
||||||
import electrosphere.entity.types.item.ItemUtils;
|
import electrosphere.entity.types.item.ItemUtils;
|
||||||
import electrosphere.entity.types.particle.ParticleUtils;
|
import electrosphere.entity.types.particle.ParticleUtils;
|
||||||
import electrosphere.renderer.actor.Actor;
|
|
||||||
import electrosphere.server.datacell.ServerDataCell;
|
import electrosphere.server.datacell.ServerDataCell;
|
||||||
|
import electrosphere.server.poseactor.PoseActor;
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* Server-side micro-scale simulation
|
* Server-side micro-scale simulation
|
||||||
@ -24,31 +26,29 @@ public class MicroSimulation {
|
|||||||
isReady = false;
|
isReady = false;
|
||||||
}
|
}
|
||||||
|
|
||||||
public void simulate(ServerDataCell dataCell, HitboxManager hitboxManager){
|
/**
|
||||||
|
* Simulates a provided data cell
|
||||||
|
* @param dataCell The data cell
|
||||||
|
*/
|
||||||
|
public void simulate(ServerDataCell dataCell){
|
||||||
if(dataCell.isReady()){
|
if(dataCell.isReady()){
|
||||||
//simulate ai
|
//simulate ai
|
||||||
Globals.aiManager.simulate();
|
Globals.aiManager.simulate();
|
||||||
//update actor animations
|
//update actor animations
|
||||||
for(Entity currentEntity : dataCell.getScene().getEntitiesWithTag(EntityTags.DRAWABLE)){
|
Set<Entity> poseableEntities = dataCell.getScene().getEntitiesWithTag(EntityTags.POSEABLE);
|
||||||
//fetch actor
|
if(poseableEntities != null){
|
||||||
Actor currentActor = EntityUtils.getActor(currentEntity);
|
for(Entity currentEntity : dataCell.getScene().getEntitiesWithTag(EntityTags.POSEABLE)){
|
||||||
//increment animations
|
//fetch actor
|
||||||
if(currentActor.isPlayingAnimation()){
|
PoseActor currentPoseActor = EntityUtils.getPoseActor(currentEntity);
|
||||||
currentActor.incrementAnimationTime(Globals.timekeeper.getSimFrameTime() / Main.targetFrameRate);
|
//increment animations
|
||||||
}
|
if(currentPoseActor.isPlayingAnimation()){
|
||||||
}
|
currentPoseActor.incrementAnimationTime(Globals.timekeeper.getSimFrameTime() / Main.targetFrameRate);
|
||||||
//update first person model animations
|
}
|
||||||
if(Globals.firstPersonEntity != null){
|
|
||||||
//fetch actor
|
|
||||||
Actor currentActor = EntityUtils.getActor(Globals.firstPersonEntity);
|
|
||||||
//increment animations
|
|
||||||
if(currentActor.isPlayingAnimation()){
|
|
||||||
currentActor.incrementAnimationTime(Globals.timekeeper.getSimFrameTime() / Main.targetFrameRate);
|
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
//make items play idle animation
|
//make items play idle animation
|
||||||
for(Entity item : dataCell.getScene().getEntitiesWithTag(EntityTags.ITEM)){
|
for(Entity item : dataCell.getScene().getEntitiesWithTag(EntityTags.ITEM)){
|
||||||
ItemUtils.updateItemActorAnimation(item);
|
ItemUtils.updateItemPoseActorAnimation(item);
|
||||||
}
|
}
|
||||||
//particle state updates
|
//particle state updates
|
||||||
for(Entity particle : dataCell.getScene().getEntitiesWithTag(EntityTags.PARTICLE)){
|
for(Entity particle : dataCell.getScene().getEntitiesWithTag(EntityTags.PARTICLE)){
|
||||||
@ -58,9 +58,6 @@ public class MicroSimulation {
|
|||||||
}
|
}
|
||||||
//update attached entity positions
|
//update attached entity positions
|
||||||
AttachUtils.serverUpdateAttachedEntityPositions(dataCell);
|
AttachUtils.serverUpdateAttachedEntityPositions(dataCell);
|
||||||
//
|
|
||||||
//hitbox updates
|
|
||||||
hitboxManager.simulate();
|
|
||||||
//simulate behavior trees
|
//simulate behavior trees
|
||||||
dataCell.getScene().simulateBehaviorTrees((float)Globals.timekeeper.getSimFrameTime());
|
dataCell.getScene().simulateBehaviorTrees((float)Globals.timekeeper.getSimFrameTime());
|
||||||
//sum collidable impulses
|
//sum collidable impulses
|
||||||
|
|||||||
Loading…
Reference in New Issue
Block a user