protected override void OnAddNode(Node node) { base.OnAddNode(node); if (_masterController == null) { node.Owner.TryGetComponent <AMEControllerComponent>(out var controller); _masterController = controller; } }
protected override void OnRemoveNode(Node node) { base.OnRemoveNode(node); RefreshAMENodes(_masterController); if (_masterController != null && _masterController?.Owner == node.Owner) { _masterController = null; } }
public void RefreshAMENodes(AMEControllerComponent controller) { if (_masterController == null && controller != null) { _masterController = controller; } if (_cores != null) { foreach (AMEShieldComponent core in _cores) { core.UnsetCore(); } _cores.Clear(); } //Check each shield node to see if it meets core criteria foreach (Node node in Nodes) { if (!node.Owner.TryGetComponent <AMEShieldComponent>(out var shield)) { continue; } var nodeNeighbors = node.Owner .GetComponent <SnapGridComponent>() .GetCellsInSquareArea() .Select(sgc => sgc.Owner) .Where(entity => entity != node.Owner) .Select(entity => entity.TryGetComponent <AMEShieldComponent>(out var adjshield) ? adjshield : null) .Where(adjshield => adjshield != null); if (nodeNeighbors.Count() >= 8) { _cores.Add(shield); } } if (_cores == null) { return; } foreach (AMEShieldComponent core in _cores) { core.SetCore(); } }
private static void OnAMEPowerChange(EntityUid uid, AMEControllerComponent component, PowerChangedEvent args) { component.UpdateUserInterface(); }