Package cc.plural.ecs.runtime

Source Code of cc.plural.ecs.runtime.PlayerTurretComponent

package cc.plural.ecs.runtime;

import cc.plural.ecs.component.input.MouseListenerComponentMoveIntent;
import cc.plural.ecs.component.spatial.SpatialComponent;
import cc.plural.ecs.engine.Component;
import cc.plural.ecs.engine.ComponentIntent;

public class PlayerTurretComponent extends Component {

    private float turnSpeed;
    private float xStore;

    public PlayerTurretComponent() {
        turnSpeed = 0;
        xStore = -1;
    }

    @Override
    public void start() {
        turnSpeed = 0.01F;
        xStore = -1;
    }

    @Override
    public void update(float delta) {
        SpatialComponent position = (SpatialComponent) gameObject.getComponent(SpatialComponent.class);
        if (position == null) {
            return;
        }
        /*
         float mouseXPosition = Mouse.getX();
         if(xStore == -1) {
         xStore = mouseXPosition;
         } else {
         position.setRotation((mouseXPosition - xStore) * turnSpeed);
         }
         */
    }

    @Override
    public void recieveIntent(ComponentIntent intent) {
        if (intent.getClass() == MouseListenerComponentMoveIntent.class) {
            MouseListenerComponentMoveIntent mouseMoveIntent = (MouseListenerComponentMoveIntent) intent;
            float x = mouseMoveIntent.getX();
            float y = mouseMoveIntent.getY();

            SpatialComponent position = (SpatialComponent) gameObject.getComponent(SpatialComponent.class);
            if (position == null) {
                return;
            }


        }

        System.out.println(intent);
    }
}
TOP

Related Classes of cc.plural.ecs.runtime.PlayerTurretComponent

TOP
Copyright © 2018 www.massapi.com. All rights reserved.
All source code are property of their respective owners. Java is a trademark of Sun Microsystems, Inc and owned by ORACLE Inc. Contact coftware#gmail.com.