public void SendEffect(Simulator sim, UUID sourceID, UUID targetID, Vector3d targetPos, string effectType, float duration, UUID id, PCode sourceType) { if (!MaintainEffects) { return; } if (sourceID == client.Self.AgentID) { return; //not sending our own effects } if (!IsMaster(sim)) { return; } if (MaintainOnlyMasterEffects && client.MasterKey != UUID.Zero) { if (!(client.MasterKey == targetID || sourceID == client.MasterKey)) { return; } } if (id != UUID.Zero) { // if (EffectsSent.Contains(id)) return; // EffectsSent.Add(id); } object s = sourceID; object t = targetID; object p = targetPos; //if (SkippedEffects.Contains(effectType)) return; SimObject source = GetSimObjectFromUUID(sourceID); if (source == null) { if (sourceID != UUID.Zero) { source = GetSource(sim, sourceID, source, ref s, sourceType); if (source == null) { return; } } // RequestAsset(sourceID, AssetType.Object, true); } else { s = source; } if (source is SimObjectImpl && !(source is SimAvatar)) { Debug("Write source is Object " + source); } SimObject target = GetSimObjectFromUUID(targetID); if (target == null) { if (targetID != UUID.Zero) { target = GetSource(sim, targetID, target, ref t, PCode.None); if (target == null) { return; } } // RequestAsset(targetID, AssetType.Object, true); } else { t = target; } double dist; SimObject ST = target; if (ST == null) { ST = source; } if (targetPos.X < 256) { if (targetPos == Vector3d.Zero) { p = SimHeading.UNKNOWN; } else { if (ST != null) { Vector3d STGlobalPosition; if (ST.TryGetGlobalPosition(out STGlobalPosition)) { p = (STGlobalPosition + targetPos); } else { p = AsRLocation(sim, targetPos, ST); } } else { p = new Vector3((float)targetPos.X, (float)targetPos.Y, (float)targetPos.Z); } } } else { SimObject posTarget = GetSimObjectFromVector(targetPos, out dist); if (dist < 0.5) { p = posTarget; if (targetID == UUID.Zero) { // now we have a target t = posTarget; // todo should we revert back to position? //p = targetPos; } } else { if (targetID == UUID.Zero) { // now we have a target t = targetPos; // todo should we revert back to position? //p = targetPos; } } } EventQueue.Enqueue(() => { source = SecondChanceUUID(ref s, source); target = SecondChanceUUID(ref t, target); //if (source != null) source; // WriteLine("ClientManager Avatars_OnLookAt: " + sourceID.ToString() + " to " + targetID.ToString() + " at " + targetID.ToString() + " with type " + lookType.ToString() + " duration " + duration.ToString()); if (targetID == client.Self.AgentID) { // if (lookType == LookAtType.Idle) return; //WriteLine(" (TARGET IS SELF)"); client.SendPersonalEvent(SimEventType.EFFECT, "on-effect-targeted-self", ToParameter("doneBy", s), ToParameter("objectActedOn", TheSimAvatar), ToParameter("eventPartiallyOccursAt", p), ToParameter("simDuration", duration), ToParameter("effectType", effectType)); // ()/*GetObject*/(sourceID), effectType); } if (source != null) { source.OnEffect(client, effectType, t, p, duration, id); } else { CogbotEvent evt = ACogbotEvent.CreateEvent(client, effectType, SimEventType.Once | SimEventType.EFFECT | SimEventType.REGIONAL, ToParameter("doneBy", s), ToParameter("objectActedOn", t), ToParameter( "eventPartiallyOccursAt", p), ToParameter("simDuration", duration), AsEffectID(id)); if (t is SimObject) { ((SimObject)t).AddCanBeTargetOf(2, evt); } RegisterUUID(id, effectType); //TODO if (UseEventSource(s) || UseEventSource(t)) { SendPipelineEvent(evt); } //SendNewEvent("on-effect", effectType, s, t, p, duration, AsEffectID(id)); } }); }