Exemplo n.º 1
0
		/// <summary>
		/// Compares two Bodypart instances for value equality.
		/// </summary>
		/// <param name="a">The first Bodypart instance.</param>
		/// <param name="b">The second Bodypart instance. </param>
		/// <returns>True if both instances are semantically equal,
		/// otherwise false.</returns>
		bool Equals(Bodypart a, Bodypart b) {
			bool equal =
				(a.Description == b.Description) &&
				(a.Disposition.Filename == b.Disposition.Filename) &&
				(a.Disposition.Type == b.Disposition.Type) &&
				(a.Disposition.Attributes.Count == b.Disposition.Attributes.Count) &&
				(a.Encoding == b.Encoding) &&
				(a.Id == b.Id) &&
				(a.Language == b.Language) &&
				(a.Lines == b.Lines) &&
				(a.Location == b.Location) &&
				(a.Md5 == b.Md5) &&
				(a.PartNumber == b.PartNumber) &&
				(a.Size == b.Size) &&
				(a.Subtype == b.Subtype) &&
				(a.Type == b.Type) &&
				(a.Parameters.Count == b.Parameters.Count);
			if (!equal)
				return false;
			foreach (string key in a.Parameters.Keys) {
				if (a.Parameters[key] != b.Parameters[key])
					return false;
			}
			foreach (string key in a.Disposition.Attributes.Keys) {
				if (a.Disposition.Attributes[key] != b.Disposition.Attributes[key])
					return false;
			}
			return true;
		}
Exemplo n.º 2
0
        /// <inheritdoc />
        protected override Task <string> GetNoChangeMessageAsync(Bodypart bodypart)
        {
            var character = this.Appearance.Character;

            return(Task.FromResult($"{character.Nickname} doesn't have anything like that to remove."));
        }
Exemplo n.º 3
0
 /// <inheritdoc />
 protected override Task <string> GetRemoveMessageAsync(Bodypart bodypart, Chirality chirality)
 {
     return(Task.FromResult(_descriptionBuilder.BuildRemoveMessage(this.Appearance, bodypart)));
 }
 protected abstract Task <string> GetAddMessageAsync(Bodypart bodypart, Chirality chirality);
Exemplo n.º 5
0
        public string BuildRemoveMessage([NotNull] Appearance appearanceConfiguration, Bodypart bodypart)
        {
            string removalText;

            switch (bodypart)
            {
            case Bodypart.Hair:
            {
                removalText = _transformationText.Messages.Removal.Single.Hair.PickRandom();
                break;
            }

            case Bodypart.Face:
            {
                removalText = _transformationText.Messages.Removal.Single.Face.PickRandom();
                break;
            }

            case Bodypart.Ear:
            {
                removalText = _transformationText.Messages.Removal.Single.Ear.PickRandom();
                break;
            }

            case Bodypart.Eye:
            {
                removalText = _transformationText.Messages.Removal.Single.Eye.PickRandom();
                break;
            }

            case Bodypart.Teeth:
            {
                removalText = _transformationText.Messages.Removal.Single.Teeth.PickRandom();
                break;
            }

            case Bodypart.Leg:
            {
                removalText = _transformationText.Messages.Removal.Single.Leg.PickRandom();
                break;
            }

            case Bodypart.Arm:
            {
                removalText = _transformationText.Messages.Removal.Single.Arm.PickRandom();
                break;
            }

            case Bodypart.Tail:
            {
                removalText = _transformationText.Messages.Removal.Single.Tail.PickRandom();
                break;
            }

            case Bodypart.Wing:
            {
                removalText = _transformationText.Messages.Removal.Single.Wing.PickRandom();
                break;
            }

            case Bodypart.Penis:
            {
                removalText = _transformationText.Messages.Removal.Single.Penis.PickRandom();
                break;
            }

            case Bodypart.V****a:
            {
                removalText = _transformationText.Messages.Removal.Single.V****a.PickRandom();
                break;
            }

            case Bodypart.Head:
            {
                removalText = _transformationText.Messages.Removal.Single.Head.PickRandom();
                break;
            }

            case Bodypart.Body:
            {
                removalText = _transformationText.Messages.Removal.Single.Body.PickRandom();
                break;
            }

            default:
            {
                throw new ArgumentOutOfRangeException();
            }
            }

            return(ReplaceTokensWithContent(removalText, appearanceConfiguration, null));
        }
