Пример #1
0
        protected override void OnPlayerWorldRepresentationCreated(EntityWorldRepresentationCreatedEventArgs args)
        {
            EntityGameObjectDirectory characterController = args.EntityWorldRepresentation.GetComponent <EntityGameObjectDirectory>();

            //TODO: Assert it being there
            GameObjectDirectoryMappable.AddObject(args.EntityGuid, characterController);
        }
Пример #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 void InitializePositions(NetworkMovementTrackerTypeFlags context, Vector3[] positions)
        {
            EntityGameObjectDirectory directory = GameObjectDirectoryMappable.RetrieveEntity(LocalPlayerDetails.LocalPlayerGuid);

            int index = 0;

            index = InitializePositionIndex(context, NetworkMovementTrackerTypeFlags.Head, EntityGameObjectDirectory.Type.CameraRoot, positions, index, directory);
            index = InitializePositionIndex(context, NetworkMovementTrackerTypeFlags.RightHand, EntityGameObjectDirectory.Type.RightHand, positions, index, directory);
            index = InitializePositionIndex(context, NetworkMovementTrackerTypeFlags.LeftHand, EntityGameObjectDirectory.Type.LeftHand, positions, index, directory);
        }
Пример #5
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;
        }
Пример #6
0
        private void InitializeRotations(NetworkMovementTrackerTypeFlags context, Quaternion[] rotations)
        {
            EntityGameObjectDirectory directory = GameObjectDirectoryMappable.RetrieveEntity(LocalPlayerDetails.LocalPlayerGuid);

            int index = 0;

            //TODO: Right now we're only doing heads, so this works but will break later.
            index = InitializeRotationIndex(context, NetworkMovementTrackerTypeFlags.Head, EntityGameObjectDirectory.Type.CameraRoot, rotations, index, directory);
            index = InitializeRotationIndex(context, NetworkMovementTrackerTypeFlags.RightHand, EntityGameObjectDirectory.Type.RightHand, rotations, index, directory);
            index = InitializeRotationIndex(context, NetworkMovementTrackerTypeFlags.LeftHand, EntityGameObjectDirectory.Type.LeftHand, rotations, index, directory);
        }
Пример #7
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
            });
        }
Пример #8
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);
        }
Пример #9
0
 private static Vector3 ComputeRelativePosition(EntityGameObjectDirectory directory, EntityGameObjectDirectory.Type gameObjectType)
 {
     return(directory.GetGameObject(gameObjectType).transform.localPosition);
 }
Пример #10
0
 private static Quaternion ComputeRelativeRotation(EntityGameObjectDirectory directory, EntityGameObjectDirectory.Type gameObjectType)
 {
     return(directory.GetGameObject(gameObjectType).transform.localRotation);
 }
Пример #11
0
        private static int InitializePositionIndex(NetworkMovementTrackerTypeFlags context, NetworkMovementTrackerTypeFlags flagToCheck, EntityGameObjectDirectory.Type gameObjectType, Vector3[] positions, int index, EntityGameObjectDirectory directory)
        {
            if ((context & flagToCheck) != 0)
            {
                positions[index++] = ComputeRelativePosition(directory, gameObjectType);
            }

            return(index);
        }