2023-11-28 00:46:05 +02:00
|
|
|
extends RefCounted
|
2023-12-20 02:54:22 +02:00
|
|
|
class_name EntityFactory
|
2023-11-26 01:02:03 +02:00
|
|
|
|
|
|
|
const Switch = preload("res://content/entities/switch/switch.tscn")
|
|
|
|
const Light = preload("res://content/entities/light/light.tscn")
|
|
|
|
const Sensor = preload("res://content/entities/sensor/sensor.tscn")
|
2023-11-26 03:01:27 +02:00
|
|
|
const MediaPlayer = preload("res://content/entities/media_player/media_player.tscn")
|
2023-12-10 00:47:17 +02:00
|
|
|
const Camera = preload("res://content/entities/camera/camera.tscn")
|
2023-12-10 01:34:54 +02:00
|
|
|
const ButtonEntity = preload("res://content/entities/button/button.tscn")
|
2023-11-26 01:02:03 +02:00
|
|
|
|
2023-12-20 02:54:22 +02:00
|
|
|
static func create_entity(id: String):
|
2023-11-26 01:02:03 +02:00
|
|
|
var entity = null
|
2023-12-20 02:54:22 +02:00
|
|
|
var type = id.split(".")[0]
|
2023-11-26 01:02:03 +02:00
|
|
|
|
|
|
|
match type:
|
|
|
|
"switch":
|
|
|
|
entity = Switch.instantiate()
|
|
|
|
"light":
|
|
|
|
entity = Light.instantiate()
|
|
|
|
"sensor":
|
|
|
|
entity = Sensor.instantiate()
|
2023-11-26 03:01:27 +02:00
|
|
|
"media_player":
|
|
|
|
entity = MediaPlayer.instantiate()
|
2023-12-10 00:47:17 +02:00
|
|
|
"camera":
|
|
|
|
entity = Camera.instantiate()
|
2023-12-10 01:34:54 +02:00
|
|
|
"button":
|
|
|
|
entity = ButtonEntity.instantiate()
|
2023-11-26 01:02:03 +02:00
|
|
|
_:
|
|
|
|
return null
|
2023-12-10 01:34:54 +02:00
|
|
|
|
2023-11-26 01:02:03 +02:00
|
|
|
entity.entity_id = id
|
|
|
|
return entity
|