addDirt method

bool addDirt(
  1. ActorComponent component,
  2. int value,
  3. bool recurse
)

Implementation

bool addDirt(ActorComponent component, int value, bool recurse) {
  if ((component.dirtMask & value) == value) {
    // Already marked.
    return false;
  }

  // Make sure dirt is set before calling anything that can set more dirt.
  int dirt = component.dirtMask | value;
  component.dirtMask = dirt;

  _flags |= ActorFlags.isDirty;

  component.onDirty(dirt);

  /// If the order of this component is less than the current dirt depth,
  /// update the dirt depth so that the update loop can break out early
  /// and re-run (something up the tree is dirty).
  if (component.graphOrder < _dirtDepth) {
    _dirtDepth = component.graphOrder;
  }
  if (!recurse) {
    return true;
  }
  List<ActorComponent?>? dependents = component.dependents;
  if (dependents != null) {
    for (final ActorComponent? d in dependents) {
      addDirt(d!, value, recurse);
    }
  }

  return true;
}