--
-- Copyright (c) 2012 Kevin Wellwood
-- All rights reserved.
--
-- This source code is distributed under the Modified BSD License. For terms and
-- conditions, see license.txt.
--
with Allegro.Bitmaps; use Allegro.Bitmaps;
package Entities.Enemies is
type Enemy is abstract new Entity with private;
type A_Enemy is access all Enemy'Class;
-- Returns a reference to a bitmap icon that represents the enemy. The
-- returned reference is owned by the enemy. Do not modify it!
function Get_Icon( this : not null access Enemy'Class ) return A_Allegro_Bitmap;
-- Returns True if the enemy is shootable (meaning it blocks shots fired at
-- it.) Being shootable does not imply that the enemy will react in any
-- specific way if instructed to die.
function Is_Shootable( this : not null access Enemy'Class ) return Boolean;
-- Notify the enemy that something deadly happened to it and it should die.
-- If the enemy is not currently capable of dying, nothing should happen.
-- The default behavior is to do nothing. Override this procedure to cause
-- the enemy to react in some way.
procedure Die( this : access Enemy );
-- A class pattern that matches all enemy class ids registered in the entity
-- factory.
CLASS_PATTERN : constant String := "Entities.Enemies.*";
private
type Enemy is abstract new Entity with
record
icon : Integer := 0; -- used by KEd
deadlyTouch : Boolean := True; -- is the enemy deadly to the player?
shootable : Boolean := True; -- can the player's shots hit it?
end record;
-- Raises an exception on error.
procedure Construct( this : access Enemy;
width,
height : Natural;
libName : String;
iconName : String );
procedure Object_Read( stream : access Root_Stream_Type'Class; obj : out Enemy );
for Enemy'Read use Object_Read;
procedure Object_Write( stream : access Root_Stream_Type'Class; obj : Enemy );
for Enemy'Write use Object_Write;
-- Players colliding with enemies deadly to the touch will be killed.
procedure On_Collide( this : access Enemy; e : not null A_Entity );
procedure Delete( this : in out A_Enemy );
pragma Postcondition( this = null );
end Entities.Enemies;