Ejemplo n.º 1
0
        public void ChangeObject(VpObject vpObject)
        {
            int rc;

            lock (this)
            {
                Functions.vp_int_set(_instance, Attribute.ObjectId, vpObject.Id);
                Functions.vp_string_set(_instance, Attribute.ObjectAction, vpObject.Action);
                Functions.vp_string_set(_instance, Attribute.ObjectDescription, vpObject.Description);
                Functions.vp_string_set(_instance, Attribute.ObjectModel, vpObject.Model);
                Functions.vp_float_set(_instance, Attribute.ObjectRotationX, vpObject.Rotation.X);
                Functions.vp_float_set(_instance, Attribute.ObjectRotationY, vpObject.Rotation.Y);
                Functions.vp_float_set(_instance, Attribute.ObjectRotationZ, vpObject.Rotation.Z);
                Functions.vp_float_set(_instance, Attribute.ObjectX, vpObject.Position.X);
                Functions.vp_float_set(_instance, Attribute.ObjectY, vpObject.Position.Y);
                Functions.vp_float_set(_instance, Attribute.ObjectZ, vpObject.Position.Z);
                Functions.vp_float_set(_instance, Attribute.ObjectRotationAngle, vpObject.Angle);

                rc = Functions.vp_object_change(_instance);
            }
            if (rc != 0)
            {
                throw new VpException((ReasonCode)rc);
            }
        }
Ejemplo n.º 2
0
        private void OnObjectChange(IntPtr sender)
        {
            if (EventObjectChange == null)
            {
                return;
            }
            VpObject vpObject;
            int      sessionId;

            lock (this)
            {
                vpObject = new VpObject()
                {
                    Action      = Functions.vp_string(sender, Attribute.ObjectAction),
                    Description = Functions.vp_string(sender, Attribute.ObjectDescription),
                    Id          = Functions.vp_int(sender, Attribute.ObjectId),
                    Model       = Functions.vp_string(sender, Attribute.ObjectModel),
                    Rotation    = new Vector3(Functions.vp_float(sender, Attribute.ObjectRotationX), Functions.vp_float(sender, Attribute.ObjectRotationY), Functions.vp_float(sender, Attribute.ObjectRotationZ)),
                    Time        =
                        new DateTime(1970, 1, 1, 0, 0, 0, DateTimeKind.Utc).AddSeconds(
                            Functions.vp_int(sender, Attribute.ObjectTime)),
                    ObjectType = Functions.vp_int(sender, Attribute.ObjectType),
                    Owner      = Functions.vp_int(sender, Attribute.ObjectUserId),
                    Position   = new Vector3(Functions.vp_float(sender, Attribute.ObjectX), Functions.vp_float(sender, Attribute.ObjectY), Functions.vp_float(sender, Attribute.ObjectZ)),
                    Angle      = Functions.vp_float(sender, Attribute.ObjectRotationAngle),
                };
                sessionId = Functions.vp_int(sender, Attribute.AvatarSession);
            }
            EventObjectChange(this, sessionId, vpObject);
        }
Ejemplo n.º 3
0
        /// <summary>
        /// Converts an instance of <see cref="VpObject"/> to a new instance of <see cref="ParticleEmitter"/>.
        /// </summary>
        /// <param name="obj">The <see cref="VpObject"/>.</param>
        /// <returns>Returns a new instance of <see cref="ParticleEmitter"/>.</returns>
        public static async Task <ParticleEmitter> FromVpObjectAsync(VpObject obj)
        {
            throw new NotImplementedException("This method is still a work in progress.");

            if (obj.ObjectType != (int)ObjectType.Particle)
            {
                throw new ArgumentException("Object is not a particle emitter.", nameof(obj));
            }

            PropertyInfo[]  members  = typeof(ParticleEmitter).GetProperties();
            ParticleEmitter particle = new ParticleEmitter(obj.Id);
            string          data     = obj.Data.GetString();
            IDictionary <string, string> properties = await PropertiesParser.ParseAsync(data)
                                                      .ConfigureAwait(false);

            foreach (PropertyInfo member in members)
            {
                PropertyAttribute property = member.ToVpProperty();
                if (properties.ContainsKey(property.Name))
                {
                    member.SetValue(particle, properties[property.Name], null);
                }
            }

            return(particle);
        }
