mirror of
https://github.com/Bubberstation/Bubberstation.git
synced 2026-08-26 06:29:23 +01:00
Ports duplicated slipping code to a component (#29628)
* Ports duplicated slipping code to a component * Makes metal not slippery * asdf * Instead of cherry picking like an idiot I could just copy paster * OOP * And blood, don't forget Fry's blood! * Further fixes * A more generic fashion * Use the new system * Fixes * Fix cartridge type * Remove inertia
This commit is contained in:
@@ -14,3 +14,5 @@
|
||||
#define COMSIG_COMPONENT_ADDED "component_added" //when a component is added to a datum: (datum/component)
|
||||
#define COMSIG_COMPONENT_REMOVING "component_removing" //before a component is removed from a datum because of RemoveComponent: (datum/component)
|
||||
#define COMSIG_PARENT_QDELETED "parent_qdeleted" //before a datum's Destroy() is called: ()
|
||||
#define COMSIG_ATOM_ENTERED "atom_entered" //from base of atom/Entered(): (atom/movable, atom)
|
||||
#define COMSIG_MOVABLE_CROSSED "movable_crossed" //from base of atom/movable/Crossed(): (atom/movable)
|
||||
|
||||
@@ -75,6 +75,8 @@ Stands have a lot of procs which mimic mob procs. Rather than inserting hooks fo
|
||||
* Called on a component when a component of the same type was added to the same parent
|
||||
* See `/datum/component/var/dupe_mode`
|
||||
* `C`'s type will always be the same of the called component
|
||||
1. `/datum/component/proc/AfterComponentActivated()` (abstract)
|
||||
* Called on a component that was activated after it's `parent`'s `ComponentActivated()` is called
|
||||
1. `/datum/component/proc/OnTransfer(datum/new_parent)` (abstract)
|
||||
* Called before the new `parent` is assigned in `TakeComponent()`, after the remove signal, before the added signal
|
||||
* Allows the component to react to ownership transfers
|
||||
|
||||
@@ -110,6 +110,9 @@
|
||||
/datum/component/proc/OnTransfer(datum/new_parent)
|
||||
return
|
||||
|
||||
/datum/component/proc/AfterComponentActivated()
|
||||
return
|
||||
|
||||
/datum/component/proc/_GetInverseTypeList(current_type)
|
||||
. = list(current_type)
|
||||
while (current_type != /datum/component)
|
||||
@@ -126,6 +129,7 @@
|
||||
var/datum/component/C = target
|
||||
if(C.enabled && C.ReceiveSignal(arglist(args)))
|
||||
ComponentActivated(C)
|
||||
C.AfterComponentActivated()
|
||||
return TRUE
|
||||
else
|
||||
for(var/I in target)
|
||||
|
||||
@@ -0,0 +1,22 @@
|
||||
/datum/component/slippery
|
||||
var/intensity
|
||||
var/lube_flags
|
||||
var/mob/slip_victim
|
||||
|
||||
/datum/component/slippery/New(datum/P, _intensity, _lube_flags = NONE)
|
||||
..()
|
||||
intensity = max(_intensity, 0)
|
||||
lube_flags = _lube_flags
|
||||
if(ismovableatom(P))
|
||||
RegisterSignal(COMSIG_MOVABLE_CROSSED, .proc/Slip)
|
||||
else
|
||||
RegisterSignal(COMSIG_ATOM_ENTERED, .proc/Slip)
|
||||
|
||||
/datum/component/slippery/proc/Slip(atom/movable/AM)
|
||||
var/mob/victim = AM
|
||||
if(istype(victim) && !victim.is_flying() && victim.slip(intensity, parent, lube_flags))
|
||||
slip_victim = victim
|
||||
return TRUE
|
||||
|
||||
/datum/component/slippery/AfterComponentActivated()
|
||||
slip_victim = null
|
||||
@@ -610,3 +610,6 @@ GLOBAL_LIST_EMPTY(blood_splatter_icons)
|
||||
.["Add reagent"] = "?_src_=vars;addreagent=\ref[src]"
|
||||
.["Trigger EM pulse"] = "?_src_=vars;emp=\ref[src]"
|
||||
.["Trigger explosion"] = "?_src_=vars;explode=\ref[src]"
|
||||
|
||||
/atom/Entered(atom/movable/AM, atom/oldLoc)
|
||||
SendSignal(COMSIG_ATOM_ENTERED, AM, oldLoc)
|
||||
|
||||
@@ -215,7 +215,7 @@
|
||||
// This is automatically called when something enters your square
|
||||
//oldloc = old location on atom, inserted when forceMove is called and ONLY when forceMove is called!
|
||||
/atom/movable/Crossed(atom/movable/AM, oldloc)
|
||||
return
|
||||
SendSignal(COMSIG_MOVABLE_CROSSED, AM)
|
||||
|
||||
|
||||
//This is tg's equivalent to the byond bump, it used to be called bump with a second arg
|
||||
|
||||
@@ -29,6 +29,9 @@
|
||||
metal = ALUMINUM_FOAM
|
||||
icon_state = "mfoam"
|
||||
|
||||
/obj/effect/particle_effect/foam/metal/MakeSlippery()
|
||||
return
|
||||
|
||||
/obj/effect/particle_effect/foam/metal/iron
|
||||
name = "iron foam"
|
||||
metal = IRON_FOAM
|
||||
@@ -38,12 +41,16 @@
|
||||
metal = RESIN_FOAM
|
||||
|
||||
|
||||
/obj/effect/particle_effect/foam/New(loc)
|
||||
..(loc)
|
||||
/obj/effect/particle_effect/foam/Initialize()
|
||||
. = ..()
|
||||
MakeSlippery()
|
||||
create_reagents(1000) //limited by the size of the reagent holder anyway.
|
||||
START_PROCESSING(SSfastprocess, src)
|
||||
playsound(src, 'sound/effects/bubbles2.ogg', 80, 1, -3)
|
||||
|
||||
/obj/effect/particle_effect/foam/proc/MakeSlippery()
|
||||
AddComponent(/datum/component/slippery, 100)
|
||||
|
||||
/obj/effect/particle_effect/foam/Destroy()
|
||||
STOP_PROCESSING(SSfastprocess, src)
|
||||
return ..()
|
||||
@@ -101,15 +108,6 @@
|
||||
lifetime--
|
||||
return 1
|
||||
|
||||
/obj/effect/particle_effect/foam/Crossed(atom/movable/AM)
|
||||
if(istype(AM, /mob/living/carbon))
|
||||
var/mob/living/carbon/M = AM
|
||||
M.slip(100, src)
|
||||
|
||||
/obj/effect/particle_effect/foam/metal/Crossed(atom/movable/AM)
|
||||
return
|
||||
|
||||
|
||||
/obj/effect/particle_effect/foam/proc/spread_foam()
|
||||
var/turf/t_loc = get_turf(src)
|
||||
for(var/turf/T in t_loc.GetAtmosAdjacentTurfs())
|
||||
|
||||
@@ -7,16 +7,20 @@
|
||||
desc = "A portable microcomputer by Thinktronic Systems, LTD. The surface is coated with polytetrafluoroethylene and banana drippings."
|
||||
ttone = "honk"
|
||||
|
||||
/obj/item/device/pda/clown/Crossed(AM as mob|obj)
|
||||
if (istype(AM, /mob/living/carbon))
|
||||
var/mob/living/carbon/M = AM
|
||||
if(M.slip(120, src, NO_SLIP_WHEN_WALKING))
|
||||
if (ishuman(M) && (M.real_name != src.owner))
|
||||
if (istype(src.cartridge, /obj/item/weapon/cartridge/virus/clown))
|
||||
var/obj/item/weapon/cartridge/virus/cart = src.cartridge
|
||||
if(cart.charges < 5)
|
||||
cart.charges++
|
||||
/obj/item/device/pda/clown/Initialize()
|
||||
. = ..()
|
||||
AddComponent(/datum/component/slippery, 120, NO_SLIP_WHEN_WALKING)
|
||||
|
||||
/obj/item/device/pda/clown/ComponentActivated(datum/component/C)
|
||||
..()
|
||||
var/datum/component/slippery/S = C
|
||||
if(!istype(S))
|
||||
return
|
||||
var/mob/living/carbon/human/M = S.slip_victim
|
||||
if (istype(M) && (M.real_name != src.owner))
|
||||
var/obj/item/weapon/cartridge/virus/clown/cart = cartridge
|
||||
if(istype(cart) && cart.charges < 5)
|
||||
cart.charges++
|
||||
|
||||
// Special AI/pAI PDAs that cannot explode.
|
||||
/obj/item/device/pda/ai
|
||||
|
||||
@@ -23,6 +23,10 @@
|
||||
var/cleanspeed = 50 //slower than mop
|
||||
force_string = "robust... against germs"
|
||||
|
||||
/obj/item/weapon/soap/Initialize()
|
||||
. = ..()
|
||||
AddComponent(/datum/component/slippery, 80)
|
||||
|
||||
/obj/item/weapon/soap/nanotrasen
|
||||
desc = "A Nanotrasen brand bar of soap. Smells of plasma."
|
||||
icon_state = "soapnt"
|
||||
@@ -48,11 +52,6 @@
|
||||
new /obj/effect/particle_effect/foam(loc)
|
||||
return (TOXLOSS)
|
||||
|
||||
/obj/item/weapon/soap/Crossed(AM as mob|obj)
|
||||
if (istype(AM, /mob/living/carbon))
|
||||
var/mob/living/carbon/M = AM
|
||||
M.slip(80, src)
|
||||
|
||||
/obj/item/weapon/soap/afterattack(atom/target, mob/user, proximity)
|
||||
if(!proximity || !check_allowed_items(target))
|
||||
return
|
||||
|
||||
@@ -194,6 +194,7 @@
|
||||
if(wet >= wet_setting)
|
||||
return
|
||||
wet = wet_setting
|
||||
UpdateSlip()
|
||||
if(wet_setting != TURF_DRY)
|
||||
if(wet_overlay)
|
||||
cut_overlay(wet_overlay)
|
||||
@@ -216,6 +217,30 @@
|
||||
add_overlay(wet_overlay)
|
||||
HandleWet()
|
||||
|
||||
/turf/open/proc/UpdateSlip()
|
||||
switch(wet)
|
||||
if(TURF_WET_WATER)
|
||||
AddComponent(/datum/component/slippery, 60, NO_SLIP_WHEN_WALKING)
|
||||
if(TURF_WET_LUBE)
|
||||
AddComponent(/datum/component/slippery, 80, SLIDE | GALOSHES_DONT_HELP)
|
||||
if(TURF_WET_ICE)
|
||||
AddComponent(/datum/component/slippery, 120, SLIDE | GALOSHES_DONT_HELP)
|
||||
if(TURF_WET_PERMAFROST)
|
||||
AddComponent(/datum/component/slippery, 120, SLIDE_ICE | GALOSHES_DONT_HELP)
|
||||
if(TURF_WET_SLIDE)
|
||||
AddComponent(/datum/component/slippery, 80, SLIDE | GALOSHES_DONT_HELP)
|
||||
else
|
||||
qdel(GetComponent(/datum/component/slippery))
|
||||
|
||||
/turf/open/ComponentActivated(datum/component/C)
|
||||
..()
|
||||
var/datum/component/slippery/S = C
|
||||
if(!istype(S))
|
||||
return
|
||||
if(wet == TURF_WET_LUBE)
|
||||
var/mob/living/L = S.slip_victim
|
||||
L.confused = max(L.confused, 8)
|
||||
|
||||
/turf/open/proc/MakeDry(wet_setting = TURF_WET_WATER)
|
||||
if(wet > wet_setting || !wet)
|
||||
return
|
||||
@@ -228,6 +253,7 @@
|
||||
wet = TURF_DRY
|
||||
if(wet_overlay)
|
||||
cut_overlay(wet_overlay)
|
||||
UpdateSlip()
|
||||
|
||||
/turf/open/proc/HandleWet()
|
||||
if(!wet)
|
||||
|
||||
@@ -165,24 +165,6 @@
|
||||
|
||||
/turf/open/Entered(atom/movable/AM)
|
||||
..()
|
||||
//slipping
|
||||
if (istype(AM, /mob/living/carbon))
|
||||
var/mob/living/carbon/M = AM
|
||||
if(M.movement_type & FLYING)
|
||||
return
|
||||
switch(wet)
|
||||
if(TURF_WET_WATER)
|
||||
if(!M.slip(60, null, NO_SLIP_WHEN_WALKING))
|
||||
M.inertia_dir = 0
|
||||
if(TURF_WET_LUBE)
|
||||
if(M.slip(80, null, (SLIDE|GALOSHES_DONT_HELP)))
|
||||
M.confused = max(M.confused, 8)
|
||||
if(TURF_WET_ICE)
|
||||
M.slip(120, null, (SLIDE|GALOSHES_DONT_HELP))
|
||||
if(TURF_WET_PERMAFROST)
|
||||
M.slip(120, null, (SLIDE_ICE|GALOSHES_DONT_HELP))
|
||||
if(TURF_WET_SLIDE)
|
||||
M.slip(80, null, (SLIDE|GALOSHES_DONT_HELP))
|
||||
//melting
|
||||
if(isobj(AM) && air && air.temperature > T0C)
|
||||
var/obj/O = AM
|
||||
|
||||
@@ -115,8 +115,6 @@
|
||||
name = "synthesized banana peel"
|
||||
desc = "A synthetic banana peel."
|
||||
|
||||
/obj/item/weapon/grown/bananapeel/specialpeel/Crossed(AM)
|
||||
if(iscarbon(AM))
|
||||
var/mob/living/carbon/carbon = AM
|
||||
if(carbon.slip(40, src, FALSE))
|
||||
qdel(src)
|
||||
/obj/item/weapon/grown/bananapeel/specialpeel/Initialize(AM)
|
||||
. = ..()
|
||||
AddComponent(/datum/component/slippery, 40)
|
||||
|
||||
@@ -250,6 +250,7 @@
|
||||
#include "code\datums\antagonists\devil.dm"
|
||||
#include "code\datums\antagonists\ninja.dm"
|
||||
#include "code\datums\components\component.dm"
|
||||
#include "code\datums\components\slippery.dm"
|
||||
#include "code\datums\diseases\_disease.dm"
|
||||
#include "code\datums\diseases\_MobProcs.dm"
|
||||
#include "code\datums\diseases\anxiety.dm"
|
||||
|
||||
Reference in New Issue
Block a user