Compare commits
No commits in common. "4a9836f20707f87c4bec6442f0038f17f43f96b5" and "98d0abe3aaafc541fa2cff9670e664c2088250dd" have entirely different histories.
4a9836f207
...
98d0abe3aa
@ -61,49 +61,23 @@ public class BTC : MonoBehaviour {
|
|||||||
}
|
}
|
||||||
|
|
||||||
public List<ComponentController> namedObjects = new List<ComponentController>();
|
public List<ComponentController> namedObjects = new List<ComponentController>();
|
||||||
private Dictionary<string, ComponentController> namedLookup = new();
|
|
||||||
|
|
||||||
private void OnEnable()
|
|
||||||
{
|
|
||||||
BuildLookup();
|
|
||||||
}
|
|
||||||
|
|
||||||
#region update list of objects in rooms
|
#region update list of objects in rooms
|
||||||
public void ClearObjects() {
|
public void ClearObjects() {
|
||||||
//namedObjects = new List<ComponentController>();
|
namedObjects = new List<ComponentController>();
|
||||||
namedObjects.Clear();
|
|
||||||
namedLookup.Clear();
|
|
||||||
}
|
}
|
||||||
|
|
||||||
/* public T GetNamedObject<T>(string objectName) where T : ComponentController {
|
public T GetNamedObject<T>(string objectName) where T : ComponentController {
|
||||||
for (int i = namedObjects.Count - 1; i >= 0; i--) {
|
for (int i = namedObjects.Count - 1; i >= 0; i--) {
|
||||||
T ngo = namedObjects[i] as T;
|
T ngo = namedObjects[i] as T;
|
||||||
if (ngo != null) {
|
if (ngo != null) {
|
||||||
// if name equals
|
// if name equals
|
||||||
if (ngo.objectName == objectName) {
|
if (ngo.objectName == objectName) {
|
||||||
Debug.Log("BTC returns namedObject");
|
|
||||||
return ngo;
|
return ngo;
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
return null;
|
return null;
|
||||||
}*/
|
|
||||||
|
|
||||||
public void BuildLookup()
|
|
||||||
{
|
|
||||||
namedLookup.Clear();
|
|
||||||
foreach (var ctrl in namedObjects)
|
|
||||||
{
|
|
||||||
if (!string.IsNullOrEmpty(ctrl.objectName))
|
|
||||||
namedLookup[ctrl.objectName] = ctrl;
|
|
||||||
}
|
|
||||||
}
|
|
||||||
|
|
||||||
public T GetNamedObject<T>(string objectName) where T : ComponentController
|
|
||||||
{
|
|
||||||
if (namedLookup.TryGetValue(objectName, out var obj))
|
|
||||||
return obj as T;
|
|
||||||
return null;
|
|
||||||
}
|
}
|
||||||
|
|
||||||
public List<ComponentHandler> GetHandlers (string objectName) {
|
public List<ComponentHandler> GetHandlers (string objectName) {
|
||||||
|
Loading…
x
Reference in New Issue
Block a user