Пример #1
0
        private static void DrawTextFrame(BoardTextDescriptorGeneralXml textDescriptor, MaterialPropertyBlock materialPropertyBlock, ref Vector3 targetPos, ref Vector3 targetRotation, ref Vector3 baseScale, ref Color parentColor, PrefabInfo srcInfo, Camera targetCamera, ref Matrix4x4 containerMatrix, ref int defaultCallsCounter)
        {
            var frameConfig = textDescriptor.BackgroundMeshSettings.FrameMeshSettings;

            if (m_genMesh is null)
            {
                WTSDisplayContainerMeshUtils.GenerateDisplayContainer(new Vector2(1, 1), new Vector2(1, 1), new Vector2(), 0.05f, 0.3f, 0.1f, out Vector3[] points, out Vector4[] tangents);
Пример #2
0
        private void ApplyShowRules(BoardTextDescriptorGeneralXml x)
        {
            m_customText.parent.isVisible              = x.m_textType == TextType.Fixed;
            m_textFixedColor.parent.isVisible          = !x.ColoringConfig.UseContrastColor;
            m_invertTextHorizontalAlignClone.isVisible = x.PlacingConfig.m_create180degYClone;
            m_sliderIllumination.parent.isVisible      = x.IlluminationConfig.IlluminationType != MaterialType.OPAQUE;
            m_dropdownBlinkType.parent.isVisible       = x.IlluminationConfig.IlluminationType != MaterialType.OPAQUE;
            m_arrayCustomBlink[0].parent.isVisible     = x.IlluminationConfig.IlluminationType != MaterialType.OPAQUE && m_dropdownBlinkType.selectedIndex == (int)BlinkType.Custom;

            m_textPrefix.parent.isVisible         = !x.IsSpriteText();
            m_textSuffix.parent.isVisible         = !x.IsSpriteText();
            m_overrideFontSelect.parent.isVisible = !x.IsSpriteText();
            m_fontClassSelect.parent.isVisible    = !x.IsSpriteText();
            m_allCaps.isVisible             = !x.IsSpriteText();
            m_applyAbbreviations.isVisible  = x.m_textType == TextType.StreetSuffix || x.m_textType == TextType.StreetNameComplete || x.m_textType == TextType.StreetPrefix;
            m_spriteFilter.parent.isVisible = x.m_textType == TextType.GameSprite;

            m_flagsContainer.isVisible = x.IlluminationConfig.IlluminationType == MaterialType.FLAGS;

            m_tabFrame.isVisible = ((Vector2)x.BackgroundMeshSettings.Size).magnitude > 0.001f;
            m_frameBackSize[0].parent.isVisible        = x.BackgroundMeshSettings.UseFrame;
            m_frameBackOffset[0].parent.isVisible      = x.BackgroundMeshSettings.UseFrame;
            m_frameDepths[0].parent.isVisible          = x.BackgroundMeshSettings.UseFrame;
            m_frameFrontBorder.parent.isVisible        = x.BackgroundMeshSettings.UseFrame;
            m_frameGlassTransparency.parent.isVisible  = x.BackgroundMeshSettings.UseFrame;
            m_frameOuterSpecularLevel.parent.isVisible = x.BackgroundMeshSettings.UseFrame;
            m_frameGlassSpecularLevel.parent.isVisible = x.BackgroundMeshSettings.UseFrame;
            m_frameUseVehicleColor.isVisible           = x.BackgroundMeshSettings.UseFrame;
            m_frameColor.parent.isVisible      = x.BackgroundMeshSettings.UseFrame && !x.BackgroundMeshSettings.FrameMeshSettings.InheritColor;
            m_frameGlassColor.parent.isVisible = x.BackgroundMeshSettings.UseFrame;
        }
Пример #3
0
        internal static BasicRenderInformation GetTextMesh(BoardTextDescriptorGeneralXml textDescriptor, ushort refID, int boardIdx, int secIdx, BoardInstanceXml instance, BoardDescriptorGeneralXml propLayout, out IEnumerable <BasicRenderInformation> multipleOutput, PrefabInfo refPrefab)
        {
            multipleOutput = null;
            DynamicSpriteFont baseFont = FontServer.instance[WTSEtcData.Instance.FontSettings.GetTargetFont(textDescriptor.m_fontClass)] ?? FontServer.instance[propLayout?.FontName];

            if (instance is BoardPreviewInstanceXml preview)
            {
                return(GetTextForPreview(textDescriptor, propLayout, ref multipleOutput, ref baseFont, preview, refPrefab));
            }
            else if (instance is LayoutDescriptorVehicleXml vehicleDescriptor)
            {
                return(GetTextForVehicle(textDescriptor, refID, ref baseFont, vehicleDescriptor));
            }
            else if (instance is BoardInstanceBuildingXml buildingDescritpor)
            {
                return(GetTextForBuilding(textDescriptor, refID, boardIdx, secIdx, ref multipleOutput, ref baseFont, buildingDescritpor));
            }
            else if (instance is BoardInstanceRoadNodeXml)
            {
                return(GetTextForRoadNode(textDescriptor, refID, boardIdx, secIdx, ref baseFont));
            }
            else if (instance is OnNetInstanceCacheContainerXml onNet)
            {
                return(GetTextForOnNet(textDescriptor, refID, boardIdx, secIdx, onNet, ref baseFont, out multipleOutput));
            }
            return(WTSCacheSingleton.GetTextData(textDescriptor.m_fixedText ?? "", textDescriptor.m_prefix, textDescriptor.m_suffix, null, textDescriptor.m_overrideFont));
        }
        private void ApplyShowRules(BoardTextDescriptorGeneralXml x)
        {
            m_customText.parent.isVisible              = x.m_textType == TextType.Fixed;
            m_destinationRef.parent.isVisible          = WTSPropLayoutEditor.Instance.EditingInstance.m_allowedRenderClass == TextRenderingClass.PlaceOnNet && x.IsTextRelativeToSegment();
            m_parameterIdx.parent.isVisible            = x.IsParameter();
            m_parameterDisplayName.parent.isVisible    = x.IsParameter();
            m_defaultParameterValue.parent.isVisible   = x.IsParameter();
            m_slideDurationFrames.parent.isVisible     = x.m_textType == TextType.ParameterizedGameSprite;
            m_slideDesync.parent.isVisible             = x.m_textType == TextType.ParameterizedGameSprite;
            m_textFixedColor.parent.isVisible          = !x.ColoringConfig.UseContrastColor;
            m_invertTextHorizontalAlignClone.isVisible = x.PlacingConfig.m_create180degYClone;
            m_sliderIllumination.parent.isVisible      = x.IlluminationConfig.IlluminationType != MaterialType.OPAQUE;
            m_dropdownBlinkType.parent.isVisible       = x.IlluminationConfig.IlluminationType != MaterialType.OPAQUE;
            m_arrayCustomBlink[0].parent.isVisible     = x.IlluminationConfig.IlluminationType != MaterialType.OPAQUE && m_dropdownBlinkType.selectedIndex == (int)BlinkType.Custom;

            m_textPrefix.parent.isVisible         = !x.IsSpriteText();
            m_textSuffix.parent.isVisible         = !x.IsSpriteText();
            m_overrideFontSelect.parent.isVisible = !x.IsSpriteText();
            m_fontClassSelect.parent.isVisible    = !x.IsSpriteText();
            m_allCaps.isVisible                          = !x.IsSpriteText();
            m_spriteFilter.parent.isVisible              = x.m_textType == TextType.GameSprite;
            m_arrayRowColumnsCount[0].parent.isVisible   = x.IsMultiItemText();
            m_arrayRowColumnsSpacing[0].parent.isVisible = x.IsMultiItemText();
            m_checkboxVerticalFirst.isVisible            = x.IsMultiItemText();
            m_verticalAlignDD.parent.isVisible           = x.IsMultiItemText();
        }
Пример #5
0
        private static Matrix4x4 DrawBgMesh(ref Matrix4x4 propMatrix, BoardTextDescriptorGeneralXml textDescriptor, MaterialPropertyBlock materialPropertyBlock, ref Vector3 targetPos,
                                            ref Vector3 targetRotation, ref Vector3 baseScale, UIHorizontalAlignment targetTextAlignment, Camera targetCamera, Tuple <Matrix4x4, Tuple <Matrix4x4, Matrix4x4, Matrix4x4, Matrix4x4> > textMatrixTuple,
                                            PropManager instance, BasicRenderInformation bgBri, ref int defaultCallsCounter)
        {
            materialPropertyBlock.SetColor(WTSDynamicTextRenderingRules.SHADER_PROP_COLOR, textDescriptor.BackgroundMeshSettings.BackgroundColor * new Color(1, 1, 1, 0));
            materialPropertyBlock.SetVector(instance.ID_ObjectIndex, new Vector4());
            var bgBriMatrix = ApplyTextAdjustments(targetPos, targetRotation, bgBri, baseScale, textDescriptor.BackgroundMeshSettings.Size.Y, targetTextAlignment, textDescriptor.BackgroundMeshSettings.Size.X, false, false, false);

            var lineAdjustmentVector = new Vector3(0, (-textDescriptor.BackgroundMeshSettings.Size.Y / 2) + (32 * SCALING_FACTOR * textDescriptor.m_textScale) - (bgBri.m_YAxisOverflows.min + bgBri.m_YAxisOverflows.max) * SCALING_FACTOR * textDescriptor.m_textScale / 2, -0.001f);
            var containerMatrix      = propMatrix
                                       * Matrix4x4.Translate(targetPos)
                                       * textMatrixTuple.Second.Second
                                       * Matrix4x4.Translate(lineAdjustmentVector)
                                       * textMatrixTuple.Second.Fourth
            ;
            var bgMatrix = propMatrix
                           * Matrix4x4.Translate(targetPos)
                           * textMatrixTuple.Second.Second
                           * Matrix4x4.Translate(lineAdjustmentVector)
                           * Matrix4x4.Scale(new Vector3(textDescriptor.BackgroundMeshSettings.Size.X / bgBri.m_mesh.bounds.size.x, textDescriptor.BackgroundMeshSettings.Size.Y / bgBri.m_mesh.bounds.size.y, 1))
                           * textMatrixTuple.Second.Fourth;

            defaultCallsCounter++;
            Graphics.DrawMesh(bgBri.m_mesh, bgMatrix, bgBri.m_generatedMaterial, 10, targetCamera, 0, materialPropertyBlock, false);
            return(containerMatrix);
        }
Пример #6
0
        private void AddTabToItem(UIComponent x, UIMouseEventParameter y)
        {
            var newItem = new BoardTextDescriptorGeneralXml
            {
                SaveName = $"New text"
            };

            EditingInstance.TextDescriptors = EditingInstance.TextDescriptors.Concat(new BoardTextDescriptorGeneralXml[] { newItem }).ToArray();
            FixTabstrip();
        }
Пример #7
0
        private static BasicRenderInformation GetTextForRoadNode(BoardTextDescriptorGeneralXml textDescriptor, ushort refID, int boardIdx, int secIdx, ref DynamicSpriteFont baseFont)
        {
            CacheRoadNodeItem data = WTSRoadNodesData.Instance.BoardsContainers[refID, boardIdx, secIdx];

            if (data == null)
            {
                return(null);
            }

            if (baseFont == null)
            {
                baseFont = FontServer.instance[WTSRoadNodesData.Instance.DefaultFont];
            }

            TextType targetType = textDescriptor.m_textType;

            switch (targetType)
            {
            case TextType.ParkOrDistrict: targetType = data.m_districtParkId > 0 ? TextType.Park : TextType.District; break;

            case TextType.DistrictOrPark: targetType = data.m_districtId == 0 && data.m_districtParkId > 0 ? TextType.Park : TextType.District; break;

            case TextType.Park:
                if (data.m_districtParkId == 0)
                {
                    return(null);
                }
                break;
            }
            switch (targetType)
            {
            case TextType.GameSprite: return(GetSpriteFromParameter(data.m_currentDescriptor.Descriptor.CachedProp, textDescriptor.m_spriteParam));

            case TextType.DistanceFromReference: return(WTSCacheSingleton.GetTextData($"{data.m_distanceRefKm}", textDescriptor.m_prefix, textDescriptor.m_suffix, baseFont, textDescriptor.m_overrideFont));

            case TextType.Fixed: return(WTSCacheSingleton.GetTextData(textDescriptor.m_fixedText ?? "", textDescriptor.m_prefix, textDescriptor.m_suffix, baseFont, textDescriptor.m_overrideFont));

            case TextType.StreetSuffix: return(GetFromCacheArray(textDescriptor, WTSCacheSingleton.instance.GetSegment(data.m_segmentId).StreetName, baseFont));

            case TextType.StreetNameComplete: return(GetFromCacheArray(textDescriptor, WTSCacheSingleton.instance.GetSegment(data.m_segmentId).FullStreetName, baseFont));

            case TextType.StreetPrefix: return(GetFromCacheArray(textDescriptor, WTSCacheSingleton.instance.GetSegment(data.m_segmentId).StreetQualifier, baseFont));

            case TextType.District: return(GetFromCacheArray(textDescriptor, WTSCacheSingleton.instance.GetDistrict(data.m_districtId).Name, baseFont));

            case TextType.Park: return(GetFromCacheArray(textDescriptor, WTSCacheSingleton.instance.GetPark(data.m_districtParkId).Name, baseFont));

            case TextType.PostalCode: return(GetFromCacheArray(textDescriptor, WTSCacheSingleton.instance.GetSegment(data.m_segmentId).PostalCode, baseFont));

            case TextType.CityName: return(GetFromCacheArray(textDescriptor, WTSCacheSingleton.instance.GetDistrict(0).Name, baseFont));

            default: return(null);
            }
            ;
        }
        private void OnSetData(ref BoardTextDescriptorGeneralXml x)
        {
            m_tabName.text = x.SaveName;

            m_arrayCoord[0].text      = x.PlacingConfig.Position.X.ToString("F3");
            m_arrayCoord[1].text      = x.PlacingConfig.Position.Y.ToString("F3");
            m_arrayCoord[2].text      = x.PlacingConfig.Position.Z.ToString("F3");
            m_arrayRotation[0].text   = x.PlacingConfig.Rotation.X.ToString("F3");
            m_arrayRotation[1].text   = x.PlacingConfig.Rotation.Y.ToString("F3");
            m_arrayRotation[2].text   = x.PlacingConfig.Rotation.Z.ToString("F3");
            m_textScale.text          = x.m_textScale.ToString("F3");
            m_maxWidth.text           = x.m_maxWidthMeters.ToString("F3");
            m_applyScaleOnY.isChecked = x.m_applyOverflowResizingOnY;
            m_invertTextHorizontalAlignClone.isChecked = x.PlacingConfig.m_invertYCloneHorizontalAlign;
            m_create180degSimmetricClone.isChecked     = x.PlacingConfig.m_create180degYClone;
            //  m_mirrored.isChecked = x.PlacingConfig.m_mirrored;

            m_dropdownTextAlignHorizontal.selectedIndex = (int)x.m_textAlign;
            m_useContrastColor.isChecked         = x.ColoringConfig.UseContrastColor;
            m_dropdownMaterialType.selectedIndex = (int)x.IlluminationConfig.IlluminationType;
            m_sliderIllumination.value           = x.IlluminationConfig.IlluminationStrength;
            m_sliderDepth.value = x.IlluminationConfig.IlluminationDepth;
            m_dropdownBlinkType.selectedIndex = (int)x.IlluminationConfig.BlinkType;
            m_textFixedColor.selectedColor    = x.ColoringConfig.m_cachedColor;

            m_dropdownTextContent.items         = WTSDynamicTextRenderingRules.ALLOWED_TYPES_PER_RENDERING_CLASS[WTSPropLayoutEditor.Instance.EditingInstance.m_allowedRenderClass].Select(y => Locale.Get("K45_WTS_BOARD_TEXT_TYPE_DESC", y.ToString())).ToArray();
            m_dropdownTextContent.selectedIndex = Array.IndexOf(WTSDynamicTextRenderingRules.ALLOWED_TYPES_PER_RENDERING_CLASS[WTSPropLayoutEditor.Instance.EditingInstance.m_allowedRenderClass], x.m_textType);
            m_customText.text                  = x.m_fixedText ?? "";
            m_parameterDisplayName.text        = x.ParameterDisplayName ?? "";
            m_destinationRef.selectedIndex     = (int)(x.m_destinationRelative);
            m_parameterIdx.selectedIndex       = x.m_parameterIdx;
            m_defaultParameterValue.text       = x.DefaultParameterValueAsString ?? "";
            m_slideDesync.text                 = x.AnimationSettings.m_extraDelayCycleFrames.ToString();
            m_slideDurationFrames.text         = x.AnimationSettings.m_itemCycleFramesDuration.ToString();
            m_overrideFontSelect.selectedIndex = x.m_overrideFont == null ? 0 : x.m_overrideFont == WTSController.DEFAULT_FONT_KEY ? 1 : Array.IndexOf(m_overrideFontSelect.items, x.m_overrideFont);
            m_fontClassSelect.selectedIndex    = (int)x.m_fontClass;
            m_textPrefix.text                  = x.m_prefix ?? "";
            m_textSuffix.text                  = x.m_suffix ?? "";
            m_allCaps.isChecked                = x.m_allCaps;
            m_spriteFilter.text                = x.m_spriteParam?.ToString() ?? "";
            m_applyAbbreviations.isChecked     = x.m_applyAbbreviations;

            m_arrayCustomBlink[0].text       = x.IlluminationConfig.CustomBlink.X.ToString("F3");
            m_arrayCustomBlink[1].text       = x.IlluminationConfig.CustomBlink.Y.ToString("F3");
            m_arrayCustomBlink[2].text       = x.IlluminationConfig.CustomBlink.Z.ToString("F3");
            m_arrayCustomBlink[3].text       = x.IlluminationConfig.CustomBlink.W.ToString("F3");
            m_arrayRowColumnsCount[1].text   = x.MultiItemSettings.SubItemsPerRow.ToString();
            m_arrayRowColumnsCount[0].text   = x.MultiItemSettings.SubItemsPerColumn.ToString();
            m_arrayRowColumnsSpacing[0].text = x.MultiItemSettings.SubItemSpacing.X.ToString("F3");
            m_arrayRowColumnsSpacing[1].text = x.MultiItemSettings.SubItemSpacing.Y.ToString("F3");

            ApplyShowRules(x);
        }
Пример #9
0
        private void RenderDescriptor(ref Vehicle v, RenderManager.CameraInfo cameraInfo, ushort vehicleId, Vector3 position, Matrix4x4 vehicleMatrix, ref LayoutDescriptorVehicleXml targetDescriptor)
        {
            var instance = VehicleManager.instance;

            for (int j = 0; j < targetDescriptor.TextDescriptors.Length; j++)
            {
                ref BoardTextDescriptorGeneralXml descriptor = ref targetDescriptor.TextDescriptors[j];
                if (descriptor != null && cameraInfo.CheckRenderDistance(position, 200 * descriptor.m_textScale * (descriptor.IlluminationConfig?.IlluminationType == FontStashSharp.MaterialType.OPAQUE ? 1 : 2)))
                {
                    MaterialPropertyBlock properties = instance.m_materialBlock;
                    properties.Clear();
                    var flags = v.m_flags;
                    if ((flags & Vehicle.Flags.Inverted) != 0)
                    {
                        flags ^= Vehicle.Flags.Reversed;
                    }
                    ref Vehicle vehicle = ref instance.m_vehicles.m_buffer[vehicleId];
                    WTSDynamicTextRenderingRules.RenderTextMesh(vehicleId, 0, 0, targetDescriptor, vehicleMatrix, null, ref targetDescriptor.TextDescriptors[j], properties, (int)flags, vehicle.Info.m_vehicleAI.GetColor(vehicleId, ref vehicle, InfoManager.InfoMode.None), v.Info, ref VehicleManager.instance.m_drawCallData.m_batchedCalls);
                }
Пример #10
0
        private void OnSetData(ref BoardTextDescriptorGeneralXml x)
        {
            m_tabName.text = x.SaveName ?? "";

            m_arrayCoord[0].text      = x.PlacingConfig.Position.X.ToString("F3");
            m_arrayCoord[1].text      = x.PlacingConfig.Position.Y.ToString("F3");
            m_arrayCoord[2].text      = x.PlacingConfig.Position.Z.ToString("F3");
            m_arrayRotation[0].text   = x.PlacingConfig.Rotation.X.ToString("F3");
            m_arrayRotation[1].text   = x.PlacingConfig.Rotation.Y.ToString("F3");
            m_arrayRotation[2].text   = x.PlacingConfig.Rotation.Z.ToString("F3");
            m_textScale.text          = x.m_textScale.ToString("F3");
            m_maxWidth.text           = x.m_maxWidthMeters.ToString("F3");
            m_applyScaleOnY.isChecked = x.m_applyOverflowResizingOnY;
            m_invertTextHorizontalAlignClone.isChecked = x.PlacingConfig.m_invertYCloneHorizontalAlign;
            m_create180degSimmetricClone.isChecked     = x.PlacingConfig.m_create180degYClone;


            m_bgSize[0].text        = x.BackgroundMeshSettings.Size.X.ToString("F3");
            m_bgSize[1].text        = x.BackgroundMeshSettings.Size.Y.ToString("F3");
            m_bgColor.selectedColor = x.BackgroundMeshSettings.BackgroundColor;

            m_dropdownTextAlignHorizontal.selectedIndex = (int)x.m_textAlign;
            m_useContrastColor.isChecked         = x.ColoringConfig.UseContrastColor;
            m_dropdownMaterialType.selectedIndex = (int)x.IlluminationConfig.IlluminationType;
            m_sliderIllumination.value           = x.IlluminationConfig.IlluminationStrength;
            m_sliderDepth.value = x.IlluminationConfig.IlluminationDepth;
            m_dropdownBlinkType.selectedIndex = (int)x.IlluminationConfig.BlinkType;
            m_textFixedColor.selectedColor    = x.ColoringConfig.m_cachedColor;

            m_useFrame.isChecked             = x.BackgroundMeshSettings.UseFrame;
            m_frameBackSize[0].text          = x.BackgroundMeshSettings.FrameMeshSettings.BackSize.X.ToString("F3");
            m_frameBackSize[1].text          = x.BackgroundMeshSettings.FrameMeshSettings.BackSize.Y.ToString("F3");
            m_frameBackOffset[0].text        = x.BackgroundMeshSettings.FrameMeshSettings.BackOffset.X.ToString("F3");
            m_frameBackOffset[1].text        = x.BackgroundMeshSettings.FrameMeshSettings.BackOffset.Y.ToString("F3");
            m_frameDepths[0].text            = x.BackgroundMeshSettings.FrameMeshSettings.FrontDepth.ToString("F3");
            m_frameDepths[1].text            = x.BackgroundMeshSettings.FrameMeshSettings.BackDepth.ToString("F3");
            m_frameFrontBorder.text          = x.BackgroundMeshSettings.FrameMeshSettings.FrontBorderThickness.ToString("F3");
            m_frameGlassTransparency.value   = x.BackgroundMeshSettings.FrameMeshSettings.GlassTransparency;
            m_frameOuterSpecularLevel.value  = x.BackgroundMeshSettings.FrameMeshSettings.OuterSpecularLevel;
            m_frameGlassSpecularLevel.value  = x.BackgroundMeshSettings.FrameMeshSettings.GlassSpecularLevel;
            m_frameUseVehicleColor.isChecked = x.BackgroundMeshSettings.FrameMeshSettings.InheritColor;
            m_frameColor.selectedColor       = x.BackgroundMeshSettings.FrameMeshSettings.OutsideColor;
            m_frameGlassColor.selectedColor  = x.BackgroundMeshSettings.FrameMeshSettings.GlassColor;

            m_dropdownTextContent.selectedIndex = Array.IndexOf(WTSDynamicTextRenderingRules.ALLOWED_TYPES_VEHICLE, x.m_textType);
            m_customText.text = x.m_fixedText ?? "";
            m_overrideFontSelect.selectedIndex = x.m_overrideFont == null ? 0 : x.m_overrideFont == WTSController.DEFAULT_FONT_KEY ? 1 : Array.IndexOf(m_overrideFontSelect.items, x.m_overrideFont);
            m_fontClassSelect.selectedIndex    = (int)x.m_fontClass;
            m_textPrefix.text   = x.m_prefix ?? "";
            m_textSuffix.text   = x.m_suffix ?? "";
            m_allCaps.isChecked = x.m_allCaps;
            m_spriteFilter.text = x.m_spriteParam?.ToString() ?? "";

            m_arrayCustomBlink[0].text = x.IlluminationConfig.CustomBlink.X.ToString("F3");
            m_arrayCustomBlink[1].text = x.IlluminationConfig.CustomBlink.Y.ToString("F3");
            m_arrayCustomBlink[2].text = x.IlluminationConfig.CustomBlink.Z.ToString("F3");
            m_arrayCustomBlink[3].text = x.IlluminationConfig.CustomBlink.W.ToString("F3");

            foreach (var f in (Enum.GetValues(typeof(Vehicle.Flags)) as Vehicle.Flags[]))
            {
                m_flagsState[f].activeStateIndex = ((x.IlluminationConfig.m_forbiddenFlags & (int)f) != 0) ? 2 : ((x.IlluminationConfig.m_requiredFlags & (int)f) != 0) ? 1 : 0;
            }

            ApplyShowRules(x);
        }
Пример #11
0
 private static BasicRenderInformation GetTextForBuilding(BoardTextDescriptorGeneralXml textDescriptor, ushort refID, int boardIdx, int secIdx, ref IEnumerable <BasicRenderInformation> multipleOutput, ref DynamicSpriteFont baseFontRef, BoardInstanceBuildingXml buildingDescritpor)
 {
     ref BoardBunchContainerBuilding data = ref WTSBuildingsData.Instance.BoardsContainers[refID, 0, 0][boardIdx];
Пример #12
0
        private static void DrawTextBri(ushort refID, int boardIdx, int secIdx, Matrix4x4 propMatrix, BoardTextDescriptorGeneralXml textDescriptor,
                                        MaterialPropertyBlock materialPropertyBlock, BasicRenderInformation renderInfo, Color colorToSet, Vector3 targetPos, Vector3 targetRotation,
                                        Vector3 baseScale, bool placeClone180Y, UIHorizontalAlignment targetTextAlignment, float maxWidth, int instanceFlags, Color parentColor,
                                        PrefabInfo srcInfo, ref int defaultCallsCounter, Camera targetCamera = null)
        {
            var textMatrixes = CalculateTextMatrix(targetPos, targetRotation, baseScale, targetTextAlignment, maxWidth, textDescriptor, renderInfo, placeClone180Y);

            foreach (var textMatrixTuple in textMatrixes)
            {
                Matrix4x4 matrix = propMatrix * textMatrixTuple.First;

                materialPropertyBlock.Clear();

                Material    targetMaterial = renderInfo.m_generatedMaterial;
                PropManager instance       = CalculateIllumination(refID, boardIdx, secIdx, textDescriptor, materialPropertyBlock, ref colorToSet, instanceFlags);


                defaultCallsCounter++;
                Graphics.DrawMesh(renderInfo.m_mesh, matrix, targetMaterial, 10, targetCamera, 0, materialPropertyBlock, false);

                if (((Vector2)textDescriptor.BackgroundMeshSettings.Size).sqrMagnitude != 0)
                {
                    BasicRenderInformation bgBri = WriteTheSignsMod.Controller.AtlasesLibrary.GetFromLocalAtlases(null, KlyteResourceLoader.GetDefaultSpriteNameFor(LineIconSpriteNames.K45_SquareIcon));
                    if (bgBri != null)
                    {
                        Matrix4x4 containerMatrix = DrawBgMesh(ref propMatrix, textDescriptor, materialPropertyBlock, ref targetPos, ref targetRotation, ref baseScale, targetTextAlignment, targetCamera, textMatrixTuple, instance, bgBri, ref defaultCallsCounter);
                        if (textDescriptor.BackgroundMeshSettings.UseFrame)
                        {
                            DrawTextFrame(textDescriptor, materialPropertyBlock, ref targetPos, ref targetRotation, ref baseScale, ref parentColor, srcInfo, targetCamera, ref containerMatrix, ref defaultCallsCounter);
                        }
                    }
                }
            }
        }
Пример #13
0
        public static void RenderTextMesh(ushort refID, int boardIdx, int secIdx, BoardInstanceXml descriptor, Matrix4x4 propMatrix,
                                          BoardDescriptorGeneralXml propLayout, ref BoardTextDescriptorGeneralXml textDescriptor, MaterialPropertyBlock materialPropertyBlock,
                                          int instanceFlags, Color parentColor, PrefabInfo srcInfo, ref int defaultCallsCounter, Camera targetCamera = null)
        {
            BasicRenderInformation renderInfo = WTSTextMeshProcess.GetTextMesh(textDescriptor, refID, boardIdx, secIdx, descriptor, propLayout, out IEnumerable <BasicRenderInformation> multipleOutput, propLayout?.CachedProp);

            if (renderInfo == null)
            {
                if (multipleOutput != null && multipleOutput.Count() > 0)
                {
                    BasicRenderInformation[] resultArray = multipleOutput.ToArray();
                    if (resultArray.Length == 1)
                    {
                        renderInfo = multipleOutput.First();
                    }
                    else
                    {
                        BoardTextDescriptorGeneralXml.SubItemSettings settings = textDescriptor.MultiItemSettings;
                        int targetCount = Math.Min(settings.SubItemsPerRow * settings.SubItemsPerColumn, resultArray.Length);
                        int maxItemsInARow, maxItemsInAColumn, lastRowOrColumnItemCount;

                        if (textDescriptor.MultiItemSettings.VerticalFirst)
                        {
                            maxItemsInAColumn        = Math.Min(targetCount, settings.SubItemsPerColumn);
                            maxItemsInARow           = Mathf.CeilToInt((float)targetCount / settings.SubItemsPerColumn);
                            lastRowOrColumnItemCount = targetCount % settings.SubItemsPerColumn;
                        }
                        else
                        {
                            maxItemsInARow           = Math.Min(targetCount, settings.SubItemsPerRow);
                            maxItemsInAColumn        = Mathf.CeilToInt((float)targetCount / settings.SubItemsPerRow);
                            lastRowOrColumnItemCount = targetCount % settings.SubItemsPerRow;
                        }
                        float unscaledColumnWidth = resultArray.Max(x => x?.m_sizeMetersUnscaled.x ?? 0) * SCALING_FACTOR;
                        float rowHeight           = resultArray.Max(x => x?.m_sizeMetersUnscaled.y ?? 0) * SCALING_FACTOR * textDescriptor.m_textScale + textDescriptor.MultiItemSettings.SubItemSpacing.Y;
                        float columnWidth         = (unscaledColumnWidth * textDescriptor.m_textScale) + textDescriptor.MultiItemSettings.SubItemSpacing.X;
                        var   maxWidth            = textDescriptor.m_maxWidthMeters;


                        float regularOffsetX = CalculateOffsetXMultiItem(textDescriptor.m_textAlign, maxItemsInARow, columnWidth, maxWidth);
                        float cloneOffsetX   = textDescriptor.PlacingConfig.m_invertYCloneHorizontalAlign ? CalculateOffsetXMultiItem(2 - textDescriptor.m_textAlign, maxItemsInARow, columnWidth, maxWidth) : regularOffsetX;
                        float regularOffsetY = CalculateOffsetYMultiItem(textDescriptor.MultiItemSettings.VerticalAlign, maxItemsInAColumn, rowHeight);

                        var startPoint      = new Vector3(textDescriptor.PlacingConfig.Position.X + regularOffsetX, textDescriptor.PlacingConfig.Position.Y - regularOffsetY, textDescriptor.PlacingConfig.Position.Z);
                        var startPointClone = new Vector3(textDescriptor.PlacingConfig.Position.X + cloneOffsetX, textDescriptor.PlacingConfig.Position.Y - regularOffsetY, textDescriptor.PlacingConfig.Position.Z);

                        Vector3 lastRowOrColumnStartPoint = textDescriptor.MultiItemSettings.VerticalFirst
                            ? new Vector3(startPoint.x, textDescriptor.PlacingConfig.Position.Y - CalculateOffsetYMultiItem(textDescriptor.MultiItemSettings.VerticalAlign, lastRowOrColumnItemCount, rowHeight), startPoint.z)
                            : new Vector3(textDescriptor.PlacingConfig.Position.X + CalculateOffsetXMultiItem(textDescriptor.m_textAlign, lastRowOrColumnItemCount, columnWidth, maxWidth), startPoint.y, startPoint.z);
                        Color colorToSet = GetTextColor(refID, boardIdx, secIdx, descriptor, propLayout, textDescriptor);
                        //LogUtils.DoWarnLog($"sz = {resultArray.Length};targetCount = {targetCount}; origPos = {textDescriptor.PlacingConfig.Position}; maxItemsInAColumn = {maxItemsInAColumn}; maxItemsInARow = {maxItemsInARow};columnWidth={columnWidth};rowHeight={rowHeight}");



                        int firstItemIdxLastRowOrColumn = targetCount - lastRowOrColumnItemCount;
                        for (int i = 0; i < targetCount; i++)
                        {
                            int x, y;
                            if (textDescriptor.MultiItemSettings.VerticalFirst)
                            {
                                y = i % settings.SubItemsPerColumn;
                                x = i / settings.SubItemsPerColumn;
                            }
                            else
                            {
                                x = i % settings.SubItemsPerRow;
                                y = i / settings.SubItemsPerRow;
                            }

                            BasicRenderInformation currentItem = resultArray[i];
                            Vector3 targetPosA = (i >= firstItemIdxLastRowOrColumn ? lastRowOrColumnStartPoint : startPoint) - new Vector3(columnWidth * x, rowHeight * y);
                            DrawTextBri(refID, boardIdx, secIdx, propMatrix, textDescriptor, materialPropertyBlock, currentItem, colorToSet, targetPosA, textDescriptor.PlacingConfig.Rotation, descriptor.PropScale, false, textDescriptor.m_textAlign, 0, instanceFlags, parentColor, srcInfo, ref defaultCallsCounter, targetCamera);
                            if (textDescriptor.PlacingConfig.m_create180degYClone)
                            {
                                targetPosA    = startPointClone - new Vector3(columnWidth * (maxItemsInARow - x - 1), rowHeight * y);
                                targetPosA.z *= -1;
                                DrawTextBri(refID, boardIdx, secIdx, propMatrix, textDescriptor, materialPropertyBlock, currentItem, colorToSet, targetPosA, textDescriptor.PlacingConfig.Rotation + new Vector3(0, 180), descriptor.PropScale, false, textDescriptor.m_textAlign, 0, instanceFlags, parentColor, srcInfo, ref defaultCallsCounter, targetCamera);
                            }
                        }
                    }
                }
                else
                {
                    return;
                }
            }
            if (renderInfo?.m_mesh is null || renderInfo?.m_generatedMaterial is null)
            {
                return;
            }

            Vector3 targetPos = textDescriptor.PlacingConfig.Position;


            DrawTextBri(refID, boardIdx, secIdx, propMatrix, textDescriptor, materialPropertyBlock, renderInfo, GetTextColor(refID, boardIdx, secIdx, descriptor, propLayout, textDescriptor), targetPos, textDescriptor.PlacingConfig.Rotation, descriptor.PropScale, textDescriptor.PlacingConfig.m_create180degYClone, textDescriptor.m_textAlign, textDescriptor.m_maxWidthMeters, instanceFlags, parentColor, srcInfo, ref defaultCallsCounter, targetCamera);
        }