Use automatic component registration.

This commit is contained in:
Pieter-Jan Briers
2019-07-31 15:02:36 +02:00
parent a90d7a645c
commit ceb8cc8421
94 changed files with 353 additions and 540 deletions

View File

@@ -1,29 +1,15 @@
using System;
using Content.Client.Chat;
using Content.Client.GameObjects;
using Content.Client.GameObjects.Components;
using Content.Client.GameObjects.Components.Actor;
using Content.Client.GameObjects.Components.Clothing;
using Content.Client.GameObjects.Components.Construction;
using Content.Client.GameObjects.Components.IconSmoothing;
using Content.Client.GameObjects.Components.Mobs;
using Content.Client.GameObjects.Components.Power;
using Content.Client.GameObjects.Components.Research;
using Content.Client.GameObjects.Components.Sound;
using Content.Client.GameObjects.Components.Storage;
using Content.Client.GameObjects.Components.Weapons.Ranged;
using Content.Client.GameTicking;
using Content.Client.Input;
using Content.Client.Interfaces;
using Content.Client.Interfaces.Chat;
using Content.Client.Interfaces.GameObjects;
using Content.Client.Interfaces.Parallax;
using Content.Client.Parallax;
using Content.Client.UserInterface;
using Content.Shared.GameObjects.Components.Chemistry;
using Content.Shared.GameObjects.Components.Markers;
using Content.Shared.GameObjects.Components.Materials;
using Content.Shared.GameObjects.Components.Mobs;
using Content.Shared.GameObjects.Components.Research;
using Content.Shared.Interfaces;
using Robust.Client;
@@ -51,115 +37,74 @@ namespace Content.Client
var factory = IoCManager.Resolve<IComponentFactory>();
var prototypes = IoCManager.Resolve<IPrototypeManager>();
factory.RegisterIgnore("Interactable");
factory.RegisterIgnore("Destructible");
factory.RegisterIgnore("Temperature");
factory.RegisterIgnore("PowerTransfer");
factory.RegisterIgnore("PowerNode");
factory.RegisterIgnore("PowerProvider");
factory.RegisterIgnore("PowerDevice");
factory.RegisterIgnore("PowerStorage");
factory.RegisterIgnore("PowerGenerator");
factory.DoAutoRegistrations();
factory.RegisterIgnore("Explosive");
factory.RegisterIgnore("OnUseTimerTrigger");
var registerIgnore = new[]
{
"Interactable",
"Destructible",
"Temperature",
"PowerTransfer",
"PowerNode",
"PowerProvider",
"PowerDevice",
"PowerStorage",
"PowerGenerator",
"Explosive",
"OnUseTimerTrigger",
"ToolboxElectricalFill",
"ToolLockerFill",
"EmitSoundOnUse",
"FootstepModifier",
"HeatResistance",
"CombatMode",
"Teleportable",
"ItemTeleporter",
"Portal",
"EntityStorage",
"PlaceableSurface",
"Wirecutter",
"Screwdriver",
"Multitool",
"Welder",
"Wrench",
"Crowbar",
"HitscanWeapon",
"ProjectileWeapon",
"Projectile",
"MeleeWeapon",
"Storeable",
"Stack",
"Dice",
"Construction",
"Apc",
"Door",
"PoweredLight",
"Smes",
"Powercell",
"HandheldLight",
"LightBulb",
"Healing",
"Catwalk",
"BallisticMagazine",
"BallisticMagazineWeapon",
"BallisticBullet",
"HitscanWeaponCapacitor",
"PowerCell",
"AiController",
"PlayerInputMover",
};
factory.RegisterIgnore("ToolboxElectricalFill");
factory.RegisterIgnore("ToolLockerFill");
factory.RegisterIgnore("EmitSoundOnUse");
factory.RegisterIgnore("FootstepModifier");
factory.RegisterIgnore("HeatResistance");
factory.RegisterIgnore("CombatMode");
factory.RegisterIgnore("Teleportable");
factory.RegisterIgnore("ItemTeleporter");
factory.RegisterIgnore("Portal");
factory.RegisterIgnore("EntityStorage");
factory.RegisterIgnore("PlaceableSurface");
factory.RegisterIgnore("Wirecutter");
factory.RegisterIgnore("Screwdriver");
factory.RegisterIgnore("Multitool");
factory.RegisterIgnore("Welder");
factory.RegisterIgnore("Wrench");
factory.RegisterIgnore("Crowbar");
factory.Register<ClientRangedWeaponComponent>();
factory.RegisterIgnore("HitscanWeapon");
factory.RegisterIgnore("ProjectileWeapon");
factory.RegisterIgnore("Projectile");
factory.RegisterIgnore("MeleeWeapon");
factory.RegisterIgnore("Storeable");
factory.RegisterIgnore("Stack");
factory.RegisterIgnore("Dice");
factory.Register<HandsComponent>();
factory.RegisterReference<HandsComponent, IHandsComponent>();
factory.Register<ClientStorageComponent>();
factory.Register<ClientInventoryComponent>();
factory.Register<PowerDebugTool>();
factory.Register<ConstructorComponent>();
factory.Register<ConstructionGhostComponent>();
factory.Register<IconSmoothComponent>();
factory.Register<LowWallComponent>();
factory.RegisterReference<LowWallComponent, IconSmoothComponent>();
factory.Register<DamageableComponent>();
factory.Register<ClothingComponent>();
factory.Register<ItemComponent>();
factory.Register<MaterialComponent>();
factory.Register<SolutionComponent>();
factory.Register<SoundComponent>();
factory.Register<MaterialStorageComponent>();
factory.RegisterReference<MaterialStorageComponent, SharedMaterialStorageComponent>();
factory.RegisterReference<ClothingComponent, ItemComponent>();
factory.Register<SpeciesUI>();
factory.Register<CharacterInterface>();
factory.RegisterIgnore("Construction");
factory.RegisterIgnore("Apc");
factory.RegisterIgnore("Door");
factory.RegisterIgnore("PoweredLight");
factory.RegisterIgnore("Smes");
factory.RegisterIgnore("Powercell");
factory.RegisterIgnore("HandheldLight");
factory.RegisterIgnore("LightBulb");
factory.RegisterIgnore("Healing");
factory.RegisterIgnore("Catwalk");
factory.RegisterIgnore("BallisticMagazine");
factory.RegisterIgnore("BallisticMagazineWeapon");
factory.RegisterIgnore("BallisticBullet");
factory.RegisterIgnore("HitscanWeaponCapacitor");
prototypes.RegisterIgnore("material");
factory.RegisterIgnore("PowerCell");
factory.Register<SharedSpawnPointComponent>();
foreach (var ignoreName in registerIgnore)
{
factory.RegisterIgnore(ignoreName);
}
factory.Register<SharedLatheComponent>();
factory.Register<LatheDatabaseComponent>();
factory.Register<SharedSpawnPointComponent>();
factory.Register<SolutionComponent>();
factory.RegisterReference<LatheDatabaseComponent, SharedLatheDatabaseComponent>();
factory.Register<CameraRecoilComponent>();
factory.RegisterReference<CameraRecoilComponent, SharedCameraRecoilComponent>();
factory.Register<SubFloorHideComponent>();
factory.RegisterIgnore("AiController");
factory.RegisterIgnore("PlayerInputMover");
factory.Register<ExaminerComponent>();
factory.Register<CharacterInfoComponent>();
factory.Register<WindowComponent>();
prototypes.RegisterIgnore("material");
IoCManager.Register<IGameHud, GameHud>();
IoCManager.Register<IClientNotifyManager, ClientNotifyManager>();
@@ -188,6 +133,7 @@ namespace Content.Client
_escapeMenuOwner.Initialize();
}
/// <summary>
/// Subscribe events to the player manager after the player manager is set up
/// </summary>

