private void OnPortableAnchorAttempt(EntityUid uid, GasPortableComponent component, AnchorAttemptEvent args) { if (!EntityManager.TryGetComponent(uid, out TransformComponent? transform)) { return; } // If we can't find any ports, cancel the anchoring. if (!FindGasPortIn(transform.GridID, transform.Coordinates, out _)) { args.Cancel(); } }
private void OnAnchorChanged(EntityUid uid, GasPortableComponent portable, ref AnchorStateChangedEvent args) { if (!EntityManager.TryGetComponent(uid, out NodeContainerComponent? nodeContainer)) { return; } if (!nodeContainer.TryGetNode(portable.PortName, out PipeNode? portableNode)) { return; } portableNode.ConnectionsEnabled = args.Anchored; if (EntityManager.TryGetComponent(uid, out AppearanceComponent? appearance)) { appearance.SetData(GasPortableVisuals.ConnectedState, args.Anchored); } }
private void OnPortableUnanchored(EntityUid uid, GasPortableComponent portable, UnanchoredEvent args) { if (!ComponentManager.TryGetComponent(uid, out NodeContainerComponent? nodeContainer)) { return; } if (!nodeContainer.TryGetNode(portable.PortName, out PipeNode? portableNode)) { return; } portableNode.ConnectionsEnabled = false; if (ComponentManager.TryGetComponent(uid, out AppearanceComponent? appearance)) { appearance.SetData(GasPortableVisuals.ConnectedState, false); } }