Okay. I guess we're pretty much on the same page, because atomization is what I've been trying to accomplish the whole time. My difficulty is in puzzling out the atomization but not understanding the process.
I think I'll base it around a common base game object (abstract of course).
Code:
type
TGameObject = class
public
class function Duplicate: TGameObject; virtual; abstract;
procedure Assign(From: TGameObject); virtual; abstract;
end;
Then adapt to my various derivative objects.
Code:
type
TItem = class(TGameObject, ISerialize)
private
// All the properties and variables, etc....
public
class function Duplicate: TGameObject; virtual;
procedure Assign(From: TGameObject); virtual;
procedure Save(Stream: TStream);
procedure Load(Stream: TStream);
end;
TStackedItem = class(TItem);
TWeapon = class(TItem);
TAttribute = class(TGameObject, ISerialize)
private
// All the properties and variables, etc....
// Plus storage for the amounts given,
// taken, etc to make revocation simple.
public
class function Duplicate: TGameObject; virtual; override;
procedure Assign(From: TGameObject); virtual; override;
procedure Save(Stream: TStream);
procedure Load(Stream: TStream);
// Unique:
procedure ApplyTo(What: TWeapon);
procedure Revoke(From: TWeapon);
end;
I think that this would make things simpler. For instance, I could do this:
Code:
class function TItem.Duplicate: TGameObject;
begin
Result := TItem.Create;
Result.Assign(Self);
end;
procedure TItem.Assign(From: TGameObject);
begin
if not (From is TItem) then
raise Exception.CreateFmt('Error! Cannot assign to a TItem from a %s.', [From.ClassName])
else begin
// reset any properties that are objects...
// and then apply any settings from the FROM object...
// and duplicate any TGameObject descended classes needed.
end;
end;
This is currently pseudocode and errant ramblings on the subject, but I think my brain is slowly straightening these things out. Thankfully if it is, then it is all subconsciously--because my head hurts less this way. I feel more confident about it at least. Obviously there is still much to consider, test, and work out. I think this is a decent start to planning at least.
Brainer: It may be helpful, but I am only after designing the OOP framework, the OOA&D portions, and not the rest about DX8 or DX9 and the rest of the engine stuff. Once I get the basic data types down and all the interdependencies worked together, then I can easily make myself an engine. Dunno what rendering framework I'll do it with yet, but it may just be ASCII. I am quite far from that point in time just now.
Bookmarks