mirror of
https://gitlab.com/MaddoScientisto/cirnogodot.git
synced 2026-06-16 03:03:47 +00:00
Custom func_godot entities
This commit is contained in:
parent
8ab7735d17
commit
929d993f99
360 changed files with 4983 additions and 3944 deletions
11
3D/TrenchBroom/EntityScripts/Lights/light_base.gd
Normal file
11
3D/TrenchBroom/EntityScripts/Lights/light_base.gd
Normal file
|
|
@ -0,0 +1,11 @@
|
|||
## Special Light base class that contains static helper functions for LightOmni and LightSpot entities.
|
||||
class_name LightBase
|
||||
extends Light3D
|
||||
|
||||
static func _func_godot_apply_properties(node: Light3D, props: Dictionary) -> void:
|
||||
node.light_energy = props["energy"] as float
|
||||
node.light_indirect_energy = props["indirect_energy"] as float
|
||||
node.shadow_bias = props["shadow_bias"] as float
|
||||
node.shadow_enabled = props["shadows"] as bool
|
||||
node.light_color = props["color"] as Color
|
||||
node.light_bake_mode = Light3D.BAKE_DYNAMIC
|
||||
1
3D/TrenchBroom/EntityScripts/Lights/light_base.gd.uid
Normal file
1
3D/TrenchBroom/EntityScripts/Lights/light_base.gd.uid
Normal file
|
|
@ -0,0 +1 @@
|
|||
uid://d2pcteabi8kb0
|
||||
7
3D/TrenchBroom/EntityScripts/Lights/light_omni.gd
Normal file
7
3D/TrenchBroom/EntityScripts/Lights/light_omni.gd
Normal file
|
|
@ -0,0 +1,7 @@
|
|||
@tool
|
||||
class_name LightOmni
|
||||
extends OmniLight3D
|
||||
|
||||
func _func_godot_apply_properties(props: Dictionary) -> void:
|
||||
LightBase._func_godot_apply_properties(self, props)
|
||||
omni_range = (props["range"] as float) * TbManager.INVERSE_SCALE
|
||||
1
3D/TrenchBroom/EntityScripts/Lights/light_omni.gd.uid
Normal file
1
3D/TrenchBroom/EntityScripts/Lights/light_omni.gd.uid
Normal file
|
|
@ -0,0 +1 @@
|
|||
uid://cpyxccm5gwv84
|
||||
8
3D/TrenchBroom/EntityScripts/Lights/light_spot.gd
Normal file
8
3D/TrenchBroom/EntityScripts/Lights/light_spot.gd
Normal file
|
|
@ -0,0 +1,8 @@
|
|||
@tool
|
||||
class_name LightSpot
|
||||
extends SpotLight3D
|
||||
|
||||
func _func_godot_apply_properties(props: Dictionary) -> void:
|
||||
LightBase._func_godot_apply_properties(self, props)
|
||||
spot_angle = props["angle"] as float
|
||||
spot_range = (props["range"] as float) * TbManager.INVERSE_SCALE
|
||||
1
3D/TrenchBroom/EntityScripts/Lights/light_spot.gd.uid
Normal file
1
3D/TrenchBroom/EntityScripts/Lights/light_spot.gd.uid
Normal file
|
|
@ -0,0 +1 @@
|
|||
uid://crjplbs250g75
|
||||
42
3D/TrenchBroom/EntityScripts/tb_manager.gd
Normal file
42
3D/TrenchBroom/EntityScripts/tb_manager.gd
Normal file
|
|
@ -0,0 +1,42 @@
|
|||
class_name TbManager
|
||||
extends Node
|
||||
|
||||
# Common inverse scale. Calculated as 1.0 / Inverse Scale Factor.
|
||||
# Used to help translate properties using Quake Units into Godot Units.
|
||||
const INVERSE_SCALE: float = 0.03125
|
||||
|
||||
enum {
|
||||
WORLD_LAYER = (1 << 0),
|
||||
ACTOR_LAYER = (1 << 1),
|
||||
TRIGGER_LAYER = (1 << 2)
|
||||
}
|
||||
|
||||
func use_targets(activator: Node, target: String) -> void:
|
||||
# Targetnames are really Godot Groups, so we can have multiple entities
|
||||
# share a common "targetname" in Trenchbroom.
|
||||
var target_list: Array[Node] = get_tree().get_nodes_in_group(target)
|
||||
for targ in target_list:
|
||||
var f: String
|
||||
# Be careful when specifying a function since we can't pass arguments
|
||||
# to it (without hackarounds of course)
|
||||
if 'targetfunc' in activator:
|
||||
f = activator.targetfunc
|
||||
if f.is_empty():
|
||||
f = "use"
|
||||
if targ.has_method(f):
|
||||
targ.call(f)
|
||||
|
||||
func set_targetname(node: Node, targetname: String) -> void:
|
||||
if node != null and not targetname.is_empty():
|
||||
node.add_to_group(targetname)
|
||||
|
||||
# Converts Quake 1 axis to Godot axis
|
||||
static func id_vec_to_godot_vec(vec: Variant)->Vector3:
|
||||
var org: Vector3 = Vector3.ZERO
|
||||
if vec is Vector3:
|
||||
org = vec
|
||||
elif vec is String:
|
||||
var arr: PackedFloat64Array = (vec as String).split_floats(" ")
|
||||
for i in max(arr.size(), 3):
|
||||
org[i] = arr[i]
|
||||
return Vector3(org.y, org.z, org.x)
|
||||
1
3D/TrenchBroom/EntityScripts/tb_manager.gd.uid
Normal file
1
3D/TrenchBroom/EntityScripts/tb_manager.gd.uid
Normal file
|
|
@ -0,0 +1 @@
|
|||
uid://s1kbl27osvoy
|
||||
Loading…
Add table
Add a link
Reference in a new issue