-
Notifications
You must be signed in to change notification settings - Fork 0
/
SelectionEventReceiver.cs
80 lines (75 loc) · 3.99 KB
/
SelectionEventReceiver.cs
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
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
using System.Collections;
using System.Collections.Generic;
using UnityEngine;
public class SelectionEventReceiver : MonoBehaviour {
private void OnEnable()
{
hom3r.coreLink.SubscribeEventObserver(DoInternalEventCommand); //Subscribe a method to the event delegate
}
private void OnDisable()
{
hom3r.coreLink.UnsubscribeEventObserver(DoInternalEventCommand); //Unsubscribe a method to the event delegate
}
private void DoInternalEventCommand(CCoreEvent _event)
{
if (_event.GetType() == typeof(CCoreEvent)) { ExecuteCoreEvents(_event); }
else { /* Do nothing */ }
}
/// <summary>Execute internal events commands</summary>
/// <param name="_event">command to be executed</param>
private void ExecuteCoreEvents(CCoreEvent _event)
{
if (_event.data != null)
{
switch (_event.data.commandEvent)
{
case TCoreEvent.MouseManager_MousePosition:
if (hom3r.state.currentMode == THom3rMode.idle)
{
hom3r.quickLinks.scriptsObject.GetComponent<SelectionManager>().IndicationByMousePosition(_event.data.mousePosition);
}
break;
case TCoreEvent.MouseManager_LeftButtonUp:
if (hom3r.state.currentMode == THom3rMode.idle)
{
hom3r.quickLinks.scriptsObject.GetComponent<SelectionManager>().ConfirmByMouseLeftClickAndMousePosition(_event.data.mousePosition, _event.data.obj, _event.data.control);
}
break;
case TCoreEvent.TouchManager_OneSelectionTouch:
if (hom3r.state.currentMode == THom3rMode.idle)
{
hom3r.quickLinks.scriptsObject.GetComponent<SelectionManager>().ConfirmByMouseLeftClickAndMousePosition(_event.data.mousePosition, _event.data.obj, _event.data.control);
}
break;
case TCoreEvent.Occlusion_ExplodingAreas:
foreach (GameObject go in _event.data.gameObjectList)
{
//go.GetComponent<ObjectStateManager>().SendEvent(ObjectExplosionStateEvents_Type.Explode);
go.GetComponent<ObjectStateManager>().Do(new CObjectVisualStateCommand(TObjectVisualStateCommands.Explode));
}
break;
case TCoreEvent.Occlusion_ImplodingAreas:
foreach (GameObject go in _event.data.gameObjectList)
{
//go.GetComponent<ObjectStateManager>().SendEvent(ObjectExplosionStateEvents_Type.Implode);
go.GetComponent<ObjectStateManager>().Do(new CObjectVisualStateCommand(TObjectVisualStateCommands.Implode));
}
break;
case TCoreEvent.ModelManagement_FileDownloadBegin:
hom3r.coreLink.Do(new CSelectionCommand(TSelectionCommands.BlockSelection, true), Constants.undoNotAllowed); //Block Selection
break;
case TCoreEvent.ModelManagement_FileDownloadEnd:
hom3r.coreLink.Do(new CSelectionCommand(TSelectionCommands.BlockSelection, false), Constants.undoNotAllowed); //UnBlock selection
break;
case TCoreEvent.ObjectState_AreaIndicateOn:
hom3r.quickLinks.scriptsObject.GetComponent<SelectionManager>().AddToIndicatedList(_event.data.obj); //Introduce into the indicated object list
break;
case TCoreEvent.ObjectState_AreaIndicateOff:
hom3r.quickLinks.scriptsObject.GetComponent<SelectionManager>().RemoveFromIndicatedList(_event.data.obj);
break;
default:
break;
}
}
}
}