Scripts/Room/RoomManager.cs
namespace Milaine.Room;
public sealed class RoomManager : Component {
[Property]
public List<GameObject> Models { get; set; } = [];
private List<GameObject> ChairChildren = [];
protected override void OnAwake() {
if (Models.Count == 0) {
Log.Warning("Models list is empty");
return;
}
foreach (GameObject gameObject in Models) {
if (!gameObject.IsValid()) {
continue;
}
Prop prop = gameObject.GetComponent<Prop>();
if (!prop.IsValid()) {
continue;
}
prop.IsStatic = true;
if (gameObject.Name == "office_chair") {
gameObject.GetComponent<ModelRenderer>().Destroy();
gameObject.GetComponent<ModelPhysics>().Destroy();
foreach (GameObject obj in gameObject.Children) {
ChairChildren.Add(obj);
}
}
}
}
protected override void OnUpdate() {
if (ChairChildren.Count == 0) {
return;
}
foreach (GameObject gameObject in ChairChildren) {
gameObject.Destroy();
}
ChairChildren = [];
}
}