コード例 #1
0
        /// <summary>
        /// Give the user the rider component if they're buckling to the vehicle,
        /// otherwise remove it.
        /// </summary>
        private void OnBuckleChange(EntityUid uid, VehicleComponent component, BuckleChangeEvent args)
        {
            // Send an event that our vehicle buckle changed
            if (TryComp <MindComponent>(args.BuckledEntity, out var mind) && mind.Mind != null && mind.Mind.TryGetSession(out var session))
            {
                RaiseNetworkEvent(new BuckledToVehicleEvent(uid, args.BuckledEntity, args.Buckling), Filter.SinglePlayer(session));
            }

            if (args.Buckling)
            {
                // Add a virtual item to rider's hand, unbuckle if we can't.
                if (!_virtualItemSystem.TrySpawnVirtualItemInHand(uid, args.BuckledEntity))
                {
                    _riderSystem.UnbuckleFromVehicle(args.BuckledEntity);
                    return;
                }
                // Set up the rider and vehicle with each other
                EnsureComp <SharedPlayerInputMoverComponent>(uid);
                var rider = EnsureComp <RiderComponent>(args.BuckledEntity);
                component.Rider    = args.BuckledEntity;
                rider.Vehicle      = component;
                component.HasRider = true;

                // Handle pulling
                RemComp <SharedPullableComponent>(args.BuckledEntity);
                RemComp <SharedPullableComponent>(uid);

                // Let this open doors if it has the key in it
                if (component.HasKey)
                {
                    _tagSystem.AddTag(uid, "DoorBumpOpener");
                }
                // Update appearance stuff, add actions
                UpdateBuckleOffset(Transform(uid), component);
                UpdateDrawDepth(uid, GetDrawDepth(Transform(uid), component.NorthOnly));
                if (TryComp <ActionsComponent>(args.BuckledEntity, out var actions) && TryComp <UnpoweredFlashlightComponent>(uid, out var flashlight))
                {
                    _actionsSystem.AddAction(args.BuckledEntity, flashlight.ToggleAction, uid, actions);
                }
                if (component.HornSound != null)
                {
                    _actionsSystem.AddAction(args.BuckledEntity, component.HornAction, uid, actions);
                }
                _itemSlotsSystem.SetLock(uid, component.Name, true);
                return;
            }
            // Clean up actions and virtual items
            _actionsSystem.RemoveProvidedActions(args.BuckledEntity, uid);
            _virtualItemSystem.DeleteInHandsMatching(args.BuckledEntity, uid);
            // Go back to old pullable behavior
            _tagSystem.RemoveTag(uid, "DoorBumpOpener");
            EnsureComp <SharedPullableComponent>(args.BuckledEntity);
            EnsureComp <SharedPullableComponent>(uid);
            // Entity is no longer riding
            RemComp <RiderComponent>(args.BuckledEntity);
            // Reset component
            component.HasRider = false;
            component.Rider    = null;
            _itemSlotsSystem.SetLock(uid, component.Name, false);
        }
コード例 #2
0
        /// <summary>
        ///     Force a nuclear bomb to start a countdown timer
        /// </summary>
        public void ArmBomb(EntityUid uid, NukeComponent?component = null)
        {
            if (!Resolve(uid, ref component))
            {
                return;
            }

            if (component.Status == NukeStatus.ARMED)
            {
                return;
            }

            var stationUid = _stationSystem.GetOwningStation(uid);

            // The nuke may not be on a station, so it's more important to just
            // let people know that a nuclear bomb was armed in their vicinity instead.
            // Otherwise, you could set every station to whatever AlertLevelOnActivate is.
            if (stationUid != null)
            {
                _alertLevel.SetLevel(stationUid.Value, component.AlertLevelOnActivate, true, true, true, true);
            }

            var nukeXform = Transform(uid);
            var pos       = nukeXform.MapPosition;
            var x         = (int)pos.X;
            var y         = (int)pos.Y;
            var posText   = $"({x}, {y})";

            // warn a crew
            var announcement = Loc.GetString("nuke-component-announcement-armed",
                                             ("time", (int)component.RemainingTime), ("position", posText));
            var sender = Loc.GetString("nuke-component-announcement-sender");

            _chatSystem.DispatchStationAnnouncement(uid, announcement, sender, false, null, Color.Red);

            NukeArmedAudio(component);

            _itemSlots.SetLock(uid, component.DiskSlot, true);
            nukeXform.Anchored = true;
            component.Status   = NukeStatus.ARMED;
            UpdateUserInterface(uid, component);
        }
コード例 #3
0
 private void OnComponentStartup(EntityUid uid, ItemCabinetComponent cabinet, ComponentStartup args)
 {
     UpdateAppearance(uid, cabinet);
     _itemSlotsSystem.SetLock(uid, cabinet.CabinetSlot, !cabinet.Opened);
 }