unit ObjectStartPoint;

interface

uses
  CustomObject, Vec2f, IniFiles, Subject, System.SysUtils, Units.Custom;

type
  TObjectStartPoint = class(TCustomObject)
  private
    FAngle: Integer;
    FSubject: TSubjectType;
  published
    procedure Load(Aini: TIniFile); override;
    procedure Draw; override;
    procedure DrawLight; override;
    procedure SetHero(AHero: TCustomUnit); override;
    procedure Process(const Delta: Double); override;
    property Angle: Integer read FAngle;

  end;

implementation

uses
  Resources, Level.Map, GlobalTypes, QuadEngine;

procedure TObjectStartPoint.Load(Aini: TIniFile);
var
  Str: String;
begin
  inherited;
  Str := 'Obj_' + IntToStr(ID);
  FAngle := Aini.ReadInteger(Str, 'Angle', 0);
end;

procedure TObjectStartPoint.SetHero(AHero: TCustomUnit);
begin
  inherited;
  if ParentAction and Assigned(FHero) then
    SetActive(True);
end;

procedure TObjectStartPoint.Process(const Delta: Double);
begin
  UpdateParentAction;
end;

procedure TObjectStartPoint.Draw;
begin
  TTextures.exit.DrawRot(Position, 0, 1)
end;

procedure TObjectStartPoint.DrawLight;
begin
  if ParentAction then
  begin
    TGlobals.QuadCamera.Disable;
    TTextures.QuadGBuffer.DrawLight(
      TVec3f.Create(
        (Position.X - TGlobals.QuadCamera.GetPosition.X) / TGlobals.GWidth,
        (Position.Y - TGlobals.QuadCamera.GetPosition.Y) / TGlobals.GHeight,
        0.2
      ), 0.2, $FFFFFFFF);
    TGlobals.QuadCamera.Enable;
  end;
end;

end.
