Advertisement
Guest User

Untitled

a guest
Sep 29th, 2016
114
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
C++ 6.94 KB | None | 0 0
  1. struct PlayerData: public ShapeBaseData {
  2.    typedef ShapeBaseData Parent;
  3.    enum Constants {
  4.       RecoverDelayBits = 7,
  5.       JumpDelayBits = 7,
  6.       NumSpineNodes = 6,
  7.       ImpactBits = 3,
  8.       NUM_SPLASH_EMITTERS = 3,
  9.       BUBBLE_EMITTER = 2,
  10.    };
  11.    bool renderFirstPerson;    ///< Render the player shape in first person
  12.  
  13.    F32 pickupRadius;          ///< Radius around player for items (on server)
  14.    F32 maxTimeScale;          ///< Max timeScale for action animations
  15.  
  16.    F32 minLookAngle;          ///< Lowest angle (radians) the player can look
  17.    F32 maxLookAngle;          ///< Highest angle (radians) the player can look
  18.    F32 maxFreelookAngle;      ///< Max left/right angle the player can look
  19.  
  20.    /// @name Physics constants
  21.    /// @{
  22.  
  23.    F32 runForce;                   ///< Force used to accelerate player
  24.    F32 runEnergyDrain;             ///< Energy drain/tick
  25.    F32 minRunEnergy;               ///< Minimum energy required to run
  26.    F32 maxForwardSpeed;            ///< Maximum forward speed when running
  27.    F32 maxBackwardSpeed;           ///< Maximum backward speed when running
  28.    F32 maxSideSpeed;               ///< Maximum side speed when running
  29.    F32 maxUnderwaterForwardSpeed;  ///< Maximum underwater forward speed when running
  30.    F32 maxUnderwaterBackwardSpeed; ///< Maximum underwater backward speed when running
  31.    F32 maxUnderwaterSideSpeed;     ///< Maximum underwater side speed when running
  32.  
  33.    F32 maxStepHeight;         ///< Maximum height the player can step up
  34.    F32 runSurfaceAngle;       ///< Maximum angle from vertical in degrees the player can run up
  35.  
  36.    F32 horizMaxSpeed;         ///< Max speed attainable in the horizontal
  37.    F32 horizResistSpeed;      ///< Speed at which resistence will take place
  38.    F32 horizResistFactor;     ///< Factor of resistence once horizResistSpeed has been reached
  39.  
  40.    F32 upMaxSpeed;            ///< Max vertical speed attainable
  41.    F32 upResistSpeed;         ///< Speed at which resistence will take place
  42.    F32 upResistFactor;        ///< Factor of resistence once upResistSpeed has been reached
  43.  
  44.    S32 recoverDelay;          ///< # tick
  45.    F32 recoverRunForceScale;  ///< RunForce multiplier in recover state
  46.  
  47.    F32 jumpForce;             ///< Force exherted per jump
  48.    F32 jumpEnergyDrain;       ///< Energy drained per jump
  49.    F32 minJumpEnergy;         ///< Minimum energy required to jump
  50.    F32 minJumpSpeed;          ///< Minimum speed needed to jump
  51.    F32 maxJumpSpeed;          ///< Maximum speed before the player can no longer jump
  52.    F32 jumpSurfaceAngle;      ///< Angle from vertical in degrees where the player can jump
  53.    S32 jumpDelay;             ///< Delay time in ticks between jumps
  54.    /// @}
  55.  
  56.    /// @name Hitboxes
  57.    /// @{
  58.  
  59.    F32 boxHeadPercentage;
  60.    F32 boxTorsoPercentage;
  61.  
  62.    S32 boxHeadLeftPercentage;
  63.    S32 boxHeadRightPercentage;
  64.    S32 boxHeadBackPercentage;
  65.    S32 boxHeadFrontPercentage;
  66.    /// @}
  67.  
  68.    F32 minImpactSpeed;        ///< Minimum impact speed required to apply fall damage
  69.  
  70.    F32 decalOffset;
  71.  
  72.    F32 groundImpactMinSpeed;      ///< Minimum impact speed required to apply fall damage with the ground
  73.    VectorF groundImpactShakeFreq; ///< Frequency in each direction for the camera to shake
  74.    VectorF groundImpactShakeAmp;  ///< How much to shake
  75.    F32 groundImpactShakeDuration; ///< How long to shake
  76.    F32 groundImpactShakeFalloff;  ///< How fast the shake disapates
  77.  
  78.    /// Zounds!
  79.    enum Sounds {
  80.       FootSoft,
  81.       FootHard,
  82.       FootMetal,
  83.       FootSnow,
  84.       FootShallowSplash,
  85.       FootWading,
  86.       FootUnderWater,
  87.       FootBubbles,
  88.       MoveBubbles,
  89.       WaterBreath,
  90.       ImpactSoft,
  91.       ImpactHard,
  92.       ImpactMetal,
  93.       ImpactSnow,
  94.       ImpactWaterEasy,
  95.       ImpactWaterMedium,
  96.       ImpactWaterHard,
  97.       ExitWater,
  98.       MaxSounds
  99.    };
  100.    AudioProfile* sound[MaxSounds];
  101.  
  102.    Point3F boxSize;           ///< Width, depth, height
  103.  
  104.    /// Animation and other data intialized in onAdd
  105.    struct ActionAnimationDef {
  106.       const char* name;       ///< Sequence name
  107.       struct Vector {
  108.          F32 x,y,z;
  109.       } dir;                  ///< Default direction
  110.    };
  111.    struct ActionAnimation {
  112.       const char* name;       ///< Sequence name
  113.       S32      sequence;      ///< Sequence index
  114.       VectorF  dir;           ///< Dir of animation ground transform
  115.       F32      speed;         ///< Speed in m/s
  116.       bool     velocityScale; ///< Scale animation by velocity
  117.       bool     death;         ///< Are we dying?
  118.    };
  119.    enum {
  120.       // *** WARNING ***
  121.       // These enum values are used to index the ActionAnimationList
  122.       // array instantiated in player.cc
  123.       // The first five are selected in the move state based on velocity
  124.       RootAnim,
  125.       RunForwardAnim,
  126.       BackBackwardAnim,
  127.       SideLeftAnim,
  128.  
  129.       // These are set explicitly based on player actions
  130.       FallAnim,
  131.       JumpAnim,
  132.       StandJumpAnim,
  133.       LandAnim,
  134.  
  135.       //
  136.       NumMoveActionAnims = SideLeftAnim + 1,
  137.       NumTableActionAnims = LandAnim + 1,
  138.       NumExtraActionAnims = 512,
  139.       NumActionAnims = NumTableActionAnims + NumExtraActionAnims,
  140.       ActionAnimBits = 9,
  141.       NullAnimation = (1 << ActionAnimBits) - 1
  142.    };
  143.  
  144.    static ActionAnimationDef ActionAnimationList[NumTableActionAnims];
  145.    ActionAnimation actionList[NumActionAnims];
  146.    U32 actionCount;
  147.    U32 lookAction;
  148.    S32 spineNode[NumSpineNodes];
  149.    S32 pickupDelta;           ///< Base off of pcikupRadius
  150.    F32 runSurfaceCos;         ///< Angle from vertical in cos(runSurfaceAngle)
  151.    F32 jumpSurfaceCos;        ///< Angle from vertical in cos(jumpSurfaceAngle)
  152.  
  153.    enum Impacts {
  154.       ImpactNone,
  155.       ImpactNormal,
  156.    };
  157.  
  158.    enum Recoil {
  159.       LightRecoil,
  160.       MediumRecoil,
  161.       HeavyRecoil,
  162.       NumRecoilSequences
  163.    };
  164.    S32 recoilSequence[NumRecoilSequences];
  165.  
  166.    /// @name Particles
  167.    /// All of the data relating to environmental effects
  168.    /// @{
  169.  
  170.    ParticleEmitterData * footPuffEmitter;
  171.    S32 footPuffID;
  172.    S32 footPuffNumParts;
  173.    F32 footPuffRadius;
  174.  
  175.    DecalData* decalData;
  176.    S32 decalID;
  177.  
  178.    ParticleEmitterData * dustEmitter;
  179.    S32 dustID;
  180.  
  181.    SplashData* splash;
  182.    S32 splashId;
  183.    F32 splashVelocity;
  184.    F32 splashAngle;
  185.    F32 splashFreqMod;
  186.    F32 splashVelEpsilon;
  187.    F32 bubbleEmitTime;
  188.  
  189.    F32 medSplashSoundVel;
  190.    F32 hardSplashSoundVel;
  191.    F32 exitSplashSoundVel;
  192.    F32 footSplashHeight;
  193.  
  194.    ParticleEmitterData* splashEmitterList[NUM_SPLASH_EMITTERS];
  195.    S32 splashEmitterIDList[NUM_SPLASH_EMITTERS];
  196.    /// @}
  197.  
  198.    //
  199.    DECLARE_CONOBJECT(PlayerData);
  200.    PlayerData();
  201.    bool preload(bool server, char errorBuffer[256]);
  202.    void getGroundInfo(TSShapeInstance*,TSThread*,ActionAnimation*);
  203.    bool isTableSequence(S32 seq);
  204.    bool isJumpAction(U32 action);
  205.  
  206.    static void initPersistFields();
  207.    virtual void packData(BitStream* stream);
  208.    virtual void unpackData(BitStream* stream);
  209. };
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement