File confec.cpp changed (mode: 100644) (index b5b3bd0..8802b2c) |
... |
... |
int GetButtonState( std::string *button ); |
795 |
795 |
|
|
796 |
796 |
bool WorldInteract( int ent_index ); |
bool WorldInteract( int ent_index ); |
797 |
797 |
|
|
|
798 |
|
void PlaceEntity( long long place_x, long long place_y ); |
|
799 |
|
|
798 |
800 |
int GetTradingTotal(); |
int GetTradingTotal(); |
799 |
801 |
|
|
800 |
802 |
void BeginTrading(); |
void BeginTrading(); |
|
... |
... |
bool WorldInteract( int ent_index ){ |
3691 |
3693 |
return true; |
return true; |
3692 |
3694 |
} |
} |
3693 |
3695 |
|
|
|
3696 |
|
void PlaceEntity( long long place_x, long long place_y ){ |
|
3697 |
|
if( world.followEntity < 0 || world.entities.empty() ) return; |
|
3698 |
|
auto &player = world.entities[world.followEntity]; |
|
3699 |
|
// Constrain to world bounds. |
|
3700 |
|
if( place_x < 0 ) place_x = 0; |
|
3701 |
|
if( place_y < 0 ) place_y = 0; |
|
3702 |
|
if( place_x > (long long)world.mapInfo[0].size() - 1 ) |
|
3703 |
|
place_x = world.mapInfo[0].size() - 1; |
|
3704 |
|
if( place_y > (long long)world.mapInfo.size() - 1 ) |
|
3705 |
|
place_y = world.mapInfo.size() - 1; |
|
3706 |
|
if( !world.tileBlocking( place_x, place_y, true ) |
|
3707 |
|
&& world.mapEntities[place_y][place_x] < 0xB0 ){ |
|
3708 |
|
// Iterate in reverse order to place the last valid entity. |
|
3709 |
|
for( int i = (int)item_selected.size() - 1; i >= 0; i-- ){ |
|
3710 |
|
auto &item = |
|
3711 |
|
world.items[player.inventory[i].first]; |
|
3712 |
|
if( item_selected[i] |
|
3713 |
|
&& player.inventory[i].second > 0.0 |
|
3714 |
|
&& item.entity.sprite.success ){ |
|
3715 |
|
AddEntity( item.entity, place_x, place_y ); |
|
3716 |
|
player.inventory[i].second--; |
|
3717 |
|
if( player.inventory[i].second == 0.0 ){ |
|
3718 |
|
// Remove the item from the player's inventory. |
|
3719 |
|
player.inventory.erase( player.inventory.begin() + i ); |
|
3720 |
|
// Deselect all. |
|
3721 |
|
item_selected.assign( player.inventory.size(), false ); |
|
3722 |
|
somethingSelected = false; |
|
3723 |
|
} |
|
3724 |
|
// Do not propagate the task. |
|
3725 |
|
player.task = fworld::TASK_NONE; |
|
3726 |
|
// Wake the player and un-stun to avoid a perpetual sleep mode. |
|
3727 |
|
sleep_mode = false; |
|
3728 |
|
player.stun = 0.0; |
|
3729 |
|
// TODO: Sound. |
|
3730 |
|
break; |
|
3731 |
|
} |
|
3732 |
|
} |
|
3733 |
|
} |
|
3734 |
|
} |
|
3735 |
|
|
3694 |
3736 |
int GetTradingTotal(){ |
int GetTradingTotal(){ |
3695 |
3737 |
// Calculate total. |
// Calculate total. |
3696 |
3738 |
int total = 0; |
int total = 0; |
|
... |
... |
void GameLoop( double d ){ |
5812 |
5854 |
}else if( ( entityButtonDown |
}else if( ( entityButtonDown |
5813 |
5855 |
|| ( player.task == fworld::TASK_DROP && player.path.empty() ) ) |
|| ( player.task == fworld::TASK_DROP && player.path.empty() ) ) |
5814 |
5856 |
&& player.stun <= 0.0 && somethingSelected ){ |
&& player.stun <= 0.0 && somethingSelected ){ |
5815 |
|
// Do not propagate the task. |
|
5816 |
|
player.task = fworld::TASK_NONE; |
|
5817 |
5857 |
// Trigger entity placement. |
// Trigger entity placement. |
5818 |
5858 |
static const long long // Up, down, right, left. |
static const long long // Up, down, right, left. |
5819 |
5859 |
offset_x[] = { 0, 0, 1, -1 }, |
offset_x[] = { 0, 0, 1, -1 }, |
|
... |
... |
void GameLoop( double d ){ |
5828 |
5868 |
place_x += offset_x[player.direction]; |
place_x += offset_x[player.direction]; |
5829 |
5869 |
place_y += offset_y[player.direction]; |
place_y += offset_y[player.direction]; |
5830 |
5870 |
} |
} |
|
5871 |
|
PlaceEntity( place_x, place_y ); |
|
5872 |
|
/* |
|
5873 |
|
// Do not propagate the task. |
|
5874 |
|
player.task = fworld::TASK_NONE; |
5831 |
5875 |
if( place_x < 0 ) place_x = 0; |
if( place_x < 0 ) place_x = 0; |
5832 |
5876 |
if( place_y < 0 ) place_y = 0; |
if( place_y < 0 ) place_y = 0; |
5833 |
5877 |
if( place_x > (long long)world.mapInfo[0].size() - 1 ) |
if( place_x > (long long)world.mapInfo[0].size() - 1 ) |
|
... |
... |
void GameLoop( double d ){ |
5858 |
5902 |
} |
} |
5859 |
5903 |
} |
} |
5860 |
5904 |
} |
} |
|
5905 |
|
*/ |
5861 |
5906 |
}else if( fgl::keystates[/*SDL_SCANCODE_GRAVE*/ SDL_SCANCODE_SLASH] |
}else if( fgl::keystates[/*SDL_SCANCODE_GRAVE*/ SDL_SCANCODE_SLASH] |
5862 |
5907 |
&& !fgl::textInputEnabled ){ |
&& !fgl::textInputEnabled ){ |
5863 |
5908 |
// Trigger command input. |
// Trigger command input. |
|
... |
... |
void GameLoop( double d ){ |
6051 |
6096 |
// Trigger an interaction. |
// Trigger an interaction. |
6052 |
6097 |
WorldInteract( world.facingEntity ); |
WorldInteract( world.facingEntity ); |
6053 |
6098 |
} |
} |
|
6099 |
|
}else if( !show_cursor && world.facingEntity < 0 && interactButtonDown ){ |
|
6100 |
|
// Do not propagate the button press. |
|
6101 |
|
interactButtonDown = false; |
|
6102 |
|
actionButtonDown = false; |
|
6103 |
|
// Drop items in front of the player. |
|
6104 |
|
player.path.clear(); |
|
6105 |
|
static const long long // Up, down, right, left. |
|
6106 |
|
offset_x[] = { 0, 0, 1, -1 }, |
|
6107 |
|
offset_y[] = { -1, 1, 0, 0 }; |
|
6108 |
|
long long |
|
6109 |
|
place_x = player.x + 0.5 + offset_x[player.direction], |
|
6110 |
|
place_y = player.y + 0.5 + offset_y[player.direction]; |
|
6111 |
|
PlaceEntity( place_x, place_y ); |
6054 |
6112 |
}else if( mouse_on_world |
}else if( mouse_on_world |
6055 |
6113 |
&& world.cursorOverEntity >= 0 && show_cursor ){ |
&& world.cursorOverEntity >= 0 && show_cursor ){ |
6056 |
6114 |
// The cursor is visible over an entity and not over the inventory. |
// The cursor is visible over an entity and not over the inventory. |