Exemplo n.º 1
0
        private CogbotEvent MsgToCogEvent(object sender, IMessage msg)
        {
            var evt = ACogbotEvent.CreateEvent(sender, SimEventType.Once, msg.Type,
                                               SimEventType.UNKNOWN | SimEventType.PERSONAL | SimEventType.DATA_UPDATE);
            List <NamedParam> from = ScriptManager.GetMemberValues("", msg);

            foreach (var f in from)
            {
                if (f.Type != typeof(byte[]))
                {
                    evt.AddParam(f.Key, f.Value);
                }
            }
            if (msg is IBytesMessage)
            {
                IBytesMessage ibm    = (IBytesMessage)msg;
                var           actual = RK_publisher.DecodeMessage(ibm);
                foreach (var f in ScriptManager.GetMemberValues("", actual))
                {
                    if (f.Type != typeof(byte[]))
                    {
                        evt.AddParam(f.Key, f.Value);
                    }
                }
            }
            DLRConsole.DebugWriteLine("msg=" + evt);
            return(evt);
        }
Exemplo n.º 2
0
 public override void Self_OnMeanCollision(object sender, MeanCollisionEventArgs e)
 {
     if (!MaintainEffects)
     {
         return;
     }
     EventQueue.Enqueue(() =>
     {
         SimObject perpAv, victimAv;
         if (TryGetSimObject(e.Aggressor, out perpAv) &&
             TryGetSimObject(e.Victim, out victimAv))
         {
             // if (victimAv.Name == client.Self.Name)
             //   WriteLine(perpAv.Name + " bumped into $bot like " + type);
             // else if (perpAv.Name == client.Self.Name)
             //   WriteLine("$bot bumped into " + victimAv.Name + " like " + type);
             CogbotEvent newSimObjectEvent = ACogbotEvent.CreateEvent(sender,
                                                                      "MeanCollisionType-" + e.Type, SimEventType.Once | SimEventType.SOCIAL | SimEventType.REGIONAL,
                                                                      ToParameter("primaryObjectMoving", perpAv),
                                                                      ToParameter("objectActedOn", victimAv),
                                                                      ToParameter("initialSpeedOfPrimaryObjectMoving", "MetersPerSecond", e.Magnitude));
             perpAv.LogEvent(newSimObjectEvent);
         }
     });
 }
Exemplo n.º 3
0
 private void LogSitEvent(SimObject user, SimEventType updown, string p, params NamedParam[] args)
 {
     if (!MaintainActions)
     {
         return;
     }
     if (user != null)
     {
         user.Parent = null;
         user.LogEvent(SendPipelineEvent(ACogbotEvent.CreateEvent(client, p, updown | SimEventType.SIT | SimEventType.REGIONAL, args)));
     }
     //DLRConsole.WriteLine(user + " " + p + " " + ScriptEngines.ScriptEventListener.argsListString(args));
 }
Exemplo n.º 4
0
 public CogbotEvent CreateAEvent(SimEventType status, string eventName, SimEventType type, params NamedParam[] pzs)
 {
     return(ACogbotEvent.CreateEvent(this, status | type, eventName, pzs));
 }
Exemplo n.º 5
0
        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));
                }
            });
        }
Exemplo n.º 6
0
        /*
         * TODO
         *   On-Avatar-Sit-Changed
         *  simulator: "OpenSim Test"
         *  avatar: '(avatar "Nephrael Rae")
         *  sittingOn: 3135593693
         *  oldSeat: 0
         */
        public override void Objects_OnAvatarSitChanged(object sender, AvatarSitChangedEventArgs e)
        {
            var simulator = e.Simulator;

            if (!IsMaster(simulator))
            {
                return;
            }
            var avatar    = e.Avatar;
            var sittingOn = e.SittingOn;
            var oldSeat   = e.OldSeat;

            if (avatar != null)
            {
                DeclareAvatar(avatar.ID);
            }
            if (!MaintainActions)
            {
                return;
            }
            EventQueue.Enqueue("Objects_OnAvatarSitChanged", () =>
            {
                SimObject user    = GetSimObject(avatar, simulator);
                SimObject newSit  = GetSimObject(sittingOn, simulator);
                SimObject oldSit  = GetSimObject(oldSeat, simulator);
                string newSitName = null;
                string oldSitName = null;
                if (newSit != null)
                {
                    newSitName = newSit.SitName;
                }
                if (newSitName == null)
                {
                    newSitName = "SitOnObject";
                }
                if (oldSit != null)
                {
                    oldSitName = oldSit.SitName;
                }
                if (oldSitName == null)
                {
                    oldSitName = "SitOnObject";
                }

                //if (SendAllEvents)
                // SendNewEvent("On-Avatar-Sit-Changed", user, newSit, oldSit);
                if (user != null)
                {
                    if (oldSeat != 0)
                    {
                        LogSitEvent(user, SimEventType.Stop, oldSitName,
                                    ToParameter("doneBy", user),
                                    ToParameter("objectActedOn", oldSit));
                    }
                    if (sittingOn != 0)
                    {
                        LogSitEvent(user, SimEventType.Start, newSitName,
                                    ToParameter("doneBy", user),
                                    ToParameter("objectActedOn", newSit));
                    }
                    if (sittingOn + oldSeat == 0)
                    {
                        LogSitEvent(user, SimEventType.Once, "SitChangedUnknown", ToParameter("doneBy", user));
                    }
                }
                else
                {
                    //object[] eventArgs = new object[] { user, newSit, oldSit };
                    if (oldSit != null)
                    {
                        oldSit.AddCanBeTargetOf(1, SendPipelineEvent(
                                                    ACogbotEvent.CreateEvent(sender, SimEventType.Stop, newSitName,
                                                                             SimEventType.SIT | SimEventType.REGIONAL,
                                                                             ToParameter("doneBy", avatar),
                                                                             ToParameter("objectActedOn", oldSit))));
                    }
                    if (newSit != null)
                    {
                        newSit.AddCanBeTargetOf(1, SendPipelineEvent(
                                                    ACogbotEvent.CreateEvent(sender, SimEventType.Start, newSitName,
                                                                             SimEventType.SIT | SimEventType.REGIONAL,
                                                                             ToParameter("doneBy", avatar),
                                                                             ToParameter("objectActedOn", newSit))));
                    }
                }
            });
        }