disallow collection via shift when contained (#1677)

liquid_container
David Dormagen 2016-02-10 18:12:09 +01:00
parent 5f895c14fc
commit 77bdc8e841
1 changed files with 73 additions and 64 deletions

View File

@ -63,80 +63,89 @@ public func ObjectControl(int plr, int ctrl, int x, int y, int strength, bool re
return true; return true;
} }
// Quick-pickup item via click? Note that this relies on being executed after the normal Clonk controls // Collection and dropping is only allowed when the Clonk is not contained.
if (ctrl == CON_Use && !this->GetHandItem(0) && !release) if (!Contained())
{ {
var sort = Sort_Distance(x, y); // Quick-pickup item via click? Note that this relies on being executed after the normal Clonk controls
var items = FindAllPickupItems(sort); if (ctrl == CON_Use && !this->GetHandItem(0) && !release)
for (var item in items)
{ {
if (item && TryToCollect(item)) return true; var sort = Sort_Distance(x, y);
var items = FindAllPickupItems(sort);
for (var item in items)
{
if (item && TryToCollect(item)) return true;
}
} }
}
// Begin picking up objects.
// Begin picking up objects. if (ctrl == CON_PickUp && !release)
if (ctrl == CON_PickUp && !release) {
{ this->CancelUse();
this->CancelUse(); BeginPickingUp();
BeginPickingUp(); return true;
return true; }
}
// Drop the mouse item?
// Drop the mouse item? if (ctrl == CON_Drop && !release)
if (ctrl == CON_Drop && !release) {
{ // Do not immediately collect another thing unless chosen with left/right.
// Do not immediately collect another thing unless chosen with left/right. if (this.inventory.is_picking_up)
{
SetNextPickupItem(nil);
}
var item = this->GetHandItem(0);
if (item)
this->DropInventoryItem(this->GetHandItemPos(0));
return true;
}
// Switching pickup object or finish pickup?
if (this.inventory.is_picking_up) if (this.inventory.is_picking_up)
{ {
SetNextPickupItem(nil); // Stop picking up.
if (ctrl == CON_PickUpNext_Stop)
{
AbortPickingUp();
return true;
}
// Quickly pick up everything possible.
if (ctrl == CON_PickUpNext_All)
{
PickUpAll();
AbortPickingUp();
return true;
}
// Finish picking up (aka "collect").
if (ctrl == CON_PickUp && release)
{
EndPickingUp();
return true;
}
// Switch left/right through objects.
var dir = nil;
if (ctrl == CON_PickUpNext_Left) dir = -1;
else if (ctrl == CON_PickUpNext_Right) dir = 1;
if (dir != nil)
{
var item = FindNextPickupObject(this.inventory.pickup_item, dir);
if (item)
SetNextPickupItem(item);
return true;
}
} }
var item = this->GetHandItem(0);
if (item)
this->DropInventoryItem(this->GetHandItemPos(0));
return true;
} }
else // Contained
// Switching pickup object or finish pickup?
if (this.inventory.is_picking_up)
{ {
// Stop picking up. // If we are contained, have a picking up process running, and issue another command we first stop the selection.
if (ctrl == CON_PickUpNext_Stop) if (this.inventory.is_picking_up) AbortPickingUp();
{
AbortPickingUp();
return true;
}
// Quickly pick up everything possible.
if (ctrl == CON_PickUpNext_All)
{
PickUpAll();
AbortPickingUp();
return true;
}
// Finish picking up (aka "collect").
if (ctrl == CON_PickUp && release)
{
EndPickingUp();
return true;
}
// Switch left/right through objects.
var dir = nil;
if (ctrl == CON_PickUpNext_Left) dir = -1;
else if (ctrl == CON_PickUpNext_Right) dir = 1;
if (dir != nil)
{
var item = FindNextPickupObject(this.inventory.pickup_item, dir);
if (item)
SetNextPickupItem(item);
return true;
}
} }
// shift inventory // shift inventory
var inventory_shift = 0; var inventory_shift = 0;
if (ctrl == CON_InventoryShiftForward) inventory_shift = 1; if (ctrl == CON_InventoryShiftForward) inventory_shift = 1;