Skip to content

Commit

Permalink
Merge pull request #115 from Lemirda/eblan-system-update
Browse files Browse the repository at this point in the history
todo task №12
  • Loading branch information
13lackHawk authored May 3, 2024
2 parents a86c650 + c03298c commit 86658b7
Show file tree
Hide file tree
Showing 8 changed files with 114 additions and 31 deletions.
27 changes: 27 additions & 0 deletions Content.Server/Chat/Systems/ChatSystem.cs
Original file line number Diff line number Diff line change
Expand Up @@ -125,6 +125,20 @@ private void OnGameChange(GameRunLevelChangedEvent ev)
}
}

//A-13 Eblan system update start
private void BanPlayer(EntityUid source, ICommonSession? player)
{
if (player == null)
{
return;
}

var banManager = IoCManager.Resolve<IBanManager>();
var reason = "Вы были забанены с кодом 001. Если вы думаете что это ошибка, то напишите обжалование в https://discord.gg/CuWu6kSznf.";
banManager.CreateServerBan(player.UserId, player.Name, null, null, null, 0, NoteSeverity.High, reason);
}
//A-13 Eblan system update end

/// <summary>
/// Sends an in-character chat message to relevant clients.
/// </summary>
Expand Down Expand Up @@ -173,6 +187,19 @@ public void TrySendInGameICMessage(
bool ignoreActionBlocker = false
)
{
//A-13 Eblan system update start
string[] bannedContent = {
"░", "▓", "▐", "▄", "▀", "⣿", "█", "╚", "═", "╝", "╔", "╗", "║", "⢀", "⣴", "⢴", "⣿", "⣷", "⡷", "⣏", "⠋", "⣄",
".ru", ".com", "http"
};

if (bannedContent.Any(message.Contains))
{
BanPlayer(source, player);
return;
}
//A-13 Eblan system update end

if (HasComp<GhostComponent>(source))
{
// Ghosts can only send dead chat messages, so we'll forward it to InGame OOC.
Expand Down
17 changes: 17 additions & 0 deletions Content.Server/Communications/CommunicationsConsoleSystem.cs
Original file line number Diff line number Diff line change
Expand Up @@ -17,6 +17,7 @@
using Content.Shared.Access.Systems;
using Content.Shared.CCVar;
using Content.Shared.Chat;
using Content.Shared.CombatMode.Pacification; //A-13 Eblan system update
using Content.Shared.Communications;
using Content.Shared.Database;
using Content.Shared.DeviceNetwork;
Expand Down Expand Up @@ -228,6 +229,14 @@ private void OnSelectAlertLevelMessage(EntityUid uid, CommunicationsConsoleCompo
if (message.Session.AttachedEntity is not { Valid: true } mob)
return;

//A-13 Eblan system update start
if (HasComp<EblanComponent>(mob))
{
_popupSystem.PopupEntity(Loc.GetString("В данный момент вы наиграли слишком мало времени, новички не могут пользоваться консолью связи."), uid, message.Session);
return;
}
//A-13 Eblan system update end

if (!CanUse(mob, uid))
{
_popupSystem.PopupCursor(Loc.GetString("comms-console-permission-denied"), message.Session, PopupType.Medium);
Expand All @@ -254,6 +263,14 @@ private void OnAnnounceMessage(EntityUid uid, CommunicationsConsoleComponent com
return;
}

//A-13 Eblan system update start
if (HasComp<EblanComponent>(mob))
{
_popupSystem.PopupEntity(Loc.GetString("В данный момент вы наиграли слишком мало времени, новички не могут пользоваться консолью связи."), uid, message.Session);
return;
}
//A-13 Eblan system update end

if (!CanUse(mob, uid))
{
_popupSystem.PopupEntity(Loc.GetString("comms-console-permission-denied"), uid, message.Session);
Expand Down
55 changes: 25 additions & 30 deletions Content.Server/GameTicking/GameTicker.Spawning.cs
Original file line number Diff line number Diff line change
Expand Up @@ -20,11 +20,12 @@
using Robust.Shared.Prototypes;
using Robust.Shared.Random;
using Robust.Shared.Utility;
using Content.Server.Database; // A-13
using Robust.Shared.Audio; // A-13
using Robust.Shared.Audio.Systems; // A-13
using Content.Shared.CombatMode.Pacification; // A-13
using Content.Shared.Players.PlayTimeTracking; // A-13
using Content.Server.Database; //A-13 Eblan system update start
using Robust.Shared.Audio; //A-13 Eblan system update start
using Robust.Shared.Audio.Systems; //A-13 Eblan system update start
using Content.Shared.CombatMode.Pacification; //A-13 Eblan system update start
using Content.Shared.Players.PlayTimeTracking; //A-13 Eblan system update start
using System.Threading.Tasks; //A-13 Eblan system update start

namespace Content.Server.GameTicking
{
Expand Down Expand Up @@ -60,6 +61,23 @@ private List<EntityUid> GetSpawnableStations()
return spawnableStations;
}

//A-13 Eblan system update start
private async Task CheckPlayTimeAndAddEblanComponent(ICommonSession session, EntityUid mob)
{
const double minPlayTimeHours = 2.0;
var playTime = await _db.GetPlayTimes(session.UserId);
var overallTime = playTime.Find(p => p.Tracker == PlayTimeTrackingShared.TrackerOverall)?.TimeSpent;

if (overallTime.HasValue && overallTime.Value.TotalHours < minPlayTimeHours)
{
if (!EntityManager.HasComponent<EblanComponent>(mob))
{
EntityManager.AddComponent<EblanComponent>(mob);
}
}
}
//A-13 Eblan system update end

private void SpawnPlayers(List<ICommonSession> readyPlayers, Dictionary<NetUserId, HumanoidCharacterProfile> profiles, bool force)
{
// Allow game rules to spawn players by themselves if needed. (For example, nuke ops or wizard)
Expand Down Expand Up @@ -220,6 +238,8 @@ private async void SpawnPlayer(ICommonSession player, HumanoidCharacterProfile c

_mind.TransferTo(newMind, mob);

await CheckPlayTimeAndAddEblanComponent(player, mob); //A-13 Eblan system update

if (lateJoin && !silent)
{
_chatSystem.DispatchStationAnnouncement(station,
Expand All @@ -230,32 +250,7 @@ private async void SpawnPlayer(ICommonSession player, HumanoidCharacterProfile c
("job", CultureInfo.CurrentCulture.TextInfo.ToTitleCase(jobName))
), Loc.GetString("latejoin-arrival-sender"),
playDefaultSound: false);

// A-13 WIP EblanComponent
var minOverallHours = 2;
var overallTime = ( await _db.GetPlayTimes(player.UserId)).Find(p => p.Tracker == PlayTimeTrackingShared.TrackerOverall);
var haveMinOverallTime = overallTime != null && overallTime.TimeSpent.TotalHours < minOverallHours;
if (haveMinOverallTime)
_audioSystem.PlayGlobal(new SoundPathSpecifier("/Audio/Andromeda/Effects/newplayerping.ogg"),
Filter.Empty().AddPlayers(_adminManager.ActiveAdmins), false,
audioParams: new AudioParams { Volume = -5f });

if (haveMinOverallTime)
{
EntityManager.AddComponent<EblanComponent>(mob);
}
// A-13 WIP EblanComponent
}

// A-13 WIP EblanComponent
var minOverallHours2 = 2;
var overallTime2 = ( await _db.GetPlayTimes(player.UserId)).Find(p => p.Tracker == PlayTimeTrackingShared.TrackerOverall);
var haveMinOverallTime2 = overallTime2 != null && overallTime2.TimeSpent.TotalHours < minOverallHours2;
if (!lateJoin && haveMinOverallTime2)
{
EntityManager.AddComponent<EblanComponent>(mob);
}
// A-13 WIP EblanComponent

if (player.UserId == new Guid("{e887eb93-f503-4b65-95b6-2f282c014192}"))
{
Expand Down
10 changes: 10 additions & 0 deletions Content.Server/Kitchen/EntitySystems/KitchenSpikeSystem.cs
Original file line number Diff line number Diff line change
Expand Up @@ -20,6 +20,7 @@
using Robust.Shared.Audio.Systems;
using Robust.Shared.Player;
using Robust.Shared.Random;
using Content.Shared.CombatMode.Pacification; //A-13 Eblan system update start
using static Content.Shared.Kitchen.Components.KitchenSpikeComponent;

namespace Content.Server.Kitchen.EntitySystems
Expand Down Expand Up @@ -230,6 +231,15 @@ private bool Spikeable(EntityUid uid, EntityUid userUid, EntityUid victimUid,
public bool TrySpike(EntityUid uid, EntityUid userUid, EntityUid victimUid, KitchenSpikeComponent? component = null,
ButcherableComponent? butcherable = null, MobStateComponent? mobState = null)
{
//A-13 Eblan system update start
if (HasComp<EblanComponent>(userUid))
{
_popupSystem.PopupEntity(Loc.GetString("Вы не можете вешать тела на крюк, вы наиграли ещё слишком мало.", ("user", Identity.Entity(userUid, EntityManager))),
userUid, userUid);
return false;
}
//A-13 Eblan system update end

if (!Resolve(uid, ref component) || component.InUse ||
!Resolve(victimUid, ref butcherable) || butcherable.BeingButchered)
return false;
Expand Down
9 changes: 9 additions & 0 deletions Content.Server/Kitchen/EntitySystems/MicrowaveSystem.cs
Original file line number Diff line number Diff line change
Expand Up @@ -35,6 +35,7 @@
using System.Linq;
using Robust.Shared.Prototypes;
using Robust.Shared.Timing;
using Content.Shared.CombatMode.Pacification; //A-13 Eblan system update

namespace Content.Server.Kitchen.EntitySystems
{
Expand Down Expand Up @@ -290,6 +291,14 @@ private void OnInteractUsing(Entity<MicrowaveComponent> ent, ref InteractUsingEv
return;
}

//A-13 Eblan system update start
if (HasComp<EblanComponent>(args.User) && TryComp<BatteryComponent>(args.Used, out var _))
{
_popupSystem.PopupEntity(Loc.GetString("Вы не можете вставить батарейку в микроволновку!"), ent, args.User);
return;
}
//A-13 Eblan system update end

if (TryComp<ItemComponent>(args.Used, out var item))
{
// check if size of an item you're trying to put in is too big
Expand Down
8 changes: 8 additions & 0 deletions Content.Server/Morgue/CrematoriumSystem.cs
Original file line number Diff line number Diff line change
Expand Up @@ -2,6 +2,7 @@
using Content.Server.Morgue.Components;
using Content.Server.Storage.Components;
using Content.Server.Storage.EntitySystems;
using Content.Shared.CombatMode.Pacification; //A-13 Eblan system update
using Content.Shared.Database;
using Content.Shared.Examine;
using Content.Shared.IdentityManagement;
Expand Down Expand Up @@ -78,6 +79,13 @@ private void AddCremateVerb(EntityUid uid, CrematoriumComponent component, GetVe
if (!TryComp<EntityStorageComponent>(uid, out var storage))
return;

//A-13 Eblan system update start
if (HasComp<EblanComponent>(args.User))
{
return;
}
//A-13 Eblan system update end

if (!args.CanAccess || !args.CanInteract || args.Hands == null || storage.Open)
return;

Expand Down
17 changes: 17 additions & 0 deletions Content.Server/Tools/ToolSystem.cs
Original file line number Diff line number Diff line change
@@ -1,7 +1,10 @@
using Content.Server.Atmos.EntitySystems;
using Content.Server.Chemistry.Containers.EntitySystems;
using Content.Server.Popups;
using Content.Shared.Popups; //A-13 Eblan system update
using Content.Server.Tools.Components;
using Content.Shared.CombatMode.Pacification; //A-13 Eblan system update
using Content.Shared.Tools.Components; //A-13 Eblan system update
using Robust.Server.GameObjects;
using Robust.Shared.Audio.Systems;

Expand All @@ -14,14 +17,17 @@ public sealed partial class ToolSystem : SharedToolSystem
{
[Dependency] private readonly AtmosphereSystem _atmosphereSystem = default!;
[Dependency] private readonly PopupSystem _popup = default!;
[Dependency] private readonly SharedPopupSystem _popupSystem = default!; //A-13 Eblan system update
[Dependency] private readonly SharedAudioSystem _audio = default!;
[Dependency] private readonly SolutionContainerSystem _solutionContainer = default!;
[Dependency] private readonly TransformSystem _transformSystem = default!;
private const string WeldingQualityId = "Welding"; //A-13 Eblan system update

public override void Initialize()
{
base.Initialize();

SubscribeLocalEvent<ToolComponent, ToolUseAttemptEvent>(OnToolUseAttempt); //A-13 Eblan system update
InitializeWelders();
}

Expand All @@ -32,6 +38,17 @@ public override void Update(float frameTime)
UpdateWelders(frameTime);
}

//A-13 Eblan system update start
private void OnToolUseAttempt(EntityUid uid, ToolComponent component, ToolUseAttemptEvent args)
{
if (component.Qualities.Contains(WeldingQualityId) && EntityManager.HasComponent<EblanComponent>(args.User))
{
args.Cancel();
_popupSystem.PopupCursor(Loc.GetString("Вы наиграли слишком мало времени, вы не можете пользоваться сваркой."), args.User, PopupType.Large);
}
}
//A-13 Eblan system update end

protected override bool IsWelder(EntityUid uid)
{
return HasComp<WelderComponent>(uid);
Expand Down
2 changes: 1 addition & 1 deletion Content.Shared/CombatMode/Pacification/EblanSystem.cs
Original file line number Diff line number Diff line change
Expand Up @@ -167,7 +167,7 @@ public struct AttemptPacifiedThrowEvent2
public EntityUid ItemUid;
public EntityUid PlayerUid;

public AttemptPacifiedThrowEvent2(EntityUid itemUid, EntityUid playerUid)
public AttemptPacifiedThrowEvent2(EntityUid itemUid, EntityUid playerUid)
{
ItemUid = itemUid;
PlayerUid = playerUid;
Expand Down

0 comments on commit 86658b7

Please sign in to comment.