playerbaseclient.c 2.0 KB

1234567891011121314151617181920212223242526272829303132333435363738394041424344454647484950515253545556575859606162636465666768697071727374757677787980
  1. class PlayerBaseClient extends PlayerBase
  2. {
  3. static ScriptedLightBase m_PersonalLight;
  4. static bool m_PersonalLightEnabledOnCurrentServer = false; // "disablePersonalLight" in server.cfg decides if this is true or false
  5. static bool m_PersonalLightDisabledByDebug = false;
  6. static bool m_PersonalLightIsSwitchedOn = true;
  7. //! Creates PL if it doesn't exist already.
  8. static void CreatePersonalLight()
  9. {
  10. if (!m_PersonalLight && ( !GetGame().IsServer() || !GetGame().IsMultiplayer() ))
  11. {
  12. m_PersonalLight = ScriptedLightBase.CreateLight(PersonalLight, "0 0 0");
  13. }
  14. }
  15. /*
  16. override void OnRPC(PlayerIdentity sender, int rpc_type, ParamsReadContext ctx)
  17. {
  18. super.OnRPC(sender, rpc_type, ctx);
  19. switch( rpc_type )
  20. {
  21. case ERPCs.RPC_TOGGLE_PERSONAL_LIGHT:
  22. {
  23. Param1<bool> is_enabled = new Param1<bool>(false);
  24. if (ctx.Read(is_enabled))
  25. {
  26. m_PersonalLightEnabledOnCurrentServer = is_enabled.param1;
  27. UpdatePersonalLight();
  28. }
  29. break;
  30. }
  31. }
  32. }*/
  33. override void OnGameplayDataHandlerSync()
  34. {
  35. super.OnGameplayDataHandlerSync();
  36. m_PersonalLightEnabledOnCurrentServer = !CfgGameplayHandler.GetDisablePersonalLight();
  37. UpdatePersonalLight();
  38. UpdateHitDirectionValues();
  39. }
  40. //! Controls the ON/OFF switch of the Personal Light. PL will still shine only if the server allows it.
  41. static void SwitchPersonalLight(bool state)
  42. {
  43. if ( !GetGame().IsServer() || !GetGame().IsMultiplayer() )
  44. {
  45. m_PersonalLightIsSwitchedOn = state;
  46. UpdatePersonalLight();
  47. }
  48. }
  49. //! Updates state of PL
  50. static void UpdatePersonalLight()
  51. {
  52. string param;
  53. CreatePersonalLight();
  54. // Allow PL unless it's disabled by debug or client-side starting parameter
  55. if ( !GetCLIParam("disablePersonalLight", param) && !m_PersonalLightDisabledByDebug && m_PersonalLightIsSwitchedOn )
  56. {
  57. m_PersonalLight.SetEnabled(m_PersonalLightEnabledOnCurrentServer);
  58. }
  59. else
  60. {
  61. m_PersonalLight.SetEnabled(false);
  62. }
  63. }
  64. static void UpdateHitDirectionValues()
  65. {
  66. HitDirectionEffectBase.CheckValues();
  67. }
  68. }