-
Notifications
You must be signed in to change notification settings - Fork 791
Expand file tree
/
Copy pathBatteryObjectEvent.cs
More file actions
38 lines (32 loc) · 1020 Bytes
/
BatteryObjectEvent.cs
File metadata and controls
38 lines (32 loc) · 1020 Bytes
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
using System.Collections;
using System.Collections.Generic;
using UnityEngine;
using TierIV.Event;
public class BatteryObjectEvent : MonoBehaviour
{
// Start is called before the first frame update
void Start()
{
}
void OnEnable()
{
EventNotifier.Instance.SubscribeEvent(OnReceiveChargeEvent, "Charge");
}
void OnDisable()
{
EventNotifier.Instance.UnSubscribeEvent(OnReceiveChargeEvent);
}
void OnReceiveChargeEvent(EventArgsBase chargeEvent)
{
if (typeof(ChargeStationEvent.BatteryVolume).GetHashCode() != chargeEvent.TypeHash)
{
throw new System.ArgumentException(string.Format("different class hashcode {0}({1}) / {2}({3})",
typeof(ChargeStationEvent.BatteryVolume).GetHashCode(),
typeof(EventArgsBase).Name,
chargeEvent.TypeHash,
chargeEvent.GetType().Name
));
}
// receive chargeEvent values to appropriate proces
}
}