113 lines
3.4 KiB
Plaintext
113 lines
3.4 KiB
Plaintext
//VEHICLE DEFAULT HANDLING
|
|
/obj/vehicle/proc/generate_actions()
|
|
return
|
|
|
|
/obj/vehicle/proc/generate_action_type(actiontype)
|
|
var/datum/action/vehicle/A = new actiontype
|
|
if(!istype(A))
|
|
return
|
|
A.vehicle_target = src
|
|
return A
|
|
|
|
/obj/vehicle/proc/initialize_passenger_action_type(actiontype)
|
|
autogrant_actions_passenger += actiontype
|
|
for(var/i in occupants)
|
|
grant_passenger_actions(i) //refresh
|
|
|
|
/obj/vehicle/proc/initialize_controller_action_type(actiontype, control_flag)
|
|
LAZYINITLIST(autogrant_actions_controller["[control_flag]"])
|
|
autogrant_actions_controller["[control_flag]"] += actiontype
|
|
for(var/i in occupants)
|
|
grant_controller_actions(i) //refresh
|
|
|
|
/obj/vehicle/proc/grant_action_type_to_mob(actiontype, mob/m)
|
|
if(isnull(occupants[m]) || !actiontype)
|
|
return FALSE
|
|
LAZYINITLIST(occupant_actions[m])
|
|
if(occupant_actions[m][actiontype])
|
|
return TRUE
|
|
var/datum/action/action = generate_action_type(actiontype)
|
|
action.Grant(m)
|
|
occupant_actions[m][action.type] = action
|
|
return TRUE
|
|
|
|
/obj/vehicle/proc/remove_action_type_from_mob(actiontype, mob/m)
|
|
if(isnull(occupants[m]) || !actiontype)
|
|
return FALSE
|
|
LAZYINITLIST(occupant_actions[m])
|
|
if(occupant_actions[m][actiontype])
|
|
var/datum/action/action = occupant_actions[m][actiontype]
|
|
action.Remove(m)
|
|
occupant_actions[m] -= actiontype
|
|
return TRUE
|
|
|
|
/obj/vehicle/proc/grant_passenger_actions(mob/M)
|
|
for(var/v in autogrant_actions_passenger)
|
|
grant_action_type_to_mob(v, M)
|
|
|
|
/obj/vehicle/proc/remove_passenger_actions(mob/M)
|
|
for(var/v in autogrant_actions_passenger)
|
|
remove_action_type_from_mob(v, M)
|
|
|
|
/obj/vehicle/proc/grant_controller_actions(mob/M)
|
|
if(!istype(M) || isnull(occupants[M]))
|
|
return FALSE
|
|
for(var/i in GLOB.bitflags)
|
|
if(occupants[M] & i)
|
|
grant_controller_actions_by_flag(M, i)
|
|
return TRUE
|
|
|
|
/obj/vehicle/proc/remove_controller_actions(mob/M)
|
|
if(!istype(M) || isnull(occupants[M]))
|
|
return FALSE
|
|
for(var/i in GLOB.bitflags)
|
|
remove_controller_actions_by_flag(M, i)
|
|
return TRUE
|
|
|
|
/obj/vehicle/proc/grant_controller_actions_by_flag(mob/M, flag)
|
|
if(!istype(M))
|
|
return FALSE
|
|
for(var/v in autogrant_actions_controller["[flag]"])
|
|
grant_action_type_to_mob(v, M)
|
|
return TRUE
|
|
|
|
/obj/vehicle/proc/remove_controller_actions_by_flag(mob/M, flag)
|
|
if(!istype(M))
|
|
return FALSE
|
|
for(var/v in autogrant_actions_controller["[flag]"])
|
|
remove_action_type_from_mob(v, M)
|
|
return TRUE
|
|
|
|
/obj/vehicle/proc/cleanup_actions_for_mob(mob/M)
|
|
if(!istype(M))
|
|
return FALSE
|
|
for(var/path in occupant_actions[M])
|
|
stack_trace("Leftover action type [path] in vehicle type [type] for mob type [M.type] - THIS SHOULD NOT BE HAPPENING!")
|
|
var/datum/action/action = occupant_actions[M][path]
|
|
action.Remove(M)
|
|
occupant_actions[M] -= path
|
|
occupant_actions -= M
|
|
return TRUE
|
|
|
|
//ACTION DATUMS
|
|
|
|
/datum/action/vehicle
|
|
check_flags = AB_CHECK_RESTRAINED | AB_CHECK_STUN | AB_CHECK_CONSCIOUS
|
|
icon_icon = 'icons/mob/actions/actions_vehicle.dmi'
|
|
button_icon_state = "vehicle_eject"
|
|
var/obj/vehicle/vehicle_target
|
|
|
|
/datum/action/vehicle/sealed
|
|
var/obj/vehicle/sealed/vehicle_entered_target
|
|
|
|
/datum/action/vehicle/sealed/climb_out
|
|
name = "Climb Out"
|
|
desc = "Climb out of your vehicle!"
|
|
|
|
/datum/action/vehicle/sealed/climb_out/Trigger()
|
|
if(..() && istype(vehicle_entered_target))
|
|
vehicle_entered_target.mob_try_exit(owner, owner)
|
|
|
|
/datum/action/vehicle/ridden
|
|
var/obj/vehicle/ridden/vehicle_ridden_target
|