//CPlayer - [2020-04-13 11:57:47]
#ifndef _CPLAYER_H_
#define _CPLAYER_H_

#include "common.h"
#include "TAnimData.h"
#include "TPlayerInfo.h"
#include "CAnimManager.h"

/*
0011DE8C CPlayer::SetPos(int,int)
00125D8C CPlayer::SetPos(TPoint3D)
00154314 CPlayer::GetDistance(TPoint)
0015432C CPlayer::GetDistanceSq(TPoint)
0015CBD0 CPlayer::SetPos(TPoint)
0016E630 CPlayer::UpdateFE()
0016E64E CPlayer::UpdateRot()
0016E6B0 CPlayer::UpdateHeadRot()
0016E7A4 CPlayer::UpdateFinalise()
0016E7C2 CPlayer::Update()
0016E81A CPlayer::UpdateSprint()
0016E874 CPlayer::UpdateFace()
0016E9BC CPlayer::UpdatePosVel()
0016EB6C CPlayer::UpdateFuturePos()
0016EB86 CPlayer::UpdateBallInHands()
0016EB88 CPlayer::SetPos(int,int,int)
0016EBDE CPlayer::SetPosDest()
0016EBE6 CPlayer::SetMoveDest(int,int)
0016EBF2 CPlayer::SetMoveDest(TPoint)
0016EBFE CPlayer::SetRotExplicit(int)
0016EC02 CPlayer::SetRot(int,bool)
0016EC0C CPlayer::SetRot(TPoint,bool)
0016EC20 CPlayer::GetRotPoint(TPoint)
0016EC34 CPlayer::SetFace(int)
0016EC3A CPlayer::SetFace(int,int)
0016EC48 CPlayer::SetFace(TPoint)
0016EC56 CPlayer::SetFaceDest()
0016EC7A CPlayer::Stop(int)
0016EC8E CPlayer::GetRotDest()
0016ECB6 CPlayer::GetRotPoint(TPoint3D)
0016ECCC CPlayer::GetRotBall()
0016ECF0 CPlayer::GetDistance(CPlayer*)
0016ED1C CPlayer::GetDistanceSq(CPlayer*)
0016ED40 CPlayer::SetSpaceRot(int,int)
0016ED8A CPlayer::GetMoveDistance()
0016ED96 CPlayer::Init()
0016EDD0 CPlayer::SetupGoally(int,TPlayerInfo *)
0016EEC6 CPlayer::SetupPlayer(int,int,TPlayerInfo *)
0016EFBC CPlayer::SetupStandard()
0016F008 CPlayer::SetupOfficial()
0016F044 CPlayer::Reset()
0016F114 CPlayer::CancelHeadInputControl()
0016F11C CPlayer::SetHeadRotRel(int,bool)
0016F12C CPlayer::GetBonePos(int)
0016F13C CPlayer::GetTimePos(int)
0016F280 CPlayer::AttributeInterpolate_Internal(EPlayerAttribute,int,int,int,int,int)
0016F324 CPlayer::UpdateAction()
0016F3D4 CPlayer::ActionTend(int,TPoint3D *)
0016F734 CPlayer::UpdateActionSlideTackleX(int)
0016FA40 CPlayer::UpdateActionSlideTackle(int)
0016FAAC CPlayer::UpdateActionConservativeTackle(int)
0016FB24 CPlayer::UpdateActionGKSave(int)
0016FB94 CPlayer::UpdateActionDeek(int)
0016FE80 CPlayer::UpdateActionControl(int)
0016FF24 CPlayer::UpdateActionKick(int)
0016FF78 CPlayer::UpdateActionGKKick(int)
0016FFC8 CPlayer::ClearAction()
0016FFD4 CPlayer::ActionCheckIsStillValidRange(int,int,int)
001700C0 CPlayer::KickFail()
001700E4 CPlayer::ActionUpdateDynamic()
0017012C CPlayer::ActionTendSetupDest(TPoint3D)
001701D0 CPlayer::ActionTendSetup(TActionSetup *,EACTION)
00170242 CPlayer::ActionGetPosFromDest()
001702B0 CPlayer::Animate(int)
0017039C CPlayer::ApplyRootBoneOfs(TAnimData *,int)
00170440 CPlayer::SetNextState(TAnimData *)
001704DC CPlayer::GetAnimData()
001704F4 CPlayer::SetAnim(int)
00170694 CPlayer::GetRootBoneMove(TPoint *)
0017077C CPlayer::GetTrueRot()
00170820 CPlayer::AnimBlendNeeded()
0017082C CPlayer::UpdateAnimCalcs()
001708D0 CPlayer::SetTrophyData(ETrophyPos,ushort,ushort)
001708DE CPlayer::ClearBlend()
001708E8 CPlayer::UpdateJostlePoint()
00170A14 CPlayer::SetReaction(int,int,int)
00170A50 CPlayer::UpdateAnimation()
00170BD0 CPlayer::OverrideAnimFrame(int)
00170C0C CPlayer::EnableIdleAnims(bool)
00170C14 CPlayer::SetAnimFromStateGen(int,int,int)
00170D10 CPlayer::SetAnimFromStateI()
00170DD4 CPlayer::GetRootBoneOfs(TPoint *,TAnimData *)
00170E50 CPlayer::UpdateActOKTime()
00170E98 CPlayer::GetActionTime()
00170EC8 CPlayer::GetAnimTime()
00170EE0 CPlayer::SetAnimFromStateAction(int,int,int,int,int,int,TActionSetup *,int,int)
001714E4 CPlayer::GetAnimActionPoint(TPoint *,TAnimData *,int,int)
00171534 CPlayer::GetActionPoint(TPoint3D *)
001715EC CPlayer::GetBonePosition(int,TPoint3D *)
00171798 CPlayer::GetHandPosition(TPoint3D *,bool)
001717A8 CPlayer::GetHandsPosition(int)
00171868 CPlayer::GetBoneOrientation(int,TPoint3D *)
00172634 CPlayer::GetDistanceSq(TPoint3D)
00172EB2 CPlayer::Fell(TPoint,bool)
00172EE4 CPlayer::Fell(int,bool)
00172F78 CPlayer::Trip(int,int)
00172FF8 CPlayer::UpdateLogic()
00173080 CPlayer::UpdateIdle()
00173188 CPlayer::UpdateReactions()
001731B8 CPlayer::UpdateBallReactions()
001731CA CPlayer::UpdateFall()
00173208 CPlayer::UpdateAvoid()
001733C4 CPlayer::IsWalking()
001733EC CPlayer::IsSprinting()
00173414 CPlayer::IsStanding()
0017341E CPlayer::IsFacing(int,int)
00173442 CPlayer::IsAtDest(TPoint *,int)
0017346C CPlayer::UpdateMovement()
00173DBA CPlayer::SetStateStand(bool)
00173DD4 CPlayer::SetStateLoco()
00173E58 CPlayer::SetAnimFromStateLoco(int,int,int)
00174074 CPlayer::CheckAvoid(TPoint *,int,int)
001741FC CPlayer::SetConstantSpeed(bool)
00174204 CPlayer::GetAverageRunSpeed()
00174260 CPlayer::SetAverageRunSpeed(int)
00174290 CPlayer::GetInterceptRunSpeed()
00174294 CPlayer::GetWalkSpeed()
001742B4 CPlayer::GetSprintSpeed()
00174310 CPlayer::GetTargetRunSpeed()
0017432C CPlayer::GetCurrentRunSpeed()
00174458 CPlayer::GetRunSpeed()
001744CC CPlayer::AttributeInterpolate(EPlayerAttribute,int,int)
001744E2 CPlayer::GetMoveSpeed()
001744E8 CPlayer::GetInterceptMaxHeight()
00174530 CPlayer::SetUrgency(int)
00174550 CPlayer::SetUrgencyTime(int,bool)
0017464C CPlayer::UpdateUrgency()
001746EE CPlayer::GetDirMoveX()
00174702 CPlayer::GetDirMoveY()
0017471E CPlayer::NewPlayerStateX(int,int,int)
0017472E CPlayer::NewPlayerStateXF(int,int,int,int)
00174778 CPlayer::NewPlayerStateGen(int)
001747A8 CPlayer::NewPlayerStateData(int,int,int,int)
001748A8 CPlayer::NewPlayerStateDataNIS(int,int,int,int)
001749A0 CPlayer::CheckBlockedOff(int)
00174A24 CPlayer::NewPlayerStateXFKick(TPoint3D,int,int,TActionSetup *,int,int)
00174ADC CPlayer::UpdateTake()
00174C9C CPlayer::ControlTakeBall(int)
00174FBC CPlayer::SetAnimControl(int,int,int,int,int,int,int,TActionSetup *)
0017555C CPlayer::ControlFinish(int,int,int)
00175968 CPlayer::SetAnimTurn(int,int,int,int,int,int,int,TActionSetup *)
00175B2C CPlayer::Turn(int,int,bool)
00178AAC CPlayer::operator=(CPlayer const&)

0x1A4
*/

