2018-07-06 15:30:00 +02:00
package com.eu.habbo.habbohotel.items.interactions ;
import com.eu.habbo.Emulator ;
import com.eu.habbo.habbohotel.gameclients.GameClient ;
import com.eu.habbo.habbohotel.items.Item ;
import com.eu.habbo.habbohotel.rooms.* ;
import com.eu.habbo.threading.runnables.KickBallAction ;
import java.sql.ResultSet ;
import java.sql.SQLException ;
2018-10-07 00:28:00 +02:00
public abstract class InteractionPushable extends InteractionDefault {
2018-07-08 23:32:00 +02:00
2018-07-06 15:30:00 +02:00
private KickBallAction currentThread ;
2018-10-07 00:28:00 +02:00
2018-07-06 15:30:00 +02:00
public InteractionPushable ( ResultSet set , Item baseItem ) throws SQLException
{
super ( set , baseItem ) ;
}
public InteractionPushable ( int id , int userId , Item item , String extradata , int limitedStack , int limitedSells )
{
super ( id , userId , item , extradata , limitedStack , limitedSells ) ;
}
2018-10-07 00:28:00 +02:00
2018-07-06 15:30:00 +02:00
@Override
public boolean canWalkOn ( RoomUnit roomUnit , Room room , Object [ ] objects )
{
return true ;
}
@Override
public boolean isWalkable ( )
{
return true ;
}
2018-10-07 00:28:00 +02:00
2018-07-06 15:30:00 +02:00
@Override
public void onWalkOff ( RoomUnit roomUnit , final Room room , Object [ ] objects ) throws Exception
{
super . onWalkOff ( roomUnit , room , objects ) ;
2018-10-07 00:28:00 +02:00
2018-07-06 15:30:00 +02:00
if ( ! ( currentThread = = null | | currentThread . dead ) )
return ;
2018-10-07 00:28:00 +02:00
2018-07-06 15:30:00 +02:00
int velocity = this . getWalkOffVelocity ( roomUnit , room ) ;
RoomUserRotation direction = this . getWalkOffDirection ( roomUnit , room ) ;
this . onKick ( room , roomUnit , velocity , direction ) ;
2018-10-07 00:28:00 +02:00
2018-07-06 15:30:00 +02:00
if ( velocity > 0 )
{
if ( currentThread ! = null )
currentThread . dead = true ;
2018-10-07 00:28:00 +02:00
2018-07-06 15:30:00 +02:00
currentThread = new KickBallAction ( this , room , roomUnit , direction , velocity ) ;
Emulator . getThreading ( ) . run ( currentThread , 0 ) ;
}
}
2018-10-07 00:28:00 +02:00
2018-07-06 15:30:00 +02:00
@Override
public void onClick ( GameClient client , Room room , Object [ ] objects ) throws Exception
{
super . onClick ( client , room , objects ) ;
2018-10-07 00:28:00 +02:00
2018-07-06 15:30:00 +02:00
if ( RoomLayout . tilesAdjecent ( client . getHabbo ( ) . getRoomUnit ( ) . getCurrentLocation ( ) , room . getLayout ( ) . getTile ( this . getX ( ) , this . getY ( ) ) ) )
{
int velocity = this . getTackleVelocity ( client . getHabbo ( ) . getRoomUnit ( ) , room ) ;
RoomUserRotation direction = this . getWalkOnDirection ( client . getHabbo ( ) . getRoomUnit ( ) , room ) ;
this . onTackle ( room , client . getHabbo ( ) . getRoomUnit ( ) , velocity , direction ) ;
2018-10-07 00:28:00 +02:00
2018-07-06 15:30:00 +02:00
if ( velocity > 0 )
{
if ( currentThread ! = null )
currentThread . dead = true ;
2018-10-07 00:28:00 +02:00
2018-07-06 15:30:00 +02:00
currentThread = new KickBallAction ( this , room , client . getHabbo ( ) . getRoomUnit ( ) , direction , velocity ) ;
Emulator . getThreading ( ) . run ( currentThread , 0 ) ;
}
}
}
2018-10-07 00:28:00 +02:00
2018-07-06 15:30:00 +02:00
@Override
public void onWalkOn ( RoomUnit roomUnit , final Room room , Object [ ] objects ) throws Exception
{
super . onWalkOn ( roomUnit , room , objects ) ;
2018-10-07 00:28:00 +02:00
2018-07-06 15:30:00 +02:00
int velocity ;
RoomUserRotation direction ;
2018-10-07 00:28:00 +02:00
2018-07-06 15:30:00 +02:00
if ( this . getX ( ) = = roomUnit . getGoal ( ) . x & & this . getY ( ) = = roomUnit . getGoal ( ) . y ) //User clicked on the tile the ball is on, they want to kick it
{
velocity = this . getWalkOnVelocity ( roomUnit , room ) ;
direction = this . getWalkOnDirection ( roomUnit , room ) ;
this . onKick ( room , roomUnit , velocity , direction ) ;
}
else //User is walking past the ball, they want to drag it with them
{
velocity = this . getDragVelocity ( roomUnit , room ) ;
direction = this . getDragDirection ( roomUnit , room ) ;
this . onDrag ( room , roomUnit , velocity , direction ) ;
}
2018-10-07 00:28:00 +02:00
2018-07-06 15:30:00 +02:00
if ( velocity > 0 )
{
if ( currentThread ! = null )
currentThread . dead = true ;
2018-10-07 00:28:00 +02:00
2018-07-06 15:30:00 +02:00
currentThread = new KickBallAction ( this , room , roomUnit , direction , velocity ) ;
Emulator . getThreading ( ) . run ( currentThread , 0 ) ;
}
}
2018-07-08 23:32:00 +02:00
2018-07-06 15:30:00 +02:00
public abstract int getWalkOnVelocity ( RoomUnit roomUnit , Room room ) ;
2018-10-07 00:28:00 +02:00
2018-07-08 23:32:00 +02:00
2018-07-06 15:30:00 +02:00
public abstract RoomUserRotation getWalkOnDirection ( RoomUnit roomUnit , Room room ) ;
2018-10-07 00:28:00 +02:00
2018-07-08 23:32:00 +02:00
2018-07-06 15:30:00 +02:00
public abstract int getWalkOffVelocity ( RoomUnit roomUnit , Room room ) ;
2018-10-07 00:28:00 +02:00
2018-07-08 23:32:00 +02:00
2018-07-06 15:30:00 +02:00
public abstract RoomUserRotation getWalkOffDirection ( RoomUnit roomUnit , Room room ) ;
2018-10-07 00:28:00 +02:00
2018-07-08 23:32:00 +02:00
2018-07-06 15:30:00 +02:00
public abstract int getDragVelocity ( RoomUnit roomUnit , Room room ) ;
2018-10-07 00:28:00 +02:00
2018-07-08 23:32:00 +02:00
2018-07-06 15:30:00 +02:00
public abstract RoomUserRotation getDragDirection ( RoomUnit roomUnit , Room room ) ;
2018-10-07 00:28:00 +02:00
2018-07-08 23:32:00 +02:00
2018-07-06 15:30:00 +02:00
public abstract int getTackleVelocity ( RoomUnit roomUnit , Room room ) ;
2018-10-07 00:28:00 +02:00
2018-07-08 23:32:00 +02:00
2018-07-06 15:30:00 +02:00
public abstract RoomUserRotation getTackleDirection ( RoomUnit roomUnit , Room room ) ;
2018-10-07 00:28:00 +02:00
2018-07-08 23:32:00 +02:00
2018-07-06 15:30:00 +02:00
public abstract int getNextRollDelay ( int currentStep , int totalSteps ) ; //The length in milliseconds when the ball should next roll
2018-10-07 00:28:00 +02:00
2018-07-08 23:32:00 +02:00
2018-07-06 15:30:00 +02:00
public abstract RoomUserRotation getBounceDirection ( Room room , RoomUserRotation currentDirection ) ; //Returns the new direction to move the ball when the ball cannot move
2018-10-07 00:28:00 +02:00
2018-07-08 23:32:00 +02:00
2018-07-06 15:30:00 +02:00
public abstract boolean validMove ( Room room , RoomTile from , RoomTile to ) ; //Checks if the next move is valid
2018-10-07 00:28:00 +02:00
2018-07-08 23:32:00 +02:00
2018-07-06 15:30:00 +02:00
public abstract void onDrag ( Room room , RoomUnit roomUnit , int velocity , RoomUserRotation direction ) ;
2018-10-07 00:28:00 +02:00
2018-07-08 23:32:00 +02:00
2018-07-06 15:30:00 +02:00
public abstract void onKick ( Room room , RoomUnit roomUnit , int velocity , RoomUserRotation direction ) ;
2018-10-07 00:28:00 +02:00
2018-07-08 23:32:00 +02:00
2018-07-06 15:30:00 +02:00
public abstract void onTackle ( Room room , RoomUnit roomUnit , int velocity , RoomUserRotation direction ) ;
2018-10-07 00:28:00 +02:00
2018-07-08 23:32:00 +02:00
2018-07-06 15:30:00 +02:00
public abstract void onMove ( Room room , RoomTile from , RoomTile to , RoomUserRotation direction , RoomUnit kicker , int nextRoll , int currentStep , int totalSteps ) ;
2018-10-07 00:28:00 +02:00
2018-07-08 23:32:00 +02:00
2018-07-06 15:30:00 +02:00
public abstract void onBounce ( Room room , RoomUserRotation oldDirection , RoomUserRotation newDirection , RoomUnit kicker ) ;
2018-10-07 00:28:00 +02:00
2018-07-08 23:32:00 +02:00
2018-07-06 15:30:00 +02:00
public abstract void onStop ( Room room , RoomUnit kicker , int currentStep , int totalSteps ) ;
2018-10-07 00:28:00 +02:00
2018-07-08 23:32:00 +02:00
2018-07-06 15:30:00 +02:00
public abstract boolean canStillMove ( Room room , RoomTile from , RoomTile to , RoomUserRotation direction , RoomUnit kicker , int nextRoll , int currentStep , int totalSteps ) ;
2018-10-07 00:28:00 +02:00
}