<commit_before>﻿using Content.Server.GameObjects;
using Content.Server.GameObjects.Components;
using Content.Server.GameObjects.Components.Power;
using Content.Server.GameObjects.Components.Interactable.Tools;
using Content.Server.Interfaces.GameObjects;
using Content.Server.Placement;
using SS14.Server;
using SS14.Server.Interfaces;
using SS14.Server.Interfaces.Chat;
using SS14.Server.Interfaces.Maps;
using SS14.Server.Interfaces.Player;
using SS14.Server.Player;
using SS14.Shared.Console;
using SS14.Shared.ContentPack;
using SS14.Shared.Enums;
using SS14.Shared.Interfaces.GameObjects;
using SS14.Shared.Interfaces.Map;
using SS14.Shared.Interfaces.Timers;
using SS14.Shared.IoC;
using SS14.Shared.Log;
using SS14.Shared.Map;
using SS14.Shared.Timers;
using SS14.Shared.Interfaces.Timing;
using SS14.Shared.Maths;
using Content.Server.GameObjects.Components.Weapon.Ranged.Hitscan;
using Content.Server.GameObjects.Components.Weapon.Ranged.Projectile;
using Content.Server.GameObjects.Components.Projectiles;
using Content.Server.GameObjects.Components.Weapon.Melee;
using Content.Server.GameObjects.Components.Materials;
using Content.Server.GameObjects.Components.Stack;
using Content.Server.GameObjects.Components.Construction;
using Content.Server.GameObjects.Components.Mobs;
using Content.Server.GameObjects.EntitySystems;
using Content.Server.Mobs;
using Content.Server.Players;
using Content.Server.GameObjects.Components.Interactable;
using Content.Server.Interfaces;
using Content.Shared.GameObjects.Components.Inventory;
using Content.Shared.Interfaces;

namespace Content.Server
{
    public class EntryPoint : GameServer
    {
        const string PlayerPrototypeName = "HumanMob_Content";

        private IBaseServer _server;
        private IPlayerManager _players;
        private IEntityManager entityManager;
        private IChatManager chatManager;

        private bool _countdownStarted;

        private GridLocalCoordinates SpawnPoint;

        /// <inheritdoc />
        public override void Init()
        {
            base.Init();

            _server = IoCManager.Resolve<IBaseServer>();
            _players = IoCManager.Resolve<IPlayerManager>();
            entityManager = IoCManager.Resolve<IEntityManager>();
            chatManager = IoCManager.Resolve<IChatManager>();

            _players.PlayerStatusChanged += HandlePlayerStatusChanged;

            var factory = IoCManager.Resolve<IComponentFactory>();

            factory.Register<HandsComponent>();
            factory.RegisterReference<HandsComponent, IHandsComponent>();

            factory.Register<InventoryComponent>();

            factory.Register<StoreableComponent>();
            factory.Register<ItemComponent>();
            factory.RegisterReference<ItemComponent, StoreableComponent>();
            factory.Register<ClothingComponent>();
            factory.RegisterReference<ClothingComponent, ItemComponent>();

            factory.Register<DamageableComponent>();
            factory.Register<DestructibleComponent>();
            factory.Register<TemperatureComponent>();
            factory.Register<ServerDoorComponent>();

            //Power Components
            factory.Register<PowerTransferComponent>();
            factory.Register<PowerProviderComponent>();
            factory.RegisterReference<PowerProviderComponent, PowerDeviceComponent>();
            factory.Register<PowerNodeComponent>();
            factory.Register<PowerStorageNetComponent>();
            factory.RegisterReference<PowerStorageNetComponent, PowerStorageComponent>();
            factory.Register<PowerCellComponent>();
            factory.RegisterReference<PowerCellComponent, PowerStorageComponent>();
            factory.Register<PowerDeviceComponent>();
            factory.Register<PowerGeneratorComponent>();

            //Tools
            factory.Register<MultitoolComponent>();
            factory.Register<WirecutterComponent>();
            factory.Register<WrenchComponent>();
            factory.Register<WelderComponent>();
            factory.Register<ScrewdriverComponent>();
            factory.Register<CrowbarComponent>();

            factory.Register<HitscanWeaponComponent>();
            factory.Register<ProjectileWeaponComponent>();
            factory.Register<ProjectileComponent>();
            factory.Register<ThrownItemComponent>();
            factory.Register<MeleeWeaponComponent>();

            factory.Register<HandheldLightComponent>();

            factory.Register<ServerStorageComponent>();
            factory.RegisterReference<ServerStorageComponent, IActivate>();

            factory.Register<PowerDebugTool>();
            factory.Register<PoweredLightComponent>();
            factory.Register<SmesComponent>();
            factory.Register<ApcComponent>();
            factory.Register<MaterialComponent>();
            factory.Register<StackComponent>();

            factory.Register<ConstructionComponent>();
            factory.Register<ConstructorComponent>();
            factory.RegisterIgnore("ConstructionGhost");

            factory.Register<MindComponent>();

            IoCManager.Register<ISharedNotifyManager, ServerNotifyManager>();
            IoCManager.Register<IServerNotifyManager, ServerNotifyManager>();
            IoCManager.BuildGraph();

            IoCManager.Resolve<IServerNotifyManager>().Initialize();
        }

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

