コード例 #1
0
        private void OnMouseEnteredStack(object?sender, StackContextElement e)
        {
            var realGlobalPosition = e.GlobalPosition;

            _cancellationTokenSource?.Cancel();
            _cancellationTokenSource = new();

            Timer.Spawn(e.HoverDelay, () =>
            {
                _verbSystem.CloseGroupMenu();

                if (_contextMenuView.Menus.Count == 0)
                {
                    return;
                }

                OnCloseChildMenu(sender, e.ParentMenu?.Depth ?? 0);

                var filteredEntities = e.ContextEntities.Where(entity => !entity.Deleted);
                if (filteredEntities.Any())
                {
                    _contextMenuView.AddChildMenu(filteredEntities, realGlobalPosition, e);
                }
            }, _cancellationTokenSource.Token);
        }
コード例 #2
0
        public void RequestRoundEnd(TimeSpan countdownTime, EntityUid?requester = null, bool checkCooldown = true)
        {
            if (_gameTicker.RunLevel != GameRunLevel.InRound)
            {
                return;
            }

            if (checkCooldown && _cooldownTokenSource != null)
            {
                return;
            }

            if (_countdownTokenSource != null)
            {
                return;
            }
            _countdownTokenSource = new();

            if (requester != null)
            {
                _adminLogger.Add(LogType.ShuttleCalled, LogImpact.High, $"Shuttle called by {ToPrettyString(requester.Value):user}");
            }
            else
            {
                _adminLogger.Add(LogType.ShuttleCalled, LogImpact.High, $"Shuttle called");
            }

            // I originally had these set up here but somehow time gets passed as 0 to Loc so IDEK.
            int    time;
            string units;

            if (countdownTime.TotalSeconds < 60)
            {
                time  = countdownTime.Seconds;
                units = "eta-units-seconds";
            }
            else
            {
                time  = countdownTime.Minutes;
                units = "eta-units-minutes";
            }

            _chatSystem.DispatchGlobalAnnouncement(Loc.GetString("round-end-system-shuttle-called-announcement",
                                                                 ("time", time),
                                                                 ("units", Loc.GetString(units))),
                                                   Loc.GetString("Station"),
                                                   false,
                                                   null,
                                                   Color.Gold);

            SoundSystem.Play("/Audio/Announcements/shuttlecalled.ogg", Filter.Broadcast());

            LastCountdownStart   = _gameTiming.CurTime;
            ExpectedCountdownEnd = _gameTiming.CurTime + countdownTime;
            Timer.Spawn(countdownTime, _shuttle.CallEmergencyShuttle, _countdownTokenSource.Token);

            ActivateCooldown();
            RaiseLocalEvent(RoundEndSystemChangedEvent.Default);
        }
コード例 #3
0
 private void ActivateCooldown()
 {
     _cooldownTokenSource?.Cancel();
     _cooldownTokenSource = new();
     Timer.Spawn(DefaultCooldownDuration, () =>
     {
         _cooldownTokenSource.Cancel();
         _cooldownTokenSource = null;
         RaiseLocalEvent(RoundEndSystemChangedEvent.Default);
     }, _cooldownTokenSource.Token);
 }
コード例 #4
0
 public void EndRound()
 {
     if (_gameTicker.RunLevel != GameRunLevel.InRound)
     {
         return;
     }
     ExpectedCountdownEnd = null;
     RaiseLocalEvent(RoundEndSystemChangedEvent.Default);
     _gameTicker.EndRound();
     _countdownTokenSource?.Cancel();
     _countdownTokenSource = new();
     _chatManager.DispatchServerAnnouncement(Loc.GetString("round-end-system-round-restart-eta-announcement", ("seconds", DefaultRestartRoundDuration.Seconds)));
     Timer.Spawn(DefaultRestartRoundDuration, AfterEndRoundRestart, _countdownTokenSource.Token);
 }
コード例 #5
0
        public void TestSpawn()
        {
            var timerManager = IoCManager.Resolve <ITimerManager>();

            var fired = false;

            Timer.Spawn(TimeSpan.FromMilliseconds(500), () => fired = true);
            Assert.That(fired, Is.False);

            // Set timers ahead 250 ms
            timerManager.UpdateTimers(new FrameEventArgs(.25f));
            Assert.That(fired, Is.False);
            // Another 300ms should do it.
            timerManager.UpdateTimers(new FrameEventArgs(.30f));
            Assert.That(fired, Is.True);
        }
コード例 #6
0
        public void HandleTimerTrigger(TimeSpan delay, EntityUid triggered, EntityUid?user = null)
        {
            if (delay.TotalSeconds <= 0)
            {
                Trigger(triggered, user);
                return;
            }

            Timer.Spawn(delay, () =>
            {
                if (Deleted(triggered))
                {
                    return;
                }
                Trigger(triggered, user);
            });
        }
コード例 #7
0
        public void TestCancellation()
        {
            var timerManager = IoCManager.Resolve <ITimerManager>();
            var taskManager  = IoCManager.Resolve <ITaskManager>();

            var cts = new CancellationTokenSource();
            var ran = false;

            Timer.Spawn(1000, () => ran = true, cts.Token);

            timerManager.UpdateTimers(new FrameEventArgs(.5f));

            Assert.That(ran, Is.False);

            cts.Cancel();

            timerManager.UpdateTimers(new FrameEventArgs(.6f));

            Assert.That(ran, Is.False);
        }
コード例 #8
0
        public void RequestRoundEnd(TimeSpan countdownTime, EntityUid?requester = null, bool checkCooldown = true)
        {
            if (_gameTicker.RunLevel != GameRunLevel.InRound)
            {
                return;
            }

            if (checkCooldown && _cooldownTokenSource != null)
            {
                return;
            }

            if (_countdownTokenSource != null)
            {
                return;
            }
            _countdownTokenSource = new();

            if (requester != null)
            {
                _adminLog.Add(LogType.ShuttleCalled, LogImpact.High, $"Shuttle called by {ToPrettyString(requester.Value):user}");
            }
            else
            {
                _adminLog.Add(LogType.ShuttleCalled, LogImpact.High, $"Shuttle called");
            }

            _chatManager.DispatchStationAnnouncement(Loc.GetString("round-end-system-shuttle-called-announcement", ("minutes", countdownTime.Minutes)), Loc.GetString("Station"), false);

            SoundSystem.Play(Filter.Broadcast(), "/Audio/Announcements/shuttlecalled.ogg");

            ExpectedCountdownEnd = _gameTiming.CurTime + countdownTime;
            Timer.Spawn(countdownTime, EndRound, _countdownTokenSource.Token);

            ActivateCooldown();
            RaiseLocalEvent(RoundEndSystemChangedEvent.Default);
        }
