Added triggers and targetting system for brushes. Added corresponding Scripting API endpoint for accessing those.

This commit is contained in:
Antoine Pilote
2021-06-27 22:27:57 -04:00
parent 8f4c5f8b08
commit fcdeff9d99
13 changed files with 454 additions and 119 deletions

View File

@@ -30,8 +30,9 @@ class Scene {
return this.GetScript_(id)
} else if (component == "Trigger") {
return Trigger.new(id)
} else if (component == "Brush") {
return Brush.new(id)
}
}
//
@@ -67,6 +68,9 @@ class Scene {
foreign static TriggerGetOverlappingBodyCount_(e)
foreign static TriggerGetOverlappingBodies_(e)
foreign static BrushGetTargets_(e)
foreign static BrushGetTargetsCount_(e)
}
class Entity {
@@ -170,12 +174,40 @@ class Trigger {
}
GetOverlappingBodies() {
bodies = Scene.TriggerGetOverlappingBodies_(_entityId)
if(this.GetOverlappingBodyCount() <= 0) {
return []
}
entities = []
var bodies = Scene.TriggerGetOverlappingBodies_(_entityId)
var entities = []
for(b in bodies) {
entities.add(Entity.new(b))
}
return entities
}
}
class Brush {
construct new(id) {
_entityId = id
}
GetTargetsCount() {
return Scene.BrushGetTargetsCount_(_entityId)
}
GetTargets() {
if(this.GetTargetsCount() <= 0) {
return []
}
var entities = []
var targets = Scene.BrushGetTargets_(_entityId)
for(t in targets) {
entities.add(Entity.new(t))
}
return entities
}
}