コード例 #1
0
        public CameraInputData Create(EmptyFactoryContext context)
        {
            EntityGameObjectDirectory directory = CameraObjectMappable.RetrieveEntity(Details.LocalPlayerGuid);

            return(new CameraInputData()
            {
                RootRotationalObject = directory.GetGameObject(EntityGameObjectDirectory.Type.Root),
                CameraGameObject = directory.GetGameObject(EntityGameObjectDirectory.Type.CameraRoot),
                CurrentRotation = directory.GetGameObject(EntityGameObjectDirectory.Type.Root).transform.eulerAngles
            });
        }
コード例 #2
0
        protected override void OnEntityCreationFinished(EntityCreationFinishedEventArgs args)
        {
            //If they have a floating name root we should try to set the name.
            EntityGameObjectDirectory directory = ObjectDirectoryMappable.RetrieveEntity(args.EntityGuid);
            GameObject nameRoot = directory.GetGameObject(EntityGameObjectDirectory.Type.NameRoot);

            IUIText text = nameRoot.GetComponent <IUIText>();

            if (text == null)
            {
                return;
            }

            if (NameQueryable.Exists(args.EntityGuid))
            {
                text.Text = NameQueryable.Retrieve(args.EntityGuid);
            }
            else
            {
                UnityAsyncHelper.UnityMainThreadContext.PostAsync(async() =>
                {
                    string name = await NameQueryable.RetrieveAsync(args.EntityGuid);

                    //Maybe it got deleted before query was done.
                    if (nameRoot == null)
                    {
                        return;
                    }

                    text.Text = NameQueryable.Retrieve(args.EntityGuid);
                });
            }
        }
コード例 #3
0
        private static int InitializeRotationIndex(NetworkMovementTrackerTypeFlags context, NetworkMovementTrackerTypeFlags flagToCheck, 
            EntityGameObjectDirectory.Type gameObjectType, Quaternion[] rotations, int index,
            EntityGameObjectDirectory directory)
        {
            if((context & flagToCheck) != 0)
                directory.GetGameObject(gameObjectType).transform.localRotation = rotations[index++];

            return index;
        }
コード例 #4
0
        private static int InitializePositionIndex(NetworkMovementTrackerTypeFlags context, NetworkMovementTrackerTypeFlags flagToCheck, 
            EntityGameObjectDirectory.Type gameObjectType, Vector3[] positions, int index,
            EntityGameObjectDirectory directory)
        {
            //cameraTransform.position = (rootTransform.position + args.ChangeInformation.Data.TrackerPositionUpdates[0]);
            if((context & flagToCheck) != 0)
                directory.GetGameObject(gameObjectType).transform.localPosition = positions[index++];

            return index;
        }
コード例 #5
0
        protected override void HandleEvent(PlayerTrackerTransformChangedEventArgs args)
        {
            //TODO: Log this
            if (!KnownEntities.isEntityKnown(args.ChangeInformation.EntityGuid))
                return;

            EntityGameObjectDirectory directory = GameObjectDirectoryMappable.RetrieveEntity(args.ChangeInformation.EntityGuid);

            //TODO: We need to support more than just the head.
            Transform rootTransform = directory.GetGameObject(EntityGameObjectDirectory.Type.Root).transform;

            int index = 0;
            index = InitializeRotationIndex(args.ChangeInformation.Data.UpdateFields, NetworkMovementTrackerTypeFlags.Head, EntityGameObjectDirectory.Type.CameraRoot, args.ChangeInformation.Data.TrackerRotationUpdates, index, directory);
            index = InitializeRotationIndex(args.ChangeInformation.Data.UpdateFields, NetworkMovementTrackerTypeFlags.RightHand, EntityGameObjectDirectory.Type.RightHand, args.ChangeInformation.Data.TrackerRotationUpdates, index, directory);
            index = InitializeRotationIndex(args.ChangeInformation.Data.UpdateFields, NetworkMovementTrackerTypeFlags.LeftHand, EntityGameObjectDirectory.Type.LeftHand, args.ChangeInformation.Data.TrackerRotationUpdates, index, directory);

            index = 0;
            index = InitializePositionIndex(args.ChangeInformation.Data.UpdateFields, NetworkMovementTrackerTypeFlags.Head, EntityGameObjectDirectory.Type.CameraRoot, args.ChangeInformation.Data.TrackerPositionUpdates, index, directory);
            index = InitializePositionIndex(args.ChangeInformation.Data.UpdateFields, NetworkMovementTrackerTypeFlags.RightHand, EntityGameObjectDirectory.Type.RightHand, args.ChangeInformation.Data.TrackerPositionUpdates, index, directory);
            index = InitializePositionIndex(args.ChangeInformation.Data.UpdateFields, NetworkMovementTrackerTypeFlags.LeftHand, EntityGameObjectDirectory.Type.LeftHand, args.ChangeInformation.Data.TrackerPositionUpdates, index, directory);
        }
コード例 #6
0
 private static Vector3 ComputeRelativePosition(EntityGameObjectDirectory directory, EntityGameObjectDirectory.Type gameObjectType)
 {
     return(directory.GetGameObject(gameObjectType).transform.localPosition);
 }
コード例 #7
0
 private static Quaternion ComputeRelativeRotation(EntityGameObjectDirectory directory, EntityGameObjectDirectory.Type gameObjectType)
 {
     return(directory.GetGameObject(gameObjectType).transform.localRotation);
 }