Exemplo n.º 1
0
        /// <inheritdoc />
        public GameObject Create(LocalPlayerWorldRepresentationCreationContext context)
        {
            GameObject player = GameObject.Instantiate(PrefabProvider.LocalPlayerPrefab, context.SpawnData.AssociatedObject.Position, context.SpawnData.AssociatedObject.Rotation);

            //This makes it so things can go from GameObject (root) to entity guid.
            WorldPlayerMap.Add(player, context.SpawnData.EntityGuid);
            //This allows for the reverse
            EntityGuidToGameObjectMappable.Add(context.SpawnData.EntityGuid, player);

            //TODO: How should we handle rooms?
            //Rooms.DefaultRoom.TryEnter(player);
            return(player);
        }
        /// <inheritdoc />
        public GameObject Create(RemotePlayerWorldRepresentationCreationContext context)
        {
            //TODO: Save to assume non-cheaters have sent the required position data.
            WorldTransform transform = EntityWorldTransformMappable[context.EntityGuid];

            GameObject player = GameObject.Instantiate(PrefabProvider.RemotePlayerPrefab, transform.Position, transform.Rotation);

            //This makes it so things can go from GameObject (root) to entity guid.
            WorldPlayerMap.Add(player, context.EntityGuid);
            //This allows for the reverse
            EntityGuidToGameObjectMappable.Add(context.EntityGuid, player);

            //TODO: Maybe make movementmanager in a factory?
            //TODO: This is kinda a hack to down cast. We don't have another way right now.
            //Remote players also get a default movement manager
            MovementManagerMappable.Add(context.EntityGuid, new MovementManager((IReadonlyEntityGuidMappable <GameObject>)EntityGuidToGameObjectMappable));

            //TODO: How should we handle rooms?
            //Rooms.DefaultRoom.TryEnter(player);
            return(player);
        }