From 20cf3a6a9bc998fe1e4a407a50d97d641d6adabe Mon Sep 17 00:00:00 2001 From: Pieter-Jan Briers Date: Thu, 10 May 2018 19:21:15 +0200 Subject: [PATCH] Rename IEntity.GetComponents to GetAllComponents. (#68) * Rename IEntity.GetComponents to GetAllComponents. This is to avoid confusion. A single s to distinguish it from GetComponent() is quite hard to miss. * Update submodule. --- .../Components/Damage/DamageableComponent.cs | 2 +- .../Components/Items/Storage/ItemComponent.cs | 6 ++-- .../EntitySystems/Click/ExamineSystem.cs | 6 ++-- .../EntitySystems/Click/InteractionSystem.cs | 30 +++++++++---------- engine | 2 +- 5 files changed, 23 insertions(+), 23 deletions(-) diff --git a/Content.Server/GameObjects/Components/Damage/DamageableComponent.cs b/Content.Server/GameObjects/Components/Damage/DamageableComponent.cs index aeac75cd7b..5332ae1b3e 100644 --- a/Content.Server/GameObjects/Components/Damage/DamageableComponent.cs +++ b/Content.Server/GameObjects/Components/Damage/DamageableComponent.cs @@ -119,7 +119,7 @@ namespace Content.Server.GameObjects void RecalculateComponentThresholds() { - foreach (IOnDamageBehavior onDamageBehaviorComponent in Owner.GetComponents()) + foreach (IOnDamageBehavior onDamageBehaviorComponent in Owner.GetAllComponents()) { AddThresholdsFrom(onDamageBehaviorComponent); } diff --git a/Content.Server/GameObjects/Components/Items/Storage/ItemComponent.cs b/Content.Server/GameObjects/Components/Items/Storage/ItemComponent.cs index dc90a6c131..ab0305d8ad 100644 --- a/Content.Server/GameObjects/Components/Items/Storage/ItemComponent.cs +++ b/Content.Server/GameObjects/Components/Items/Storage/ItemComponent.cs @@ -8,11 +8,11 @@ namespace Content.Server.GameObjects public class ItemComponent : StoreableComponent, EntitySystems.IAttackHand { public override string Name => "Item"; - + public void RemovedFromSlot() { - foreach (var component in Owner.GetComponents()) + foreach (var component in Owner.GetAllComponents()) { component.Visible = true; } @@ -20,7 +20,7 @@ namespace Content.Server.GameObjects public void EquippedToSlot(ContainerSlot slot) { - foreach (var component in Owner.GetComponents()) + foreach (var component in Owner.GetAllComponents()) { component.Visible = false; } diff --git a/Content.Server/GameObjects/EntitySystems/Click/ExamineSystem.cs b/Content.Server/GameObjects/EntitySystems/Click/ExamineSystem.cs index 0a437deb52..433e0260a8 100644 --- a/Content.Server/GameObjects/EntitySystems/Click/ExamineSystem.cs +++ b/Content.Server/GameObjects/EntitySystems/Click/ExamineSystem.cs @@ -48,16 +48,16 @@ namespace Content.Server.GameObjects.EntitySystems StringBuilder fullexaminetext = new StringBuilder("This is " + examined.Name); //Add an entity description if one is declared - if(!string.IsNullOrEmpty(examined.Description)) + if (!string.IsNullOrEmpty(examined.Description)) { fullexaminetext.Append(Environment.NewLine + examined.Description); } //Add component statuses from components that report one - foreach (var examinecomponents in examined.GetComponents()) + foreach (var examinecomponents in examined.GetAllComponents()) { string componentdescription = examinecomponents.Examine(); - if(!string.IsNullOrEmpty(componentdescription)) + if (!string.IsNullOrEmpty(componentdescription)) { fullexaminetext.Append(Environment.NewLine + componentdescription); } diff --git a/Content.Server/GameObjects/EntitySystems/Click/InteractionSystem.cs b/Content.Server/GameObjects/EntitySystems/Click/InteractionSystem.cs index 7a0fa8b417..a48ed41659 100644 --- a/Content.Server/GameObjects/EntitySystems/Click/InteractionSystem.cs +++ b/Content.Server/GameObjects/EntitySystems/Click/InteractionSystem.cs @@ -95,7 +95,7 @@ namespace Content.Server.GameObjects.EntitySystems IEntity attacked = null; if (msg.Uid.IsValid()) attacked = EntityManager.GetEntity(msg.Uid); - + //Verify player has a transform component if (!player.TryGetComponent(out var playerTransform)) { @@ -121,7 +121,7 @@ namespace Content.Server.GameObjects.EntitySystems //TODO: Mob status code that allows or rejects interactions based on current mob status //Check if client should be able to see that object to click on it in the first place, prevent using locaters by firing a laser or something - + //Clicked on empty space behavior, try using ranged attack if (attacked == null && item != null) { @@ -129,7 +129,7 @@ namespace Content.Server.GameObjects.EntitySystems InteractAfterattack(player, item, msg.Coordinates); return; } - else if(attacked == null) + else if (attacked == null) { return; } @@ -156,14 +156,14 @@ namespace Content.Server.GameObjects.EntitySystems var distance = (playerTransform.WorldPosition - attacked.GetComponent().WorldPosition).LengthSquared; if (distance > INTERACTION_RANGE_SQUARED) { - if(item != null) + if (item != null) { RangedInteraction(player, item, attacked, msg.Coordinates); return; } return; //Add some form of ranged attackhand here if you need it someday, or perhaps just ways to modify the range of attackhand } - + //We are close to the nearby object and the object isn't contained in our active hand //ATTACKBY/AFTERATTACK: We will either use the item on the nearby object if (item != null) @@ -194,7 +194,7 @@ namespace Content.Server.GameObjects.EntitySystems /// public static void InteractAfterattack(IEntity user, IEntity weapon, LocalCoordinates clicklocation) { - List afterattacks = weapon.GetComponents().ToList(); + List afterattacks = weapon.GetAllComponents().ToList(); for (var i = 0; i < afterattacks.Count; i++) { @@ -211,9 +211,9 @@ namespace Content.Server.GameObjects.EntitySystems /// public static void Interaction(IEntity user, IEntity weapon, IEntity attacked, LocalCoordinates clicklocation) { - List interactables = attacked.GetComponents().ToList(); + List interactables = attacked.GetAllComponents().ToList(); - for(var i = 0; i < interactables.Count; i++) + for (var i = 0; i < interactables.Count; i++) { if (interactables[i].Attackby(user, weapon)) //If an attackby returns a status completion we finish our attack { @@ -225,7 +225,7 @@ namespace Content.Server.GameObjects.EntitySystems //If we aren't directly attacking the nearby object, lets see if our item has an after attack we can do - List afterattacks = weapon.GetComponents().ToList(); + List afterattacks = weapon.GetAllComponents().ToList(); for (var i = 0; i < afterattacks.Count; i++) { @@ -241,7 +241,7 @@ namespace Content.Server.GameObjects.EntitySystems /// public static void Interaction(IEntity user, IEntity attacked) { - List interactables = attacked.GetComponents().ToList(); + List interactables = attacked.GetAllComponents().ToList(); for (var i = 0; i < interactables.Count; i++) { @@ -262,7 +262,7 @@ namespace Content.Server.GameObjects.EntitySystems /// public static void TryUseInteraction(IEntity user, IEntity used) { - if(user != null && used != null && MobCanInteract(user)) + if (user != null && used != null && MobCanInteract(user)) { UseInteraction(user, used); } @@ -276,7 +276,7 @@ namespace Content.Server.GameObjects.EntitySystems /// public static void UseInteraction(IEntity user, IEntity used) { - List usables = used.GetComponents().ToList(); + List usables = used.GetAllComponents().ToList(); //Try to use item on any components which have the interface for (var i = 0; i < usables.Count; i++) @@ -297,7 +297,7 @@ namespace Content.Server.GameObjects.EntitySystems /// public static void RangedInteraction(IEntity user, IEntity weapon, IEntity attacked, LocalCoordinates clicklocation) { - List rangedusables = attacked.GetComponents().ToList(); + List rangedusables = attacked.GetAllComponents().ToList(); //See if we have a ranged attack interaction for (var i = 0; i < rangedusables.Count; i++) @@ -308,9 +308,9 @@ namespace Content.Server.GameObjects.EntitySystems } } - if(weapon != null) + if (weapon != null) { - List afterattacks = weapon.GetComponents().ToList(); + List afterattacks = weapon.GetAllComponents().ToList(); //See if we have a ranged attack interaction for (var i = 0; i < afterattacks.Count; i++) diff --git a/engine b/engine index cb469c4f86..1375da7f70 160000 --- a/engine +++ b/engine @@ -1 +1 @@ -Subproject commit cb469c4f86502d5616ccae6ec96f4aa50eb1c3fd +Subproject commit 1375da7f70c37c0dac32a6c944b2792155cf23ab