a0_ss0.cpp

Home   »   a0_ss0.cpp

class AbstractTrait {
public:
  	// some stuff here ...
	virtual void onStart() 		= 0;
  	virtual void onUpdate() 	= 0;
  	virtual void onRender2D() 	= 0;
  	virtual void onRender3D() 	= 0;
  	virtual void onEnd() 		= 0;
  	// some stuff there ...
};

class GameObject {
  	// some stuff here ...
	std::vector traits;
  	void onStart() {
    		for (AbstractTrait* trait : traits) { trait->onStart(); }
    	}
  	void onUpdate() {
    		for (AbstractTrait* trait : traits) { trait->onUpdate(); }
    	}
  	void onRender2D() {
    		for (AbstractTrait* trait : traits) { trait->onRender2D(); }
    	}
  	void onRender3D() {
    		for (AbstractTrait* trait : traits) { trait->onRender3D(); }
    	}
	void onEnd() {
    		for (AbstractTrait* trait : traits) { trait->onEnd(); }
    	}
	// some stuff there ...
};

Leave a Reply

Your email address will not be published. Required fields are marked *