Files
crystall-punk-14/Content.Client/EntryPoint.cs

308 lines
10 KiB
C#
Raw Normal View History

using System;
using Content.Client.GameObjects.Components.Actor;
using Content.Client.Input;
using Content.Client.Interfaces;
2019-07-30 23:13:05 +02:00
using Content.Client.Interfaces.Chat;
2018-11-30 21:54:30 +01:00
using Content.Client.Interfaces.Parallax;
using Content.Client.Parallax;
2019-10-02 10:45:06 +02:00
using Content.Client.Sandbox;
2019-12-06 00:41:30 +01:00
using Content.Client.State;
2019-07-30 23:13:05 +02:00
using Content.Client.UserInterface;
using Content.Client.UserInterface.Stylesheets;
using Content.Shared.GameObjects.Components;
using Content.Shared.GameObjects.Components.Cargo;
using Content.Shared.GameObjects.Components.Chemistry;
2020-05-02 15:02:52 +01:00
using Content.Shared.GameObjects.Components.Gravity;
2019-07-30 23:13:05 +02:00
using Content.Shared.GameObjects.Components.Markers;
using Content.Shared.GameObjects.Components.Research;
using Content.Shared.GameObjects.Components.VendingMachines;
2020-05-01 23:34:04 -05:00
using Content.Shared.Kitchen;
using Robust.Client;
using Robust.Client.Interfaces;
using Robust.Client.Interfaces.Graphics.Overlays;
using Robust.Client.Interfaces.Input;
using Robust.Client.Interfaces.State;
using Robust.Client.Player;
using Robust.Shared.ContentPack;
using Robust.Shared.Interfaces.GameObjects;
using Robust.Shared.Interfaces.Map;
using Robust.Shared.IoC;
using Robust.Shared.Map;
using Robust.Shared.Prototypes;
2019-08-04 01:08:55 +02:00
using Robust.Shared.Timing;
namespace Content.Client
{
public class EntryPoint : GameClient
{
2019-04-29 13:12:50 +02:00
#pragma warning disable 649
2019-04-29 12:53:09 +02:00
[Dependency] private readonly IPlayerManager _playerManager;
2019-12-06 00:41:30 +01:00
[Dependency] private readonly IBaseClient _baseClient;
2019-05-14 15:19:41 +02:00
[Dependency] private readonly IEscapeMenuOwner _escapeMenuOwner;
[Dependency] private readonly IGameController _gameController;
[Dependency] private readonly IStateManager _stateManager;
2019-04-29 13:12:50 +02:00
#pragma warning restore 649
2019-04-29 12:53:09 +02:00
public override void Init()
{
2017-09-26 19:59:31 +02:00
var factory = IoCManager.Resolve<IComponentFactory>();
var prototypes = IoCManager.Resolve<IPrototypeManager>();
2017-09-26 19:59:31 +02:00
2019-07-31 15:02:36 +02:00
factory.DoAutoRegistrations();
2019-07-31 15:02:36 +02:00
var registerIgnore = new[]
{
"Anchorable",
"AmmoBox",
2019-08-14 18:15:26 +02:00
"Breakable",
"Pickaxe",
2019-07-31 15:02:36 +02:00
"Interactable",
"Destructible",
"Temperature",
"PowerTransfer",
"PowerNode",
"PowerProvider",
"PowerDevice",
"PowerStorage",
"PowerGenerator",
"Explosive",
"OnUseTimerTrigger",
"ToolboxElectricalFill",
2020-05-24 16:56:19 +00:00
"ToolboxEmergencyFill",
"WarpPoint",
"ToolboxGoldFill",
2019-07-31 15:02:36 +02:00
"ToolLockerFill",
"EmitSoundOnUse",
"FootstepModifier",
"HeatResistance",
"Teleportable",
"ItemTeleporter",
"Portal",
"EntityStorage",
"PlaceableSurface",
"Wirecutter",
"Screwdriver",
"Multitool",
"Wrench",
"Crowbar",
"HitscanWeapon",
"ProjectileWeapon",
"Projectile",
"MeleeWeapon",
"Storeable",
"Dice",
"Construction",
"Apc",
"Door",
"PoweredLight",
"Smes",
"Powercell",
"LightBulb",
"Healing",
"Catwalk",
"BallisticMagazine",
"BallisticBullet",
"HitscanWeaponCapacitor",
"PowerCell",
"WeaponCapacitorCharger",
"PowerCellCharger",
2019-07-31 15:02:36 +02:00
"AiController",
"PlayerInputMover",
"Computer",
"AsteroidRock",
"ResearchServer",
"ResearchPointSource",
"ResearchClient",
"IdCard",
"Access",
"AccessReader",
"IdCardConsole",
"Airlock",
"MedicalScanner",
2019-09-20 01:52:53 +02:00
"WirePlacer",
"Species",
"Drink",
"Food",
"FoodContainer",
"Stomach",
"Hunger",
"Thirst",
"Rotatable",
"MagicMirror",
"MedkitFill",
"FloorTile",
"FootstepSound",
"UtilityBeltClothingFill",
"ShuttleController",
"HumanInventoryController",
Add solution pouring / click-transfer (#574) * Add click-based solution transfer For example, clicking on a beaker with a soda can to transfer the soda to the beaker. Works on plain solution containers like beakers and also on open drink containers like soda cans as long as they have the `PourIn` and `PourOut` solution capabilities. If no `SolutionComponent` is added to a drink entity, the `DrinkComponent` will give the entity one. This PR extends that behavior slightly by also giving these default `SolutionComponent`'s the proper capabilities for pouring in/out. * Improve fix for poured drinks not immediately disappearing Instead of making `DrinkComponent.Use` public this splits out the code important to both users and made that function public, leaving `Use` private. * Shorten solution transfer popup * Make code review changes - Move pouring code from SolutionComponent to new PourableComponent. Added PourableComponent to client ignore list and added to existing container prototypes. - Added EmptyVolume property to shared SolutionComponent for convenience. - Removed DrinkComponent fix from pouring AttackBy code. Instead DrinkComponent subscribes to the SolutionChanged action and updates its self when necessary. - Fixed pouring being able to add more than a containers max volume and sometimes deleting reagents. - Added message for when a container is full. * More code review changes - Remove IAttackBy ComponentReference attribute in PourableComponent - Remove _transferAmount from shared SolutionComponent. Left over var from previous commit not being used anymore.
2020-01-28 20:07:02 -05:00
"UseDelay",
"Pourable",
"Paper",
"Write",
"Bloodstream",
"TransformableContainer",
"Mind",
"MovementSpeedModifier",
2020-04-22 04:23:12 +10:00
"StorageFill",
"Mop",
"Bucket",
"Puddle",
"CanSpill",
"RandomPottedPlant",
"CommunicationsConsole",
"BarSign",
2020-05-22 17:59:13 +01:00
"DroppedBodyPart",
"DroppedMechanism",
"BodyManager",
"Stunnable",
"SolarPanel",
"BodyScanner",
"Stunbaton",
"EmergencyClosetFill",
"Tool",
"TilePrying",
"RandomToolColor",
"ConditionalSpawner",
"PottedPlantHide",
"SecureEntityStorage",
"PresetIdCard",
"SolarControlConsole",
2019-07-31 15:02:36 +02:00
};
foreach (var ignoreName in registerIgnore)
{
factory.RegisterIgnore(ignoreName);
}
factory.Register<SharedResearchConsoleComponent>();
2019-07-31 15:02:36 +02:00
factory.Register<SharedLatheComponent>();
factory.Register<SharedSpawnPointComponent>();
factory.Register<SharedSolutionComponent>();
factory.Register<SharedVendingMachineComponent>();
factory.Register<SharedWiresComponent>();
factory.Register<SharedCargoConsoleComponent>();
Reagent dispensers (#360) * Expose more private values of Solution and SolutionComponent Expose SolutionComponent.ContainedSolution and Solution.Contents. Both needed by ReagentDispenserComponent. * Implement IExamine for SolutionComponent Allows players to see the contents of a solution by examining the entity which contains it. * Implement ReagentDispenserComponent Adds ReagentDispenserComponent. A component which can add or remove reagents from a solution container. It's written in a general way so that it can be used for things such as the Chemical dispensers in chemistry, but also the booze and soda dispensers in the bar. The chemicals it may dispense are defined in yaml, similar to the way that vending machines define which entities they can dispense, by defining a reagent pack. * Add chemical dispenser and equipment Adds the chemical dispenser, beaker, large beaker, dropper, and a few more chemicals. * Add booze and soda dispensers. Adds the booze and soda dispensers, and a few chemicals for them to dispense. There's no drink mixing or drunkenness yet. * Update engine submodule. * Remove unneeded and commented out code Had a few WIP notes and debug code bits I forgot to remove beforehand. * Make SolutionComponent._containedSolution and it's values private again - Remove `SolutionComponent.ContainedSolution` property, replace with specific access functions to maintain safety. - Make Solution.Contents return a `ReadOnlyCollection` instead of `_contents` to prevent uncontrolled access to the Solution values. - Add `SolutionComponent.RemoveAllSolution()` * Update Content.Shared/Chemistry/Solution.cs Commits a suggestion from RemieRichards to match the coding style of the rest of the codebase. Using `IReadOnlyList` instead of `IReadOnlyCollection`. Co-Authored-By: Remie Richards <remierichards@gmail.com> * Update Content.Shared/GameObjects/Components/Chemistry/SolutionComponent.cs Commits a suggestion from RemieRichards to match the coding style of the rest of the codebase. Using `IReadOnlyList` instead of `IReadOnlyCollection`. Co-Authored-By: Remie Richards <remierichards@gmail.com> * Add import for IReadOnlyList to Shared/SolutionComponent.cs * Add documentation * Improve localization Improve use of ILocalizationManager. * Resolve ReagentDispenserWindow._localizationManager before using it Forgot to do this in the last commit, resulting in a crash. Oops. * Add SolutionCaps.FitsInDispenser. Use in ReagentDispenserComponent. Used to limit large containers like buckets or mop buckets from being placed in a dispenser. Both have large capacities (500) and weren't designed to hold certain chemicals like a beaker is, so for now they can be blocked from being put in a dispenser by giving them that flag. * Add colors to new reagents * Update engine submodule
2019-10-05 09:10:05 -04:00
factory.Register<SharedReagentDispenserComponent>();
2020-05-01 23:34:04 -05:00
factory.Register<SharedMicrowaveComponent>();
2020-05-02 15:02:52 +01:00
factory.Register<SharedGravityGeneratorComponent>();
prototypes.RegisterIgnore("material");
Add basic chemical reactions (#376) * Add basic chemical reaction system What it adds: - Reactions defined in yaml with an arbitrary amount of reactants (can be catalysts), products, and effects. What it doesn't add: - Temperature dependent reactions - Metabolism or other medical/health effects * Add many common SS13 chemicals and reactions Added many of the common SS13 medicines and other chemicals, and their chemical reactions. Note that many of them are lacking their effects since we don't have medical yet. * Add ExplosiveReactionEffect Shows how IReactionEffect can be implemented to have effects that occur with a reaction by adding ExplosionReactionEffect and the potassium + water explosion reaction. * Move ReactionSystem logic into SolutionComponent No need for this to be a system currently so the behavior for reaction checking has been moved into SolutionComponent. Now it only checks for reactions when a reagent or solution is added to a solution. Also fixed a bug with SolutionValidReaction incorrectly returning true. * Move explosion logic out of ExplosiveComponent Allows you to create explosions without needing to add an ExplosiveComponent to an entity first. * Add SolutionComponent.SolutionChanged event. Trigger dispenser ui updates with it. This removes the need for SolutionComponent having a reference to the dispenser it's in. Instead the dispenser subscribes to the event and updates it's UI whenever the event is triggered. * Add forgotten checks `SolutionComponent.TryAddReagent` and `SolutionComponent.TryAddSolution` now check to see if `skipReactionCheck` is false before checking for a chemical reaction to avoid unnecessarily checking themselves for a reaction again when `SolutionComponent.PerformReaction` calls either of them. * Change SolutionComponent.SolutionChanged to an Action The arguments for event handler have no use here, and any class that can access SolutionChanged can access the SolutionComponent so it can just be an Action with no arguments instead.
2019-10-11 16:57:16 -04:00
prototypes.RegisterIgnore("reaction"); //Chemical reactions only needed by server. Reactions checks are server-side.
2020-04-23 00:58:43 +02:00
prototypes.RegisterIgnore("barSign");
ClientContentIoC.Register();
2019-10-02 10:45:06 +02:00
2019-06-29 01:58:16 +02:00
if (TestingCallbacks != null)
{
var cast = (ClientModuleTestingCallbacks) TestingCallbacks;
cast.ClientBeforeIoC?.Invoke();
}
IoCManager.BuildGraph();
2018-11-30 21:54:30 +01:00
IoCManager.Resolve<IParallaxManager>().LoadParallax();
IoCManager.Resolve<IBaseClient>().PlayerJoinedServer += SubscribePlayerAttachmentEvents;
IoCManager.Resolve<IStylesheetManager>().Initialize();
2020-04-30 12:45:21 +02:00
IoCManager.Resolve<IScreenshotHook>().Initialize();
2019-04-29 12:53:09 +02:00
IoCManager.InjectDependencies(this);
2019-05-14 15:19:41 +02:00
_escapeMenuOwner.Initialize();
2019-12-06 00:41:30 +01:00
_baseClient.PlayerJoinedServer += (sender, args) =>
{
IoCManager.Resolve<IMapManager>().CreateNewMapEntity(MapId.Nullspace);
};
2019-05-14 15:19:41 +02:00
}
2019-07-31 15:02:36 +02:00
/// <summary>
/// Subscribe events to the player manager after the player manager is set up
/// </summary>
/// <param name="sender"></param>
/// <param name="args"></param>
public void SubscribePlayerAttachmentEvents(object sender, EventArgs args)
{
2019-04-29 12:53:09 +02:00
_playerManager.LocalPlayer.EntityAttached += AttachPlayerToEntity;
_playerManager.LocalPlayer.EntityDetached += DetachPlayerFromEntity;
}
/// <summary>
/// Add the character interface master which combines all character interfaces into one window
/// </summary>
2019-04-29 12:53:09 +02:00
public static void AttachPlayerToEntity(EntityAttachedEventArgs eventArgs)
{
2019-04-29 12:53:09 +02:00
eventArgs.NewEntity.AddComponent<CharacterInterface>();
}
/// <summary>
/// Remove the character interface master from this entity now that we have detached ourselves from it
/// </summary>
2019-04-29 12:53:09 +02:00
public static void DetachPlayerFromEntity(EntityDetachedEventArgs eventArgs)
{
2019-04-29 12:53:09 +02:00
eventArgs.OldEntity.RemoveComponent<CharacterInterface>();
}
public override void PostInit()
{
base.PostInit();
// Setup key contexts
var inputMan = IoCManager.Resolve<IInputManager>();
ContentContexts.SetupContexts(inputMan.Contexts);
IoCManager.Resolve<IGameHud>().Initialize();
IoCManager.Resolve<IClientNotifyManager>().Initialize();
IoCManager.Resolve<IClientGameTicker>().Initialize();
2018-11-30 21:54:30 +01:00
IoCManager.Resolve<IOverlayManager>().AddOverlay(new ParallaxOverlay());
IoCManager.Resolve<IChatManager>().Initialize();
2019-10-02 10:45:06 +02:00
IoCManager.Resolve<ISandboxManager>().Initialize();
IoCManager.Resolve<IClientPreferencesManager>().Initialize();
_baseClient.RunLevelChanged += (sender, args) =>
{
if (args.NewLevel == ClientRunLevel.Initialize)
{
SwitchToDefaultState(args.OldLevel == ClientRunLevel.Connected ||
args.OldLevel == ClientRunLevel.InGame);
}
};
SwitchToDefaultState();
}
private void SwitchToDefaultState(bool disconnected = false)
{
// Fire off into state dependent on launcher or not.
if (_gameController.LaunchState.FromLauncher)
{
_stateManager.RequestStateChange<LauncherConnecting>();
var state = (LauncherConnecting) _stateManager.CurrentState;
if (disconnected)
{
state.SetDisconnected();
}
}
else
{
_stateManager.RequestStateChange<MainScreen>();
}
}
2019-08-04 01:08:55 +02:00
public override void Update(ModUpdateLevel level, FrameEventArgs frameEventArgs)
{
2019-08-04 01:08:55 +02:00
base.Update(level, frameEventArgs);
switch (level)
{
case ModUpdateLevel.FramePreEngine:
2019-08-04 01:08:55 +02:00
IoCManager.Resolve<IClientNotifyManager>().FrameUpdate(frameEventArgs);
IoCManager.Resolve<IChatManager>().FrameUpdate(frameEventArgs);
break;
}
}
}
}