コード例 #1
0
    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);
    }
コード例 #2
0
        public void LeaveAtmosphere(AtmosDeviceComponent component)
        {
            if (!_atmosphereSystem.RemoveAtmosDevice(component))
            {
                return;
            }

            component.LastProcess = TimeSpan.Zero;
            RaiseLocalEvent(component.Owner.Uid, new AtmosDeviceDisabledEvent(), false);
        }
コード例 #3
0
        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);
            }
        }
コード例 #4
0
        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);
            }
        }
コード例 #5
0
        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);
        }
コード例 #6
0
        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);
            }
        }
コード例 #7
0
        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);
        }
コード例 #8
0
 private void OnDeviceParentChanged(EntityUid uid, AtmosDeviceComponent component, EntParentChangedMessage args)
 {
     RejoinAtmosphere(component);
 }
コード例 #9
0
 private void OnDeviceShutdown(EntityUid uid, AtmosDeviceComponent component, ComponentShutdown args)
 {
     LeaveAtmosphere(component);
 }
コード例 #10
0
 private void OnDeviceInitialize(EntityUid uid, AtmosDeviceComponent component, ComponentInit args)
 {
     JoinAtmosphere(component);
 }
コード例 #11
0
 public void RejoinAtmosphere(AtmosDeviceComponent component)
 {
     LeaveAtmosphere(component);
     JoinAtmosphere(component);
 }
コード例 #12
0
 private bool CanJoinAtmosphere(AtmosDeviceComponent component)
 {
     return(!component.RequireAnchored || !component.Owner.Transform.Anchored);
 }
コード例 #13
0
 private bool CanJoinAtmosphere(AtmosDeviceComponent component)
 {
     return(!component.RequireAnchored || !component.Owner.TryGetComponent(out PhysicsComponent? physics) || physics.BodyType == BodyType.Static);
 }
コード例 #14
0
 public override void RemoveAtmosDevice(AtmosDeviceComponent atmosDevice)
 {
 }
コード例 #15
0
 public override void AddAtmosDevice(AtmosDeviceComponent atmosDevice)
 {
 }