diff --git a/ZoFo/GameCore/GameManagers/CollisionManager/CollisionManager.cs b/ZoFo/GameCore/GameManagers/CollisionManager/CollisionManager.cs index 8cf63f2..5242d4a 100644 --- a/ZoFo/GameCore/GameManagers/CollisionManager/CollisionManager.cs +++ b/ZoFo/GameCore/GameManagers/CollisionManager/CollisionManager.cs @@ -17,7 +17,10 @@ namespace ZoFo.GameCore.GameManagers.CollisionManager public List CollisionComponent; public List TriggerComponent; - + public void RegisterComponent() + { + + } public static bool CheckComponentCollision(List collisionComponents, CollisionComponent component) { diff --git a/ZoFo/GameCore/GameManagers/NetworkManager/Updates/ServerToClient/UpdateInteraction.cs b/ZoFo/GameCore/GameManagers/NetworkManager/Updates/ServerToClient/UpdateInteraction.cs new file mode 100644 index 0000000..6c87be3 --- /dev/null +++ b/ZoFo/GameCore/GameManagers/NetworkManager/Updates/ServerToClient/UpdateInteraction.cs @@ -0,0 +1,7 @@ +namespace ZoFo.GameCore.GameManagers.NetworkManager.Updates.ServerToClient; + +public class UpdateInteraction : IUpdateData // при попытке взаимодействия с объектом +{ + public int IdEntity { get; set; } + public string UpdateType { get; set; } +} \ No newline at end of file diff --git a/ZoFo/GameCore/GameManagers/NetworkManager/Updates/ServerToClient/UpdateInteractionAvailable.cs b/ZoFo/GameCore/GameManagers/NetworkManager/Updates/ServerToClient/UpdateInteractionAvailable.cs new file mode 100644 index 0000000..26471f5 --- /dev/null +++ b/ZoFo/GameCore/GameManagers/NetworkManager/Updates/ServerToClient/UpdateInteractionAvailable.cs @@ -0,0 +1,9 @@ +namespace ZoFo.GameCore.GameManagers.NetworkManager.Updates.ServerToClient; + +public class UpdateInteractionAvailable(int idEntity, bool isReady) + : IUpdateData // при изменении возможности повзаимодействовать с объектом +{ + public int IdEntity { get; set; } = idEntity; + public string UpdateType { get; set; } + public bool IsReady { get; set; } = isReady; +} \ No newline at end of file diff --git a/ZoFo/GameCore/GameObjects/Entities/Interactables/Collectables/Collectable.cs b/ZoFo/GameCore/GameObjects/Entities/Interactables/Collectables/Collectable.cs index b900e4a..d31d536 100644 --- a/ZoFo/GameCore/GameObjects/Entities/Interactables/Collectables/Collectable.cs +++ b/ZoFo/GameCore/GameObjects/Entities/Interactables/Collectables/Collectable.cs @@ -2,7 +2,7 @@ using System; namespace ZoFo.GameCore.GameObjects.Entities.Interactables.Collectables; -public class Collectable : Entity +public class Collectable : Interactable { public Collectable(Vector2 position) : base(position) { diff --git a/ZoFo/GameCore/GameObjects/Entities/Interactables/Interactable.cs b/ZoFo/GameCore/GameObjects/Entities/Interactables/Interactable.cs new file mode 100644 index 0000000..60d4576 --- /dev/null +++ b/ZoFo/GameCore/GameObjects/Entities/Interactables/Interactable.cs @@ -0,0 +1,21 @@ +using Microsoft.Xna.Framework; +using ZoFo.GameCore.GameManagers; +using ZoFo.GameCore.GameManagers.CollisionManager; +using ZoFo.GameCore.GameManagers.NetworkManager.Updates.ServerToClient; +using ZoFo.GameCore.GameObjects.Entities.LivingEntities.Player; + +namespace ZoFo.GameCore.GameObjects.Entities.Interactables; + +public class Interactable : Entity +{ + public Interactable(Vector2 position) : base(position) + { + collisionComponent.OnTriggerEnter += (sender, e) => ChangeInteraction(sender, e, true); + collisionComponent.OnTriggerExit += (sender, e) => ChangeInteraction(sender, e, false); + } + + private void ChangeInteraction(object sender, CollisionComponent e, bool isReady) + { + AppManager.Instance.server.AddData(new UpdateInteractionAvailable((sender as Player).Id, isReady)); + } +} \ No newline at end of file