Skip to content
This repository has been archived by the owner on Jun 28, 2024. It is now read-only.

Новые мобы (гопники) #23

Closed
wants to merge 14 commits into from
4 changes: 2 additions & 2 deletions .github/ISSUE_TEMPLATE/config.yml
Original file line number Diff line number Diff line change
@@ -1,7 +1,7 @@
contact_links:
- name: Предложение
url: https://discord.com/invite/CPacm3dfrA
url: https://discord.gg/CuWu6kSznf #A-13
about: Свои предложения можете оставлять в соответствующем канале Discord.
- name: Сообщить об уязвимости
url: https://discord.com/invite/CPacm3dfrA
url: https://discord.gg/CuWu6kSznf #A-13
about: Пожалуйста, сообщайте о серьезных эксплойтах и уязвимостях безопасности lemird (634710558364663819) или 13lackhawk (236910741146304515) в Discord.
2 changes: 1 addition & 1 deletion Content.Client/Launcher/LauncherConnectingGui.xaml.cs
Original file line number Diff line number Diff line change
Expand Up @@ -47,7 +47,7 @@ public LauncherConnectingGui(LauncherConnecting state, IRobustRandom random,
ChangeLoginTip();
ReconnectButton.OnPressed += ReconnectButtonPressed;
RetryButton.OnPressed += ReconnectButtonPressed;
DiscordButton.OnPressed += _ => IoCManager.Resolve<IUriOpener>().OpenUri("https://discord.gg/CPacm3dfrA"); // A-13
DiscordButton.OnPressed += _ => IoCManager.Resolve<IUriOpener>().OpenUri("https://discord.gg/CuWu6kSznf"); // A-13
ExitButton.OnPressed += _ => _state.Exit();

var addr = state.Address;
Expand Down
2 changes: 1 addition & 1 deletion Content.Docfx/index.md
Original file line number Diff line number Diff line change
Expand Up @@ -6,4 +6,4 @@

## Links

[Website](https://spacestation14.io/) | [Discord](https://discord.gg/t2jac3p) | [Forum](https://forum.spacestation14.io/) | [Steam](https://store.steampowered.com/app/1255460/Space_Station_14/) | [Standalone Download](https://spacestation14.io/about/nightlies/)
[Website](https://spacestation14.io/) | [Discord](https://discord.gg/CuWu6kSznf) | [Forum](https://forum.spacestation14.io/) | [Steam](https://store.steampowered.com/app/1255460/Space_Station_14/) | [Standalone Download](https://spacestation14.io/about/nightlies/)
15 changes: 13 additions & 2 deletions Content.Server/Administration/Managers/AdminManager.cs
Original file line number Diff line number Diff line change
Expand Up @@ -19,12 +19,13 @@
using Robust.Shared.Toolshed;
using Robust.Shared.Toolshed.Errors;
using Robust.Shared.Utility;

using Content.Server.Andromeda.AdministrationNotifications.GameTicking; //A-13 AdminNotifications

namespace Content.Server.Administration.Managers
{
public sealed partial class AdminManager : IAdminManager, IPostInjectInit, IConGroupControllerImplementation
{
[Dependency] private readonly IEntityManager _entityManager = default!; //A-13 AdminNotifications
[Dependency] private readonly IPlayerManager _playerManager = default!;
[Dependency] private readonly IServerDbManager _dbManager = default!;
[Dependency] private readonly IConfigurationManager _cfg = default!;
Expand Down Expand Up @@ -342,7 +343,7 @@ private void PlayerStatusChanged(object? sender, SessionStatusEventArgs e)
}
else if (e.NewStatus == SessionStatus.Disconnected)
{
if (_admins.Remove(e.Session, out var reg ) && _cfg.GetCVar(CCVars.AdminAnnounceLogout))
if (_admins.TryGetValue(e.Session, out var reg ) && _cfg.GetCVar(CCVars.AdminAnnounceLogout)) //A-13 AdminNotifications
{
if (reg.Data.Stealth)
{
Expand All @@ -355,6 +356,12 @@ private void PlayerStatusChanged(object? sender, SessionStatusEventArgs e)
_chat.SendAdminAnnouncement(Loc.GetString("admin-manager-admin-logout-message",
("name", e.Session.Name)));
}
//A-13 AdminNotifications start
var logoutEvent = new AdminLoggedOutEvent(e.Session);
_entityManager.EventBus.RaiseEvent(EventSource.Local, logoutEvent);

_admins.Remove(e.Session);
//A-13 AdminNotifications end
}
}
}
Expand Down Expand Up @@ -398,6 +405,10 @@ private async void LoginAdminMaybe(ICommonSession session)
_chat.SendAdminAnnouncement(Loc.GetString("admin-manager-admin-login-message",
("name", session.Name)));
}
//A-13 AdminNotifications start
var loginEvent = new AdminLoggedInEvent(session);
_entityManager.EventBus.RaiseEvent(EventSource.Local, loginEvent);
//A-13 AdminNotifications end
}

SendPermsChangedEvent(session);
Expand Down
Original file line number Diff line number Diff line change
@@ -0,0 +1,82 @@
using Content.Shared.Administration;
using Robust.Shared;
using Robust.Shared.Configuration;
using Robust.Shared.Player;
using System.Net.Http;
using System.Text.Json;
using System.Text;
using Content.Server.Discord;
using Content.Shared.CCVar;
using Content.Shared.Andromeda.CCVar;
using Content.Server.Andromeda.AdministrationNotifications.GameTicking;

namespace Content.Server.Andromeda.AdministrationNotifications
{

public sealed class AdminNotificationsSystem : EntitySystem
{
[Dependency] private readonly IConfigurationManager _config = default!;
private ISawmill _sawmill = default!;
private readonly HttpClient _httpClient = new();
private string _webhookUrl = String.Empty;
private int _adminCount = 0;

public override void Initialize()
{
_sawmill = Logger.GetSawmill("admin_notifications");
SubscribeLocalEvent<AdminLoggedInEvent>(OnAdminLoggedIn);
SubscribeLocalEvent<AdminLoggedOutEvent>(OnAdminLoggedOut);
_config.OnValueChanged(AndromedaCCVars.DiscordAdminWebhook, value => _webhookUrl = value, true);
}

private async void SendDiscordMessage(WebhookPayload payload)
{
var request = await _httpClient.PostAsync(_webhookUrl,
new StringContent(JsonSerializer.Serialize(payload), Encoding.UTF8, "application/json"));

_sawmill.Debug($"Вебхук Discord в формате json: {JsonSerializer.Serialize(payload)}");

var content = await request.Content.ReadAsStringAsync();
if (!request.IsSuccessStatusCode)
{
_sawmill.Error($"Discord вернул неверный код статуса при публикации сообщения: {request.StatusCode}\nResponse: {content}");
return;
}
}

private void OnAdminLoggedIn(AdminLoggedInEvent e)
{
_adminCount++;
SendAdminStatusUpdate(e.Session, "вошёл", 0x00FF00);
}

private void OnAdminLoggedOut(AdminLoggedOutEvent e)
{
_adminCount--;
SendAdminStatusUpdate(e.Session, "вышел", 0xFF0000);
}

private void SendAdminStatusUpdate(ICommonSession session, string action, int color)
{
if (String.IsNullOrEmpty(_webhookUrl))
return;

var message = $"{session.Name} {action}. Всего администраторов онлайн: {_adminCount}";

var payload = new WebhookPayload
{
Username = "Отчёт входов админов",
Embeds = new List<WebhookEmbed>
{
new()
{
Description = message,
Color = color,
},
},
};

SendDiscordMessage(payload);
}
}
}
Original file line number Diff line number Diff line change
@@ -0,0 +1,13 @@
using Robust.Shared.Player;

namespace Content.Server.Andromeda.AdministrationNotifications.GameTicking;

public sealed class AdminLoggedInEvent : EntityEventArgs
{
public ICommonSession Session { get; }

public AdminLoggedInEvent(ICommonSession session)
{
Session = session;
}
}
Original file line number Diff line number Diff line change
@@ -0,0 +1,13 @@
using Robust.Shared.Player;

namespace Content.Server.Andromeda.AdministrationNotifications.GameTicking;

public sealed class AdminLoggedOutEvent : EntityEventArgs
{
public ICommonSession Session { get; }

public AdminLoggedOutEvent(ICommonSession session)
{
Session = session;
}
}
116 changes: 75 additions & 41 deletions Content.Server/Antag/AntagSelectionSystem.cs
Original file line number Diff line number Diff line change
Expand Up @@ -17,9 +17,9 @@
using System.Linq;
using Content.Shared.Chat;
using Robust.Shared.Enums;
using Content.Server.Corvax.Sponsors; //A-13
using Content.Server.Andromeda.Roles; //A-13
using Robust.Server.Player; //A-13
using Content.Server.Corvax.Sponsors; //A-13 SponsorAntag
using Content.Server.Andromeda.Roles; //A-13 SponsorAntag
using Robust.Server.Player; //A-13 SponsorAntag

namespace Content.Server.Antag;

Expand All @@ -30,8 +30,8 @@ public sealed class AntagSelectionSystem : GameRuleSystem<GameRuleComponent>
[Dependency] private readonly JobSystem _jobs = default!;
[Dependency] private readonly MindSystem _mindSystem = default!;
[Dependency] private readonly SharedRoleSystem _roleSystem = default!;
[Dependency] private readonly SponsorsManager _sponsorsManager = default!; //A-13
[Dependency] private readonly IPlayerManager _playerSystem = default!; //A-13
[Dependency] private readonly SponsorsManager _sponsorsManager = default!; //A-13 SponsorAntag
[Dependency] private readonly IPlayerManager _playerSystem = default!; //A-13 SponsorAntag

#region Eligible Player Selection
/// <summary>
Expand All @@ -57,7 +57,17 @@ public List<EntityUid> GetEligiblePlayers(IEnumerable<ICommonSession> playerSess
foreach (var player in playerSessions)
{
if (IsPlayerEligible(player, antagPrototype, includeAllJobs, acceptableAntags, ignorePreferences, allowNonHumanoids, customExcludeCondition))
{
//A-13 No Thief-Agents system v5 start
if (player.AttachedEntity.HasValue && HasComp<ThiefCheckComponent>(player.AttachedEntity.Value))
{
Log.Warning($"[AntagSelectionSystem] Игрок {player.Name} пропущен для избежания дублирования.");
continue;
}
//A-13 No Thief-Agents system v5 end

eligiblePlayers.Add(player.AttachedEntity!.Value);
}
}

return eligiblePlayers;
Expand Down Expand Up @@ -198,6 +208,7 @@ public int CalculateAntagCount(int playerCount, int playersPerAntag, int maxAnta
/// <returns>Up to the specified count of elements from all provided lists</returns>
public List<EntityUid> ChooseAntags(int count, params List<EntityUid>[] eligiblePlayerLists)
{
Log.Info($"[AntagSelectionSystem] Вход в ChooseAntags(1)"); //A-13 SponsorAntag
var chosenPlayers = new List<EntityUid>();
foreach (var playerList in eligiblePlayerLists)
{
Expand All @@ -217,15 +228,40 @@ public List<EntityUid> ChooseAntags(int count, params List<EntityUid>[] eligible
return chosenPlayers;
}
/// <summary>
/// Helper method to choose antags from a list
/// Helper method to choose antags from a list, giving priority to sponsored players.
/// </summary>
/// <param name="eligiblePlayers">List of eligible players</param>
/// <param name="count">How many to choose</param>
/// <returns>Up to the specified count of elements from the provided list</returns>
public List<EntityUid> ChooseAntags(int count, List<EntityUid> eligiblePlayers)
{
Log.Info($"[AntagSelectionSystem] Вход в ChooseAntags(2)"); //A-13 SponsorAntag
var chosenPlayers = new List<EntityUid>();

//A-13 SponsorAntag start
var sponsorPrefList = new List<EntityUid>();
foreach (var player in eligiblePlayers)
{
if (_playerSystem.TryGetSessionByEntity(player, out var session) &&
//Используйте "session.UserId" для тестов, закомментировав часть кода "_sponsorsManager":
//session.UserId == new Guid("{ВАШ UserId}"))
_sponsorsManager.TryGetInfo(session.UserId, out var sponsorData) && sponsorData.ExtraSlots >= 7)
{
sponsorPrefList.Add(player);
Log.Info($"[AntagSelectionSystem] Игрок с именем {session.Name} добавлен в список спонсорских кандидатов на роль антагониста.");
}
}

while (sponsorPrefList.Count > 0 && count > 0)
{
var player = RobustRandom.PickAndTake(sponsorPrefList);
eligiblePlayers.Remove(player);
chosenPlayers.Add(player);
count--;
Log.Info($"[AntagSelectionSystem] Игрок {player} выбран как спонсорский антагонист. Оставшееся количество мест: {count}");
}
//A-13 SponsorAntag end

for (var i = 0; i < count; i++)
{
if (eligiblePlayers.Count == 0)
Expand All @@ -245,6 +281,7 @@ public List<EntityUid> ChooseAntags(int count, List<EntityUid> eligiblePlayers)
/// <returns>Up to the specified count of elements from all provided lists</returns>
public List<ICommonSession> ChooseAntags(int count, params List<ICommonSession>[] eligiblePlayerLists)
{
Log.Info($"[AntagSelectionSystem] Вход в ChooseAntagsICommonSession(1)"); //A-13 SponsorAntag
var chosenPlayers = new List<ICommonSession>();
foreach (var playerList in eligiblePlayerLists)
{
Expand All @@ -254,37 +291,6 @@ public List<ICommonSession> ChooseAntags(int count, params List<ICommonSession>[
playerList.Remove(chosenPlayer);
}

// A-13 SponsorAntag start
/*
var sponsorPrefList = new List<ICommonSession>();
var allPlayers = _playerSystem.Sessions.ToList();
foreach (var player in allPlayers)
{
// A-13 Use this for tests only
//if (player.UserId == new Guid("{c48a881f-25c0-4ea6-8489-1aaba1831ce3}"))
if (_sponsorsManager.TryGetInfo(player.UserId, out var sponsor) && sponsor.ExtraSlots >= 7) //Checker
{
Logger.InfoS("SPONSOR", "Selected a sponsor antag!1");
sponsorPrefList.Add(player);
}
}

while (sponsorPrefList.Count > 0 && count > 0)
{
var player = RobustRandom.PickAndTake(sponsorPrefList);
playerList.Remove(player);
chosenPlayers.Add(player);
count -= 1;
Logger.InfoS("SPONSOR", "Selected a sponsor antag!");
}
// If we have reached the desired number of players, exit the loop
//if (chosenPlayers.Count >= count)
//{
// break;
//}
// A-13 SponsorAntag end
*/

//If we have reached the desired number of players, skip
if (chosenPlayers.Count >= count)
continue;
Expand All @@ -302,15 +308,43 @@ public List<ICommonSession> ChooseAntags(int count, params List<ICommonSession>[
/// <returns>Up to the specified count of elements from the provided list</returns>
public List<ICommonSession> ChooseAntags(int count, List<ICommonSession> eligiblePlayers)
{
Log.Info($"[AntagSelectionSystem] Вход в ChooseAntagsICommonSession(2)"); //A-13 SponsorAntag
var chosenPlayers = new List<ICommonSession>();

for (int i = 0; i < count; i++)
//A-13 SponsorAntag start
var sponsorPrefList = new List<ICommonSession>();
foreach (var player in eligiblePlayers)
{
if (eligiblePlayers.Count == 0)
break;
//Используйте "player.UserId" для тестов, закомментировав часть кода "_sponsorsManager":
//if (player.UserId == new Guid("{ВАШ UserId}"))
if (_sponsorsManager.TryGetInfo(player.UserId, out var sponsorData) && sponsorData.ExtraSlots >= 7)
{
Log.Info($"[AntagSelectionSystem] Игрок {player} прошёл проверку на спонсорство.");
sponsorPrefList.Add(player);
}
else
{
Log.Warning($"[AntagSelectionSystem] Игрок {player} не прошёл проверку на спонсорство или его уровень слишком маленький.");
}
}

chosenPlayers.Add(RobustRandom.PickAndTake(eligiblePlayers));
while (sponsorPrefList.Count > 0 && count > 0)
{
var player = RobustRandom.PickAndTake(sponsorPrefList);
eligiblePlayers.Remove(player);
chosenPlayers.Add(player);
count--;
Log.Info($"[AntagSelectionSystem] Игрок {player} выбран как спонсорский антаг.");
}

while (sponsorPrefList.Count <= 0 && eligiblePlayers.Count > 0 && count > 0)
{
var player = RobustRandom.PickAndTake(eligiblePlayers);
chosenPlayers.Add(player);
count--;
Log.Info($"[AntagSelectionSystem] Игрок {player} выбран как НЕ спонсорский антаг.");
}
// A-13 SponsorAntag end

return chosenPlayers;
}
Expand Down
7 changes: 0 additions & 7 deletions Content.Server/Dragon/DragonSystem.cs
Original file line number Diff line number Diff line change
Expand Up @@ -95,13 +95,6 @@ public override void Update(float frameTime)
}

comp.RiftAccumulator += frameTime;

// Delete it, naughty dragon!
if (comp.RiftAccumulator >= comp.RiftMaxAccumulator)
{
Roar(uid, comp);
QueueDel(uid);
}
}
}

Expand Down
Loading
Loading