Use Null-Propagation Operator
This commit is contained in:
@@ -381,8 +381,7 @@ namespace OpenRA.Mods.Common.Traits
|
||||
foreach (var t in triggers)
|
||||
t.Dirty = true;
|
||||
|
||||
if (CellUpdated != null)
|
||||
CellUpdated(c.Cell);
|
||||
CellUpdated?.Invoke(c.Cell);
|
||||
}
|
||||
}
|
||||
|
||||
@@ -403,8 +402,7 @@ namespace OpenRA.Mods.Common.Traits
|
||||
foreach (var t in triggers)
|
||||
t.Dirty = true;
|
||||
|
||||
if (CellUpdated != null)
|
||||
CellUpdated(c.Cell);
|
||||
CellUpdated?.Invoke(c.Cell);
|
||||
}
|
||||
}
|
||||
|
||||
|
||||
@@ -49,8 +49,7 @@ namespace OpenRA.Mods.Common.Traits
|
||||
ClearRedo();
|
||||
undoStack.Push(actionContainer);
|
||||
|
||||
if (ItemAdded != null)
|
||||
ItemAdded(actionContainer);
|
||||
ItemAdded?.Invoke(actionContainer);
|
||||
}
|
||||
|
||||
public void Undo()
|
||||
@@ -66,8 +65,7 @@ namespace OpenRA.Mods.Common.Traits
|
||||
editorAction.Status = EditorActionStatus.Future;
|
||||
redoStack.Push(editorAction);
|
||||
|
||||
if (OnChange != null)
|
||||
OnChange();
|
||||
OnChange?.Invoke();
|
||||
}
|
||||
|
||||
void ClearRedo()
|
||||
@@ -76,8 +74,7 @@ namespace OpenRA.Mods.Common.Traits
|
||||
{
|
||||
var item = redoStack.Pop();
|
||||
|
||||
if (ItemRemoved != null)
|
||||
ItemRemoved(item);
|
||||
ItemRemoved?.Invoke(item);
|
||||
}
|
||||
}
|
||||
|
||||
@@ -95,8 +92,7 @@ namespace OpenRA.Mods.Common.Traits
|
||||
undoStack.Peek().Status = EditorActionStatus.History;
|
||||
undoStack.Push(editorAction);
|
||||
|
||||
if (OnChange != null)
|
||||
OnChange();
|
||||
OnChange?.Invoke();
|
||||
}
|
||||
|
||||
public bool HasUndos()
|
||||
|
||||
@@ -92,8 +92,7 @@ namespace OpenRA.Mods.Common.Traits
|
||||
UpdateNetWorth(t.Type, t.Density, newTile.Type, newTile.Density);
|
||||
Tiles[uv] = newTile;
|
||||
Map.CustomTerrain[uv] = newTerrain;
|
||||
if (CellChanged != null)
|
||||
CellChanged(cell, type);
|
||||
CellChanged?.Invoke(cell, type);
|
||||
|
||||
// Neighbouring cell density depends on this cell
|
||||
foreach (var d in CVec.Directions)
|
||||
@@ -111,8 +110,7 @@ namespace OpenRA.Mods.Common.Traits
|
||||
neighbouringTile.Density = density;
|
||||
Tiles[neighbouringCell] = neighbouringTile;
|
||||
|
||||
if (CellChanged != null)
|
||||
CellChanged(neighbouringCell, type);
|
||||
CellChanged?.Invoke(neighbouringCell, type);
|
||||
}
|
||||
}
|
||||
|
||||
|
||||
@@ -158,8 +158,7 @@ namespace OpenRA.Mods.Common.Traits
|
||||
cell.Density = Math.Min(cell.Type.Info.MaxDensity, cell.Density + n);
|
||||
Content[p] = cell;
|
||||
|
||||
if (CellChanged != null)
|
||||
CellChanged(p, cell.Type);
|
||||
CellChanged?.Invoke(p, cell.Type);
|
||||
}
|
||||
|
||||
public bool IsFull(CPos cell)
|
||||
@@ -183,8 +182,7 @@ namespace OpenRA.Mods.Common.Traits
|
||||
else
|
||||
Content[cell] = c;
|
||||
|
||||
if (CellChanged != null)
|
||||
CellChanged(cell, c.Type);
|
||||
CellChanged?.Invoke(cell, c.Type);
|
||||
|
||||
return c.Type;
|
||||
}
|
||||
@@ -202,8 +200,7 @@ namespace OpenRA.Mods.Common.Traits
|
||||
Content[cell] = ResourceLayerContents.Empty;
|
||||
world.Map.CustomTerrain[cell] = byte.MaxValue;
|
||||
|
||||
if (CellChanged != null)
|
||||
CellChanged(cell, c.Type);
|
||||
CellChanged?.Invoke(cell, c.Type);
|
||||
}
|
||||
|
||||
public ResourceType GetResourceType(CPos cell) { return Content[cell].Type; }
|
||||
|
||||
Reference in New Issue
Block a user