public TryGetScenePresence ( UUID avatarId, ScenePresence &avatar ) : bool | ||
avatarId | UUID | |
avatar | ScenePresence | |
return | bool |
public UUID CreateNPC( string firstname, string lastname, Vector3 position, UUID owner, bool senseAsAgent, Scene scene, AvatarAppearance appearance) { NPCAvatar npcAvatar = new NPCAvatar(firstname, lastname, position, owner, senseAsAgent, scene); npcAvatar.CircuitCode = (uint)Util.RandomClass.Next(0, int.MaxValue); m_log.DebugFormat( "[NPC MODULE]: Creating NPC {0} {1} {2}, owner={3}, senseAsAgent={4} at {5} in {6}", firstname, lastname, npcAvatar.AgentId, owner, senseAsAgent, position, scene.RegionInfo.RegionName); AgentCircuitData acd = new AgentCircuitData(); acd.AgentID = npcAvatar.AgentId; acd.firstname = firstname; acd.lastname = lastname; acd.ServiceURLs = new Dictionary<string, object>(); AvatarAppearance npcAppearance = new AvatarAppearance(appearance, true); acd.Appearance = npcAppearance; // for (int i = 0; i < acd.Appearance.Texture.FaceTextures.Length; i++) // { // m_log.DebugFormat( // "[NPC MODULE]: NPC avatar {0} has texture id {1} : {2}", // acd.AgentID, i, acd.Appearance.Texture.FaceTextures[i]); // } lock (m_avatars) { scene.AuthenticateHandler.AddNewCircuit(npcAvatar.CircuitCode, acd); scene.AddNewClient(npcAvatar, PresenceType.Npc); ScenePresence sp; if (scene.TryGetScenePresence(npcAvatar.AgentId, out sp)) { // m_log.DebugFormat( // "[NPC MODULE]: Successfully retrieved scene presence for NPC {0} {1}", sp.Name, sp.UUID); sp.CompleteMovement(npcAvatar, false); m_avatars.Add(npcAvatar.AgentId, npcAvatar); m_log.DebugFormat("[NPC MODULE]: Created NPC with id {0}", npcAvatar.AgentId); return npcAvatar.AgentId; } else { m_log.WarnFormat("[NPC MODULE]: Could not find scene presence for NPC {0} {1}", sp.Name, sp.UUID); return UUID.Zero; } } }
public UUID CreateNPC(string firstname, string lastname, Vector3 position, Scene scene, UUID cloneAppearanceFrom) { NPCAvatar npcAvatar = new NPCAvatar(firstname, lastname, position, scene); npcAvatar.CircuitCode = (uint)Util.RandomClass.Next(0, int.MaxValue); m_log.DebugFormat( "[NPC MODULE]: Creating NPC {0} {1} {2} at {3} in {4}", firstname, lastname, npcAvatar.AgentId, position, scene.RegionInfo.RegionName); AgentCircuitData acd = new AgentCircuitData(); acd.AgentID = npcAvatar.AgentId; acd.firstname = firstname; acd.lastname = lastname; acd.ServiceURLs = new Dictionary<string, object>(); AvatarAppearance originalAppearance = GetAppearance(cloneAppearanceFrom, scene); AvatarAppearance npcAppearance = new AvatarAppearance(originalAppearance, true); acd.Appearance = npcAppearance; scene.AuthenticateHandler.AddNewCircuit(npcAvatar.CircuitCode, acd); scene.AddNewClient(npcAvatar); ScenePresence sp; if (scene.TryGetScenePresence(npcAvatar.AgentId, out sp)) { m_log.DebugFormat( "[NPC MODULE]: Successfully retrieved scene presence for NPC {0} {1}", sp.Name, sp.UUID); // Shouldn't call this - temporary. sp.CompleteMovement(npcAvatar); // sp.SendAppearanceToAllOtherAgents(); // // // Send animations back to the avatar as well // sp.Animator.SendAnimPack(); } else { m_log.WarnFormat("[NPC MODULE]: Could not find scene presence for NPC {0} {1}", sp.Name, sp.UUID); } lock (m_avatars) m_avatars.Add(npcAvatar.AgentId, npcAvatar); m_log.DebugFormat("[NPC MODULE]: Created NPC with id {0}", npcAvatar.AgentId); return npcAvatar.AgentId; }
public void Autopilot(UUID agentID, Scene scene, Vector3 pos) { lock (m_avatars) { if (m_avatars.ContainsKey(agentID)) { ScenePresence sp; scene.TryGetScenePresence(agentID, out sp); sp.DoAutoPilot(0, pos, m_avatars[agentID]); } } }
public bool Whisper(UUID agentID, Scene scene, string text, int channel) { lock (m_avatars) { if (m_avatars.ContainsKey(agentID)) { ScenePresence sp; scene.TryGetScenePresence(agentID, out sp); m_avatars[agentID].Whisper(channel, text); return true; } } return false; }
public bool AllowTeleport(UUID userID, Scene scene, Vector3 Position, AgentCircuitData ACD, out Vector3 newPosition, out string reason) { newPosition = Position; UserAccount account = scene.UserAccountService.GetUserAccount(scene.RegionInfo.ScopeID, userID); ScenePresence Sp = scene.GetScenePresence(userID); if (account == null) { reason = "Failed authentication."; return false; //NO! } //Check how long its been since the last TP if (m_enabledBlockTeleportSeconds && Sp != null && !Sp.IsChildAgent) { if (TimeSinceLastTeleport.ContainsKey(Sp.Scene.RegionInfo.RegionID)) { if (TimeSinceLastTeleport[Sp.Scene.RegionInfo.RegionID] > Util.UnixTimeSinceEpoch()) { reason = "Too many teleports. Please try again soon."; return false; // Too soon since the last TP } } TimeSinceLastTeleport[Sp.Scene.RegionInfo.RegionID] = Util.UnixTimeSinceEpoch() + ((int)(SecondsBeforeNextTeleport)); } //Gods tp freely if ((Sp != null && Sp.GodLevel != 0) || account.UserLevel != 0) { reason = ""; return true; } //Check whether they fit any ban criteria if (Sp != null) { foreach (string banstr in BanCriteria) { if (Sp.Name.Contains(banstr)) { reason = "You have been banned from this region."; return false; } else if (((System.Net.IPEndPoint)Sp.ControllingClient.GetClientEP()).Address.ToString().Contains(banstr)) { reason = "You have been banned from this region."; return false; } } } EstateSettings ES = scene.RegionInfo.EstateSettings; if (scene.RegionInfo.RegionSettings.AgentLimit < scene.GetRootAgentCount() + 1) { reason = "Too many agents at this time. Please come back later."; return false; } List<EstateBan> EstateBans = new List<EstateBan>(ES.EstateBans); int i = 0; //Check bans foreach (EstateBan ban in EstateBans) { if (ban.BannedUserID == userID) { string banIP = ((System.Net.IPEndPoint)Sp.ControllingClient.GetClientEP()).Address.ToString(); if (ban.BannedHostIPMask != banIP) //If it changed, ban them again { //Add the ban with the new hostname ES.AddBan(new EstateBan() { BannedHostIPMask = banIP, BannedUserID = ban.BannedUserID, EstateID = ban.EstateID, BannedHostAddress = ban.BannedHostAddress, BannedHostNameMask = ban.BannedHostNameMask }); //Update the database ES.Save(); } reason = "Banned from this region."; return false; } if (ban.BannedHostIPMask == ACD.IPAddress) { //Ban the new user ES.AddBan(new EstateBan() { EstateID = ES.EstateID, BannedHostIPMask = ACD.IPAddress, BannedUserID = userID, BannedHostAddress = ACD.IPAddress, BannedHostNameMask = ACD.IPAddress }); ES.Save(); reason = "Banned from this region."; return false; } i++; } //Estate owners/managers/access list people/access groups tp freely as well if (ES.EstateOwner == userID || new List<UUID>(ES.EstateManagers).Contains(userID) || new List<UUID>(ES.EstateAccess).Contains(userID) || (Sp != null && new List<UUID>(ES.EstateGroups).Contains(Sp.ControllingClient.ActiveGroupId))) { reason = ""; return true; } if (ES.DenyAnonymous && ((account.UserFlags & (int)ProfileFlags.NoPaymentInfoOnFile) == (int)ProfileFlags.NoPaymentInfoOnFile)) { reason = "You may not enter this region."; return false; } if (ES.DenyIdentified && ((account.UserFlags & (int)ProfileFlags.PaymentInfoOnFile) == (int)ProfileFlags.PaymentInfoOnFile)) { reason = "You may not enter this region."; return false; } if (ES.DenyTransacted && ((account.UserFlags & (int)ProfileFlags.PaymentInfoInUse) == (int)ProfileFlags.PaymentInfoInUse)) { reason = "You may not enter this region."; return false; } long m_Day = 25 * 60 * 60; //Find out day length in seconds if (scene.RegionInfo.RegionSettings.MinimumAge != 0 && (account.Created - Util.UnixTimeSinceEpoch()) < (scene.RegionInfo.RegionSettings.MinimumAge * m_Day)) { reason = "You may not enter this region."; return false; } if (!ES.PublicAccess) { reason = "You may not enter this region."; return false; } IAgentConnector AgentConnector = DataManager.DataManager.RequestPlugin<IAgentConnector>(); IAgentInfo agentInfo = null; if (AgentConnector != null) { agentInfo = AgentConnector.GetAgent(userID); if (agentInfo == null) { AgentConnector.CreateNewAgent(userID); agentInfo = AgentConnector.GetAgent(userID); } } if (agentInfo != null && scene.RegionInfo.RegionSettings.Maturity > agentInfo.MaturityRating) { reason = "The region has too high of a maturity level. Blocking teleport."; return false; } if (agentInfo != null && ES.DenyMinors && (agentInfo.Flags & IAgentFlags.Minor) == IAgentFlags.Minor) { reason = "The region has too high of a maturity level. Blocking teleport."; return false; } ILandObject ILO = scene.LandChannel.GetLandObject(Position.X, Position.Y); if (ILO == null) // Can't teleport into a parcel that doesn't exist { reason = "Failed authentication."; return false; } //parcel permissions if (ILO.IsEitherBannedOrRestricted(userID)) { if (Sp == null) { reason = "Banned from this parcel."; return true; } if (!FindUnBannedParcel(Position, Sp, userID, out ILO, out newPosition, out reason)) { //We found a place for them, but we don't need to check any further return true; } } //Move them out of banned parcels ParcelFlags parcelflags = (ParcelFlags)ILO.LandData.Flags; if ((parcelflags & ParcelFlags.UseAccessGroup) == ParcelFlags.UseAccessGroup && (parcelflags & ParcelFlags.UseAccessList) == ParcelFlags.UseAccessList && (parcelflags & ParcelFlags.UsePassList) == ParcelFlags.UsePassList) { //One of these is in play then if ((parcelflags & ParcelFlags.UseAccessGroup) == ParcelFlags.UseAccessGroup) { if (Sp == null) { reason = "Banned from this parcel."; return true; } if (Sp.ControllingClient.ActiveGroupId != ILO.LandData.GroupID) { if (!FindUnBannedParcel(Position, Sp, userID, out ILO, out newPosition, out reason)) //We found a place for them, but we don't need to check any further return true; } } else if ((parcelflags & ParcelFlags.UseAccessList) == ParcelFlags.UseAccessList) { if (Sp == null) { reason = "Banned from this parcel."; return true; } //All but the people on the access list are banned if (!ILO.CreateAccessListArrayByFlag(AccessList.Access).Contains(Sp.UUID)) if (!FindUnBannedParcel(Position, Sp, userID, out ILO, out newPosition, out reason)) //We found a place for them, but we don't need to check any further return true; } else if ((parcelflags & ParcelFlags.UsePassList) == ParcelFlags.UsePassList) { if (Sp == null) { reason = "Banned from this parcel."; return true; } //All but the people on the pass/access list are banned if (!ILO.CreateAccessListArrayByFlag(AccessList.Access).Contains(Sp.UUID)) if (!FindUnBannedParcel(Position, Sp, userID, out ILO, out newPosition, out reason)) //We found a place for them, but we don't need to check any further return true; } } //Move them to the nearest landing point if (!ES.AllowDirectTeleport) { Telehub telehub = RegionConnector.FindTelehub(scene.RegionInfo.RegionID); if (telehub != null) { if (telehub.SpawnPos.Count == 0) { newPosition = new Vector3(telehub.TelehubLocX, telehub.TelehubLocY, telehub.TelehubLocZ); } else { int LastTelehubNum = 0; if (!LastTelehub.TryGetValue(scene.RegionInfo.RegionID, out LastTelehubNum)) LastTelehubNum = 0; newPosition = telehub.SpawnPos[LastTelehubNum] + new Vector3(telehub.TelehubLocX, telehub.TelehubLocY, telehub.TelehubLocZ); LastTelehubNum++; if (LastTelehubNum == telehub.SpawnPos.Count) LastTelehubNum = 0; LastTelehub[scene.RegionInfo.RegionID] = LastTelehubNum; } } else { reason = "Teleport has been blocked for this region."; return false; } } else { //If they are owner, they don't have to have permissions checked if (!m_scene.Permissions.GenericParcelPermission(userID, ILO, (ulong)GroupPowers.None)) { if (ILO.LandData.LandingType == 2) //Blocked, force this person off this land { //Find a new parcel for them List<ILandObject> Parcels = m_scene.LandChannel.ParcelsNearPoint(Position); if (Parcels.Count == 0) { ScenePresence SP; scene.TryGetScenePresence(userID, out SP); newPosition = m_scene.LandChannel.GetNearestRegionEdgePosition(SP); } else { bool found = false; //We need to check here as well for bans, can't toss someone into a parcel they are banned from foreach (ILandObject Parcel in Parcels) { if (!Parcel.IsBannedFromLand(userID)) { //Now we have to check their userloc if (ILO.LandData.LandingType == 2) continue; //Blocked, check next one else if (ILO.LandData.LandingType == 1) //Use their landing spot newPosition = Parcel.LandData.UserLocation; else //They allow for anywhere, so dump them in the center at the ground newPosition = m_scene.LandChannel.GetParcelCenterAtGround(Parcel); found = true; } } if (!found) //Dump them at the edge { if(Sp != null) newPosition = m_scene.LandChannel.GetNearestRegionEdgePosition(Sp); else { reason = "Banned from this parcel."; return true; } } } } else if (ILO.LandData.LandingType == 1) //Move to tp spot newPosition = ILO.LandData.UserLocation; } } //Can only enter prelude regions once! int flags = m_scene.GridService.GetRegionFlags(m_scene.RegionInfo.ScopeID, m_scene.RegionInfo.RegionID); //We assume that our own region isn't null.... if (((flags & (int)OpenSim.Data.RegionFlags.Prelude) == (int)OpenSim.Data.RegionFlags.Prelude) && agentInfo != null) { if (((agentInfo.Flags & IAgentFlags.PastPrelude) == IAgentFlags.PastPrelude)) { reason = "You may not enter this region as you have already been to a prelude region."; return false; } else { agentInfo.Flags |= IAgentFlags.PastPrelude; AgentConnector.UpdateAgent(agentInfo); //This only works for standalones... and thats ok } } if ((ILO.LandData.Flags & (int)ParcelFlags.DenyAnonymous) != 0) { if ((account.UserFlags & (int)ProfileFlags.NoPaymentInfoOnFile) == (int)ProfileFlags.NoPaymentInfoOnFile) { reason = "You may not enter this region."; return false; } } if ((ILO.LandData.Flags & (uint)ParcelFlags.DenyAgeUnverified) != 0 && agentInfo != null) { if ((agentInfo.Flags & IAgentFlags.Minor) == IAgentFlags.Minor) { reason = "You may not enter this region."; return false; } } reason = ""; return true; }
public bool Say(UUID agentID, Scene scene, string text) { lock (m_avatars) { if (m_avatars.ContainsKey(agentID)) { ScenePresence sp; scene.TryGetScenePresence(agentID, out sp); m_avatars[agentID].Say(text); return true; } } return false; }
public bool Stand(UUID agentID, Scene scene) { lock (m_avatars) { if (m_avatars.ContainsKey(agentID)) { ScenePresence sp; scene.TryGetScenePresence(agentID, out sp); sp.StandUp(); return true; } } return false; }
public bool MoveToTarget(UUID agentID, Scene scene, Vector3 pos, bool noFly, bool landAtTarget, bool running) { lock (m_avatars) { if (m_avatars.ContainsKey(agentID)) { ScenePresence sp; if (scene.TryGetScenePresence(agentID, out sp)) { if (sp.IsSatOnObject || sp.SitGround) return false; // m_log.DebugFormat( // "[NPC MODULE]: Moving {0} to {1} in {2}, noFly {3}, landAtTarget {4}", // sp.Name, pos, scene.RegionInfo.RegionName, // noFly, landAtTarget); sp.MoveToTarget(pos, noFly, landAtTarget); sp.SetAlwaysRun = running; return true; } } } return false; }
private bool OnAllowedIncomingTeleport(UUID userID, Scene scene, Vector3 Position, out Vector3 newPosition, out string reason) { newPosition = Position; UserAccount account = scene.UserAccountService.GetUserAccount(scene.RegionInfo.ScopeID, userID); ScenePresence Sp = scene.GetScenePresence(userID); if (account == null) { reason = "Failed authentication."; return false; //NO! } //Make sure that this user is inside the region as well if (Position.X < 0f || Position.Y < 0f || Position.X > scene.RegionInfo.RegionSizeX || Position.Y > scene.RegionInfo.RegionSizeY) { m_log.DebugFormat( "[EstateService]: AllowedIncomingTeleport was given an illegal position of {0} for avatar {1}, {2}. Clamping", Position, Name, userID); bool changedX = false; bool changedY = false; while (Position.X < 0) { Position.X += scene.RegionInfo.RegionSizeX; changedX = true; } while (Position.X > scene.RegionInfo.RegionSizeX) { Position.X -= scene.RegionInfo.RegionSizeX; changedX = true; } while (Position.Y < 0) { Position.Y += scene.RegionInfo.RegionSizeY; changedY = true; } while (Position.Y > scene.RegionInfo.RegionSizeY) { Position.Y -= scene.RegionInfo.RegionSizeY; changedY = true; } if (changedX) Position.X = scene.RegionInfo.RegionSizeX - Position.X; if(changedY) Position.Y = scene.RegionInfo.RegionSizeY - Position.Y; } //Check that we are not underground as well float posZLimit = (float)scene.RequestModuleInterface<ITerrainChannel>()[(int)Position.X, (int)Position.Y]; if (posZLimit >= (Position.Z) && !(Single.IsInfinity(posZLimit) || Single.IsNaN(posZLimit))) { Position.Z = posZLimit; } IAgentConnector AgentConnector = DataManager.DataManager.RequestPlugin<IAgentConnector>(); IAgentInfo agentInfo = null; if (AgentConnector != null) agentInfo = AgentConnector.GetAgent(userID); ILandObject ILO = null; IParcelManagementModule parcelManagement = scene.RequestModuleInterface<IParcelManagementModule>(); if (parcelManagement != null) ILO = parcelManagement.GetLandObject(Position.X, Position.Y); if (ILO == null) { //Can't find land, give them the first parcel in the region and find a good position for them ILO = parcelManagement.AllParcels()[0]; Position = parcelManagement.GetParcelCenterAtGround(ILO); } //parcel permissions if (ILO.IsBannedFromLand(userID)) //Note: restricted is dealt with in the next block { if (Sp == null) { reason = "Banned from this parcel."; return true; } if (!FindUnBannedParcel(Position, Sp, userID, out ILO, out newPosition, out reason)) { //We found a place for them, but we don't need to check any further return true; } } //Move them out of banned parcels ParcelFlags parcelflags = (ParcelFlags)ILO.LandData.Flags; if ((parcelflags & ParcelFlags.UseAccessGroup) == ParcelFlags.UseAccessGroup && (parcelflags & ParcelFlags.UseAccessList) == ParcelFlags.UseAccessList && (parcelflags & ParcelFlags.UsePassList) == ParcelFlags.UsePassList) { //One of these is in play then if ((parcelflags & ParcelFlags.UseAccessGroup) == ParcelFlags.UseAccessGroup) { if (Sp == null) { reason = "Banned from this parcel."; return true; } if (Sp.ControllingClient.ActiveGroupId != ILO.LandData.GroupID) { if (!FindUnBannedParcel(Position, Sp, userID, out ILO, out newPosition, out reason)) //We found a place for them, but we don't need to check any further return true; } } else if ((parcelflags & ParcelFlags.UseAccessList) == ParcelFlags.UseAccessList) { if (Sp == null) { reason = "Banned from this parcel."; return true; } //All but the people on the access list are banned if (ILO.IsRestrictedFromLand(userID)) if (!FindUnBannedParcel(Position, Sp, userID, out ILO, out newPosition, out reason)) //We found a place for them, but we don't need to check any further return true; } else if ((parcelflags & ParcelFlags.UsePassList) == ParcelFlags.UsePassList) { if (Sp == null) { reason = "Banned from this parcel."; return true; } //All but the people on the pass/access list are banned if (ILO.IsRestrictedFromLand(Sp.UUID)) if (!FindUnBannedParcel(Position, Sp, userID, out ILO, out newPosition, out reason)) //We found a place for them, but we don't need to check any further return true; } } EstateSettings ES = scene.RegionInfo.EstateSettings; //Move them to the nearest landing point if (!ES.AllowDirectTeleport) { Telehub telehub = RegionConnector.FindTelehub(scene.RegionInfo.RegionID); if (telehub != null) { if (telehub.SpawnPos.Count == 0) { newPosition = new Vector3(telehub.TelehubLocX, telehub.TelehubLocY, telehub.TelehubLocZ); } else { int LastTelehubNum = 0; if (!LastTelehub.TryGetValue(scene.RegionInfo.RegionID, out LastTelehubNum)) LastTelehubNum = 0; newPosition = telehub.SpawnPos[LastTelehubNum] + new Vector3(telehub.TelehubLocX, telehub.TelehubLocY, telehub.TelehubLocZ); LastTelehubNum++; if (LastTelehubNum == telehub.SpawnPos.Count) LastTelehubNum = 0; LastTelehub[scene.RegionInfo.RegionID] = LastTelehubNum; } } else { reason = "Teleport has been blocked for this region."; return false; } } else { //If they are owner, they don't have to have permissions checked if (!scene.Permissions.GenericParcelPermission(userID, ILO, (ulong)GroupPowers.None)) { if (ILO.LandData.LandingType == 2) //Blocked, force this person off this land { //Find a new parcel for them List<ILandObject> Parcels = parcelManagement.ParcelsNearPoint(Position); if (Parcels.Count == 0) { ScenePresence SP; scene.TryGetScenePresence(userID, out SP); newPosition = parcelManagement.GetNearestRegionEdgePosition(SP); } else { bool found = false; //We need to check here as well for bans, can't toss someone into a parcel they are banned from foreach (ILandObject Parcel in Parcels) { if (!Parcel.IsBannedFromLand(userID)) { //Now we have to check their userloc if (ILO.LandData.LandingType == 2) continue; //Blocked, check next one else if (ILO.LandData.LandingType == 1) //Use their landing spot newPosition = Parcel.LandData.UserLocation; else //They allow for anywhere, so dump them in the center at the ground newPosition = parcelManagement.GetParcelCenterAtGround(Parcel); found = true; } } if (!found) //Dump them at the edge { if (Sp != null) newPosition = parcelManagement.GetNearestRegionEdgePosition(Sp); else { reason = "Banned from this parcel."; return true; } } } } else if (ILO.LandData.LandingType == 1) //Move to tp spot if (ILO.LandData.UserLocation != Vector3.Zero) newPosition = ILO.LandData.UserLocation; else // Dump them at the nearest region corner since they havn't set a landing point newPosition = parcelManagement.GetNearestRegionEdgePosition(Sp); } } //Can only enter prelude regions once! int flags = scene.GridService.GetRegionFlags(scene.RegionInfo.ScopeID, scene.RegionInfo.RegionID); //We assume that our own region isn't null.... if (agentInfo != null) { if (((flags & (int)Aurora.Framework.RegionFlags.Prelude) == (int)Aurora.Framework.RegionFlags.Prelude) && agentInfo != null) { if (agentInfo.OtherAgentInformation.ContainsKey("Prelude" + scene.RegionInfo.RegionID)) { reason = "You may not enter this region as you have already been to this prelude region."; return false; } else { agentInfo.OtherAgentInformation.Add("Prelude" + scene.RegionInfo.RegionID, OSD.FromInteger((int)IAgentFlags.PastPrelude)); AgentConnector.UpdateAgent(agentInfo); //This only works for standalones... and thats ok } } } if ((ILO.LandData.Flags & (int)ParcelFlags.DenyAnonymous) != 0) { if ((account.UserFlags & (int)IUserProfileInfo.ProfileFlags.NoPaymentInfoOnFile) == (int)IUserProfileInfo.ProfileFlags.NoPaymentInfoOnFile) { reason = "You may not enter this region."; return false; } } if ((ILO.LandData.Flags & (uint)ParcelFlags.DenyAgeUnverified) != 0 && agentInfo != null) { if ((agentInfo.Flags & IAgentFlags.Minor) == IAgentFlags.Minor) { reason = "You may not enter this region."; return false; } } newPosition = Position; reason = ""; return true; }
public bool Sit(UUID agentID, UUID partID, Scene scene) { m_avatarsRwLock.AcquireReaderLock(-1); try { if (m_avatars.ContainsKey(agentID)) { ScenePresence sp; if (scene.TryGetScenePresence(agentID, out sp)) { sp.HandleAgentRequestSit(m_avatars[agentID], agentID, partID, Vector3.Zero); return true; } } } finally { m_avatarsRwLock.ReleaseReaderLock(); } return false; }
public bool Stand(UUID agentID, Scene scene) { m_avatarsRwLock.AcquireReaderLock(-1); try { if (m_avatars.ContainsKey(agentID)) { ScenePresence sp; if (scene.TryGetScenePresence(agentID, out sp)) { sp.StandUp(); return true; } } } finally { m_avatarsRwLock.ReleaseReaderLock(); } return false; }
public bool StopMoveToTarget(UUID agentID, Scene scene) { m_avatarsRwLock.AcquireReaderLock(-1); try { if (m_avatars.ContainsKey(agentID)) { ScenePresence sp; if (scene.TryGetScenePresence(agentID, out sp)) { sp.Velocity = Vector3.Zero; sp.ResetMoveToTarget(); return true; } } } finally { m_avatarsRwLock.ReleaseReaderLock(); } return false; }
public UUID CreateNPC(string firstname, string lastname, Vector3 position, UUID agentID, UUID owner, bool senseAsAgent, Scene scene, AvatarAppearance appearance) { NPCAvatar npcAvatar = null; try { if (agentID == UUID.Zero) npcAvatar = new NPCAvatar(firstname, lastname, position, owner, senseAsAgent, scene); else npcAvatar = new NPCAvatar(firstname, lastname, agentID, position, owner, senseAsAgent, scene); } catch (Exception e) { m_log.Info("[NPC MODULE]: exception creating NPC avatar: " + e.ToString()); return UUID.Zero; } npcAvatar.CircuitCode = (uint)Util.RandomClass.Next(0, int.MaxValue); m_log.DebugFormat( "[NPC MODULE]: Creating NPC {0} {1} {2}, owner={3}, senseAsAgent={4} at {5} in {6}", firstname, lastname, npcAvatar.AgentId, owner, senseAsAgent, position, scene.RegionInfo.RegionName); AgentCircuitData acd = new AgentCircuitData(); acd.AgentID = npcAvatar.AgentId; acd.firstname = firstname; acd.lastname = lastname; acd.ServiceURLs = new Dictionary<string, object>(); AvatarAppearance npcAppearance = new AvatarAppearance(appearance, true); acd.Appearance = npcAppearance; /* for (int i = 0; i < acd.Appearance.Texture.FaceTextures.Length; i++) { m_log.DebugFormat( "[NPC MODULE]: NPC avatar {0} has texture id {1} : {2}", acd.AgentID, i, acd.Appearance.Texture.FaceTextures[i]); } */ m_avatarsRwLock.AcquireWriterLock(-1); try { scene.AuthenticateHandler.AddNewCircuit(npcAvatar.CircuitCode, acd); scene.AddNewAgent(npcAvatar, PresenceType.Npc); ScenePresence sp; if (scene.TryGetScenePresence(npcAvatar.AgentId, out sp)) { /* m_log.DebugFormat( "[NPC MODULE]: Successfully retrieved scene presence for NPC {0} {1}", sp.Name, sp.UUID); */ sp.CompleteMovement(npcAvatar, false); m_avatars.Add(npcAvatar.AgentId, npcAvatar); m_log.DebugFormat("[NPC MODULE]: Created NPC {0} {1}", npcAvatar.AgentId, sp.Name); return npcAvatar.AgentId; } else { m_log.WarnFormat( "[NPC MODULE]: Could not find scene presence for NPC {0} {1}", sp.Name, sp.UUID); return UUID.Zero; } } finally { m_avatarsRwLock.ReleaseWriterLock(); } }
public UUID CreateNPC(string firstname, string lastname, Vector3 position, UUID agentID, UUID owner, string groupTitle, UUID groupID, bool senseAsAgent, Scene scene, AvatarAppearance appearance) { NPCAvatar npcAvatar = null; try { if (agentID == UUID.Zero) npcAvatar = new NPCAvatar(firstname, lastname, position, owner, senseAsAgent, scene); else npcAvatar = new NPCAvatar(firstname, lastname, agentID, position, owner, senseAsAgent, scene); } catch (Exception e) { m_log.Info("[NPC MODULE]: exception creating NPC avatar: " + e.ToString()); return UUID.Zero; } npcAvatar.CircuitCode = (uint)Util.RandomClass.Next(0, int.MaxValue); // m_log.DebugFormat( // "[NPC MODULE]: Creating NPC {0} {1} {2}, owner={3}, senseAsAgent={4} at {5} in {6}", // firstname, lastname, npcAvatar.AgentId, owner, senseAsAgent, position, scene.RegionInfo.RegionName); AgentCircuitData acd = new AgentCircuitData(); acd.AgentID = npcAvatar.AgentId; acd.firstname = firstname; acd.lastname = lastname; acd.ServiceURLs = new Dictionary<string, object>(); AvatarAppearance npcAppearance = new AvatarAppearance(appearance, true); acd.Appearance = npcAppearance; /* for (int i = 0; i < acd.Appearance.Texture.FaceTextures.Length; i++) { m_log.DebugFormat( "[NPC MODULE]: NPC avatar {0} has texture id {1} : {2}", acd.AgentID, i, acd.Appearance.Texture.FaceTextures[i]); } */ // ManualResetEvent ev = new ManualResetEvent(false); // Util.FireAndForget(delegate(object x) { lock (m_avatars) { scene.AuthenticateHandler.AddNewCircuit(npcAvatar.CircuitCode, acd); scene.AddNewAgent(npcAvatar, PresenceType.Npc); ScenePresence sp; if (scene.TryGetScenePresence(npcAvatar.AgentId, out sp)) { npcAvatar.ActiveGroupId = groupID; sp.CompleteMovement(npcAvatar, false); sp.Grouptitle = groupTitle; m_avatars.Add(npcAvatar.AgentId, npcAvatar); // m_log.DebugFormat("[NPC MODULE]: Created NPC {0} {1}", npcAvatar.AgentId, sp.Name); } } // ev.Set(); // }); // ev.WaitOne(); // m_log.DebugFormat("[NPC MODULE]: Created NPC with id {0}", npcAvatar.AgentId); return npcAvatar.AgentId; }
public bool MoveToTarget(UUID agentID, Scene scene, Vector3 pos, bool noFly, bool landAtTarget) { lock (m_avatars) { if (m_avatars.ContainsKey(agentID)) { ScenePresence sp; scene.TryGetScenePresence(agentID, out sp); m_log.DebugFormat( "[NPC MODULE]: Moving {0} to {1} in {2}, noFly {3}, landAtTarget {4}", sp.Name, pos, scene.RegionInfo.RegionName, noFly, landAtTarget); sp.MoveToTarget(pos, noFly, landAtTarget); return true; } } return false; }
public bool CanTeleport(UUID userID, Scene scene, Vector3 Position, OpenSim.Framework.AgentCircuitData ACD, out Vector3 newPosition, out string reason) { newPosition = Position; reason = ""; ScenePresence SP = null; if (scene.TryGetScenePresence(userID, out SP)) if (DisallowTeleportingForCombatants) if (SP.RequestModuleInterface<ICombatPresence>() != null) if (SP.RequestModuleInterface<ICombatPresence>().HasLeftCombat == false) if (!SP.Invulnerable) return false; return true; }
public bool StopMoveToTarget(UUID agentID, Scene scene) { lock (m_avatars) { if (m_avatars.ContainsKey(agentID)) { ScenePresence sp; scene.TryGetScenePresence(agentID, out sp); sp.Velocity = Vector3.Zero; sp.ResetMoveToTarget(); return true; } } return false; }
public void MoveToTarget(UUID agentID, Scene scene, Vector3 pos) { lock (m_avatars) { if (m_avatars.ContainsKey(agentID)) { ScenePresence sp; scene.TryGetScenePresence(agentID, out sp); m_log.DebugFormat( "[NPC MODULE]: Moving {0} to {1} in {2}", sp.Name, pos, scene.RegionInfo.RegionName); sp.MoveToTarget(pos); } } }
public bool Sit(UUID agentID, UUID partID, Scene scene) { lock (m_avatars) { if (m_avatars.ContainsKey(agentID)) { ScenePresence sp; scene.TryGetScenePresence(agentID, out sp); sp.HandleAgentRequestSit(m_avatars[agentID], agentID, partID, Vector3.Zero); // sp.HandleAgentSit(m_avatars[agentID], agentID); return true; } } return false; }
private bool AllowedTeleports(UUID userID, Scene scene, out string reason) { //Make sure that agents that are in combat cannot tp around. They CAN tp if they are out of combat however reason = ""; ScenePresence SP = null; if (scene.TryGetScenePresence(userID, out SP)) if (DisallowTeleportingForCombatants) if (SP.RequestModuleInterface<ICombatPresence>() != null) if (SP.RequestModuleInterface<ICombatPresence>().HasLeftCombat == false) if (!SP.Invulnerable) return false; return true; }
/// <summary> /// Gets the user's inventory URL from its serviceURLs, if the user is foreign, /// and sticks it in the cache /// </summary> /// <param name="userID"></param> private void CacheInventoryServiceURL(Scene scene, UUID userID) { if (scene.UserAccountService.GetUserAccount(scene.RegionInfo.ScopeID, userID) == null) { // The user does not have a local account; let's cache its service URL string inventoryURL = string.Empty; ScenePresence sp = null; scene.TryGetScenePresence(userID, out sp); if (sp != null) { AgentCircuitData aCircuit = scene.AuthenticateHandler.GetAgentCircuitData(sp.ControllingClient.CircuitCode); if (aCircuit.ServiceURLs.ContainsKey("InventoryServerURI")) { inventoryURL = aCircuit.ServiceURLs["InventoryServerURI"].ToString(); if (inventoryURL != null && inventoryURL != string.Empty) { inventoryURL = inventoryURL.Trim(new char[] { '/' }); m_InventoryURLs.Add(userID, inventoryURL); } } } } }
public UUID MoveInventory(Scene scene,UUID destID, string category, SceneObjectPart host, List<UUID> items) { InventoryFolderBase StoreFolder = new InventoryFolderBase(); List<InventoryFolderBase> m_invbase = new List<InventoryFolderBase> (); m_invbase = inventoryService.GetInventorySkeleton (destID); foreach (InventoryFolderBase current in m_invbase) { if (current.Name.ToString () == "Web Store Items") { StoreFolder = current; } } UUID newFolderID = UUID.Random(); InventoryFolderBase newFolder = new InventoryFolderBase(newFolderID, category, destID, -1, StoreFolder.ID, StoreFolder.Version); inventoryService.AddFolder(newFolder); foreach (UUID itemID in items) { InventoryItemBase agentItem = CreateAgentInventoryItemFromTask(scene,destID, host, itemID); if (agentItem != null) { agentItem.Folder = newFolderID; scene.AddInventoryItem(agentItem); } } ScenePresence avatar = null; if (scene.TryGetScenePresence(destID, out avatar)) { scene.SendInventoryUpdate(avatar.ControllingClient, StoreFolder, true, false); scene.SendInventoryUpdate(avatar.ControllingClient, newFolder, false, true); } return newFolderID; }