Merge branch 'programming'
This commit is contained in:
		
						commit
						4a9836f207
					
				@ -61,23 +61,49 @@ public class BTC : MonoBehaviour {
 | 
			
		||||
    }
 | 
			
		||||
 | 
			
		||||
    public List<ComponentController> namedObjects = new List<ComponentController>();
 | 
			
		||||
    private Dictionary<string, ComponentController> namedLookup = new();
 | 
			
		||||
 | 
			
		||||
    private void OnEnable()
 | 
			
		||||
    {
 | 
			
		||||
        BuildLookup();
 | 
			
		||||
    }
 | 
			
		||||
 | 
			
		||||
    #region update list of objects in rooms
 | 
			
		||||
    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--) {
 | 
			
		||||
            T ngo = namedObjects[i] as T;
 | 
			
		||||
            if (ngo != null) {
 | 
			
		||||
                // if name equals
 | 
			
		||||
                if (ngo.objectName == objectName) {
 | 
			
		||||
                    Debug.Log("BTC returns namedObject");
 | 
			
		||||
                    return ngo;
 | 
			
		||||
                }
 | 
			
		||||
            }
 | 
			
		||||
        }
 | 
			
		||||
        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) {
 | 
			
		||||
 | 
			
		||||
		Loading…
	
	
			
			x
			
			
		
	
		Reference in New Issue
	
	Block a user