public void AddObserver <T>(IReceive <T> handler) { if (_messageReceivers.Contains(handler)) { return; } _messageReceivers.Add(handler); _messageReceivers.Sort(_msgSorter); }
public bool TryAddCommand(Command cmd) { if (!cmd.CanStart()) { return(false); } var otherCmd = GetCommand(cmd.Owner.Entity); if (otherCmd != null) { if (!otherCmd.CanBeReplacedBy(cmd)) { cmd.Owner.Post(new StatusUpdate(cmd.Owner, "Can't replace current command")); return(false); } otherCmd.Cancel(); _commands.Remove(otherCmd); } cmd.StartCommand(); #if DEBUG DebugLog.Add(cmd.Owner.Entity.DebugId + " started command " + cmd.GetType()); #endif _commands.Add(cmd); return(true); }
protected BufferedList(bool addToGlobalList) { _addToGlobalList = addToGlobalList; if (_addToGlobalList) { _allLists.Add(this); } }
private void StartColorDamageTween(SpriteColorComponent colorComponent) { colorComponent.AnimatingColor = true; colorComponent.UpdateCurrentColor(Color.red); var tween = _floatPool.New(); tween.Restart(1, colorComponent.DmgMaxScale); _colorList.Add(new SpriteColorWatch(colorComponent, tween, colorComponent.Renderer.transform.localScale)); }
public void UpdateCellMapVisible(LevelCell cell) { if (Cells.Contains(cell)) { return; } //if (cell.HasActor()) { // for (int i = 0; i < cell.Actors.Count; i++) { // var actor = cell.Actors[i]; // if (actor != null) { // AddWatch(actor, true); // } // } //} cell.IsVisible = true; Cells.Add(cell); }
public bool TryAddCommand(Command cmd) { if (!cmd.CanStart()) { return(false); } var otherCmd = GetCommand(cmd.EntityOwner); if (otherCmd != null) { if (!otherCmd.CanBeReplacedBy(cmd)) { cmd.EntityOwner.PostAll(new StatusUpdate("Can't replace current command")); return(false); } otherCmd.Cancel(); _commands.Remove(otherCmd); } cmd.StartCommand(); _commands.Add(cmd); return(true); }