예제 #1
0
        public static Table Serialize(this Kingdom kingdom, Script script)
        {
            var table = new Table(script);

            table.Set("color", DynValue.NewString(kingdom.color.ToHex()));
            table.Set("demonym", DynValue.NewString(kingdom.demonym));
            table.Set("name", DynValue.NewString(kingdom.name));
            table.Set("mainland", DynValue.NewNumber(kingdom.mainland));

            // Resources
            table.Set("resources", DynValue.NewTable(kingdom.resources.Serialize(script)));

            // Getters
            table.Set("getTerritory", new LuaFunction(
                          (context) => {
                return(DynValue.NewTable(kingdom.GetTerritory().Serialize(script)));
            }
                          ));
            table.Set("getMap", new LuaFunction(
                          (context) => {
                return(DynValue.NewTable(kingdom.map.Serialize(script)));
            }
                          ));

            // Setters

            return(table);
        }