Skip to content
Open
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
8 changes: 8 additions & 0 deletions Assets/Scripts/Events/EventController.cs
Original file line number Diff line number Diff line change
Expand Up @@ -8,3 +8,11 @@ public class EventController
public void InvokeEvent() => baseEvent?.Invoke();
}

public class EventController<T> // generic class
{
public Action<T> baseEvent;
public void AddListener(Action<T> listener) => baseEvent += listener;
public void RemoveListener(Action<T> listener) => baseEvent -= listener;
public void InvokeEvent(T type) => baseEvent?.Invoke(type);
}

17 changes: 17 additions & 0 deletions Assets/Scripts/Service/EventService.cs
Original file line number Diff line number Diff line change
Expand Up @@ -13,8 +13,25 @@ public static EventService Instance
return instance;
}
}


//int x = 5;
//public int getx()
//{
// return x;
//}

//public void setx(int value)
//{
// x = value;

//}

//public int X { get { return x; } private set { x = value; } }

//public int X { get;private set; }
public EventController OnLightSwitchToggled { get; private set; }
public EventController<int> OnKeyPickedUp { get; private set; }

public EventService()
{
Expand Down