コード例 #9
0
    // All smite verbs have names so invokeverb works.
    private void AddSmiteVerbs(GetVerbsEvent <Verb> args)
    {
        if (!EntityManager.TryGetComponent <ActorComponent?>(args.User, out var actor))
        {
            return;
        }

        var player = actor.PlayerSession;

        if (!_adminManager.HasAdminFlag(player, AdminFlags.Fun))
        {
            return;
        }

        Verb explode = new()
        {
            Text        = "Explode",
            Category    = VerbCategory.Smite,
            IconTexture = "/Textures/Interface/VerbIcons/smite.svg.192dpi.png",
            Act         = () =>
            {
                var coords = Transform(args.Target).MapPosition;
                Timer.Spawn(_gameTiming.TickPeriod,
                            () => _explosionSystem.QueueExplosion(coords, ExplosionSystem.DefaultExplosionPrototypeId,
                                                                  4, 1, 2, maxTileBreak: 0), // it gibs, damage doesn't need to be high.
                            CancellationToken.None);

                if (TryComp(args.Target, out SharedBodyComponent? body))
                {
                    body.Gib();
                }
            },
            Impact  = LogImpact.Extreme,
            Message = "Explode them.",
        };

        args.Verbs.Add(explode);

        Verb chess = new()
        {
            Text        = "Chess Dimension",
            Category    = VerbCategory.Smite,
            IconTexture = "/Textures/Objects/Fun/Tabletop/chessboard.rsi/chessboard.png",
            Act         = () =>
            {
                _godmodeSystem.EnableGodmode(args.Target); // So they don't suffocate.
                EnsureComp <TabletopDraggableComponent>(args.Target);
                RemComp <PhysicsComponent>(args.Target);   // So they can be dragged around.
                var xform = Transform(args.Target);
                _popupSystem.PopupEntity(Loc.GetString("admin-smite-chess-self"), args.Target, Filter.Entities(args.Target));
                _popupSystem.PopupCoordinates(Loc.GetString("admin-smite-chess-others", ("name", args.Target)), xform.Coordinates, Filter.Pvs(args.Target).RemoveWhereAttachedEntity(x => x == args.Target));
                var board   = Spawn("ChessBoard", xform.Coordinates);
                var session = _tabletopSystem.EnsureSession(Comp <TabletopGameComponent>(board));
                xform.Coordinates   = EntityCoordinates.FromMap(_mapManager, session.Position);
                xform.WorldRotation = Angle.Zero;
            },
            Impact  = LogImpact.Extreme,
            Message = "Banishment to the Chess Dimension.",
        };

        args.Verbs.Add(chess);

        if (TryComp <FlammableComponent>(args.Target, out var flammable))
        {
            Verb flames = new()
            {
                Text        = "Set Alight",
                Category    = VerbCategory.Smite,
                IconTexture = "/Textures/Interface/Alerts/Fire/fire.png",
                Act         = () =>
                {
                    // F**k you. Burn Forever.
                    flammable.FireStacks = 99999.9f;
                    _flammableSystem.Ignite(args.Target);
                    var xform = Transform(args.Target);
                    _popupSystem.PopupEntity(Loc.GetString("admin-smite-set-alight-self"), args.Target, Filter.Entities(args.Target));
                    _popupSystem.PopupCoordinates(Loc.GetString("admin-smite-set-alight-others", ("name", args.Target)), xform.Coordinates, Filter.Pvs(args.Target).RemoveWhereAttachedEntity(x => x == args.Target));
                },
                Impact  = LogImpact.Extreme,
                Message = "Makes them burn.",
            };
            args.Verbs.Add(flames);
        }

        Verb monkey = new()
        {
            Text        = "Monkeyify",
            Category    = VerbCategory.Smite,
            IconTexture = "/Textures/Mobs/Animals/monkey.rsi/dead.png",
            Act         = () =>
            {
                _polymorphableSystem.PolymorphEntity(args.Target, "AdminMonkeySmite");
            },
            Impact  = LogImpact.Extreme,
            Message = "Monkey mode.",
        };

        args.Verbs.Add(monkey);

        if (TryComp <DiseaseCarrierComponent>(args.Target, out var carrier))
        {
            Verb lungCancer = new()
            {
                Text        = "Lung Cancer",
                Category    = VerbCategory.Smite,
                IconTexture = "/Textures/Mobs/Species/Human/organs.rsi/lung-l.png",
                Act         = () =>
                {
                    _diseaseSystem.TryInfect(carrier, _prototypeManager.Index <DiseasePrototype>("StageIIIALungCancer"),
                                             1.0f, true);
                },
                Impact  = LogImpact.Extreme,
                Message = "Stage IIIA Lung Cancer, for when they really like the hit show Breaking Bad.",
            };
            args.Verbs.Add(lungCancer);
        }

        if (TryComp <DamageableComponent>(args.Target, out var damageable) &&
            TryComp <MobStateComponent>(args.Target, out var mobState))
        {
            Verb hardElectrocute = new()
            {
                Text        = "Electrocute",
                Category    = VerbCategory.Smite,
                IconTexture = "/Textures/Clothing/Hands/Gloves/Color/yellow.rsi/icon.png",
                Act         = () =>
                {
                    int damageToDeal;
                    var critState = mobState._highestToLowestStates.Where(x => x.Value.IsCritical()).FirstOrNull();
                    if (critState is null)
                    {
                        // We can't crit them so try killing them.
                        var deadState = mobState._highestToLowestStates.Where(x => x.Value.IsDead()).FirstOrNull();
                        if (deadState is null)
                        {
                            return; // whelp.
                        }
                        damageToDeal = deadState.Value.Key - (int)damageable.TotalDamage;
                    }
                    else
                    {
                        damageToDeal = critState.Value.Key - (int)damageable.TotalDamage;
                    }

                    if (damageToDeal <= 0)
                    {
                        damageToDeal = 100; // murder time.
                    }
                    if (_inventorySystem.TryGetSlots(args.Target, out var slotDefinitions))
                    {
                        foreach (var slot in slotDefinitions)
                        {
                            if (!_inventorySystem.TryGetSlotEntity(args.Target, slot.Name, out var slotEnt))
                            {
                                continue;
                            }

                            RemComp <InsulatedComponent>(slotEnt.Value); // Fry the gloves.
                        }
                    }

                    _electrocutionSystem.TryDoElectrocution(args.Target, null, damageToDeal,
                                                            TimeSpan.FromSeconds(30), true);
                },
                Impact  = LogImpact.Extreme,
                Message = "Electrocutes them, rendering anything they were wearing useless.",
            };
            args.Verbs.Add(hardElectrocute);
        }

        if (TryComp <CreamPiedComponent>(args.Target, out var creamPied))
        {
            Verb creamPie = new()
            {
                Text        = "Creampie",
                Category    = VerbCategory.Smite,
                IconTexture = "/Textures/Objects/Consumable/Food/Baked/pie.rsi/plain-slice.png",
                Act         = () =>
                {
                    _creamPieSystem.SetCreamPied(args.Target, creamPied, true);
                },
                Impact  = LogImpact.Extreme,
                Message = "A cream pie, condensed into a button.",
            };
            args.Verbs.Add(creamPie);
        }

        if (TryComp <BloodstreamComponent>(args.Target, out var bloodstream))
        {
            Verb bloodRemoval = new()
            {
                Text        = "Remove blood",
                Category    = VerbCategory.Smite,
                IconTexture = "/Textures/Fluids/tomato_splat.rsi/puddle-1.png",
                Act         = () =>
                {
                    _bloodstreamSystem.SpillAllSolutions(args.Target, bloodstream);
                    var xform = Transform(args.Target);
                    _popupSystem.PopupEntity(Loc.GetString("admin-smite-remove-blood-self"), args.Target, Filter.Entities(args.Target));
                    _popupSystem.PopupCoordinates(Loc.GetString("admin-smite-remove-blood-others", ("name", args.Target)), xform.Coordinates, Filter.Pvs(args.Target).RemoveWhereAttachedEntity(x => x == args.Target));
                },
                Impact  = LogImpact.Extreme,
                Message = "Removes their blood. All of it.",
            };
            args.Verbs.Add(bloodRemoval);
        }

        // bobby...
        if (TryComp <BodyComponent>(args.Target, out var body))
        {
            Verb vomitOrgans = new()
            {
                Text        = "Vomit organs",
                Category    = VerbCategory.Smite,
                IconTexture = "/Textures/Fluids/vomit_toxin.rsi/vomit_toxin-1.png",
                Act         = () =>
                {
                    _vomitSystem.Vomit(args.Target, -1000, -1000); // You feel hollow!
                    var organs    = _bodySystem.GetComponentsOnMechanisms <TransformComponent>(args.Target, body);
                    var baseXform = Transform(args.Target);
                    foreach (var(xform, mechanism) in organs)
                    {
                        if (HasComp <BrainComponent>(xform.Owner) || HasComp <EyeComponent>(xform.Owner))
                        {
                            continue;
                        }

                        mechanism.Part?.RemoveMechanism(mechanism);
                        xform.Coordinates = baseXform.Coordinates.Offset(_random.NextVector2(0.5f, 0.75f));
                    }

                    _popupSystem.PopupEntity(Loc.GetString("admin-smite-vomit-organs-self"), args.Target, Filter.Entities(args.Target));
                    _popupSystem.PopupCoordinates(Loc.GetString("admin-smite-vomit-organs-others", ("name", args.Target)), baseXform.Coordinates, Filter.Pvs(args.Target).RemoveWhereAttachedEntity(x => x == args.Target));
                },
                Impact  = LogImpact.Extreme,
                Message = "Causes them to vomit, including their internal organs.",
            };
            args.Verbs.Add(vomitOrgans);

            Verb handRemoval = new()
            {
                Text        = "Remove hands",
                Category    = VerbCategory.Smite,
                IconTexture = "/Textures/Interface/fist.svg.192dpi.png",
                Act         = () =>
                {
                    var baseXform = Transform(args.Target);
                    foreach (var part in body.GetPartsOfType(BodyPartType.Hand))
                    {
                        body.RemovePart(part);
                        Transform(part.Owner).Coordinates = baseXform.Coordinates;
                    }
                    _popupSystem.PopupEntity(Loc.GetString("admin-smite-remove-hands-self"), args.Target, Filter.Entities(args.Target));
                    _popupSystem.PopupCoordinates(Loc.GetString("admin-smite-remove-hands-others", ("name", args.Target)), baseXform.Coordinates, Filter.Pvs(args.Target).RemoveWhereAttachedEntity(x => x == args.Target));
                },
                Impact  = LogImpact.Extreme,
                Message = "Removes the target's hands.",
            };
            args.Verbs.Add(handRemoval);
        }

        if (TryComp <PhysicsComponent>(args.Target, out var physics))
        {
            Verb pinball = new()
            {
                Text        = "Pinball",
                Category    = VerbCategory.Smite,
                IconTexture = "/Textures/Objects/Fun/toys.rsi/basketball.png",
                Act         = () =>
                {
                    var xform    = Transform(args.Target);
                    var fixtures = Comp <FixturesComponent>(args.Target);
                    xform.Anchored     = false; // Just in case.
                    physics.BodyType   = BodyType.Dynamic;
                    physics.BodyStatus = BodyStatus.InAir;
                    physics.WakeBody();
                    foreach (var(_, fixture) in fixtures.Fixtures)
                    {
                        if (!fixture.Hard)
                        {
                            continue;
                        }
                        fixture.Restitution = 1.1f;
                    }

                    physics.LinearVelocity  = _random.NextVector2(1.5f, 1.5f);
                    physics.AngularVelocity = MathF.PI * 12;
                    physics.LinearDamping   = 0.0f;
                    physics.AngularDamping  = 0.0f;
                },
                Impact  = LogImpact.Extreme,
                Message =
                    "Turns them into a super bouncy ball, flinging them around until they clip through the station into the abyss.",
            };
            args.Verbs.Add(pinball);

            Verb yeet = new()
            {
                Text        = "Yeet",
                Category    = VerbCategory.Smite,
                IconTexture = "/Textures/Interface/VerbIcons/eject.svg.192dpi.png",
                Act         = () =>
                {
                    var xform    = Transform(args.Target);
                    var fixtures = Comp <FixturesComponent>(args.Target);
                    xform.Anchored     = false; // Just in case.
                    physics.BodyType   = BodyType.Dynamic;
                    physics.BodyStatus = BodyStatus.InAir;
                    physics.WakeBody();
                    foreach (var(_, fixture) in fixtures.Fixtures)
                    {
                        fixture.Hard = false;
                    }

                    physics.LinearVelocity  = _random.NextVector2(8.0f, 8.0f);
                    physics.AngularVelocity = MathF.PI * 12;
                    physics.LinearDamping   = 0.0f;
                    physics.AngularDamping  = 0.0f;
                },
                Impact  = LogImpact.Extreme,
                Message = "Banishes them into the depths of space by turning on no-clip and tossing them.",
            };
            args.Verbs.Add(yeet);
        }

        Verb bread = new()
        {
            Text        = "Become Bread",
            Category    = VerbCategory.Smite,
            IconTexture = "/Textures/Objects/Consumable/Food/Baked/bread.rsi/plain.png",
            Act         = () =>
            {
                _polymorphableSystem.PolymorphEntity(args.Target, "AdminBreadSmite");
            },
            Impact  = LogImpact.Extreme,
            Message = "It turns them into bread. Really. That's all it does.",
        };

        args.Verbs.Add(bread);

        if (TryComp <ActorComponent>(args.Target, out var actorComponent))
        {
            Verb ghostKick = new()
            {
                Text        = "Ghostkick",
                Category    = VerbCategory.Smite,
                IconTexture = "/Textures/Interface/gavel.svg.192dpi.png",
                Act         = () =>
                {
                    _ghostKickManager.DoDisconnect(actorComponent.PlayerSession.ConnectedClient, "Smitten.");
                },
                Impact  = LogImpact.Extreme,
                Message = "Silently kicks the user, dropping their connection.",
            };
            args.Verbs.Add(ghostKick);
        }

        if (TryComp <InventoryComponent>(args.Target, out var inventory))
        {
            Verb nyanify = new()
            {
                Text        = "Nyanify",
                Category    = VerbCategory.Smite,
                IconTexture = "/Textures/Clothing/Head/Hats/catears.rsi/icon.png",
                Act         = () =>
                {
                    var ears = Spawn("ClothingHeadHatCatEars", Transform(args.Target).Coordinates);
                    EnsureComp <UnremoveableComponent>(ears);
                    _inventorySystem.TryUnequip(args.Target, "head", true, true, false, inventory);
                    _inventorySystem.TryEquip(args.Target, ears, "head", true, true, false, inventory);
                },
                Impact  = LogImpact.Extreme,
                Message = "Forcibly adds cat ears. There is no escape.",
            };
            args.Verbs.Add(nyanify);

            Verb killSign = new()
            {
                Text        = "Kill sign",
                Category    = VerbCategory.Smite,
                IconTexture = "/Textures/Objects/Misc/killsign.rsi/icon.png",
                Act         = () =>
                {
                    EnsureComp <KillSignComponent>(args.Target);
                },
                Impact  = LogImpact.Extreme,
                Message = "Marks a player for death by their fellows.",
            };
            args.Verbs.Add(killSign);

            // TODO: Port cluwne outfit.
            Verb clown = new()
            {
                Text        = "Clown",
                Category    = VerbCategory.Smite,
                IconTexture = "/Textures/Objects/Fun/bikehorn.rsi/icon.png",
                Act         = () =>
                {
                    SetOutfitCommand.SetOutfit(args.Target, "ClownGear", EntityManager, (_, clothing) =>
                    {
                        if (HasComp <ClothingComponent>(clothing))
                        {
                            EnsureComp <UnremoveableComponent>(clothing);
                        }
                        EnsureComp <ClumsyComponent>(args.Target);
                    });
                },
                Impact  = LogImpact.Extreme,
                Message = "Clowns them. The suit cannot be removed.",
            };
            args.Verbs.Add(clown);
        }

        Verb angerPointingArrows = new()
        {
            Text        = "Anger Pointing Arrows",
            Category    = VerbCategory.Smite,
            IconTexture = "/Textures/Interface/Misc/pointing.rsi/pointing.png",
            Act         = () =>
            {
                EnsureComp <PointingArrowAngeringComponent>(args.Target);
            },
            Impact  = LogImpact.Extreme,
            Message = "Angers the pointing arrows, causing them to assault this entity.",
        };

        args.Verbs.Add(angerPointingArrows);

        Verb dust = new()
        {
            Text        = "Dust",
            Category    = VerbCategory.Smite,
            IconTexture = "/Textures/Objects/Materials/materials.rsi/ash.png",
            Act         = () =>
            {
                EntityManager.QueueDeleteEntity(args.Target);
                Spawn("Ash", Transform(args.Target).Coordinates);
                _popupSystem.PopupEntity(Loc.GetString("admin-smite-turned-ash-other", ("name", args.Target)), args.Target, Filter.Pvs(args.Target));
            },
            Impact  = LogImpact.Extreme,
            Message = "Reduces the target to a small pile of ash.",
        };

        args.Verbs.Add(dust);

        Verb youtubeVideoSimulation = new()
        {
            Text        = "Buffering",
            Category    = VerbCategory.Smite,
            IconTexture = "/Textures/Interface/Misc/buffering_smite_icon.png",
            Act         = () =>
            {
                EnsureComp <BufferingComponent>(args.Target);
            },
            Impact  = LogImpact.Extreme,
            Message = "Causes the target to randomly start buffering, freezing them in place for a short timespan while they load.",
        };

        args.Verbs.Add(youtubeVideoSimulation);

        Verb instrumentation = new()
        {
            Text        = "Become Instrument",
            Category    = VerbCategory.Smite,
            IconTexture = "/Textures/Objects/Fun/Instruments/h_synthesizer.rsi/icon.png",
            Act         = () =>
            {
                _polymorphableSystem.PolymorphEntity(args.Target, "AdminInstrumentSmite");
            },
            Impact  = LogImpact.Extreme,
            Message = "It turns them into a supersynth. Really. That's all it does.",
        };

        args.Verbs.Add(instrumentation);

        Verb noGravity = new()
        {
            Text        = "Remove gravity",
            Category    = VerbCategory.Smite,
            IconTexture = "/Textures/Structures/Machines/gravity_generator.rsi/off.png",
            Act         = () =>
            {
                var grav = EnsureComp <MovementIgnoreGravityComponent>(args.Target);
                grav.Weightless = true;
            },
            Impact  = LogImpact.Extreme,
            Message = "Grants them anti-gravity.",
        };

        args.Verbs.Add(noGravity);
    }
