Ejemplo n.º 1
0
        /// <summary>
        /// Forces a facial expression on the specified girl.
        /// </summary>
        /// <param name="girl">The <see cref="Girl"/> instance on which to set the expression on.</param>
        /// <param name="pieceIndex">Which index of <see cref="GirlDefinition.pieces"/> to set.</param>
        /// <param name="changeEyes">When <c>true</c>, also set the girl's eyes to the one that belongs to the specified expression.</param>
        /// <param name="changeMouth">When <c>true</c>, also set the girl's mouth to the one that belongs to the specified expression.</param>
        /// <remarks>
        /// The girl's eyebrows and face/blush are always set.
        /// When the specified piece is not found or it's <see cref="GirlPiece.type"/> is not <see cref="GirlPieceType.EXPRESSION"/>,
        /// the girl's <see cref="GirlDefinition.defaultExpression"/> will be used.
        /// </remarks>
        public static void ForceExpression(this Girl girl, int pieceIndex, bool changeEyes = true, bool changeMouth = true)
        {
            if (pieceIndex < 0 || pieceIndex >= girl.definition.pieces.Count)
            {
                throw new IndexOutOfRangeException(nameof(pieceIndex));
            }

            GirlPiece piece = girl.definition.pieces[pieceIndex];

            if (piece == null || piece.type != GirlPieceType.EXPRESSION)
            {
                piece = girl.definition.pieces[girl.definition.defaultExpression];
            }

            if (piece != null)
            {
                if (changeEyes)
                {
                    girl.eyes.RemoveAllChildren();
                }
                girl.eyebrows.RemoveAllChildren();
                if (changeMouth)
                {
                    girl.mouth.RemoveAllChildren();
                }
                girl.face.RemoveAllChildren();

                if (changeEyes)
                {
                    girl.AddGirlPieceArtToContainer(piece.primaryArt, girl.eyes);
                }
                girl.AddGirlPieceArtToContainer(piece.secondaryArt, girl.eyebrows);
                if (changeMouth)
                {
                    girl.AddGirlPieceArtToContainer(piece.tertiaryArt, girl.mouth);
                }
                girl.AddGirlPieceArtToContainer(piece.quaternaryArt, girl.face);

                girl.ChangeExpression(piece.expressionType, true, changeEyes, changeMouth, 0.5f);
            }
        }
Ejemplo n.º 2
0
 /// <summary>
 /// Adds all the <see cref="GirlPieceArt"/> contained in the specified <see cref="GirlPiece"/> to the correct container/layer of this girl.
 /// </summary>
 /// <param name="girl">The <see cref="Girl"/> instance the piece will be added to.</param>
 /// <param name="girlPiece">The piece to be added to the <see cref="Girl"/> instance. Most can be obtained using <see cref="GirlDefinition.GetPiecesByType"/>.</param>
 /// <remarks>
 /// Note that this expects that the <see cref="GirlPiece.art"/> (specifically <see cref="GirlPieceArt.spriteName"/>) values exist in <see cref="Girl.spriteCollection"/>.
 /// All the existing children of the container where the piece will be added to will be destroyed.
 /// </remarks>
 public static void AddGirlPiece(this Girl girl, GirlPiece girlPiece)
 {
     AccessTools.Method(typeof(Girl), nameof(AddGirlPiece)).Invoke(girl, new object[] { girlPiece });
 }