<commit_before>package com.google.sprint1;

import com.metaio.sdk.jni.IGeometry;
import com.metaio.sdk.jni.Rotation;
import com.metaio.sdk.jni.Vector3d;

public class PaintBall extends Drawable 
{
	public static final String TAG = "PaintBall";
	
	private IGeometry geometry; 
	private IGeometry splashGeometry;
	private IGeometry paintballShadow;
	private int id; 
	private int playerId;
	private boolean isActive;
	private final MobileConnection connection;
	
	public PaintBall(int id, IGeometry geo, IGeometry splGeo, IGeometry pbShad, int playerID) {
		super();
	
		connection = GameState.getState().connection;
		
		this.id = id;
		geometry = geo;
		splashGeometry = splGeo;
		paintballShadow = pbShad;
		playerId = playerID;
		
		startPosition= new Vector3d(0.0f,0.0f,0.0f);
		startVelocity= new Vector3d(0.0f,0.0f,0.0f);
		startTime = 0;
		
		setGeometryProperties(geometry, 2f, new Vector3d(0f, 0f, 0f), new Rotation(0f, 0f, 0f));
		setGeometryProperties(splashGeometry, 2f, new Vector3d(0f, 0f, 0f), new Rotation(0f, 0f, 0f));
		setGeometryProperties(paintballShadow, 0.7f, new Vector3d(0f, 0f, 0f), new Rotation((float) (3*Math.PI/2), 0f, 0f));
		geometry.setVisible(false);	
		splashGeometry.setVisible(false);
		paintballShadow.setVisible(false);
		isActive = false;
		
		}
	
	//return the id of the player who ownes the paintball
	public int getPlayerId()
	{
		return playerId;
	}
		
	public IGeometry getGeometry()
	{
		return geometry;
	}
	
	public void setPosition(Vector3d vec)
	{
		geometry.setTranslation(vec);
	}
	
	public int getId()
	{
		return id;
	}
	
	public void setId(int ID)
	{
		id = ID;
	}
	
	/** Called every frame. Updates position and checks if on the ground */
	public void update(){
		
		if(isActive)
		{
			physicsPositionCalibration();
			paintballShadow.setTranslation(new Vector3d(geometry.getTranslation().getX(),
					  									geometry.getTranslation().getY(),
					  									0f));
		}
		// checks for collision with ground 	
		if(geometry.getTranslation().getZ() <= 0f)
		{	
			disable();
		}
		checkCollisions();
		
	}
	
	private void checkCollisions(){
		
		//Check for collision with ants
		for(int i = 0; i < GameActivity.getNrOfAnts() ; i++)
		{
			if (checkCollision(GameState.getState().ants.get(i).getGeometry())) { 
				//GameState.getState().ants.get(i).ant.setRotation(new Rotation( (float) (3 * Math.PI / 4), 0f, 0f), true);
				
				connection.sendData(NetDataHandler.antHit(i, getPlayerId(), getId()));
				GameState.getState().ants.get(i).setIsHit(true, getPlayerId());
				
				disable();
			}
		}
		
		for (int i = 0; i < GameState.getState().powerUps.size(); i++)
		{
			if (checkCollision(GameState.getState().powerUps.get(i).getGeometry()) && isActive == true) {
				//player.superPower = true;
				GameState.getState().powerUps.get(i).setHit();
			}
		}
	}
	/** Check if paintball is current active */
	public boolean isActive()
	{
		return isActive;
	}<commit_msg>PaintBall now only checks collisions for the owner<commit_after>package com.google.sprint1;

import com.metaio.sdk.jni.IGeometry;
import com.metaio.sdk.jni.Rotation;
import com.metaio.sdk.jni.Vector3d;

public class PaintBall extends Drawable 
{
	public static final String TAG = "PaintBall";
	
