A while back, I asked the best way to spawn actors where each inherited class needs different params. It was suggested to use a SpawnParams struct. And pass it through the constructor. So I do this:
AActor::AActor(SpawnParams params) {
_spawnParams = std::move(params);
}
But others are saying they don't like that _spawnParams is an actor class member because it has duplicate and unused variables.
However, this way is really easy. And the other way means I have to make a custom function for like 40 actors.
Suggestions? SpawnParams is about 240 bytes of data.
As class member:
AActor::GetSpawnParams() {
return _spawnParams;
}
Not as a class member:
MyActor::SetSpawnParams(SpawnParams& params) {
params.Location = Pos;
params.Speed = Speed;
// etc.
}
class AActor {
public:
/* 0x00 */ s16 Type = 0;
/* 0x02 */ s16 Flags;
/* 0x04 */ s16 Unk_04;
/* 0x06 */ s16 State;
/* 0x08 */ f32 Unk_08;
/* 0x0C */ f32 BoundingBoxSize;
/* 0x10 */ Vec3s Rot = {0, 0, 0};
/* 0x16 */ s16 Unk_16;
/* 0x18 */ Vec3f Pos;
/* 0x24 */ Vec3f Velocity = {0, 0, 0};
/* 0x30 */ Collision Unk30;
/* 0x */ const char* Model = "";
uint8_t uuid[16];
const char* Name = "";
const char* ResourceName = "";
FVector Scale = {1, 1, 1};
std::vector<Triangle> Triangles;
SpawnParams _spawnParams;
bool bPendingDestroy = false;
}