<commit_before>package components

import (
	. "mater"
	"box2d"
	"json"
	"os"
)

//wrapper around box2d.Transform
type Transform struct {
	*box2d.Transform
}

func (xf *Transform) Name () string {
	return "Transform"
}

//If the Transform is set and the owner has a body attached, we replace its transform
//else if the Transform is not set we try to take it from the owners body or create a new one
func (xf *Transform) Init (owner *Entity) {
	//check if we already have a transform
	if xf.Transform == nil {
		//we don't, see if our owner has a body attached
		if bcomp, ok := owner.Components["Body"]; ok {
			body := bcomp.(*Body)
			//take its transform
			xf.Transform = body.Transform()
		} else {
			//create a new one
			xf.Transform = new(box2d.Transform)
		}
	} else {
		//we do, check if our owner has a body attached
		if bcomp, ok := owner.Components["Body"]; ok {
			body := bcomp.(*Body)
			//set its transform
			body.SetTransform(&xf.Position, xf.Angle())
			//take the address of the bodies transform
			xf.Transform = body.Transform()
		}
	}
}

func (xf *Transform) Update (owner *Entity, dt float64) {
	
}

func (xf *Transform) Destroy (owner *Entity) {
	
}

func (xf *Transform) Marshal(owner *Entity) ([]byte, os.Error) {
	return json.Marshal(xf.Transform)
}

func (xf *Transform) Unmarshal(owner *Entity, data []byte) (os.Error) {
	return json.Unmarshal(data, xf.Transform)
}

func init() {
	RegisterComponent(&Transform{})
}
<commit_msg>fixed Transform component deserialization<commit_after>package components

import (
	. "mater"
	"box2d"
	"json"
	"os"
)

//wrapper around box2d.Transform
type Transform struct {
	*box2d.Transform
}

func (xf *Transform) Name () string {
	return "Transform"
}

//If the Transform is set and the owner has a body attached, we replace its transform
//else if the Transform is not set we try to take it from the owners body or create a new one
func (xf *Transform) Init (owner *Entity) {
	//check if we already have a transform
	if xf.Transform == nil {
		//we don't, see if our owner has a body attached
		if bcomp, ok := owner.Components["Body"]; ok {
			body := bcomp.(*Body)
			//take its transform
			xf.Transform = body.Transform()
		} else {
			//create a new one
			xf.Transform = new(box2d.Transform)
		}
	} else {
		//we do, check if our owner has a body attached
		if bcomp, ok := owner.Components["Body"]; ok {
			body := bcomp.(*Body)
			//set its transform
			body.SetTransform(&xf.Position, xf.Angle())
			//take the address of the bodies transform
			xf.Transform = body.Transform()
		}
	}
}

func (xf *Transform) Update (owner *Entity, dt float64) {
	
}

func (xf *Transform) Destroy (owner *Entity) {
	
}

func (xf *Transform) Marshal(owner *Entity) ([]byte, os.Error) {
	return json.Marshal(xf.Transform)
}

func (xf *Transform) Unmarshal(owner *Entity, data []byte) (os.Error) {
	if xf.Transform == nil {
		xf.Transform = new(box2d.Transform)
	}
	return json.Unmarshal(data, xf.Transform)
}

func init() {
	RegisterComponent(&Transform{})
}

{'fraction_non_alphanumeric': 0.12918184829413712, 'fraction_numerical': 0.004306061609804571, 'mean_word_length': 3.5345345345345347, 'pattern_counts': {'":': 0, '<': 3, '<?xml version=': 0, '>': 3, 'https://': 0, 'lorem ipsum': 0, 'www.': 0, 'xml': 0}, 'pii_count': 0, 'substrings_counts': 0, 'word_list_counts': {'cursed_substrings.json': 0, 'profanity_word_list.json': 0, 'sexual_word_list.json': 0, 'zh_pornsignals.json': 0}}
{'dir': 'git-commits-cleaned', 'id': '5275880', 'n_tokens_mistral': 1061, 'n_tokens_neox': 986, 'n_words': 352}