Exemplo n.º 6
0
    /*
    public void fightingPose()
    {
        attackState = true;
        foreach (Bodypart p in slots)
        {
            if (p.sprite_fight != null)
            {
                // flip if
                if (flipped)
                {
                    Vector3 theScale = headRenderer.transform.localScale;
                    theScale.x *= -1;
                    headRenderer.transform.localScale = theScale;
                    flipped = false;
                }

                switch (p.type)
                {
                    case Bodypart.TYPE.HEAD:
                        Debug.Log("head");
                        headRenderer.sprite = p.sprite_fight;
                        break;
                    case Bodypart.TYPE.TORSO:

                        Debug.Log("torso");
                        torsoRenderer.sprite = p.sprite_fight;
                        break;
                    case Bodypart.TYPE.LEGS:

                        Debug.Log("legs");
                        legsRenderer.sprite = p.sprite_fight;
                        break;
                }
            }
        }
    }
    */
    public void selectBodypart(Bodypart bp)
    {
        if(GameManager.Instance.State == GameManager.STATE.BUILD)
        {
            if(!(bp == this.slots[0] || bp == this.slots[1] || bp == this.slots[2]))
            {
                switch (bp.type)
                {
                    case Bodypart.TYPE.HEAD:
                        this.slots[0] = bp;
                        headRenderer.gameObject.SetActive(false);
                        break;
                    case Bodypart.TYPE.TORSO:
                        this.slots[1] = bp;
                        torsoRenderer.gameObject.SetActive(false);
                        break;
                    case Bodypart.TYPE.LEGS:
                        this.slots[2] = bp;
                        legsRenderer.gameObject.SetActive(false);
                        break;
                }

                playMovieTexture(bp);

                if(bp.movie.audioClip != null)
                {
                    SoundManager.Instance.PlaySingle(bp.movie.audioClip);
                   // SoundManager.Instance.PlaySingle(SoundManager.Instance.startFight);
                }
                else
                {
                    Debug.Log("no audio clip");
                }

                refreshCurrentSlot();
            }

        }
    }
    /// <inheritdoc />
    protected override Task <string> GetShiftMessageAsync(Bodypart bodypart, Chirality chirality)
    {
        var component = this.Appearance.GetAppearanceComponent(bodypart, chirality);

        return(Task.FromResult(_descriptionBuilder.BuildPatternColourShiftMessage(this.Appearance, component)));
    }
Exemplo n.º 8
0
    /// <inheritdoc />
    protected override async Task <Result <ShiftBodypartResult> > RemoveBodypartAsync(Bodypart bodypart, Chirality chirality)
    {
        if (!this.Appearance.TryGetAppearanceComponent(bodypart, chirality, out var currentComponent))
        {
            return(new UserError("The character doesn't have that bodypart."));
        }

        if (currentComponent.Pattern is null)
        {
            return(new ShiftBodypartResult(await GetNoChangeMessageAsync(bodypart), ShiftBodypartAction.Nothing));
        }

        currentComponent.Pattern       = null;
        currentComponent.PatternColour = null;

        var shiftMessage = await GetRemoveMessageAsync(bodypart, chirality);

        return(new ShiftBodypartResult(shiftMessage, ShiftBodypartAction.Remove));
    }
Exemplo n.º 9
0
 public virtual bool CanBeEquipped(Bodypart bodypartToEquipOn)
 {
     return(_decoratedItem.CanBeEquipped(bodypartToEquipOn));
 }
Exemplo n.º 10
0
 /// <summary>
 /// Determines whether or not the given part has a left- or right-handed counterpart.
 /// </summary>
 /// <param name="this">The bodypart.</param>
 /// <returns>true if the part is a chiral part; otherwise, false.</returns>
 public static bool IsChiral(this Bodypart @this)
 {
     return(@this.HasCustomAttribute <ChiralAttribute>());
 }
