enemy spawner

This commit is contained in:
2025-10-26 14:17:31 +01:00
parent 20d3b46834
commit 40a62b5b5a
2102 changed files with 1255290 additions and 70 deletions

View File

@@ -11,7 +11,14 @@ namespace MegaKoop.Game.Networking
CharacterTransform = 3,
WeaponFire = 4,
HealthSync = 5,
ProjectileSpawn = 6
ProjectileSpawn = 6,
ProjectileImpact = 7
}
public enum ProjectileImpactKind : byte
{
Hero = 0,
Enemy = 1
}
public readonly struct NetworkMessage
@@ -213,4 +220,36 @@ namespace MegaKoop.Game.Networking
return new ProjectileSpawnMessage(networkId, index, position, direction, speed, life, damage);
}
}
public readonly struct ProjectileImpactMessage
{
public readonly ProjectileImpactKind Kind;
public readonly Vector3 Position;
public readonly Vector3 Normal;
public ProjectileImpactMessage(ProjectileImpactKind kind, Vector3 position, Vector3 normal)
{
Kind = kind;
Position = position;
Normal = normal;
}
public static byte[] Serialize(ProjectileImpactMessage message)
{
using var writer = new NetworkWriter();
writer.Write((byte)message.Kind);
writer.Write(message.Position);
writer.Write(message.Normal);
return writer.ToArray();
}
public static ProjectileImpactMessage Deserialize(byte[] buffer)
{
using var reader = new NetworkReader(buffer);
ProjectileImpactKind kind = (ProjectileImpactKind)reader.ReadByte();
Vector3 position = reader.ReadVector3();
Vector3 normal = reader.ReadVector3();
return new ProjectileImpactMessage(kind, position, normal);
}
}
}