1
 2
 3
 4
 5
 6
 7
 8
 9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
/********************************************************************
*
*	File:		fsCEphemeralComponent.h
*
*	Purpose:	Keep an entity  alive until....
*
*********************************************************************/

#ifndef fsCEphemeralComponenthdr
#define fsCEphemeralComponenthdr

//#include <functional>

#include "fsIComponent.h"

class fsCEphemeralComponent : public fsIComponent
{
	friend fsCComponentFactory;
	
public:

	class fsFncCondition
	{
	public:
		virtual fsBool operator()(fsCEntity* pParent) = 0;

		virtual ~fsFncCondition()
		{
		}
	};

	static const fsCUniqueId mTypeId;

	//	void init(std::function< fsBool (fsCEntity* const pParent) > pCondition);
	void init(fsFncCondition* pCondition);

protected:

	void updateDo(fsS32 pDeltaMs) override;

	static fsIComponent* create(fsCEntity* pParent);
	fsCEphemeralComponent(fsCEntity* pParent);
	~fsCEphemeralComponent();<--- Destructor in derived class

private:

	//	std::function< fsBool (fsCEntity* const pParent)  > mCondition;
	fsFncCondition* mCondition;
};


#endif