Exemplo n.º 11
0
 protected virtual void Awake()
 {
     bodypart = _bodypartData.CreateBodypartInstance();
     bodypart.BodypartDamageChanged += OnBodypartDamageChanged;
 }
Exemplo n.º 12
0
 public static bool IsComposite(this Bodypart @this)
 {
     return(@this.HasCustomAttribute <CompositeAttribute>());
 }
Exemplo n.º 13
0
 public static bool IsGenderNeutral(this Bodypart @this)
 {
     return([email protected] <GenderedAttribute>());
 }
Exemplo n.º 14
0
        public string BuildUniformRemoveMessage([NotNull] Appearance appearanceConfiguration, Bodypart bodypart)
        {
            string removalText;

            switch (bodypart)
            {
            case Bodypart.Leg:
            {
                removalText = _transformationText.Messages.Removal.Uniform.Legs.PickRandom();
                break;
            }

            case Bodypart.Arm:
            {
                removalText = _transformationText.Messages.Removal.Uniform.Arms.PickRandom();
                break;
            }

            case Bodypart.Wing:
            {
                removalText = _transformationText.Messages.Removal.Uniform.Wings.PickRandom();
                break;
            }

            case Bodypart.Ear:
            {
                removalText = _transformationText.Messages.Removal.Uniform.Ears.PickRandom();
                break;
            }

            case Bodypart.Eye:
            {
                removalText = _transformationText.Messages.Removal.Uniform.Eyes.PickRandom();
                break;
            }

            default:
            {
                throw new ArgumentOutOfRangeException();
            }
            }

            return(ReplaceTokensWithContent(removalText, appearanceConfiguration, null));
        }
Exemplo n.º 15
0
    /// <inheritdoc />
    protected override Task <string> GetUniformShiftMessageAsync(Bodypart bodypart)
    {
        var component = this.Appearance.GetAppearanceComponent(bodypart, Chirality.Left);

        return(Task.FromResult(_descriptionBuilder.BuildUniformPatternShiftMessage(this.Appearance, component)));
    }
Exemplo n.º 16
0
 protected abstract Task <string> GetNoChangeMessageAsync(Bodypart bodypart);
Exemplo n.º 17
0
        /// <summary>
        /// Adds a body part to an existing MailMessage instance.
        /// </summary>
        /// <param name="message">Extension method for the MailMessage class.</param>
        /// <param name="part">The body part to add to the MailMessage instance.</param>
        /// <param name="content">The content of the body part.</param>
        internal void AddBodypart(MailMessage message, Bodypart part, string content)
        {
            Encoding encoding = part.Parameters.ContainsKey("Charset") ?
                                Util.GetEncoding(part.Parameters["Charset"]) : Encoding.ASCII;

            // Decode the content if it is encoded.
            byte[] bytes;
            try
            {
                switch (part.Encoding)
                {
                case ContentTransferEncoding.QuotedPrintable:
                    bytes = encoding.GetBytes(Util.QPDecode(content, encoding));
                    break;

                case ContentTransferEncoding.Base64:
                    bytes = Util.Base64Decode(content);
                    break;

                default:
                    bytes = Encoding.ASCII.GetBytes(content);
                    break;
                }
            }
            catch
            {
                // If it's not a valid Base64 or quoted-printable encoded string just leave the data as is.
                bytes = Encoding.ASCII.GetBytes(content);
            }

            // If the part has a name it most likely is an attachment and it should go into the
            // Attachments collection.
            bool hasName = part.Parameters.ContainsKey("name");

            // If the MailMessage's Body fields haven't been initialized yet, put it there. Some weird
            // (i.e. spam) mails like to omit content-types so we don't check for that here and just
            // assume it's text.
            if (String.IsNullOrEmpty(message.Body) &&
                part.Disposition.Type != ContentDispositionType.Attachment)
            {
                message.Body         = encoding.GetString(bytes);
                message.BodyEncoding = encoding;
                message.IsBodyHtml   = part.Subtype.ToLower() == "html";
                return;
            }

            // Check for alternative view.
            string ContentType       = ParseMIMEField(message.Headers["Content-Type"])["value"];
            bool   preferAlternative = string.Compare(ContentType, "multipart/alternative", true) == 0;

            // Many attachments are missing the disposition-type. If it's not defined as alternative
            // and it has a name attribute, assume it is Attachment rather than an AlternateView.
            if (part.Disposition.Type == ContentDispositionType.Attachment ||
                (part.Disposition.Type == ContentDispositionType.Unknown &&
                 preferAlternative == false && hasName))
            {
                message.Attachments.Add(CreateAttachment(part, bytes));
            }
            else
            {
                message.AlternateViews.Add(CreateAlternateView(part, bytes));
            }
        }
