//------------------------------------------------------------------------------------
// irr::scene::IParticleAffector wrappers
//------------------------------------------------------------------------------------

class BMXIParticleAffector : public IParticleAffector
{
public:

	BMXBinder binder;

	void (*BMXIParticleAffector_affect)(s32 binding,u32 now,array<SParticle>* particlearray);
	void (*BMXIParticleAffector_serializeAttributes)(s32 binding,io::IAttributes* out,io::SAttributeReadWriteOptions* options);
	void (*BMXIParticleAffector_deserializeAttributes)(s32 binding,io::IAttributes* in,io::SAttributeReadWriteOptions* options);
	E_PARTICLE_AFFECTOR_TYPE (*BMXIParticleAffector_getType)(s32 binding);

	BMXBinder* getBinder()
	{
		return &binder;
	}

	BMXIParticleAffector() : IParticleAffector()
	{
		BMXIParticleAffector_affect=0;
		BMXIParticleAffector_serializeAttributes=0;
		BMXIParticleAffector_deserializeAttributes=0;
		BMXIParticleAffector_getType=0;
	}
	
	void bindAffect(void (*bind_Affect)(s32 binding,u32 now,array<SParticle>* particlearray))
	{
		BMXIParticleAffector_affect=bind_Affect;
	}

	virtual void affect(u32 now,SParticle* particlearray,u32 count)
	{
		if (BMXIParticleAffector_affect)
		{
			array<SParticle>* retval=new array<SParticle>();
			retval->set_free_when_destroyed(false); // dont want to kill the particle array
			retval->set_pointer(particlearray,count);

			BMXIParticleAffector_affect(binder.binding,now,retval);
		}
	}
	
	void bindSerializeAttributes(void (*bind_serializeAttributes)(s32 binding,io::IAttributes* out,io::SAttributeReadWriteOptions* options))
	{
		BMXIParticleAffector_serializeAttributes=bind_serializeAttributes;
	}
	
	void serializeAttributes(io::IAttributes* out, io::SAttributeReadWriteOptions* options=0)
	{
		if (BMXIParticleAffector_serializeAttributes)
			BMXIParticleAffector_serializeAttributes(binder.binding,out,options);
	}

	void bindDeserializeAttributes(void (*bind_deserializeAttributes)(s32 binding,io::IAttributes* in,io::SAttributeReadWriteOptions* options))
	{
		BMXIParticleAffector_deserializeAttributes=bind_deserializeAttributes;
	}
	
	void deserializeAttributes(io::IAttributes* in,io::SAttributeReadWriteOptions* options=0)
	{
		if (BMXIParticleAffector_deserializeAttributes)
			BMXIParticleAffector_deserializeAttributes(binder.binding,in,options);
	}

	void bindGetType(E_PARTICLE_AFFECTOR_TYPE (*bind_getType)(s32 binding))
	{
		BMXIParticleAffector_getType=bind_getType;
	}

	E_PARTICLE_AFFECTOR_TYPE getType() const
	{
		if (BMXIParticleAffector_getType)
			return BMXIParticleAffector_getType(binder.binding);
		//else return IParticleAffector::getType();
	}
};

extern "C" 
{
	BMXBinder* IrrScene_BMXIParticleAffector_getBinder(BMXIParticleAffector* pa)
	{
		if (pa)
			return pa->getBinder();
		else return 0;
	}
	
	BMXIParticleAffector* IrrScene_BMXIParticleAffector_new()
	{
		return new BMXIParticleAffector();
	}
	
	void IrrScene_BMXIParticleAffector_bindAffect(BMXIParticleAffector* pa,void (*bind_Affect)(s32 binding,u32 now,array<SParticle>* particlearray))
	{
		if (pa)
			pa->bindAffect(bind_Affect);
	}

	void IrrScene_BMXIParticleAffector_bindSerializeAttributes(BMXIParticleAffector* pa,void (*bind_serializeAttributes)(s32 binding,io::IAttributes* out,io::SAttributeReadWriteOptions* options))
	{
		if (pa)
			pa->bindSerializeAttributes(bind_serializeAttributes);
	}
	
	void IrrScene_BMXIParticleAffector_bindDeserializeAttributes(BMXIParticleAffector* pa,void (*bind_deserializeAttributes)(s32 binding,io::IAttributes* in,io::SAttributeReadWriteOptions* options))
	{
		if (pa)
			pa->bindDeserializeAttributes(bind_deserializeAttributes);
	}
	
	void IrrScene_BMXIParticleAffector_bindGetType(BMXIParticleAffector* pa,E_PARTICLE_AFFECTOR_TYPE (*bind_getType)(s32 binding))
	{
		if (pa)
			pa->bindGetType(bind_getType);
	}	
}

