code optimizations

This commit is contained in:
paprka
2014-12-25 13:28:05 -08:00
parent a6acdeb3c2
commit 404da4dbdd
5 changed files with 9 additions and 60 deletions
+5 -5
View File
@@ -2,7 +2,7 @@
name = "lattice"
desc = "A lightweight support lattice."
icon = 'icons/obj/structures.dmi'
icon_state = "lattice"
icon_state = "latticefull"
density = 0
anchored = 1.0
layer = 2.3 //under pipes
@@ -60,7 +60,7 @@
if (istype(C, /obj/item/weapon/weldingtool))
var/obj/item/weapon/weldingtool/WT = C
if(WT.remove_fuel(0, user))
user << "<span class='notice'>Slicing [initial(icon_state)] joints ...</span>"
user << "<span class='notice'>Slicing [name] joints ...</span>"
Deconstruct()
return
@@ -78,7 +78,7 @@
if(!(istype(get_step(src, direction), /turf/space)))
dir_sum += direction
icon_state = "[initial(icon_state)][dir_sum]"
icon_state = "[name][dir_sum]"
return
/obj/structure/lattice/Deconstruct()
@@ -93,7 +93,7 @@
/obj/structure/lattice/catwalk
name = "catwalk"
desc = "A catwalk for easier EVA manuevering."
icon_state = "catwalk"
icon_state = "catwalkfull"
/obj/structure/lattice/catwalk/attackby(obj/item/C as obj, mob/user as mob)
..()
@@ -103,4 +103,4 @@
if((LC.d1==0)||(LC.d2==0))
LC.attackby(C,user)
return
coil.catwalk_place(src, user)
coil.place(src, user)
+1 -1
View File
@@ -63,7 +63,7 @@
if((LC.d1==0)||(LC.d2==0))
LC.attackby(C,user)
return
coil.turf_place(src, user)
coil.place(src, user)
else if(istype(C, /obj/item/weapon/weldingtool))
var/obj/item/weapon/weldingtool/welder = C
if( welder.isOn() && (broken || burnt) )
+2 -53
View File
@@ -623,7 +623,7 @@ obj/structure/cable/proc/avail()
return new path (location)
// called when cable_coil is clicked on a turf/simulated/floor
/obj/item/stack/cable_coil/proc/turf_place(turf/simulated/floor/F, mob/user)
/obj/item/stack/cable_coil/proc/place(turf/simulated/floor/F, mob/user)
if(!isturf(user.loc))
return
@@ -677,57 +677,6 @@ obj/structure/cable/proc/avail()
if (prob(50)) //fail
C.Deconstruct()
// called when cable_coil is clicked on a catwalk
/obj/item/stack/cable_coil/proc/catwalk_place(var/obj/structure/lattice/catwalk/W, mob/user)
if(get_amount() < 1) // Out of cable
user << "There is no cable left."
return
if(get_dist(W,user) > 1) // Too far
user << "You can't lay cable at a place that far away."
return
else
var/dirn
if(user.loc == W)
dirn = user.dir // if laying on the tile we're on, lay in the direction we're facing
else
dirn = get_dir(W, user)
for(var/obj/structure/cable/LC in W)
if(LC.d2 == dirn && LC.d1 == 0)
user << "There's already a cable at that position."
return
var/obj/structure/cable/C = get_new_cable (W)
//set up the new cable
C.d1 = 0 //it's a O-X node cable
C.d2 = dirn
C.add_fingerprint(user)
C.updateicon()
//create a new powernet with the cable, if needed it will be merged later
var/datum/powernet/PN = new()
PN.add_cable(C)
C.mergeConnectedNetworks(C.d2) //merge the powernet with adjacents powernets
C.mergeConnectedNetworksOnTurf() //merge the powernet with on turf powernets
if(C.d2 & (C.d2 - 1))// if the cable is layed diagonally, check the others 2 possible directions
C.mergeDiagonalsNetworks(C.d2)
use(1)
if (C.shock(user, 50))
if (prob(50)) //fail
C.Deconstruct()
// called when cable_coil is click on an installed obj/cable
// or click on a turf that already contains a "node" cable
/obj/item/stack/cable_coil/proc/cable_join(obj/structure/cable/C, mob/user)
@@ -749,7 +698,7 @@ obj/structure/cable/proc/avail()
for(var/obj/structure/lattice/catwalk/W in src)
catwalk_place(W,user)
return
turf_place(T,user)
place(T,user)
return
var/dirn = get_dir(C, user)
+1 -1
View File
@@ -128,7 +128,7 @@
if(get_dist(src, user) > 1)
return
coil.turf_place(T, user)
coil.place(T, user)
return
else
..()
Binary file not shown.

Before

Width:  |  Height:  |  Size: 104 KiB

After

Width:  |  Height:  |  Size: 104 KiB