import SystemEventBase from "./SystemEventBase";

/** 系統事件管理 */
export default class SystemEventManager {
	private static systems: Map<string, SystemEventBase> = new Map();

	public static AddSystem(system: SystemEventBase): void {
		this.systems.set(system.name, system);
	}

	public static DestroySystem(system: SystemEventBase): void {
		this.systems.delete(system.name);
	}

	/** 首次進入大廳 */
	public static FirstEnteringLobby(): void {
		SystemEventManager.systems.forEach(system => system.ImplementFirstEnteringLobby());
	}

	/** 進入大廳 */
	public static EnteringLobby(): void {
		SystemEventManager.systems.forEach(system => system.ImplementEnteringLobby());
	}

	/** 關閉商城頁 */
	public static CloseMall(): void {
		SystemEventManager.systems.forEach(system => system.ImplementCloseMall());
	}

	/** 離開機台 */
	public static LeaveSlot(slotID: number): void {
		SystemEventManager.systems.forEach(system => system.ImplementLeaveSlot(slotID));
	}
}
