Skip to content

Commit

Permalink
I dont think we need to do it like this
Browse files Browse the repository at this point in the history
  • Loading branch information
FalloutFalcon committed Apr 29, 2024
1 parent b6c472b commit 5936ef8
Show file tree
Hide file tree
Showing 2 changed files with 5 additions and 30 deletions.
32 changes: 5 additions & 27 deletions code/datums/components/attachment.dm
Original file line number Diff line number Diff line change
Expand Up @@ -7,32 +7,10 @@
#define COMSIG_ATTACHMENT_UPDATE_OVERLAY "attach-overlay"

#define COMSIG_ATTACHMENT_GET_SLOT "attach-slot-who"
#define ATTACHMENT_SLOT_MUZZLE "attach-slot-muzzle"
#define ATTACHMENT_SLOT_SCOPE "attach-slot-scope"
#define ATTACHMENT_SLOT_GRIP "attach-slot-grip"
#define ATTACHMENT_SLOT_RAIL "attach-slot-rail"

/proc/attachment_slot_to_bflag(slot)
switch(slot)
if(ATTACHMENT_SLOT_MUZZLE)
return (1<<0)
if(ATTACHMENT_SLOT_SCOPE)
return (1<<1)
if(ATTACHMENT_SLOT_GRIP)
return (1<<2)
if(ATTACHMENT_SLOT_RAIL)
return (1<<3)

/proc/attachment_slot_from_bflag(slot)
switch(slot)
if(1<<0)
return ATTACHMENT_SLOT_MUZZLE
if(1<<1)
return ATTACHMENT_SLOT_SCOPE
if(1<<2)
return ATTACHMENT_SLOT_GRIP
if(1<<3)
return ATTACHMENT_SLOT_RAIL
#define ATTACHMENT_SLOT_MUZZLE "attach-slot-muzzle"
#define ATTACHMENT_SLOT_SCOPE "attach-slot-scope"
#define ATTACHMENT_SLOT_GRIP "attach-slot-grip"
#define ATTACHMENT_SLOT_RAIL "attach-slot-rail"

#define COMSIG_ATTACHMENT_TOGGLE "attach-toggle"

Expand Down Expand Up @@ -150,4 +128,4 @@

/datum/component/attachment/proc/send_slot(obj/item/parent)
SIGNAL_HANDLER
return attachment_slot_to_bflag(slot)
return slot
3 changes: 0 additions & 3 deletions code/datums/components/attachment_holder.dm
Original file line number Diff line number Diff line change
Expand Up @@ -40,7 +40,6 @@

for(var/obj/item/attachment/attach as anything in attachments)
var/slot = SEND_SIGNAL(attach, COMSIG_ATTACHMENT_GET_SLOT)
slot = attachment_slot_from_bflag(slot)
var/list/attach_overlays = list()
SEND_SIGNAL(attach, COMSIG_ATTACHMENT_UPDATE_OVERLAY, attach_overlays)
for(var/mutable_appearance/overlay as anything in attach_overlays)
Expand Down Expand Up @@ -101,7 +100,6 @@

/datum/component/attachment_holder/proc/do_attach(obj/item/attachment, mob/user)
var/slot = SEND_SIGNAL(attachment, COMSIG_ATTACHMENT_GET_SLOT)
slot = attachment_slot_from_bflag(slot)
if(!(attachment.type in valid_types))
to_chat(user, "<span class='notice'>[attachment] is not a valid attachment for this [parent]!</span>")
return
Expand All @@ -117,7 +115,6 @@

/datum/component/attachment_holder/proc/do_detach(obj/item/attachment, mob/user)
var/slot = SEND_SIGNAL(attachment, COMSIG_ATTACHMENT_GET_SLOT)
slot = attachment_slot_from_bflag(slot)
if(slot in slot_room)
slot_room[slot]++
. = SEND_SIGNAL(attachment, COMSIG_ATTACHMENT_DETACH, parent, user)
Expand Down

0 comments on commit 5936ef8

Please sign in to comment.