//-------------------------------------------------------------------------------------------------
//长度至少是0x28
struct TActionSetup {
  int field_0;
  int field_4;
  int field_8;
  volatile int field_C;
  TPoint3D tPoint3D_10;
  TPoint3D tPoint3D_1C;
};
//-------------------------------------------------------------------------------------------------
enum EPlayerAttribute {
  EPlayerAttribute_0,
  EPlayerAttribute_1,
  EPlayerAttribute_2,
  EPlayerAttribute_3,
  EPlayerAttribute_4,
  EPlayerAttribute_5,
  EPlayerAttribute_6,
  EPlayerAttribute_7,
  EPlayerAttribute_8,
  EPlayerAttribute_9,
  EPlayerAttribute_10,
  EPlayerAttribute_11,
  EPlayerAttribute_12,
  EPlayerAttribute_13,
  EPlayerAttribute_14,
  EPlayerAttribute_15,
  EPlayerAttribute_16,
};
//-------------------------------------------------------------------------------------------------
enum EACTION {
  EACTION_0,
  EACTION_1,
  EACTION_2,
  EACTION_3,
  EACTION_4,
  EACTION_5,
  EACTION_6,
  EACTION_7,
  EACTION_8,
  EACTION_9,
  EACTION_10,
  EACTION_11,
};
//-------------------------------------------------------------------------------------------------
enum ETrophyPos {
  ETrophyPos_0,
  ETrophyPos_1,
  ETrophyPos_2,
  ETrophyPos_3,
  ETrophyPos_4,
  ETrophyPos_5,
};
//-------------------------------------------------------------------------------------------------
struct TPlayerAI {
  float f_0;
  int field_4;
  float f_8;
  int field_C;
  int field_10;
  int field_14;
  int field_18;
  int field_1C;

