forked from ss220-space/Paradise
-
Notifications
You must be signed in to change notification settings - Fork 0
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
refactor: LootPanel И большой рефактор Альт Клика (ss220-space#6598)
* a * bugfix: LootPanel И большой рефактор Альт Клика * fixes
- Loading branch information
1 parent
4297798
commit c11e2e1
Showing
136 changed files
with
874 additions
and
794 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,8 @@ | ||
/// Action has succeeded, preventing further alt click interaction | ||
#define CLICK_ACTION_SUCCESS (1<<0) | ||
/// Action failed, preventing further alt click interaction | ||
#define CLICK_ACTION_BLOCKING (1<<1) | ||
/// Either return state | ||
#define CLICK_ACTION_ANY (CLICK_ACTION_SUCCESS | CLICK_ACTION_BLOCKING) | ||
|
||
/// Use NONE for continue interaction |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,3 @@ | ||
#define DEFAULT_SIGHT_DISTANCE 7 | ||
/// Basic check to see if the src object can see the target object. | ||
#define CAN_I_SEE(target) ((src in viewers(DEFAULT_SIGHT_DISTANCE, target)) || in_range(target, src)) |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,88 @@ | ||
///Main proc for primary alt click | ||
/mob/proc/AltClickOn(atom/target) | ||
base_click_alt(target) | ||
|
||
/** | ||
* ### Base proc for alt click interaction. Returns if the click was intercepted & handled | ||
* | ||
* If you wish to add custom `click_alt` behavior for a single type, use that proc. | ||
*/ | ||
/mob/proc/base_click_alt(atom/target) | ||
SHOULD_NOT_OVERRIDE(TRUE) | ||
|
||
// Check if they've hooked in to prevent src from alt clicking anything | ||
//if(SEND_SIGNAL(src, COMSIG_MOB_ALTCLICKON, target) & COMSIG_MOB_CANCEL_CLICKON) | ||
// return TRUE | ||
|
||
// Ghosties just see loot | ||
if(isobserver(src)) | ||
client.loot_panel.open(get_turf(target)) | ||
return | ||
|
||
// If it has a signal handler that returns a click action, done. | ||
if(SEND_SIGNAL(target, COMSIG_CLICK_ALT, src) & CLICK_ACTION_ANY) | ||
return TRUE | ||
|
||
// If it has a custom click_alt that returns success/block, done. | ||
if(can_perform_action(target, (target.interaction_flags_click | SILENT_ADJACENCY))) | ||
return target.click_alt(src) & CLICK_ACTION_ANY | ||
|
||
// No alt clicking to view turf from beneath | ||
if(HAS_TRAIT(src, TRAIT_MOVE_VENTCRAWLING)) | ||
return | ||
|
||
client.loot_panel.open(get_turf(target)) | ||
|
||
return FALSE | ||
|
||
/mob/living/base_click_alt(atom/target) | ||
SHOULD_NOT_OVERRIDE(TRUE) | ||
|
||
if(..()) | ||
return | ||
if(!CAN_I_SEE(target) || (!has_vision() && !IN_GIVEN_RANGE(src, target, 1))) | ||
return | ||
|
||
// No alt clicking to view turf from beneath | ||
if(HAS_TRAIT(src, TRAIT_MOVE_VENTCRAWLING)) | ||
return | ||
|
||
/// No loot panel if it's on our person | ||
if(isobj(target) && (target in get_all_gear())) | ||
to_chat(src, span_warning("You can't search for this item, it's already in your inventory! Take it off first.")) | ||
return | ||
|
||
client.loot_panel.open(get_turf(target)) | ||
return TRUE | ||
|
||
|
||
/** | ||
* ## Custom alt click interaction | ||
* Override this to change default alt click behavior. Return `CLICK_ACTION_SUCCESS`, `CLICK_ACTION_BLOCKING` or `NONE`. | ||
* | ||
* ### Guard clauses | ||
* Consider adding `interaction_flags_click` before adding unique guard clauses. | ||
* | ||
* ### Return flags | ||
* Forgetting your return will cause the default alt click behavior to occur thereafter. | ||
* | ||
* The difference between NONE and BLOCKING can get hazy, but I like to keep NONE limited to guard clauses and "never" cases. | ||
* | ||
* A good usage for BLOCKING over NONE is when it's situational for the item and there's some feedback indicating this. | ||
* | ||
* ### Examples: | ||
* User is a ghost, alt clicks on item with special disk eject: NONE | ||
* | ||
* Machine broken, no feedback: NONE | ||
* | ||
* Alt click a pipe to max output but its already max: BLOCKING | ||
* | ||
* Alt click a gun that normally works, but is out of ammo: BLOCKING | ||
* | ||
* User unauthorized, machine beeps: BLOCKING | ||
* | ||
* @param {mob} user - The person doing the alt clicking. | ||
*/ | ||
/atom/proc/click_alt(mob/user) | ||
SHOULD_CALL_PARENT(FALSE) | ||
return NONE |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Oops, something went wrong.