File size: 2,078 Bytes
24b81cb |
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 67 68 69 70 71 72 73 74 75 76 77 78 79 80 |
class PlayerBaseClient extends PlayerBase
{
static ScriptedLightBase m_PersonalLight;
static bool m_PersonalLightEnabledOnCurrentServer = false; // "disablePersonalLight" in server.cfg decides if this is true or false
static bool m_PersonalLightDisabledByDebug = false;
static bool m_PersonalLightIsSwitchedOn = true;
//! Creates PL if it doesn't exist already.
static void CreatePersonalLight()
{
if (!m_PersonalLight && ( !GetGame().IsServer() || !GetGame().IsMultiplayer() ))
{
m_PersonalLight = ScriptedLightBase.CreateLight(PersonalLight, "0 0 0");
}
}
/*
override void OnRPC(PlayerIdentity sender, int rpc_type, ParamsReadContext ctx)
{
super.OnRPC(sender, rpc_type, ctx);
switch( rpc_type )
{
case ERPCs.RPC_TOGGLE_PERSONAL_LIGHT:
{
Param1<bool> is_enabled = new Param1<bool>(false);
if (ctx.Read(is_enabled))
{
m_PersonalLightEnabledOnCurrentServer = is_enabled.param1;
UpdatePersonalLight();
}
break;
}
}
}*/
override void OnGameplayDataHandlerSync()
{
super.OnGameplayDataHandlerSync();
m_PersonalLightEnabledOnCurrentServer = !CfgGameplayHandler.GetDisablePersonalLight();
UpdatePersonalLight();
UpdateHitDirectionValues();
}
//! Controls the ON/OFF switch of the Personal Light. PL will still shine only if the server allows it.
static void SwitchPersonalLight(bool state)
{
if ( !GetGame().IsServer() || !GetGame().IsMultiplayer() )
{
m_PersonalLightIsSwitchedOn = state;
UpdatePersonalLight();
}
}
//! Updates state of PL
static void UpdatePersonalLight()
{
string param;
CreatePersonalLight();
// Allow PL unless it's disabled by debug or client-side starting parameter
if ( !GetCLIParam("disablePersonalLight", param) && !m_PersonalLightDisabledByDebug && m_PersonalLightIsSwitchedOn )
{
m_PersonalLight.SetEnabled(m_PersonalLightEnabledOnCurrentServer);
}
else
{
m_PersonalLight.SetEnabled(false);
}
}
static void UpdateHitDirectionValues()
{
HitDirectionEffectBase.CheckValues();
}
} |