            var timing = IoCManager.Resolve<IGameTiming>();
            var mapLoader = IoCManager.Resolve<IMapLoader>();
            var mapMan = IoCManager.Resolve<IMapManager>();

            var newMap = mapMan.CreateMap();
            var grid = mapLoader.LoadBlueprint(newMap, "Maps/stationstation.yml");

            SpawnPoint = new GridLocalCoordinates(Vector2.Zero, grid);

            var startTime = timing.RealTime;
            var timeSpan = timing.RealTime - startTime;
            Logger.Info($"Loaded map in {timeSpan.TotalMilliseconds:N2}ms.");
        }

        /// <inheritdoc />
        protected override void Dispose(bool disposing)
        {
            if (disposing)
            {
                _players.PlayerStatusChanged -= HandlePlayerStatusChanged;
            }

            base.Dispose(disposing);
        }

        private void HandlePlayerStatusChanged(object sender, SessionStatusEventArgs args)
        {
            var session = args.Session;

            switch (args.NewStatus)
            {
                case SessionStatus.Connected:
                    {
                        if (session.Data.ContentDataUncast == null)
                        {
                            session.Data.ContentDataUncast = new PlayerData(session.SessionId);
                        }
                        // timer time must be > tick length
                        Timer.Spawn(250, args.Session.JoinLobby);
<commit_msg>Remove even more join delay<commit_after>﻿using Content.Server.GameObjects;
using Content.Server.GameObjects.Components;
using Content.Server.GameObjects.Components.Power;
using Content.Server.GameObjects.Components.Interactable.Tools;
using Content.Server.Interfaces.GameObjects;
using Content.Server.Placement;
using SS14.Server;
using SS14.Server.Interfaces;
using SS14.Server.Interfaces.Chat;
using SS14.Server.Interfaces.Maps;
using SS14.Server.Interfaces.Player;
using SS14.Server.Player;
using SS14.Shared.Console;
using SS14.Shared.ContentPack;
using SS14.Shared.Enums;
using SS14.Shared.Interfaces.GameObjects;
using SS14.Shared.Interfaces.Map;
using SS14.Shared.Interfaces.Timers;
using SS14.Shared.IoC;
using SS14.Shared.Log;
using SS14.Shared.Map;
using SS14.Shared.Timers;
using SS14.Shared.Interfaces.Timing;
using SS14.Shared.Maths;
using Content.Server.GameObjects.Components.Weapon.Ranged.Hitscan;
using Content.Server.GameObjects.Components.Weapon.Ranged.Projectile;
using Content.Server.GameObjects.Components.Projectiles;
using Content.Server.GameObjects.Components.Weapon.Melee;
using Content.Server.GameObjects.Components.Materials;
using Content.Server.GameObjects.Components.Stack;
using Content.Server.GameObjects.Components.Construction;
using Content.Server.GameObjects.Components.Mobs;
using Content.Server.GameObjects.EntitySystems;
using Content.Server.Mobs;
using Content.Server.Players;
using Content.Server.GameObjects.Components.Interactable;
using Content.Server.Interfaces;
using Content.Shared.GameObjects.Components.Inventory;
using Content.Shared.Interfaces;

namespace Content.Server
{
    public class EntryPoint : GameServer
    {
        const string PlayerPrototypeName = "HumanMob_Content";

        private IBaseServer _server;
        private IPlayerManager _players;
        private IEntityManager entityManager;
        private IChatManager chatManager;

        private bool _countdownStarted;

        private GridLocalCoordinates SpawnPoint;

        /// <inheritdoc />
        public override void Init()
        {
            base.Init();

            _server = IoCManager.Resolve<IBaseServer>();
            _players = IoCManager.Resolve<IPlayerManager>();
            entityManager = IoCManager.Resolve<IEntityManager>();
            chatManager = IoCManager.Resolve<IChatManager>();

            _players.PlayerStatusChanged += HandlePlayerStatusChanged;

            var factory = IoCManager.Resolve<IComponentFactory>();

            factory.Register<HandsComponent>();
            factory.RegisterReference<HandsComponent, IHandsComponent>();

            factory.Register<InventoryComponent>();

            factory.Register<StoreableComponent>();
            factory.Register<ItemComponent>();
            factory.RegisterReference<ItemComponent, StoreableComponent>();
            factory.Register<ClothingComponent>();
            factory.RegisterReference<ClothingComponent, ItemComponent>();

            factory.Register<DamageableComponent>();
            factory.Register<DestructibleComponent>();
            factory.Register<TemperatureComponent>();
            factory.Register<ServerDoorComponent>();

            //Power Components
            factory.Register<PowerTransferComponent>();
            factory.Register<PowerProviderComponent>();
            factory.RegisterReference<PowerProviderComponent, PowerDeviceComponent>();
            factory.Register<PowerNodeComponent>();
            factory.Register<PowerStorageNetComponent>();
            factory.RegisterReference<PowerStorageNetComponent, PowerStorageComponent>();
            factory.Register<PowerCellComponent>();
            factory.RegisterReference<PowerCellComponent, PowerStorageComponent>();
            factory.Register<PowerDeviceComponent>();
            factory.Register<PowerGeneratorComponent>();

            //Tools
            factory.Register<MultitoolComponent>();
            factory.Register<WirecutterComponent>();
            factory.Register<WrenchComponent>();
            factory.Register<WelderComponent>();
            factory.Register<ScrewdriverComponent>();
            factory.Register<CrowbarComponent>();

            factory.Register<HitscanWeaponComponent>();
            factory.Register<ProjectileWeaponComponent>();
            factory.Register<ProjectileComponent>();
            factory.Register<ThrownItemComponent>();
            factory.Register<MeleeWeaponComponent>();

            factory.Register<HandheldLightComponent>();

            factory.Register<ServerStorageComponent>();
            factory.RegisterReference<ServerStorageComponent, IActivate>();

            factory.Register<PowerDebugTool>();
            factory.Register<PoweredLightComponent>();
            factory.Register<SmesComponent>();
            factory.Register<ApcComponent>();
            factory.Register<MaterialComponent>();
            factory.Register<StackComponent>();

            factory.Register<ConstructionComponent>();
            factory.Register<ConstructorComponent>();
            factory.RegisterIgnore("ConstructionGhost");

            factory.Register<MindComponent>();

            IoCManager.Register<ISharedNotifyManager, ServerNotifyManager>();
            IoCManager.Register<IServerNotifyManager, ServerNotifyManager>();
            IoCManager.BuildGraph();

            IoCManager.Resolve<IServerNotifyManager>().Initialize();
        }

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

            var timing = IoCManager.Resolve<IGameTiming>();
            var mapLoader = IoCManager.Resolve<IMapLoader>();
            var mapMan = IoCManager.Resolve<IMapManager>();

            var newMap = mapMan.CreateMap();
            var grid = mapLoader.LoadBlueprint(newMap, "Maps/stationstation.yml");

            SpawnPoint = new GridLocalCoordinates(Vector2.Zero, grid);

            var startTime = timing.RealTime;
            var timeSpan = timing.RealTime - startTime;
            Logger.Info($"Loaded map in {timeSpan.TotalMilliseconds:N2}ms.");
        }

        /// <inheritdoc />
        protected override void Dispose(bool disposing)
        {
            if (disposing)
            {
                _players.PlayerStatusChanged -= HandlePlayerStatusChanged;
            }

            base.Dispose(disposing);
        }

        private void HandlePlayerStatusChanged(object sender, SessionStatusEventArgs args)
        {
            var session = args.Session;

            switch (args.NewStatus)
            {
                case SessionStatus.Connected:
                    {
                        if (session.Data.ContentDataUncast == null)
                        {
                            session.Data.ContentDataUncast = new PlayerData(session.SessionId);
                        }
                        // timer time must be > tick length
                        Timer.Spawn(0, args.Session.JoinLobby);

{'fraction_non_alphanumeric': 0.09651898734177215, 'fraction_numerical': 0.005753739930955121, 'mean_word_length': 2.78779624080632, 'pattern_counts': {'":': 0, '<': 119, '<?xml version=': 0, '>': 121, 'https://': 0, 'lorem ipsum': 0, 'www.': 0, 'xml': 0}, 'pii_count': 0, 'substrings_counts': 0, 'word_list_counts': {'cursed_substrings.json': 0, 'profanity_word_list.json': 0, 'sexual_word_list.json': 0, 'zh_pornsignals.json': 0}}
{'dir': 'git-commits-cleaned', 'id': '2856779', 'n_tokens_mistral': 3383, 'n_tokens_neox': 3270, 'n_words': 526}