コード例 #1
0
    private void AddRegionName(DefaultWorldViewTechnique defaultWorldViewTechnique, HxTechniqueGraphicData.RegionNameGraphicData.RegionData regionData, Region region)
    {
        InstanciedMeshHolders instanciedMeshHolders       = defaultWorldViewTechnique.HxTechniqueGraphicData.InstanciedMeshHolders;
        InstanciedMeshBlock   orCreateInstanciedMeshBlock = instanciedMeshHolders.GetOrCreateInstanciedMeshBlock(0, 67108864UL, InstanciedMeshHelpers.LetterPixelsPerInstance);
        Vector3 absoluteWorldPosition2D = AbstractGlobalPositionning.GetAbsoluteWorldPosition2D((int)regionData.Center.Row, (int)regionData.Center.Column);

        absoluteWorldPosition2D.y = base.GlobalPositionningService.GetAltitudeFromAbsoluteWorldPosition(new Vector3(absoluteWorldPosition2D.x, 0f, absoluteWorldPosition2D.z));
        string  localizedName     = region.LocalizedName;
        AgeFont ageFont           = this.regionNameGraphicData.AgeFont;
        int     orCreateMeshIndex = AbstractRegionPatchRenderer.GetOrCreateMeshIndex(this.regionNameGraphicData.Material, defaultWorldViewTechnique.HxTechniqueGraphicData.InstanciedMeshHolders);
        float   textSize          = this.regionNameGraphicData.TextSize;
        bool    disableKerning    = GameManager.Preferences.GameGraphicSettings.DisableKerning;
        float   num  = 0f;
        float   num2 = 0f;
        float   num3 = 0f;
        float   num4 = 0f;
        float   num5 = 0f;

        for (int i = 0; i < localizedName.Length; i++)
        {
            char    charcode     = localizedName[i];
            char    nextCharCode = (disableKerning || i + 1 >= localizedName.Length) ? '\0' : localizedName[i + 1];
            Vector2 vector;
            Vector2 vector2;
            Rect    rect;
            float   num6;
            ageFont.GetCharInfo(charcode, nextCharCode, out vector, out vector2, out rect, out num6);
            num2 = Math.Min(num + vector2.x, num2);
            num3 = Math.Max(num + vector2.x + vector.x, num3);
            num4 = Math.Min(num4, -vector2.y - vector.y);
            num5 = Math.Max(num5, -vector2.y);
            num += num6;
        }
        float z    = -(num4 + num5) * 0.5f;
        float num7 = -(num2 + num3) * 0.5f;

        for (int j = 0; j < localizedName.Length; j++)
        {
            char    charcode2     = localizedName[j];
            char    nextCharCode2 = (disableKerning || j + 1 >= localizedName.Length) ? '\0' : localizedName[j + 1];
            Vector2 vector3;
            Vector2 vector4;
            Rect    rect2;
            float   num8;
            ageFont.GetCharInfo(charcode2, nextCharCode2, out vector3, out vector4, out rect2, out num8);
            if (vector3.x > 0f && vector3.y > 0f)
            {
                float num9 = 128f;
                bool  flag = rect2.xMin >= num9;
                int   minPixelIndexX;
                int   minPixelIndexY;
                int   pixelCountX;
                int   pixelCountY;
                if (flag)
                {
                    minPixelIndexX = Mathf.RoundToInt(rect2.xMin - num9);
                    minPixelIndexY = Mathf.RoundToInt(rect2.yMin - num9);
                    pixelCountX    = (int)rect2.width;
                    pixelCountY    = (int)rect2.height;
                }
                else
                {
                    minPixelIndexX = Mathf.RoundToInt(rect2.xMin * (float)this.regionNameGraphicData.FontTextureWidth);
                    minPixelIndexY = Mathf.RoundToInt(rect2.yMin * (float)this.regionNameGraphicData.FontTextureHeight);
                    pixelCountX    = Mathf.RoundToInt(rect2.width * (float)this.regionNameGraphicData.FontTextureWidth);
                    pixelCountY    = Mathf.RoundToInt(rect2.height * (float)this.regionNameGraphicData.FontTextureHeight);
                }
                Vector3 a = new Vector3(num7, 0f, z) + new Vector3(vector4.x, 0f, -vector4.y) - new Vector3(0f, 0f, vector3.y);
                InstanciedMeshHelpers.AddLetterInstance(instanciedMeshHolders, orCreateInstanciedMeshBlock, absoluteWorldPosition2D + textSize * a, minPixelIndexX, minPixelIndexY, pixelCountX, pixelCountY, vector3 * textSize, orCreateMeshIndex, flag);
            }
            num7 += num8;
        }
        orCreateInstanciedMeshBlock.CloseAndSort();
        if (this.regionNameInstanciedMeshBlocks == null)
        {
            this.regionNameInstanciedMeshBlocks = new List <InstanciedMeshBlock>();
        }
        this.regionNameInstanciedMeshBlocks.Add(orCreateInstanciedMeshBlock);
        base.AddInstanciedMeshBlock(orCreateInstanciedMeshBlock, false);
    }
