Room Container

This class prevents various errors in additive room systems by keeping various classes specific to the room.

Members

  • public static readonly SingletonContainer

  • public static readonly ListenerContainer

Singleton Container

Members

  • private static readonly Dictionary<Scene, RoomContainerData> _data:

    • structure that holds data for the scene and the classes within the scene.

Methods

  • public static bool Add<T>(Scene scene, T element) where T : class
    • Parameters:

      • T: Type of class to add.

      • scene: scene where the class will be added.

      • element: class to be added.

    • Tries to add a specific object to a specified Scene.

    • The addition is performed using the type specified by the generic type parameter T

    • If an object of type T already exists in the relevant scene, adding a new object is prevented and the method returns false.

    • If the specified Scene does not exist yet, a new RoomContainerData object is created and a new object of type T is added with the element.

  • public static bool Remove<T>(Scene scene) where T : class
    • Parameters:

      • T: Type of class to remove

      • scene: scene where the class will be removed.

    • Tries to delete an object of type T from the specified Scene.

    • If there is no object of type T in the specified Scene, the method returns false, indicating that no deletion has occurred.

    • If there is an object of type T in the specified Scene, this object is deleted from the Objects collection and the method returns true.

  • public static T Get<T>(Scene scene) where T : class
    • Parameters:

      • T: Type of class to get

      • scene: scene where the class will be returned.

    • If an object of type T exists in the specified Scene, it returns that object. If there is no object of type T, the method returns null.

    • An object of type T is taken and this object is given as output. The type of this object may be set to T.

Listener Container

RoomListenersHandler

Provides funcionality to manage and invoke room listeners for a specific room.

Members

  • private static readonly Dictionary<Type, List<IRoomListener>> _listeners:

    • Keeps listeners derived from IRoomListener with their types and objects list

Methods

  • public List<T> GetListeners<T>()
    • Parameters:

      • T: The type of the listeners of retrieve.

    • Searches the list for listeners of type T.

    • If found it returns the list.

  • public void AddListener<T>(IRoomListener listener)
    • Parameters:

      • T: The type of the listener to be added.

      • listener: The listener to be added.

    • If the specified type of listener list does not exist, it creates and adds it.

    • Adds it to the existing list if it exists.

  • public void RemoveListener<T>(IRoomListener listener)
    • Parameters:

      • T: The type of the listener to be added.

      • listener: The listener to be removed.

Members

  • private readonly Dictionary<string, RoomListenersHandler> _listenerHandlers;

    • Keeps listenerHandlers based on room name

Methods

  • public void CallSceneChangeListeners(string roomName, Scene scene)
    • Parameters:

      • roomName: The name of the room.

      • scene: The new scene that has been changed to.

    • If there is a room with the specified name,

    • it takes the listeners and calls the onRoomSceneChanged method of all the listeners it finds.

  • public void RemoveRoomListenerHandlers(string roomName)
    • Parameters:

      • roomName: The name of the room.

    • If there is a room with the specified name,

    • it deletes the listenerHandler added to that room.

  • public void RegisterListener<T>(string roomName, IRoomListener listener)
    • Parameters:

      • T: The type of the listener to be register.

      • roomName: The name of the room.

      • listener: The listener to be registered.

    • If the listenersHandler does not exist for the room, it creates it and adds the listeners to the list.

    • Adds listenar to the list of existing handlers, if any

  • public void UnRegisterListener<T>(string roomName, IRoomListener listener)
    • Parameters:

      • T: The type of the listener to be register.

      • roomName: The name of the room.

      • listener: The listener to be registered.

    • If there is no listenersHandler for the specified room, it does nothing.

    • Removes the specified listener from the handlers, if any.

  • private List<T> GetListeners<T>(string roomName) where T : IRoomListener
    • Parameters:

      • T: The type of the listener to be register.

      • roomName: The name of the room.

    • Returns all listeners for the specified room

  • private bool HasRoom(string roomName)
    • Parameters:

      • roomName: The name of the room.

    • Checks whether listenerHandlers exist for the specified room

Last updated