#include "world.h"

// exports
DllExport	void	effect_fog	(userEntity_t *self);
DllExport	void	effect_snow	(userEntity_t *self);
DllExport	void	effect_rain (userEntity_t *self);
DllExport	void	effect_glow (userEntity_t *self);

void effect_fog (userEntity_t *self)
{
	gstate->SetOrigin (self, self->s.origin [0], self->s.origin [1], self->s.origin [2]);
	gstate->SetModel (self, self->modelName);
}

void effect_snow (userEntity_t *self)
{
	int		i;
	float	height = 0;

	for (i = 0; self->epair[i].key != NULL; i++)
		if (!stricmp (self->epair[i].key, "height"))
			height = atof (self->epair[i].value);

	self->solid = SOLID_NOT;
	self->movetype = MOVETYPE_NONE;

	self->s.effects |= PV_TYPESNOW;
	self->s.renderfx |= PV_TYPESNOW;
	gstate->SetOrigin (self, self->s.origin [0], self->s.origin [1], self->s.origin [2]);
	gstate->SetModel (self, self->modelName);

	self->s.maxs[2] = self->s.mins[2] + height;
}

void effect_rain (userEntity_t *self)
{
	int		i;
	float	height = 0;

	for (i = 0; self->epair[i].key != NULL; i++)
		if (!stricmp (self->epair[i].key, "height"))
			height = atof (self->epair[i].value);

	self->solid = SOLID_NOT;
	self->movetype = MOVETYPE_NONE;

	self->s.effects |= PV_TYPERAIN | PV_RAIN_FAST | PV_RAIN_0;
	self->s.renderfx |= PV_TYPERAIN | PV_RAIN_FAST | PV_RAIN_0;
	gstate->SetOrigin (self, self->s.origin [0], self->s.origin [1], self->s.origin [2]);
	gstate->SetModel (self, self->modelName);

	self->s.maxs[2] = self->s.mins[2] + height;
}

void	effect_glow (userEntity_t *self)
{
	gstate->Precache_Model ("models/kingg/kingg.md2");
	gstate->SetModel (self, "models/kingg/kingg.md2");

	self->movetype = MOVETYPE_NONE;
	self->solid = SOLID_NOT;

	self->s.effects |= EF_DIMLIGHT;
}