コード例 #10
0
    private void UpdateEmergencyConsole(float frameTime)
    {
        if (_consoleAccumulator <= 0f)
        {
            return;
        }

        _consoleAccumulator -= frameTime;

        // No early launch but we're under the timer.
        if (!_launchedShuttles && _consoleAccumulator <= _authorizeTime)
        {
            if (!EarlyLaunchAuthorized)
            {
                AnnounceLaunch();
            }
        }

        // Imminent departure
        if (!_launchedShuttles && _consoleAccumulator <= DefaultStartupTime)
        {
            _launchedShuttles = true;

            if (_centComMap != null)
            {
                foreach (var comp in EntityQuery <StationDataComponent>(true))
                {
                    if (!TryComp <ShuttleComponent>(comp.EmergencyShuttle, out var shuttle))
                    {
                        continue;
                    }

                    if (Deleted(_centCom))
                    {
                        // TODO: Need to get non-overlapping positions.
                        FTLTravel(shuttle,
                                  new EntityCoordinates(
                                      _mapManager.GetMapEntityId(_centComMap.Value),
                                      Vector2.One * 1000f), _consoleAccumulator, TransitTime);
                    }
                    else
                    {
                        FTLTravel(shuttle,
                                  _centCom.Value, _consoleAccumulator, TransitTime, dock: true);
                    }
                }
            }
        }

        // Departed
        if (_consoleAccumulator <= 0f)
        {
            _launchedShuttles = true;
            _chatSystem.DispatchGlobalAnnouncement(Loc.GetString("emergency-shuttle-left", ("transitTime", $"{TransitTime:0}")));

            _roundEndCancelToken = new CancellationTokenSource();
            Timer.Spawn((int)(TransitTime * 1000) + _bufferTime.Milliseconds, () => _roundEnd.EndRound(), _roundEndCancelToken.Token);

            // Guarantees that emergency shuttle arrives first before anyone else can FTL.
            if (_centCom != null)
            {
                AddFTLDestination(_centCom.Value, true);
            }
        }
    }
