func (s *Sheeple) Serialize(w io.Writer) error {
	enc := json.NewEncoder(w)
	us := UserSheeple{}
	us.UserRudder = Rudder2UserRudder(s.Rudder)
	us.LastP = lib.BlasVec2UserVec(s.LastP)
	return enc.Encode(&us)
}
Exemple #2
0
func (gr TvGroup) Render() {
	boxes := make([]ColorBox, len(gr.user))
	fr := gr.render.fr
	for i, un := range gr.user {
		ts := gr.render.torscreen
		mapped := core.MapNode(ts, gr.nodes[i])
		e := mapped.Entity
		tv := e.(*ext.Tv) // A better deserialization mechanism would allow no typecast
		exprad := ts.Scale(tv.R)
		boxes[i] = renderNode(core.SimNode2UserNode(mapped), BaseExtension(gr).noderad())
		expls := make([]Explosion, len(un.Expression))
		for i, b := range un.Expression {
			expls[i] = renderExplosion(core.BlasVec2UserVec(mapped.P), exprad, gr.render.time, b)
		}
		fr.Explosions = append(fr.Explosions, expls...)
	}
	tvShape := gr.render.entshapes["tv"]

	fr.Shapes[tvShape] = append(fr.Shapes[tvShape], boxes...)
}
Exemple #3
0
func Rudder2UserRudder(r Rudder) UserRudder {
	u := UserRudder{}
	u.D = lib.BlasVec2UserVec(r.D)
	u.S = r.S
	return u
}