Exemplo n.º 1
0
        public static BuildingMessage PrepareBuilding(ushort id)
        {
            if (!ManagersUtil.ExistsBuilding(id))
            {
                return(null);
            }
            Building building = ManagersUtil.BuildingS(id);

            return(new BuildingMessage()
            {
                id = id,
                position = building.m_position.FromUnity(),
                prefab_name = building.Info.name,
                angle = building.m_angle
            });
        }
Exemplo n.º 2
0
        public static BatchObjectMessage PrepareBuildingsStartingFromIndex(ushort id)
        {
            var    buffer           = ManagersUtil.BuildingManager.m_buildings.m_buffer;
            var    resultArray      = new BuildingData[500];
            int    resultArrayIndex = 0;
            bool   endOfStream      = true;
            ushort i;

            for (i = id; i < buffer.Length; i++)
            {
                if (ManagersUtil.ExistsBuilding(i))
                {
                    resultArray[resultArrayIndex] = PrepareBuilding(i);
                    resultArrayIndex++;
                    if (resultArrayIndex == 500)
                    {
                        endOfStream = false;
                        break;
                    }
                }
                if (i == ushort.MaxValue)
                {
                    break;
                }
            }
            if (endOfStream)
            {
                Array.Resize(ref resultArray, resultArrayIndex);
            }
            return(new BatchObjectMessage()
            {
                array = resultArray,
                endOfStream = endOfStream,
                lastVisitedIndex = i
            });
        }