コード例 #1
0
 public TerrainGeometryWaterBrushCatalogResource(int APIversion,
                                                 uint version,
                                                 uint brushVersion,
                                                 Common common,
                                                 BrushOperation normalOperation,
                                                 BrushOperation oppositeOperation,
                                                 TGIBlock profileTexture,
                                                 BrushOrientation orientation,
                                                 float width,
                                                 float strength,
                                                 byte baseTextureValue,
                                                 float wiggleAmount
                                                 )
     : base(APIversion, version, common)
 {
     this.brushVersion      = brushVersion;
     this.normalOperation   = normalOperation;
     this.oppositeOperation = oppositeOperation;
     this.profileTexture    = profileTexture;
     this.orientation       = orientation;
     this.width             = width;
     this.strength          = strength;
     this.baseTextureValue  = baseTextureValue;
     this.wiggleAmount      = wiggleAmount;
 }
コード例 #2
0
 public TerrainGeometryWaterBrushCatalogResource(int APIversion,
     uint version,
     uint brushVersion,
     Common common,
     BrushOperation normalOperation,
     BrushOperation oppositeOperation,
     TGIBlock profileTexture,
     BrushOrientation orientation,
     float width,
     float strength,
     byte baseTextureValue,
     float wiggleAmount
     )
     : base(APIversion, version, common)
 {
     this.brushVersion = brushVersion;
     this.normalOperation = normalOperation;
     this.oppositeOperation = oppositeOperation;
     this.profileTexture = profileTexture;
     this.orientation = orientation;
     this.width = width;
     this.strength = strength;
     this.baseTextureValue = baseTextureValue;
     this.wiggleAmount = wiggleAmount;
 }
コード例 #3
0
 public TerrainPaintBrushCatalogResource(uint version,
                                         uint brushVersion,
                                         Common common,
                                         BrushOperation normalOperation, BrushOperation oppositeOperation, TGIBlock profileTexture,
                                         BrushOrientation orientation,
                                         float width, float strength, byte baseTextureValue, float wiggleAmount,
                                         TGIBlock brushTexture,
                                         TerrainType terrain, CategoryType category)
     : base(version,
            brushVersion,
            common,
            normalOperation,
            oppositeOperation,
            profileTexture,
            orientation,
            width,
            strength,
            baseTextureValue,
            wiggleAmount
            )
 {
     this.brushTexture = (TGIBlock)brushTexture.Clone(OnResourceChanged);
     this.terrain      = terrain;
     this.category     = category;
 }
コード例 #4
0
 public TerrainPaintBrushCatalogResource(uint version,
                                         uint brushVersion,
                                         Common common,
                                         BrushOperation normalOperation, BrushOperation oppositeOperation, TGIBlock profileTexture,
                                         BrushOrientation orientation,
                                         float width, float strength, byte baseTextureValue, float wiggleAmount,
                                         TGIBlock brushTexture)
     : this(version,
            brushVersion,
            common,
            normalOperation,
            oppositeOperation,
            profileTexture,
            orientation,
            width,
            strength,
            baseTextureValue,
            wiggleAmount,
            brushTexture,
            0, 0
            )
 {
     if (version >= 0x00000004)
     {
         throw new InvalidOperationException(String.Format("Constructor requires terrain and category for version {0}", version));
     }
 }
コード例 #5
0
 public TerrainPaintBrushCatalogResource(int APIversion,
     uint version,
     uint brushVersion,
     Common common,
     BrushOperation normalOperation, BrushOperation oppositeOperation, TGIBlock profileTexture, BrushOrientation orientation,
     float width, float strength, byte baseTextureValue, float wiggleAmount,
     TGIBlock brushTexture,
     TerrainType terrain, CategoryType category
     )
     : base(APIversion,
         version,
         brushVersion,
         common,
         normalOperation,
         oppositeOperation,
         profileTexture,
         orientation,
         width,
         strength,
         baseTextureValue,
         wiggleAmount
     )
 {
     this.brushTexture = (TGIBlock)brushTexture.Clone(OnResourceChanged);
     this.terrain = terrain;
     this.category = category;
 }
