package net.mgsx.game.examples.platformer.tasks;

import com.badlogic.gdx.ai.btree.annotation.TaskAttribute;
import com.badlogic.gdx.physics.box2d.BodyDef.BodyType;

import net.mgsx.game.plugins.box2d.components.Box2DBodyModel;
import net.mgsx.game.plugins.btree.BTreePlugin.EntityLeafTask;
import net.mgsx.game.plugins.btree.annotations.TaskAlias;

@TaskAlias("physicsType")
public class PhysicTypeTask extends EntityLeafTask
{
	@TaskAttribute(required=true)
	public boolean dynamic;
	
	@Override
	public Status execute() {
		
		Box2DBodyModel physics = Box2DBodyModel.components.get(getObject().entity);
		if(physics != null){
			physics.body.setType(dynamic ? BodyType.DynamicBody : BodyType.KinematicBody);
		}
		
		return Status.SUCCEEDED;
	}
}

@@ -441,23 +441,8 @@
 bute
-(required=true)
 %0A%09pu
@@ -503,19 +503,16 @@
 ute() %7B%0A
-%09%09%0A
 %09%09Box2DB

remove required attribute (fix serialization)