Sunday Update: graphic and bots improvements, ConfigFile, menu settings
This commit is contained in:
@@ -0,0 +1,144 @@
|
||||
extends MeshInstance
|
||||
|
||||
class_name Road
|
||||
|
||||
export var end_rotation:Vector3 = Vector3(0,0,0)
|
||||
|
||||
export var first_speed_factor:float = 1.0
|
||||
export var creator_speed_factor:float = 1.0
|
||||
export var chasers_speed_factor:float = 1.0
|
||||
|
||||
export var reset_index:int = 0
|
||||
|
||||
export (PoolVector3Array) var speed_constrains = PoolVector3Array()
|
||||
export (PoolVector3Array) var force_penalties = PoolVector3Array()
|
||||
export (PoolVector3Array) var torque_penalties = PoolVector3Array()
|
||||
export (Array,float) var path_penalties = []
|
||||
|
||||
var body:StaticBody
|
||||
|
||||
var creator:int = -1
|
||||
var preview:bool = false
|
||||
|
||||
|
||||
func _init():
|
||||
if not has_node("StaticBody"):
|
||||
body = StaticBody.new()
|
||||
body.set_name("StaticBody")
|
||||
var shape = CollisionShape.new()
|
||||
shape.set_name("CollisionShape")
|
||||
shape.shape = mesh.create_trimesh_shape()
|
||||
body.add_child(shape)
|
||||
body.set_collision_layer_bit(0,1)
|
||||
body.set_collision_layer_bit(1,1)
|
||||
body.set_collision_layer_bit(2,1)
|
||||
body.set_collision_layer_bit(3,1)
|
||||
add_child(body)
|
||||
else:
|
||||
body = get_node("StaticBody")
|
||||
|
||||
|
||||
func get_creator():
|
||||
return creator
|
||||
|
||||
|
||||
func set_creator(new_creator):
|
||||
creator = int(new_creator)
|
||||
|
||||
|
||||
func set_color(new_color):
|
||||
pass # TODO
|
||||
|
||||
|
||||
func get_path():
|
||||
return get_node("Path")
|
||||
|
||||
|
||||
func get_curve():
|
||||
return get_path().get_curve()
|
||||
|
||||
|
||||
func get_lane_curve(lane:int):
|
||||
if has_node("lanes"):
|
||||
return get_node("lanes").get_child(lane).get_curve()
|
||||
else:
|
||||
return get_path().get_curve()
|
||||
|
||||
|
||||
func get_end_rotation():
|
||||
return end_rotation
|
||||
|
||||
|
||||
func set_preview(prev):
|
||||
preview = prev
|
||||
if prev:
|
||||
set_material_override(SpatialMaterial.new())
|
||||
else:
|
||||
set_material_override(null)
|
||||
|
||||
|
||||
func is_preview():
|
||||
return preview
|
||||
|
||||
|
||||
func get_next_lane(lane):
|
||||
return lane
|
||||
|
||||
|
||||
func get_constrain_index(distance:float):
|
||||
for index in range(speed_constrains.size()):
|
||||
var constrain = speed_constrains[index]
|
||||
if constrain.x <= distance && constrain.y >= distance:
|
||||
return index
|
||||
return -1
|
||||
|
||||
|
||||
func penalty_index(distance:float, speed:float):
|
||||
var constrain_index = get_constrain_index(distance)
|
||||
if constrain_index >= 0:
|
||||
var constrain = speed_constrains[constrain_index]
|
||||
if constrain.z < 0 && speed < constrain.z * -1 || constrain.z > 0 && speed > constrain.z:
|
||||
return constrain_index
|
||||
return -1
|
||||
|
||||
|
||||
func get_torque_penalty(index:int):
|
||||
if index >= 0:
|
||||
if torque_penalties.size() < (index + 1):
|
||||
return get_torque_penalty(index - 1)
|
||||
return torque_penalties[index]
|
||||
return Vector3(0,0,0)
|
||||
|
||||
|
||||
func get_force_penalty(index:int):
|
||||
if index >= 0:
|
||||
if force_penalties.size() < (index + 1):
|
||||
return get_force_penalty(index - 1)
|
||||
if get_rotation().length() != 0:
|
||||
return force_penalties[index].rotated(get_rotation().normalized(), get_rotation().length())
|
||||
else:
|
||||
return force_penalties[index]
|
||||
|
||||
return Vector3(0,0,0)
|
||||
|
||||
|
||||
func get_path_penalty(index:int):
|
||||
if index >= 0:
|
||||
if path_penalties.size() < (index + 1):
|
||||
return get_path_penalty(index - 1)
|
||||
|
||||
return path_penalties[index]
|
||||
|
||||
return 0.0
|
||||
|
||||
|
||||
func get_first_speed_factor():
|
||||
return first_speed_factor
|
||||
|
||||
|
||||
func get_creator_speed_factor():
|
||||
return creator_speed_factor
|
||||
|
||||
|
||||
func get_chasers_speed_factor():
|
||||
return chasers_speed_factor
|
||||
@@ -0,0 +1,33 @@
|
||||
extends Node
|
||||
|
||||
class_name TracksFactory
|
||||
|
||||
const START = "Start"
|
||||
const STRAIGHT = "StraightLong"
|
||||
const STRAIGHT_SMALL = "Straight"
|
||||
const CURVE_RIGHT = "CornerLarge"
|
||||
const CURVE_LEFT = "CornerLargeFlipped"
|
||||
const CURVE_LARGE_RIGHT = "CornerLarger"
|
||||
const CURVE_LARGE_LEFT = "CornerLargerFlipped"
|
||||
const CURVE_SMALL_RIGHT = "CornerSmall"
|
||||
const CURVE_SMALL_LEFT = "CornerSmallFlipped"
|
||||
const BUMP = "StraightLongBump"
|
||||
const BUMP_SMALL = "Bump"
|
||||
const SKEW_RIGHT = "StraightSkew"
|
||||
const SKEW_LEFT = "StraightSkewFlipped"
|
||||
const RAMP_UP = "RampLong"
|
||||
const RAMP_DOWN = "RampLongFlipped"
|
||||
const RAMP_CURVED_UP = "RampLongCurved"
|
||||
const RAMP_CURVED_DOWN = "RampLongCurvedFlipped"
|
||||
const RAMP_SMALL_UP = "Ramp"
|
||||
const RAMP_SMALL_DOWN = "RampFlipped"
|
||||
const CURVED_RIGHT = "CurvedFlipped"
|
||||
const CURVED_LEFT = "Curved"
|
||||
const LOOP = "Loop"
|
||||
|
||||
|
||||
func get_road_instance(road):
|
||||
var instance = load("res://scenes/road/road" + road + ".tscn").instance()
|
||||
if !instance.get_script():
|
||||
instance.set_script(load("res://scripts/road/road.gd"))
|
||||
return instance
|
||||
Reference in New Issue
Block a user