コード例 #6
0
 public TerrainPaintBrushCatalogResource(int APIversion,
     uint version,
     uint brushVersion,
     Common common,
     BrushOperation normalOperation, BrushOperation oppositeOperation, TGIBlock profileTexture, BrushOrientation orientation,
     float width, float strength, byte baseTextureValue, float wiggleAmount,
     TGIBlock brushTexture
     )
     : this(APIversion,
         version,
         brushVersion,
         common,
         normalOperation,
         oppositeOperation,
         profileTexture,
         orientation,
         width,
         strength,
         baseTextureValue,
         wiggleAmount,
         brushTexture,
         0, 0
     )
 {
     if (checking) if (version >= 0x00000004)
             throw new InvalidOperationException(String.Format("Constructor requires terrain and category for version {0}", version));
 }
コード例 #7
0
 protected override void Parse(Stream s)
 {
     base.Parse(s);
     BinaryReader r = new BinaryReader(s);
     this.brushVersion = r.ReadUInt32();
     common = new Common(requestedApiVersion, OnResourceChanged, s);
     this.normalOperation = (BrushOperation)r.ReadUInt32();
     this.oppositeOperation = (BrushOperation)r.ReadUInt32();
     this.profileTexture = new TGIBlock(requestedApiVersion, OnResourceChanged, s);
     this.orientation = (BrushOrientation)r.ReadUInt32();
     this.width = r.ReadSingle();
     this.strength = r.ReadSingle();
     this.baseTextureValue = r.ReadByte();
     this.wiggleAmount = r.ReadSingle();
 }
コード例 #8
0
        protected override void Parse(Stream s)
        {
            base.Parse(s);
            BinaryReader r = new BinaryReader(s);

            this.brushVersion      = r.ReadUInt32();
            common                 = new Common(requestedApiVersion, OnResourceChanged, s);
            this.normalOperation   = (BrushOperation)r.ReadUInt32();
            this.oppositeOperation = (BrushOperation)r.ReadUInt32();
            this.profileTexture    = new TGIBlock(requestedApiVersion, OnResourceChanged, s);
            this.orientation       = (BrushOrientation)r.ReadUInt32();
            this.width             = r.ReadSingle();
            this.strength          = r.ReadSingle();
            this.baseTextureValue  = r.ReadByte();
            this.wiggleAmount      = r.ReadSingle();
        }