コード例 #2
0
    protected void AddText(string stringToWrite, float textSizeMultiplier, Vector3 absoluteWorldPosition)
    {
        this.CreateDebugInstanciedMeshBlockIFN();
        AgeFont ageFont           = this.debugGraphicData.AgeFont;
        int     orCreateMeshIndex = AbstractDebugPatchRenderer.GetOrCreateMeshIndex(this.debugGraphicData.Material, this.instanciedMeshHolders);
        float   d    = textSizeMultiplier * this.debugGraphicData.TextSize;
        float   num  = 0f;
        float   num2 = 0f;
        float   num3 = 0f;
        float   num4 = 0f;
        float   num5 = 0f;
        float   num6 = 0f;

        for (int i = 0; i < stringToWrite.Length; i++)
        {
            char c = stringToWrite[i];
            if (c == '\n')
            {
                num2 -= ageFont.LineHeight;
                num   = 0f;
            }
            else
            {
                char    nextCharCode = (i + 1 >= stringToWrite.Length) ? '\0' : stringToWrite[i];
                Vector2 vector;
                Vector2 vector2;
                Rect    rect;
                float   num7;
                ageFont.GetCharInfo(c, nextCharCode, out vector, out vector2, out rect, out num7);
                num3 = Math.Min(num + vector2.x, num3);
                num4 = Math.Max(num + vector2.x + vector.x, num4);
                num5 = Math.Min(num5, -vector2.y - vector.y + num2);
                num6 = Math.Max(num6, -vector2.y + num2);
                num += num7;
            }
        }
        float num8  = -(num5 + num6) * 0.5f;
        float num9  = -(num3 + num4) * 0.5f;
        float num10 = num9;
        float num11 = num8;

        for (int j = 0; j < stringToWrite.Length; j++)
        {
            char c2 = stringToWrite[j];
            if (c2 == '\n')
            {
                num11 -= ageFont.LineHeight;
                num10  = num9;
            }
            else
            {
                char    nextCharCode2 = (j + 1 >= stringToWrite.Length) ? '\0' : stringToWrite[j];
                Vector2 vector3;
                Vector2 vector4;
                Rect    rect2;
                float   num12;
                ageFont.GetCharInfo(c2, nextCharCode2, out vector3, out vector4, out rect2, out num12);
                if (vector3.x > 0f && vector3.y > 0f)
                {
                    Vector3 a = new Vector3(num10, 0f, num11 + num8) + new Vector3(vector4.x, 0f, -vector4.y) - new Vector3(0f, 0f, vector3.y);
                    int     minPixelIndexX = Mathf.RoundToInt(rect2.xMin * (float)this.debugGraphicData.FontTextureWidth);
                    int     minPixelIndexY = Mathf.RoundToInt(rect2.yMin * (float)this.debugGraphicData.FontTextureHeight);
                    int     pixelCountX    = Mathf.RoundToInt(rect2.width * (float)this.debugGraphicData.FontTextureWidth);
                    int     pixelCountY    = Mathf.RoundToInt(rect2.height * (float)this.debugGraphicData.FontTextureHeight);
                    InstanciedMeshHelpers.AddLetterInstance(this.instanciedMeshHolders, this.debugTextInstanciedMeshBlock, absoluteWorldPosition + d * a, minPixelIndexX, minPixelIndexY, pixelCountX, pixelCountY, vector3 * d, orCreateMeshIndex, false);
                }
                num10 += num12;
            }
        }
    }