Facebook
From Burly Macaw, 2 Years ago, written in Plain Text.
Embed
Download Paste or View Raw
Hits: 75
  1. /* Abstract action base class. */
  2. UCLASS(Abstract)
  3. class PROJECT_CHRONOLOGY_API UBase_Action : public UObject
  4. {
  5. public:
  6.  
  7.         GENERATED_BODY()
  8.  
  9. ////////////////////////////////////////////////////////////////////////////
  10. ////////// -- Setup. -- ////////////////////////////////////////////////////
  11.  
  12.         /* Required call after creation. */
  13.         virtual void Setup_Action(AChronology_GameState* Chronology_Game_State_Pointer)
  14.         {
  15.                 // Brain pointer must be valid.
  16.                 verify(Chronology_Game_State_Pointer)
  17.                 CGSP = Chronology_Game_State_Pointer;
  18.  
  19.                 // The action must be deterministic, or deterministic location and rotation must be false.
  20.                 check(Is_Deterministic || (!Is_Location_Deterministic && !Is_Rotation_Deterministic))
  21.  
  22.                 // The actions rotation and location must both be determinisitic, or the rotation isn't determinisitic.
  23.                 check((Is_Rotation_Deterministic && Is_Location_Deterministic) || !Is_Rotation_Deterministic)
  24.         }
  25.  
  26.         // Connection to the brain...
  27.         AChronology_GameState* CGSP;
  28.  
  29. ////////////////////////////////////////////////////////////////////////////
  30. ////////// -- Deterministic. -- ////////////////////////////////////////////
  31.  
  32.         /** Clients MUST know about this action before the min net delay.
  33.        
  34.                 Note: Deterministic effects of any kind won't be allowed before the
  35.                 game state variable Min_Network_Segment_Delay has elapsed completed,
  36.                 that's the promise we make to clients. So that they have time to
  37.                 learn about deterministic actions before they can alter the simulation. */
  38.         bool Is_Deterministic = true;
  39.  
  40.         /** Clients MUST also know the location during the action. (input prevented)
  41.                 location replicated in advance.
  42.                
  43.                 Note: The use case for this being false would be extremely restricted,
  44.                 an action that can't be interrupted with collisions because the entity
  45.                 location has been assumed, so they can't reliably be hit, this actions
  46.                 effect can't actually be limited by distance so they must be applied
  47.                 globally, an example use case would be a buff applied to your whole,
  48.                 from inside character should, because collision isn't possible... */
  49.         bool Is_Location_Deterministic = true;
  50.  
  51.         /** Clients MUST also know the rotation during the action. (input prevented)
  52.                 rotation replicated in advance.
  53.                
  54.                 Note: There is no use case where this is true but location is false.
  55.                 the rotation being predetermined while the location is unknown has
  56.                 no practical purpose, why does it matter what direction your looking
  57.                 without context of where you are looking from!
  58.                
  59.                 Note: The use case for this being false is to allow vulnerability to
  60.                 charged up actions while still allowing the entity to visually turn
  61.                 during the charge up period, the entity can still be hit even if the
  62.                 client doesn't know their rotation, (it's because of this uncertainty
  63.                 that backstab effects arn't possible in project chronology. ) */
  64.         bool Is_Rotation_Deterministic = true;
  65.  
  66. ////////////////////////////////////////////////////////////////////////////
  67. ////////// -- Start. -- ////////////////////////////////////////////////////
  68.  
  69.         /* Required to not be deterministically active.
  70.         ---
  71.         Test if requirements to start this action, stimulus manual input.
  72.         ---     */
  73.         virtual bool Action_Initilize_Requirements(const uint32& Current_Segment, UChronology_Entity& Entity, Enum_Action_Type& Request_Action) {};
  74.  
  75. //////
  76.  
  77.         /* Not required to be deterministically active.
  78.         ---
  79.         Called when initally setting this action, setup can trigger movement based stimulus.
  80.         ---     */
  81.         virtual void Action_Initilize(const uint32& Current_Segment, bool Event_Initlized, UChronology_Entity& Entity, Enum_Action_Type& Request_Action) {};
  82.  
  83. ////////////////////////////////////////////////////////////////////////////
  84. ////////// -- Action generated collisions. -- //////////////////////////////
  85.  
  86.         /* Required to be deterministically active.
  87.         ---
  88.         Inital action collision creation.
  89.         ---     */
  90.         virtual void Action_Collision_Initilize(const uint32& Current_Segment, UChronology_Entity& Entity, Enum_Action_Type& Request_Action) {};
  91.  
  92. //////
  93.  
  94.         /* Required to be deterministically active.
  95.         ---
  96.         Finalize action collision setup.
  97.         ---     */
  98.         virtual void Action_Collision_Finalize(const uint32& Current_Segment, UChronology_Entity& Entity, Enum_Action_Type& Request_Action) {};
  99.  
  100. //////
  101.  
  102.         /* Required to be deterministically active.
  103.         ---
  104.         Apply action collision effects to collided entities.
  105.         ---     */
  106.         virtual void Action_Collision_Effects(const uint32& Current_Segment, UChronology_Entity& Entity, Enum_Action_Type& Request_Action) {};
  107.  
  108. ////////////////////////////////////////////////////////////////////////////
  109. ////////// -- Immediate stop? -- ///////////////////////////////////////////
  110.  
  111.         /* Required to not be deterministically active.
  112.         ---
  113.         Can this action be stopped immediatly for the requested action?
  114.         ---     */
  115.         virtual bool Action_Stop_Requirements(const uint32& Current_Segment, const UChronology_Entity& Entity, Enum_Action_Type& Request_Action) {};
  116.  
  117. ////////////////////////////////////////////////////////////////////////////
  118. ////////// -- Latent switch? -- ////////////////////////////////////////////
  119.  
  120.         /* Required to be deterministically active.
  121.         ---
  122.         Can this action be switch out for another, if true the returned segment won't equal the current segment.
  123.         ---     */
  124.         virtual uint32 Action_Switch_Requirements(const uint32& Current_Segment, UChronology_Entity& Entity, Enum_Action_Type& Request_Action) {};
  125.  
  126. ////////////////////////////////////////////////////////////////////////////
  127. ////////// -- Responses to stimulus. -- ////////////////////////////////////
  128.  
  129.         /* Can trigger regardless of deterministic status.
  130.         ---
  131.         The entity health is going to be set to zero, action response?
  132.         ---     */
  133.         virtual void Action_Death(const uint32& Current_Segment, const uint16& Damage, UChronology_Entity& Entity, Enum_Action_Type& Request_Action) {};
  134.  
  135. //////
  136.  
  137.         /* Can trigger regardless of deterministic status.
  138.         ---
  139.         The entity has collided with terrain, action response?
  140.         ---     */
  141.         virtual void Action_Terrain_Collision(const uint32& Current_Segment, UChronology_Entity& Entity, bool& Collision_Surface_Walkable, FVector& Collision_Impact_Normal) {};
  142.  
  143. ////////////////////////////////////////////////////////////////////////////
  144. ////////// -- Action ended. -- /////////////////////////////////////////////
  145.  
  146.         /* Can trigger regardless of deterministic status.
  147.         ---
  148.         This action has ended.
  149.         ---     */
  150.         virtual void Action_Completed(const uint32& Segment, UChronology_Entity& Entity, Enum_Action_Complete_Type Complete_Reason) {};
  151.  
  152. ////////////////////////////////////////////////////////////////////////////
  153. ////////// -- Base Variable Action Overrides. -- ///////////////////////////
  154.  
  155.         /* Triggers regardless of deterministic status.
  156.         ---
  157.         This action has ended.
  158.         ---     */
  159.         virtual void Action_Maximum_Speed(uint32& Segment, UChronology_Entity& Entity, float& Return_New_Maximum_Speed) {};
  160.  
  161. //////
  162.  
  163.         /* Triggers regardless of deterministic status.
  164.         ---
  165.         This action has ended.
  166.         ---     */
  167.         virtual void Action_Ground_Breaking_Friction(uint32& Segment, UChronology_Entity& Entity, float& Return_New_Deceleration) {};
  168.  
  169. //////
  170.  
  171.         /* Triggers regardless of deterministic status.
  172.         ---
  173.         The amount the speed of the character is reduced in air each segment proccessed.
  174.         ---     */
  175.         virtual void Action_Air_Breaking_Friction(uint32& Segment, UChronology_Entity& Entity, float& Return_New_Deceleration) {};
  176. };