private bool HasScriptEngine(Scene scene) { IScriptModule[] engines = scene.RequestModuleInterfaces <IScriptModule>(); if (engines.Length == 0) { return(false); } if (engines[0] == null) // happens under Phlox if disabled { return(false); } return(true); }
public ScenePresence( IClientAPI client, Scene world, AvatarAppearance appearance, PresenceType type) { m_scene = world; AttachmentsSyncLock = new Object(); AllowMovement = true; IsChildAgent = true; IsLoggingIn = false; m_sendCoarseLocationsMethod = SendCoarseLocationsDefault; Animator = new ScenePresenceAnimator(this); Overrides = new MovementAnimationOverrides(); PresenceType = type; DrawDistance = world.DefaultDrawDistance; RegionHandle = world.RegionInfo.RegionHandle; ControllingClient = client; Firstname = ControllingClient.FirstName; Lastname = ControllingClient.LastName; m_name = String.Format("{0} {1}", Firstname, Lastname); m_uuid = client.AgentId; LocalId = m_scene.AllocateLocalId(); LegacySitOffsets = m_scene.LegacySitOffsets; UserAccount account = m_scene.UserAccountService.GetUserAccount(m_scene.RegionInfo.ScopeID, m_uuid); if (account != null) m_userFlags = account.UserFlags; else m_userFlags = 0; if (account != null) UserLevel = account.UserLevel; IGroupsModule gm = m_scene.RequestModuleInterface<IGroupsModule>(); if (gm != null) Grouptitle = gm.GetGroupTitle(m_uuid); m_scriptEngines = m_scene.RequestModuleInterfaces<IScriptModule>(); AbsolutePosition = posLastSignificantMove = CameraPosition = m_lastCameraPosition = ControllingClient.StartPos; m_reprioritization_timer = new Timer(world.ReprioritizationInterval); m_reprioritization_timer.Elapsed += new ElapsedEventHandler(Reprioritize); m_reprioritization_timer.AutoReset = false; AdjustKnownSeeds(); RegisterToEvents(); SetDirectionVectors(); Appearance = appearance; m_stateMachine = new ScenePresenceStateMachine(this); }
public void SetState(string objXMLData, IScene ins) { if (!(ins is Scene)) { return; } Scene s = (Scene)ins; if (objXMLData == String.Empty) { return; } IScriptModule scriptModule = null; foreach (IScriptModule sm in s.RequestModuleInterfaces <IScriptModule>()) { if (sm.ScriptEngineName == s.DefaultScriptEngine) { scriptModule = sm; } else if (scriptModule == null) { scriptModule = sm; } } if (scriptModule == null) { return; } XmlDocument doc = new XmlDocument(); try { doc.LoadXml(objXMLData); } catch (Exception) // (System.Xml.XmlException) { // We will get here if the XML is invalid or in unit // tests. Really should determine which it is and either // fail silently or log it // Fail silently, for now. // TODO: Fix this // return; } XmlNodeList rootL = doc.GetElementsByTagName("ScriptData"); if (rootL.Count != 1) { return; } XmlElement rootE = (XmlElement)rootL[0]; XmlNodeList dataL = rootE.GetElementsByTagName("ScriptStates"); if (dataL.Count != 1) { return; } XmlElement dataE = (XmlElement)dataL[0]; foreach (XmlNode n in dataE.ChildNodes) { XmlElement stateE = (XmlElement)n; UUID itemID = new UUID(stateE.GetAttribute("UUID")); scriptModule.SetXMLState(itemID, n.OuterXml); } }
public void RegionLoaded(Scene scene) { IScriptModule[] scriptModules = scene.RequestModuleInterfaces<IScriptModule>(); foreach (IScriptModule scriptModule in scriptModules) { scriptModule.OnScriptRemoved += ScriptRemoved; scriptModule.OnObjectRemoved += ObjectRemoved; } }
public void OnTimer(double tickDuration) { if (m_skipLoops > 0) { m_skipLoops--; return; } if (m_timerStopped) // trap events still in air even after a timer.stop { return; } if (m_group == null) { return; } bool update = false; if (m_selected) { if (m_group.RootPart.Velocity != Vector3.Zero) { m_group.RootPart.Velocity = Vector3.Zero; m_group.SendGroupRootTerseUpdate(); } return; } if (m_isCrossing) { // if crossing and timer running then cross failed // wait some time then // retry to set the position that evtually caused the outbound // if still outside region this will call startCrossing below m_isCrossing = false; m_group.AbsolutePosition = m_nextPosition; if (!m_isCrossing) { StopTimer(); StartTimer(); } return; } if (m_frames.Count == 0) { GetNextList(); if (m_frames.Count == 0) { Stop(); Scene scene = m_group.Scene; IScriptModule[] scriptModules = scene.RequestModuleInterfaces <IScriptModule>(); foreach (IScriptModule m in scriptModules) { if (m == null) { continue; } m.PostObjectEvent(m_group.RootPart.UUID, "moving_end", new object[0]); } return; } m_currentFrame = m_frames[0]; m_currentFrame.TimeMS += (int)tickDuration; //force a update on a keyframe transition update = true; } m_currentFrame.TimeMS -= (int)tickDuration; // Do the frame processing double steps = (double)m_currentFrame.TimeMS / tickDuration; if (steps <= 0.0) { m_group.RootPart.Velocity = Vector3.Zero; m_group.RootPart.AngularVelocity = Vector3.Zero; m_nextPosition = (Vector3)m_currentFrame.Position; m_group.AbsolutePosition = m_nextPosition; // we are sending imediate updates, no doing force a extra terseUpdate // m_group.UpdateGroupRotationR((Quaternion)m_currentFrame.Rotation); m_group.RootPart.RotationOffset = (Quaternion)m_currentFrame.Rotation; m_frames.RemoveAt(0); if (m_frames.Count > 0) { m_currentFrame = m_frames[0]; } update = true; } else { float complete = ((float)m_currentFrame.TimeTotal - (float)m_currentFrame.TimeMS) / (float)m_currentFrame.TimeTotal; Vector3 v = (Vector3)m_currentFrame.Position - m_group.AbsolutePosition; Vector3 motionThisFrame = v / (float)steps; v = v * 1000 / m_currentFrame.TimeMS; if (Vector3.Mag(motionThisFrame) >= 0.05f) { // m_group.AbsolutePosition += motionThisFrame; m_nextPosition = m_group.AbsolutePosition + motionThisFrame; m_group.AbsolutePosition = m_nextPosition; //m_group.RootPart.Velocity = v; update = true; } if ((Quaternion)m_currentFrame.Rotation != m_group.GroupRotation) { Quaternion current = m_group.GroupRotation; Quaternion step = Quaternion.Slerp(m_currentFrame.StartRotation, (Quaternion)m_currentFrame.Rotation, complete); step.Normalize(); /* use simpler change detection * float angle = 0; * * float aa = current.X * current.X + current.Y * current.Y + current.Z * current.Z + current.W * current.W; * float bb = step.X * step.X + step.Y * step.Y + step.Z * step.Z + step.W * step.W; * float aa_bb = aa * bb; * * if (aa_bb == 0) * { * angle = 0; * } * else * { * float ab = current.X * step.X + * current.Y * step.Y + * current.Z * step.Z + * current.W * step.W; * float q = (ab * ab) / aa_bb; * * if (q > 1.0f) * { * angle = 0; * } * else * { * angle = (float)Math.Acos(2 * q - 1); * } * } * * if (angle > 0.01f) */ if (Math.Abs(step.X - current.X) > 0.001f || Math.Abs(step.Y - current.Y) > 0.001f || Math.Abs(step.Z - current.Z) > 0.001f) // assuming w is a dependente var { // m_group.UpdateGroupRotationR(step); m_group.RootPart.RotationOffset = step; //m_group.RootPart.UpdateAngularVelocity(m_currentFrame.AngularVelocity / 2); update = true; } } } if (update) { m_group.SendGroupRootTerseUpdate(); } }
private ScenePresence(IClientAPI client, Scene world, RegionInfo reginfo) : this() { m_rootRegionHandle = reginfo.RegionHandle; m_controllingClient = client; m_firstname = m_controllingClient.FirstName; m_lastname = m_controllingClient.LastName; m_name = String.Format("{0} {1}", m_firstname, m_lastname); m_scene = world; m_uuid = client.AgentId; m_regionInfo = reginfo; m_localId = m_scene.AllocateLocalId(); UserAccount account = m_scene.UserAccountService.GetUserAccount(m_scene.RegionInfo.ScopeID, m_uuid); if (account != null) m_userLevel = account.UserLevel; IGroupsModule gm = m_scene.RequestModuleInterface<IGroupsModule>(); if (gm != null) m_grouptitle = gm.GetGroupTitle(m_uuid); m_scriptEngines = m_scene.RequestModuleInterfaces<IScriptModule>(); AbsolutePosition = posLastSignificantMove = m_CameraCenter = m_lastCameraCenter = m_controllingClient.StartPos; m_reprioritization_timer = new Timer(world.ReprioritizationInterval); m_reprioritization_timer.Elapsed += new ElapsedEventHandler(Reprioritize); m_reprioritization_timer.AutoReset = false; AdjustKnownSeeds(); // TODO: I think, this won't send anything, as we are still a child here... Animator.TrySetMovementAnimation("STAND"); // we created a new ScenePresence (a new child agent) in a fresh region. // Request info about all the (root) agents in this region // Note: This won't send data *to* other clients in that region (children don't send) SendInitialFullUpdateToAllClients(); RegisterToEvents(); SetDirectionVectors(); }
private ScenePresence(IClientAPI client, Scene world, RegionInfo reginfo) { m_regionHandle = reginfo.RegionHandle; m_controllingClient = client; Firstname = m_controllingClient.FirstName; Lastname = m_controllingClient.LastName; m_name = String.Format("{0} {1}", Firstname, Lastname); m_scene = world; m_uuid = client.AgentId; m_regionInfo = reginfo; m_localId = m_scene.AllocateLocalId(); m_useFlySlow = m_scene.m_useFlySlow; m_usePreJump = m_scene.m_usePreJump; IGroupsModule gm = m_scene.RequestModuleInterface<IGroupsModule>(); if (gm != null) m_grouptitle = gm.GetGroupTitle(m_uuid); m_scriptEngines = m_scene.RequestModuleInterfaces<IScriptModule>(); ISceneViewModule sceneViewModule = m_scene.RequestModuleInterface<ISceneViewModule>(); if (sceneViewModule != null) m_sceneView = sceneViewModule.CreateSceneView(this); else m_log.Warn("[SCENE PRESENCE]: Failed to create a scene view"); SetAgentPositionInfo(null, true, m_controllingClient.StartPos, null, Vector3.Zero, m_velocity); m_animPersistUntil = 0; RegisterToEvents(); SetDirectionVectors(); SetDirectionFlags(); m_remotePresences = new AvatarRemotePresences(world, this); m_connection = world.ConnectionManager.GetConnection(this.UUID); if (m_connection != null) // can be null for bots which don't have a LLCV m_connection.ScenePresence = this; // Prime (cache) the user's group list. m_scene.UserGroupsGet(this.UUID); }
private ScenePresence(IClientAPI client, Scene world, RegionInfo reginfo) { m_sendCourseLocationsMethod = SendCoarseLocationsDefault; CreateSceneViewer(); m_regionHandle = reginfo.RegionHandle; m_controllingClient = client; m_firstname = m_controllingClient.FirstName; m_lastname = m_controllingClient.LastName; m_name = String.Format("{0} {1}", m_firstname, m_lastname); m_scene = world; m_uuid = client.AgentId; m_regionInfo = reginfo; m_localId = m_scene.AllocateLocalId(); m_useFlySlow = m_scene.m_useFlySlow; m_usePreJump = m_scene.m_usePreJump; IGroupsModule gm = m_scene.RequestModuleInterface<IGroupsModule>(); if (gm != null) m_grouptitle = gm.GetGroupTitle(m_uuid); m_scriptEngines = m_scene.RequestModuleInterfaces<IScriptModule>(); AbsolutePosition = m_controllingClient.StartPos; AdjustKnownSeeds(); TrySetMovementAnimation("STAND"); // TODO: I think, this won't send anything, as we are still a child here... // we created a new ScenePresence (a new child agent) in a fresh region. // Request info about all the (root) agents in this region // Note: This won't send data *to* other clients in that region (children don't send) SendInitialFullUpdateToAllClients(); RegisterToEvents(); SetDirectionVectors(); }
public ScenePresence( IClientAPI client, Scene world, AvatarAppearance appearance, PresenceType type) { m_scene = world; AttachmentsSyncLock = new Object(); AllowMovement = true; IsChildAgent = true; IsLoggingIn = false; m_sendCoarseLocationsMethod = SendCoarseLocationsDefault; Animator = new ScenePresenceAnimator(this); Overrides = new MovementAnimationOverrides(); PresenceType = type; DrawDistance = world.DefaultDrawDistance; RegionHandle = world.RegionInfo.RegionHandle; ControllingClient = client; Firstname = ControllingClient.FirstName; Lastname = ControllingClient.LastName; m_name = String.Format("{0} {1}", Firstname, Lastname); m_uuid = client.AgentId; LocalId = m_scene.AllocateLocalId(); LegacySitOffsets = m_scene.LegacySitOffsets; UserAccount account = m_scene.UserAccountService.GetUserAccount(m_scene.RegionInfo.ScopeID, m_uuid); if (account != null) m_userFlags = account.UserFlags; else m_userFlags = 0; if (account != null) UserLevel = account.UserLevel; // IGroupsModule gm = m_scene.RequestModuleInterface<IGroupsModule>(); // if (gm != null) // Grouptitle = gm.GetGroupTitle(m_uuid); m_scriptEngines = m_scene.RequestModuleInterfaces<IScriptModule>(); AbsolutePosition = posLastMove = posLastSignificantMove = CameraPosition = m_reprioritizationLastPosition = ControllingClient.StartPos; m_reprioritizationLastDrawDistance = DrawDistance; // disable updates workjobs for now childUpdatesBusy = true; m_reprioritizationBusy = true; AdjustKnownSeeds(); RegisterToEvents(); SetDirectionVectors(); Appearance = appearance; m_stateMachine = new ScenePresenceStateMachine(this); HealRate = 0.5f; IConfig sconfig = m_scene.Config.Configs["EntityTransfer"]; if (sconfig != null) { string lpb = sconfig.GetString("LandingPointBehavior", "LandingPointBehavior_OS"); if (lpb == "LandingPointBehavior_SL") m_LandingPointBehavior = LandingPointBehavior.SL; } }
public static bool TryGetScriptInstanceRunning(Scene scene, TaskInventoryItem item, out bool running) { running = false; if (item.InvType != (int)InventoryType.LSL) return false; IScriptModule[] engines = scene.RequestModuleInterfaces<IScriptModule>(); if (engines == null) // No engine at all return false; foreach (IScriptModule e in engines) { if (e.HasScript(item.ItemID, out running)) return true; } return false; }
private bool HasScriptEngine(Scene scene) { IScriptModule[] engines = scene.RequestModuleInterfaces<IScriptModule>(); if (engines.Length == 0) return false; if (engines[0] == null) // happens under Phlox if disabled return false; return true; }
public ScenePresence( IClientAPI client, Scene world, AvatarAppearance appearance, PresenceType type) { AttachmentsSyncLock = new Object(); m_sendCourseLocationsMethod = SendCoarseLocationsDefault; Animator = new ScenePresenceAnimator(this); PresenceType = type; DrawDistance = world.DefaultDrawDistance; RegionHandle = world.RegionInfo.RegionHandle; ControllingClient = client; Firstname = ControllingClient.FirstName; Lastname = ControllingClient.LastName; m_name = String.Format("{0} {1}", Firstname, Lastname); m_scene = world; m_uuid = client.AgentId; LocalId = m_scene.AllocateLocalId(); UserAccount account = m_scene.UserAccountService.GetUserAccount(m_scene.RegionInfo.ScopeID, m_uuid); if (account != null) m_userFlags = account.UserFlags; else m_userFlags = 0; if (account != null) UserLevel = account.UserLevel; IGroupsModule gm = m_scene.RequestModuleInterface<IGroupsModule>(); if (gm != null) Grouptitle = gm.GetGroupTitle(m_uuid); m_scriptEngines = m_scene.RequestModuleInterfaces<IScriptModule>(); AbsolutePosition = posLastSignificantMove = CameraPosition = m_lastCameraPosition = ControllingClient.StartPos; m_reprioritization_timer = new Timer(world.ReprioritizationInterval); m_reprioritization_timer.Elapsed += new ElapsedEventHandler(Reprioritize); m_reprioritization_timer.AutoReset = false; AdjustKnownSeeds(); // TODO: I think, this won't send anything, as we are still a child here... Animator.TrySetMovementAnimation("STAND"); // we created a new ScenePresence (a new child agent) in a fresh region. // Request info about all the (root) agents in this region // Note: This won't send data *to* other clients in that region (children don't send) // MIC: This gets called again in CompleteMovement // SendInitialFullUpdateToAllClients(); SendOtherAgentsAvatarDataToMe(); SendOtherAgentsAppearanceToMe(); RegisterToEvents(); SetDirectionVectors(); Appearance = appearance; }