mirror of
https://github.com/FOSS-Supremacy/OpenLiberty.git
synced 2025-04-28 20:07:57 +03:00
Change how items are spawned
This commit is contained in:
parent
2faf8902e1
commit
b10b98176b
2 changed files with 14 additions and 9 deletions
|
@ -1,8 +1,11 @@
|
|||
extends Node
|
||||
|
||||
|
||||
@onready var world := Node3D.new()
|
||||
|
||||
|
||||
func _ready() -> void:
|
||||
MapBuilder.clear_map()
|
||||
world.rotation.x = deg_to_rad(-90.0)
|
||||
|
||||
var start := Time.get_ticks_msec()
|
||||
var target = MapBuilder.placements.size()
|
||||
|
@ -11,7 +14,7 @@ func _ready() -> void:
|
|||
|
||||
# add_child(MapBuilder.map)
|
||||
for ipl in MapBuilder.placements:
|
||||
MapBuilder.spawn_placement(ipl)
|
||||
world.add_child(MapBuilder.spawn_placement(ipl))
|
||||
count += 1
|
||||
|
||||
if Time.get_ticks_msec() - start > (1.0 / 30.0) * 1000:
|
||||
|
@ -19,5 +22,4 @@ func _ready() -> void:
|
|||
print("%f" % (float(count) / float(target)))
|
||||
await get_tree().physics_frame
|
||||
print("Map load completed in %f seconds" % ((Time.get_ticks_msec() - start_t) / 1000))
|
||||
|
||||
add_child(MapBuilder.map)
|
||||
add_child(world)
|
||||
|
|
|
@ -103,14 +103,15 @@ func clear_map() -> void:
|
|||
map.rotation.x = deg_to_rad(-90.0)
|
||||
|
||||
|
||||
func spawn_placement(ipl: ItemPlacement):
|
||||
spawn(ipl.id, ipl.model_name, ipl.position, ipl.scale, ipl.rotation)
|
||||
func spawn_placement(ipl: ItemPlacement) -> Node3D:
|
||||
return spawn(ipl.id, ipl.model_name, ipl.position, ipl.scale, ipl.rotation)
|
||||
|
||||
|
||||
func spawn(id: int, model_name: String, position: Vector3, scale: Vector3, rotation: Quaternion):
|
||||
func spawn(id: int, model_name: String, position: Vector3, scale: Vector3, rotation: Quaternion) -> Node3D:
|
||||
var result := Node3D.new()
|
||||
var item := items[id] as ItemDef
|
||||
if item.flags & 0x40:
|
||||
return
|
||||
return result
|
||||
|
||||
var access := AssetLoader.open_asset(model_name + ".dff")
|
||||
var glist := RWClump.new(access).geometry_list
|
||||
|
@ -123,4 +124,6 @@ func spawn(id: int, model_name: String, position: Vector3, scale: Vector3, rotat
|
|||
instance.scale = scale
|
||||
instance.quaternion = rotation
|
||||
|
||||
map.add_child(instance)
|
||||
result.add_child(instance)
|
||||
|
||||
return result
|
||||
|
|
Loading…
Add table
Add a link
Reference in a new issue