コード例 #11
0
    // All smite verbs have names so invokeverb works.
    private void AddSmiteVerbs(GetVerbsEvent <Verb> args)
    {
        if (!EntityManager.TryGetComponent <ActorComponent?>(args.User, out var actor))
        {
            return;
        }

        var player = actor.PlayerSession;

        if (!_adminManager.HasAdminFlag(player, AdminFlags.Fun))
        {
            return;
        }

        // 1984.
        if (HasComp <IMapComponent>(args.Target) || HasComp <IMapGridComponent>(args.Target))
        {
            return;
        }

        Verb explode = new()
        {
            Text        = "Explode",
            Category    = VerbCategory.Smite,
            IconTexture = "/Textures/Interface/VerbIcons/smite.svg.192dpi.png",
            Act         = () =>
            {
                var coords = Transform(args.Target).MapPosition;
                Timer.Spawn(_gameTiming.TickPeriod,
                            () => _explosionSystem.QueueExplosion(coords, ExplosionSystem.DefaultExplosionPrototypeId,
                                                                  4, 1, 2, maxTileBreak: 0), // it gibs, damage doesn't need to be high.
                            CancellationToken.None);

                if (TryComp(args.Target, out SharedBodyComponent? body))
                {
                    body.Gib();
                }
            },
            Impact  = LogImpact.Extreme,
            Message = Loc.GetString("admin-smite-explode-description")
        };

        args.Verbs.Add(explode);

        Verb chess = new()
        {
            Text        = "Chess Dimension",
            Category    = VerbCategory.Smite,
            IconTexture = "/Textures/Objects/Fun/Tabletop/chessboard.rsi/chessboard.png",
            Act         = () =>
            {
                _godmodeSystem.EnableGodmode(args.Target); // So they don't suffocate.
                EnsureComp <TabletopDraggableComponent>(args.Target);
                RemComp <PhysicsComponent>(args.Target);   // So they can be dragged around.
                var xform = Transform(args.Target);
                _popupSystem.PopupEntity(Loc.GetString("admin-smite-chess-self"), args.Target,
                                         Filter.Entities(args.Target), PopupType.LargeCaution);
                _popupSystem.PopupCoordinates(
                    Loc.GetString("admin-smite-chess-others", ("name", args.Target)), xform.Coordinates,
                    Filter.PvsExcept(args.Target), PopupType.MediumCaution);
                var board   = Spawn("ChessBoard", xform.Coordinates);
                var session = _tabletopSystem.EnsureSession(Comp <TabletopGameComponent>(board));
                xform.Coordinates   = EntityCoordinates.FromMap(_mapManager, session.Position);
                xform.WorldRotation = Angle.Zero;
            },
            Impact  = LogImpact.Extreme,
            Message = Loc.GetString("admin-smite-chess-dimension-description")
        };

        args.Verbs.Add(chess);

        if (TryComp <FlammableComponent>(args.Target, out var flammable))
        {
            Verb flames = new()
            {
                Text        = "Set Alight",
                Category    = VerbCategory.Smite,
                IconTexture = "/Textures/Interface/Alerts/Fire/fire.png",
                Act         = () =>
                {
                    // F**k you. Burn Forever.
                    flammable.FireStacks = 99999.9f;
                    _flammableSystem.Ignite(args.Target);
                    var xform = Transform(args.Target);
                    _popupSystem.PopupEntity(Loc.GetString("admin-smite-set-alight-self"), args.Target,
                                             Filter.Entities(args.Target), PopupType.LargeCaution);
                    _popupSystem.PopupCoordinates(Loc.GetString("admin-smite-set-alight-others", ("name", args.Target)), xform.Coordinates,
                                                  Filter.PvsExcept(args.Target), PopupType.MediumCaution);
                },
                Impact  = LogImpact.Extreme,
                Message = Loc.GetString("admin-smite-set-alight-description")
            };
            args.Verbs.Add(flames);
        }

        Verb monkey = new()
        {
            Text        = "Monkeyify",
            Category    = VerbCategory.Smite,
            IconTexture = "/Textures/Mobs/Animals/monkey.rsi/dead.png",
            Act         = () =>
            {
                _polymorphableSystem.PolymorphEntity(args.Target, "AdminMonkeySmite");
            },
            Impact  = LogImpact.Extreme,
            Message = Loc.GetString("admin-smite-monkeyify-description")
        };

        args.Verbs.Add(monkey);

        Verb disposalBin = new()
        {
            Text        = "Garbage Can",
            Category    = VerbCategory.Smite,
            IconTexture = "/Textures/Structures/Piping/disposal.rsi/disposal.png",
            Act         = () =>
            {
                _polymorphableSystem.PolymorphEntity(args.Target, "AdminDisposalsSmite");
            },
            Impact  = LogImpact.Extreme,
            Message = Loc.GetString("admin-smite-garbage-can-description")
        };

        args.Verbs.Add(disposalBin);

        if (TryComp <DiseaseCarrierComponent>(args.Target, out var carrier))
        {
            Verb lungCancer = new()
            {
                Text        = "Lung Cancer",
                Category    = VerbCategory.Smite,
                IconTexture = "/Textures/Mobs/Species/Human/organs.rsi/lung-l.png",
                Act         = () =>
                {
                    _diseaseSystem.TryInfect(carrier, _prototypeManager.Index <DiseasePrototype>("StageIIIALungCancer"),
                                             1.0f, true);
                },
                Impact  = LogImpact.Extreme,
                Message = Loc.GetString("admin-smite-lung-cancer-description")
            };
            args.Verbs.Add(lungCancer);
        }

        if (TryComp <DamageableComponent>(args.Target, out var damageable) &&
            TryComp <MobStateComponent>(args.Target, out var mobState))
        {
            Verb hardElectrocute = new()
            {
                Text        = "Electrocute",
                Category    = VerbCategory.Smite,
                IconTexture = "/Textures/Clothing/Hands/Gloves/Color/yellow.rsi/icon.png",
                Act         = () =>
                {
                    int damageToDeal;
                    var critState = mobState._highestToLowestStates.Where(x => x.Value == DamageState.Critical).FirstOrNull();
                    if (critState is null)
                    {
                        // We can't crit them so try killing them.
                        var deadState = mobState._highestToLowestStates.Where(x => x.Value == DamageState.Dead).FirstOrNull();
                        if (deadState is null)
                        {
                            return; // whelp.
                        }
                        damageToDeal = deadState.Value.Key - (int)damageable.TotalDamage;
                    }
                    else
                    {
                        damageToDeal = critState.Value.Key - (int)damageable.TotalDamage;
                    }

                    if (damageToDeal <= 0)
                    {
                        damageToDeal = 100; // murder time.
                    }
                    if (_inventorySystem.TryGetSlots(args.Target, out var slotDefinitions))
                    {
                        foreach (var slot in slotDefinitions)
                        {
                            if (!_inventorySystem.TryGetSlotEntity(args.Target, slot.Name, out var slotEnt))
                            {
                                continue;
                            }

                            RemComp <InsulatedComponent>(slotEnt.Value); // Fry the gloves.
                        }
                    }

                    _electrocutionSystem.TryDoElectrocution(args.Target, null, damageToDeal,
                                                            TimeSpan.FromSeconds(30), true);
                },
                Impact  = LogImpact.Extreme,
                Message = Loc.GetString("admin-smite-electrocute-description")
            };
            args.Verbs.Add(hardElectrocute);
        }

        if (TryComp <CreamPiedComponent>(args.Target, out var creamPied))
        {
            Verb creamPie = new()
            {
                Text        = "Creampie",
                Category    = VerbCategory.Smite,
                IconTexture = "/Textures/Objects/Consumable/Food/Baked/pie.rsi/plain-slice.png",
                Act         = () =>
                {
                    _creamPieSystem.SetCreamPied(args.Target, creamPied, true);
                },
                Impact  = LogImpact.Extreme,
                Message = Loc.GetString("admin-smite-creampie-description")
            };
            args.Verbs.Add(creamPie);
        }

        if (TryComp <BloodstreamComponent>(args.Target, out var bloodstream))
        {
            Verb bloodRemoval = new()
            {
                Text        = "Remove blood",
                Category    = VerbCategory.Smite,
                IconTexture = "/Textures/Fluids/tomato_splat.rsi/puddle-1.png",
                Act         = () =>
                {
                    _bloodstreamSystem.SpillAllSolutions(args.Target, bloodstream);
                    var xform = Transform(args.Target);
                    _popupSystem.PopupEntity(Loc.GetString("admin-smite-remove-blood-self"), args.Target,
                                             Filter.Entities(args.Target), PopupType.LargeCaution);
                    _popupSystem.PopupCoordinates(Loc.GetString("admin-smite-remove-blood-others", ("name", args.Target)), xform.Coordinates,
                                                  Filter.PvsExcept(args.Target), PopupType.MediumCaution);
                },
                Impact  = LogImpact.Extreme,
                Message = Loc.GetString("admin-smite-remove-blood-description")
            };
            args.Verbs.Add(bloodRemoval);
        }

        // bobby...
        if (TryComp <BodyComponent>(args.Target, out var body))
        {
            Verb vomitOrgans = new()
            {
                Text        = "Vomit organs",
                Category    = VerbCategory.Smite,
                IconTexture = "/Textures/Fluids/vomit_toxin.rsi/vomit_toxin-1.png",
                Act         = () =>
                {
                    _vomitSystem.Vomit(args.Target, -1000, -1000); // You feel hollow!
                    var organs    = _bodySystem.GetComponentsOnMechanisms <TransformComponent>(args.Target, body);
                    var baseXform = Transform(args.Target);
                    foreach (var(xform, mechanism) in organs)
                    {
                        if (HasComp <BrainComponent>(xform.Owner) || HasComp <EyeComponent>(xform.Owner))
                        {
                            continue;
                        }

                        mechanism.Part?.RemoveMechanism(mechanism);
                        xform.Coordinates = baseXform.Coordinates.Offset(_random.NextVector2(0.5f, 0.75f));
                    }

                    _popupSystem.PopupEntity(Loc.GetString("admin-smite-vomit-organs-self"), args.Target,
                                             Filter.Entities(args.Target), PopupType.LargeCaution);
                    _popupSystem.PopupCoordinates(Loc.GetString("admin-smite-vomit-organs-others", ("name", args.Target)), baseXform.Coordinates,
                                                  Filter.PvsExcept(args.Target), PopupType.MediumCaution);
                },
                Impact  = LogImpact.Extreme,
                Message = Loc.GetString("admin-smite-vomit-organs-description")
            };
            args.Verbs.Add(vomitOrgans);

            Verb handsRemoval = new()
            {
                Text        = "Remove hands",
                Category    = VerbCategory.Smite,
                IconTexture = "/Textures/Interface/AdminActions/remove-hands.png",
                Act         = () =>
                {
                    var baseXform = Transform(args.Target);
                    foreach (var part in body.GetPartsOfType(BodyPartType.Hand))
                    {
                        body.RemovePart(part);
                        Transform(part.Owner).Coordinates = baseXform.Coordinates;
                    }
                    _popupSystem.PopupEntity(Loc.GetString("admin-smite-remove-hands-self"), args.Target,
                                             Filter.Entities(args.Target), PopupType.LargeCaution);
                    _popupSystem.PopupCoordinates(Loc.GetString("admin-smite-remove-hands-others", ("name", args.Target)), baseXform.Coordinates,
                                                  Filter.PvsExcept(args.Target), PopupType.Medium);
                },
                Impact  = LogImpact.Extreme,
                Message = Loc.GetString("admin-smite-remove-hands-description")
            };
            args.Verbs.Add(handsRemoval);

            Verb handRemoval = new()
            {
                Text        = "Remove hands",
                Category    = VerbCategory.Smite,
                IconTexture = "/Textures/Interface/AdminActions/remove-hand.png",
                Act         = () =>
                {
                    var baseXform = Transform(args.Target);
                    foreach (var part in body.GetPartsOfType(BodyPartType.Hand))
                    {
                        body.RemovePart(part);
                        Transform(part.Owner).Coordinates = baseXform.Coordinates;
                        break;
                    }
                    _popupSystem.PopupEntity(Loc.GetString("admin-smite-remove-hands-self"), args.Target,
                                             Filter.Entities(args.Target), PopupType.LargeCaution);
                    _popupSystem.PopupCoordinates(Loc.GetString("admin-smite-remove-hands-others", ("name", args.Target)), baseXform.Coordinates,
                                                  Filter.PvsExcept(args.Target), PopupType.Medium);
                },
                Impact  = LogImpact.Extreme,
                Message = Loc.GetString("admin-smite-remove-hand-description")
            };
            args.Verbs.Add(handRemoval);

            Verb stomachRemoval = new()
            {
                Text        = "Stomach Removal",
                Category    = VerbCategory.Smite,
                IconTexture = "/Textures/Mobs/Species/Human/organs.rsi/stomach.png",
                Act         = () =>
                {
                    foreach (var part in body.Parts)
                    {
                        foreach (var mechanism in part.Key.Mechanisms)
                        {
                            if (HasComp <StomachComponent>(mechanism.Owner))
                            {
                                QueueDel(mechanism.Owner);
                            }
                        }
                    }

                    _popupSystem.PopupEntity(Loc.GetString("admin-smite-stomach-removal-self"), args.Target,
                                             Filter.Entities(args.Target), PopupType.LargeCaution);
                },
                Impact  = LogImpact.Extreme,
                Message = Loc.GetString("admin-smite-stomach-removal-description"),
            };
            args.Verbs.Add(stomachRemoval);

            Verb lungRemoval = new()
            {
                Text        = "Lungs Removal",
                Category    = VerbCategory.Smite,
                IconTexture = "/Textures/Mobs/Species/Human/organs.rsi/lung-r.png",
                Act         = () =>
                {
                    foreach (var part in body.Parts)
                    {
                        foreach (var mechanism in part.Key.Mechanisms)
                        {
                            if (HasComp <LungComponent>(mechanism.Owner))
                            {
                                QueueDel(mechanism.Owner);
                            }
                        }
                    }

                    _popupSystem.PopupEntity(Loc.GetString("admin-smite-lung-removal-self"), args.Target,
                                             Filter.Entities(args.Target), PopupType.LargeCaution);
                },
                Impact  = LogImpact.Extreme,
                Message = Loc.GetString("admin-smite-lung-removal-description"),
            };
            args.Verbs.Add(lungRemoval);
        }

        if (TryComp <PhysicsComponent>(args.Target, out var physics))
        {
            Verb pinball = new()
            {
                Text        = "Pinball",
                Category    = VerbCategory.Smite,
                IconTexture = "/Textures/Objects/Fun/toys.rsi/basketball.png",
                Act         = () =>
                {
                    var xform    = Transform(args.Target);
                    var fixtures = Comp <FixturesComponent>(args.Target);
                    xform.Anchored     = false; // Just in case.
                    physics.BodyType   = BodyType.Dynamic;
                    physics.BodyStatus = BodyStatus.InAir;
                    physics.WakeBody();
                    foreach (var(_, fixture) in fixtures.Fixtures)
                    {
                        if (!fixture.Hard)
                        {
                            continue;
                        }
                        fixture.Restitution = 1.1f;
                    }

                    physics.LinearVelocity  = _random.NextVector2(1.5f, 1.5f);
                    physics.AngularVelocity = MathF.PI * 12;
                    physics.LinearDamping   = 0.0f;
                    physics.AngularDamping  = 0.0f;
                },
                Impact  = LogImpact.Extreme,
                Message = Loc.GetString("admin-smite-pinball-description")
            };
            args.Verbs.Add(pinball);

            Verb yeet = new()
            {
                Text        = "Yeet",
                Category    = VerbCategory.Smite,
                IconTexture = "/Textures/Interface/VerbIcons/eject.svg.192dpi.png",
                Act         = () =>
                {
                    var xform    = Transform(args.Target);
                    var fixtures = Comp <FixturesComponent>(args.Target);
                    xform.Anchored     = false; // Just in case.
                    physics.BodyType   = BodyType.Dynamic;
                    physics.BodyStatus = BodyStatus.InAir;
                    physics.WakeBody();
                    foreach (var(_, fixture) in fixtures.Fixtures)
                    {
                        fixture.Hard = false;
                    }

                    physics.LinearVelocity  = _random.NextVector2(8.0f, 8.0f);
                    physics.AngularVelocity = MathF.PI * 12;
                    physics.LinearDamping   = 0.0f;
                    physics.AngularDamping  = 0.0f;
                },
                Impact  = LogImpact.Extreme,
                Message = Loc.GetString("admin-smite-yeet-description")
            };
            args.Verbs.Add(yeet);
        }

        Verb bread = new()
        {
            Text        = "Become Bread",
            Category    = VerbCategory.Smite,
            IconTexture = "/Textures/Objects/Consumable/Food/Baked/bread.rsi/plain.png",
            Act         = () =>
            {
                _polymorphableSystem.PolymorphEntity(args.Target, "AdminBreadSmite");
            },
            Impact  = LogImpact.Extreme,
            Message = Loc.GetString("admin-smite-become-bread-description")
        };

        args.Verbs.Add(bread);

        Verb mouse = new()
        {
            Text        = "Become Mouse",
            Category    = VerbCategory.Smite,
            IconTexture = "/Textures/Mobs/Animals/mouse.rsi/icon-0.png",
            Act         = () =>
            {
                _polymorphableSystem.PolymorphEntity(args.Target, "AdminMouseSmite");
            },
            Impact  = LogImpact.Extreme,
            Message = Loc.GetString("admin-smite-become-mouse-description")
        };

        args.Verbs.Add(mouse);

        if (TryComp <ActorComponent>(args.Target, out var actorComponent))
        {
            Verb ghostKick = new()
            {
                Text        = "Ghostkick",
                Category    = VerbCategory.Smite,
                IconTexture = "/Textures/Interface/gavel.svg.192dpi.png",
                Act         = () =>
                {
                    _ghostKickManager.DoDisconnect(actorComponent.PlayerSession.ConnectedClient, "Smitten.");
                },
                Impact  = LogImpact.Extreme,
                Message = Loc.GetString("admin-smite-ghostkick-description")
            };
            args.Verbs.Add(ghostKick);
        }

        if (TryComp <InventoryComponent>(args.Target, out var inventory))
        {
            Verb nyanify = new()
            {
                Text        = "Nyanify",
                Category    = VerbCategory.Smite,
                IconTexture = "/Textures/Clothing/Head/Hats/catears.rsi/icon.png",
                Act         = () =>
                {
                    var ears = Spawn("ClothingHeadHatCatEars", Transform(args.Target).Coordinates);
                    EnsureComp <UnremoveableComponent>(ears);
                    _inventorySystem.TryUnequip(args.Target, "head", true, true, false, inventory);
                    _inventorySystem.TryEquip(args.Target, ears, "head", true, true, false, inventory);
                },
                Impact  = LogImpact.Extreme,
                Message = Loc.GetString("admin-smite-nyanify-description")
            };
            args.Verbs.Add(nyanify);

            Verb killSign = new()
            {
                Text        = "Kill sign",
                Category    = VerbCategory.Smite,
                IconTexture = "/Textures/Objects/Misc/killsign.rsi/icon.png",
                Act         = () =>
                {
                    EnsureComp <KillSignComponent>(args.Target);
                },
                Impact  = LogImpact.Extreme,
                Message = Loc.GetString("admin-smite-kill-sign-description")
            };
            args.Verbs.Add(killSign);

            // TODO: Port cluwne outfit.
            Verb clown = new()
            {
                Text        = "Clown",
                Category    = VerbCategory.Smite,
                IconTexture = "/Textures/Objects/Fun/bikehorn.rsi/icon.png",
                Act         = () =>
                {
                    SetOutfitCommand.SetOutfit(args.Target, "ClownGear", EntityManager, (_, clothing) =>
                    {
                        if (HasComp <ClothingComponent>(clothing))
                        {
                            EnsureComp <UnremoveableComponent>(clothing);
                        }
                        EnsureComp <ClumsyComponent>(args.Target);
                    });
                },
                Impact  = LogImpact.Extreme,
                Message = Loc.GetString("admin-smite-clown-description")
            };
            args.Verbs.Add(clown);

            Verb maiden = new()
            {
                Text        = "Maid",
                Category    = VerbCategory.Smite,
                IconTexture = "/Textures/Clothing/Uniforms/Jumpskirt/janimaid.rsi/icon.png",
                Act         = () =>
                {
                    SetOutfitCommand.SetOutfit(args.Target, "JanitorMaidGear", EntityManager, (_, clothing) =>
                    {
                        if (HasComp <ClothingComponent>(clothing))
                        {
                            EnsureComp <UnremoveableComponent>(clothing);
                        }
                        EnsureComp <ClumsyComponent>(args.Target);
                    });
                },
                Impact  = LogImpact.Extreme,
                Message = Loc.GetString("admin-smite-maid-description")
            };
            args.Verbs.Add(maiden);
        }

        Verb angerPointingArrows = new()
        {
            Text        = "Anger Pointing Arrows",
            Category    = VerbCategory.Smite,
            IconTexture = "/Textures/Interface/Misc/pointing.rsi/pointing.png",
            Act         = () =>
            {
                EnsureComp <PointingArrowAngeringComponent>(args.Target);
            },
            Impact  = LogImpact.Extreme,
            Message = Loc.GetString("admin-smite-anger-pointing-arrows-description")
        };

        args.Verbs.Add(angerPointingArrows);

        Verb dust = new()
        {
            Text        = "Dust",
            Category    = VerbCategory.Smite,
            IconTexture = "/Textures/Objects/Materials/materials.rsi/ash.png",
            Act         = () =>
            {
                EntityManager.QueueDeleteEntity(args.Target);
                Spawn("Ash", Transform(args.Target).Coordinates);
                _popupSystem.PopupEntity(Loc.GetString("admin-smite-turned-ash-other", ("name", args.Target)), args.Target,
                                         Filter.Pvs(args.Target), PopupType.LargeCaution);
            },
            Impact  = LogImpact.Extreme,
            Message = Loc.GetString("admin-smite-dust-description"),
        };

        args.Verbs.Add(dust);

        Verb youtubeVideoSimulation = new()
        {
            Text        = "Buffering",
            Category    = VerbCategory.Smite,
            IconTexture = "/Textures/Interface/Misc/buffering_smite_icon.png",
            Act         = () =>
            {
                EnsureComp <BufferingComponent>(args.Target);
            },
            Impact  = LogImpact.Extreme,
            Message = Loc.GetString("admin-smite-buffering-description"),
        };

        args.Verbs.Add(youtubeVideoSimulation);

        Verb instrumentation = new()
        {
            Text        = "Become Instrument",
            Category    = VerbCategory.Smite,
            IconTexture = "/Textures/Objects/Fun/Instruments/h_synthesizer.rsi/icon.png",
            Act         = () =>
            {
                _polymorphableSystem.PolymorphEntity(args.Target, "AdminInstrumentSmite");
            },
            Impact  = LogImpact.Extreme,
            Message = Loc.GetString("admin-smite-become-instrument-description"),
        };

        args.Verbs.Add(instrumentation);

        Verb noGravity = new()
        {
            Text        = "Remove gravity",
            Category    = VerbCategory.Smite,
            IconTexture = "/Textures/Structures/Machines/gravity_generator.rsi/off.png",
            Act         = () =>
            {
                var grav = EnsureComp <MovementIgnoreGravityComponent>(args.Target);
                grav.Weightless = true;

                Dirty(grav);
            },
            Impact  = LogImpact.Extreme,
            Message = Loc.GetString("admin-smite-remove-gravity-description"),
        };

        args.Verbs.Add(noGravity);

        Verb reptilian = new()
        {
            Text        = "Reptilian Species Swap",
            Category    = VerbCategory.Smite,
            IconTexture = "/Textures/Objects/Fun/toys.rsi/plushie_lizard.png",
            Act         = () =>
            {
                _polymorphableSystem.PolymorphEntity(args.Target, "AdminLizardSmite");
            },
            Impact  = LogImpact.Extreme,
            Message = Loc.GetString("admin-smite-reptilian-species-swap-description"),
        };

        args.Verbs.Add(reptilian);

        Verb locker = new()
        {
            Text        = "Locker stuff",
            Category    = VerbCategory.Smite,
            IconTexture = "/Textures/Structures/Storage/closet.rsi/generic.png",
            Act         = () =>
            {
                var xform  = Transform(args.Target);
                var locker = Spawn("ClosetMaintenance", xform.Coordinates);
                if (TryComp <EntityStorageComponent>(locker, out var storage))
                {
                    _entityStorageSystem.ToggleOpen(args.Target, locker, storage);
                    _entityStorageSystem.Insert(args.Target, locker, storage);
                    _entityStorageSystem.ToggleOpen(args.Target, locker, storage);
                }
                _weldableSystem.ForceWeldedState(locker, true);
            },
            Impact  = LogImpact.Extreme,
            Message = Loc.GetString("admin-smite-locker-stuff-description"),
        };

        args.Verbs.Add(locker);

        Verb headstand = new()
        {
            Text        = "Headstand",
            Category    = VerbCategory.Smite,
            IconTexture = "/Textures/Interface/VerbIcons/refresh.svg.192dpi.png",
            Act         = () =>
            {
                EnsureComp <HeadstandComponent>(args.Target);
            },
            Impact  = LogImpact.Extreme,
            Message = Loc.GetString("admin-smite-headstand-description"),
        };

        args.Verbs.Add(headstand);

        Verb zoomIn = new()
        {
            Text        = "Zoom in",
            Category    = VerbCategory.Smite,
            IconTexture = "/Textures/Interface/AdminActions/zoom.png",
            Act         = () =>
            {
                var eye = EnsureComp <EyeComponent>(args.Target);

                eye.Zoom *= Vector2.One * 0.2f;

                Dirty(eye);
            },
            Impact  = LogImpact.Extreme,
            Message = Loc.GetString("admin-smite-zoom-in-description"),
        };

        args.Verbs.Add(zoomIn);

        Verb flipEye = new()
        {
            Text        = "Flip eye",
            Category    = VerbCategory.Smite,
            IconTexture = "/Textures/Interface/AdminActions/flip.png",
            Act         = () =>
            {
                var eye = EnsureComp <EyeComponent>(args.Target);

                eye.Zoom *= -1;

                Dirty(eye);
            },
            Impact  = LogImpact.Extreme,
            Message = Loc.GetString("admin-smite-flip-eye-description"),
        };

        args.Verbs.Add(flipEye);

        Verb runWalkSwap = new()
        {
            Text        = "Run Walk Swap",
            Category    = VerbCategory.Smite,
            IconTexture = "/Textures/Interface/AdminActions/run-walk-swap.png",
            Act         = () =>
            {
                var movementSpeed = EnsureComp <MovementSpeedModifierComponent>(args.Target);
                (movementSpeed.BaseSprintSpeed, movementSpeed.BaseWalkSpeed) = (movementSpeed.BaseWalkSpeed, movementSpeed.BaseSprintSpeed);

                Dirty(movementSpeed);

                _popupSystem.PopupEntity(Loc.GetString("admin-smite-run-walk-swap-prompt"), args.Target,
                                         Filter.Entities(args.Target), PopupType.LargeCaution);
            },
            Impact  = LogImpact.Extreme,
            Message = Loc.GetString("admin-smite-run-walk-swap-description"),
        };

        args.Verbs.Add(runWalkSwap);

        Verb backwardsAccent = new()
        {
            Text        = "Speak Backwards",
            Category    = VerbCategory.Smite,
            IconTexture = "/Textures/Interface/AdminActions/help-backwards.png",
            Act         = () =>
            {
                EnsureComp <BackwardsAccentComponent>(args.Target);
            },
            Impact  = LogImpact.Extreme,
            Message = Loc.GetString("admin-smite-speak-backwards-description"),
        };

        args.Verbs.Add(backwardsAccent);

        Verb disarmProne = new()
        {
            Text        = "Disarm Prone",
            Category    = VerbCategory.Smite,
            IconTexture = "/Textures/Interface/Actions/disarm.png",
            Act         = () =>
            {
                EnsureComp <DisarmProneComponent>(args.Target);
            },
            Impact  = LogImpact.Extreme,
            Message = Loc.GetString("admin-smite-disarm-prone-description"),
        };

        args.Verbs.Add(disarmProne);
    }
}
コード例 #12
0
        private void AddDebugVerbs(GetOtherVerbsEvent args)
        {
            if (!args.User.TryGetComponent <ActorComponent>(out var actor))
            {
                return;
            }

            var player = actor.PlayerSession;

            // Delete verb
            if (_groupController.CanCommand(player, "deleteentity"))
            {
                Verb verb = new();
                verb.Text        = Loc.GetString("delete-verb-get-data-text");
                verb.Category    = VerbCategory.Debug;
                verb.IconTexture = "/Textures/Interface/VerbIcons/delete.svg.192dpi.png";
                verb.Act         = () => args.Target.Delete();
                args.Verbs.Add(verb);
            }

            // Rejuvenate verb
            if (_groupController.CanCommand(player, "rejuvenate"))
            {
                Verb verb = new();
                verb.Text        = Loc.GetString("rejuvenate-verb-get-data-text");
                verb.Category    = VerbCategory.Debug;
                verb.IconTexture = "/Textures/Interface/VerbIcons/rejuvenate.svg.192dpi.png";
                verb.Act         = () => RejuvenateCommand.PerformRejuvenate(args.Target);
                args.Verbs.Add(verb);
            }

            // Control mob verb
            if (_groupController.CanCommand(player, "controlmob") &&
                args.User != args.Target &&
                args.User.HasComponent <MindComponent>() &&
                args.Target.TryGetComponent <MindComponent>(out var targetMind))
            {
                Verb verb = new();
                verb.Text     = Loc.GetString("control-mob-verb-get-data-text");
                verb.Category = VerbCategory.Debug;
                // TODO VERB ICON control mob icon
                verb.Act = () =>
                {
                    targetMind.Mind?.TransferTo(null);
                    player.ContentData()?.Mind?.TransferTo(args.Target, ghostCheckOverride: true);
                };
                args.Verbs.Add(verb);
            }

            // Make Sentient verb
            if (_groupController.CanCommand(player, "makesentient") &&
                args.User != args.Target &&
                !args.Target.HasComponent <MindComponent>())
            {
                Verb verb = new();
                verb.Text        = Loc.GetString("make-sentient-verb-get-data-text");
                verb.Category    = VerbCategory.Debug;
                verb.IconTexture = "/Textures/Interface/VerbIcons/sentient.svg.192dpi.png";
                verb.Act         = () => MakeSentientCommand.MakeSentient(args.Target);
                args.Verbs.Add(verb);
            }

            if (_adminManager.HasAdminFlag(player, AdminFlags.Fun))
            {
                Verb verb = new();
                verb.Text     = Loc.GetString("explode-verb-get-data-text");
                verb.Category = VerbCategory.Debug;
                verb.Act      = () =>
                {
                    var coords = args.Target.Transform.Coordinates;
                    Timer.Spawn(_gameTiming.TickPeriod, () => ExplosionHelper.SpawnExplosion(coords, 0, 1, 2, 1), CancellationToken.None);
                    if (args.Target.TryGetComponent(out SharedBodyComponent? body))
                    {
                        body.Gib();
                    }
                };
                args.Verbs.Add(verb);
            }

            // Set clothing verb
            if (_groupController.CanCommand(player, "setoutfit") &&
                args.Target.HasComponent <InventoryComponent>())
            {
                Verb verb = new();
                verb.Text        = Loc.GetString("set-outfit-verb-get-data-text");
                verb.Category    = VerbCategory.Debug;
                verb.IconTexture = "/Textures/Interface/VerbIcons/outfit.svg.192dpi.png";
                verb.Act         = () => _euiManager.OpenEui(new SetOutfitEui(args.Target), player);
                args.Verbs.Add(verb);
            }

            // In range unoccluded verb
            if (_groupController.CanCommand(player, "inrangeunoccluded"))
            {
                Verb verb = new();
                verb.Text        = Loc.GetString("in-range-unoccluded-verb-get-data-text");
                verb.Category    = VerbCategory.Debug;
                verb.IconTexture = "/Textures/Interface/VerbIcons/information.svg.192dpi.png";
                verb.Act         = () =>
                {
                    var message = args.User.InRangeUnOccluded(args.Target)
                    ? Loc.GetString("in-range-unoccluded-verb-on-activate-not-occluded")
                    : Loc.GetString("in-range-unoccluded-verb-on-activate-occluded");
                    args.Target.PopupMessage(args.User, message);
                };
                args.Verbs.Add(verb);
            }

            // Get Disposal tube direction verb
            if (_groupController.CanCommand(player, "tubeconnections") &&
                args.Target.TryGetComponent <IDisposalTubeComponent>(out var tube))
            {
                Verb verb = new();
                verb.Text        = Loc.GetString("tube-direction-verb-get-data-text");
                verb.Category    = VerbCategory.Debug;
                verb.IconTexture = "/Textures/Interface/VerbIcons/information.svg.192dpi.png";
                verb.Act         = () => tube.PopupDirections(args.User);
                args.Verbs.Add(verb);
            }

            // Make ghost role verb
            if (_groupController.CanCommand(player, "makeghostrole") &&
                !(args.Target.GetComponentOrNull <MindComponent>()?.HasMind ?? false))
            {
                Verb verb = new();
                verb.Text     = Loc.GetString("make-ghost-role-verb-get-data-text");
                verb.Category = VerbCategory.Debug;
                // TODO VERB ICON add ghost icon
                // Where is the national park service icon for haunted forests?
                verb.Act = () => _ghostRoleSystem.OpenMakeGhostRoleEui(player, args.Target.Uid);
                args.Verbs.Add(verb);
            }

            // Configuration verb. Is this even used for anything!?
            if (_groupController.CanAdminMenu(player) &&
                args.Target.TryGetComponent <ConfigurationComponent>(out var config))
            {
                Verb verb = new();
                verb.Text        = Loc.GetString("configure-verb-get-data-text");
                verb.IconTexture = "/Textures/Interface/VerbIcons/settings.svg.192dpi.png";
                verb.Category    = VerbCategory.Debug;
                verb.Act         = () => config.OpenUserInterface(actor);
                args.Verbs.Add(verb);
            }

            // Add reagent verb
            if (_adminManager.HasAdminFlag(player, AdminFlags.Fun) &&
                args.Target.HasComponent <SolutionContainerManagerComponent>())
            {
                Verb verb = new();
                verb.Text        = Loc.GetString("admin-add-reagent-verb-get-data-text");
                verb.Category    = VerbCategory.Debug;
                verb.IconTexture = "/Textures/Interface/VerbIcons/spill.svg.192dpi.png";
                verb.Act         = () => _euiManager.OpenEui(new AdminAddReagentEui(args.Target), player);

                // TODO CHEMISTRY
                // Add reagent ui broke after solution refactor. Needs fixing
                verb.Disabled = true;
                verb.Tooltip  = "Currently non functional after solution refactor.";
                verb.Priority = -2;

                args.Verbs.Add(verb);
            }
        }
    }