예제 #1
0
        private static void AddObjectToScene(RoomScene room, short gridX, short gridY, byte objectId, byte subType = 0, Dictionary <string, short> paramList = null)
        {
            // Adjust for World Gaps
            gridX += (byte)TilemapEnum.GapLeft;
            gridY += (byte)TilemapEnum.GapUp;

            // Prepare Position
            FVector pos = FVector.Create(
                Snap.GridToPos((short)TilemapEnum.TileWidth, gridX),
                Snap.GridToPos((short)TilemapEnum.TileHeight, gridY)
                );

            GameMapper mapper = Systems.mapper;

            // Identify Object Class Type
            Type classType;
            bool hasType = mapper.ObjectTypeDict.TryGetValue(objectId, out classType);

            if (!hasType || classType == null)
            {
                return;
            }

            // Create Object
            GameObject gameObj = (GameObject)Activator.CreateInstance(classType, new object[] { room, (byte)subType, (FVector)pos, (Dictionary <string, short>)paramList });

            // Add the Object to the Scene
            if (gameObj is GameObject)
            {
                room.AddToScene((GameObject)gameObj, true);
            }
        }