// Add a map to the map-list public static void AddMap(String body, ILoadOnDemand map) { // If the map is null, abort if (map == null) { return; } // Create the sublist if (!Maps.ContainsKey(body)) { Maps[body] = new List <ILoadOnDemand>(); } // Add the map if (!Maps[body].Contains(map)) { Maps[body].Add(map); // Log Debug.Log("[OD] Adding for body " + body + " map named " + map.Name + " of path = " + map.Path); } else { Debug.Log("[OD] WARNING: trying to add a map but is already tracked! Current body is " + body + " and map name is " + map.Name + " and path is " + map.Path); } }
// Remove a map from the list public static void RemoveMap(String body, ILoadOnDemand map) { // If the map is null, abort if (map == null) { return; } // If the sublist exists, remove the map if (Maps.ContainsKey(body)) { if (Maps[body].Contains(map)) { Maps[body].Remove(map); } else { Debug.Log( "[OD] WARNING: Trying to remove a map from a body, but the map is not tracked for the body!"); } } else { Debug.Log("[OD] WARNING: Trying to remove a map from a body, but the body is not known!"); } // If all maps of the body are unloaded, remove the body completely if (Maps[body].Count == 0) { Maps.Remove(body); } }
// Add a map to the map-list public static void AddMap(string body, ILoadOnDemand map) { // If the map is null, abort if (map == null) return; // Create the sublist if (!maps.ContainsKey(body)) maps[body] = new List<ILoadOnDemand>(); // Add the map if (!maps[body].Contains(map)) { maps[body].Add(map); // Log Debug.Log("[OD] Adding for body " + body + " map named " + map.name + " of path = " + map.Path); } else { Debug.Log("[OD] WARNING: trying to add a map but is already tracked! Current body is " + body + " and map name is " + map.name + " and path is " + map.Path); } }
// Thanks to both Allan Ritchie ([email protected]) // and Gerrod Thomas (http://www.Gerrod.com) for advice and code public object Resync(object entityObject) { EntityMap entity = this.mappings[entityObject.GetType()]; for (int index = 0; index < entity.RelationCount; index++) { RelationMap relation = entity.Relation(index); object member = this[entityObject].GetField(relation.Member); ILoadOnDemand lazy = member as ILoadOnDemand; if (lazy != null) { if (lazy.IsLoaded) { lazy.Resync(); } } } this.EndTracking(entityObject); EntityKey entityKey = new EntityKey(this, entityObject, true); return(this.GetObject(entityObject.GetType(), entityKey.Value, true)); }
// Remove a map from the list public static void RemoveMap(string body, ILoadOnDemand map) { // If the map is null, abort if (map == null) return; // If the sublist exists, remove the map if (maps.ContainsKey(body)) { if (maps[body].Contains(map)) { maps[body].Remove(map); } else { Debug.Log("[OD] WARNING: Trying to remove a map from a body, but the map is not tracked for the body!"); } } else { Debug.Log("[OD] WARNING: Trying to remove a map from a body, but the body is not known!"); } // If all maps of the body are unloaded, remove the body completely if (maps[body].Count == 0) maps.Remove(body); }
public static void RemoveMap(string body, ILoadOnDemand map) { if (map == null) return; if (bodyMapLists.ContainsKey(body)) bodyMapLists[body].Remove(map); mapList.Remove(map); enabledMaps.Remove(map); mapTimes.Remove(map); List<string> bodies = mapBodies[map]; if (bodies.Count <= 1) mapBodies.Remove(map); else bodies.Remove(body); }
public static void AddMap(string body, ILoadOnDemand map) { if (map == null) return; if(!bodyMapLists.ContainsKey(body)) bodyMapLists[body] = new List<ILoadOnDemand>(); bodyMapLists[body].Add(map); Debug.Log("OD: Adding for body " + body + " map named " + map.MapName() + " of path = " + map.MapPath()); if (!mapList.Contains(map)) { mapList.Add(map); enabledMaps[map] = false; mapTimes[map] = 0f; } else { Debug.Log("OD: WARNING: trying to add a map but is already tracked! Current body is " + body + " and map name is " + map.MapName() + " and path is " + map.MapPath()); } if (!mapBodies.ContainsKey(map)) mapBodies[map] = new List<string>(); if(!mapBodies[map].Contains(body)) mapBodies[map].Add(body); }