fix for monkeycube expand related lag.

changed the new human call instead of using set_species incidently dropping the number of delete from ~50 to ~10 per monkey cube.

added a limit to monkeycube expand to only expand one every 0.2 second instead of doing them all at once in the event of a mass expand.
This commit is contained in:
Jey
2016-01-14 13:05:22 -05:00
parent 9b96b2be3c
commit f1e4e2a787
2 changed files with 51 additions and 4 deletions
@@ -1649,6 +1649,7 @@
baconbeacon.digest_delay()
var/lastmonkeycubeexpand = 0
/obj/item/weapon/reagent_containers/food/snacks/monkeycube
name = "monkey cube"
desc = "Just add water!"
@@ -1656,6 +1657,7 @@
bitesize = 12
filling_color = "#ADAC7F"
var/monkey_type = "Monkey"
var/expanding = 0
/obj/item/weapon/reagent_containers/food/snacks/monkeycube/New()
..()
@@ -1663,6 +1665,8 @@
/obj/item/weapon/reagent_containers/food/snacks/monkeycube/afterattack(obj/O, mob/user, proximity)
if(!proximity) return
if (expanding == 1)
return ..()
if(istype(O,/obj/structure/sink) && !wrapped)
user << "<span class='notice'>You place [src] under a stream of water...</span>"
user.drop_item()
@@ -1675,14 +1679,22 @@
Unwrap(user)
/obj/item/weapon/reagent_containers/food/snacks/monkeycube/water_act(volume, temperature)
if (expanding == 1)
return
if(volume >= 5)
return Expand()
/obj/item/weapon/reagent_containers/food/snacks/monkeycube/proc/Expand()
visible_message("<span class='notice'>[src] expands!</span>")
var/mob/living/carbon/human/H = new (get_turf(src))
H.set_species(monkey_type)
qdel(src)
if (expanding == 1)
return
expanding = 1
spawn(0)
while (world.time - lastmonkeycubeexpand < 2) //do at most one monkeycube every 0.2sec
sleep(world.time - lastmonkeycubeexpand)
lastmonkeycubeexpand = world.time
visible_message("<span class='notice'>[src] expands!</span>")
new/mob/living/carbon/human(get_turf(src),monkey_type)
qdel(src)
/obj/item/weapon/reagent_containers/food/snacks/monkeycube/proc/Unwrap(mob/user)
icon_state = "monkeycube"