示例#1
0
        /// <summary>
        /// Set member values by decoding out of propertyData. Should only
        /// be called in initialization time (e.g. from constructor).
        /// </summary>
        /// <param name="propertyData"></param>
        private void FromOSDArray(OSDArray propertyData)
        {
            Property            = (SyncableProperties.Type)(propertyData[0].AsInteger());
            LastUpdateTimeStamp = propertyData[1].AsLong();
            LastUpdateSyncID    = propertyData[2].AsString();

            OSD value = propertyData[3];

            switch (Property)
            {
            ///////////////////////////////////////
            // Complex structure properties
            ///////////////////////////////////////
            case SyncableProperties.Type.AgentCircuitData:
            case SyncableProperties.Type.AvatarAppearance:
                LastUpdateValue = (OSDMap)value;
                break;

            case SyncableProperties.Type.Animations:
                LastUpdateValue = (OSDArray)value;
                break;

            ////////////////////////////
            // Integer/enum type properties
            ////////////////////////////
            case SyncableProperties.Type.CreationDate:              // int
            case SyncableProperties.Type.LinkNum:                   // int
            case SyncableProperties.Type.OwnershipCost:             // int
            case SyncableProperties.Type.SalePrice:                 // int
            case SyncableProperties.Type.ScriptAccessPin:           // int
            case SyncableProperties.Type.AggregateScriptEvents:     // enum
            case SyncableProperties.Type.Flags:                     // enum
            case SyncableProperties.Type.LocalFlags:                // enum
            case SyncableProperties.Type.PresenceType:              // enum
                LastUpdateValue = value.AsInteger();
                break;

            case SyncableProperties.Type.ClickAction:
            case SyncableProperties.Type.Material:
            case SyncableProperties.Type.ObjectSaleType:
                LastUpdateValue = (byte)value.AsInteger();
                break;

            ////////////////////////////
            // Boolean type properties
            ////////////////////////////
            case SyncableProperties.Type.AllowedDrop:
            case SyncableProperties.Type.IsAttachment:
            case SyncableProperties.Type.PassTouches:
            case SyncableProperties.Type.VolumeDetectActive:
            case SyncableProperties.Type.Flying:
            case SyncableProperties.Type.IsColliding:
            case SyncableProperties.Type.CollidingGround:
            case SyncableProperties.Type.Kinematic:
            case SyncableProperties.Type.IsSelected:
            case SyncableProperties.Type.AllowMovement:
                LastUpdateValue = value.AsBoolean();
                break;

            ////////////////////////////
            // Vector3 type properties
            ////////////////////////////
            case SyncableProperties.Type.AngularVelocity:
            case SyncableProperties.Type.AttachedPos:
            case SyncableProperties.Type.GroupPosition:
            case SyncableProperties.Type.OffsetPosition:
            case SyncableProperties.Type.Scale:
            case SyncableProperties.Type.SitTargetPosition:
            case SyncableProperties.Type.SitTargetPositionLL:
            case SyncableProperties.Type.SOP_Acceleration:
            case SyncableProperties.Type.Velocity:
            case SyncableProperties.Type.Force:
            case SyncableProperties.Type.PA_Acceleration:
            case SyncableProperties.Type.PA_Velocity:
            case SyncableProperties.Type.PA_TargetVelocity:
            case SyncableProperties.Type.Position:
            case SyncableProperties.Type.RotationalVelocity:
            case SyncableProperties.Type.Size:
            case SyncableProperties.Type.Torque:
            case SyncableProperties.Type.AbsolutePosition:
                LastUpdateValue = value.AsVector3();
                break;

            ////////////////////////////
            // UUID type properties
            ////////////////////////////
            case SyncableProperties.Type.AttachedAvatar:
            case SyncableProperties.Type.CollisionSound:
            case SyncableProperties.Type.CreatorID:
            case SyncableProperties.Type.FolderID:
            case SyncableProperties.Type.GroupID:
            case SyncableProperties.Type.LastOwnerID:
            case SyncableProperties.Type.OwnerID:
            case SyncableProperties.Type.Sound:
                LastUpdateValue = value.AsUUID();
                break;

            ////////////////////////////
            // UInt type properties
            ////////////////////////////
            case SyncableProperties.Type.LocalId:
            case SyncableProperties.Type.AttachmentPoint:
            case SyncableProperties.Type.BaseMask:
            case SyncableProperties.Type.Category:
            case SyncableProperties.Type.EveryoneMask:
            case SyncableProperties.Type.GroupMask:
            case SyncableProperties.Type.InventorySerial:
            case SyncableProperties.Type.NextOwnerMask:
            case SyncableProperties.Type.OwnerMask:
            case SyncableProperties.Type.AgentControlFlags:
            case SyncableProperties.Type.ParentId:
                LastUpdateValue = value.AsUInteger();
                break;

            ////////////////////////////
            // Float type properties
            ////////////////////////////
            case SyncableProperties.Type.CollisionSoundVolume:
            case SyncableProperties.Type.Buoyancy:
                LastUpdateValue = (float)value.AsReal();
                break;

            ////////////////////////////
            // String type properties
            ////////////////////////////
            case SyncableProperties.Type.Color:
            case SyncableProperties.Type.CreatorData:
            case SyncableProperties.Type.Description:
            case SyncableProperties.Type.MediaUrl:
            case SyncableProperties.Type.Name:
            case SyncableProperties.Type.RealRegion:
            case SyncableProperties.Type.Shape:
            case SyncableProperties.Type.SitName:
            case SyncableProperties.Type.TaskInventory:
            case SyncableProperties.Type.Text:
            case SyncableProperties.Type.TouchName:
                LastUpdateValue = value.AsString();
                break;

            ////////////////////////////
            // byte[] (binary data) type properties
            ////////////////////////////
            case SyncableProperties.Type.ParticleSystem:
            case SyncableProperties.Type.TextureAnimation:
                LastUpdateValue = value.AsBinary();
                break;

            ////////////////////////////
            // Quaternion type properties
            ////////////////////////////
            case SyncableProperties.Type.RotationOffset:
            case SyncableProperties.Type.SitTargetOrientation:
            case SyncableProperties.Type.SitTargetOrientationLL:
            case SyncableProperties.Type.Orientation:
            case SyncableProperties.Type.Rotation:
                LastUpdateValue = value.AsQuaternion();
                break;

            default:
                DebugLog.WarnFormat("[SYNCED PROPERTY] FromOSDArray: No handler for property {0} ", Property);
                break;
            }
        }