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.
This commit is contained in:
committed by
GitHub
parent
205a4fc530
commit
20cf3a6a9b
@@ -119,7 +119,7 @@ namespace Content.Server.GameObjects
|
|||||||
|
|
||||||
void RecalculateComponentThresholds()
|
void RecalculateComponentThresholds()
|
||||||
{
|
{
|
||||||
foreach (IOnDamageBehavior onDamageBehaviorComponent in Owner.GetComponents<IOnDamageBehavior>())
|
foreach (IOnDamageBehavior onDamageBehaviorComponent in Owner.GetAllComponents<IOnDamageBehavior>())
|
||||||
{
|
{
|
||||||
AddThresholdsFrom(onDamageBehaviorComponent);
|
AddThresholdsFrom(onDamageBehaviorComponent);
|
||||||
}
|
}
|
||||||
|
|||||||
@@ -8,11 +8,11 @@ namespace Content.Server.GameObjects
|
|||||||
public class ItemComponent : StoreableComponent, EntitySystems.IAttackHand
|
public class ItemComponent : StoreableComponent, EntitySystems.IAttackHand
|
||||||
{
|
{
|
||||||
public override string Name => "Item";
|
public override string Name => "Item";
|
||||||
|
|
||||||
|
|
||||||
public void RemovedFromSlot()
|
public void RemovedFromSlot()
|
||||||
{
|
{
|
||||||
foreach (var component in Owner.GetComponents<ISpriteRenderableComponent>())
|
foreach (var component in Owner.GetAllComponents<ISpriteRenderableComponent>())
|
||||||
{
|
{
|
||||||
component.Visible = true;
|
component.Visible = true;
|
||||||
}
|
}
|
||||||
@@ -20,7 +20,7 @@ namespace Content.Server.GameObjects
|
|||||||
|
|
||||||
public void EquippedToSlot(ContainerSlot slot)
|
public void EquippedToSlot(ContainerSlot slot)
|
||||||
{
|
{
|
||||||
foreach (var component in Owner.GetComponents<ISpriteRenderableComponent>())
|
foreach (var component in Owner.GetAllComponents<ISpriteRenderableComponent>())
|
||||||
{
|
{
|
||||||
component.Visible = false;
|
component.Visible = false;
|
||||||
}
|
}
|
||||||
|
|||||||
@@ -48,16 +48,16 @@ namespace Content.Server.GameObjects.EntitySystems
|
|||||||
StringBuilder fullexaminetext = new StringBuilder("This is " + examined.Name);
|
StringBuilder fullexaminetext = new StringBuilder("This is " + examined.Name);
|
||||||
|
|
||||||
//Add an entity description if one is declared
|
//Add an entity description if one is declared
|
||||||
if(!string.IsNullOrEmpty(examined.Description))
|
if (!string.IsNullOrEmpty(examined.Description))
|
||||||
{
|
{
|
||||||
fullexaminetext.Append(Environment.NewLine + examined.Description);
|
fullexaminetext.Append(Environment.NewLine + examined.Description);
|
||||||
}
|
}
|
||||||
|
|
||||||
//Add component statuses from components that report one
|
//Add component statuses from components that report one
|
||||||
foreach (var examinecomponents in examined.GetComponents<IExamine>())
|
foreach (var examinecomponents in examined.GetAllComponents<IExamine>())
|
||||||
{
|
{
|
||||||
string componentdescription = examinecomponents.Examine();
|
string componentdescription = examinecomponents.Examine();
|
||||||
if(!string.IsNullOrEmpty(componentdescription))
|
if (!string.IsNullOrEmpty(componentdescription))
|
||||||
{
|
{
|
||||||
fullexaminetext.Append(Environment.NewLine + componentdescription);
|
fullexaminetext.Append(Environment.NewLine + componentdescription);
|
||||||
}
|
}
|
||||||
|
|||||||
@@ -95,7 +95,7 @@ namespace Content.Server.GameObjects.EntitySystems
|
|||||||
IEntity attacked = null;
|
IEntity attacked = null;
|
||||||
if (msg.Uid.IsValid())
|
if (msg.Uid.IsValid())
|
||||||
attacked = EntityManager.GetEntity(msg.Uid);
|
attacked = EntityManager.GetEntity(msg.Uid);
|
||||||
|
|
||||||
//Verify player has a transform component
|
//Verify player has a transform component
|
||||||
if (!player.TryGetComponent<IServerTransformComponent>(out var playerTransform))
|
if (!player.TryGetComponent<IServerTransformComponent>(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
|
//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
|
//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
|
//Clicked on empty space behavior, try using ranged attack
|
||||||
if (attacked == null && item != null)
|
if (attacked == null && item != null)
|
||||||
{
|
{
|
||||||
@@ -129,7 +129,7 @@ namespace Content.Server.GameObjects.EntitySystems
|
|||||||
InteractAfterattack(player, item, msg.Coordinates);
|
InteractAfterattack(player, item, msg.Coordinates);
|
||||||
return;
|
return;
|
||||||
}
|
}
|
||||||
else if(attacked == null)
|
else if (attacked == null)
|
||||||
{
|
{
|
||||||
return;
|
return;
|
||||||
}
|
}
|
||||||
@@ -156,14 +156,14 @@ namespace Content.Server.GameObjects.EntitySystems
|
|||||||
var distance = (playerTransform.WorldPosition - attacked.GetComponent<IServerTransformComponent>().WorldPosition).LengthSquared;
|
var distance = (playerTransform.WorldPosition - attacked.GetComponent<IServerTransformComponent>().WorldPosition).LengthSquared;
|
||||||
if (distance > INTERACTION_RANGE_SQUARED)
|
if (distance > INTERACTION_RANGE_SQUARED)
|
||||||
{
|
{
|
||||||
if(item != null)
|
if (item != null)
|
||||||
{
|
{
|
||||||
RangedInteraction(player, item, attacked, msg.Coordinates);
|
RangedInteraction(player, item, attacked, msg.Coordinates);
|
||||||
return;
|
return;
|
||||||
}
|
}
|
||||||
return; //Add some form of ranged attackhand here if you need it someday, or perhaps just ways to modify the range of attackhand
|
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
|
//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
|
//ATTACKBY/AFTERATTACK: We will either use the item on the nearby object
|
||||||
if (item != null)
|
if (item != null)
|
||||||
@@ -194,7 +194,7 @@ namespace Content.Server.GameObjects.EntitySystems
|
|||||||
/// <param name="clicklocation"></param>
|
/// <param name="clicklocation"></param>
|
||||||
public static void InteractAfterattack(IEntity user, IEntity weapon, LocalCoordinates clicklocation)
|
public static void InteractAfterattack(IEntity user, IEntity weapon, LocalCoordinates clicklocation)
|
||||||
{
|
{
|
||||||
List<IAfterAttack> afterattacks = weapon.GetComponents<IAfterAttack>().ToList();
|
List<IAfterAttack> afterattacks = weapon.GetAllComponents<IAfterAttack>().ToList();
|
||||||
|
|
||||||
for (var i = 0; i < afterattacks.Count; i++)
|
for (var i = 0; i < afterattacks.Count; i++)
|
||||||
{
|
{
|
||||||
@@ -211,9 +211,9 @@ namespace Content.Server.GameObjects.EntitySystems
|
|||||||
/// <param name="attacked"></param>
|
/// <param name="attacked"></param>
|
||||||
public static void Interaction(IEntity user, IEntity weapon, IEntity attacked, LocalCoordinates clicklocation)
|
public static void Interaction(IEntity user, IEntity weapon, IEntity attacked, LocalCoordinates clicklocation)
|
||||||
{
|
{
|
||||||
List<IAttackby> interactables = attacked.GetComponents<IAttackby>().ToList();
|
List<IAttackby> interactables = attacked.GetAllComponents<IAttackby>().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
|
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
|
//If we aren't directly attacking the nearby object, lets see if our item has an after attack we can do
|
||||||
List<IAfterAttack> afterattacks = weapon.GetComponents<IAfterAttack>().ToList();
|
List<IAfterAttack> afterattacks = weapon.GetAllComponents<IAfterAttack>().ToList();
|
||||||
|
|
||||||
for (var i = 0; i < afterattacks.Count; i++)
|
for (var i = 0; i < afterattacks.Count; i++)
|
||||||
{
|
{
|
||||||
@@ -241,7 +241,7 @@ namespace Content.Server.GameObjects.EntitySystems
|
|||||||
/// <param name="attacked"></param>
|
/// <param name="attacked"></param>
|
||||||
public static void Interaction(IEntity user, IEntity attacked)
|
public static void Interaction(IEntity user, IEntity attacked)
|
||||||
{
|
{
|
||||||
List<IAttackHand> interactables = attacked.GetComponents<IAttackHand>().ToList();
|
List<IAttackHand> interactables = attacked.GetAllComponents<IAttackHand>().ToList();
|
||||||
|
|
||||||
for (var i = 0; i < interactables.Count; i++)
|
for (var i = 0; i < interactables.Count; i++)
|
||||||
{
|
{
|
||||||
@@ -262,7 +262,7 @@ namespace Content.Server.GameObjects.EntitySystems
|
|||||||
/// <param name="used"></param>
|
/// <param name="used"></param>
|
||||||
public static void TryUseInteraction(IEntity user, IEntity used)
|
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);
|
UseInteraction(user, used);
|
||||||
}
|
}
|
||||||
@@ -276,7 +276,7 @@ namespace Content.Server.GameObjects.EntitySystems
|
|||||||
/// <param name="attacked"></param>
|
/// <param name="attacked"></param>
|
||||||
public static void UseInteraction(IEntity user, IEntity used)
|
public static void UseInteraction(IEntity user, IEntity used)
|
||||||
{
|
{
|
||||||
List<IUse> usables = used.GetComponents<IUse>().ToList();
|
List<IUse> usables = used.GetAllComponents<IUse>().ToList();
|
||||||
|
|
||||||
//Try to use item on any components which have the interface
|
//Try to use item on any components which have the interface
|
||||||
for (var i = 0; i < usables.Count; i++)
|
for (var i = 0; i < usables.Count; i++)
|
||||||
@@ -297,7 +297,7 @@ namespace Content.Server.GameObjects.EntitySystems
|
|||||||
/// <param name="attacked"></param>
|
/// <param name="attacked"></param>
|
||||||
public static void RangedInteraction(IEntity user, IEntity weapon, IEntity attacked, LocalCoordinates clicklocation)
|
public static void RangedInteraction(IEntity user, IEntity weapon, IEntity attacked, LocalCoordinates clicklocation)
|
||||||
{
|
{
|
||||||
List<IRangedAttackby> rangedusables = attacked.GetComponents<IRangedAttackby>().ToList();
|
List<IRangedAttackby> rangedusables = attacked.GetAllComponents<IRangedAttackby>().ToList();
|
||||||
|
|
||||||
//See if we have a ranged attack interaction
|
//See if we have a ranged attack interaction
|
||||||
for (var i = 0; i < rangedusables.Count; i++)
|
for (var i = 0; i < rangedusables.Count; i++)
|
||||||
@@ -308,9 +308,9 @@ namespace Content.Server.GameObjects.EntitySystems
|
|||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
if(weapon != null)
|
if (weapon != null)
|
||||||
{
|
{
|
||||||
List<IAfterAttack> afterattacks = weapon.GetComponents<IAfterAttack>().ToList();
|
List<IAfterAttack> afterattacks = weapon.GetAllComponents<IAfterAttack>().ToList();
|
||||||
|
|
||||||
//See if we have a ranged attack interaction
|
//See if we have a ranged attack interaction
|
||||||
for (var i = 0; i < afterattacks.Count; i++)
|
for (var i = 0; i < afterattacks.Count; i++)
|
||||||
|
|||||||
2
engine
2
engine
Submodule engine updated: cb469c4f86...1375da7f70
Reference in New Issue
Block a user