Merge branch 'NetworkLivingEntitiesSupport'

This commit is contained in:
AnloGames 2023-08-18 14:26:07 +03:00
commit 221f5f15a2
5 changed files with 19 additions and 18 deletions

View file

@ -247,11 +247,6 @@ namespace DangerousD.GameCore.GameObjects.LivingEntities
}
}
}
if (AppManager.Instance.multiPlayerStatus != MultiPlayerStatus.SinglePlayer)
{
NetworkTask task = new NetworkTask(id, Pos);
AppManager.Instance.NetworkTasks.Add(task);
}
}
public void MoveDown()
{

View file

@ -1,4 +1,6 @@
using Microsoft.Xna.Framework;
using DangerousD.GameCore.GameObjects.LivingEntities;
using DangerousD.GameCore.Network;
using Microsoft.Xna.Framework;
namespace DangerousD.GameCore.GameObjects;
@ -15,6 +17,14 @@ public abstract class LivingEntity : Entity
public override void SetPosition(Vector2 position)
{
_pos = position;
if (AppManager.Instance.multiPlayerStatus != MultiPlayerStatus.SinglePlayer)
{
NetworkTask task = new NetworkTask(id, _pos);
if (this is Player || AppManager.Instance.multiPlayerStatus == MultiPlayerStatus.Host)
{
AppManager.Instance.NetworkTasks.Add(task);
}
}
} //TODO befrend targetpos and physics engine

View file

@ -1,4 +1,6 @@
using DangerousD.GameCore.Managers;
using DangerousD.GameCore.GameObjects;
using DangerousD.GameCore.GameObjects.LivingEntities;
using DangerousD.GameCore.Managers;
using DangerousD.GameCore.Network;
using Microsoft.Xna.Framework;
using Microsoft.Xna.Framework.Content;
@ -107,13 +109,13 @@ namespace DangerousD.GameCore.Graphics
public void StartAnimation(string startedanimationId)
{
if (startedanimationId == "playerShootRight" && parentId == 17)
{
string a = "2";
}
if (AppManager.Instance.multiPlayerStatus != MultiPlayerStatus.SinglePlayer && startedanimationId != GetCurrentAnimation)
if (AppManager.Instance.multiPlayerStatus != MultiPlayerStatus.SinglePlayer)
{
LivingEntity entity = AppManager.Instance.GameManager.livingEntities.Find(x => x.id == parentId);
if (((entity is Player) || AppManager.Instance.multiPlayerStatus == MultiPlayerStatus.Host) && startedanimationId != GetCurrentAnimation)
{
AppManager.Instance.NetworkTasks.Add(new NetworkTask(parentId, startedanimationId, Vector2.Zero));
}
}
currentFrame = 0;
currentAnimation = animations.Find(x => x.Id == startedanimationId);

View file

@ -246,11 +246,6 @@ namespace DangerousD.GameCore
case NetworkTaskOperationEnum.ChangeState:
if (networkTask.objId != GameManager.GetPlayer1.id)
{
List<GraphicsComponent> gcs = new List<GraphicsComponent>();
foreach (var player in GameManager.players)
{
gcs.Add(player.GetGraphicsComponent());
}
LivingEntity entity = GameManager.livingEntities.Find(x => x.id == networkTask.objId);
if (entity != null)
{

View file

@ -149,7 +149,6 @@ namespace DangerousD.GameCore
}
}
else
{
for (int i = 0; i < livingEntitiesWithoutPlayers.Count; i++)
{