Beispiel #1
0
        protected override void OnCreate()
        {
            var cs = new NativeArray <ComponentType>(5, Allocator.Temp)
            {
                [0] = ComponentType.ReadOnly <Translation>(),
                [1] = ComponentType.ReadOnly <Rotation>(),
                [2] = ComponentType.ReadOnly <PhysicsVelocity>(),
                [3] = ComponentType.ReadOnly <PlayerMachineTag>(),
                [4] = ComponentType.ReadOnly <TeamTag>(),
            };

            GetEntityQuery(cs);
            cs.Dispose();
            FindComponentOfInterfaceOrClassHelper.FindComponentOfInterfaceOrClass(out _playerGenerator);
            _findPlayerEntityHelper = World.Active.GetOrCreateSystem <FindPlayerEntityHelper>();
            RequireSingletonForUpdate <UserIdSingleton>();
        }
Beispiel #2
0
    void OnEnable()
    {
        var manager = World.Active.EntityManager;

        var moveCommandComponentTypes = ArrayPool.Get <ComponentType>(3);

        moveCommandComponentTypes[0] = ComponentType.ReadWrite <MoveCommand>();
        moveCommandComponentTypes[1] = ComponentType.ReadWrite <DestroyableComponentData>();
        moveCommandComponentTypes[2] = ComponentType.ReadWrite <DateTimeTicksToProcess>();

        _moveCommandComponentTypes = manager.CreateArchetype(moveCommandComponentTypes);

        var synchronizePositionComponentTypes = ArrayPool.Get <ComponentType>(6);

        synchronizePositionComponentTypes[0] = ComponentType.ReadWrite <SyncInfoTag>();
        synchronizePositionComponentTypes[1] = ComponentType.ReadWrite <TeamTag>();
        synchronizePositionComponentTypes[2] = ComponentType.ReadWrite <Translation>();
        synchronizePositionComponentTypes[3] = ComponentType.ReadWrite <Rotation>();
        synchronizePositionComponentTypes[4] = ComponentType.ReadWrite <PhysicsVelocity>();
        synchronizePositionComponentTypes[5] = ComponentType.ReadWrite <DestroyableComponentData>();

        _synchronizePositionComponentTypes = manager.CreateArchetype(synchronizePositionComponentTypes);

        if (!FindComponentOfInterfaceOrClassHelper.FindComponentOfInterfaceOrClass(out _prefabStorage))
        {
            throw new KeyNotFoundException();
        }
        if (!FindSystemOfInterfaceHelper.FindSystemOfInterface(out _initialDeserializer))
        {
            throw new KeyNotFoundException();
        }
        _prefabStorage.FindPrefab <PlayerMachineTag>(manager, out _playerPrefabEntity);
        if (IsMine)
        {
            var idEntity        = manager.CreateEntity(ComponentType.ReadWrite <UserIdSingleton>());
            var userIdSingleton = new UserIdSingleton(OwnerActorNr);
            manager.SetComponentData(idEntity, userIdSingleton);
            RPC(nameof(SpawnPlayerMachine), RpcTarget.Others);
        }
        _prefabStorage.FindPrefab <Point, DateTimeTicksToProcess>(manager, out _nextPointPrefabEntity);
    }
Beispiel #3
0
 protected override void OnStartRunning()
 {
     if (_playerGenerator == null && !FindComponentOfInterfaceOrClassHelper.FindComponentOfInterfaceOrClass(out _playerGenerator))
     {
         return;
     }
     if (_playerEntity == Entity.Null)
     {
         _playerEntity = _playerGenerator.PlayerInstantiate(View.OwnerActorNr);
         return;
     }
     if (EntityManager.Exists(_playerEntity) || View == null)
     {
         return;
     }
     _playerEntity = _findPlayerEntityHelper.Find();
     if (EntityManager.Exists(_playerEntity))
     {
         return;
     }
     _playerEntity = _playerGenerator.PlayerInstantiate(View.OwnerActorNr);
 }