Beispiel #1
0
        private void _UpdateSetProperty(long entity_id, int property, byte[] buffer)
        {
            IGhost ghost = _FindGhost(entity_id);

            if (ghost == null)
            {
                return;
            }

            MemberMap    map  = _Protocol.GetMemberMap();
            PropertyInfo info = map.GetProperty(property);

            object    value    = _Serializer.Deserialize(buffer);
            object    instance = ghost.GetInstance();
            Type      type     = _InterfaceProvider.Find(info.DeclaringType);
            FieldInfo field    = type.GetField("_" + info.Name, BindingFlags.Instance | BindingFlags.Public);

            if (field != null)
            {
                object      filedValue = field.GetValue(instance);
                IAccessable updateable = filedValue as IAccessable;
                updateable.Set(value);


                PackageSetPropertyDone pkg = new PackageSetPropertyDone();
                pkg.EntityId = entity_id;
                pkg.Property = property;
                _Requester.Request(ClientToServerOpCode.UpdateProperty, pkg.ToBuffer(_Serializer));
            }
        }
        private IObjectAccessible _GetAccesser(PackagePropertySoul data, IGhost owner)
        {
            MemberMap    map        = _Protocol.GetMemberMap();
            PropertyInfo info       = map.GetProperty(data.PropertyId);
            var          type       = _InterfaceProvider.Find(info.DeclaringType);
            var          fieldName  = _GetFieldName(info);
            FieldInfo    field      = type.GetField(fieldName, BindingFlags.Instance | BindingFlags.Public);
            object       filedValue = field.GetValue(owner.GetInstance());

            return(filedValue as IObjectAccessible);
        }
Beispiel #3
0
        private void _UpdateProperty(Guid entity_id, int property, byte[] buffer)
        {
            var ghost = _FindGhost(entity_id);

            if (ghost != null)
            {
                var map      = _Protocol.GetMemberMap();
                var info     = map.GetProperty(property);
                var value    = _Serializer.Deserialize(buffer);
                var instance = ghost.GetInstance();
                var type     = _GhostProvider.Find(info.DeclaringType);
                var field    = type.GetField("_" + info.Name, BindingFlags.Instance | BindingFlags.Public);
                if (field != null)
                {
                    field.SetValue(instance, value);
                }
            }
        }