Exemple #1
0
    private void OnEnable()
    {
        _controller = GetComponent <CharacterController>();
        _collider   = GetComponent <Collider>();

        ServerSimulation.StartTrackingCollider(_collider);
    }
Exemple #2
0
    private void OnEnable()
    {
        _navmeshAgent = GetComponent <NavMeshAgent>();
        _collider     = GetComponent <Collider>();

        ServerSimulation.RegisterObject(this);
        ServerSimulation.StartTrackingCollider(_collider);
    }
Exemple #3
0
 protected override void TearDownGameScene()
 {
     base.TearDownGameScene();
     if (simulation != null)
     {
         simulation = null;
     }
     if (hotelGameServer != null)
     {
         hotelGameServer.Destroy();
         hotelGameServer = null;
     }
 }
Exemple #4
0
        public GameWorld(
            WorldType worldType,
            WorldInstanceId id,
            ILogger logger,
            IServerConfig config,
            OutgoingServerChannel channelManager,
            IGameWorldLoader gameWorldLoader)
        {
            this.WorldType  = worldType;
            this.InstanceId = id;
            this._logger    = logger ?? throw new ArgumentNullException(nameof(logger));
            this._isStopped = false;
            this._world     = new World(config.Ecs);

            this._fixedTick = config.Simulation.FixedTick;

            this._channelManager = channelManager ?? throw new ArgumentNullException(nameof(channelManager));

            this._simulationSynchronizer = new SimulationSynchronizer(this._world);
            this._entityGridMap          = new EntityGridMap(config.Replication.GridSize);

            this._players = new WorldPlayers(
                config.Replication,
                config.PlayerInput,
                config.PlayerConnection.Capacity.InitialConnectionsCapacity);

            this._replicationManager = new WorldReplicationManager(config.Replication, this._players, this._entityGridMap);

            this._physicsWorld = new VolatilePhysicsWorld(config.Replication.PhysicsHistoryCount);

            this._systems =
                new Systems(this._world)
                .Add(new PhysicsSystem())
                .Add(new ServerEntityReplicationSystem())
                .Add(new JiggleSystem())
                .Inject(this._physicsWorld)
                .Inject(new ReplicationDataBroker(config.Replication.Capacity, this._replicationManager))
                .Inject(this._entityGridMap);

            this._simulation = new ServerSimulation <InputComponent>(
                config.Simulation,
                this._world,
                this._systems);

            this._simulation.Create();

            gameWorldLoader.LoadWorld(this.WorldType, this._world, this._physicsWorld);
        }
Exemple #5
0
    public async Task StartServer(string host, int port, bool loadScene)
    {
        netChannel.StartServer(port);
        // TODO: Determine why this extra wait is needed on the startup case.
        // It doesnt seem to cause an error when omitted, but the POST below never happens.
        await Hotel.HotelClient.Instance.WaitUntilInitialized();

        hotelGameServer = await Hotel.HotelClient.Instance.StartHostingServer(
            host, port, 8, "Test");

        Debug.Log($"Registered game with master server.");
        if (loadScene)
        {
            LoadGameScene();
        }

        // Initialize simulation.
        simulation = new ServerSimulation(
            debugPhysicsErrorChance, playerManager, networkObjectManager, this);
    }
Exemple #6
0
    void Shoot(PlayerInputState input)
    {
        Vector3 origin    = cameraPosition.position;
        Vector3 direction = cameraPosition.forward;

        if (isServer && input.serverFrame != ServerSimulation.frameNumber)
        {
            ServerSimulation.Rewind(input.networkTime - _currentLatency);
        }

        RaycastHit hit;

        if (Physics.Raycast(origin, direction, out hit, 1000))
        {
            var instance = Instantiate(hitPrefab, hit.collider.transform, false);
            instance.transform.position = hit.point;
            instance.transform.forward  = hit.normal;
        }

        Debug.DrawRay(origin, direction * 1000);
        Debug.Break();
    }
Exemple #7
0
 private void OnDisable()
 {
     ServerSimulation.StopTrackingCollider(_collider);
 }
Exemple #8
0
 private void OnDestroy()
 {
     ServerSimulation.UnregisterObject(this);
 }
Exemple #9
0
 public override void OnStartServer()
 {
     ServerSimulation.RegisterObject(this);
 }
Exemple #10
0
 private void OnDisable()
 {
     ServerSimulation.UnregisterObject(this);
     ServerSimulation.StopTrackingCollider(_collider);
 }
Exemple #11
0
 private void Awake()
 {
     _instance = this;
     DontDestroyOnLoad(gameObject);
 }