View File

@@ -10,6 +10,7 @@ using Robust.Shared.Localization;
namespace Content.Client.GameObjects.Components.Actor
{
[RegisterComponent]
public sealed class CharacterInfoComponent : Component, ICharacterUI
{
private CharacterInfoControl _control;

View File

@@ -18,6 +18,7 @@ namespace Content.Client.GameObjects.Components.Actor
/// A semi-abstract component which gets added to entities upon attachment and collects all character
/// user interfaces into a single window and keybind for the user
/// </summary>
[RegisterComponent]
public class CharacterInterface : Component
{
public override string Name => "Character Interface Component";

View File

@@ -1,13 +1,15 @@
using Content.Shared.GameObjects;
using System;
using Content.Shared.GameObjects;
using Content.Shared.GameObjects.Components.Inventory;
using Content.Shared.GameObjects.Components.Items;
using Robust.Client.Graphics;
using Robust.Shared.GameObjects;
using Robust.Shared.ViewVariables;
using System;
namespace Content.Client.GameObjects.Components.Clothing
{
[RegisterComponent]
[ComponentReference(typeof(ItemComponent))]
public class ClothingComponent : ItemComponent
{
public override string Name => "Clothing";

View File

@@ -6,6 +6,7 @@ using Robust.Shared.ViewVariables;
namespace Content.Client.GameObjects.Components.Construction
{
[RegisterComponent]
public class ConstructionGhostComponent : Component
{
public override string Name => "ConstructionGhost";

View File

@@ -15,6 +15,7 @@ using Robust.Shared.Maths;
namespace Content.Client.GameObjects.Components.Construction
{
[RegisterComponent]
public class ConstructorComponent : SharedConstructorComponent
{
#pragma warning disable 649

View File

@@ -1,6 +1,6 @@
using Content.Shared.GameObjects;
using System.Collections.Generic;
using Content.Shared.GameObjects;
using Robust.Shared.GameObjects;
using System.Collections.Generic;
namespace Content.Client.GameObjects
{
@@ -8,6 +8,7 @@ namespace Content.Client.GameObjects
/// Fuck I really hate doing this
/// TODO: make sure the client only gets damageable component on the clientside entity for its player mob
/// </summary>
[RegisterComponent]
public class DamageableComponent : SharedDamageableComponent
{
/// <inheritdoc />

View File

@@ -18,6 +18,7 @@ namespace Content.Client.GameObjects
/// <summary>
/// A character UI which shows items the user has equipped within his inventory
/// </summary>
[RegisterComponent]
public class ClientInventoryComponent : SharedInventoryComponent
{
private readonly Dictionary<Slots, IEntity> _slots = new Dictionary<Slots, IEntity>();

View File

@@ -25,6 +25,7 @@ namespace Content.Client.GameObjects.Components.IconSmoothing
/// To use, set <c>base</c> equal to the prefix of the corner states in the sprite base RSI.
/// Any objects with the same <c>key</c> will connect.
/// </remarks>
[RegisterComponent]
public class IconSmoothComponent : Component
{
private string _smoothKey;

View File

@@ -15,6 +15,8 @@ using Robust.Shared.ViewVariables;
namespace Content.Client.GameObjects
{
[RegisterComponent]
[ComponentReference(typeof(IHandsComponent))]
public class HandsComponent : SharedHandsComponent, IHandsComponent
{
private HandsGui _gui;

View File

@@ -1,4 +1,5 @@
using Content.Shared.GameObjects;
using System;
using Content.Shared.GameObjects;
using Content.Shared.GameObjects.Components.Items;
using Robust.Client.Graphics;
using Robust.Client.Interfaces.ResourceManagement;
@@ -9,10 +10,10 @@ using Robust.Shared.IoC;
using Robust.Shared.Serialization;
using Robust.Shared.Utility;
using Robust.Shared.ViewVariables;
using System;
namespace Content.Client.GameObjects
{
[RegisterComponent]
public class ItemComponent : Component
{
public override string Name => "Item";

View File

@@ -1,6 +1,7 @@
using System.Collections.Generic;
using System.Diagnostics.CodeAnalysis;
using Content.Client.GameObjects.Components.IconSmoothing;
using Robust.Shared.GameObjects;
using Robust.Shared.Interfaces.GameObjects;
using Robust.Shared.Maths;
using static Robust.Client.GameObjects.SpriteComponent;
@@ -14,6 +15,8 @@ namespace Content.Client.GameObjects.Components
/// <summary>
/// Override of icon smoothing to handle the specific complexities of low walls.
/// </summary>
[RegisterComponent]
[ComponentReference(typeof(IconSmoothComponent))]
public class LowWallComponent : IconSmoothComponent
{
public override string Name => "LowWall";

View File

@@ -8,6 +8,8 @@ using Robust.Shared.Maths;
namespace Content.Client.GameObjects.Components.Mobs
{
[RegisterComponent]
[ComponentReference(typeof(SharedCameraRecoilComponent))]
public sealed class CameraRecoilComponent : SharedCameraRecoilComponent
{
// Maximum rate of magnitude restore towards 0 kick.

View File

@@ -1,31 +1,31 @@
using Content.Client.GameObjects.Components.Actor;
using Content.Client.GameObjects.Components.Mobs;
using System.Collections.Generic;
using Content.Client.GameObjects.Components.Actor;
using Content.Client.Graphics.Overlays;
using Content.Client.UserInterface;
using Content.Client.Utility;
using Content.Shared.GameObjects;
using Content.Shared.GameObjects.Components.Mobs;
using Robust.Client.GameObjects;
using Robust.Client.Graphics;
using Robust.Client.Graphics.Overlays;
using Robust.Client.Interfaces.Graphics.Overlays;
using Robust.Client.Interfaces.ResourceManagement;
using Robust.Client.Interfaces.UserInterface;
using Robust.Client.Player;
using Robust.Client.UserInterface;
using Robust.Client.UserInterface.Controls;
using Robust.Shared.GameObjects;
using Robust.Shared.GameObjects.Components.Renderable;
using Robust.Shared.Interfaces.GameObjects;
using Robust.Shared.Interfaces.Network;
using Robust.Shared.IoC;
using System.Collections.Generic;
using Content.Client.UserInterface;
using Content.Client.Utility;
using Content.Shared.GameObjects.Components.Mobs;
using Robust.Client.Graphics;
using Robust.Client.Graphics.Overlays;
using Robust.Client.Interfaces.UserInterface;
using Robust.Shared.GameObjects.Components.Renderable;
namespace Content.Client.GameObjects
{
/// <summary>
/// A character UI component which shows the current damage state of the mob (living/dead)
/// </summary>
[RegisterComponent]
public class SpeciesUI : SharedSpeciesComponent//, ICharacterUI
{
private StatusEffectsUI _ui;

View File

@@ -1,14 +1,13 @@
using Content.Shared.GameObjects.Components.Power;
using Robust.Client.Interfaces.Graphics;
using Robust.Client.UserInterface.Controls;
using Robust.Client.UserInterface.CustomControls;
using Robust.Shared.GameObjects;
using Robust.Shared.Interfaces.GameObjects;
using Robust.Shared.Interfaces.Network;
using Robust.Shared.IoC;
namespace Content.Client.GameObjects.Components.Power
{
[RegisterComponent]
public class PowerDebugTool : SharedPowerDebugTool
{
SS14Window LastWindow;

View File

@@ -1,13 +1,13 @@
using Content.Shared.GameObjects.Components.Research;
using Content.Shared.Research;
using Robust.Shared.GameObjects;
using Robust.Shared.Interfaces.GameObjects;
using Robust.Shared.Interfaces.Network;
using Robust.Shared.IoC;
using Robust.Shared.Prototypes;
namespace Content.Client.GameObjects.Components.Research
{
[RegisterComponent]
[ComponentReference(typeof(SharedLatheDatabaseComponent))]
public class LatheDatabaseComponent : SharedLatheDatabaseComponent
{
#pragma warning disable CS0649

View File

@@ -2,11 +2,11 @@ using System;
using System.Collections.Generic;
using Content.Shared.GameObjects.Components.Research;
using Robust.Shared.GameObjects;
using Robust.Shared.Interfaces.GameObjects;
using Robust.Shared.Interfaces.Network;
namespace Content.Client.GameObjects.Components.Research
{
[RegisterComponent]
[ComponentReference(typeof(SharedMaterialStorageComponent))]
public class MaterialStorageComponent : SharedMaterialStorageComponent
{
protected override Dictionary<string, int> Storage { get; set; } = new Dictionary<string, int>();

View File

@@ -5,14 +5,13 @@ using Robust.Client.GameObjects.EntitySystems;
using Robust.Shared.GameObjects;
using Robust.Shared.Interfaces.GameObjects;
using Robust.Shared.Interfaces.Network;
using Robust.Shared.Interfaces.Timers;
using Robust.Shared.IoC;
using Robust.Shared.Log;
using Robust.Shared.Serialization;
using Robust.Shared.Timers;
namespace Content.Client.GameObjects.Components.Sound
{
[RegisterComponent]
public class SoundComponent : SharedSoundComponent
{
private readonly List<ScheduledSound> _schedules = new List<ScheduledSound>();

View File

@@ -17,6 +17,7 @@ namespace Content.Client.GameObjects.Components.Storage
/// <summary>
/// Client version of item storage containers, contains a UI which displays stored entities and their size
/// </summary>
[RegisterComponent]
public class ClientStorageComponent : SharedStorageComponent
{
private Dictionary<EntityUid, int> StoredEntities { get; set; } = new Dictionary<EntityUid, int>();

View File

@@ -10,6 +10,7 @@ namespace Content.Client.GameObjects.Components
/// is not a sub floor (plating).
/// </summary>
/// <seealso cref="ContentTileDefinition.IsSubFloor"/>
[RegisterComponent]
public sealed class SubFloorHideComponent : Component
{
private SnapGridComponent _snapGridComponent;

View File

@@ -1,12 +1,13 @@
using System;
using Content.Shared.GameObjects.Components.Weapons.Ranged;
using Robust.Shared.GameObjects;
using Robust.Shared.Interfaces.Timing;
using Robust.Shared.IoC;
using Robust.Shared.Log;
using Robust.Shared.Map;
namespace Content.Client.GameObjects.Components.Weapons.Ranged
{
[RegisterComponent]
public sealed class ClientRangedWeaponComponent : SharedRangedWeaponComponent
{
private TimeSpan _lastFireTime;

View File

@@ -8,6 +8,7 @@ using static Content.Client.GameObjects.Components.IconSmoothing.IconSmoothCompo
namespace Content.Client.GameObjects.Components
{
[RegisterComponent]
public sealed class WindowComponent : Component
{
public override string Name => "Window";