scriptlight.c 1.0 KB

12345678910111213141516171819202122232425262728293031323334353637383940
  1. #ifdef GAME_TEMPLATE
  2. [EditorAttribute("box", "GameLib/Scripted", "Script light", "-0.25 -0.25 -0.25", "0.25 0.25 0.25", "255 0 0 255")]
  3. class ScriptLightClass
  4. {
  5. }
  6. ScriptLightClass ScriptLightSource;
  7. class ScriptLight: GenericEntity
  8. {
  9. [Attribute("1", "flags", "Flags", "", { ParamEnum("Point", "1"), ParamEnum("Spot", "2"), ParamEnum("Directional", "4") } )]
  10. int Flags;
  11. [Attribute("1", "combobox", "Type", "", { ParamEnum("Point", "1"), ParamEnum("Spot", "2"), ParamEnum("Directional", "3") } )]
  12. int Type;
  13. [Attribute("1", "editbox", "Radius", "", NULL )]
  14. float Radius;
  15. [Attribute("1 1 1", "color", "Color", "", NULL )]
  16. vector Color;
  17. [Attribute("1", "editbox", "Intensity", "", NULL )]
  18. float Intensity;
  19. HLIGHT m_light;
  20. void ScriptLight(IEntitySource src, IEntity parent)
  21. {
  22. //SetFlags(this, EntityFlags.ACTIVE | EntityFlags.SOLID | EntityFlags.VISIBLE);
  23. m_light = AddLight(this, LightType.POINT, LightFlags.DYNAMIC|LightFlags.CASTSHADOW, Radius, Color * Intensity);
  24. }
  25. void ~ScriptLight()
  26. {
  27. if(m_light)
  28. {
  29. RemoveLight(m_light);
  30. }
  31. }
  32. }
  33. #endif