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:
Jordan Brown
2017-08-09 16:06:15 +02:00
committed by AnturK
parent 79bad5c881
commit 3c56d0f4f3
13 changed files with 90 additions and 49 deletions
+2
View File
@@ -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
+4
View File
@@ -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)
+22
View File
@@ -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