예제 #1
0
 private void OnActivate(EntityUid uid, GasValveComponent component, ActivateInWorldEvent args)
 {
     if (args.User.InRangeUnobstructed(args.Target) && Get <ActionBlockerSystem>().CanInteract(args.User))
     {
         Toggle(uid, component);
     }
 }
 public void Set(EntityUid uid, GasValveComponent component, bool value)
 {
     component.Open = value;
     if (TryComp(uid, out NodeContainerComponent? nodeContainer) &&
         nodeContainer.TryGetNode(component.InletName, out PipeNode? inlet) &&
         nodeContainer.TryGetNode(component.OutletName, out PipeNode? outlet))
     {
         if (TryComp <AppearanceComponent>(component.Owner, out var appearance))
         {
             appearance.SetData(FilterVisuals.Enabled, component.Open);
         }
         if (component.Open)
         {
             inlet.AddAlwaysReachable(outlet);
             outlet.AddAlwaysReachable(inlet);
             _ambientSoundSystem.SetAmbience(component.Owner, true);
         }
         else
         {
             inlet.RemoveAlwaysReachable(outlet);
             outlet.RemoveAlwaysReachable(inlet);
             _ambientSoundSystem.SetAmbience(component.Owner, false);
         }
     }
 }
예제 #3
0
 private void OnActivate(EntityUid uid, GasValveComponent component, ActivateInWorldEvent args)
 {
     if (args.User.InRangeUnobstructed(args.Target) && _actionBlockerSystem.CanInteract(args.User))
     {
         Toggle(uid, component);
         SoundSystem.Play(Filter.Pvs(component.Owner), component.ValveSound.GetSound(), component.Owner, AudioHelpers.WithVariation(0.25f));
     }
 }
예제 #4
0
        public void Set(EntityUid uid, GasValveComponent component, bool value)
        {
            component.Open = value;

            if (EntityManager.TryGetComponent(uid, out NodeContainerComponent? nodeContainer) &&
                nodeContainer.TryGetNode(component.PipeName, out PipeNode? pipe))
            {
                pipe.ConnectionsEnabled = component.Open;
            }
        }
        private void OnExamined(EntityUid uid, GasValveComponent valve, ExaminedEvent args)
        {
            if (!Comp <TransformComponent>(valve.Owner).Anchored || !args.IsInDetailsRange) // Not anchored? Out of range? No status.
            {
                return;
            }

            if (Loc.TryGetString("gas-valve-system-examined", out var str,
                                 ("statusColor", valve.Open ? "green" : "orange"),
                                 ("open", valve.Open)
                                 ))
            {
                args.PushMarkup(str);
            }
        }
 public void Toggle(EntityUid uid, GasValveComponent component)
 {
     Set(uid, component, !component.Open);
 }
 private void OnActivate(EntityUid uid, GasValveComponent component, ActivateInWorldEvent args)
 {
     Toggle(uid, component);
     SoundSystem.Play(Filter.Pvs(component.Owner), component.ValveSound.GetSound(), component.Owner, AudioHelpers.WithVariation(0.25f));
 }
 private void OnStartup(EntityUid uid, GasValveComponent component, ComponentStartup args)
 {
     // We call set in startup so it sets the appearance, node state, etc.
     Set(uid, component, component.Open);
 }