Exemplo n.º 18
0
        private async Task <ShiftBodypartResult> ShiftCompositeBodypartAsync(Bodypart bodypart)
        {
            var composingParts = bodypart.GetComposingParts();

            var currentParagraphLength = 0;
            var messageBuilder         = new StringBuilder();

            void InsertShiftMessage(string message)
            {
                messageBuilder.Append(message);

                if (!message.EndsWith(" "))
                {
                    messageBuilder.Append(" ");
                }

                if (currentParagraphLength > 240)
                {
                    messageBuilder.AppendLine();
                    messageBuilder.AppendLine();

                    currentParagraphLength = 0;
                }

                currentParagraphLength += message.Length;
            }

            foreach (var composingPart in composingParts)
            {
                if (composingPart.IsComposite())
                {
                    var shiftResult = await ShiftCompositeBodypartAsync(composingPart);

                    if (!shiftResult.IsSuccess || shiftResult.Action == ShiftBodypartAction.Nothing)
                    {
                        continue;
                    }

                    InsertShiftMessage(shiftResult.ShiftMessage);
                    continue;
                }

                if (composingPart.IsChiral())
                {
                    var leftShift = await ShiftBodypartAsync(composingPart, Chirality.Left);

                    var rightShift = await ShiftBodypartAsync(composingPart, Chirality.Right);

                    // There's a couple of cases here for us to deal with.
                    // 1: both parts were shifted
                    // 2: one part was shifted
                    // 3: one part was shifted and one was added
                    // 4: both parts were added
                    // 5: no changes were made
                    if (leftShift.Action == ShiftBodypartAction.Nothing && rightShift.Action == ShiftBodypartAction.Nothing)
                    {
                        // No change, keep moving
                        continue;
                    }

                    if (leftShift.Action == ShiftBodypartAction.Shift && rightShift.Action == ShiftBodypartAction.Shift)
                    {
                        var uniformShiftMessage = await GetUniformShiftMessageAsync(composingPart);

                        InsertShiftMessage(uniformShiftMessage);
                        continue;
                    }

                    if (leftShift.Action == ShiftBodypartAction.Add && rightShift.Action == ShiftBodypartAction.Add)
                    {
                        var uniformGrowMessage = await GetUniformAddMessageAsync(composingPart);

                        InsertShiftMessage(uniformGrowMessage);
                        continue;
                    }

                    if (leftShift.Action != ShiftBodypartAction.Nothing)
                    {
                        InsertShiftMessage
                        (
                            await BuildMessageFromResultAsync(leftShift, composingPart, Chirality.Left)
                        );
                    }

                    if (rightShift.Action != ShiftBodypartAction.Nothing)
                    {
                        InsertShiftMessage
                        (
                            await BuildMessageFromResultAsync(rightShift, composingPart, Chirality.Right)
                        );
                    }
                }
                else
                {
                    var simpleShiftResult = await ShiftBodypartAsync
                                            (
                        composingPart,
                        Chirality.Center
                                            );

                    if (simpleShiftResult.Action != ShiftBodypartAction.Nothing)
                    {
                        InsertShiftMessage
                        (
                            await BuildMessageFromResultAsync(simpleShiftResult, composingPart, Chirality.Center)
                        );
                    }
                }
            }

            if (messageBuilder.Length == 0)
            {
                return(ShiftBodypartResult.FromSuccess
                       (
                           await GetNoChangeMessageAsync(bodypart),
                           ShiftBodypartAction.Nothing
                       ));
            }

            return(ShiftBodypartResult.FromSuccess(messageBuilder.ToString(), ShiftBodypartAction.Shift));
        }
