SceneEntity.lua 1.1 KB

1234567891011121314151617181920212223242526272829303132333435363738394041424344454647484950515253
  1. require "Polycode/Entity"
  2. class "SceneEntity" (Entity)
  3. function SceneEntity:__index__(name)
  4. if name == "castShadows" then
  5. return Polycore.SceneEntity_get_castShadows(self.__ptr)
  6. end
  7. end
  8. function SceneEntity:__set_callback(name,value)
  9. if name == "castShadows" then
  10. Polycore.SceneEntity_set_castShadows(self.__ptr, value)
  11. return true
  12. end
  13. return false
  14. end
  15. function SceneEntity:SceneEntity(...)
  16. if type(arg[1]) == "table" and count(arg) == 1 then
  17. if ""..arg[1]:class() == "Entity" then
  18. self.__ptr = arg[1].__ptr
  19. return
  20. end
  21. end
  22. for k,v in pairs(arg) do
  23. if type(v) == "table" then
  24. if v.__ptr ~= nil then
  25. arg[k] = v.__ptr
  26. end
  27. end
  28. end
  29. if self.__ptr == nil and arg[1] ~= "__skip_ptr__" then
  30. self.__ptr = Polycore.SceneEntity(unpack(arg))
  31. Polycore.__ptr_lookup[self.__ptr] = self
  32. end
  33. end
  34. function SceneEntity:testMouseCollision(x, y)
  35. local retVal = Polycore.SceneEntity_testMouseCollision(self.__ptr, x, y)
  36. return retVal
  37. end
  38. function SceneEntity:__delete()
  39. Polycore.__ptr_lookup[self.__ptr] = nil
  40. Polycore.delete_SceneEntity(self.__ptr)
  41. end