Ejemplo n.º 4
0
 void EventQueryCellResult(IInstance sender, VpObject objectData)
 {
     if (Interpreter.Interpret(objectData).SelectMany(trigger => trigger.Commands).OfType <ACName>().Any(command => command.Name == _config.Config.Name))
     {
         _billBoard = objectData;
         SetSign(_config.Config.TextItems[0]);
         _timer = AddTimer(new TimerT <TextRotatorBot>(RotationCallback, this, _config.Config.TextItems[0].Delay, 0));
         _timer.Start();
     }
 }
Ejemplo n.º 5
0
        string Name(VpObject vpObject)
        {
            var interpreted = Interpreter.Interpret(vpObject);

            foreach (ACName command in Interpreter.Interpret(vpObject).SelectMany(trigger => trigger.Commands).OfType <ACName>())
            {
                return((command as ACName).Name);
            }
            return(string.Empty);
        }
Ejemplo n.º 6
0
 /// <summary>
 /// Initializes a new instance of the <see cref="ActionAnimate"/> class.
 /// </summary>
 /// <param name="tag">The tag.</param>
 /// <param name="mask">The mask.</param>
 /// <param name="model">The model.</param>
 /// <param name="animationName">Name of the animation.</param>
 /// <param name="imageCount">The image count.</param>
 /// <param name="frameCount">The frame count.</param>
 /// <param name="frameDelay">The frame delay.</param>
 /// <param name="frameList">The frame list.</param>
 /// <param name="isGLobal">if set to <c>true</c> [is G lobal].</param>
 public ACAnimate(string tag, string mask, VpObject model, string animationName, int imageCount, int frameCount, Int64 frameDelay, List <int> frameList, bool isGLobal)
 {
     _tag           = tag;
     _mask          = mask;
     _model         = model;
     _animationName = animationName;
     _imageCount    = imageCount;
     _frameCount    = frameCount;
     _frameDelay    = frameDelay;
     _frameList     = frameList;
     _isGLobal      = isGLobal;
 }
Ejemplo n.º 7
0
        public static void AddObjectClickHandler(this Instance instance, string objectName, Callback callback)
        {
            instance.OnObjectClick += (sender, args) => {
                VpObject obj    = args.VpObject;
                Action   action = Action.Parse(obj.Action);
                string   name   = action.Create?.GetCommandOfType <NameCommand>()?.Name ?? String.Empty;

                if (name.Equals(objectName))
                {
                    callback(sender, args);
                }
            };
        }
Ejemplo n.º 8
0
        void Instance_EventQueryCellResult(IInstance sender, VpObject objectData)
        {
            var result = Interpreter.Find <ATCreate, ACName>(objectData.Action);

            if (result != null && result.Name.StartsWith("ws-"))
            {
                //_locations.Add(objectData);
                var ws = new GlobalWeatherService.GlobalWeatherSoapClient();
                ws.BeginGetWeather(Interpreter.Find <ATCreate, ACName>(objectData.Action).Name.Replace("ws-", ""), string.Empty, WeatherCacheCallback, new object[] { ws, objectData });
            }
            else if (result != null && result.Name == "display-ws")
            {
                _display = objectData;
            }
        }
Ejemplo n.º 9
0
        public static void AddObjectClickHandler <T>(this Instance instance,
                                                     Action <object, ObjectClickArgsT <Avatar, VpObject>, T> callback)
            where T : Command
        {
            instance.OnObjectClick += (sender, args) => {
                VpObject obj     = args.VpObject;
                Action   action  = Action.Parse(obj.Action);
                T        command = action.Activate?.GetCommandOfType <T>();

                if (!(command is null))
                {
                    callback(sender, args, command);
                }
            };
        }
