1
これで、独自のEntity-Component Systemを作成しています.AdapterComponent Entityメソッドでスタックされています。ここでは、Enityにコンポーネントを追加し、それがどのように見えるかです:クラスをテンプレートパラメータとして受け取り、メソッドコンストラクタとしてクラスコンストラクタのパラメータを受け取ります。
template <typename T>
void AddComponent() {
NumOfComponents++;
AllComponents.push_back(new T());
}
私はコンポーネントのコンストラクタを持っている場合、これは正常に動作しますが、何?私はAddComponentメソッドのパラメータとしてのメソッドのパラメータを変換受け入れ、上記のようなものを実現するにはどうすればよい
Entity ent1;
Vector3f Pos, Rot, Scl;
ent1.AddComponent<Transform>(Pos, Rot, Scl); // This is currently not possible
:そう
class Transform : public Component
{
public:
Transfrm(Vector3f newPosition, Vector3f newRotation, Vector3f newScale) : Component("Transfrm") {};
Vector3f Position;
Vector3f Rotation;
Vector3f Scale;
~Transfrm();
};
のように、このような何か私は何を達成しようとしているのですか?
はハローコードは、あなたは私が「無効AddComponent(Argsの&& ..args){」エラーであるライン24で私の2つのエラーを与えている示した\t C3484 \t構文エラー:予想「 - >」の戻り値の型の前 エラー\t C3613 \t ' - >'( 'int'と仮定した後の戻り値の型がない)24 – kooldart
小さなタイプミス。 1つの期間が欠落していた。 –
nevermindを修正しました。 "..args"を点在する3つのargsに置き換えます: "... args" – kooldart