with Hashed_Strings; use Hashed_Strings;
package Entities.Players.Keen is
type Keen is new Player with private;
type A_Keen is access all Keen'Class;
-- If Keen was teleporting, he will end the action and go back to the
-- moving state.
procedure Finish_Teleport( this : not null access Keen'Class );
-- Accelerates Keen in the direction 'dir'.
procedure Move_Start( this : access Keen; dir : Cardinal_Direction );
-- Stops Keen's acceleration in the direction 'dir'.
procedure Move_Stop( this : access Keen; dir : Cardinal_Direction );
-- Shoots Keen's neural stunner, returning True on success. If 'fire' is
-- False, an out of ammo sound will be played and no stunner shot will be
-- spawned.
function Shoot_Gun( this : not null access Keen'Class; fire : Boolean ) return Boolean;
-- Notifies the entity that he's not attempting to activate anymore, which
-- will allow Try_Activating to work again.
procedure Stop_Activating( this : not null access Keen'Class );
-- Stops Keen's attempt to jump, if he was attempting to do so.
procedure Stop_Jump_Attempt( this : not null access Keen'Class );
-- Checks if Keen can teleport and then queues the events needed to enter
-- the teleport state.
procedure Teleport( this : access Keen;
fromX, fromY : Float;
toX, toY : Float );
-- Toggles Keen's pogostick, if it's possible to do so. He can use his
-- pogostick when he's moving (walking, standing, jumping). Attempting to
-- use the pogo when he's bored will abort the bored action.
procedure Toggle_Pogostick( this : not null access Keen'Class );
-- Activates the entities that Keen is currently touching, if he is allowed
-- to perform the activate action right now. He must be standing flat footed
-- on the ground and not already busy activating something.
procedure Try_To_Activate( this : not null access Keen'Class );
-- Make Keen attempt to jump. The attempt will be in effect until the
-- attempt is stopped. The jump will begin on the attempt if he is able to
-- do so.
procedure Try_To_Jump( this : not null access Keen'Class );
----------------------------------------------------------------------------
-- An impulse the Keen entity sends to itself on completion of teleporting
Finish_Teleporting : constant Hashed_String := To_Hashed_String( "Finish_Teleporting" );
private
type Action_Type is (Act_Moving, Act_Looking, Act_Looking_Back,
Act_Teleporting, Act_Idle, Act_Rising, Act_Dying);
type Keen is new Player with
record
-- *** these fields are streamed ***
-- true when keen is jumping (actively accelerating upward)
jumping : Boolean := False;
-- the world y location of keen when he started his jump. this is
-- used to determine when the jump has reached min and max heights.
jumpStartY : Float := 0.0;
-- true if keen is on his pogo stick. note that jumping and grounded
-- are independent states and may or may not be true.
onPogo : Boolean := False;
-- true if keen is currently shooting. keen may shoot while
-- performing certain actions. (ie: moving, hanging from a pole)
shooting : Boolean := False;
-- the time when keen last fired a shot, used for keeping a delay
-- between shots. (relative to .age)
shootStart : Time_Span := Time_Span_Zero;
-- related to keen performing a one-shot action
action : Action_Type := Act_Moving;
actionStart : Time_Span := Time_Span_Zero; -- (relative to .age)
actionDuration : Time_Span := Time_Span_Zero;
idleStart : Time_Span := Time_Span_Zero; -- (relative to .age)
idleNumber : Positive := 1; -- number of the next idle animation
-- for the teleporting action
teleportX, -- teleport destination
teleportY : Float := 0.0; --
lastTeleport : Time_Span := Time_Span_Zero; -- time of previous teleport (relative to .age)
deathX,
deathY : Float := 0.0; -- location of keen when he died
-- ** these fields do not need to be streamed **
dead : Boolean := False; -- dead fully dead? (temporary)
upTime : Time_Span := Time_Span_Zero;
attemptingJump : Boolean := False; -- true when the jump key is being held down
activating : Boolean := False; -- true if busy activating something
minJumpHeight, -- entity.player.keen.min_jump_height
maxJumpHeight, -- entity.player.keen.max_jump_height
minPogoHeight, -- entity.player.keen.min_pogo_height
maxPogoHeight, -- entity.player.keen.max_pogo_height
maxBounceHeight : Float := 0.0; -- entity.player.keen.max_bounce_height
lookSpeed : Float := 0.0; -- entity.player.keen.look_speed
end record;
procedure Construct( this : access Keen );
procedure Die( this : access Keen );
procedure Face( this : access Keen; dir : Direction_Type );
function Is_Busy( this : not null access Keen'Class ) return Boolean;
function Object_Input( stream : access Root_Stream_Type'Class ) return Keen;
for Keen'Input use Object_Input;
procedure Object_Read( stream : access Root_Stream_Type'Class; obj : out Keen );
for Keen'Read use Object_Read;
procedure Object_Write( stream : access Root_Stream_Type'Class; obj : Keen );
for Keen'Write use Object_Write;
procedure On_Hit_Wall( this : access Keen; dir : Cardinal_Direction );
procedure Reset_Idle( this : not null access Keen'Class );
procedure Start_Action( this : not null access Keen'Class;
action : Action_Type;
length : Time_Span := Time_Span_Zero );
procedure Start_Jump( this : not null access Keen'Class );
procedure Stop_Jump( this : not null access Keen'Class );
procedure Tick( this : access Keen; time : Tick_Time );
procedure Update_Frame( this : access Keen; notify : Boolean := True );
end Entities.Players.Keen;