public IEntitySpawnResults TrySpawnEntity(Vector3 position, Quaternion rotation, ISpawnContext context)
        {
            GameObject playerGo = gameobjectFactory.CreateBuilder()
                                  .With(context)
                                  .Create(prefabProvider.GetPrefab(PrefabType.NetworkPlayer), position, rotation) as GameObject;

            return(new DefaultEntitySpawnDetails(playerGo));
        }
        protected override void OnIncomingHandlableMessage(IResponseMessage message, PlayerSpawnResponsePayload payload, IMessageParameters parameters, InstanceClientPeer peer)
        {
            //TODO: Implement spawning
            logger.Info($"Recieved player spawn response. {payload.ResponseCode} {payload.Position} {payload.Rotation}");

            gameobjectFactory.CreateBuilder()
            .With(Service <INetPeer> .As(peer))
            .With(Service <NetworkEntityGuid> .As(payload.EntityGuid))
            .Create(playerPrefab, payload.Position.ToVector3(), payload.Rotation.ToQuaternion());
        }
Пример #3
0
        public IEntitySpawnResults TrySpawnEntity(Vector3 position, Quaternion rotation, Vector3 scale, IGameObjectPrefabSpawnContext context)
        {
            if (Prefabs.FirstOrDefault(x => x.PrefabId == context.PrefabId) == null)
            {
                return(DefaultEntitySpawnDetails.Fail(SpawnResult.PrefabUnavailable));
            }

            GameObject go = gameobjectFactory.CreateBuilder()
                            .With(context)
                            .Create(Prefabs.First(x => x.PrefabId == context.PrefabId)?.PrefabReference, position, rotation);

            go.transform.localScale = scale;

            return(new DefaultEntitySpawnDetails(go));
        }
        protected override void OnIncomingHandlableMessage(IResponseMessage message, ClaimSessionResponsePayload payload, IMessageParameters parameters, InstanceClientPeer peer)
        {
            //TODO: Implement spawning
            if (Logger.IsInfoEnabled)
            {
                Logger.Info($"Recieved player spawn response. {payload.ResponseCode} {payload.Position} {payload.Rotation}");
            }

            GameObject entityGameObject = gameobjectFactory.CreateBuilder()
                                          .With(Service <INetPeer> .As(peer))
                                          .With(Service <NetworkEntityGuid> .As(payload.EntityGuid))
                                          .Create(playerPrefab, payload.Position.ToVector3(), payload.Rotation.ToQuaternion());

            //TODO: Should we do this in the factory?
            //Add to collection
            entityCollection.Add(payload.EntityGuid, new EntityContainer(payload.EntityGuid, entityGameObject));

            OnCreatedEntity(entityGameObject);
        }