  TPlayerAI &operator=(TPlayerAI const &other) {
    this->f_0 = other.f_0;
    this->field_4 = other.field_4;
    this->f_8 = other.f_8;
    this->field_C = other.field_C;

    if (this != &other) {
      this->field_10 = other.field_10;
      this->field_14 = other.field_14;
    }

    this->field_18 = other.field_18;
    this->field_1C = other.field_1C;
    return *this;
  };
};

//0x32
#pragma pack(1)
struct CPlayer_str_32 {
  uint8 uc_0;  //0016F03E   STRB.W          R0, [R4,#0x44]
  uint8 uc_1;
  uint8 uc_2;
  uint8 uc_3;
  short s_4;
  short s_6;
  uint field_8;  //00170606 这儿确定是无符号的
  uint16 s_C;
  short s_E;
  int field_10;
  int field_14;
  short s_18;
  short s_1A;
  int field_1C;
  int field_20;
  uint field_24;
  sint16 s_28;
  short s_2A;
  union {
    struct {
      short ss_2C;
      sint16 sBlend_2E;  //00170352
    } s_2C;
    int field_2C;  //001705D4
  } u_2C;

  uint16 s_30;
};
#pragma pack()

//0x58 大小确定，字段类型不确定
struct CPlayer_str_58 {
  uchar uc_0;
  uchar uc_1;
  uchar uc_2;
  uchar uc_3;
  int field_4;
  int field_8;
  int field_C[14];
  int field_44;
  int field_48;
  short s_4C;
  short s_4E;
  union {
    struct {
      uint16 field_50; //LDRH.W R1, [R0,#0xF2] r0=CPlayer 可能有两个uint16
      uint16 field_52;
    }s_50;
    int ui_50;
  } u_50;
  int field_54;
};

