Esempio n. 1
0
 //TODO: unix epoch constant
 void onObjChange(Instance sender, int sessionId, VPObject o)
 {
     buildStream.WriteLine("{0},{1},{2},{3}",
         Math.Round(o.Position.X, 3),
         Math.Round(o.Position.Y, 2),
         Math.Round(o.Position.Z, 3),
         (int)DateTime.Now.Subtract(new DateTime(1970, 1, 1, 0, 0, 0, 0)).TotalSeconds);
 }
Esempio n. 2
0
 void objectEvent(VPObject o, sqlBuildType type)
 {
     lock (VPServices.App.DataMutex)
         connection.Insert( new sqlBuildHistory
         {
             ID   = o.Id,
             X    = o.Position.X,
             Y    = o.Position.Y,
             Z    = o.Position.Z,
             Type = type,
             When = TDateTime.UnixTimestamp
         });
 }
Esempio n. 3
0
        internal void OnObjectChange(IntPtr sender)
        {
            if (ObjectChange == null)
            {
                return;
            }
            VPObject vpObject;
            int      sessionId;

            lock (instance.Mutex)
            {
                vpObject  = new VPObject(instance.Pointer);
                sessionId = Functions.vp_int(sender, IntAttributes.AvatarSession);
            }

            ObjectChange(instance, sessionId, vpObject);
        }
Esempio n. 4
0
        /// <summary>
        /// Changes an object in-world using a <see cref="VPObject"/> with newer state
        /// and the target unique ID. Asynchronous and thread-safe.
        /// </summary>
        public void ChangeObject(VPObject obj)
        {
            lock (instance.Mutex)
            {
                var referenceNumber = nextReference;
                objReferences.Add(referenceNumber, obj);

                obj.ToNative(instance.Pointer);
                Functions.vp_int_set(instance.Pointer, IntAttributes.ReferenceNumber, referenceNumber);

                try { Functions.Call(() => Functions.vp_object_change(instance.Pointer)); }
                catch
                {
                    objReferences.Remove(referenceNumber);
                    throw;
                }
            }
        }
Esempio n. 5
0
        /// <summary>
        /// Note: The native VP SDK uses the ObjectCreate event for query cell results
        /// </summary>
        internal void OnObjectCreate(IntPtr sender)
        {
            if (ObjectCreate == null && QueryCellResult == null)
            {
                return;
            }
            VPObject vpObject;
            int      sessionId;

            lock (instance.Mutex)
            {
                sessionId = Functions.vp_int(sender, IntAttributes.AvatarSession);
                vpObject  = new VPObject(instance.Pointer);
            }

            if (sessionId == -1 && QueryCellResult != null)
            {
                QueryCellResult(instance, vpObject);
            }
            else if (ObjectCreate != null)
            {
                ObjectCreate(instance, sessionId, vpObject);
            }
        }
Esempio n. 6
0
        /// <summary>
        /// Note: The native VP SDK uses the ObjectCreate event for query cell results
        /// </summary>
        internal void OnObjectCreate(IntPtr sender)
        {
            if (ObjectCreate == null && QueryCellResult == null) return;
            VPObject vpObject;
            int sessionId;

            lock (instance)
            {
                sessionId = Functions.vp_int(sender, IntAttributes.AvatarSession);
                vpObject = new VPObject(instance.pointer);
            }

            if (sessionId == -1 && QueryCellResult != null)
                QueryCellResult(instance, vpObject);
            else if (ObjectCreate != null)
                ObjectCreate(instance, sessionId, vpObject);
        }
Esempio n. 7
0
        internal void OnObjectChange(IntPtr sender)
        {
            if (ObjectChange == null) return;
            VPObject vpObject;
            int sessionId;

            lock (instance)
            {
                vpObject = new VPObject(instance.pointer);
                sessionId = Functions.vp_int(sender, IntAttributes.AvatarSession);
            }

            ObjectChange(instance, sessionId, vpObject);
        }
Esempio n. 8
0
 /// <summary>
 /// Deletes a given object
 /// </summary>
 /// <param name="vpObject">Object to delete</param>
 public void DeleteObject(VPObject vpObject)
 {
     int rc;
     var referenceNumber = nextReference;
     lock (instance)
     {
         _objectReferences.Add(referenceNumber, vpObject);
         vpObject.ToNative(instance.pointer);
         Functions.vp_int_set(instance.pointer, IntAttributes.ReferenceNumber, referenceNumber);
         rc = Functions.vp_object_delete(instance.pointer);
     }
     if (rc != 0)
     {
         _objectReferences.Remove(referenceNumber);
         throw new VPException((ReasonCode)rc);
     }
 }
