Ejemplo n.º 1
0
        public RoomNetwork RecreateRoomNetwork()
        {
                        #if PROFILE_NETWORK
            Stopwatch sw = new Stopwatch();
            sw.Start();
                        #endif

            _roomNetwork = new RoomNetwork();

            foreach (Room room in _roomRunner.rooms)
            {
                foreach (Ting exit in GetExits(room))
                {
                    var linkingTings = GetLinkedExitsInOtherRooms(exit);
                    int group        = exit.tile.group;
                    var roomGroup    = new RoomGroup(room, group);

                    Dictionary <RoomGroup, Ting> maybeRooms = null;

                    if (!_roomNetwork.linkedRoomGroups.TryGetValue(roomGroup, out maybeRooms))
                    {
                        maybeRooms = new Dictionary <RoomGroup, Ting>();
                        _roomNetwork.linkedRoomGroups.Add(roomGroup, maybeRooms);
                    }

                    D.isNull(maybeRooms, "maybeRooms is null");

                    //D.Log("The exit " + exit.name + " in " + exit.room.name + " is linked to the following tings: ");
                    foreach (var linkingTing in linkingTings)
                    {
                        D.isNull(linkingTing, "linking ting is null");
                        maybeRooms[RoomGroup.FromTing(linkingTing)] = exit;
                        //D.Log(linkedTing.name + " in " + linkedTing.room);
                    }
                }
            }

                        #if PROFILE_NETWORK
            sw.Stop();
            if (sw.Elapsed.TotalSeconds > 0.0f)
            {
                D.Log("Recreating Room Network took " + sw.Elapsed.TotalSeconds + " s.");
            }
                        #endif

            return(_roomNetwork);
        }
Ejemplo n.º 2
0
 public static void ClearRoomNetwork()
 {
     _roomNetwork = null;
 }