Ejemplo n.º 10
0
        private void OnObjectCreate(IntPtr sender)
        {
            if (EventObjectCreate == null && EventQueryCellResult == null)
            {
                return;
            }
            VpObject vpObject;
            int      sessionId;

            lock (this)
            {
                sessionId = Functions.vp_int(sender, Attribute.AvatarSession);
                vpObject  = new VpObject()

                {
                    Action      = Functions.vp_string(sender, Attribute.ObjectAction),
                    Description = Functions.vp_string(sender, Attribute.ObjectDescription),
                    Id          = Functions.vp_int(sender, Attribute.ObjectId),
                    Model       = Functions.vp_string(sender, Attribute.ObjectModel),
                    Rotation    = new Vector3(Functions.vp_float(sender, Attribute.ObjectRotationX), Functions.vp_float(sender, Attribute.ObjectRotationY), Functions.vp_float(sender, Attribute.ObjectRotationZ)),
                    Time        =
                        new DateTime(1970, 1, 1, 0, 0, 0).AddSeconds(Functions.vp_int(sender,
                                                                                      Attribute.
                                                                                      ObjectTime)),
                    ObjectType = Functions.vp_int(sender, Attribute.ObjectType),
                    Owner      = Functions.vp_int(sender, Attribute.ObjectUserId),
                    Position   = new Vector3(Functions.vp_float(sender, Attribute.ObjectX), Functions.vp_float(sender, Attribute.ObjectY), Functions.vp_float(sender, Attribute.ObjectZ)),
                    Angle      = Functions.vp_float(sender, Attribute.ObjectRotationAngle)
                };
            }
            if (sessionId == -1 && EventQueryCellResult != null)
            {
                EventQueryCellResult(this, vpObject);
            }
            else
            if (EventObjectCreate != null)
            {
                EventObjectCreate(this, sessionId, vpObject);
            }
        }
Ejemplo n.º 11
0
        /// <summary>
        /// Converts an instance of <see cref="VpObject"/> to a new instance of <see cref="ParticleEmitter"/>.
        /// </summary>
        /// <param name="vpObj">The <see cref="VpObject"/>.</param>
        /// <returns>Returns a new instance of <see cref="ParticleEmitter"/>.</returns>
        public static async Task <Object3D> FromVpObjectAsync(VpObject vpObj)
        {
            if (vpObj.ObjectType != (int)ObjectType.Object3D)
            {
                throw new ArgumentException("Object is not a 3D object.", nameof(vpObj));
            }

            Object3D obj = new Object3D(vpObj.Id)
            {
                Owner       = vpObj.Owner,
                Time        = vpObj.Time,
                Position    = vpObj.Position,
                Rotation    = vpObj.Rotation,
                Angle       = vpObj.Angle,
                Data        = vpObj.Data,
                Model       = vpObj.Model,
                Description = vpObj.Description,
                Action      = await Action.ParseAsync(vpObj.Action)
                              .ConfigureAwait(false)
            };

            ((IObject3D)obj).Action = vpObj.Action;
            return(obj);
        }
Ejemplo n.º 12
0
 public List <ICommandGroup> Interpret(VpObject vpObject)
 {
     return(Interpret(vpObject.Action));
 }
Ejemplo n.º 13
0
 void EventObjectChange(IInstance sender, int sessionId, VpObject objectData)
 {
     Console.WriteLine("Changed Object {0}", objectData.Id);
 }
Ejemplo n.º 14
0
 void EventQueryCellResult(IInstance sender, VpObject objectData)
 {
     Console.WriteLine("{0} {1} {2} name: {3}", objectData.Id, objectData.Model, objectData.Owner, Name(objectData));
 }
Ejemplo n.º 15
0
 public void AddObject(VpObject <VpNet.Vector3> vpObject)
 {
     Instance.AddObject(vpObject);
 }
Ejemplo n.º 16
0
 public void QueryCellResultCallback(Instance sender, VpObject objectData)
 {
     throw new NotImplementedException();
 }
Ejemplo n.º 17
0
 public void ObjectCreateCallback(Instance sender, int sessionId, VpObject objectData)
 {
     throw new NotImplementedException();
 }