refactor: Simplify by combining SafeSendControlsToScripts() from fe8e835
into SendControlsToScripts() (instead of SendControlToScripts()).
parent
fe8e835bfc
commit
d0598c63f3
|
@ -1336,7 +1336,7 @@ namespace OpenSim.Region.Framework.Scenes
|
|||
PhysicsActor actor = PhysicsActor;
|
||||
if (actor == null)
|
||||
{
|
||||
SafeSendControlsToScripts(flagsForScripts);
|
||||
SendControlsToScripts(flagsForScripts);
|
||||
return;
|
||||
}
|
||||
|
||||
|
@ -1513,25 +1513,12 @@ namespace OpenSim.Region.Framework.Scenes
|
|||
if (update_movementflag && ParentID == 0)
|
||||
Animator.UpdateMovementAnimations();
|
||||
|
||||
SafeSendControlsToScripts(flagsForScripts);
|
||||
SendControlsToScripts(flagsForScripts);
|
||||
}
|
||||
|
||||
m_scene.EventManager.TriggerOnClientMovement(this);
|
||||
}
|
||||
|
||||
private void SafeSendControlsToScripts(uint flagsForScripts)
|
||||
{
|
||||
lock (scriptedcontrols)
|
||||
{
|
||||
if (scriptedcontrols.Count > 0)
|
||||
{
|
||||
// Notify the scripts only after calling UpdateMovementAnimations(), so that if a script
|
||||
// (e.g., a walking script) checks which animation is active it will be the correct animation.
|
||||
SendControlToScripts(flagsForScripts);
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
/// <summary>
|
||||
/// Calculate an update to move the presence to the set target.
|
||||
/// </summary>
|
||||
|
@ -3687,8 +3674,15 @@ namespace OpenSim.Region.Framework.Scenes
|
|||
}
|
||||
}
|
||||
|
||||
internal void SendControlToScripts(uint flags)
|
||||
private void SendControlsToScripts(uint flags)
|
||||
{
|
||||
// Notify the scripts only after calling UpdateMovementAnimations(), so that if a script
|
||||
// (e.g., a walking script) checks which animation is active it will be the correct animation.
|
||||
lock (scriptedcontrols)
|
||||
{
|
||||
if (scriptedcontrols.Count <= 0)
|
||||
return;
|
||||
|
||||
ScriptControlled allflags = ScriptControlled.CONTROL_ZERO;
|
||||
|
||||
if (MouseDown)
|
||||
|
@ -3706,6 +3700,7 @@ namespace OpenSim.Region.Framework.Scenes
|
|||
allflags |= ScriptControlled.CONTROL_ML_LBUTTON;
|
||||
MouseDown = true;
|
||||
}
|
||||
|
||||
if ((flags & (uint)AgentManager.ControlFlags.AGENT_CONTROL_LBUTTON_DOWN) != 0)
|
||||
{
|
||||
allflags |= ScriptControlled.CONTROL_LBUTTON;
|
||||
|
@ -3717,38 +3712,44 @@ namespace OpenSim.Region.Framework.Scenes
|
|||
{
|
||||
allflags |= ScriptControlled.CONTROL_FWD;
|
||||
}
|
||||
|
||||
if ((flags & (uint)AgentManager.ControlFlags.AGENT_CONTROL_AT_NEG) != 0 || (flags & (uint)AgentManager.ControlFlags.AGENT_CONTROL_NUDGE_AT_NEG) != 0)
|
||||
{
|
||||
allflags |= ScriptControlled.CONTROL_BACK;
|
||||
}
|
||||
|
||||
if ((flags & (uint)AgentManager.ControlFlags.AGENT_CONTROL_UP_POS) != 0 || (flags & (uint)AgentManager.ControlFlags.AGENT_CONTROL_NUDGE_UP_POS) != 0)
|
||||
{
|
||||
allflags |= ScriptControlled.CONTROL_UP;
|
||||
}
|
||||
|
||||
if ((flags & (uint)AgentManager.ControlFlags.AGENT_CONTROL_UP_NEG) != 0 || (flags & (uint)AgentManager.ControlFlags.AGENT_CONTROL_NUDGE_UP_NEG) != 0)
|
||||
{
|
||||
allflags |= ScriptControlled.CONTROL_DOWN;
|
||||
}
|
||||
|
||||
if ((flags & (uint)AgentManager.ControlFlags.AGENT_CONTROL_LEFT_POS) != 0 || (flags & (uint)AgentManager.ControlFlags.AGENT_CONTROL_NUDGE_LEFT_POS) != 0)
|
||||
{
|
||||
allflags |= ScriptControlled.CONTROL_LEFT;
|
||||
}
|
||||
|
||||
if ((flags & (uint)AgentManager.ControlFlags.AGENT_CONTROL_LEFT_NEG) != 0 || (flags & (uint)AgentManager.ControlFlags.AGENT_CONTROL_NUDGE_LEFT_NEG) != 0)
|
||||
{
|
||||
allflags |= ScriptControlled.CONTROL_RIGHT;
|
||||
}
|
||||
|
||||
if ((flags & (uint)AgentManager.ControlFlags.AGENT_CONTROL_YAW_NEG) != 0)
|
||||
{
|
||||
allflags |= ScriptControlled.CONTROL_ROT_RIGHT;
|
||||
}
|
||||
|
||||
if ((flags & (uint)AgentManager.ControlFlags.AGENT_CONTROL_YAW_POS) != 0)
|
||||
{
|
||||
allflags |= ScriptControlled.CONTROL_ROT_LEFT;
|
||||
}
|
||||
|
||||
// optimization; we have to check per script, but if nothing is pressed and nothing changed, we can skip that
|
||||
if (allflags != ScriptControlled.CONTROL_ZERO || allflags != LastCommands)
|
||||
{
|
||||
lock (scriptedcontrols)
|
||||
{
|
||||
foreach (KeyValuePair<UUID, ScriptControllers> kvp in scriptedcontrols)
|
||||
{
|
||||
|
@ -3758,6 +3759,7 @@ namespace OpenSim.Region.Framework.Scenes
|
|||
ScriptControlled localHeld = allflags & scriptControlData.eventControls; // the flags interesting for us
|
||||
ScriptControlled localLast = LastCommands & scriptControlData.eventControls; // the activated controls in the last cycle
|
||||
ScriptControlled localChange = localHeld ^ localLast; // the changed bits
|
||||
|
||||
if (localHeld != ScriptControlled.CONTROL_ZERO || localChange != ScriptControlled.CONTROL_ZERO)
|
||||
{
|
||||
// only send if still pressed or just changed
|
||||
|
@ -3765,10 +3767,10 @@ namespace OpenSim.Region.Framework.Scenes
|
|||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
LastCommands = allflags;
|
||||
}
|
||||
}
|
||||
|
||||
internal static AgentManager.ControlFlags RemoveIgnoredControls(AgentManager.ControlFlags flags, ScriptControlled ignored)
|
||||
{
|
||||
|
|
Loading…
Reference in New Issue