public DodReadOnlyDictionary <int, GameObject> this[IntVec point, ActorType identity] { get{ string pointKey = point.toKey(); if (!_actors.ContainsKey(pointKey)) { return(MapNodeCenter._empty); //返回一个固定的空列表避免判空操作 } if (identity == ActorType.MONSTER) { return(_readonlyEnemies[pointKey]); } else if (identity == ActorType.OPERATOR) { return(_readonlyOperators[pointKey]); } else if (identity == ActorType.ANY) { return(_readonlyActors[pointKey]); } else { Debug.LogWarning("Invalid Actor Type Request"); return(null); } } }
/*获取某一点上的全部Actors*/ private Dictionary <int, GameObject> getActorsFromPoint(IntVec point) { string pointKey = point.toKey(); if (!_actors.ContainsKey(pointKey)) //如果此坐标尚未被记录过,则终止函数 { return(null); } return(_actors[pointKey]); }
private void _initPoint(IntVec point) { _loadedNode.Add(point.clone()); string pointKey = point.toKey(); Dictionary <int, GameObject>[] dics = new Dictionary <int, GameObject>[] { new Dictionary <int, GameObject>(), new Dictionary <int, GameObject>(), new Dictionary <int, GameObject>() }; _actors.Add(pointKey, dics[0]); _readonlyActors.Add(pointKey, new DodReadOnlyDictionary <int, GameObject>(dics[0])); _enemies.Add(pointKey, dics[1]); _readonlyEnemies.Add(pointKey, new DodReadOnlyDictionary <int, GameObject>(dics[1])); _operators.Add(pointKey, dics[2]); _readonlyOperators.Add(pointKey, new DodReadOnlyDictionary <int, GameObject>(dics[2])); }