Adjust interaction menu object ordering.

The clonk opening the menu should always have higher priority so the clonk is predictably selected on the left side even if standing behind e.g. a crate.

Other clonks should be behind because interaction with them is rare but having your fellow players stand in front of a building is very common. Allies also tend to run in front just when you opened that menu.
shapetextures
Sven Eberhardt 2015-09-15 21:13:53 -04:00
parent 9ec3ca0304
commit bf1596a229
2 changed files with 23 additions and 2 deletions

View File

@ -142,7 +142,10 @@ func FxIntCheckObjectsTimer(target, effect fx)
// Find only vehicles and structures (plus Clonks ("livings") and helper objects). This makes sure that no C4D_Object-containers (extra slot) are shown.
Find_Or(Find_Category(C4D_Vehicle), Find_Category(C4D_Structure), Find_OCF(OCF_Alive), Find_ActionTarget(target), Find_Func("IsContainerEx")),
// But these objects still need to either be a container or provide an own interaction menu.
Find_Or(Find_Func("IsContainer"), Find_Func("HasInteractionMenu")), Find_Func("CheckVisibility", GetOwner()));
Find_Or(Find_Func("IsContainer"), Find_Func("HasInteractionMenu")), Find_Func("CheckVisibility", GetOwner()),
// Normally sorted by z-order. But some objects may have a lower priority.
Sort_Reverse(Sort_Func("GetInteractionPriority", target))
);
var equal = GetLength(new_objects) == GetLength(current_objects);
if (equal)

View File

@ -1362,4 +1362,22 @@ func ExecuteInteraction(proplist action_info)
if(action_info.extra_data)
action_info.extra_data.Object->Call(action_info.extra_data.Fn, this);
}
}
}
// Interaction with clonks is special:
// * The clonk opening the menu should always have higher priority so the clonk is predictably selected on the left side even if standing behind e.g. a crate
// * Other clonks should be behind because interaction with them is rare but having your fellow players stand in front of a building is very common
// (Allies also tend to run in front just when you opened that menu...)
func GetInteractionPriority(object target)
{
// Self with high priority
if (target == this) return 100;
var owner = NO_OWNER;
if (target) owner = target->GetOwner();
// Prefer own clonks for item transfer
if (owner == GetOwner()) return -100;
// If no own clonk, prefer friendly
if (!Hostile(owner, GetOwner())) return -120;
// Hostile clonks? Lowest priority.
return -200;
}