예제 #1
0
        /// <summary>
        /// Finds 1-3 random, dead entities across the station
        /// and turns them into zombies.
        /// </summary>
        public override void Started()
        {
            base.Started();
            List <MobStateComponent> deadList = new();

            foreach (var mobState in EntityManager.EntityQuery <MobStateComponent>())
            {
                if (mobState.IsDead() || mobState.IsCritical())
                {
                    deadList.Add(mobState);
                }
            }
            RobustRandom.Shuffle(deadList);

            var toInfect = RobustRandom.Next(1, 3);

            foreach (var target in deadList)
            {
                if (toInfect-- == 0)
                {
                    break;
                }

                _zombify.ZombifyEntity(target.Owner);
            }
        }
    /// <summary>
    /// Finds 2-5 random, alive entities that can host diseases
    /// and gives them a randomly selected disease.
    /// They all get the same disease.
    /// </summary>
    public override void Started()
    {
        base.Started();
        HashSet <EntityUid>            stationsToNotify = new();
        List <DiseaseCarrierComponent> aliveList        = new();

        foreach (var(carrier, mobState) in EntityManager.EntityQuery <DiseaseCarrierComponent, MobStateComponent>())
        {
            if (!mobState.IsDead())
            {
                aliveList.Add(carrier);
            }
        }
        RobustRandom.Shuffle(aliveList);

        // We're going to filter the above out to only alive mobs. Might change after future mobstate rework
        var toInfect = RobustRandom.Next(2, 5);

        var diseaseName = RobustRandom.Pick(NotTooSeriousDiseases);

        if (!PrototypeManager.TryIndex(diseaseName, out DiseasePrototype? disease))
        {
            return;
        }

        // Now we give it to people in the list of living disease carriers earlier
        foreach (var target in aliveList)
        {
            if (toInfect-- == 0)
            {
                break;
            }

            _diseaseSystem.TryAddDisease(target.Owner, disease, target);

            var station = StationSystem.GetOwningStation(target.Owner);
            if (station == null)
            {
                continue;
            }
            stationsToNotify.Add((EntityUid)station);
        }
    }
예제 #3
0
    public override void Started()
    {
        base.Started();

        var allApcs   = EntityQuery <ApcComponent>().ToList();
        var toDisable = Math.Min(RobustRandom.Next(3, 7), allApcs.Count);

        if (toDisable == 0)
        {
            return;
        }

        RobustRandom.Shuffle(allApcs);

        for (var i = 0; i < toDisable; i++)
        {
            _apcSystem.ApcToggleBreaker(allApcs[i].Owner, allApcs[i]);
        }
    }
    public override void Started()
    {
        base.Started();

        var spawnLocations = EntityManager.EntityQuery <VentCritterSpawnLocationComponent, TransformComponent>().ToList();

        RobustRandom.Shuffle(spawnLocations);

        var spawnAmount = RobustRandom.Next(7, 15); // A small colony of critters.

        for (int i = 0; i < spawnAmount && i < spawnLocations.Count - 1; i++)
        {
            var spawnChoice = RobustRandom.Pick(SpawnedPrototypeChoices);
            if (RobustRandom.Prob(0.01f) || i == 0) //small chance for multiple, but always at least 1
            {
                spawnChoice = "SpawnPointGhostRatKing";
            }

            var coords = spawnLocations[i].Item2.Coordinates;
            Sawmill.Info($"Spawning mouse {spawnChoice} at {coords}");
            EntityManager.SpawnEntity(spawnChoice, coords);
        }
    }
    public override void Started()
    {
        base.Started();
        var spawnChoice    = RobustRandom.Pick(SpawnedPrototypeChoices);
        var spawnLocations = EntityManager.EntityQuery <VentCritterSpawnLocationComponent>().ToList();

        RobustRandom.Shuffle(spawnLocations);

        var spawnAmount = RobustRandom.Next(4, 12); // A small colony of critters.

        Sawmill.Info($"Spawning {spawnAmount} of {spawnChoice}");
        foreach (var location in spawnLocations)
        {
            if (spawnAmount-- == 0)
            {
                break;
            }

            var coords = EntityManager.GetComponent <TransformComponent>(location.Owner);

            EntityManager.SpawnEntity(spawnChoice, coords.Coordinates);
        }
    }
    public override void Started()
    {
        base.Started();
        HashSet <EntityUid> stationsToNotify = new();

        var targetList = EntityManager.EntityQuery <SentienceTargetComponent>().ToList();

        RobustRandom.Shuffle(targetList);

        var toMakeSentient = RobustRandom.Next(2, 5);
        var groups         = new HashSet <string>();

        foreach (var target in targetList)
        {
            if (toMakeSentient-- == 0)
            {
                break;
            }

            MakeSentientCommand.MakeSentient(target.Owner, EntityManager);
            EntityManager.RemoveComponent <SentienceTargetComponent>(target.Owner);
            var comp = EntityManager.AddComponent <GhostTakeoverAvailableComponent>(target.Owner);
            comp.RoleName        = EntityManager.GetComponent <MetaDataComponent>(target.Owner).EntityName;
            comp.RoleDescription = Loc.GetString("station-event-random-sentience-role-description", ("name", comp.RoleName));
            groups.Add(target.FlavorKind);
        }

        if (groups.Count == 0)
        {
            return;
        }

        var groupList = groups.ToList();
        var kind1     = groupList.Count > 0 ? groupList[0] : "???";
        var kind2     = groupList.Count > 1 ? groupList[1] : "???";
        var kind3     = groupList.Count > 2 ? groupList[2] : "???";

        var entSysMgr     = IoCManager.Resolve <IEntitySystemManager>();
        var stationSystem = entSysMgr.GetEntitySystem <StationSystem>();
        var chatSystem    = entSysMgr.GetEntitySystem <ChatSystem>();

        foreach (var target in targetList)
        {
            var station = stationSystem.GetOwningStation(target.Owner);
            if (station == null)
            {
                continue;
            }
            stationsToNotify.Add((EntityUid)station);
        }
        foreach (var station in stationsToNotify)
        {
            chatSystem.DispatchStationAnnouncement(
                (EntityUid)station,
                Loc.GetString("station-event-random-sentience-announcement",
                              ("kind1", kind1), ("kind2", kind2), ("kind3", kind3), ("amount", groupList.Count),
                              ("data", Loc.GetString($"random-sentience-event-data-{RobustRandom.Next(1, 6)}")),
                              ("strength", Loc.GetString($"random-sentience-event-strength-{RobustRandom.Next(1, 8)}"))),
                playDefaultSound: false,
                colorOverride: Color.Gold
                );
        }
    }