unit uItems;

interface

uses uStatic, uItem, uWorldFile, uStaticDiff;

type    TItems = class
        public
                constructor Create;
                destructor Free;
                procedure Select( Item : PStaticItem );
                procedure UnSelect( Item : PStaticItem );
                procedure Delete( Item : PStaticItem );
                procedure SetColor( Item : PStaticItem; Color : Integer );
                procedure SetId( Item : PStaticItem; Id : Integer );
                procedure SetPos( Item : PStaticItem; X, Y, Z : Integer );
                procedure Move(Item : PStaticItem; MX, MY, MZ : Integer );
                function AddItem( Id, X, Y, Z, Color : Integer ) : Integer;
        end;

var     Items : TItems;

implementation

constructor TItems.Create;
begin
end;

destructor TItems.Free;
begin
end;

procedure TItems.Select( Item : PStaticItem );
begin
        if Item = nil then exit;
        case Item.Typ of
                Typ_Item_Static: Statics.Select( Item.Serial );
                Typ_Item_WorldFile, Typ_Item_New: WorldFile.Select( Item.Serial );
                Typ_Item_Static_Diff: StaticDiff.Select( Item.Serial );
        end;
end;

procedure TItems.UnSelect( Item : PStaticItem );
begin
        if Item = nil then exit;
        case Item.Typ of
                Typ_Item_Static: Statics.UnSelect( Item.Serial );
                Typ_Item_WorldFile, Typ_Item_New: WorldFile.UnSelect( Item.Serial );
                Typ_Item_Static_Diff: StaticDiff.UnSelect( Item.Serial );
        end;
end;

procedure TItems.Delete( Item : PStaticItem );
begin
        if Item = nil then exit;
        case Item.Typ of
                Typ_Item_Static: Statics.Delete( Item.Serial );
                Typ_Item_WorldFile, Typ_Item_New: WorldFile.Delete( Item.Serial );
                Typ_Item_Static_Diff: StaticDiff.Delete( Item.Serial );
        end;
end;

procedure TItems.SetColor( Item : PStaticItem; Color : Integer );
begin
        if Item = nil then exit;
        case Item.Typ of
                Typ_Item_Static: Statics.SetColor( Item.Serial, Color );
                Typ_Item_WorldFile, Typ_Item_New: WorldFile.SetColor( Item.Serial, Color );
                Typ_Item_Static_Diff: StaticDiff.SetColor( Item.Serial, Color );
        end;
end;

procedure TItems.SetId( Item : PStaticItem; Id : Integer );
begin
        if Item = nil then exit;
        case Item.Typ of
                Typ_Item_Static: Statics.SetId( Item.Serial, Id );
                Typ_Item_WorldFile, Typ_Item_New: WorldFile.SetId( Item.Serial, Id );
                Typ_Item_Static_Diff: StaticDiff.SetId( Item.Serial, Id );
        end;
end;

procedure TItems.SetPos( Item : PStaticItem; X,Y,Z : Integer );
begin
        if Item = nil then exit;
        case Item.Typ of
                Typ_Item_Static: Statics.SetPos( Item.Serial, X, Y, Z );
                Typ_Item_WorldFile, Typ_Item_New: WorldFile.SetPos( Item.Serial, X, Y, Z );
                Typ_Item_Static_Diff: StaticDiff.SetPos( Item.Serial, X, Y, Z );
        end;
end;

procedure TItems.Move( Item : PStaticItem; MX, MY, MZ : Integer );
begin
        if Item = nil then exit;
        case Item.Typ of
                Typ_Item_Static: Statics.Move( Item.Serial, MX, MY, MZ );
                Typ_Item_WorldFile, Typ_Item_New: WorldFile.Move( Item.Serial, MX, MY, MZ );
                Typ_Item_Static_Diff: StaticDiff.Move( Item.Serial, MX, MY, MZ );                
        end;
end;

function TItems.AddItem( Id, X, Y, Z, Color : Integer ) : Integer;
begin
        Result := WorldFile.AddItem( Id, X, Y, Z, Color );
end;

end.