Esempio n. 9
0
        /// <summary>
        /// Sends a click event on a given object
        /// </summary>
        /// <param name="vpObject">Object to click</param>
        public void ClickObject(VPObject vpObject)
        {
            int rc;
            lock (instance)
            {
                vpObject.ToNative(instance.pointer);
                rc = Functions.vp_object_click(instance.pointer);
            }

            if (rc != 0) throw new VPException((ReasonCode)rc);
        }
Esempio n. 10
0
 public ObjectCallbackData(ReasonCode rc, VPObject vpObject)
 {
     Object = vpObject;
     Reason = rc;
 }
Esempio n. 11
0
        void createHoverText(AvatarPosition pos, int damage, bool critical)
        {
            var offsetX     = ( (float) VPServices.Rand.Next(-100, 100) ) / 2000;
            var offsetZ     = ( (float) VPServices.Rand.Next(-100, 100) ) / 2000;
            var description = string.Format("{0}{1}", 0 - damage, critical ? " !!!" : "");
            var color       = damage == 0 ? "blue" : "red";
            var hover       = new VPObject
            {
                Model = "p:fac100x50,s.rwx",
                Rotation = Quaternion.ZeroEuler,
                Action = string.Format("create sign color={0} bcolor=ffff0000 hmargin=20, ambient 1, move 0 2 time=5 wait=10, solid no", color),
                Description = description,
                Position = new Vector3(pos.X + offsetX, pos.Y + .2f, pos.Z + offsetZ)
            };

            app.Bot.Property.AddObject(hover);
            spawned.Add(hover);
        }
Esempio n. 12
0
        void createBloodSplat(AvatarPosition pos)
        {
            var offsetX     = ( (float) VPServices.Rand.Next(-100, 100) ) / 2000;
            var offsetY     = ( (float) VPServices.Rand.Next(0, 100) ) / 5000;
            var offsetZ     = ( (float) VPServices.Rand.Next(-100, 100) ) / 2000;
            var size        = VPServices.Rand.Next(80, 200);

            var hover       = new VPObject
            {
                Model = "p:flat" + size + ".rwx",
                Rotation = Quaternion.ZeroEuler,
                Action = "create texture bloodsplat1.png, normalmap nmap-puddle1, specularmap smap-puddle1, specular .6 30, solid no",
                Position = new Vector3(pos.X + offsetX, pos.Y + offsetY, pos.Z + offsetZ)
            };

            app.Bot.Property.AddObject(hover);
            spawned.Add(hover);
        }
Esempio n. 13
0
 /// <summary>
 /// Sends an end collision (bump) event on a given in-world object. Thread-safe.
 /// </summary>
 /// <param name="obj">Object to stop colliding with</param>
 public void EndBump(VPObject obj)
 {
     lock (instance.Mutex)
         Functions.Call(() => Functions.vp_object_bump_end(instance.Pointer, obj.Id, 0));
 }
Esempio n. 14
0
 /// <summary>
 /// Sends a click event on a given in-world object. Thread-safe.
 /// </summary>
 /// <param name="obj">Object to click</param>
 /// <param name="eventTarget">Optional session to limit event to</param>
 public void ClickObject(VPObject obj, int eventTarget = 0)
 {
     ClickObject(obj.Id, eventTarget);
 }
Esempio n. 15
0
 /// <summary>
 /// Sends a click event on a given in-world object on the specified coordinates
 /// using a <see cref="Vector3D"/>. Thread-safe.
 /// </summary>
 /// <param name="obj">Object to click</param>
 /// <param name="coordinates">3D coordinates of the click</param>
 /// <param name="eventTarget">Optional session to limit event to</param>
 public void ClickObject(VPObject obj, Vector3 coordinates, int eventTarget = 0)
 {
     ClickObject(obj.Id, coordinates, eventTarget);
 }
Esempio n. 16
0
 /// <summary>
 /// Attempts to delete an object in-world using the unique ID of a given
 /// <see cref="VPObject"/>.  Asynchronous and thread-safe.
 /// </summary>
 public void DeleteObject(VPObject obj)
 {
     DeleteObject(obj.Id);
 }