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

import com.badlogic.ashley.core.Component;
import com.badlogic.ashley.core.ComponentMapper;
import com.badlogic.gdx.graphics.Camera;

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

@Storable(value="camera", auto=true)
@EditableComponent(autoTool=false, autoClone=true)
public class CameraComponent implements Component
{
	
	public static final ComponentMapper<CameraComponent> components = ComponentMapper.getFor(CameraComponent.class);
	
	@Storable
	@Editable public Camera camera;
	public boolean frustumDirty;
}

@@ -159,21 +159,195 @@
 gic.
-gdx.graphics.
+ashley.core.Engine;%0Aimport com.badlogic.gdx.Gdx;%0Aimport com.badlogic.gdx.graphics.Camera;%0Aimport com.badlogic.gdx.graphics.OrthographicCamera;%0Aimport com.badlogic.gdx.graphics.Perspective
 Came
@@ -503,16 +503,65 @@
 torable;
+%0Aimport net.mgsx.game.core.components.Duplicable;
 %0A%0A@Stora
@@ -695,12 +695,22 @@
 nent
+, Duplicable
 %0A%7B
-%0A%09
 %0A%09pu
@@ -896,10 +896,1007 @@
 mDirty;%0A
+%09%0A%09@Override%0A%09public Component duplicate(Engine engine) %7B%0A%09%09CameraComponent clone = engine.createComponent(CameraComponent.class);%0A%09%09clone.frustumDirty = true;%0A%09%09if(camera instanceof OrthographicCamera)%7B%0A%09%09%09OrthographicCamera camClone = new OrthographicCamera();%0A%09%09%09camClone.zoom = ((OrthographicCamera) camera).zoom;%0A%09%09%09clone.camera = camClone;%0A%09%09%7Delse if(camera instanceof PerspectiveCamera)%7B%0A%09%09%09PerspectiveCamera camClone = new PerspectiveCamera();%0A%09%09%09camClone.fieldOfView = ((PerspectiveCamera) camera).fieldOfView;%0A%09%09%09clone.camera = camClone;%0A%09%09%7Delse%7B%0A%09%09%09Gdx.app.error(%22graphics%22, %22warning : camera not supported for duplication : %22 + camera.getClass().getName());%0A%09%09%7D%0A%09%09clone.camera.position.set(camera.position);%0A%09%09clone.camera.direction.set(camera.direction);%0A%09%09clone.camera.up.set(camera.up);%0A%09%09clone.camera.near = camera.near;%0A%09%09clone.camera.far = camera.far;%0A%09%09clone.camera.viewportWidth = camera.viewportWidth;%0A%09%09clone.camera.viewportHeight = camera.viewportHeight;%0A%09%09return clone;%0A%09%7D%0A
 %7D%0A

fix camera cloning