//------------------------------------------------------------------------------
// <auto-generated>
//     This code was generated by a tool.
//     Changes to this file may cause incorrect behavior and will be lost if
//     the code is regenerated.
// </auto-generated>
//------------------------------------------------------------------------------

package cfg

import "errors"
import "bright/serialization"

type GameModelData struct {
    Id string
    Preson string
    Presonshow string
    Presonstory string
    Presondraw string
    Height float32
    Weight float32
    Ico string
    Fight string
    Img string
    Heroimg string
    Portrait string
    Bust string
    Postxyz []float32
    Rotation serialization.Vector3
    BoxPos serialization.Vector3
    BoxSize serialization.Vector3
}

const TypeId_GameModelData = -305436809

func (*GameModelData) GetTypeId() int32 {
    return -305436809
}

func (_v *GameModelData)Deserialize(_buf map[string]interface{}) (err error) {
    { var _ok_ bool; if _v.Id, _ok_ = _buf["id"].(string); !_ok_ { err = errors.New("id error"); return } }
    { var _ok_ bool; if _v.Preson, _ok_ = _buf["preson"].(string); !_ok_ { err = errors.New("preson error"); return } }
    { var _ok_ bool; if _v.Presonshow, _ok_ = _buf["presonshow"].(string); !_ok_ { err = errors.New("presonshow error"); return } }
    { var _ok_ bool; if _v.Presonstory, _ok_ = _buf["presonstory"].(string); !_ok_ { err = errors.New("presonstory error"); return } }
    { var _ok_ bool; if _v.Presondraw, _ok_ = _buf["presondraw"].(string); !_ok_ { err = errors.New("presondraw error"); return } }
    { var _ok_ bool; var _tempNum_ float64; if _tempNum_, _ok_ = _buf["height"].(float64); !_ok_ { err = errors.New("height error"); return }; _v.Height = float32(_tempNum_) }
    { var _ok_ bool; var _tempNum_ float64; if _tempNum_, _ok_ = _buf["weight"].(float64); !_ok_ { err = errors.New("weight error"); return }; _v.Weight = float32(_tempNum_) }
    { var _ok_ bool; if _v.Ico, _ok_ = _buf["ico"].(string); !_ok_ { err = errors.New("ico error"); return } }
    { var _ok_ bool; if _v.Fight, _ok_ = _buf["fight"].(string); !_ok_ { err = errors.New("fight error"); return } }
    { var _ok_ bool; if _v.Img, _ok_ = _buf["img"].(string); !_ok_ { err = errors.New("img error"); return } }
    { var _ok_ bool; if _v.Heroimg, _ok_ = _buf["heroimg"].(string); !_ok_ { err = errors.New("heroimg error"); return } }
    { var _ok_ bool; if _v.Portrait, _ok_ = _buf["portrait"].(string); !_ok_ { err = errors.New("portrait error"); return } }
    { var _ok_ bool; if _v.Bust, _ok_ = _buf["bust"].(string); !_ok_ { err = errors.New("bust error"); return } }
     {
                var _arr_ []interface{}
                var _ok_ bool
                if _arr_, _ok_ = _buf["postxyz"].([]interface{}); !_ok_ { err = errors.New("postxyz error"); return }

                _v.Postxyz = make([]float32, 0, len(_arr_))
                
                for _, _e_ := range _arr_ {
                    var _list_v_ float32
                    { var _ok_ bool; var _x_ float64; if _x_, _ok_ = _e_.(float64); !_ok_ { err = errors.New("_list_v_ error"); return }; _list_v_ = float32(_x_) }
                    _v.Postxyz = append(_v.Postxyz, _list_v_)
                }
            }

    { var _ok_ bool; var _v_ map[string]interface{}; if _v_, _ok_ = _buf["rotation"].(map[string]interface{}); !_ok_ { err = errors.New("rotation error"); return }
            var _x_, _y_, _z_ float32;
            { var _ok_ bool; var _tempNum_ float64; if _tempNum_, _ok_ = _v_["x"].(float64); !_ok_ { err = errors.New("x error"); return }; _x_ = float32(_tempNum_) }
            { var _ok_ bool; var _tempNum_ float64; if _tempNum_, _ok_ = _v_["y"].(float64); !_ok_ { err = errors.New("y error"); return }; _y_ = float32(_tempNum_) }
            { var _ok_ bool; var _tempNum_ float64; if _tempNum_, _ok_ = _v_["z"].(float64); !_ok_ { err = errors.New("z error"); return }; _z_ = float32(_tempNum_) }
            _v.Rotation = serialization.NewVector3(_x_, _y_, _z_)
            }

    { var _ok_ bool; var _v_ map[string]interface{}; if _v_, _ok_ = _buf["boxPos"].(map[string]interface{}); !_ok_ { err = errors.New("boxPos error"); return }
            var _x_, _y_, _z_ float32;
            { var _ok_ bool; var _tempNum_ float64; if _tempNum_, _ok_ = _v_["x"].(float64); !_ok_ { err = errors.New("x error"); return }; _x_ = float32(_tempNum_) }
            { var _ok_ bool; var _tempNum_ float64; if _tempNum_, _ok_ = _v_["y"].(float64); !_ok_ { err = errors.New("y error"); return }; _y_ = float32(_tempNum_) }
            { var _ok_ bool; var _tempNum_ float64; if _tempNum_, _ok_ = _v_["z"].(float64); !_ok_ { err = errors.New("z error"); return }; _z_ = float32(_tempNum_) }
            _v.BoxPos = serialization.NewVector3(_x_, _y_, _z_)
            }

    { var _ok_ bool; var _v_ map[string]interface{}; if _v_, _ok_ = _buf["boxSize"].(map[string]interface{}); !_ok_ { err = errors.New("boxSize error"); return }
            var _x_, _y_, _z_ float32;
            { var _ok_ bool; var _tempNum_ float64; if _tempNum_, _ok_ = _v_["x"].(float64); !_ok_ { err = errors.New("x error"); return }; _x_ = float32(_tempNum_) }
            { var _ok_ bool; var _tempNum_ float64; if _tempNum_, _ok_ = _v_["y"].(float64); !_ok_ { err = errors.New("y error"); return }; _y_ = float32(_tempNum_) }
            { var _ok_ bool; var _tempNum_ float64; if _tempNum_, _ok_ = _v_["z"].(float64); !_ok_ { err = errors.New("z error"); return }; _z_ = float32(_tempNum_) }
            _v.BoxSize = serialization.NewVector3(_x_, _y_, _z_)
            }

    return
}

func DeserializeGameModelData(_buf map[string]interface{}) (*GameModelData, error) {
    v := &GameModelData{}
    if err := v.Deserialize(_buf); err == nil {
        return v, nil
    } else {
        return nil, err
    }
}
