public bool RemoveAtmosDevice(EntityUid gridUid, AtmosDeviceComponent device) { // TODO: check device is on grid var ev = new RemoveAtmosDeviceMethodEvent(gridUid, device); RaiseLocalEvent(gridUid, ref ev); return(ev.Result); }
public void LeaveAtmosphere(AtmosDeviceComponent component) { if (!_atmosphereSystem.RemoveAtmosDevice(component)) { return; } component.LastProcess = TimeSpan.Zero; RaiseLocalEvent(component.Owner.Uid, new AtmosDeviceDisabledEvent(), false); }
public void LeaveAtmosphere(AtmosDeviceComponent component) { var atmosphere = component.Atmosphere; atmosphere?.RemoveAtmosDevice(component); component.Atmosphere = null; component.LastProcess = TimeSpan.Zero; if (atmosphere != null) { RaiseLocalEvent(component.Owner.Uid, new AtmosDeviceDisabledEvent(atmosphere), false); } }
private void OnDeviceAnchorChanged(EntityUid uid, AtmosDeviceComponent component, AnchorStateChangedEvent args) { // Do nothing if the component doesn't require being anchored to function. if (!component.RequireAnchored) { return; } if (component.Owner.Transform.Anchored) { JoinAtmosphere(component); } else { LeaveAtmosphere(component); } }
public void JoinAtmosphere(AtmosDeviceComponent component) { if (!CanJoinAtmosphere(component)) { return; } // We try to add the device to a valid atmosphere. if (!_atmosphereSystem.AddAtmosDevice(component)) { return; } component.LastProcess = _gameTiming.CurTime; RaiseLocalEvent(component.Owner.Uid, new AtmosDeviceEnabledEvent(), false); }
private void OnDeviceBodyTypeChanged(EntityUid uid, AtmosDeviceComponent component, PhysicsBodyTypeChangedEvent args) { // Do nothing if the component doesn't require being anchored to function. if (!component.RequireAnchored) { return; } if (args.New == BodyType.Static) { JoinAtmosphere(component); } else { LeaveAtmosphere(component); } }
public void JoinAtmosphere(AtmosDeviceComponent component) { if (!CanJoinAtmosphere(component)) { return; } // We try to get a valid, simulated atmosphere. if (!Get <AtmosphereSystem>().TryGetSimulatedGridAtmosphere(component.Owner.Transform.MapPosition, out var atmosphere)) { return; } component.LastProcess = _gameTiming.CurTime; component.Atmosphere = atmosphere; atmosphere.AddAtmosDevice(component); RaiseLocalEvent(component.Owner.Uid, new AtmosDeviceEnabledEvent(atmosphere), false); }
private void OnDeviceParentChanged(EntityUid uid, AtmosDeviceComponent component, EntParentChangedMessage args) { RejoinAtmosphere(component); }
private void OnDeviceShutdown(EntityUid uid, AtmosDeviceComponent component, ComponentShutdown args) { LeaveAtmosphere(component); }
private void OnDeviceInitialize(EntityUid uid, AtmosDeviceComponent component, ComponentInit args) { JoinAtmosphere(component); }
public void RejoinAtmosphere(AtmosDeviceComponent component) { LeaveAtmosphere(component); JoinAtmosphere(component); }
private bool CanJoinAtmosphere(AtmosDeviceComponent component) { return(!component.RequireAnchored || !component.Owner.Transform.Anchored); }
private bool CanJoinAtmosphere(AtmosDeviceComponent component) { return(!component.RequireAnchored || !component.Owner.TryGetComponent(out PhysicsComponent? physics) || physics.BodyType == BodyType.Static); }
public override void RemoveAtmosDevice(AtmosDeviceComponent atmosDevice) { }
public override void AddAtmosDevice(AtmosDeviceComponent atmosDevice) { }