Fix issue in Rocket.lua script.
[cafu-Engine.git] / Ca3DE / PlayerCommand.hpp
blobba1e0b8cd60cc7ed58ff49eee387ad5b6e2ce331
1 /*
2 Cafu Engine, http://www.cafu.de/
3 Copyright (c) Carsten Fuchs and other contributors.
4 This project is licensed under the terms of the MIT license.
5 */
7 #ifndef CAFU_PLAYERCOMMAND_HPP_INCLUDED
8 #define CAFU_PLAYERCOMMAND_HPP_INCLUDED
10 #if defined(_WIN32) && _MSC_VER<1600
11 #include "pstdint.h" // Paul Hsieh's portable implementation of the stdint.h header.
12 #else
13 #include <stdint.h>
14 #endif
17 // Player command key flags
18 const uint32_t PCK_MoveForward = 0x00000001;
19 const uint32_t PCK_MoveBackward = 0x00000002;
20 const uint32_t PCK_TurnLeft = 0x00000004;
21 const uint32_t PCK_TurnRight = 0x00000008;
22 const uint32_t PCK_StrafeLeft = 0x00000010;
23 const uint32_t PCK_StrafeRight = 0x00000020;
24 const uint32_t PCK_LookUp = 0x00000040;
25 const uint32_t PCK_LookDown = 0x00000080;
26 const uint32_t PCK_CenterView = 0x00000100;
27 const uint32_t PCK_Jump = 0x00000200;
28 const uint32_t PCK_Duck = 0x00000400;
29 const uint32_t PCK_Walk = 0x00000800; // Walk (slower than normal)
30 const uint32_t PCK_Fire1 = 0x00001000; // Primary Fire (also used e.g. for "Respawn")
31 const uint32_t PCK_Fire2 = 0x00002000; // Secondary Fire
32 const uint32_t PCK_Use = 0x00004000; // for "using" or "activating" things
33 // Bits 28-31 are reserved for storing a number, e.g. for selecting the weapon slot.
34 // Only one such number can be active at any time.
37 /// This struct represents per-frame player inputs for controlling human player entities.
38 /// Player commands are acquired on the clients and sent to the server.
39 struct PlayerCommandT
41 PlayerCommandT(uint32_t Keys_=0)
42 : FrameTime(0.0f),
43 Keys(Keys_),
44 DeltaHeading(0),
45 DeltaPitch(0),
46 DeltaBank(0)
50 bool IsDown(uint32_t Key) const
52 return (Keys & Key) != 0;
55 void Set(uint32_t Key, bool set)
57 if (set)
59 Keys |= Key;
61 else
63 Keys &= ~Key;
67 void SetNumber(uint32_t n)
69 Keys &= 0x0FFFFFFF;
70 Keys |= (n << 28);
73 float FrameTime;
74 uint32_t Keys;
75 uint16_t DeltaHeading;
76 uint16_t DeltaPitch;
77 uint16_t DeltaBank;
80 #endif