コード例 #9
0
    /// <summary>
    /// Upgrades oriented brush (v1.x) into an oriented brush (v2.x).
    /// </summary>
    /// <param name="record">Record for existing v1.x brush.</param>
    private void UpgradeOrientedBrush(RtsBrushAssetRecordWrapper record)
    {
        if (useNewAssets)
        {
            // Is this the original "Smooth Platform" master brushes?
            if (record.assetPath == "Assets/Rotorz Tile System/Brushes/Smooth Platform.prefab" ||
                record.assetPath == "Assets/Rotorz Tile System/Brushes/Smooth Platform (Join).prefab" ||
                record.assetPath == "Assets/Rotorz Tile System/Brushes/Smooth Platform (Small).prefab")
            {
                // This is a special case that can be switched to new version
                // if it was imported.
                OrientedBrush newMasterBrush = AssetDatabase.LoadAssetAtPath("Assets/Rotorz/Tile System/TileBrushes/Master/" + record.displayName + ".brush.asset", typeof(OrientedBrush)) as OrientedBrush;
                if (newMasterBrush != null)
                {
                    RtsUpgradedBrushMap.BrushMappings.SetMapping(record.brush, newMasterBrush);
                    return;
                }

                // If new version was not found then just proceed to upgrade
                // existing version.
            }
            // Is this one of the original demo brushes?
            else if (record.assetPath == "Assets/Rotorz Tile System/_Demos/TilePrefabs/Diamond.prefab" ||
                     record.assetPath == "Assets/Rotorz Tile System/_Demos/TilePrefabs/Hat Guy.prefab" ||
                     record.assetPath == "Assets/Rotorz Tile System/_Demos/TilePrefabs/Steel Brick.prefab")
            {
                // This is a special case that can be switched to new version
                // if it was imported.
                OrientedBrush newDemoBrush = AssetDatabase.LoadAssetAtPath("Assets/Rotorz/Tile System/Demo/Hat Guy/TileBrushes/" + record.displayName + ".brush.asset", typeof(OrientedBrush)) as OrientedBrush;
                if (newDemoBrush != null)
                {
                    RtsUpgradedBrushMap.BrushMappings.SetMapping(record.brush, newDemoBrush);
                    return;
                }

                // If new version was not found then just proceed to upgrade
                // existing version.
            }
        }

        Transform oldBrushTransform = record.brush.transform;

        OrientedBrush newBrush = BrushUtility.CreateOrientedBrush(record.displayName);

        newBrush.RemoveOrientation(newBrush.DefaultOrientationMask);
        List <Object> variations = new List <Object>();

        RtsUpgradedBrushMap map = RtsUpgradedBrushMap.BrushMappings;

        // Copy orientations from old brush.
        for (int ti = 0; ti < oldBrushTransform.childCount; ++ti)
        {
            MonoBehaviour oldOrientation = oldBrushTransform.GetChild(ti).GetComponent(_tyTileBrushOrientation) as MonoBehaviour;
            if (oldOrientation == null)
            {
                continue;
            }

            Object[] oldVariations = (Object[])_fiTileBrushOrientation_variations.GetValue(oldOrientation);

            BrushOrientation newOrientation = newBrush.AddOrientation(OrientationUtility.MaskFromName(oldOrientation.name));

            variations.Clear();
            for (int i = 0; i < oldVariations.Length; ++i)
            {
                if (oldVariations[i] == null)
                {
                    continue;
                }

                Type       variationType  = oldVariations[i].GetType();
                GameObject variationGO    = oldVariations[i] as GameObject;
                Object     variationBrush = null;

                // If game object is nested, check if it is a tile brush prefab!
                if (variationGO != null)
                {
                    variationBrush = variationGO.GetComponent(_tyTileBrush);
                }
                // If variation is a tile brush then...
                else if (_tyTileBrush.IsAssignableFrom(variationType))
                {
                    variationBrush = oldVariations[i];
                }

                // Need to isolate nested brushes!
                if (variationBrush != null)
                {
                    // Note: This only works because oriented brushes are processed last,
                    //		 and it is not possible to nest oriented brushes.

                    // Use new version of brush!
                    Brush replacementBrush = map.Lookup(variationBrush);
                    if (replacementBrush != null)
                    {
                        variations.Add(replacementBrush);
                    }
                }
                else if (variationGO != null)
                {
                    variations.Add(variationGO);
                }
            }
            newOrientation.variations = variations.ToArray();
        }

        newBrush.DefaultOrientationMask = OrientationUtility.MaskFromName((string)_fiOrientedTileBrush_defaultOrientation.GetValue(record.brush));
        newBrush.FallbackMode           = (FallbackMode)_fiOrientedTileBrush_fallbackMode.GetValue(record.brush);

        if (_fiTileBrush_coalesce != null)
        {
            newBrush.Coalesce = (Coalesce)_fiTileBrush_coalesce.GetValue(record.brush);
        }
        if (_fiTileBrush_coalesceTileGroup != null)
        {
            newBrush.CoalesceBrushGroup = (int)_fiTileBrush_coalesceTileGroup.GetValue(record.brush);
        }

        if (_fiOrientedTileBrush_forceOverrideFlags != null)
        {
            newBrush.forceOverrideFlags = (bool)_fiOrientedTileBrush_forceOverrideFlags.GetValue(record.brush);
        }

        FinalizeStandaloneBrush(record, newBrush);
    }