/
Bronuh
/
vector-survovors
Обзор
Документация
Войти
/
Bronuh
/
vector-survovors
Код
Запросы
0
Пакеты
0
Релизы
0
CI/CD
Аналитика
Безопасность
master
Features/SceneStructure/AbstractStorage.cs
36 строк
998 B
Bronuh
Remove multiplayer
24 фев 2024, 18:47
24 фев 2024, 18:47
4e4198f
Код
Авторство
О чём код?
using System; using System.Reflection; using Godot; using Godot.Collections; using KludgeBox; namespace VectorSurvivors; public abstract partial class AbstractStorage : Node { public override void _Ready() { NotNullChecker.CheckProperties(this); RegisterScenes(this); } private Dictionary<string, PackedScene> _scenes = new(); public bool TryGetScene(string name, out PackedScene scene) { return _scenes.TryGetValue(name, out scene); } private void RegisterScenes(object obj) { if (obj == null) throw new ArgumentNullException(nameof(obj)); Type type = obj.GetType(); foreach (PropertyInfo property in type.GetProperties()) { if (!property.PropertyType.IsAssignableTo(typeof(PackedScene))) continue; if (!Attribute.IsDefined(property, typeof(ExportAttribute))) continue; _scenes[property.Name] = property.GetValue(this) as PackedScene; } } }