public void SelectRandomMap()
    {
        var maps = CurrentlyEligibleMaps().ToList();

        _currentMap       = _random.Pick(maps);
        _currentMapForced = false;
    }
Exemplo n.º 2
0
    public void SelectRandomMap()
    {
        var maps = CurrentlyEligibleMaps().ToList();

        _random.Shuffle(maps);
        _currentMap       = maps[0];
        _currentMapForced = false;
    }
Exemplo n.º 3
0
 public void ForceSelectMap(string gameMap)
 {
     if (!TryLookupMap(gameMap, out var map))
     {
         throw new ArgumentException($"The map \"{gameMap}\" is invalid!");
     }
     _currentMap       = map;
     _currentMapForced = true;
 }
Exemplo n.º 4
0
    public bool TrySelectMap(string gameMap)
    {
        if (!TryLookupMap(gameMap, out var map) || !IsMapEligible(map))
        {
            return(false);
        }

        _currentMap       = map;
        _currentMapForced = false;
        return(true);
    }
Exemplo n.º 5
0
 public void Initialize()
 {
     _configurationManager.OnValueChanged(CCVars.GameMap, value =>
     {
         if (TryLookupMap(value, out var map))
         {
             _currentMap = map;
         }
         else
         {
             throw new ArgumentException($"Unknown map prototype {value} was selected!");
         }
     }, true);
     _configurationManager.OnValueChanged(CCVars.GameMapForced, value => _currentMapForced = value, true);
 }
    public void Initialize()
    {
        _configurationManager.OnValueChanged(CCVars.GameMap, value =>
        {
            if (TryLookupMap(value, out var map))
            {
                _currentMap = map;
            }
            else
            {
                throw new ArgumentException($"Unknown map prototype {value} was selected!");
            }
        }, true);
        _configurationManager.OnValueChanged(CCVars.GameMapForced, value => _currentMapForced     = value, true);
        _configurationManager.OnValueChanged(CCVars.GameMapRotation, value => _mapRotationEnabled = value, true);
        _configurationManager.OnValueChanged(CCVars.GameMapMemoryDepth, value =>
        {
            _mapQueueDepth = value;
            // Drain excess.
            while (_previousMaps.Count > _mapQueueDepth)
            {
                _previousMaps.Dequeue();
            }
        }, true);

        var maps = AllVotableMaps().ToArray();

        _random.Shuffle(maps);
        foreach (var map in maps)
        {
            if (_previousMaps.Count >= _mapQueueDepth)
            {
                break;
            }
            _previousMaps.Enqueue(map.ID);
        }
    }
Exemplo n.º 7
0
 public string GenerateMapName(GameMapPrototype gameMap)
 {
     if (gameMap.NameGenerator is not null && gameMap.MapNameTemplate is not null)
     {
         return(gameMap.NameGenerator.FormatName(gameMap.MapNameTemplate));
     }
Exemplo n.º 8
0
 private bool IsMapEligible(GameMapPrototype map)
 {
     return(map.MaxPlayers >= _playerManager.PlayerCount &&
            map.MinPlayers <= _playerManager.PlayerCount &&
            map.Conditions.All(x => x.Check(map)));
 }
    public override bool Check(GameMapPrototype map)
    {
        var holidaySystem = EntitySystem.Get <HolidaySystem>();

        return(Holidays.Any(holiday => holidaySystem.IsCurrentlyHoliday(holiday)) ^ Inverted);
    }
Exemplo n.º 10
0
 private bool IsMapEligible(GameMapPrototype map)
 {
     return(map.MaxPlayers >= _playerManager.PlayerCount && map.MinPlayers <= _playerManager.PlayerCount);
 }
Exemplo n.º 11
0
 public abstract bool Check(GameMapPrototype map);
Exemplo n.º 12
0
 public StationInfoData(string name, GameMapPrototype mapPrototype, Dictionary <string, int> jobList)
 {
     Name         = name;
     MapPrototype = mapPrototype;
     _jobList     = jobList;
 }