diff --git a/Maple2.File.Ingest/Mapper/MapEntityMapper.cs b/Maple2.File.Ingest/Mapper/MapEntityMapper.cs index ad8349fae..b2ad7e155 100644 --- a/Maple2.File.Ingest/Mapper/MapEntityMapper.cs +++ b/Maple2.File.Ingest/Mapper/MapEntityMapper.cs @@ -25,7 +25,8 @@ private IEnumerable ParseMap(string xblock, IEnumerable e IMS2Bounding? secondBounding = null; Dictionary ms2WayPoints = new(); - foreach (var wayPoint in entities) { + IMapEntity[] mapEntities = entities as IMapEntity[] ?? entities.ToArray(); + foreach (IMapEntity wayPoint in mapEntities) { switch (wayPoint) { case IMS2WayPoint ms2WayPoint: ms2WayPoints.Add(ms2WayPoint.EntityId, ms2WayPoint); @@ -35,7 +36,7 @@ private IEnumerable ParseMap(string xblock, IEnumerable e } } - foreach (IMapEntity entity in entities) { + foreach (IMapEntity entity in mapEntities) { switch (entity) { case IMS2InteractObject interactObject: @@ -56,6 +57,9 @@ private IEnumerable ParseMap(string xblock, IEnumerable e }; continue; case IMS2SimpleUiObject simpleUiObject: + yield return new MapEntity(xblock, new Guid(entity.EntityId), entity.EntityName) { + Block = new Ms2SimpleUiObject(simpleUiObject.interactID, simpleUiObject.Position, simpleUiObject.Rotation), + }; continue; case IMS2Telescope telescope: yield return new MapEntity(xblock, new Guid(entity.EntityId), entity.EntityName) { diff --git a/Maple2.File.Ingest/Program.cs b/Maple2.File.Ingest/Program.cs index 9af669bcd..a6886c9b2 100644 --- a/Maple2.File.Ingest/Program.cs +++ b/Maple2.File.Ingest/Program.cs @@ -222,11 +222,11 @@ var index = new FlatTypeIndex(exportedReader); -XBlockParser parser = new XBlockParser(exportedReader, index); +var xBlockParser = new XBlockParser(exportedReader, index); -UpdateDatabase(metadataContext, new MapEntityMapper(metadataContext, parser)); +UpdateDatabase(metadataContext, new MapEntityMapper(metadataContext, xBlockParser)); -MapDataMapper mapDataMapper = new MapDataMapper(metadataContext, parser); +var mapDataMapper = new MapDataMapper(metadataContext, xBlockParser); UpdateDatabase(metadataContext, mapDataMapper); diff --git a/Maple2.Model/Common/Vector.cs b/Maple2.Model/Common/Vector.cs index bcdb76b83..8d73c81b4 100644 --- a/Maple2.Model/Common/Vector.cs +++ b/Maple2.Model/Common/Vector.cs @@ -40,6 +40,9 @@ public static implicit operator Vector3(Vector3B vector) { public static Vector3B operator +(in Vector3B a, in Vector3B b) => new((sbyte) (a.X + b.X), (sbyte) (a.Y + b.Y), (sbyte) (a.Z + b.Z)); + public static Vector3 operator *(in Vector3B a, float multiplier) => + new(a.X * multiplier, a.Y * multiplier, a.Z * multiplier); + public int ConvertToInt() { // Convert x, y, and z to a single 24-bit integer return ((Z & 0xFF) << 16) | ((Y & 0xFF) << 8) | (X & 0xFF); diff --git a/Maple2.Server.Game/Commands/CoordCommand.cs b/Maple2.Server.Game/Commands/CoordCommand.cs index 5f72b6031..7289eadc0 100644 --- a/Maple2.Server.Game/Commands/CoordCommand.cs +++ b/Maple2.Server.Game/Commands/CoordCommand.cs @@ -36,8 +36,10 @@ private void Handle(InvocationContext ctx, string? x, string? y, string? z, bool if (session.Field is null) return; Vector3 pos = session.Player.Position; + Vector3B vector3B = pos; + Vector3 center = vector3B * Constant.BlockSize; if (x == null && y == null && z == null) { - ctx.Console.Out.WriteLine("Current position: " + pos + ", Vector3B: " + (Vector3B) pos); + ctx.Console.Out.WriteLine("Current position: " + pos + "\nVector3B: " + vector3B + "\nBlock center: " + center); return; } diff --git a/Maple2.Server.Game/Manager/Field/FieldManager/FieldManager.State.cs b/Maple2.Server.Game/Manager/Field/FieldManager/FieldManager.State.cs index fe7a2cbc2..42daf528b 100644 --- a/Maple2.Server.Game/Manager/Field/FieldManager/FieldManager.State.cs +++ b/Maple2.Server.Game/Manager/Field/FieldManager/FieldManager.State.cs @@ -750,7 +750,7 @@ public bool RemoveInteract(IInteractObject interactObject, TimeSpan removeDelay } public bool RemoveNpc(int objectId, TimeSpan removeDelay = default) { - if (!Mobs.TryGetValue(objectId, out FieldNpc? npc) && !Npcs.TryGetValue(objectId, out npc)) { + if (!Mobs.TryGetValue(objectId, out _) && !Npcs.TryGetValue(objectId, out _)) { return false; }