Exemplo n.º 19
0
 public bool CanBeEquipped(Bodypart bodypartToEquipOn)
 {
     return(true);
 }
Exemplo n.º 20
0
 protected abstract Task <ShiftBodypartResult> ShiftBodypartAsync(Bodypart bodypart, Chirality chirality);
Exemplo n.º 21
0
 /// <inheritdoc />
 protected override Task <string> GetUniformAddMessageAsync(Bodypart bodypart)
 {
     throw new InvalidOperationException("Colours can't be added.");
 }
Exemplo n.º 22
0
 protected abstract Task <string> GetUniformAddMessageAsync(Bodypart bodypart);
Exemplo n.º 23
0
    private void playMovieTexture(Bodypart bp)
    {
        if(videowall != null)
        {
            if(bp.movTexture != null)
            {
                videowall.gameObject.SetActive(true);
                videowall.material.mainTexture = bp.movTexture;
                bp.movTexture.Stop();
                bp.movTexture.Play();

            }
            else
            {
                Debug.Log("no movTexture assigned");
            }
        }
        else
        {
            Debug.Log("no videowall assigned");
        }

        //SoundManager.Instance.PlaySingle(bp.movie.audioClip);
        //SoundManager.Instance.PlaySingle(SoundManager.Instance.stitch);
    }
Exemplo n.º 24
0
        /// <inheritdoc />
        protected override async Task <ShiftBodypartResult> ShiftBodypartAsync(Bodypart bodypart, Chirality chirality)
        {
            if (_species is null)
            {
                throw new InvalidOperationException
                      (
                          "The shifter must be constructed with a target species when shifting parts."
                      );
            }

            var character = this.Appearance.Character;

            var getTFResult = await _transformations.GetTransformationsByPartAndSpeciesAsync(bodypart, _species);

            if (!getTFResult.IsSuccess)
            {
                return(ShiftBodypartResult.FromError(getTFResult));
            }

            var transformation = getTFResult.Entity.First();

            var getAppearanceResult = await _transformations.GetOrCreateCurrentAppearanceAsync(character);

            if (!getAppearanceResult.IsSuccess)
            {
                return(ShiftBodypartResult.FromError(getAppearanceResult));
            }

            var appearance = getAppearanceResult.Entity;

            if (appearance.TryGetAppearanceComponent(bodypart, chirality, out var existingComponent))
            {
                if (existingComponent.Transformation.Species.Name.Equals(transformation.Species.Name))
                {
                    var message = await GetNoChangeMessageAsync(bodypart);

                    return(ShiftBodypartResult.FromError
                           (
                               message
                           ));
                }
            }

            string shiftMessage;

            if (!appearance.TryGetAppearanceComponent(bodypart, chirality, out var currentComponent))
            {
                currentComponent = AppearanceComponent.CreateFrom(transformation, chirality);

                appearance.Components.Add(currentComponent);

                shiftMessage = await GetAddMessageAsync(bodypart, chirality);

                return(ShiftBodypartResult.FromSuccess(shiftMessage, ShiftBodypartAction.Add));
            }

            if (currentComponent.Transformation.Species.Name == "template")
            {
                // Apply default settings
                currentComponent.BaseColour = transformation.DefaultBaseColour.Clone();

                currentComponent.Pattern       = transformation.DefaultPattern;
                currentComponent.PatternColour = transformation.DefaultPatternColour?.Clone();
            }

            currentComponent.Transformation = transformation;

            shiftMessage = await GetShiftMessageAsync(bodypart, chirality);

            return(ShiftBodypartResult.FromSuccess(shiftMessage, ShiftBodypartAction.Shift));
        }