WorldObjects =
class
private
Flist:
array
of
Obj;
procedure
SetCount(Value:
Integer
);
function
GetCount:
Integer
;
function
GetList(Index:
Integer
): Obj;
public
constructor
create;
destructor
Destroy(); override;
property
Count:
Integer
read GetCount
write
SetCount;
procedure
AddLine(stp, enp: coords);
property
List[Index:
Integer
]: Obj read GetList;
end
;
implementation
constructor
WorldObjects
.
Create;
begin
end
;
function
WorldObjects
.
GetCount:
Integer
;
begin
Result := Length(FList);
end
;
procedure
WorldObjects
.
SetCount(Value:
Integer
);
var
oldCount, i:
Integer
;
begin
oldCount := Count;
for
i := oldCount
downto
Value
do
Flist[i].Free;
SetLength(Flist, Value);
for
i := oldCount
to
Value -
1
do
Flist[i] := Obj
.
Create();
end
;
procedure
WorldObjects
.
AddLine(stp, enp: coords);
var
nextObj: Obj;
begin
nextObj := list[count];
nextObj
.
name :=
2
;
nextObj
.
lin
.
stp := stp;
nextObj
.
lin
.
enp := enp;
end
;
function
WorldObjects
.
GetList(Index:
Integer
): Obj;
begin
if
Index >= Count
then
Count := Index +
1
;
Result := FList[Index];
end
;
destructor
WorldObjects
.
Destroy;
begin
Count :=
0
;
inherited
;
end
;