Changeset 409 for tags/1.4.0/Building.pas
- Timestamp:
- Jan 8, 2025, 11:01:27 AM (2 days ago)
- Location:
- tags/1.4.0
- Files:
-
- 2 edited
Legend:
- Unmodified
- Added
- Removed
-
tags/1.4.0
-
tags/1.4.0/Building.pas
r344 r409 39 39 public 40 40 Kind: TBuildingKind; 41 Game: TObject; // TGame 42 class function GetFields: TItemFields; override; 43 procedure GetValue(Index: Integer; out Value); override; 44 procedure SetValue(Index: Integer; var Value); override; 45 function GetReferenceList(Index: Integer): TBaseItemList; override; 41 46 procedure Assign(Source: TItem); override; 42 47 property MapCell: TObject read FMapCell write SetMapCell; // TMapCell; … … 47 52 TBuildings = class(TItemList<TBuilding>) 48 53 Game: TObject; // TGame; 54 function CreateItem(Name: string = ''): TBuilding; override; 55 procedure Assign(Source: TItemList<TBuilding>); override; 49 56 end; 50 57 … … 64 71 65 72 uses 66 Map ;73 Map, Game; 67 74 68 75 { TBuilding } … … 80 87 end; 81 88 89 class function TBuilding.GetFields: TItemFields; 90 var 91 Field: TItemField; 92 begin 93 Result := inherited; 94 Field := Result.AddField(2, 'Kind', SBuildingKind, dtReference); 95 end; 96 97 procedure TBuilding.GetValue(Index: Integer; out Value); 98 begin 99 if Index = 1 then string(Value) := Name 100 else if Index = 2 then TBuildingKind(Value) := Kind 101 else inherited; 102 end; 103 104 procedure TBuilding.SetValue(Index: Integer; var Value); 105 begin 106 if Index = 1 then Name := string(Value) 107 else if Index = 2 then Kind := TBuildingKind(Value) 108 else inherited; 109 end; 110 111 function TBuilding.GetReferenceList(Index: Integer): TBaseItemList; 112 begin 113 if Index = 2 then Result := TGame(Game).GameSystem.BuildingKinds.BaseItemList 114 else Result := nil; 115 end; 116 82 117 procedure TBuilding.Assign(Source: TItem); 83 118 begin 84 119 inherited; 85 120 Kind := TBuilding(Source).Kind; 121 end; 122 123 { TBuildings } 124 125 function TBuildings.CreateItem(Name: string): TBuilding; 126 begin 127 Result := inherited; 128 Result.Game := Game; 129 end; 130 131 procedure TBuildings.Assign(Source: TItemList<TBuilding>); 132 var 133 I: Integer; 134 begin 135 inherited; 136 for I := 0 to Count - 1 do 137 Items[I].Game := Game; 86 138 end; 87 139
Note:
See TracChangeset
for help on using the changeset viewer.