// part of uber 3
procedure TEntityPtr.SetNull;
begin
  FEntity := nil;
  FId := -1;
end;

constructor TEntityPtr.Store(Entity: PEntity);
begin
  FEntity := Entity;
  if Entity <> nil then
    FId := Entity^.FId;
end;

function TEntityPtr.Alive: Boolean;
begin
  Result := (FEntity <> nil) and (FEntity^.FId = FId);
end;

operator := (Entity: PEntity): TEntityPtr;
begin
  Result.Store(Entity);
end;
