|
@@ -15,7 +15,7 @@ ActionTarget::ActionTarget( int entityId )
|
|
|
: entityId( entityId )
|
|
|
{}
|
|
|
|
|
|
-void ActionTarget::applyItemSkillOnTarget( Entity* zActor, ItemSkill* zItemSkill, Item* zUsedItem, Game* zGame )
|
|
|
+void ActionTarget::applyItemSkillOnTarget( Entity* zActor, ItemSkill* zItemSkill, Item* zUsedItem )
|
|
|
{
|
|
|
if( entityId >= 0 )
|
|
|
{
|
|
@@ -23,19 +23,19 @@ void ActionTarget::applyItemSkillOnTarget( Entity* zActor, ItemSkill* zItemSkill
|
|
|
}
|
|
|
else
|
|
|
{
|
|
|
- Block* block = zGame->zRealBlockInstance( blockPos, zActor->getCurrentDimensionId() );
|
|
|
+ Block* block = Game::INSTANCE->zRealBlockInstance( blockPos, zActor->getCurrentDimensionId() );
|
|
|
if( block )
|
|
|
zItemSkill->use( zActor, zUsedItem, block );
|
|
|
}
|
|
|
}
|
|
|
|
|
|
-void ActionTarget::placeBlock( Entity* zActor, Item* zItem, Game* zGame )
|
|
|
+void ActionTarget::placeBlock( Entity* zActor, Item* zItem )
|
|
|
{
|
|
|
// TODO: check stamina of actor
|
|
|
- Block* block = zItem->zPlacedBlockType()->createBlockAt( blockPos + getDirection( targetBlockSide ), zGame, zItem );
|
|
|
+ Block* block = zItem->zPlacedBlockType()->createBlockAt( blockPos + getDirection( targetBlockSide ), zItem );
|
|
|
if( block )
|
|
|
{
|
|
|
- if( zGame->requestWorldUpdate( new PlaceBlockUpdate( block, zActor->getCurrentDimensionId() ) ) )
|
|
|
+ if( Game::INSTANCE->requestWorldUpdate( new PlaceBlockUpdate( block, zActor->getCurrentDimensionId() ) ) )
|
|
|
{
|
|
|
zItem->onPlaced();
|
|
|
// TODO: decrese stamina of actor
|
|
@@ -78,7 +78,7 @@ Entity::Entity( const EntityType* zType, Framework::Vec3<float> location, int di
|
|
|
void Entity::onDeath()
|
|
|
{}
|
|
|
|
|
|
-void Entity::useItem( const ItemType* zType, Item* zItem, Game* zGame )
|
|
|
+void Entity::useItem( const ItemType* zType, Item* zItem )
|
|
|
{
|
|
|
if( zItem && zItem->isEatable() )
|
|
|
{ // TODO: eat item
|
|
@@ -87,7 +87,7 @@ void Entity::useItem( const ItemType* zType, Item* zItem, Game* zGame )
|
|
|
else if( zItem && zItem->isPlaceable() )
|
|
|
{ // TODO: place item
|
|
|
if( target )
|
|
|
- target->placeBlock( this, zItem, zGame );
|
|
|
+ target->placeBlock( this, zItem );
|
|
|
}
|
|
|
else if( !zItem || zItem->isUsable() )
|
|
|
{ // use item skill
|
|
@@ -107,12 +107,12 @@ void Entity::useItem( const ItemType* zType, Item* zItem, Game* zGame )
|
|
|
selected = zType->createDefaultItemSkill();
|
|
|
skills.add( selected );
|
|
|
}
|
|
|
- target->applyItemSkillOnTarget( this, selected, zItem, zGame );
|
|
|
+ target->applyItemSkillOnTarget( this, selected, zItem );
|
|
|
}
|
|
|
}
|
|
|
}
|
|
|
|
|
|
-void Entity::prepareTick( const Dimension* zDimension, Game* zGame )
|
|
|
+void Entity::prepareTick( const Dimension* zDimension )
|
|
|
{
|
|
|
Vec3<float> headPosition = location + faceOffset;
|
|
|
int px = (int)floor( headPosition.x );
|
|
@@ -122,7 +122,7 @@ void Entity::prepareTick( const Dimension* zDimension, Game* zGame )
|
|
|
Direction dir = BOTTOM;
|
|
|
while( true )
|
|
|
{
|
|
|
- if( getDefaultBlock( zGame->zBlockAt( Vec3<int>{ px, py, pz }, zDimension->getDimensionId() ) )->isInteractable() )
|
|
|
+ if( getDefaultBlock( Game::INSTANCE->zBlockAt( Vec3<int>{ px, py, pz }, zDimension->getDimensionId() ) )->isInteractable() )
|
|
|
{
|
|
|
delete target;
|
|
|
target = new ActionTarget( { px, py, pz }, dir );
|
|
@@ -201,7 +201,7 @@ void Entity::prepareTick( const Dimension* zDimension, Game* zGame )
|
|
|
}
|
|
|
}
|
|
|
|
|
|
-void Entity::tick( const Dimension* zDimension, Game* zGame )
|
|
|
+void Entity::tick( const Dimension* zDimension )
|
|
|
{
|
|
|
Vec3<float> oldPos = location;
|
|
|
// current block cooredinates
|
|
@@ -224,7 +224,7 @@ void Entity::tick( const Dimension* zDimension, Game* zGame )
|
|
|
Vec3<float> tmp = oldPos + frameSpeed * xt;
|
|
|
if( xt <= 1.f && tmp.y >= (float)py && tmp.y < (float)py + 1.f && tmp.z >= (float)pz && tmp.z < (float)pz + 1.f )
|
|
|
{
|
|
|
- if( !getDefaultBlock( zGame->zBlockAt( Vec3<int>{ px + 1, py, pz }, zDimension->getDimensionId() ) )->isPassable() )
|
|
|
+ if( !getDefaultBlock( Game::INSTANCE->zBlockAt( Vec3<int>{ px + 1, py, pz }, zDimension->getDimensionId() ) )->isPassable() )
|
|
|
{
|
|
|
frameSpeed.x = frameSpeed.x * (xt - 0.1f);
|
|
|
speed.x = 0;
|
|
@@ -241,7 +241,7 @@ void Entity::tick( const Dimension* zDimension, Game* zGame )
|
|
|
Vec3<float> tmp = oldPos + frameSpeed * xt;
|
|
|
if( xt <= 1.f && tmp.y >= (float)py && tmp.y < (float)py + 1.f && tmp.z >= (float)pz && tmp.z < (float)pz + 1.f )
|
|
|
{
|
|
|
- if( !getDefaultBlock( zGame->zBlockAt( Vec3<int>{ px - 1, py, pz }, zDimension->getDimensionId() ) )->isPassable() )
|
|
|
+ if( !getDefaultBlock( Game::INSTANCE->zBlockAt( Vec3<int>{ px - 1, py, pz }, zDimension->getDimensionId() ) )->isPassable() )
|
|
|
{
|
|
|
frameSpeed.x = frameSpeed.x * (xt - 0.1f);
|
|
|
speed.x = 0;
|
|
@@ -258,7 +258,7 @@ void Entity::tick( const Dimension* zDimension, Game* zGame )
|
|
|
Vec3<float> tmp = oldPos + frameSpeed * yt;
|
|
|
if( yt <= 1.f && tmp.x >= (float)px && tmp.x < (float)px + 1.f && tmp.z >= (float)pz && tmp.z < (float)pz + 1.f )
|
|
|
{
|
|
|
- if( !getDefaultBlock( zGame->zBlockAt( Vec3<int>{ px, py + 1, pz }, zDimension->getDimensionId() ) )->isPassable() )
|
|
|
+ if( !getDefaultBlock( Game::INSTANCE->zBlockAt( Vec3<int>{ px, py + 1, pz }, zDimension->getDimensionId() ) )->isPassable() )
|
|
|
{
|
|
|
frameSpeed.y = frameSpeed.y * (yt - 0.1f);
|
|
|
speed.y = 0;
|
|
@@ -275,7 +275,7 @@ void Entity::tick( const Dimension* zDimension, Game* zGame )
|
|
|
Vec3<float> tmp = oldPos + frameSpeed * yt;
|
|
|
if( yt <= 1.f && tmp.x >= (float)px && tmp.x < (float)px + 1.f && tmp.z >= (float)pz && tmp.z < (float)pz + 1.f )
|
|
|
{
|
|
|
- if( !getDefaultBlock( zGame->zBlockAt( Vec3<int>{ px, py - 1, pz }, zDimension->getDimensionId() ) )->isPassable() )
|
|
|
+ if( !getDefaultBlock( Game::INSTANCE->zBlockAt( Vec3<int>{ px, py - 1, pz }, zDimension->getDimensionId() ) )->isPassable() )
|
|
|
{
|
|
|
frameSpeed.y = frameSpeed.y * (yt - 0.1f);
|
|
|
speed.y = 0;
|
|
@@ -292,7 +292,7 @@ void Entity::tick( const Dimension* zDimension, Game* zGame )
|
|
|
Vec3<float> tmp = oldPos + frameSpeed * zt;
|
|
|
if( zt <= 1.f && tmp.x >= (float)px && tmp.x < (float)px + 1.f && tmp.y >= (float)py && tmp.y < (float)py + 1.f )
|
|
|
{
|
|
|
- if( !getDefaultBlock( zGame->zBlockAt( Vec3<int>{ px, py, pz + 1 }, zDimension->getDimensionId() ) )->isPassable() )
|
|
|
+ if( !getDefaultBlock( Game::INSTANCE->zBlockAt( Vec3<int>{ px, py, pz + 1 }, zDimension->getDimensionId() ) )->isPassable() )
|
|
|
{
|
|
|
frameSpeed.z = frameSpeed.z * (zt - 0.1f);
|
|
|
speed.z = 0;
|
|
@@ -309,7 +309,7 @@ void Entity::tick( const Dimension* zDimension, Game* zGame )
|
|
|
Vec3<float> tmp = oldPos + frameSpeed * zt;
|
|
|
if( zt <= 1.f && tmp.x >= (float)px && tmp.x < (float)px + 1.f && tmp.y >= (float)py && tmp.y < (float)py + 1 )
|
|
|
{
|
|
|
- if( !getDefaultBlock( zGame->zBlockAt( Vec3<int>{ px, py, pz - 1 }, zDimension->getDimensionId() ) )->isPassable() )
|
|
|
+ if( !getDefaultBlock( Game::INSTANCE->zBlockAt( Vec3<int>{ px, py, pz - 1 }, zDimension->getDimensionId() ) )->isPassable() )
|
|
|
{
|
|
|
frameSpeed.z = frameSpeed.z * (zt - 0.1f);
|
|
|
onFall( speed.z );
|