	private IGeometry geometry; 
	private IGeometry splashGeometry;
	private IGeometry paintballShadow;
	private int id; 
	private int playerId;
	private boolean isActive;
	private final MobileConnection connection;
	
	public PaintBall(int id, IGeometry geo, IGeometry splGeo, IGeometry pbShad, int playerID) {
		super();
	
		connection = GameState.getState().connection;
		
		this.id = id;
		geometry = geo;
		splashGeometry = splGeo;
		paintballShadow = pbShad;
		playerId = playerID;
		
		startPosition= new Vector3d(0.0f,0.0f,0.0f);
		startVelocity= new Vector3d(0.0f,0.0f,0.0f);
		startTime = 0;
		
		setGeometryProperties(geometry, 2f, new Vector3d(0f, 0f, 0f), new Rotation(0f, 0f, 0f));
		setGeometryProperties(splashGeometry, 2f, new Vector3d(0f, 0f, 0f), new Rotation(0f, 0f, 0f));
		setGeometryProperties(paintballShadow, 0.7f, new Vector3d(0f, 0f, 0f), new Rotation((float) (3*Math.PI/2), 0f, 0f));
		geometry.setVisible(false);	
		splashGeometry.setVisible(false);
		paintballShadow.setVisible(false);
		isActive = false;
		
		}
	
	//return the id of the player who ownes the paintball
	public int getPlayerId()
	{
		return playerId;
	}
		
	public IGeometry getGeometry()
	{
		return geometry;
	}
	
	public void setPosition(Vector3d vec)
	{
		geometry.setTranslation(vec);
	}
	
	public int getId()
	{
		return id;
	}
	
	public void setId(int ID)
	{
		id = ID;
	}
	
	/** Called every frame. Updates position and checks if on the ground */
	public void update(){
		
		if(isActive)
		{
			physicsPositionCalibration();
			paintballShadow.setTranslation(new Vector3d(geometry.getTranslation().getX(),
					  									geometry.getTranslation().getY(),
					  									0f));
		}
		// checks for collision with ground 	
		if(geometry.getTranslation().getZ() <= 0f)
		{	
			disable();
		}
		if(getPlayerId() == GameState.getState().myPlayerID)
			checkCollisions();
		
	}
	
	private void checkCollisions(){
		
		//Check for collision with ants
		for(int i = 0; i < GameActivity.getNrOfAnts() ; i++)
		{
			if (checkCollision(GameState.getState().ants.get(i).getGeometry())) { 
				//GameState.getState().ants.get(i).ant.setRotation(new Rotation( (float) (3 * Math.PI / 4), 0f, 0f), true);
				
				connection.sendData(NetDataHandler.antHit(i, getPlayerId(), getId()));
				GameState.getState().ants.get(i).setIsHit(true, getPlayerId());
				
				disable();
			}
		}
		
		for (int i = 0; i < GameState.getState().powerUps.size(); i++)
		{
			if (checkCollision(GameState.getState().powerUps.get(i).getGeometry()) && isActive == true) {
				//player.superPower = true;
				GameState.getState().powerUps.get(i).setHit();
			}
		}
	}
	/** Check if paintball is current active */
	public boolean isActive()
	{
		return isActive;
	}
{'fraction_non_alphanumeric': 0.13169830337644886, 'fraction_numerical': 0.017806148160591298, 'mean_word_length': 3.7404458598726116, 'pattern_counts': {'":': 0, '<': 9, '<?xml version=': 0, '>': 3, 'https://': 0, 'lorem ipsum': 0, 'www.': 0, 'xml': 0}, 'pii_count': 0, 'substrings_counts': 0, 'word_list_counts': {'cursed_substrings.json': 0, 'profanity_word_list.json': 0, 'sexual_word_list.json': 0, 'zh_pornsignals.json': 0}}
{'dir': 'git-commits-cleaned', 'id': '4659370', 'n_tokens_mistral': 2420, 'n_tokens_neox': 2056, 'n_words': 469}