Add conditional spawning component (#1069)
* Add conditional spawning component * Remove null checks * Remove leftover return * Properly spawn items when game rule gets added * Fix duplicate uids in saltern * GameRules returns IEnumerable using yield.
This commit is contained in:
committed by
GitHub
parent
470f81fca1
commit
e1df008bce
@@ -98,6 +98,7 @@ namespace Content.Server.GameTicking
|
||||
}
|
||||
|
||||
public event Action<GameRunLevelChangedEventArgs> OnRunLevelChanged;
|
||||
public event Action<GameRuleAddedEventArgs> OnRuleAdded;
|
||||
|
||||
private TimeSpan LobbyDuration =>
|
||||
TimeSpan.FromSeconds(_configurationManager.GetCVar<int>("game.lobbyduration"));
|
||||
@@ -327,9 +328,25 @@ namespace Content.Server.GameTicking
|
||||
_gameRules.Add(instance);
|
||||
instance.Added();
|
||||
|
||||
OnRuleAdded?.Invoke(new GameRuleAddedEventArgs(instance));
|
||||
|
||||
return instance;
|
||||
}
|
||||
|
||||
public bool HasGameRule(Type t)
|
||||
{
|
||||
if (t == null || !t.IsAssignableFrom(typeof(GameRule)))
|
||||
return false;
|
||||
|
||||
foreach (var rule in _gameRules)
|
||||
{
|
||||
if (rule.GetType().Equals(t))
|
||||
return true;
|
||||
}
|
||||
|
||||
return false;
|
||||
}
|
||||
|
||||
public void RemoveGameRule(GameRule rule)
|
||||
{
|
||||
if (_gameRules.Contains(rule)) return;
|
||||
@@ -786,4 +803,14 @@ The current game mode is: [color=white]{0}[/color].
|
||||
public GameRunLevel OldRunLevel { get; }
|
||||
public GameRunLevel NewRunLevel { get; }
|
||||
}
|
||||
|
||||
public class GameRuleAddedEventArgs : EventArgs
|
||||
{
|
||||
public GameRule GameRule { get; }
|
||||
|
||||
public GameRuleAddedEventArgs(GameRule rule)
|
||||
{
|
||||
GameRule = rule;
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
Reference in New Issue
Block a user