本文整理汇总了C#中ScriptControlled类的典型用法代码示例。如果您正苦于以下问题:C# ScriptControlled类的具体用法?C# ScriptControlled怎么用?C# ScriptControlled使用的例子?那么恭喜您, 这里精选的类代码示例或许可以为您提供帮助。
ScriptControlled类属于命名空间,在下文中一共展示了ScriptControlled类的14个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的C#代码示例。
示例1: RemoveIgnoredControls
internal static AgentManager.ControlFlags RemoveIgnoredControls(AgentManager.ControlFlags flags, ScriptControlled ignored)
{
if (ignored == ScriptControlled.CONTROL_ZERO)
return flags;
if ((ignored & ScriptControlled.CONTROL_BACK) != 0)
flags &= ~(AgentManager.ControlFlags.AGENT_CONTROL_AT_NEG | AgentManager.ControlFlags.AGENT_CONTROL_NUDGE_AT_NEG);
if ((ignored & ScriptControlled.CONTROL_FWD) != 0)
flags &= ~(AgentManager.ControlFlags.AGENT_CONTROL_NUDGE_AT_POS | AgentManager.ControlFlags.AGENT_CONTROL_AT_POS);
if ((ignored & ScriptControlled.CONTROL_DOWN) != 0)
flags &= ~(AgentManager.ControlFlags.AGENT_CONTROL_UP_NEG | AgentManager.ControlFlags.AGENT_CONTROL_NUDGE_UP_NEG);
if ((ignored & ScriptControlled.CONTROL_UP) != 0)
flags &= ~(AgentManager.ControlFlags.AGENT_CONTROL_NUDGE_UP_POS | AgentManager.ControlFlags.AGENT_CONTROL_UP_POS);
if ((ignored & ScriptControlled.CONTROL_LEFT) != 0)
flags &= ~(AgentManager.ControlFlags.AGENT_CONTROL_LEFT_POS | AgentManager.ControlFlags.AGENT_CONTROL_NUDGE_LEFT_POS);
if ((ignored & ScriptControlled.CONTROL_RIGHT) != 0)
flags &= ~(AgentManager.ControlFlags.AGENT_CONTROL_NUDGE_LEFT_NEG | AgentManager.ControlFlags.AGENT_CONTROL_LEFT_NEG);
if ((ignored & ScriptControlled.CONTROL_ROT_LEFT) != 0)
flags &= ~(AgentManager.ControlFlags.AGENT_CONTROL_YAW_NEG);
if ((ignored & ScriptControlled.CONTROL_ROT_RIGHT) != 0)
flags &= ~(AgentManager.ControlFlags.AGENT_CONTROL_YAW_POS);
if ((ignored & ScriptControlled.CONTROL_ML_LBUTTON) != 0)
flags &= ~(AgentManager.ControlFlags.AGENT_CONTROL_ML_LBUTTON_DOWN);
if ((ignored & ScriptControlled.CONTROL_LBUTTON) != 0)
flags &= ~(AgentManager.ControlFlags.AGENT_CONTROL_LBUTTON_UP | AgentManager.ControlFlags.AGENT_CONTROL_LBUTTON_DOWN);
//DIR_CONTROL_FLAG_FORWARD = AgentManager.ControlFlags.AGENT_CONTROL_AT_POS,
//DIR_CONTROL_FLAG_BACK = AgentManager.ControlFlags.AGENT_CONTROL_AT_NEG,
//DIR_CONTROL_FLAG_LEFT = AgentManager.ControlFlags.AGENT_CONTROL_LEFT_POS,
//DIR_CONTROL_FLAG_RIGHT = AgentManager.ControlFlags.AGENT_CONTROL_LEFT_NEG,
//DIR_CONTROL_FLAG_UP = AgentManager.ControlFlags.AGENT_CONTROL_UP_POS,
//DIR_CONTROL_FLAG_DOWN = AgentManager.ControlFlags.AGENT_CONTROL_UP_NEG,
//DIR_CONTROL_FLAG_DOWN_NUDGE = AgentManager.ControlFlags.AGENT_CONTROL_NUDGE_UP_NEG
return flags;
}
示例2: UnRegisterControlEventsToScript
public void UnRegisterControlEventsToScript(uint Obj_localID, UUID Script_item_UUID)
{
ScriptControllers takecontrols;
lock (scriptedcontrols)
{
if (scriptedcontrols.TryGetValue(Script_item_UUID, out takecontrols))
{
ScriptControlled sctc = takecontrols.eventControls;
ControllingClient.SendTakeControls((int)sctc, false, false);
ControllingClient.SendTakeControls((int)sctc, true, false);
scriptedcontrols.Remove(Script_item_UUID);
IgnoredControls = ScriptControlled.CONTROL_ZERO;
foreach (ScriptControllers scData in scriptedcontrols.Values)
{
IgnoredControls |= scData.ignoreControls;
}
}
}
}
示例3: SendControlsToScripts
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)
{
allflags = LastCommands & (ScriptControlled.CONTROL_ML_LBUTTON | ScriptControlled.CONTROL_LBUTTON);
if ((flags & (uint)AgentManager.ControlFlags.AGENT_CONTROL_LBUTTON_UP) != 0 || (flags & unchecked((uint)AgentManager.ControlFlags.AGENT_CONTROL_ML_LBUTTON_UP)) != 0)
{
allflags = ScriptControlled.CONTROL_ZERO;
MouseDown = true;
}
}
if ((flags & (uint)AgentManager.ControlFlags.AGENT_CONTROL_ML_LBUTTON_DOWN) != 0)
{
allflags |= ScriptControlled.CONTROL_ML_LBUTTON;
MouseDown = true;
}
if ((flags & (uint)AgentManager.ControlFlags.AGENT_CONTROL_LBUTTON_DOWN) != 0)
{
allflags |= ScriptControlled.CONTROL_LBUTTON;
MouseDown = true;
}
// find all activated controls, whether the scripts are interested in them or not
if ((flags & (uint)AgentManager.ControlFlags.AGENT_CONTROL_AT_POS) != 0 || (flags & (uint)AgentManager.ControlFlags.AGENT_CONTROL_NUDGE_AT_POS) != 0)
{
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)
{
foreach (KeyValuePair<UUID, ScriptControllers> kvp in scriptedcontrols)
{
UUID scriptUUID = kvp.Key;
ScriptControllers scriptControlData = kvp.Value;
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
m_scene.EventManager.TriggerControlEvent(scriptUUID, UUID, (uint)localHeld, (uint)localChange);
}
}
}
LastCommands = allflags;
}
}
示例4: HandleForceReleaseControls
public void HandleForceReleaseControls(IClientAPI remoteClient, UUID agentID)
{
IgnoredControls = ScriptControlled.CONTROL_ZERO;
lock (scriptedcontrols)
{
scriptedcontrols.Clear();
}
ControllingClient.SendTakeControls(int.MaxValue, false, false);
}
示例5: ClearControls
public void ClearControls()
{
IgnoredControls = ScriptControlled.CONTROL_ZERO;
lock (scriptedcontrols)
{
scriptedcontrols.Clear();
}
}
示例6: SendControlToScripts
internal void SendControlToScripts(uint flags)
{
ScriptControlled allflags = ScriptControlled.CONTROL_ZERO;
// The viewers send a stream of control flags repeatedly while there is movement. If no control is active,
// viewers send a CONTROL_NONE flag. This logic introduces a small repeat delay in controls to mimic the
// behavior in SL and thus retain LSL script compatibility.
//
// If an active control flag is sent and it has been a while since the last one,
// begin the delay interval.
if (flags != (uint)AgentManager.ControlFlags.NONE)
{
if (((uint)Environment.TickCount - m_LastControlsTime) > CONTROLS_REPEAT_DELAY)
{
m_NextControlsTime = 0;
}
m_LastControlsTime = (uint)Environment.TickCount;
}
// Let the first control event through, but set a delay interval.
if (m_NextControlsTime == 0)
{
m_NextControlsTime = (uint)Environment.TickCount + CONTROLS_REPEAT_DELAY;
}
// Drop the events until either the delay ends or a different set of flags arrive.
else if ((uint)Environment.TickCount < m_NextControlsTime && flags == m_LastControls)
{
// m_log.DebugFormat("[SCENE PRESENCE]: Skipped flags={0} now={1} next={2}", (AgentManager.ControlFlags)flags, Environment.TickCount, m_NextControlsTime);
return;
}
m_LastControls = flags;
// m_log.DebugFormat("[SCENE PRESENCE]: Processed flags={0} now={1} next={2}", (AgentManager.ControlFlags)flags, Environment.TickCount, m_NextControlsTime);
if (MouseDown)
{
allflags = LastCommands & (ScriptControlled.CONTROL_ML_LBUTTON | ScriptControlled.CONTROL_LBUTTON);
if ((flags & (uint)AgentManager.ControlFlags.AGENT_CONTROL_LBUTTON_UP) != 0 || (flags & unchecked((uint)AgentManager.ControlFlags.AGENT_CONTROL_ML_LBUTTON_UP)) != 0)
{
allflags = ScriptControlled.CONTROL_ZERO;
MouseDown = true;
}
}
if ((flags & (uint)AgentManager.ControlFlags.AGENT_CONTROL_ML_LBUTTON_DOWN) != 0)
{
allflags |= ScriptControlled.CONTROL_ML_LBUTTON;
MouseDown = true;
}
if ((flags & (uint)AgentManager.ControlFlags.AGENT_CONTROL_LBUTTON_DOWN) != 0)
{
allflags |= ScriptControlled.CONTROL_LBUTTON;
MouseDown = true;
}
// find all activated controls, whether the scripts are interested in them or not
if ((flags & (uint)AgentManager.ControlFlags.AGENT_CONTROL_AT_POS) != 0 || (flags & (uint)AgentManager.ControlFlags.AGENT_CONTROL_NUDGE_AT_POS) != 0)
{
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)
{
UUID[] scripts;
lock (m_scriptedcontrols)
{
// Must not call TriggerControlEvent with thes controls locked (deadlocks with m_items iterations).
scripts = new UUID[m_scriptedcontrols.Count];
m_scriptedcontrols.Keys.CopyTo(scripts, 0);
}
foreach (UUID scriptUUID in scripts)
//.........这里部分代码省略.........
示例7: RegisterControlEventsToScript
public void RegisterControlEventsToScript(int controls, int accept, int pass_on, uint Obj_localID, UUID Script_item_UUID)
{
SceneObjectPart p = m_scene.GetSceneObjectPart(Obj_localID);
if (p == null)
return;
ControllingClient.SendTakeControls(controls, false, false);
ControllingClient.SendTakeControls(controls, true, false);
ScriptControllers obj = new ScriptControllers();
obj.ignoreControls = ScriptControlled.CONTROL_ZERO;
obj.eventControls = ScriptControlled.CONTROL_ZERO;
obj.objectID = p.ParentGroup.UUID;
obj.itemID = Script_item_UUID;
if (pass_on == 0 && accept == 0)
{
IgnoredControls |= (ScriptControlled)controls;
obj.ignoreControls = (ScriptControlled)controls;
}
if (pass_on == 0 && accept == 1)
{
IgnoredControls |= (ScriptControlled)controls;
obj.ignoreControls = (ScriptControlled)controls;
obj.eventControls = (ScriptControlled)controls;
}
if (pass_on == 1 && accept == 1)
{
IgnoredControls = ScriptControlled.CONTROL_ZERO;
obj.eventControls = (ScriptControlled)controls;
obj.ignoreControls = ScriptControlled.CONTROL_ZERO;
}
lock (scriptedcontrols)
{
if (pass_on == 1 && accept == 0)
{
IgnoredControls &= ~(ScriptControlled)controls;
if (scriptedcontrols.ContainsKey(Script_item_UUID))
scriptedcontrols.Remove(Script_item_UUID);
}
else
{
scriptedcontrols[Script_item_UUID] = obj;
}
}
ControllingClient.SendTakeControls(controls, pass_on == 1 ? true : false, true);
}
示例8: RegisterControlEventsToScript
public void RegisterControlEventsToScript(int oldControls, int oldPassOn, int controls, int accept, int pass_on, uint Obj_localID, UUID Script_item_UUID, bool silent)
{
ScriptControllers obj = new ScriptControllers();
obj.ignoreControls = ScriptControlled.CONTROL_ZERO;
obj.eventControls = ScriptControlled.CONTROL_ZERO;
obj.itemID = Script_item_UUID;
obj.objID = Obj_localID;
SceneObjectPart part = m_scene.GetSceneObjectPart(Obj_localID);
if (part == null)
{
m_log.ErrorFormat("[SCENE PRESENCE]: Could not register control events to script in object {0}. Object was not found in the scene", Obj_localID);
return;
}
lock (m_scriptedcontrols)
{
if (pass_on == 0 && accept == 0)
{
IgnoredControls |= (ScriptControlled)controls;
obj.ignoreControls = (ScriptControlled)controls;
}
if (pass_on == 0 && accept == 1)
{
IgnoredControls |= (ScriptControlled)controls;
obj.ignoreControls = (ScriptControlled)controls;
obj.eventControls = (ScriptControlled)controls;
}
if (pass_on == 1 && accept == 1)
{
IgnoredControls = ScriptControlled.CONTROL_ZERO;
obj.eventControls = (ScriptControlled)controls;
obj.ignoreControls = ScriptControlled.CONTROL_ZERO;
}
if (pass_on == 1 && accept == 0)
{
IgnoredControls &= ~(ScriptControlled)controls;
RemoveScriptFromControlNotifications(Script_item_UUID, part);
}
else
{
AddScriptToControlNotifications(Script_item_UUID, part, ref obj);
}
}
if (!silent)
{
// SL includes these extra bits if you request FWD/BACK/LEFT/RIGHT
oldControls = AdjustControlsForNudges(oldControls);
controls = AdjustControlsForNudges(controls);
if (accept == 0)
{
if (pass_on == 0) // a=false, p=false
ControllingClient.SendTakeControls2(oldControls, false, oldPassOn != 0, ~controls, true, false);
else // false, true
ControllingClient.SendTakeControls2(oldControls, false, oldPassOn != 0, ~controls, true, true);
}
else
{
if (pass_on == 0) // a=true, p=false
ControllingClient.SendTakeControls2(oldControls, false, oldPassOn != 0, controls, true, false);
else // true, true
ControllingClient.SendTakeControls2(oldControls, false, oldPassOn != 0, controls, true, true);
}
}
}
示例9: UnRegisterControlEventsToScript
public void UnRegisterControlEventsToScript(uint Obj_localID, UUID Script_item_UUID, bool silent)
{
SceneObjectPart part = m_scene.GetSceneObjectPart(Obj_localID);
lock (m_scriptedcontrols)
{
int controls;
bool accept;
bool pass_on;
if (m_scriptedcontrols.ContainsKey(Script_item_UUID))
{
ScriptControllers takecontrolls = m_scriptedcontrols[Script_item_UUID];
if (m_isChildAgent)
m_log.InfoFormat("[SCENE PRESENCE]: UnRegisterControlEventsToScript2: Request({0}) from CHILD agent {1}", silent.ToString(), this.UUID.ToString());
if (takecontrolls.ignoreControls == ScriptControlled.CONTROL_ZERO)
{
// the only one with zero ignoreControls is a=true,p=true case
controls = (int)takecontrolls.eventControls;
accept = true;
pass_on = true;
} else
if (takecontrolls.eventControls == ScriptControlled.CONTROL_ZERO)
{
// the only one with zero eventControls is a=false,p=false case
controls = (int)takecontrolls.ignoreControls;
accept = false;
pass_on = false;
} else {
// that only leaves a=true,p=false case
controls = (int)takecontrolls.eventControls; // also in ignoreControls
accept = true;
pass_on = false;
}
RemoveScriptFromControlNotifications(Script_item_UUID, part);
IgnoredControls = ScriptControlled.CONTROL_ZERO;
foreach (ScriptControllers scData in m_scriptedcontrols.Values)
{
IgnoredControls |= scData.ignoreControls;
}
}
else
{
// the only one with no m_scriptedcontrols is a=false,p=true
controls = 0;
accept = false;
pass_on = true;
}
// SL includes these extra bits if you request FWD/BACK/LEFT/RIGHT
controls = AdjustControlsForNudges(controls);
// accept==false sends inverted controls bits
if (accept == false)
controls = ~controls;
if (!(silent || m_isChildAgent)) // don't notify the viewer if silent or child agent
{
// accept isn't used in this case, always false on release
ControllingClient.SendTakeControls(controls, false, pass_on);
}
}
}
示例10: MakeChildAgent
/// <summary>
/// This turns a root agent into a child agent
/// when an agent departs this region for a neighbor, this gets called.
///
/// It doesn't get called for a teleport. Reason being, an agent that
/// teleports out may not end up anywhere near this region
/// </summary>
public void MakeChildAgent(ulong destinationRegionHandle)
{
DumpDebug("MakeChildAgent", "n/a");
m_log.Info("[SCENE]: " + Scene.RegionInfo.RegionName + ": MakeChildAgent...");
m_animations.Clear(m_scene.AvatarIsInTransitOnPrim(UUID));
// Clear controls in the child SP. (They'll be set again if the root agent returns, if needed.
lock (m_scriptedcontrols)
{
m_scriptedcontrols.Clear();
IgnoredControls = ScriptControlled.CONTROL_ZERO;
}
// m_log.DebugFormat(
// "[SCENE PRESENCE]: Downgrading root agent {0}, {1} to a child agent in {2}",
// Name, UUID, m_scene.RegionInfo.RegionName);
// Don't zero out the velocity since this can cause problems when an avatar is making a region crossing,
// depending on the exact timing. This shouldn't matter anyway since child agent positions are not updated.
//Velocity = Vector3.Zero;
RemoveFromPhysicalScene();
m_requestedSitTargetID = 0;
m_requestedSitTargetUUID = UUID.Zero;
lock (m_posInfo)
{
Vector3 restorePos = m_posInfo.Parent == null ? AbsolutePosition : m_posInfo.m_parentPos;
IsFullyInRegion = false;
m_isChildAgent = true;
m_posInfo.Position = restorePos;
m_posInfo.Parent = null;
m_posInfo.m_parentPos = Vector3.Zero;
m_scene.SwapRootAgentCount(true);
currentParcelUUID = UUID.Zero; // so that if the agent reenters this region, it recognizes it as a parcel change.
if (!IsBot)
m_scene.CommsManager.UserService.UnmakeLocalUser(m_uuid);
}
m_scene.EventManager.TriggerOnMakeChildAgent(this);
ClearSceneView();
}
示例11: SendControlToScripts
internal void SendControlToScripts(uint flags)
{
ScriptControlled allflags = ScriptControlled.CONTROL_ZERO;
if (MouseDown)
{
allflags = LastCommands & (ScriptControlled.CONTROL_ML_LBUTTON | ScriptControlled.CONTROL_LBUTTON);
if ((flags & (uint)AgentManager.ControlFlags.AGENT_CONTROL_LBUTTON_UP) != 0 || (flags & unchecked((uint)AgentManager.ControlFlags.AGENT_CONTROL_ML_LBUTTON_UP)) != 0)
{
allflags = ScriptControlled.CONTROL_ZERO;
MouseDown = true;
}
}
if ((flags & (uint)AgentManager.ControlFlags.AGENT_CONTROL_ML_LBUTTON_DOWN) != 0)
{
allflags |= ScriptControlled.CONTROL_ML_LBUTTON;
MouseDown = true;
}
if ((flags & (uint)AgentManager.ControlFlags.AGENT_CONTROL_LBUTTON_DOWN) != 0)
{
allflags |= ScriptControlled.CONTROL_LBUTTON;
MouseDown = true;
}
// find all activated controls, whether the scripts are interested in them or not
if ((flags & (uint)AgentManager.ControlFlags.AGENT_CONTROL_AT_POS) != 0 || (flags & (uint)AgentManager.ControlFlags.AGENT_CONTROL_NUDGE_AT_POS) != 0)
{
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 (UUID scriptUUID in scriptedcontrols.Keys)
{
ScriptControllers scriptControlData = scriptedcontrols[scriptUUID];
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
m_scene.EventManager.TriggerControlEvent(scriptControlData.objID, scriptUUID, UUID, (uint)localHeld, (uint)localChange);
}
}
}
}
LastCommands = allflags;
}
示例12: RegisterControlEventsToScript
public void RegisterControlEventsToScript(int controls, int accept, int pass_on, uint Obj_localID, UUID Script_item_UUID)
{
ScriptControllers obj = new ScriptControllers();
obj.ignoreControls = ScriptControlled.CONTROL_ZERO;
obj.eventControls = ScriptControlled.CONTROL_ZERO;
obj.itemID = Script_item_UUID;
obj.objID = Obj_localID;
if (pass_on == 0 && accept == 0)
{
IgnoredControls |= (ScriptControlled)controls;
obj.ignoreControls = (ScriptControlled)controls;
}
if (pass_on == 0 && accept == 1)
{
IgnoredControls |= (ScriptControlled)controls;
obj.ignoreControls = (ScriptControlled)controls;
obj.eventControls = (ScriptControlled)controls;
}
if (pass_on == 1 && accept == 1)
{
IgnoredControls = ScriptControlled.CONTROL_ZERO;
obj.eventControls = (ScriptControlled)controls;
obj.ignoreControls = ScriptControlled.CONTROL_ZERO;
}
lock (scriptedcontrols)
{
if (pass_on == 1 && accept == 0)
{
IgnoredControls &= ~(ScriptControlled)controls;
if (scriptedcontrols.ContainsKey(Script_item_UUID))
scriptedcontrols.Remove(Script_item_UUID);
}
else
{
if (scriptedcontrols.ContainsKey(Script_item_UUID))
{
scriptedcontrols[Script_item_UUID] = obj;
}
else
{
scriptedcontrols.Add(Script_item_UUID, obj);
}
}
}
ControllingClient.SendTakeControls(controls, pass_on == 1 ? true : false, true);
}
示例13: RegisterControlEventsToScript
public void RegisterControlEventsToScript(int controls, int accept, int pass_on, ISceneChildEntity part,
UUID Script_item_UUID)
{
ScriptControllers obj = new ScriptControllers
{
ignoreControls = ScriptControlled.CONTROL_ZERO,
eventControls = ScriptControlled.CONTROL_ZERO,
itemID = Script_item_UUID,
part = part
};
if (pass_on == 0 && accept == 0)
{
IgnoredControls |= (ScriptControlled) controls;
obj.ignoreControls = (ScriptControlled) controls;
}
if (pass_on == 0 && accept == 1)
{
IgnoredControls |= (ScriptControlled) controls;
obj.ignoreControls = (ScriptControlled) controls;
obj.eventControls = (ScriptControlled) controls;
}
if (pass_on == 1 && accept == 1)
{
IgnoredControls = ScriptControlled.CONTROL_ZERO;
obj.eventControls = (ScriptControlled) controls;
obj.ignoreControls = ScriptControlled.CONTROL_ZERO;
}
lock (scriptedcontrols)
{
if (pass_on == 1 && accept == 0)
{
IgnoredControls &= ~(ScriptControlled) controls;
if (scriptedcontrols.ContainsKey(Script_item_UUID))
scriptedcontrols.Remove(Script_item_UUID);
}
else
{
scriptedcontrols[Script_item_UUID] = obj;
}
}
m_sp.ControllingClient.SendTakeControls(controls, pass_on == 1 ? true : false, true);
}
示例14: HandleForceReleaseControls
public void HandleForceReleaseControls(IClientAPI remoteClient, UUID agentID)
{
IgnoredControls = ScriptControlled.CONTROL_ZERO;
scriptedcontrolsRwLock.AcquireWriterLock(-1);
try
{
scriptedcontrols.Clear();
}
finally
{
scriptedcontrolsRwLock.ReleaseWriterLock();
}
ControllingClient.SendTakeControls(int.MaxValue, false, false);
}