//-------------------------------------------------------------------------------------------------
class CPlayer {
public:
  void SetPos(int, int);                                                               //0011DE8C
  void SetPos(TPoint3D);                                                               //00125D8C
  uint64_t GetDistance(TPoint);                                                        //00154314
  int GetDistanceSq(TPoint);                                                           //0015432C
  void SetPos(TPoint);                                                                 //0015CBD0
  void UpdateFE();                                                                     //0016E630
  void UpdateRot();                                                                    //0016E64E
  void UpdateHeadRot();                                                                //0016E6B0
  void UpdateFinalise();                                                               //0016E7A4
  void Update();                                                                       //0016E7C2
  void UpdateSprint();                                                                 //0016E81A
  void UpdateFace();                                                                   //0016E874
  void UpdatePosVel();                                                                 //0016E9BC
  void UpdateFuturePos();                                                              //0016EB6C
  void UpdateBallInHands();                                                            //0016EB86
  void SetPos(int, int, int);                                                          //0016EB88
  void SetPosDest();                                                                   //0016EBDE
  void SetMoveDest(int, int);                                                          //0016EBE6
  void SetMoveDest(TPoint);                                                            //0016EBF2
  void SetRotExplicit(int);                                                            //0016EBFE
  void SetRot(int, bool);                                                              //0016EC02
  void SetRot(TPoint, bool);                                                           //0016EC0C
  ushort GetRotPoint(TPoint);                                                          //0016EC20
  void SetFace(int);                                                                   //0016EC34
  void SetFace(int, int);                                                              //0016EC3A
  void SetFace(TPoint);                                                                //0016EC48
  void SetFaceDest();                                                                  //0016EC56
  void Stop(int);                                                                      //0016EC7A
  int GetRotDest();                                                                    //0016EC8E
  ushort GetRotPoint(TPoint3D);                                                        //0016ECB6
  int GetRotBall();                                                                    //0016ECCC
  void GetDistance(CPlayer *);                                                         //0016ECF0
  void GetDistanceSq(CPlayer *);                                                       //0016ED1C
  void SetSpaceRot(int, int);                                                          //0016ED40
  void GetMoveDistance();                                                              //0016ED8A
  void Init();                                                                         //0016ED96
  void SetupGoally(int, TPlayerInfo *);                                                //0016EDD0
  void SetupPlayer(int, int, TPlayerInfo *);                                           //0016EEC6
  void SetupStandard();                                                                //0016EFBC
  void SetupOfficial();                                                                //0016F008
  void Reset();                                                                        //0016F044
  void CancelHeadInputControl();                                                       //0016F114
  void SetHeadRotRel(int, bool);                                                       //0016F11C
  TPoint3D GetBonePos(int);                                                            //0016F12C
  TPoint GetTimePos(int);                                                              //0016F13C
  int AttributeInterpolate_Internal(EPlayerAttribute, int, int, int, int, int);        //0016F280
  void UpdateAction();                                                                 //0016F324
  int ActionTend(int, TPoint3D *);                                                     //0016F3D4
  void UpdateActionSlideTackleX(int);                                                  //0016F734
  void UpdateActionSlideTackle(int);                                                   //0016FA40
  void UpdateActionConservativeTackle(int);                                            //0016FAAC
  void UpdateActionGKSave(int);                                                        //0016FB24
  void UpdateActionDeek(int);                                                          //0016FB94
  void UpdateActionControl(int);                                                       //0016FE80
  void UpdateActionKick(int);                                                          //0016FF24
  void UpdateActionGKKick(int);                                                        //0016FF78
  void ClearAction();                                                                  //0016FFC8
  bool ActionCheckIsStillValidRange(int, int, int);                                    //0016FFD4
  void KickFail();                                                                     //001700C0
  void ActionUpdateDynamic();                                                          //001700E4
  void ActionTendSetupDest(TPoint3D);                                                  //0017012C
  void ActionTendSetup(TActionSetup *, EACTION);                                       //001701D0
  TPoint3D ActionGetPosFromDest();                                                     //00170242
  void Animate(int);                                                                   //001702B0
  void ApplyRootBoneOfs(TAnimData *, int);                                             //0017039C
  void SetNextState(TAnimData *);                                                      //00170440
  TAnimData *GetAnimData();                                                            //001704DC
  void SetAnim(int);                                                                   //001704F4
  void GetRootBoneMove(TPoint *);                                                      //00170694
  int GetTrueRot();                                                                    //0017077C
  bool AnimBlendNeeded();                                                              //00170820
  void UpdateAnimCalcs();                                                              //0017082C
  void SetTrophyData(ETrophyPos, ushort, ushort);                                      //001708D0
  void ClearBlend();                                                                   //001708DE
  void UpdateJostlePoint();                                                            //001708E8
  bool SetReaction(int, int, int);                                                     //00170A14
  void UpdateAnimation();                                                              //00170A50
  void OverrideAnimFrame(int);                                                         //00170BD0
  void EnableIdleAnims(bool);                                                          //00170C0C
  void SetAnimFromStateGen(int, int, int);                                             //00170C14
  void SetAnimFromStateI();                                                            //00170D10
  void GetRootBoneOfs(TPoint *, TAnimData *);                                          //00170DD4
  void UpdateActOKTime();                                                              //00170E50
  int GetActionTime();                                                                 //00170E98
  void GetAnimTime();                                                                  //00170EC8
  int SetAnimFromStateAction(int, int, int, int, int, int, TActionSetup *, int, int);  //00170EE0
  void GetAnimActionPoint(TPoint *, TAnimData *, int, int);                            //001714E4
  void GetActionPoint(TPoint3D *);                                                     //00171534
  void GetBonePosition(int, TPoint3D *);                                               //001715EC
  void GetHandPosition(TPoint3D *, bool);                                              //00171798
  TPoint3D GetHandsPosition(int i1);                                                   //001717A8
  void GetBoneOrientation(int, TPoint3D *);                                            //00171868
  int GetDistanceSq(TPoint3D);                                                         //00172634
  bool Fell(TPoint, bool);                                                             //00172EB2
  bool Fell(int, bool);                                                                //00172EE4
  bool Trip(int, int);                                                                 //00172F78
  void UpdateLogic();                                                                  //00172FF8
  void UpdateIdle();                                                                   //00173080
  void UpdateReactions();                                                              //00173188
  void UpdateBallReactions();                                                          //001731B8
  void UpdateFall();                                                                   //001731CA
  void UpdateAvoid();                                                                  //00173208
  void IsWalking();                                                                    //001733C4
  bool IsSprinting();                                                                  //001733EC
  void IsStanding();                                                                   //00173414
  void IsFacing(int, int);                                                             //0017341E
  void IsAtDest(TPoint *, int);                                                        //00173442
  void UpdateMovement();                                                               //0017346C
  void SetStateStand(bool);                                                            //00173DBA
  void SetStateLoco();                                                                 //00173DD4
  void SetAnimFromStateLoco(int, int, int);                                            //00173E58
  void CheckAvoid(TPoint *, int, int);                                                 //00174074
  void SetConstantSpeed(bool);                                                         //001741FC
  int GetAverageRunSpeed();                                                            //00174204
  void SetAverageRunSpeed(int);                                                        //00174260
  void GetInterceptRunSpeed();                                                         //00174290
  void GetWalkSpeed();                                                                 //00174294
  int GetSprintSpeed();                                                                //001742B4
  int GetTargetRunSpeed();                                                             //00174310
  int GetCurrentRunSpeed();                                                            //0017432C
  int GetRunSpeed();                                                                   //00174458
  int AttributeInterpolate(EPlayerAttribute, int, int);                                //001744CC
  float GetMoveSpeed();                                                                //001744E2
  int GetInterceptMaxHeight();                                                         //001744E8
  void SetUrgency(int);                                                                //00174530
  void SetUrgencyTime(int, bool);                                                      //00174550
  void UpdateUrgency();                                                                //0017464C
  void GetDirMoveX();                                                                  //001746EE
  void GetDirMoveY();                                                                  //00174702
  void NewPlayerStateX(int, int, int);                                                 //0017471E
  void NewPlayerStateXF(int, int, int, int);                                           //0017472E
  void NewPlayerStateGen(int);                                                         //00174778
  void NewPlayerStateData(int, int, int, int);                                         //001747A8
  void NewPlayerStateDataNIS(int, int, int, int);                                      //001748A8
  bool CheckBlockedOff(int);                                                           //001749A0
  bool NewPlayerStateXFKick(TPoint3D, int, int, TActionSetup *, int, int);             //00174A24
  void UpdateTake();                                                                   //00174ADC
  void ControlTakeBall(int);                                                           //00174C9C
  void SetAnimControl(int, int, int, int, int, int, int, TActionSetup *);              //00174FBC
  void ControlFinish(int, int, int);                                                   //0017555C
  void SetAnimTurn(int, int, int, int, int, int, int, TActionSetup *);                 //00175968
  bool Turn(int, int, bool);                                                           //00175B2C
  CPlayer &operator=(CPlayer const &);                                                 //00178AAC
  union {
    struct {
      sint16 s_0; //??? 001D1DAE 在这个地址是取4个字节，int, 存疑
      int16 s_2;  //0018FC98确定类型
    } s_2_0;
    uint32 field_0;  //0015BBDC 此处可以确定也可能是一个int
  } u_0;
  TPoint3D ballPosPrev_4;
  uint field_10;
  TPoint3D Point3D_14;
  TPoint point_20;  //00170830 此处可以确定
  short s_28;
  short s_2A;
  sint16 s_2C;
  uint8 uc_2E;
  bool bool_2F;
  bool b_30;
  bool b_31;
  short s_32;
  TPoint point_34;  //001708BE
  TPoint point_3C;
  CPlayer_str_32 tStr32_44;  //00178B04 由此推断为数据结构，长度为0x32
  uint8 uc_76;
  uint8 uc_77;
  TPoint point_78;
  sint16 s_80;
  uint16 s_82;
  int dFace_84;
  uint8 uc_88;
  uint8 uc_89;
  uint8 uc_8A;
  uint8 uc_8B;
  int field_8C;  //00178B70 ??? 通过此年观察可能是short
                 //00170A28 此处代码显示 field_8C 为int
  short s_90;
  short s_92;
  short s_94;
  short s_96;
  TPoint point_98;
  CPlayer_str_58 tStr58_A0;  //00178B90 此处可以确定是0x58
  TPlayerAI tTPlayerAI_F8;
  short s_118;
  short s_11A;
  int field_11C;
  sint16 field_120;  //0016F09C 00173100 此处显示是short
  ushort s_122;
  uchar uc_124;
  uchar uc_125;
  uchar uc_126;
  uchar uc_127;
  uchar uc_128;
  uchar uc_129;
  uchar uc_12A;
  uchar uc_12B;
  uchar uc_12C;
  uchar uc_12D;
  uchar uc_12E;
  uchar uc_12F;
  uchar uc_130;
  uchar uc_131;
  uchar uc_132;
  uchar uc_133;
  uchar uc_134;
  uchar uc_135;
  uchar uc_136;
  uchar uc_137;
  TPoint point_138;
  int field_140;
  int field_144;
  int field_148;
  int field_14C;
  bool b_150;
  uchar uc_151;
  uchar uc_152;
  uchar uc_153;
  EACTION eAction_154;
  volatile sint16 s_158;
  volatile short s_15A;
  short s_15C;
  short s_15E;
  uchar uc_160;
  uchar uc_161;
  short s_162;
  TPoint3D point3D_164;
  int field_170;
  int field_174;
  //TriangleI triangle_178;  //00178C6A 由空间中的三个点组成的数据结构，猜测是三角型
  TPoint3D aPoint3D_178[3];
  //TPoint3D point3D_184;
  //TPoint3D point3D_190;
  ETrophyPos eTrophyPos_19C;
  ushort s_1A0;
  ushort s_1A2;
};


extern int LOCO_SPEED_WALK_MIN;     // 0033E988
extern int LOCO_SPEED_WALK_MAX ;     // 0033E98C
extern int LOCO_SPEED_WALK_AVG;     // 0033E990
extern int LOCO_SPEED_JOG_MIN ;      // 0033E994
extern int LOCO_SPEED_JOG_MAX;      // 0033E998
extern int LOCO_SPEED_JOG_AVG;      // 0033E99C
extern int LOCO_SPEED_SPRINT_MIN;   // 0033E9A0
extern int LOCO_SPEED_SPRINT_MAX;  // 0033E9A4
extern int LOCO_SPEED_SPRINT_AVG;  // 0033E9A8

/*
0016EC34   STR.W           R1, [R0,#0x84]
*/
//-------------------------------------------------------------------------------------------------
#endif  //_CPLAYER_H_