#pragma once
#pragma flag enable rootconstructor

#define CALL_GUARDED_CONSTRUCTOR(x) if(this.classname == #x) \
{ \
  GuardedConstructor(); \
}

// global
#define SPAWNFIELD_REMAP_PARSEFLOAT(x, r, v) case #r: this.##x = stof(v); break;
#define SPAWNFIELD_REMAP_PARSEINT(x, r, v) case #r: this.##x = stoi(v); break;
#define SPAWNFIELD_REMAP_PARSEVEC3(x, r, v) case #r: this.##x = stov(v); break;
#define SPAWNFIELD_REMAP_PARSESTRING(x, r, v) case #r: this.##x = v; break;

#define SPAWNFIELD_PARSEFLOAT(x, v) SPAWNFIELD_REMAP_PARSEFLOAT(x, x, v)
#define SPAWNFIELD_PARSEINT(x, v) SPAWNFIELD_REMAP_PARSEINT(x, x, v)
#define SPAWNFIELD_PARSEVEC3(x, v) SPAWNFIELD_REMAP_PARSEVEC3(x, x, v)
#define SPAWNFIELD_PARSESTRING(x, v) SPAWNFIELD_REMAP_PARSESTRING(x, x, v)

#define SPAWNFIELDS_PARSE_SET(k, v, x) \
    switch(k) { x(v) }

class map_entity_c
{
    map_entity_c();

    string seasonal_date;
    string seasonal_enddate;
    int seasonal_flags;
    
    /* Constructor that can only run if entity's classname matches 
    *   Invoked by adding CALL_GUARDED_CONSTRUCTOR(x) to class constructor
    */
    virtual void GuardedConstructor();

    nonvirtual void HandleSpawnFields(__inout string inspawndata);

    /* Ingest a key value pair from fullspawndata (e.g. Trenchbroom) */ 
    virtual void ParseSpawnField(string key, string value);

    /* Gives ent a chance to set its preferred default before the spawn data is parsed */
    virtual void DefaultSpawnFields(void);
};

.float priority; // use priority, when running use_targets, higher runs first