Skip to content

Commit

Permalink
Use automatic component registration.
Browse files Browse the repository at this point in the history
  • Loading branch information
PJB3005 committed Jul 31, 2019
1 parent a90d7a6 commit ceb8cc8
Show file tree
Hide file tree
Showing 94 changed files with 348 additions and 535 deletions.
184 changes: 65 additions & 119 deletions Content.Client/EntryPoint.cs
Original file line number Diff line number Diff line change
@@ -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;
Expand Down Expand Up @@ -51,115 +37,74 @@ public override void Init()
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.RegisterIgnore("Explosive");
factory.RegisterIgnore("OnUseTimerTrigger");

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.DoAutoRegistrations();

factory.RegisterIgnore("PowerCell");

factory.Register<SharedSpawnPointComponent>();
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",
};

foreach (var ignoreName in registerIgnore)
{
factory.RegisterIgnore(ignoreName);
}

factory.Register<SharedLatheComponent>();
factory.Register<LatheDatabaseComponent>();

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<SharedSpawnPointComponent>();
factory.Register<SolutionComponent>();

factory.Register<WindowComponent>();
prototypes.RegisterIgnore("material");

IoCManager.Register<IGameHud, GameHud>();
IoCManager.Register<IClientNotifyManager, ClientNotifyManager>();
Expand Down Expand Up @@ -188,6 +133,7 @@ public override void Init()

_escapeMenuOwner.Initialize();
}

/// <summary>
/// Subscribe events to the player manager after the player manager is set up
/// </summary>
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -10,6 +10,7 @@

namespace Content.Client.GameObjects.Components.Actor
{
[RegisterComponent]
public sealed class CharacterInfoComponent : Component, ICharacterUI
{
private CharacterInfoControl _control;
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -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";
Expand Down
Original file line number Diff line number Diff line change
@@ -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";
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -6,6 +6,7 @@

namespace Content.Client.GameObjects.Components.Construction
{
[RegisterComponent]
public class ConstructionGhostComponent : Component
{
public override string Name => "ConstructionGhost";
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -15,6 +15,7 @@

namespace Content.Client.GameObjects.Components.Construction
{
[RegisterComponent]
public class ConstructorComponent : SharedConstructorComponent
{
#pragma warning disable 649
Expand Down
5 changes: 3 additions & 2 deletions Content.Client/GameObjects/Components/DamageableComponent.cs
Original file line number Diff line number Diff line change
@@ -1,13 +1,14 @@
using Content.Shared.GameObjects;
using System.Collections.Generic;
using Content.Shared.GameObjects;
using Robust.Shared.GameObjects;
using System.Collections.Generic;

namespace Content.Client.GameObjects
{
/// <summary>
/// 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 />
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -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>();
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -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;
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -15,6 +15,8 @@

namespace Content.Client.GameObjects
{
[RegisterComponent]
[ComponentReference(typeof(IHandsComponent))]
public class HandsComponent : SharedHandsComponent, IHandsComponent
{
private HandsGui _gui;
Expand Down
5 changes: 3 additions & 2 deletions Content.Client/GameObjects/Components/Items/ItemComponent.cs
Original file line number Diff line number Diff line change
@@ -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;
Expand All @@ -9,10 +10,10 @@
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";
Expand Down
3 changes: 3 additions & 0 deletions Content.Client/GameObjects/Components/LowWallComponent.cs
Original file line number Diff line number Diff line change
@@ -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;
Expand All @@ -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";
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -8,6 +8,8 @@

namespace Content.Client.GameObjects.Components.Mobs
{
[RegisterComponent]
[ComponentReference(typeof(SharedCameraRecoilComponent))]
public sealed class CameraRecoilComponent : SharedCameraRecoilComponent
{
// Maximum rate of magnitude restore towards 0 kick.
Expand Down
20 changes: 10 additions & 10 deletions Content.Client/GameObjects/Components/Mobs/SpeciesUI.cs
Original file line number Diff line number Diff line change
@@ -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;
Expand Down
Loading

0 comments on commit ceb8cc8

Please sign in to comment.