-
Notifications
You must be signed in to change notification settings - Fork 1
/
Copy pathWidgetScript.js
74 lines (59 loc) · 1.87 KB
/
WidgetScript.js
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
//Basic function that makes this.me the entity holding this script
//Also creates a dynamiccomponent for dynamic checking and connects the Update function into frame.
function WidgetScript(entity, comp){
this.me = entity;
this.selected = false;
var inputmapper = me.GetOrCreateComponent("EC_InputMapper");
inputmapper.RegisterMapping("Ctrl+Tab", "ToggleCamera", 1);
this.CreateHandlers();
}
WidgetScript.prototype.CreateHandlers = function(){
var thingie =
{
highlightName : "MySpecialHighlight",
handleClick : function(ent, button, raycast)
{
print("Entity clicked: " + ent);
this.toggleHover(ent);
},
toggleHover : function(ent)
{
var h = ent.GetComponent("EC_Highlight", this.highlightName);
if (h == null)
{
print("- Enabling selection");
h = ent.CreateComponent("EC_Highlight", this.highlightName, 2, false);
h.temporary = true;
this.selected = true;
}
else
{
print("- Disabling selection");
ent.RemoveComponent(this.highlightName);
this.selected = false;
}
},
getSelectedEntities : function()
{
scene.GetEntitiesWithComponent("EC_Highlight", this.highlightName);
},
init: function()
{
print("Initialized");
sceneinteract.EntityClicked.connect(this, this.handleClick);
//me.Action("MousePress").Triggered.connect(this.handleClick);
}
};
if (server.IsRunning())
thingie.init();
}
WidgetScript.prototype.SelectionActions = function(){
var selectedList = scene.GetEntitiesWithComponent("EC_Highlight", this.highlightName);
for (i in selectedList){
print('Selected: ', selectedList[i]);
/*
Create some sort of inputmapping system to move selected object with
keyboard
*/
}
}