void CreateAgent(Coord coordinates, GameObject agent, float elevation) { var agentData = new AgentData() { coords = new int[] { coordinates.X, coordinates.Y }, prefId = _agentInfoIDs[agent.name] }; var go = Instantiate(agent, Grid.CoordToPosition(coordinates) + (1 + elevation) * Vector3.up, Quaternion.AngleAxis(45, Vector3.up)) as GameObject; go.active = false; foreach(var comp in go.GetComponents<Component>()) { if(!comp is Renderer) { if (comp is MonoBehaviour) { (comp as MonoBehaviour).enabled = false; } } } foreach(var comp in go.GetComponentsInChildren<Component>()) { if(!comp is Renderer) { if (comp is MonoBehaviour) { (comp as MonoBehaviour).enabled = false; } } } agentData.obj = go; _agentObjects.Add(go); _agents.Add(agentData); go.active = true; }
/// <summary> /// Deserialize the message /// </summary> /// <param name="map">An <see cref="OSDMap"/> containing the data</param> public void Deserialize(OSDMap map) { OSDArray agentDataArray = (OSDArray)map["AgentData"]; AgentDataBlock = new AgentData[agentDataArray.Count]; for (int i = 0; i < agentDataArray.Count; i++) { OSDMap agentMap = (OSDMap)agentDataArray[i]; AgentData agentData = new AgentData(); agentData.AgentID = agentMap["AgentID"].AsUUID(); agentData.GroupID = agentMap["GroupID"].AsUUID(); AgentDataBlock[i] = agentData; } }
public UnknownFightLogic(ushort triggerID, AgentData agentData) : base(triggerID, agentData) { Extension = "boss"; IconUrl = "https://wiki.guildwars2.com/images/d/d2/Guild_emblem_004.png"; }
public virtual bool CrossAgent(GridRegion crossingRegion, Vector3 pos, Vector3 velocity, AgentCircuitData circuit, AgentData cAgent, UUID AgentID, ulong requestingRegion, out string reason) { try { IClientCapsService clientCaps = m_registry.RequestModuleInterface<ICapsService>().GetClientCapsService(AgentID); IRegionClientCapsService requestingRegionCaps = clientCaps.GetCapsService(requestingRegion); ISimulationService SimulationService = m_registry.RequestModuleInterface<ISimulationService>(); if (SimulationService != null) { //Note: we have to pull the new grid region info as the one from the region cannot be trusted IGridService GridService = m_registry.RequestModuleInterface<IGridService>(); if (GridService != null) { //Set the user in transit so that we block duplicate tps and reset any cancelations if (!SetUserInTransit(AgentID)) { reason = "Already in a teleport"; return false; } bool result = false; //We need to get it from the grid service again so that we can get the simulation service urls correctly // as regions don't get that info crossingRegion = GridService.GetRegionByUUID(clientCaps.AccountInfo.AllScopeIDs, crossingRegion.RegionID); cAgent.IsCrossing = true; if (!SimulationService.UpdateAgent(crossingRegion, cAgent)) { MainConsole.Instance.Warn("[AgentProcessing]: Failed to cross agent " + AgentID + " because region did not accept it. Resetting."); reason = "Failed to update an agent"; } else { IEventQueueService EQService = m_registry.RequestModuleInterface<IEventQueueService>(); //Add this for the viewer, but not for the sim, seems to make the viewer happier int XOffset = crossingRegion.RegionLocX - requestingRegionCaps.RegionX; pos.X += XOffset; int YOffset = crossingRegion.RegionLocY - requestingRegionCaps.RegionY; pos.Y += YOffset; IRegionClientCapsService otherRegion = clientCaps.GetCapsService(crossingRegion.RegionHandle); //Tell the client about the transfer EQService.CrossRegion(crossingRegion.RegionHandle, pos, velocity, otherRegion.LoopbackRegionIP, otherRegion.CircuitData.RegionUDPPort, otherRegion.CapsUrl, AgentID, circuit.SessionID, crossingRegion.RegionSizeX, crossingRegion.RegionSizeY, requestingRegion); result = WaitForCallback(AgentID); if (!result) { MainConsole.Instance.Warn("[AgentProcessing]: Callback never came in crossing agent " + circuit.AgentID + ". Resetting."); reason = "Crossing timed out"; } else { // Next, let's close the child agent connections that are too far away. //Fix the root agent status otherRegion.RootAgent = true; requestingRegionCaps.RootAgent = false; CloseNeighborAgents(requestingRegionCaps.Region, crossingRegion, AgentID); reason = ""; } } //All done ResetFromTransit(AgentID); return result; } else reason = "Could not find the GridService"; } else reason = "Could not find the SimulationService"; } catch (Exception ex) { MainConsole.Instance.WarnFormat("[AgentProcessing]: Failed to cross an agent into a new region. {0}", ex); } ResetFromTransit(AgentID); reason = "Exception occured"; return false; }
/// <summary> /// This Closes child agents on neighboring regions /// Calls an asynchronous method to do so.. so it doesn't lag the sim. /// </summary> protected IScenePresence CrossAgentToNewRegionAsync(IScenePresence agent, Vector3 pos, GridRegion crossingRegion, bool isFlying, bool positionIsAlreadyFixed) { MainConsole.Instance.DebugFormat("[EntityTransferModule]: Crossing agent {0} to region {1}", agent.Name, crossingRegion.RegionName); IScene m_scene = agent.Scene; try { if (!positionIsAlreadyFixed) { int xOffset = crossingRegion.RegionLocX - m_scene.RegionInfo.RegionLocX; int yOffset = crossingRegion.RegionLocY - m_scene.RegionInfo.RegionLocY; if (xOffset < 0) pos.X += m_scene.RegionInfo.RegionSizeX; else if (xOffset > 0) pos.X -= m_scene.RegionInfo.RegionSizeX; if (yOffset < 0) pos.Y += m_scene.RegionInfo.RegionSizeY; else if (yOffset > 0) pos.Y -= m_scene.RegionInfo.RegionSizeY; //Make sure that they are within bounds (velocity can push it out of bounds) if (pos.X < 0) pos.X = 1; if (pos.Y < 0) pos.Y = 1; if (pos.X > crossingRegion.RegionSizeX) pos.X = crossingRegion.RegionSizeX - 1; if (pos.Y > crossingRegion.RegionSizeY) pos.Y = crossingRegion.RegionSizeY - 1; } AgentData cAgent = new AgentData(); agent.CopyTo(cAgent); cAgent.Position = pos; if (isFlying) cAgent.ControlFlags |= (uint) AgentManager.ControlFlags.AGENT_CONTROL_FLY; AgentCircuitData agentCircuit = BuildCircuitDataForPresence(agent, pos); agentCircuit.teleportFlags = (uint) TeleportFlags.ViaRegionID; agent.SetAgentLeaving(crossingRegion); IEventQueueService eq = agent.Scene.RequestModuleInterface<IEventQueueService>(); if (eq != null) { //This does UpdateAgent and closing of child agents // messages if they need to be called ISyncMessagePosterService syncPoster = agent.Scene.RequestModuleInterface<ISyncMessagePosterService>(); if (syncPoster != null) { OSDMap map = syncPoster.Get(SyncMessageHelper.CrossAgent(crossingRegion, pos, agent.Velocity, agentCircuit, cAgent, agent.Scene.RegionInfo.RegionHandle), agent.UUID, agent.Scene.RegionInfo.RegionHandle); bool result = false; if (map != null) result = map["Success"].AsBoolean(); if (!result) { //Tell modules that we have failed agent.AgentFailedToLeave(); if (map != null) { if (map.ContainsKey("Note") && !map["Note"].AsBoolean()) return agent; agent.ControllingClient.SendTeleportFailed(map["Reason"].AsString()); } else agent.ControllingClient.SendTeleportFailed("TP Failed"); if (agent.PhysicsActor != null) agent.PhysicsActor.IsPhysical = true; //Fix the setting that we set earlier // In any case agent.FailedCrossingTransit(crossingRegion); return agent; } } } //We're killing the animator and the physics actor, so we don't need to worry about agent.PhysicsActor.IsPhysical agent.MakeChildAgent(crossingRegion); //Revolution- We already were in this region... we don't need updates about the avatars we already know about, right? // OLD: now we have a child agent in this region. Request and send all interesting data about (root) agents in the sim //agent.SendOtherAgentsAvatarDataToMe(); //agent.SendOtherAgentsAppearanceToMe(); //Kill the groups here, otherwise they will become ghost attachments // and stay in the sim, they'll get readded below into the new sim KillAttachments(agent); } catch(Exception ex) { MainConsole.Instance.Warn("[EntityTransferModule]: Exception in crossing: " + ex); } // In any case agent.SuccessfulCrossingTransit(crossingRegion); return agent; }
public virtual void SpecialParse(FightData fightData, AgentData agentData, List <CombatItem> combatData) { }
public override bool InformClientOfNeighbor(UUID AgentID, ulong requestingRegion, AgentCircuitData circuitData, ref GridRegion neighbor, uint TeleportFlags, AgentData agentData, out string reason, out bool useCallbacks) { useCallbacks = true; if (neighbor == null) { reason = "Could not find neighbor to inform"; return false; } MainConsole.Instance.Info ("[AgentProcessing]: Starting to inform client about neighbor " + neighbor.RegionName); //Notes on this method // 1) the SimulationService.CreateAgent MUST have a fixed CapsUrl for the region, so we have to create (if needed) // a new Caps handler for it. // 2) Then we can call the methods (EnableSimulator and EstatablishAgentComm) to tell the client the new Urls // 3) This allows us to make the Caps on the grid server without telling any other regions about what the // Urls are. ISimulationService SimulationService = m_registry.RequestModuleInterface<ISimulationService> (); if (SimulationService != null) { ICapsService capsService = m_registry.RequestModuleInterface<ICapsService> (); IClientCapsService clientCaps = capsService.GetClientCapsService (AgentID); GridRegion originalDest = neighbor; if ((neighbor.Flags & (int)Aurora.Framework.RegionFlags.Hyperlink) == (int)Aurora.Framework.RegionFlags.Hyperlink) { neighbor = GetFinalDestination (neighbor); if (neighbor == null || neighbor.RegionHandle == 0) { reason = "Could not find neighbor to inform"; return false; } //Remove any offenders clientCaps.RemoveCAPS (originalDest.RegionHandle); clientCaps.RemoveCAPS (neighbor.RegionHandle); } IRegionClientCapsService oldRegionService = clientCaps.GetCapsService (neighbor.RegionHandle); //If its disabled, it should be removed, so kill it! if (oldRegionService != null && oldRegionService.Disabled) { clientCaps.RemoveCAPS (neighbor.RegionHandle); oldRegionService = null; } bool newAgent = oldRegionService == null; IRegionClientCapsService otherRegionService = clientCaps.GetOrCreateCapsService (neighbor.RegionHandle, CapsUtil.GetCapsSeedPath (CapsUtil.GetRandomCapsObjectPath ()), circuitData, 0); if (!newAgent) { //Note: if the agent is already there, send an agent update then bool result = true; if (agentData != null) { agentData.IsCrossing = false; result = SimulationService.UpdateAgent (neighbor, agentData); } if (result) oldRegionService.Disabled = false; reason = ""; return result; } ICommunicationService commsService = m_registry.RequestModuleInterface<ICommunicationService> (); if (commsService != null) commsService.GetUrlsForUser (neighbor, circuitData.AgentID);//Make sure that we make userURLs if we need to circuitData.CapsPath = CapsUtil.GetCapsPathFromCapsSeed (otherRegionService.CapsUrl); if (clientCaps.AccountInfo != null) { circuitData.firstname = clientCaps.AccountInfo.FirstName; circuitData.lastname = clientCaps.AccountInfo.LastName; } bool regionAccepted = false; int requestedUDPPort = 0; if ((originalDest.Flags & (int)Aurora.Framework.RegionFlags.Hyperlink) == (int)Aurora.Framework.RegionFlags.Hyperlink) { if (circuitData.ServiceURLs == null || circuitData.ServiceURLs.Count == 0) { if (clientCaps.AccountInfo != null) { circuitData.ServiceURLs = new Dictionary<string, object> (); circuitData.ServiceURLs[GetHandlers.Helpers_HomeURI] = GetHandlers.GATEKEEPER_URL; circuitData.ServiceURLs[GetHandlers.Helpers_GatekeeperURI] = GetHandlers.GATEKEEPER_URL; circuitData.ServiceURLs[GetHandlers.Helpers_InventoryServerURI] = GetHandlers.GATEKEEPER_URL; circuitData.ServiceURLs[GetHandlers.Helpers_AssetServerURI] = GetHandlers.GATEKEEPER_URL; circuitData.ServiceURLs[GetHandlers.Helpers_ProfileServerURI] = GetHandlers.GATEKEEPER_URL; circuitData.ServiceURLs[GetHandlers.Helpers_FriendsServerURI] = GetHandlers.GATEKEEPER_URL; circuitData.ServiceURLs[GetHandlers.Helpers_IMServerURI] = GetHandlers.IM_URL; clientCaps.AccountInfo.ServiceURLs = circuitData.ServiceURLs; //Store the new urls m_registry.RequestModuleInterface<IUserAccountService> ().StoreUserAccount (clientCaps.AccountInfo); } } string userAgentDriver = circuitData.ServiceURLs[GetHandlers.Helpers_HomeURI].ToString (); IUserAgentService connector = new UserAgentServiceConnector (userAgentDriver); regionAccepted = connector.LoginAgentToGrid (circuitData, originalDest, neighbor, out reason); } else { if(circuitData.child) circuitData.reallyischild = true; regionAccepted = SimulationService.CreateAgent (neighbor, ref circuitData, TeleportFlags, agentData, out requestedUDPPort, out reason); } if (regionAccepted) { IPAddress ipAddress = neighbor.ExternalEndPoint.Address; string otherRegionsCapsURL; //If the region accepted us, we should get a CAPS url back as the reason, if not, its not updated or not an Aurora region, so don't touch it. if (reason != "") { OSDMap responseMap = (OSDMap)OSDParser.DeserializeJson (reason); OSDMap SimSeedCaps = (OSDMap)responseMap["CapsUrls"]; if(responseMap.ContainsKey("OurIPForClient")) { string ip = responseMap["OurIPForClient"].AsString(); ipAddress = IPAddress.Parse(ip); } otherRegionService.AddCAPS (SimSeedCaps); otherRegionsCapsURL = otherRegionService.CapsUrl; } else { //We are assuming an OpenSim region now! #region OpenSim teleport compatibility! useCallbacks = false; otherRegionsCapsURL = neighbor.ServerURI + CapsUtil.GetCapsSeedPath (circuitData.CapsPath); otherRegionService.CapsUrl = otherRegionsCapsURL; #endregion } if (requestedUDPPort == 0) requestedUDPPort = neighbor.ExternalEndPoint.Port; if(ipAddress == null) ipAddress = neighbor.ExternalEndPoint.Address; circuitData.RegionUDPPort = requestedUDPPort; otherRegionService = clientCaps.GetCapsService(neighbor.RegionHandle); otherRegionService.LoopbackRegionIP = ipAddress; otherRegionService.CircuitData.RegionUDPPort = requestedUDPPort; IEventQueueService EQService = m_registry.RequestModuleInterface<IEventQueueService> (); EQService.EnableSimulator (neighbor.RegionHandle, ipAddress.GetAddressBytes(), requestedUDPPort, AgentID, neighbor.RegionSizeX, neighbor.RegionSizeY, requestingRegion); // EnableSimulator makes the client send a UseCircuitCode message to the destination, // which triggers a bunch of things there. // So let's wait Thread.Sleep (300); EQService.EstablishAgentCommunication (AgentID, neighbor.RegionHandle, ipAddress.GetAddressBytes(), requestedUDPPort, otherRegionsCapsURL, neighbor.RegionSizeX, neighbor.RegionSizeY, requestingRegion); if (!useCallbacks) Thread.Sleep (3000); //Give it a bit of time, only for OpenSim... MainConsole.Instance.Info ("[AgentProcessing]: Completed inform client about neighbor " + neighbor.RegionName); } else { clientCaps.RemoveCAPS (neighbor.RegionHandle); MainConsole.Instance.Error ("[AgentProcessing]: Failed to inform client about neighbor " + neighbor.RegionName + ", reason: " + reason); return false; } return true; } reason = "SimulationService does not exist"; MainConsole.Instance.Error ("[AgentProcessing]: Failed to inform client about neighbor " + neighbor.RegionName + ", reason: " + reason + "!"); return false; }
/// <summary> /// We've got an update about an agent that sees into this region, /// send it to ScenePresence for processing It's the full data. /// </summary> /// <param name="scene"></param> /// <param name="cAgentData">Agent that contains all of the relevant things about an agent. /// Appearance, animations, position, etc.</param> /// <returns>true if we handled it.</returns> public virtual bool IncomingChildAgentDataUpdate (IScene scene, AgentData cAgentData) { MainConsole.Instance.DebugFormat( "[SCENE]: Incoming child agent update for {0} in {1}", cAgentData.AgentID, scene.RegionInfo.RegionName); //No null updates! if (cAgentData == null) return false; // We have to wait until the viewer contacts this region after receiving EAC. // That calls AddNewClient, which finally creates the ScenePresence and then this gets set up // So if the client isn't here yet, save the update for them when they get into the region fully IScenePresence SP = scene.GetScenePresence (cAgentData.AgentID); if (SP != null) SP.ChildAgentDataUpdate (cAgentData); else lock (m_incomingChildAgentData) { if (!m_incomingChildAgentData.ContainsKey (scene)) m_incomingChildAgentData.Add (scene, new Dictionary<UUID, AgentData> ()); m_incomingChildAgentData[scene][cAgentData.AgentID] = cAgentData; return false;//The agent doesn't exist } return true; }
private void spawnAgent() { Vector3 spawnPos = GameObject.FindGameObjectWithTag("Spawn").transform.position; Quaternion rotate = GameObject.FindGameObjectWithTag("Spawn").transform.rotation; GameObject npc = Instantiate(SpawnList[0], spawnPos, rotate) as GameObject; AgentData tempData = new AgentData(); Debug.Log ("ID from npc : " + npc.GetInstanceID()); tempData.setID(npc.GetInstanceID()); Debug.Log ("ID from data : " + tempData.getID()); tempData.setOtherAgents(findOtherAgents()); Debug.Log ("OtherAgents : " + tempData.getOtherAgents()); Debug.Log ("Name from npc : " + npc.name); tempData.setInitial(npc.name); Debug.Log ("Name from data : " + tempData.getInitial()); npc.GetComponent<Sentry>().setAgentData(tempData); Debug.Log (npc.GetComponent<Sentry>().getAgentData().getInitial()); History.Add(tempData); //if (History[agentAttempts] == null) Debug.Log (agentAttempts + " was null"); //Debug.Log ("History ID : " + History[agentAttempts].getInitial()); //Debug.Log ("History: " + History.Count()); agentAttempts++; SpawnList.RemoveAt(0); Debug.Log ("After SpawnList Remove"); setWaypointsForNPCs(); }
public virtual bool CreateAgent(GridRegion destination, AgentCircuitData aCircuit, uint teleportFlags, AgentData data, out int requestedUDPPort, out string reason) { reason = String.Empty; // Try local first if (m_localBackend.CreateAgent(destination, aCircuit, teleportFlags, data, out requestedUDPPort, out reason)) return true; requestedUDPPort = destination.ExternalEndPoint.Port; //Just make sure.. reason = String.Empty; string uri = MakeUri(destination, true) + aCircuit.AgentID + "/"; try { OSDMap args = aCircuit.PackAgentCircuitData(); args["destination_x"] = OSD.FromString(destination.RegionLocX.ToString()); args["destination_y"] = OSD.FromString(destination.RegionLocY.ToString()); args["destination_name"] = OSD.FromString(destination.RegionName); args["destination_uuid"] = OSD.FromString(destination.RegionID.ToString()); args["teleport_flags"] = OSD.FromString(teleportFlags.ToString()); if (data != null) args["agent_data"] = data.Pack(); string resultStr = WebUtils.PostToService(uri, args); //Pull out the result and set it as the reason if (resultStr == "") return false; OSDMap result = OSDParser.DeserializeJson(resultStr) as OSDMap; reason = result["reason"] != null ? result["reason"].AsString() : ""; if (result["success"].AsBoolean()) { //Not right... don't return true except for opensim combatibility :/ if (reason == "" || reason == "authorized") return true; //We were able to contact the region try { //We send the CapsURLs through, so we need these OSDMap responseMap = (OSDMap) OSDParser.DeserializeJson(reason); if (responseMap.ContainsKey("Reason")) reason = responseMap["Reason"].AsString(); if (responseMap.ContainsKey("requestedUDPPort")) requestedUDPPort = responseMap["requestedUDPPort"]; return result["success"].AsBoolean(); } catch { //Something went wrong return false; } } reason = result.ContainsKey("Message") ? result["Message"].AsString() : "Could not contact the region"; return false; } catch (Exception e) { MainConsole.Instance.Warn("[REMOTE SIMULATION CONNECTOR]: CreateAgent failed with exception: " + e); reason = e.Message; } return false; }
public PlatformData GeneratePlatformData(AgentData agentData) { var platformData = new PlatformData(agentData); ComponentData[] pendingComponentData = QueryHistory.Select(qh => ComponentDataRetriever.GetData(qh.Value.ToArray())) .Where(c => c != null).ToArray(); pendingComponentData.ForEach(platformData.AddComponent); return platformData; }
public bool UpdateAgent(GridRegion destination, AgentData data) { return UpdateAgent(destination, (IAgentData) data); }
public bool RetrieveAgent(GridRegion destination, UUID id, bool agentIsLeaving, out AgentData agent, out AgentCircuitData circuitData) { agent = null; // Try local first if (m_localBackend.RetrieveAgent(destination, id, agentIsLeaving, out agent, out circuitData)) return true; // else do the remote thing if (!m_localBackend.IsLocalRegion(destination.RegionHandle)) { // Eventually, we want to use a caps url instead of the agentID string uri = MakeUri(destination, true) + id + "/" + destination.RegionID.ToString() + "/" + agentIsLeaving.ToString() + "/"; try { string resultStr = WebUtils.GetFromService(uri); if (resultStr != "") { OSDMap result = OSDParser.DeserializeJson(resultStr) as OSDMap; if (result["Result"] == "Not Found") return false; agent = new AgentData(); if (!result.ContainsKey("AgentData")) return false; //Disable old simulators agent.Unpack((OSDMap)result["AgentData"]); circuitData = new AgentCircuitData(); circuitData.UnpackAgentCircuitData((OSDMap)result["CircuitData"]); return true; } } catch (Exception e) { MainConsole.Instance.Warn("[REMOTE SIMULATION CONNECTOR]: UpdateAgent failed with exception: " + e); } return false; } return false; }
public PopulationData(ArrayList tested, ArrayList untested) { testedPools = new ArrayList(); untestedPools = new ArrayList(); foreach (ArrayList gen in tested) { ArrayList newGen = new ArrayList(); foreach(Agent agent in gen) { AgentData newAgent = new AgentData(agent); newGen.Add(newAgent); } testedPools.Add(newGen); } foreach (ArrayList gen in untested) { ArrayList newGen = new ArrayList(); foreach (Agent agent in gen) { AgentData newAgent = new AgentData(agent); newGen.Add(newAgent); } untestedPools.Add(newGen); } }
protected abstract void RestartStatsAndState(float percentage, AgentData data);
public void addToDeathList(AgentData data) { DeathList.Add (data); }
private static List <InstantCastEvent> ComputeInstantCastEvents(CombatData combatData, SkillData skillData, AgentData agentData, List <InstantCastFinder> instantCastFinders) { var res = new List <InstantCastEvent>(); ulong build = combatData.GetBuildEvent().Build; foreach (InstantCastFinder icf in instantCastFinders) { if (icf.Available(build)) { if (icf.NotAccurate) { skillData.NotAccurate.Add(icf.SkillID); } res.AddRange(icf.ComputeInstantCast(combatData, skillData, agentData)); } } return(res); }
protected override void RestartStatsAndState(float percentage, AgentData data) { var creepData = (CreepData)data; Stats.Clear(); CreateStat("Hp", creepData.MaxHp); var amountToSubtract = (1 - percentage) * creepData.MaxHp; AdjustStat(new StatAdjustment("Hp", "", -amountToSubtract)); CreateStat("Speed", creepData.Speed); CreateStat("Resistance", creepData.Resistance); CreateStat("Gold", creepData.GoldReward); State = new CreepState(); foreach (var modifier in creepData.TypeDamageModifier) State.SetVulnerabilityWithValue(modifier.Key, modifier.Value); }
public void CopyTo(AgentData cAgent) { cAgent.AgentID = UUID; cAgent.RegionID = Scene.RegionInfo.RegionID; cAgent.Position = AbsolutePosition + OffsetPosition; cAgent.Velocity = Velocity; cAgent.Center = m_CameraCenter; // Don't copy the size; it is inferred from appearance parameters //But it seems we should use it since it doesn't get set right on child tps sometimes cAgent.Size = new Vector3(0, 0, m_avHeight); cAgent.AtAxis = m_CameraAtAxis; cAgent.LeftAxis = m_CameraLeftAxis; cAgent.UpAxis = m_CameraUpAxis; cAgent.Far = DrawDistance; // Throttles float multiplier = 1; int innacurateNeighbors = m_scene.RequestModuleInterface<IGridRegisterModule>().GetNeighbors(m_scene).Count; if (innacurateNeighbors != 0) { multiplier = 1f / innacurateNeighbors; } if (multiplier <= 0.25f) { multiplier = 0.25f; } //MainConsole.Instance.Info("[NeighborThrottle]: " + m_scene.GetInaccurateNeighborCount().ToString() + " - m: " + multiplier.ToString()); cAgent.Throttles = ControllingClient.GetThrottlesPacked(multiplier); cAgent.HeadRotation = m_headrotation; cAgent.BodyRotation = m_bodyRot; cAgent.ControlFlags = (uint)m_AgentControlFlags; //This is checked by the other sim, so we don't have to validate it at all //if (m_scene.Permissions.IsGod(new UUID(cAgent.AgentID))) cAgent.GodLevel = (byte)m_godLevel; //else // cAgent.GodLevel = (byte) 0; cAgent.Speed = SpeedModifier; cAgent.DrawDistance = DrawDistance; cAgent.AlwaysRun = m_setAlwaysRun; IAvatarAppearanceModule appearance = RequestModuleInterface<IAvatarAppearanceModule>(); if (appearance != null) { cAgent.SentInitialWearables = appearance.InitialHasWearablesBeenSent; cAgent.Appearance = new AvatarAppearance(appearance.Appearance); } IScriptControllerModule m = RequestModuleInterface<IScriptControllerModule>(); if (m != null) cAgent.Controllers = m.Serialize(); cAgent.SittingObjects = new SittingObjectData(); if (Sitting) { ISceneChildEntity child = Scene.GetSceneObjectPart(SittingOnUUID); if (child != null && child.ParentEntity != null) { cAgent.SittingObjects.m_sittingObjectXML = ((ISceneObject)child.ParentEntity).ToXml2(); cAgent.SittingObjects.m_sitTargetPos = OffsetPosition;//Get the difference cAgent.SittingObjects.m_sitTargetRot = m_bodyRot; cAgent.SittingObjects.m_animation = m_nextSitAnimation; } } // Animations if (Animator != null) cAgent.Anims = Animator.Animations.ToArray(); }
internal override void CheckSuccess(CombatData combatData, AgentData agentData, FightData fightData, HashSet <AgentItem> playerAgents) { fightData.SetSuccess(true, fightData.FightEnd); }
public virtual void DoTeleport(IScenePresence sp, GridRegion finalDestination, Vector3 position, Vector3 lookAt, uint teleportFlags) { sp.ControllingClient.SendTeleportProgress(teleportFlags, "sending_dest"); if (finalDestination == null) { sp.ControllingClient.SendTeleportFailed("Unable to locate destination"); return; } MainConsole.Instance.DebugFormat( "[ENTITY TRANSFER MODULE]: Request Teleport to {0}:{1}/{2}", finalDestination.ServerURI, finalDestination.RegionName, position); sp.ControllingClient.SendTeleportProgress(teleportFlags, "arriving"); sp.SetAgentLeaving(finalDestination); // Fixing a bug where teleporting while sitting results in the avatar ending up removed from // both regions if (sp.ParentID != UUID.Zero) sp.StandUp(); AgentCircuitData agentCircuit = BuildCircuitDataForPresence(sp, position); AgentData agent = new AgentData(); sp.CopyTo(agent); //Fix the position agent.Position = position; IEventQueueService eq = sp.Scene.RequestModuleInterface<IEventQueueService>(); if (eq != null) { ISyncMessagePosterService syncPoster = sp.Scene.RequestModuleInterface<ISyncMessagePosterService>(); if (syncPoster != null) { //This does CreateAgent and sends the EnableSimulator/EstablishAgentCommunication/TeleportFinish // messages if they need to be called and deals with the callback syncPoster.Get(SyncMessageHelper.TeleportAgent((int)sp.DrawDistance, agentCircuit, agent, teleportFlags, finalDestination, sp.Scene.RegionInfo.RegionHandle), sp.UUID, sp.Scene.RegionInfo.RegionHandle, (map) => { if (map == null || !map["success"].AsBoolean()) { // Fix the agent status sp.IsChildAgent = false; //Tell modules about it sp.AgentFailedToLeave(); sp.ControllingClient.SendTeleportFailed(map != null ? map["Reason"].AsString() : "Teleport Failed"); return; } //Get the new destintation, it may have changed if (map.ContainsKey("Destination")) { finalDestination = new GridRegion(); finalDestination.FromOSD((OSDMap)map["Destination"]); } MakeChildAgent(sp, finalDestination, false); }); } } }
internal override long GetFightOffset(FightData fightData, AgentData agentData, List <CombatItem> combatData) { return(GetFightOffsetByFirstInvulFilter(fightData, agentData, combatData, (int)ArcDPSEnums.TargetID.Ensolyss, 762, 1500)); }
public abstract List <InstantCastEvent> ComputeInstantCast(CombatData combatData, SkillData skillData, AgentData agentData);
internal override FightData.CMStatus IsCM(CombatData combatData, AgentData agentData, FightData fightData) { return(FightData.CMStatus.CMnoName); }
internal override string GetLogicName(CombatData combatData, AgentData agentData) { return("Statue of Ice"); }
internal override FightData.EncounterMode GetEncounterMode(CombatData combatData, AgentData agentData, FightData fightData) { return(FightData.EncounterMode.CMNoName); }
internal override void EIEvtcParse(FightData fightData, AgentData agentData, List <CombatItem> combatData, List <Player> playerList) { // has breakbar state into if (combatData.Any(x => x.IsStateChange == ArcDPSEnums.StateChange.BreakbarState)) { long sacrificeID = 34442; var sacrificeList = combatData.Where(x => x.SkillID == sacrificeID && ((x.IsBuffRemove == ArcDPSEnums.BuffRemove.All && x.IsBuff != 0) || (x.IsBuff != 0 && x.BuffDmg == 0 && x.Value > 0 && x.IsStateChange == ArcDPSEnums.StateChange.None && x.IsActivation == ArcDPSEnums.Activation.None && x.IsBuffRemove == ArcDPSEnums.BuffRemove.None))).ToList(); var sacrificeStartList = sacrificeList.Where(x => x.IsBuffRemove == ArcDPSEnums.BuffRemove.None).ToList(); var sacrificeEndList = sacrificeList.Where(x => x.IsBuffRemove == ArcDPSEnums.BuffRemove.All).ToList(); var copies = new List <CombatItem>(); for (int i = 0; i < sacrificeStartList.Count; i++) { // long sacrificeStartTime = sacrificeStartList[i].Time; long sacrificeEndTime = i < sacrificeEndList.Count ? sacrificeEndList[i].Time : fightData.FightEnd; // Player sacrifice = playerList.FirstOrDefault(x => x.AgentItem == agentData.GetAgent(sacrificeStartList[i].DstAgent)); if (sacrifice == null) { continue; } AgentItem sacrificeCrystal = agentData.AddCustomAgent(sacrificeStartTime, sacrificeEndTime + 100, AgentItem.AgentType.NPC, "Sacrificed " + (i + 1) + " " + sacrifice.Character, sacrifice.Prof, (int)ArcDPSEnums.TrashID.MatthiasSacrificeCrystal, false); foreach (CombatItem cbt in combatData) { if (!sacrificeCrystal.InAwareTimes(cbt.Time)) { continue; } bool skip = !((cbt.IsStateChange.DstIsAgent() && cbt.DstAgent == sacrifice.Agent) || (cbt.IsStateChange.SrcIsAgent() && cbt.SrcAgent == sacrifice.Agent)); if (skip) { continue; } bool isDamageEvent = cbt.IsStateChange == ArcDPSEnums.StateChange.None && cbt.IsActivation == ArcDPSEnums.Activation.None && cbt.IsBuffRemove == ArcDPSEnums.BuffRemove.None && ((cbt.IsBuff != 0 && cbt.Value == 0) || (cbt.IsBuff == 0)); // redirect damage events if (isDamageEvent) { // only redirect incoming damage if (cbt.DstAgent == sacrifice.Agent) { cbt.OverrideDstAgent(sacrificeCrystal.Agent); } } // copy the rest else { var copy = new CombatItem(cbt); if (cbt.IsStateChange.DstIsAgent() && cbt.DstAgent == sacrifice.Agent) { cbt.OverrideDstAgent(sacrificeCrystal.Agent); } if (cbt.IsStateChange.SrcIsAgent() && cbt.SrcAgent == sacrifice.Agent) { cbt.OverrideSrcAgent(sacrificeCrystal.Agent); } copies.Add(copy); } } } if (copies.Any()) { combatData.AddRange(copies); combatData.Sort((x, y) => x.Time.CompareTo(y.Time)); } } ComputeFightTargets(agentData, combatData); foreach (NPC target in Targets) { if (target.ID == (int)ArcDPSEnums.TrashID.MatthiasSacrificeCrystal) { target.SetManualHealth(100000); } } }
/** * Agent-related communications */ public bool CreateAgent(GridRegion destination, AgentCircuitData aCircuit, uint teleportFlags, AgentData data, out int requestedUDPPort, out string reason) { requestedUDPPort = 0; if (destination == null) { reason = "Given destination was null"; MainConsole.Instance.DebugFormat("[LOCAL SIMULATION CONNECTOR]: CreateAgent was given a null destination"); return false; } if (destination.ExternalEndPoint != null) requestedUDPPort = destination.ExternalEndPoint.Port; #if (!ISWIN) foreach (IScene s in m_sceneList) { if (s.RegionInfo.RegionID == destination.RegionID) { //MainConsole.Instance.DebugFormat("[LOCAL SIMULATION CONNECTOR]: Found region {0} to send SendCreateChildAgent", destination.RegionName); if (data != null) UpdateAgent(destination, data); IEntityTransferModule transferModule = s.RequestModuleInterface<IEntityTransferModule>(); if (transferModule != null) return transferModule.NewUserConnection(s, aCircuit, teleportFlags, out requestedUDPPort, out reason); } } #else foreach (IScene s in m_sceneList.Where(s => s.RegionInfo.RegionID == destination.RegionID)) { //MainConsole.Instance.DebugFormat("[LOCAL SIMULATION CONNECTOR]: Found region {0} to send SendCreateChildAgent", destination.RegionName); if (data != null) UpdateAgent(destination, data); IEntityTransferModule transferModule = s.RequestModuleInterface<IEntityTransferModule>(); if (transferModule != null) return transferModule.NewUserConnection(s, aCircuit, teleportFlags, out requestedUDPPort, out reason); } #endif MainConsole.Instance.DebugFormat("[LOCAL SIMULATION CONNECTOR]: Did not find region {0} for CreateAgent", destination.RegionName); OSDMap map = new OSDMap(); map["Reason"] = "Did not find region " + destination.RegionName; map["Success"] = false; reason = OSDParser.SerializeJsonString(map); return false; }
/// <summary> /// Async component for informing client of which neighbors exist /// </summary> /// <remarks> /// This needs to run asynchronously, as a network timeout may block the thread for a long while /// </remarks> /// <param name = "remoteClient"></param> /// <param name = "a"></param> /// <param name = "regionHandle"></param> /// <param name = "endPoint"></param> public virtual bool InformClientOfNeighbor(UUID AgentID, ulong requestingRegion, AgentCircuitData circuitData, ref GridRegion neighbor, uint TeleportFlags, AgentData agentData, out string reason, out bool useCallbacks) { useCallbacks = true; if (neighbor == null || neighbor.RegionHandle == 0) { reason = "Could not find neighbor to inform"; return false; } /*if ((neighbor.Flags & (int)Aurora.Framework.RegionFlags.RegionOnline) == 0 && (neighbor.Flags & (int)(Aurora.Framework.RegionFlags.Foreign | Aurora.Framework.RegionFlags.Hyperlink)) == 0) { reason = "The region you are attempting to teleport to is offline"; return false; }*/ MainConsole.Instance.Info("[AgentProcessing]: Starting to inform client about neighbor " + neighbor.RegionName); //Notes on this method // 1) the SimulationService.CreateAgent MUST have a fixed CapsUrl for the region, so we have to create (if needed) // a new Caps handler for it. // 2) Then we can call the methods (EnableSimulator and EstatablishAgentComm) to tell the client the new Urls // 3) This allows us to make the Caps on the grid server without telling any other regions about what the // Urls are. ISimulationService SimulationService = m_registry.RequestModuleInterface<ISimulationService>(); if (SimulationService != null) { ICapsService capsService = m_registry.RequestModuleInterface<ICapsService>(); IClientCapsService clientCaps = capsService.GetClientCapsService(AgentID); IRegionClientCapsService oldRegionService = clientCaps.GetCapsService(neighbor.RegionHandle); //If its disabled, it should be removed, so kill it! if (oldRegionService != null && oldRegionService.Disabled) { clientCaps.RemoveCAPS(neighbor.RegionHandle); oldRegionService = null; } bool newAgent = oldRegionService == null; IRegionClientCapsService otherRegionService = clientCaps.GetOrCreateCapsService(neighbor.RegionHandle, CapsUtil.GetCapsSeedPath (CapsUtil. GetRandomCapsObjectPath ()), circuitData, 0); if (!newAgent) { //Note: if the agent is already there, send an agent update then bool result = true; if (agentData != null) { agentData.IsCrossing = false; result = SimulationService.UpdateAgent(neighbor, agentData); } if (result) oldRegionService.Disabled = false; reason = ""; return result; } ICommunicationService commsService = m_registry.RequestModuleInterface<ICommunicationService>(); if (commsService != null) commsService.GetUrlsForUser(neighbor, circuitData.AgentID); //Make sure that we make userURLs if we need to circuitData.CapsPath = CapsUtil.GetCapsPathFromCapsSeed(otherRegionService.CapsUrl); //For OpenSim circuitData.firstname = clientCaps.AccountInfo.FirstName; circuitData.lastname = clientCaps.AccountInfo.LastName; int requestedPort = 0; if (circuitData.child) circuitData.reallyischild = true; bool regionAccepted = CreateAgent(neighbor, otherRegionService, ref circuitData, SimulationService, ref requestedPort, out reason); if (regionAccepted) { IPAddress ipAddress = neighbor.ExternalEndPoint.Address; string otherRegionsCapsURL; //If the region accepted us, we should get a CAPS url back as the reason, if not, its not updated or not an Aurora region, so don't touch it. if (reason != "" && reason != "authorized") { OSDMap responseMap = (OSDMap) OSDParser.DeserializeJson(reason); OSDMap SimSeedCaps = (OSDMap) responseMap["CapsUrls"]; if (responseMap.ContainsKey("OurIPForClient")) { string ip = responseMap["OurIPForClient"].AsString(); if (!IPAddress.TryParse(ip, out ipAddress)) #pragma warning disable 618 ipAddress = Dns.GetHostByName(ip).AddressList[0]; #pragma warning restore 618 } otherRegionService.AddCAPS(SimSeedCaps); otherRegionsCapsURL = otherRegionService.CapsUrl; } else { //We are assuming an OpenSim region now! #region OpenSim teleport compatibility! useCallbacks = false; //OpenSim can't send us back a message, don't try it! otherRegionsCapsURL = otherRegionService.Region.ServerURI + CapsUtil.GetCapsSeedPath(circuitData.CapsPath); otherRegionService.CapsUrl = otherRegionsCapsURL; #endregion } if (ipAddress == null) ipAddress = neighbor.ExternalEndPoint.Address; if (requestedPort == 0) requestedPort = neighbor.ExternalEndPoint.Port; otherRegionService = clientCaps.GetCapsService(neighbor.RegionHandle); otherRegionService.LoopbackRegionIP = ipAddress; otherRegionService.CircuitData.RegionUDPPort = requestedPort; circuitData.RegionUDPPort = requestedPort; //Fix the port IEventQueueService EQService = m_registry.RequestModuleInterface<IEventQueueService>(); EQService.EnableSimulator(neighbor.RegionHandle, ipAddress.GetAddressBytes(), requestedPort, AgentID, neighbor.RegionSizeX, neighbor.RegionSizeY, requestingRegion); // EnableSimulator makes the client send a UseCircuitCode message to the destination, // which triggers a bunch of things there. // So let's wait Thread.Sleep(300); EQService.EstablishAgentCommunication(AgentID, neighbor.RegionHandle, ipAddress.GetAddressBytes(), requestedPort, otherRegionsCapsURL, neighbor.RegionSizeX, neighbor.RegionSizeY, requestingRegion); if (!useCallbacks) Thread.Sleep(3000); //Give it a bit of time, only for OpenSim... MainConsole.Instance.Info("[AgentProcessing]: Completed inform client about neighbor " + neighbor.RegionName); } else { clientCaps.RemoveCAPS(neighbor.RegionHandle); MainConsole.Instance.Error("[AgentProcessing]: Failed to inform client about neighbor " + neighbor.RegionName + ", reason: " + reason); return false; } return true; } reason = "SimulationService does not exist"; MainConsole.Instance.Error("[AgentProcessing]: Failed to inform client about neighbor " + neighbor.RegionName + ", reason: " + reason + "!"); return false; }
public bool UpdateAgent(GridRegion destination, AgentData cAgentData) { if (destination == null || m_sceneList.Count == 0 || cAgentData == null) return false; bool retVal = false; IEntityTransferModule transferModule = m_sceneList[0].RequestModuleInterface<IEntityTransferModule>(); if (transferModule != null) { #if (!ISWIN) foreach (IScene s in m_sceneList) { if (destination.RegionID == s.RegionInfo.RegionID) { retVal = transferModule.IncomingChildAgentDataUpdate(s, cAgentData); } } #else foreach (IScene s in m_sceneList.Where(s => destination.RegionID == s.RegionInfo.RegionID)) { retVal = transferModule.IncomingChildAgentDataUpdate(s, cAgentData); } #endif } // MainConsole.Instance.DebugFormat("[LOCAL COMMS]: Did not find region {0} for ChildAgentUpdate", regionHandle); return retVal; }
internal DirectBreakbarDamageEvent(CombatItem evtcItem, AgentData agentData, SkillData skillData) : base(evtcItem, agentData, skillData) { BreakbarDamage = evtcItem.Value / 10.0; }
public bool RetrieveAgent(GridRegion destination, UUID id, bool agentIsLeaving, out AgentData agent, out AgentCircuitData circuitData) { agent = null; circuitData = null; if (destination == null) return false; foreach (IScene s in m_sceneList) { if (s.RegionInfo.RegionID == destination.RegionID) { //MainConsole.Instance.Debug("[LOCAL COMMS]: Found region to send ChildAgentUpdate"); IEntityTransferModule transferModule = s.RequestModuleInterface<IEntityTransferModule>(); if (transferModule != null) return transferModule.IncomingRetrieveRootAgent(s, id, agentIsLeaving, out agent, out circuitData); } } return false; //MainConsole.Instance.Debug("[LOCAL COMMS]: region not found for ChildAgentUpdate"); }
// public static List <InstantCastEvent> ComputeInstantCastEvents(List <Player> players, CombatData combatData, SkillData skillData, AgentData agentData) { var instantCastFinders = new HashSet <InstantCastFinder>(_genericInstantCastFinders); var res = new List <InstantCastEvent>(); foreach (Player p in players) { switch (p.Prof) { // case "Elementalist": ElementalistHelper.InstantCastFinder.ForEach(x => instantCastFinders.Add(x)); break; case "Tempest": ElementalistHelper.InstantCastFinder.ForEach(x => instantCastFinders.Add(x)); TempestHelper.InstantCastFinder.ForEach(x => instantCastFinders.Add(x)); break; case "Weaver": ElementalistHelper.InstantCastFinder.ForEach(x => instantCastFinders.Add(x)); WeaverHelper.InstantCastFinder.ForEach(x => instantCastFinders.Add(x)); break; // case "Necromancer": NecromancerHelper.InstantCastFinder.ForEach(x => instantCastFinders.Add(x)); break; case "Reaper": NecromancerHelper.InstantCastFinder.ForEach(x => instantCastFinders.Add(x)); ReaperHelper.InstantCastFinder.ForEach(x => instantCastFinders.Add(x)); break; case "Scourge": NecromancerHelper.InstantCastFinder.ForEach(x => instantCastFinders.Add(x)); ScourgeHelper.InstantCastFinder.ForEach(x => instantCastFinders.Add(x)); break; // case "Mesmer": MesmerHelper.InstantCastFinder.ForEach(x => instantCastFinders.Add(x)); break; case "Chronomancer": MesmerHelper.InstantCastFinder.ForEach(x => instantCastFinders.Add(x)); ChronomancerHelper.InstantCastFinder.ForEach(x => instantCastFinders.Add(x)); break; case "Mirage": MesmerHelper.InstantCastFinder.ForEach(x => instantCastFinders.Add(x)); MirageHelper.InstantCastFinder.ForEach(x => instantCastFinders.Add(x)); res.AddRange(MirageHelper.TranslateMirageCloak(combatData.GetBuffData(40408), skillData)); break; // case "Thief": ThiefHelper.InstantCastFinder.ForEach(x => instantCastFinders.Add(x)); break; case "Daredevil": ThiefHelper.InstantCastFinder.ForEach(x => instantCastFinders.Add(x)); DaredevilHelper.InstantCastFinder.ForEach(x => instantCastFinders.Add(x)); break; case "Deadeye": ThiefHelper.InstantCastFinder.ForEach(x => instantCastFinders.Add(x)); DeadeyeHelper.InstantCastFinder.ForEach(x => instantCastFinders.Add(x)); break; // case "Engineer": EngineerHelper.InstantCastFinder.ForEach(x => instantCastFinders.Add(x)); break; case "Scrapper": EngineerHelper.InstantCastFinder.ForEach(x => instantCastFinders.Add(x)); ScrapperHelper.InstantCastFinder.ForEach(x => instantCastFinders.Add(x)); break; case "Holosmith": EngineerHelper.InstantCastFinder.ForEach(x => instantCastFinders.Add(x)); HolosmithHelper.InstantCastFinder.ForEach(x => instantCastFinders.Add(x)); break; // case "Ranger": RangerHelper.InstantCastFinder.ForEach(x => instantCastFinders.Add(x)); break; case "Druid": RangerHelper.InstantCastFinder.ForEach(x => instantCastFinders.Add(x)); DruidHelper.InstantCastFinder.ForEach(x => instantCastFinders.Add(x)); break; case "Soulbeast": RangerHelper.InstantCastFinder.ForEach(x => instantCastFinders.Add(x)); SoulbeastHelper.InstantCastFinder.ForEach(x => instantCastFinders.Add(x)); break; // case "Revenant": RevenantHelper.InstantCastFinder.ForEach(x => instantCastFinders.Add(x)); break; case "Herald": RevenantHelper.InstantCastFinder.ForEach(x => instantCastFinders.Add(x)); HeraldHelper.InstantCastFinder.ForEach(x => instantCastFinders.Add(x)); break; case "Renegade": RevenantHelper.InstantCastFinder.ForEach(x => instantCastFinders.Add(x)); RenegadeHelper.InstantCastFinder.ForEach(x => instantCastFinders.Add(x)); break; // case "Guardian": GuardianHelper.InstantCastFinder.ForEach(x => instantCastFinders.Add(x)); break; case "Dragonhunter": GuardianHelper.InstantCastFinder.ForEach(x => instantCastFinders.Add(x)); DragonhunterHelper.InstantCastFinder.ForEach(x => instantCastFinders.Add(x)); break; case "Firebrand": GuardianHelper.InstantCastFinder.ForEach(x => instantCastFinders.Add(x)); FirebrandHelper.InstantCastFinder.ForEach(x => instantCastFinders.Add(x)); break; // case "Warrior": WarriorHelper.InstantCastFinder.ForEach(x => instantCastFinders.Add(x)); break; case "Berserker": WarriorHelper.InstantCastFinder.ForEach(x => instantCastFinders.Add(x)); BerserkerHelper.InstantCastFinder.ForEach(x => instantCastFinders.Add(x)); break; case "Spellbreaker": WarriorHelper.InstantCastFinder.ForEach(x => instantCastFinders.Add(x)); SpellbreakerHelper.InstantCastFinder.ForEach(x => instantCastFinders.Add(x)); break; } } res.AddRange(ComputeInstantCastEvents(combatData, skillData, agentData, instantCastFinders.ToList())); return(res); }
protected void DoAgentPut(Hashtable request, Hashtable responsedata) { OSDMap args = Utils.GetOSDMap((string)request["body"]); if (args == null) { responsedata["int_response_code"] = HttpStatusCode.BadRequest; responsedata["str_response_string"] = "Bad request"; return; } // retrieve the input arguments int x = 0, y = 0; UUID uuid = UUID.Zero; string regionname = string.Empty; if (args.ContainsKey("destination_x") && args["destination_x"] != null) { Int32.TryParse(args["destination_x"].AsString(), out x); } if (args.ContainsKey("destination_y") && args["destination_y"] != null) { Int32.TryParse(args["destination_y"].AsString(), out y); } if (args.ContainsKey("destination_uuid") && args["destination_uuid"] != null) { UUID.TryParse(args["destination_uuid"].AsString(), out uuid); } if (args.ContainsKey("destination_name") && args["destination_name"] != null) { regionname = args["destination_name"].ToString(); } GridRegion destination = new GridRegion(); destination.RegionID = uuid; destination.RegionLocX = x; destination.RegionLocY = y; destination.RegionName = regionname; string messageType; if (args["message_type"] != null) { messageType = args["message_type"].AsString(); } else { m_log.Warn("[AGENT HANDLER]: Agent Put Message Type not found. "); messageType = "AgentData"; } bool result = true; if ("AgentData".Equals(messageType)) { AgentData agent = new AgentData(); try { agent.Unpack(args, m_SimulationService.GetScene(destination.RegionID)); } catch (Exception ex) { m_log.InfoFormat("[AGENT HANDLER]: exception on unpacking ChildAgentUpdate message {0}", ex.Message); responsedata["int_response_code"] = HttpStatusCode.BadRequest; responsedata["str_response_string"] = "Bad request"; return; } //agent.Dump(); // This is one of the meanings of PUT agent result = UpdateAgent(destination, agent); } else if ("AgentPosition".Equals(messageType)) { AgentPosition agent = new AgentPosition(); try { agent.Unpack(args, m_SimulationService.GetScene(destination.RegionID)); } catch (Exception ex) { m_log.InfoFormat("[AGENT HANDLER]: exception on unpacking ChildAgentUpdate message {0}", ex.Message); return; } //agent.Dump(); // This is one of the meanings of PUT agent result = m_SimulationService.UpdateAgent(destination, agent); } responsedata["int_response_code"] = HttpStatusCode.OK; responsedata["str_response_string"] = result.ToString(); //responsedata["str_response_string"] = OSDParser.SerializeJsonString(resp); ??? instead }
public void ChildAgentDataUpdate(AgentData cAgentData) { //MainConsole.Instance.Debug(" >>> ChildAgentDataUpdate <<< " + Scene.RegionInfo.RegionName); //if (!IsChildAgent) // return; CopyFrom(cAgentData); }
// subclasses can override this protected virtual bool UpdateAgent(GridRegion destination, AgentData agent) { return(m_SimulationService.UpdateAgent(destination, agent)); }
public void CopyFrom(AgentData cAgent) { try { m_callbackURI = cAgent.CallbackURI; m_pos = cAgent.Position; if (PhysicsActor != null) { AbsolutePosition = cAgent.Position; PhysicsActor.ForceSetPosition(cAgent.Position); } Velocity = cAgent.Velocity; m_CameraCenter = cAgent.Center; SetHeight(cAgent.Size.Z); m_CameraAtAxis = cAgent.AtAxis; m_CameraLeftAxis = cAgent.LeftAxis; m_CameraUpAxis = cAgent.UpAxis; DrawDistance = cAgent.Far; if ((cAgent.Throttles != null) && cAgent.Throttles.Length > 0) ControllingClient.SetChildAgentThrottle(cAgent.Throttles); m_headrotation = cAgent.HeadRotation; m_bodyRot = cAgent.BodyRotation; m_AgentControlFlags = (AgentManager.ControlFlags)cAgent.ControlFlags; m_savedVelocity = cAgent.Velocity; SpeedModifier = cAgent.Speed; DrawDistance = cAgent.DrawDistance; m_setAlwaysRun = cAgent.AlwaysRun; if (cAgent.IsCrossing) { m_scene.AuthenticateHandler.GetAgentCircuitData(UUID).teleportFlags |= (uint)TeleportFlags.ViaRegionID; m_scene.AuthenticateHandler.GetAgentCircuitData(UUID).reallyischild = false;//We're going to be a root } IAvatarAppearanceModule appearance = RequestModuleInterface<IAvatarAppearanceModule>(); if (appearance != null) { appearance.InitialHasWearablesBeenSent = cAgent.SentInitialWearables; appearance.Appearance = new AvatarAppearance(cAgent.Appearance); } // Animations try { Animator.ResetAnimations(); Animator.Animations.FromArray(cAgent.Anims); } catch { } try { if (cAgent.SittingObjects != null && cAgent.SittingObjects.m_sittingObjectXML != "") { ISceneObject sceneObject = null; IRegionSerialiserModule mod = Scene.RequestModuleInterface<IRegionSerialiserModule>(); if (mod != null) sceneObject = mod.DeserializeGroupFromXml2(cAgent.SittingObjects.m_sittingObjectXML, Scene); if (sceneObject != null) { //We were sitting on something when we crossed if (Scene.SceneGraph.RestorePrimToScene(sceneObject)) { if (sceneObject.RootChild.IsSelected) sceneObject.RootChild.CreateSelected = true; sceneObject.ScheduleGroupUpdate(PrimUpdateFlags.ForcedFullUpdate); sceneObject.CreateScriptInstances(0, false, StateSource.PrimCrossing, UUID.Zero); sceneObject.ResumeScripts(); sceneObject.RootChild.PhysActor.ForceSetVelocity(cAgent.Velocity); sceneObject.RootChild.PhysActor.Velocity = (cAgent.Velocity); sceneObject.AbsolutePosition = cAgent.Position; Animator.TrySetMovementAnimation(cAgent.SittingObjects.m_animation); m_nextSitAnimation = cAgent.SittingObjects.m_animation; cAgent.SittingObjects.m_objectID = sceneObject.UUID; m_objectToSitOn = cAgent.SittingObjects; foreach (ISceneChildEntity child in sceneObject.ChildrenEntities()) { foreach (TaskInventoryItem taskInv in child.Inventory.GetInventoryItems()) { TaskInventoryItem inv = taskInv; #if (!ISWIN) foreach (ControllerData cd in cAgent.Controllers) { if (cd.ItemID == inv.ItemID || cd.ItemID == inv.OldItemID) { cd.ItemID = taskInv.ItemID; } } #else foreach (ControllerData cd in cAgent.Controllers.Where(cd => cd.ItemID == inv.ItemID || cd.ItemID == inv.OldItemID)) { cd.ItemID = taskInv.ItemID; } #endif } } try { IScriptControllerModule m = RequestModuleInterface<IScriptControllerModule>(); if (m != null) if (cAgent.Controllers != null) m.Deserialize(cAgent.Controllers); } catch { } } } } } catch { } } catch (Exception ex) { MainConsole.Instance.Warn("[ScenePresence]: Error in CopyFrom: " + ex); } }
public override long GetFightOffset(FightData fightData, AgentData agentData, List <CombatItem> combatData) { return(GetFightOffsetByFirstInvulFilter(fightData, agentData, combatData, (int)ParseEnum.TargetIDS.MAMA, 762, 1500)); }
public virtual bool IncomingRetrieveRootAgent(IScene scene, UUID id, bool agentIsLeaving, out AgentData agent, out AgentCircuitData circuitData) { agent = null; circuitData = null; IScenePresence sp = scene.GetScenePresence (id); if ((sp != null) && (!sp.IsChildAgent)) { AgentData data = new AgentData (); sp.CopyTo (data); agent = data; circuitData = BuildCircuitDataForPresence(sp, sp.AbsolutePosition); //if (agentIsLeaving) // sp.SetAgentLeaving(null);//We arn't sure where they are going return true; } return false; }
byte[] TeleportLocation(Stream request, UUID agentID) { OSDMap retVal = new OSDMap(); if (_isInTeleportCurrently) { retVal.Add("reason", "Duplicate teleport request."); retVal.Add("success", OSD.FromBoolean(false)); return(OSDParser.SerializeLLSDXmlBytes(retVal)); } _isInTeleportCurrently = true; OSDMap rm = (OSDMap)OSDParser.DeserializeLLSDXml(HttpServerHandlerHelpers.ReadFully(request)); OSDMap pos = rm ["LocationPos"] as OSDMap; Vector3 position = new Vector3( (float)pos ["X"].AsReal(), (float)pos ["Y"].AsReal(), (float)pos ["Z"].AsReal()); /*OSDMap lookat = rm["LocationLookAt"] as OSDMap; * Vector3 lookAt = new Vector3((float)lookat["X"].AsReal(), * (float)lookat["Y"].AsReal(), * (float)lookat["Z"].AsReal());*/ ulong RegionHandle = rm ["RegionHandle"].AsULong(); const uint tpFlags = 16; if (m_service.ClientCaps.GetRootCapsService().RegionHandle != m_service.RegionHandle) { retVal.Add("reason", "Contacted by non-root region for teleport. Protocol implementation is wrong."); retVal.Add("success", OSD.FromBoolean(false)); return(OSDParser.SerializeLLSDXmlBytes(retVal)); } string reason = ""; int x, y; Util.UlongToInts(RegionHandle, out x, out y); GridRegion destination = m_service.Registry.RequestModuleInterface <IGridService> ().GetRegionByPosition( m_service.ClientCaps.AccountInfo.AllScopeIDs, x, y); ISimulationService simService = m_service.Registry.RequestModuleInterface <ISimulationService> (); AgentData ad = new AgentData(); AgentCircuitData circuitData = null; if (destination != null) { simService.RetrieveAgent(m_service.Region, m_service.AgentID, true, out ad, out circuitData); if (ad != null) { ad.Position = position; ad.Center = position; circuitData.StartingPosition = position; } } if (destination == null || circuitData == null) { retVal.Add("reason", "Could not find the destination region."); retVal.Add("success", OSD.FromBoolean(false)); return(OSDParser.SerializeLLSDXmlBytes(retVal)); } circuitData.IsChildAgent = false; if (m_agentProcessing.TeleportAgent(ref destination, tpFlags, circuitData, ad, m_service.AgentID, m_service.RegionID, out reason) || reason == "") { retVal.Add("success", OSD.FromBoolean(true)); } else { if (reason != "Already in a teleport") { //If this error occurs... don't kick them out of their current region simService.FailedToMoveAgentIntoNewRegion(m_service.AgentID, destination); } retVal.Add("reason", reason); retVal.Add("success", OSD.FromBoolean(false)); } //Send back data _isInTeleportCurrently = false; return(OSDParser.SerializeLLSDXmlBytes(retVal)); }
public virtual void InternalCross(IScenePresence agent, Vector3 attemptedPos, bool isFlying, GridRegion crossingRegion) { if(agent.PhysicsActor != null) agent.PhysicsActor.IsPhysical = false; MainConsole.Instance.DebugFormat("[EntityTransferModule]: Crossing agent {0} to region {1}", agent.Name, crossingRegion.RegionName); try { agent.SetAgentLeaving(crossingRegion); AgentData cAgent = new AgentData(); agent.CopyTo(cAgent); cAgent.Position = attemptedPos; if (isFlying) cAgent.ControlFlags |= (uint)AgentManager.ControlFlags.AGENT_CONTROL_FLY; AgentCircuitData agentCircuit = BuildCircuitDataForPresence(agent, attemptedPos); agentCircuit.teleportFlags = (uint)TeleportFlags.ViaRegionID; IEventQueueService eq = agent.Scene.RequestModuleInterface<IEventQueueService>(); if (eq != null) { //This does UpdateAgent and closing of child agents // messages if they need to be called ISyncMessagePosterService syncPoster = agent.Scene.RequestModuleInterface<ISyncMessagePosterService>(); if (syncPoster != null) { syncPoster.Get(SyncMessageHelper.CrossAgent(crossingRegion, attemptedPos, agent.Velocity, agentCircuit, cAgent, agent.Scene.RegionInfo.RegionHandle), agent.UUID, agent.Scene.RegionInfo.RegionHandle, (map) => { if (map == null || !map["success"].AsBoolean()) { //Tell modules that we have failed agent.AgentFailedToLeave(); if (map != null) { if (map.ContainsKey("Note") && !map["Note"].AsBoolean()) return; agent.ControllingClient.SendTeleportFailed(map["Reason"].AsString()); } else agent.ControllingClient.SendTeleportFailed("TP Failed"); if (agent.PhysicsActor != null) agent.PhysicsActor.IsPhysical = true; //Fix the setting that we set earlier // In any case agent.FailedCrossingTransit(crossingRegion); return; } //We're killing the animator and the physics actor, so we don't need to worry about agent.PhysicsActor.IsPhysical agent.MakeChildAgent(crossingRegion); //Revolution- We already were in this region... we don't need updates about the avatars we already know about, right? // OLD: now we have a child agent in this region. Request and send all interesting data about (root) agents in the sim //agent.SendOtherAgentsAvatarDataToMe(); //agent.SendOtherAgentsAppearanceToMe(); //Kill the groups here, otherwise they will become ghost attachments // and stay in the sim, they'll get readded below into the new sim //KillAttachments(agent); // In any case agent.SuccessfulCrossingTransit(crossingRegion); }); } } } catch(Exception ex) { MainConsole.Instance.Warn("[EntityTransferModule]: Exception in crossing: " + ex); } }
// public void InitializeNewGenerationDataArrays(int generationIndex) { // For This Player: if(generationIndex >= generationDataList.Count) { // if new generation needs to be created //Debug.Log ("InitializeNewGenerationDataArrays" + generationIndex.ToString()); int numAgents = playerRef.masterPopulation.populationMaxSize; GenerationData newGenerationData = new GenerationData(numAgents); // Now I have a generationData wrapper and an array of AgentData's // Get number of Trials int numActiveTrials = 0; for(int i = 0; i < playerRef.masterTrialsList.Count; i++) { // First loop needed just to Count if(playerRef.masterTrialsList[i].miniGameManager.gameType != MiniGameManager.MiniGameType.None) { // if active trial numActiveTrials++; } } //Debug.Log ("NumActiveTrials= " + numActiveTrials.ToString() + ", NumAgents= " + numAgents.ToString()); // Loop over all agents? for(int j = 0; j < numAgents; j++) { AgentData newAgentData = new AgentData(numActiveTrials); // Fill the AgentData's TrialsList: int curTrialIndex = 0; int totalNumComponents = 0; for(int i = 0; i < playerRef.masterTrialsList.Count; i++) { if(playerRef.masterTrialsList[i].miniGameManager.gameType != MiniGameManager.MiniGameType.None) { // if active trial // For each Trial, Get number of FitnessComponents & GameRounds int numGameRounds = playerRef.masterTrialsList[i].numberOfPlays; int totalFitnessComponents = playerRef.masterTrialsList[i].fitnessManager.brainFitnessComponentList.Count + playerRef.masterTrialsList[i].fitnessManager.gameFitnessComponentList.Count; int numActiveFitnessComponents = 0; // Brain Components: for(int b = 0; b < playerRef.masterTrialsList[i].fitnessManager.brainFitnessComponentList.Count; b++) { if(playerRef.masterTrialsList[i].fitnessManager.brainFitnessComponentList[b].on) { numActiveFitnessComponents++; totalNumComponents++; } } // Game Components: for(int g = 0; g < playerRef.masterTrialsList[i].fitnessManager.gameFitnessComponentList.Count; g++) { if(playerRef.masterTrialsList[i].fitnessManager.gameFitnessComponentList[g].on) { numActiveFitnessComponents++; totalNumComponents++; } } int curFitnessComponentIndex = 0; TrialData newTrialData = new TrialData(numActiveFitnessComponents); for(int b = 0; b < playerRef.masterTrialsList[i].fitnessManager.brainFitnessComponentList.Count; b++) { if(playerRef.masterTrialsList[i].fitnessManager.brainFitnessComponentList[b].on) { newTrialData.fitnessComponentDataArray[curFitnessComponentIndex] = new FitnessComponentData(numGameRounds); curFitnessComponentIndex++; } } for(int g = 0; g < playerRef.masterTrialsList[i].fitnessManager.gameFitnessComponentList.Count; g++) { if(playerRef.masterTrialsList[i].fitnessManager.gameFitnessComponentList[g].on) { newTrialData.fitnessComponentDataArray[curFitnessComponentIndex] = new FitnessComponentData(numGameRounds); curFitnessComponentIndex++; } } newAgentData.trialDataArray[curTrialIndex] = newTrialData; // Set AgentData for this agent. //Debug.Log ("curTrialIndex= " + curTrialIndex.ToString() + ", numGameRounds= " + numGameRounds.ToString() + ", numFitnessComponents= " + totalFitnessComponents.ToString() + ", numActiveFitnessComponents= " + numActiveFitnessComponents.ToString()); curTrialIndex++; // before or after? } } newGenerationData.agentDataArray[j] = newAgentData; // actually assign the new AgentData instance to generationData newGenerationData.totalNumFitnessComponents = totalNumComponents; } // generationDataList.Add (newGenerationData); // Add the newly created generation data to the master list } }
public override int IsCM(CombatData combatData, AgentData agentData, FightData fightData) { return(2); }
public override List <InstantCastEvent> ComputeInstantCast(CombatData combatData, SkillData skillData, AgentData agentData) { var res = new List <InstantCastEvent>(); var applies = combatData.GetBuffData(BuffID).OfType <BuffApplyEvent>().GroupBy(x => x.By).ToDictionary(x => x.Key, x => x.ToList()); foreach (KeyValuePair <AgentItem, List <BuffApplyEvent> > pair in applies) { long lastTime = int.MinValue; foreach (BuffApplyEvent bae in pair.Value) { if (bae.Time - lastTime < ICD) { lastTime = bae.Time; continue; } if (_triggerCondition != null) { if (_triggerCondition(bae, combatData)) { lastTime = bae.Time; res.Add(new InstantCastEvent(bae.Time, skillData.Get(SkillID), bae.By)); } } else { lastTime = bae.Time; res.Add(new InstantCastEvent(bae.Time, skillData.Get(SkillID), bae.By)); } } } return(res); }
public BuffRemoveManualEvent(CombatItem evtcItem, AgentData agentData, SkillData skillData) : base(evtcItem, agentData, skillData) { }
internal DespawnEvent(CombatItem evtcItem, AgentData agentData) : base(evtcItem, agentData) { }
public override void SpecialParse(FightData fightData, AgentData agentData, List <CombatItem> combatData) { // find target Target target = Targets.Find(x => x.ID == (ushort)ParseEnum.TargetIDS.Xera); if (target == null) { throw new InvalidOperationException("Main target of the fight not found"); } // enter combat CombatItem enterCombat = combatData.Find(x => x.SrcInstid == target.InstID && x.IsStateChange == ParseEnum.StateChange.EnterCombat); if (enterCombat != null) { fightData.FightStart = enterCombat.Time; } // find split foreach (AgentItem NPC in agentData.GetAgentByType(AgentItem.AgentType.NPC)) { if (NPC.ID == 16286) { target.Health = 24085950; CombatItem move = combatData.FirstOrDefault(x => x.IsStateChange == ParseEnum.StateChange.Position && x.SrcInstid == NPC.InstID && x.Time >= NPC.FirstAware + 500 && x.Time <= NPC.LastAware); if (move != null) { _specialSplit = move.Time; } else { _specialSplit = NPC.FirstAware; } target.AgentItem.LastAware = NPC.LastAware; // get unique id for the fusion ushort instID = 0; Random rnd = new Random(); while (agentData.InstIDValues.Contains(instID) || instID == 0) { instID = (ushort)rnd.Next(ushort.MaxValue / 2, ushort.MaxValue); } target.AgentItem.InstID = instID; agentData.Refresh(); HashSet <ulong> agents = new HashSet <ulong>() { NPC.Agent, target.Agent }; // update combat data foreach (CombatItem c in combatData) { if (agents.Contains(c.SrcAgent)) { c.OverrideSrcValues(target.Agent, target.InstID); } if (agents.Contains(c.DstAgent)) { c.OverrideDstValues(target.Agent, target.InstID); } } break; } } }
protected override void RestartStatsAndState(float percentage, AgentData data) {}
internal override void CheckSuccess(CombatData combatData, AgentData agentData, FightData fightData, IReadOnlyCollection <AgentItem> playerAgents) { SetSuccessByDeath(combatData, fightData, playerAgents, true, (int)ArcDPSEnums.TargetID.BrokenKing); }
internal virtual FightData.CMStatus IsCM(CombatData combatData, AgentData agentData, FightData fightData) { return(FightData.CMStatus.NoCM); }
private void CompleteAgents(ParserController operation) { var agentsLookup = _allAgentsList.GroupBy(x => x.Agent).ToDictionary(x => x.Key, x => x.ToList()); //var agentsLookup = _allAgentsList.ToDictionary(x => x.Agent); // Set Agent instid, firstAware and lastAware var invalidCombatItems = new HashSet <CombatItem>(); foreach (CombatItem c in _combatItems) { if (c.SrcIsAgent()) { if (agentsLookup.TryGetValue(c.SrcAgent, out List <AgentItem> agents)) { bool updatedAgent = false; foreach (AgentItem agent in agents) { updatedAgent = UpdateAgentData(agent, c.Time, c.SrcInstid, agents.Count > 1); if (updatedAgent) { break; } } // this means that this particular combat item does not point to a proper agent if (!updatedAgent && c.SrcInstid != 0) { invalidCombatItems.Add(c); } } } if (c.DstIsAgent()) { if (agentsLookup.TryGetValue(c.DstAgent, out List <AgentItem> agents)) { bool updatedAgent = false; foreach (AgentItem agent in agents) { updatedAgent = UpdateAgentData(agent, c.Time, c.DstInstid, agents.Count > 1); if (updatedAgent) { break; } } // this means that this particular combat item does not point to a proper agent if (!updatedAgent && c.DstInstid != 0) { invalidCombatItems.Add(c); } } } } if (invalidCombatItems.Any()) { #if DEBUG throw new InvalidDataException("Must remove " + invalidCombatItems.Count + " invalid combat items"); #else operation.UpdateProgressWithCancellationCheck("Removing " + invalidCombatItems.Count + " invalid combat items"); _combatItems.RemoveAll(x => invalidCombatItems.Contains(x)); #endif } _allAgentsList.RemoveAll(x => !(x.InstID != 0 && x.LastAware - x.FirstAware >= 0 && x.FirstAware != 0 && x.LastAware != long.MaxValue) && (x.Type != AgentItem.AgentType.Player && x.Type != AgentItem.AgentType.NonSquadPlayer)); _agentData = new AgentData(_allAgentsList); if (_agentData.GetAgentByType(AgentItem.AgentType.Player).Count == 0) { throw new EvtcAgentException("No players found"); } _fightData = new FightData(_id, _agentData, _parserSettings, _logStartTime, _logEndTime); operation.UpdateProgressWithCancellationCheck("Linking minions to their masters"); foreach (CombatItem c in _combatItems) { if (c.SrcIsAgent() && c.SrcMasterInstid != 0) { FindAgentMaster(c.Time, c.SrcMasterInstid, c.SrcAgent); } if (c.DstIsAgent() && c.DstMasterInstid != 0) { FindAgentMaster(c.Time, c.DstMasterInstid, c.DstAgent); } } // Adjust extension events if needed if (_enabledExtensions.Any()) { operation.UpdateProgressWithCancellationCheck("Adjust extension events"); foreach (CombatItem combatItem in _combatItems) { if (combatItem.IsExtension) { if (_enabledExtensions.TryGetValue(combatItem.Pad, out AbstractExtensionHandler handler)) { handler.AdjustCombatEvent(combatItem, _agentData); } } } } operation.UpdateProgressWithCancellationCheck("Creating players"); CompletePlayers(operation); }
internal virtual void CheckSuccess(CombatData combatData, AgentData agentData, FightData fightData, HashSet <AgentItem> playerAgents) { SetSuccessByDeath(combatData, fightData, playerAgents, true, GenericTriggerID); }
void doneAsync() { lock (environment) { bool ok = false; try { // log.set(MessageCollection.T_MSG_OPERATION_STARTING); // makeDbReadonly(); // string fileWorkDir = ToolMobile.getFullPath("data"); ToolMobile.createDir(fileWorkDir); string fileOutputZip = Path.Combine(fileWorkDir, "toava.zip"); string fileOutputXml = Path.Combine(fileWorkDir, "toava.xml"); // bool res = false; //Source //if (environment.getAppSettings().getBool(AvaExt.Settings.SettingsAvaAgent.MOB_USE_LOCAL_EXPIMP_B)) //{ // //SaveFileDialog sfd = new SaveFileDialog(); // //if (sfd.ShowDialog() == DialogResult.OK) // // fileOutputXml = sfd.FileName; // //else // // throw new Exception(string.Empty); //} // log.set(MessageCollection.T_MSG_DATA_READING); // XmlDocument doc = new XmlDocument(); string docID = "LOGICALREF"; AdapterUserDocument[] adapters = new AdapterUserDocument[] { new AdapterUserWholesaleSlip(environment, new ImplAdapterDataSetStub(environment, new AdapterDataSetWholesaleSlip(environment))), new AdapterUserWholesaleOrder(environment, new ImplAdapterDataSetStub(environment, new AdapterDataSetWholesaleOrder(environment))), new AdapterUserCashClient(environment, new ImplAdapterDataSetStub(environment, new AdapterDataSetCashClient(environment))) }; IPagedSource[] sources = new IPagedSource[] { new PagedSourceSlip(environment), new PagedSourceOrder(environment), new PagedSourceCashTrans(environment) }; string[] arrDesc = new string[] { environment.translate(WordCollection.T_DOC_STOCK_TRANS), environment.translate(WordCollection.T_DOC_STOCK_ORDERS), environment.translate(WordCollection.T_DOC_FINANCE) }; bool hasData = false; for (int i = 0; i < sources.Length; ++i) { IPagedSource source = sources[i]; source.getBuilder().addParameterValue(TableDUMMY.CANCELLED, ConstBool.not); AdapterUserDocument adapter = adapters[i]; log.set(MessageCollection.T_MSG_DATA_READING, new object[] { arrDesc[i] }); DataTable table = source.getAll(); log.set(MessageCollection.T_MSG_DATA_EXPORT, new object[] { arrDesc[i] }); foreach (DataRow row in table.Rows) { hasData = true; adapter.edit(row[docID]); adapter.export(doc); } } if (!hasData) { throw new Exception(MessageCollection.T_MSG_ERROR_NO_DATA); } // string[] expSettings = environment.getSysSettings().getAllSettings(); foreach (string settingsName in expSettings) { if (settingsName.StartsWith("MOB_SYS_")) { XmlAttribute attr = doc.CreateAttribute(settingsName); attr.Value = environment.getSysSettings().getString(settingsName); doc.DocumentElement.Attributes.Append(attr); } } // log.set(MessageCollection.T_MSG_DATA_WRITING); // doc.Save(fileOutputXml); ToolZip.compress(fileOutputZip, fileOutputXml); // if (!environment.getAppSettings().getBool(AvaExt.Settings.SettingsAvaAgent.MOB_USE_LOCAL_EXPIMP_B)) // { if (ToolMobile.existsFile(fileOutputZip)) { // log.set(MessageCollection.T_MSG_DATA_SENDING); // AgentData ad = new AgentData(environment); ad.chackOperationResult(ad.sendData(ToolMobile.readFileData(fileOutputZip))); } // } ok = true; } catch (Exception exc) { log.error(ToolException.unwrap(exc)); environment.getExceptionHandler().setException(exc); } finally { log.set(MessageCollection.T_MSG_OPERATION_FINISHING); Thread.Sleep(1000); log.hide(); } } }
internal virtual long GetFightOffset(FightData fightData, AgentData agentData, List <CombatItem> combatData) { return(fightData.LogStart); }
public AgentUpdate2Ret DoChildAgentUpdateCall2(SimpleRegionInfo regInfo, AgentData data) { ulong regionHandle = GetRegionHandle(regInfo.RegionHandle); string uri = "http://" + regInfo.ExternalHostName + ":" + regInfo.HttpPort + "/agent2/" + data.AgentID + "/" + regionHandle + "/"; HttpWebRequest agentPutRequest = (HttpWebRequest)WebRequest.Create(uri); agentPutRequest.Method = "PUT"; agentPutRequest.ContentType = "application/octet-stream"; agentPutRequest.Timeout = AGENT_UPDATE_TIMEOUT; agentPutRequest.Headers["authorization"] = GenerateAuthorization(); AgentPutMessage message = AgentPutMessage.FromAgentData(data); try { // send the Post Stream os = agentPutRequest.GetRequestStream(); ProtoBuf.Serializer.Serialize(os, message); os.Flush(); os.Close(); m_log.InfoFormat("[REST COMMS]: PUT DoChildAgentUpdateCall2 request to remote sim {0}", uri); } catch (Exception e) { m_log.ErrorFormat("[REST COMMS]: DoChildAgentUpdateCall2 call failed {0}", e); return AgentUpdate2Ret.Error; } // Let's wait for the response //m_log.Info("[REST COMMS]: Waiting for a reply after DoCreateChildAgentCall"); try { HttpWebResponse webResponse = (HttpWebResponse)agentPutRequest.GetResponse(); if (webResponse == null) { m_log.Error("[REST COMMS]: Null reply on DoChildAgentUpdateCall2 put"); return AgentUpdate2Ret.Error; } StreamReader sr = new StreamReader(webResponse.GetResponseStream()); string reply = sr.ReadToEnd().Trim(); sr.Close(); //this will happen during the initial rollout and tells us we need to fall back to the //old method if (webResponse.StatusCode == HttpStatusCode.NotFound) { m_log.InfoFormat("[REST COMMS]: NotFound on reply of DoChildAgentUpdateCall2"); return AgentUpdate2Ret.NotFound; } else if (webResponse.StatusCode == HttpStatusCode.OK) { return AgentUpdate2Ret.Ok; } else { m_log.ErrorFormat("[REST COMMS]: Error on reply of DoChildAgentUpdateCall2 {0}", reply); return AgentUpdate2Ret.Error; } } catch (WebException ex) { HttpWebResponse webResponse = ex.Response as HttpWebResponse; if (webResponse != null) { //this will happen during the initial rollout and tells us we need to fall back to the //old method if (webResponse.StatusCode == HttpStatusCode.NotFound) { m_log.InfoFormat("[REST COMMS]: NotFound on reply of DoChildAgentUpdateCall2"); return AgentUpdate2Ret.NotFound; } if (webResponse.StatusCode == HttpStatusCode.Forbidden) { m_log.InfoFormat("[REST COMMS]: Forbidden returned on reply of DoChildAgentUpdateCall2"); return AgentUpdate2Ret.AccessDenied; } } m_log.ErrorFormat("[REST COMMS]: exception on reply of DoChildAgentUpdateCall2 {0} Sz {1}", ex, agentPutRequest.ContentLength); } return AgentUpdate2Ret.Error; }
internal virtual void EIEvtcParse(FightData fightData, AgentData agentData, List <CombatItem> combatData, List <Player> playerList) { ComputeFightTargets(agentData, combatData); }
protected virtual OSDMap OnMessageReceived(OSDMap message) { if (!message.ContainsKey("Method")) return null; UUID AgentID = message["AgentID"].AsUUID(); ulong requestingRegion = message["RequestingRegion"].AsULong(); ICapsService capsService = m_registry.RequestModuleInterface<ICapsService>(); if (capsService == null) return new OSDMap(); IClientCapsService clientCaps = capsService.GetClientCapsService(AgentID); IRegionClientCapsService regionCaps = null; if (clientCaps != null) regionCaps = clientCaps.GetCapsService(requestingRegion); if (message["Method"] == "LogoutRegionAgents") { LogOutAllAgentsForRegion(requestingRegion); } else if (message["Method"] == "RegionIsOnline") //This gets fired when the scene is fully finished starting up { //Log out all the agents first, then add any child agents that should be in this region LogOutAllAgentsForRegion(requestingRegion); IGridService GridService = m_registry.RequestModuleInterface<IGridService>(); if (GridService != null) { int x, y; Util.UlongToInts(requestingRegion, out x, out y); GridRegion requestingGridRegion = GridService.GetRegionByPosition(null, x, y); if (requestingGridRegion != null) Util.FireAndForget((o) => EnableChildAgentsForRegion(requestingGridRegion)); } } else if (message["Method"] == "DisableSimulator") { //KILL IT! if (regionCaps == null || clientCaps == null) return null; IEventQueueService eventQueue = m_registry.RequestModuleInterface<IEventQueueService>(); eventQueue.DisableSimulator(regionCaps.AgentID, regionCaps.RegionHandle); //regionCaps.Close(); //clientCaps.RemoveCAPS(requestingRegion); regionCaps.Disabled = true; } else if (message["Method"] == "ArrivedAtDestination") { if (regionCaps == null || clientCaps == null) return null; //Recieved a callback if (clientCaps.InTeleport) //Only set this if we are in a teleport, // otherwise (such as on login), this won't check after the first tp! clientCaps.CallbackHasCome = true; regionCaps.Disabled = false; //The agent is getting here for the first time (eg. login) OSDMap body = ((OSDMap) message["Message"]); //Parse the OSDMap int DrawDistance = body["DrawDistance"].AsInteger(); AgentCircuitData circuitData = new AgentCircuitData(); circuitData.UnpackAgentCircuitData((OSDMap) body["Circuit"]); //Now do the creation EnableChildAgents(AgentID, requestingRegion, DrawDistance, circuitData); } else if (message["Method"] == "CancelTeleport") { if (regionCaps == null || clientCaps == null) return null; //Only the region the client is root in can do this IRegionClientCapsService rootCaps = clientCaps.GetRootCapsService(); if (rootCaps != null && rootCaps.RegionHandle == regionCaps.RegionHandle) { //The user has requested to cancel the teleport, stop them. clientCaps.RequestToCancelTeleport = true; regionCaps.Disabled = false; } } else if (message["Method"] == "AgentLoggedOut") { //ONLY if the agent is root do we even consider it if (regionCaps != null) { if (regionCaps.RootAgent) { LogoutAgent(regionCaps, false); //The root is killing itself } } } else if (message["Method"] == "SendChildAgentUpdate") { if (regionCaps == null || clientCaps == null) return null; IRegionClientCapsService rootCaps = clientCaps.GetRootCapsService(); if (rootCaps != null && rootCaps.RegionHandle == regionCaps.RegionHandle) //Has to be root { OSDMap body = ((OSDMap) message["Message"]); AgentPosition pos = new AgentPosition(); pos.Unpack((OSDMap) body["AgentPos"]); SendChildAgentUpdate(pos, regionCaps); regionCaps.Disabled = false; } } else if (message["Method"] == "TeleportAgent") { if (regionCaps == null || clientCaps == null) return null; IRegionClientCapsService rootCaps = clientCaps.GetRootCapsService(); if (rootCaps != null && rootCaps.RegionHandle == regionCaps.RegionHandle) { OSDMap body = ((OSDMap) message["Message"]); GridRegion destination = new GridRegion(); destination.FromOSD((OSDMap) body["Region"]); uint TeleportFlags = body["TeleportFlags"].AsUInteger(); int DrawDistance = body["DrawDistance"].AsInteger(); AgentCircuitData Circuit = new AgentCircuitData(); Circuit.UnpackAgentCircuitData((OSDMap) body["Circuit"]); AgentData AgentData = new AgentData(); AgentData.Unpack((OSDMap) body["AgentData"]); regionCaps.Disabled = false; string ResponseURL = message["ResponseURL"].AsString(); if (ResponseURL == "") { OSDMap result = new OSDMap(); string reason = ""; result["success"] = TeleportAgent(ref destination, TeleportFlags, DrawDistance, Circuit, AgentData, AgentID, requestingRegion, out reason); result["Reason"] = reason; //Remove the region flags, not the regions problem destination.Flags = 0; result["Destination"] = destination.ToOSD(); //Send back the new destination return result; } else { Util.FireAndForget(delegate { OSDMap result = new OSDMap(); string reason = ""; result["success"] = TeleportAgent(ref destination, TeleportFlags, DrawDistance, Circuit, AgentData, AgentID, requestingRegion, out reason); result["Reason"] = reason; //Remove the region flags, not the regions problem destination.Flags = 0; result["Destination"] = destination.ToOSD(); //Send back the new destination WebUtils.PostToService(ResponseURL, result); }); return new OSDMap() { new KeyValuePair<string, OSD>("WillHaveResponse", true) }; } } } else if (message["Method"] == "CrossAgent") { if (regionCaps == null || clientCaps == null) return null; IRegionClientCapsService rootCaps = clientCaps.GetRootCapsService(); if (rootCaps == null || rootCaps.RegionHandle == regionCaps.RegionHandle) { //This is a simulator message that tells us to cross the agent OSDMap body = ((OSDMap) message["Message"]); Vector3 pos = body["Pos"].AsVector3(); Vector3 Vel = body["Vel"].AsVector3(); GridRegion Region = new GridRegion(); Region.FromOSD((OSDMap) body["Region"]); AgentCircuitData Circuit = new AgentCircuitData(); Circuit.UnpackAgentCircuitData((OSDMap) body["Circuit"]); AgentData AgentData = new AgentData(); AgentData.Unpack((OSDMap) body["AgentData"]); regionCaps.Disabled = false; string ResponseURL = message["ResponseURL"].AsString(); if (ResponseURL == "") { OSDMap result = new OSDMap(); string reason = ""; result["success"] = CrossAgent(Region, pos, Vel, Circuit, AgentData, AgentID, requestingRegion, out reason); result["reason"] = reason; return result; } else { Util.FireAndForget(delegate { OSDMap result = new OSDMap(); string reason = ""; result["success"] = CrossAgent(Region, pos, Vel, Circuit, AgentData, AgentID, requestingRegion, out reason); result["reason"] = reason; if (ResponseURL != null) WebUtils.PostToService(ResponseURL, result); }); return new OSDMap() { new KeyValuePair<string, OSD>("WillHaveResponse", true) }; } } else if (clientCaps.InTeleport) { OSDMap result = new OSDMap(); result["success"] = false; result["Note"] = false; return result; } else { OSDMap result = new OSDMap(); result["success"] = false; result["Note"] = false; return result; } } return null; }
internal override string GetLogicName(CombatData combatData, AgentData agentData) { return("Twin Largos"); }
public virtual bool TeleportAgent(ref GridRegion destination, uint TeleportFlags, int DrawDistance, AgentCircuitData circuit, AgentData agentData, UUID AgentID, ulong requestingRegion, out string reason) { IClientCapsService clientCaps = m_registry.RequestModuleInterface<ICapsService>().GetClientCapsService(AgentID); IRegionClientCapsService regionCaps = clientCaps.GetCapsService(requestingRegion); if (regionCaps == null || !regionCaps.RootAgent) { reason = ""; ResetFromTransit(AgentID); return false; } bool result = false; try { bool callWasCanceled = false; ISimulationService SimulationService = m_registry.RequestModuleInterface<ISimulationService>(); if (SimulationService != null) { //Set the user in transit so that we block duplicate tps and reset any cancelations if (!SetUserInTransit(AgentID)) { reason = "Already in a teleport"; return false; } bool useCallbacks = false; //Note: we have to pull the new grid region info as the one from the region cannot be trusted GridRegion oldRegion = destination; IGridService GridService = m_registry.RequestModuleInterface<IGridService>(); if (GridService != null) { destination = GridService.GetRegionByUUID(clientCaps.AccountInfo.AllScopeIDs, destination.RegionID); if (destination == null) //If its not in this grid destination = oldRegion; //Inform the client of the neighbor if needed circuit.child = false; //Force child status to the correct type circuit.roothandle = destination.RegionHandle; if (!InformClientOfNeighbor(AgentID, requestingRegion, circuit, ref destination, TeleportFlags, agentData, out reason, out useCallbacks)) { ResetFromTransit(AgentID); return false; } } else { reason = "Could not find the grid service"; ResetFromTransit(AgentID); return false; } IEventQueueService EQService = m_registry.RequestModuleInterface<IEventQueueService>(); IRegionClientCapsService otherRegion = clientCaps.GetCapsService(destination.RegionHandle); EQService.TeleportFinishEvent(destination.RegionHandle, destination.Access, otherRegion.LoopbackRegionIP, otherRegion.CircuitData.RegionUDPPort, otherRegion.CapsUrl, 4, AgentID, TeleportFlags, destination.RegionSizeX, destination.RegionSizeY, requestingRegion); // TeleportFinish makes the client send CompleteMovementIntoRegion (at the destination), which // trigers a whole shebang of things there, including MakeRoot. So let's wait for confirmation // that the client contacted the destination before we send the attachments and close things here. result = !useCallbacks || WaitForCallback(AgentID, out callWasCanceled); if (!result) { //It says it failed, lets call the sim and check AgentData data = null; AgentCircuitData circuitData; result = SimulationService.RetrieveAgent(destination, AgentID, false, out data, out circuitData); } if (!result) { if (!callWasCanceled) { MainConsole.Instance.Warn("[AgentProcessing]: Callback never came for teleporting agent " + AgentID + ". Resetting."); } //Close the agent at the place we just created if it isn't a neighbor // 7/22 -- Kill the agent no matter what, it obviously is having issues getting there //if (IsOutsideView (regionCaps.RegionX, destination.RegionLocX, regionCaps.Region.RegionSizeX, destination.RegionSizeX, // regionCaps.RegionY, destination.RegionLocY, regionCaps.Region.RegionSizeY, destination.RegionSizeY)) { SimulationService.CloseAgent(destination, AgentID); clientCaps.RemoveCAPS(destination.RegionHandle); } reason = !callWasCanceled ? "The teleport timed out" : "Cancelled"; } else { //Fix the root agent status otherRegion.RootAgent = true; regionCaps.RootAgent = false; // Next, let's close the child agent connections that are too far away. //if (useCallbacks || oldRegion != destination)//Only close it if we are using callbacks (Aurora region) //Why? OpenSim regions need closed too, even if the protocol is kinda stupid CloseNeighborAgents(regionCaps.Region, destination, AgentID); reason = ""; } } else reason = "No SimulationService found!"; } catch (Exception ex) { MainConsole.Instance.WarnFormat("[AgentProcessing]: Exception occured during agent teleport, {0}", ex); reason = "Exception occured."; } //All done ResetFromTransit(AgentID); return result; }
private ChildAgentUpdate2Response SendChildAgentUpdate2() { ScenePresence agent = _avatar.ScenePresence; SceneObjectGroup sceneObjectGroup = _avatar.TransitArgs.RideOnGroup; SceneObjectPart part = _avatar.TransitArgs.RideOnPart; ulong newRegionHandle = _avatar.TransitArgs.DestinationRegion.RegionHandle; SimpleRegionInfo neighbourRegion = _avatar.TransitArgs.DestinationRegion; Vector3 pos = _avatar.TransitArgs.LocationInDestination; AgentLocomotionFlags locomotionFlags = 0; if (_avatar.TransitArgs.Type == TransitType.OutboundCrossing) { locomotionFlags = AgentLocomotionFlags.Crossing; } else if (_avatar.TransitArgs.Type == TransitType.OutboundTeleport) { locomotionFlags = AgentLocomotionFlags.Teleport; } AgentData cAgent = new AgentData(); agent.CopyToForRootAgent(cAgent); if (part == null) { cAgent.Position = pos; } cAgent.LocomotionState = 1; cAgent.LocomotionFlags = locomotionFlags; List <SceneObjectGroup> attachments = agent.CollectAttachmentsForCrossing(); //try the new comms first var engine = ProviderRegistry.Instance.Get <ISerializationEngine>(); if (engine == null) { _log.ErrorFormat("[SCENE COMM]: Cannot send child agent update to {0}, Serialization engine is missing!", neighbourRegion.RegionHandle); return(ChildAgentUpdate2Response.Error); } List <byte[]> serializedAttachments = new List <byte[]>(); foreach (var att in attachments) { //mark the SOG in-transit. this along with the serialization below sends a disable to the script engine, but they are not cumulative att.StartTransit(); //we are stopping the scripts as part of the serialization process here //this means that later on, should the remote creation call fail, we need to re-enable them //reenabling is done via EndTransit with success==false byte[] sogBytes = engine.SceneObjectSerializer.SerializeGroupToBytes(att, SerializationFlags.FromCrossing | SerializationFlags.StopScripts | SerializationFlags.SerializeScriptBytecode); serializedAttachments.Add(sogBytes); } cAgent.SerializedAttachments = serializedAttachments; var scene = agent.Scene; cAgent.CallbackURI = scene.RegionInfo.InsecurePublicHTTPServerURI + "/agent/" + agent.UUID.ToString() + "/" + agent.Scene.RegionInfo.RegionHandle.ToString() + "/release/"; ChildAgentUpdate2Response resp = scene.InterregionComms.SendChildAgentUpdate2(neighbourRegion, cAgent); if (resp == ChildAgentUpdate2Response.Error) { _log.ErrorFormat("[SCENE COMM]: Error sending child agent update to {0}", neighbourRegion.RegionHandle); } else if (resp == ChildAgentUpdate2Response.MethodNotAvailalble) { _log.ErrorFormat("[SCENE COMM]: Error sending child agent update to {0}, ChildAgentUpdate2 not available. Falling back to old method", neighbourRegion.RegionHandle); } return(resp); }