static ThnObjectFlags ConvertFlags(EntityTypes type, LuaTable table) { if (!(table["flags"] is float)) { return((ThnObjectFlags)table["flags"]); } var val = (int)(float)table["flags"]; if (val == 0) { return(ThnObjectFlags.None); } if (val == 1) { return(ThnObjectFlags.Reference); //Should be for all types } if (type == EntityTypes.Sound) { switch (val) { case 2: return(ThnObjectFlags.Spatial); default: throw new NotImplementedException(); } } return(ThnEnum.FlagsReflected <ThnObjectFlags>(val)); }
static void ProcessEvents(LuaTable t) { for (int ti = 0; ti < t.Capacity; ti++) { var ev = (LuaTable)t[ti]; ev[1] = ThnEnum.Check <EventTypes>(ev[1]); if (ev.Capacity >= 4) { var props = (LuaTable)ev[3]; //TODO: Property flags } } }
static void ProcessEntities(LuaTable t) { //Make sure flags aren't integers object o; for (int ti = 0; ti < t.Capacity; ti++) { var ent = (LuaTable)t[ti]; ent["type"] = ThnEnum.Check <EntityTypes>(ent["type"]); if (ent.TryGetValue("lightprops", out o)) { var lp = (LuaTable)o; if (lp.ContainsKey("type")) { lp["type"] = ThnEnum.Check <LightTypes>(lp["type"]); } } if (ent.ContainsKey("flags")) { ent["flags"] = ConvertFlags((EntityTypes)ent["type"], ent); } } }