package net.mgsx.game.plugins.core.components;

import com.badlogic.ashley.core.Component;
import com.badlogic.ashley.core.ComponentMapper;
import com.badlogic.ashley.core.Engine;
import com.badlogic.gdx.math.Vector2;

import net.mgsx.game.core.annotations.Editable;
import net.mgsx.game.core.annotations.EditableComponent;
import net.mgsx.game.core.annotations.Storable;
import net.mgsx.game.core.components.Duplicable;

@Storable("2d")
@EditableComponent(name="2D Transform")
public class Transform2DComponent implements Component, Duplicable
{
	
	public static ComponentMapper<Transform2DComponent> components = ComponentMapper.getFor(Transform2DComponent.class);
	
	@Editable public Vector2 position = new Vector2();
	@Editable public float angle;
	@Editable public boolean rotation = true;
	@Editable public boolean enabled = true;
	@Editable public Vector2 origin = new Vector2();

	@Override
	public Component duplicate(Engine engine) {
		Transform2DComponent clone = engine.createComponent(Transform2DComponent.class);
		clone.position.set(position);
		clone.angle = angle;
		clone.rotation = rotation;
		clone.enabled = enabled;
		clone.origin.set(origin);
		return clone;
	}

}

@@ -210,16 +210,61 @@
 Vector2;
+%0Aimport com.badlogic.gdx.utils.Pool.Poolable;
 %0A%0Aimport
@@ -582,16 +582,26 @@
 plicable
+, Poolable
 %0A%7B%0A%09%0A%09pu
@@ -1234,10 +1234,140 @@
 ne;%0A%09%7D%0A%0A
+%09@Override%0A%09public void reset() %7B%0A%09%09position.setZero();%0A%09%09angle = 0;%0A%09%09rotation = true;%0A%09%09enabled = true;%0A%09%09origin.setZero();%0A%09%7D%0A%0A
 %7D%0A

fix pooling