package org.inaetics.dronessimulator.drone.components.gun;

import org.inaetics.dronessimulator.common.D3PoolCoordinate;
import org.inaetics.dronessimulator.common.D3Vector;
import org.inaetics.dronessimulator.common.protocol.*;
import org.inaetics.dronessimulator.drone.components.gps.GPS;
import org.inaetics.dronessimulator.drone.droneinit.DroneInit;
import org.inaetics.dronessimulator.pubsub.api.Message;
import org.inaetics.dronessimulator.pubsub.api.publisher.Publisher;
import org.inaetics.dronessimulator.pubsub.api.subscriber.Subscriber;

import java.io.IOException;
import java.util.UUID;

/**
 * Created by mart on 17-5-17.
 */
public class Gun {
    private volatile Subscriber m_subscriber;
    private volatile Publisher m_publisher;
    private volatile DroneInit m_drone;
    private volatile GPS m_gps;
    private final double GUN_SPEED = 50.0;
    private final double MAX_DISTANCE = 100;


    public double getMaxDistance(){
        return MAX_DISTANCE;
    }

    public void fireBullet(D3PoolCoordinate direction){
        FireBulletMessage msg = new FireBulletMessage();
        msg.setDamage(100);
        msg.setFiredById(m_drone.getIdentifier());
        msg.setIdentifier(UUID.randomUUID().toString());
        msg.setType(EntityType.BULLET);
        msg.setDirection(direction);
        msg.setVelocity(direction.toVector().scale(GUN_SPEED / direction.toVector().length()));
        msg.setPosition(m_gps.getPosition());
        msg.setAcceleration(new D3Vector());

        try{
            m_publisher.send(MessageTopic.MOVEMENTS, msg);
        } catch(IOException e){
            System.out.println("Exception");
        }
    }
}

@@ -1610,38 +1610,26 @@
     
-System.out.println(%22Exception%22
+e.printStackTrace(
 );%0A 

Print stacktrace