Exemplo n.º 1
0
        public void AddedToPart(IBodyPart part)
        {
            DebugTools.AssertNotNull(Part);
            DebugTools.AssertNotNull(part);

            OnAddedToPart(part);
        }
Exemplo n.º 2
0
        private static MessageClass GetInnerMessage(IBodyPart part)
        {
            var innerMessage = new MessageClass();

            innerMessage.OpenObject(part.GetDecodedContentStream(), "_Stream");
            return(innerMessage);
        }
Exemplo n.º 3
0
        public bool TryAddPart(string slot, IBodyPart part, bool force = false)
        {
            DebugTools.AssertNotNull(part);
            DebugTools.AssertNotNull(slot);

            if (force)
            {
                if (!HasSlot(slot))
                {
                    Slots[slot] = part.PartType;
                }

                _parts[slot] = part;
            }
            else
            {
                if (!CanAddPart(slot, part))
                {
                    return(false);
                }
            }

            OnAddPart(slot, part);

            return(true);
        }
Exemplo n.º 4
0
        protected override IBodyPart CreateBody(IBodyPart current)
        {
            IBodyPart geometry = null;

            var nodeShape = CreateShapeFromNode(Node);

            if (current == null)
            {
                geometry = CreateBody(nodeShape);
            }

            var geometryShape = CreateShapeFromGeometry(current);

            if (geometryShape != nodeShape)
            {
                geometry = CreateBody(nodeShape);
            }

            if (Node is RootNode && geometry != null)
            {
                geometry.TextRenderer.FontSize = 16;
            }

            return(geometry);
        }
Exemplo n.º 5
0
        public bool RemovePart(IBodyPart part, [NotNullWhen(true)] out string?slot)
        {
            DebugTools.AssertNotNull(part);

            var pair = _parts.FirstOrDefault(kvPair => kvPair.Value == part);

            if (pair.Equals(default))
Exemplo n.º 6
0
        /// <summary>
        /// Заполним заголовок (основное содержимое тела)
        /// </summary>
        /// <param name="emailMessage"></param>
        private void FillHeaders(IBodyPart emailMessage)
        {
            if (string.IsNullOrWhiteSpace(emailMessage.Text))
            {
                return;
            }
            var bodyHeaders = _mailAnalyzeService.CommonHeaders(emailMessage.Text);
            var headerMain  = bodyHeaders.FirstOrDefault();

            if (string.IsNullOrWhiteSpace(headerMain?.Text))
            {
                return;
            }
            //сохраним
            emailMessage.MainHeader = headerMain.Text;

            /* bodyHeaders.Remove(headerMain);
             * if (bodyHeaders.Any())
             * {
             *   foreach (var mailReferent in bodyHeaders)
             *   {
             *       if (!string.IsNullOrWhiteSpace(mailReferent.Text))
             *       {
             *           emailMessage.CommonHeaders.Add(new HeaderSummary(mailReferent.Text));
             *       }
             *   }
             * }*/
        }
Exemplo n.º 7
0
        //add, replace, or remove tattoo.
        internal TattooDataChangedEventArgs(IBodyPart source, T location, TattooBase oldTattoo, TattooBase newTattoo, int newTattooCount)
        {
            parent = source ?? throw new ArgumentNullException(nameof(source));
            if (location == null)
            {
                throw new ArgumentNullException(nameof(location));
            }

            this.newTattooCount = newTattooCount;

            if (oldTattoo == null != (newTattoo == null))
            {
                if (oldTattoo == null)
                {
                    oldTattooCount = newTattooCount - 1;
                }
                else
                {
                    oldTattooCount = newTattooCount + 1;
                }
            }
            else
            {
                oldTattooCount = newTattooCount;
            }


            Dictionary <T, ValueDifference <TattooBase> > tatDiff = new Dictionary <T, ValueDifference <TattooBase> >
            {
                { location, new ValueDifference <TattooBase>(oldTattoo, newTattoo) }
            };
        }
Exemplo n.º 8
0
        protected virtual void OnRemovePart(string slot, IBodyPart part)
        {
            part.Body = null;

            var args = new BodyPartRemovedEventArgs(part, slot);

            foreach (var component in Owner.GetAllComponents <IBodyPartRemoved>())
            {
                component.BodyPartRemoved(args);
            }

            // creadth: fall down if no legs
            if (part.PartType == BodyPartType.Leg && Parts.Count(x => x.Value.PartType == BodyPartType.Leg) == 0)
            {
                EntitySystem.Get <SharedStandingStateSystem>().Down(Owner);
            }

            // creadth: immediately kill entity if last vital part removed
            if (Owner.TryGetComponent(out IDamageableComponent? damageable))
            {
                if (part.IsVital && Parts.Count(x => x.Value.PartType == part.PartType) == 0)
                {
                    damageable.CurrentState = DamageState.Dead;
                    damageable.ForceHealthChangedEvent();
                }
            }

            OnBodyChanged();
        }
Exemplo n.º 9
0
        internal TattooablePart(IBodyPart source, CreatureStr allTattoosShort, CreatureStr allTattoosLong)
        {
            parent = source ?? throw new ArgumentNullException(nameof(source));

            allTattoosShortDescription = allTattoosShort ?? throw new ArgumentNullException(nameof(allTattoosShort));
            allTattoosLongDescription  = allTattoosLong ?? throw new ArgumentNullException(nameof(allTattoosLong));
        }
Exemplo n.º 10
0
        protected override void OnRemovePart(string slot, IBodyPart part)
        {
            base.OnRemovePart(slot, part);

            _partContainer.ForceRemove(part.Owner);
            part.Owner.RandomOffset(0.25f);
        }
Exemplo n.º 11
0
        public void RemovedFromPart(IBodyPart old)
        {
            DebugTools.AssertNull(Part);
            DebugTools.AssertNotNull(old);

            OnRemovedFromPart(old);
        }
Exemplo n.º 12
0
        private bool ConnectedToCenterPart(IBodyPart target)
        {
            var searchedSlots = new List <string>();

            return(TryGetSlotName(target, out var result) &&
                   ConnectedToCenterPartRecursion(searchedSlots, result));
        }
Exemplo n.º 13
0
        private bool TryGetSlotName(IBodyPart part, [NotNullWhen(true)] out string result)
        {
            // We enforce that there is only one of each value in the dictionary,
            // so we can iterate through the dictionary values to get the key from there.
            var pair = Parts.FirstOrDefault(x => x.Value == part);
            result = pair.Key;

            return !pair.Equals(default);
Exemplo n.º 14
0
        internal Piercing(IBodyPart source, PiercingUnlocked LocationUnlocked, CreatureStr shortDesc, CreatureStr longDesc)
        {
            parent = source ?? throw new ArgumentNullException(nameof(source));

            piercingUnlocked             = LocationUnlocked ?? throw new ArgumentNullException(nameof(LocationUnlocked));
            allPiercingsShortDescription = shortDesc ?? throw new ArgumentNullException(nameof(shortDesc));
            allPiercingsLongDescription  = longDesc ?? throw new ArgumentNullException(nameof(longDesc));
        }
        protected override void OnRemovedFromPart(IBodyPart old)
        {
            base.OnRemovedFromPart(old);

            if (Owner.TryGetComponent(out ISpriteComponent? sprite))
            {
                sprite.Visible = true;
            }
        }
Exemplo n.º 16
0
        protected override void OnPartAdd(IBodyPart?old, IBodyPart current)
        {
            base.OnPartAdd(old, current);

            if (Owner.TryGetComponent(out SpriteComponent? sprite))
            {
                sprite.Visible = false;
            }
        }
Exemplo n.º 17
0
        public void AddedToPartInBody(IBody body, IBodyPart part)
        {
            DebugTools.AssertNotNull(Body);
            DebugTools.AssertNotNull(body);
            DebugTools.AssertNotNull(Part);
            DebugTools.AssertNotNull(part);

            OnAddedToPartInBody(body, part);
        }
Exemplo n.º 18
0
        protected virtual bool CanAddPart(string slot, IBodyPart part)
        {
            if (!HasSlot(slot) || !_parts.TryAdd(slot, part))
            {
                return(false);
            }

            return(true);
        }
Exemplo n.º 19
0
        public void RemovedFromPartInBody(IBody oldBody, IBodyPart oldPart)
        {
            DebugTools.AssertNull(Body);
            DebugTools.AssertNull(Part);
            DebugTools.AssertNotNull(oldBody);
            DebugTools.AssertNotNull(oldPart);

            OnRemovedFromPartInBody(oldBody, oldPart);
        }
Exemplo n.º 20
0
        public void SetPart(IBodyPart part)
        {
            if (Part != null)
            {
                RemovePart();
            }

            Part = part;
            PartAdded?.Invoke(part);
        }
Exemplo n.º 21
0
        public Win2DAdornerRenderNode(NodeBase node, Win2DRenderer renderer, IBodyPart geometry, Rect2 bounds)
            : base(node, renderer)
        {
            Guard.NotNull(geometry, nameof(geometry));

            this.geometry = geometry;

            UpdateSize(bounds.Size);
            UpdatePosition(bounds.Position);
        }
Exemplo n.º 22
0
        public bool TryAddPart(IBodyPart part)
        {
            if (!CanAddPart(part))
            {
                return(false);
            }

            SetPart(part);
            return(true);
        }
 public void Update(IBodyPart observable, IBodyPart context)
 {
     if (observable.GetState().StateEnum != StateEnum.Downwards)
     {
         context.CanModify = true;
     }
     else
     {
         context.CanModify = false;
     }
 }
Exemplo n.º 24
0
 public static bool AreIdentical <U>(IBodyPart <U> source, U originalData, bool ignoreSexualMetaData) where U : class
 {
     if (source is null)
     {
         return(originalData is null);
     }
     else
     {
         return(source.IsIdenticalTo(originalData, ignoreSexualMetaData));
     }
 }
Exemplo n.º 25
0
 public void Update(IBodyPart observable, IBodyPart context)
 {
     if (observable.GetState().StateEnum == StateEnum.StronglyContracted)
     {
         context.CanModify = true;
     }
     else
     {
         context.CanModify = false;
     }
 }
Exemplo n.º 26
0
        public static bool TryGetProperty(this IBodyPart part, Type type,
                                          [NotNullWhen(true)] out IBodyPartProperty?property)
        {
            if (!part.Owner.TryGetComponent(type, out var component))
            {
                property = null;
                return(false);
            }

            return((property = component as IBodyPartProperty) != null);
        }
Exemplo n.º 27
0
        public void ComputeBody()
        {
            var body = CreateBody(bodyGeometry);

            if (body != null)
            {
                ClearBody();

                bodyGeometry = body;
            }
        }
Exemplo n.º 28
0
        public IRequestBodyBuilder IncludePart(IBodyPart part)
        {
            AssertMultipartable();

            if (parts == null)
            {
                parts = new List <IBodyPart>();
            }

            parts.Add(part);
            multipart = true;
            return(this);
        }
Exemplo n.º 29
0
        private string GetText(IBodyPart emailMessage)
        {
            if (string.IsNullOrWhiteSpace(emailMessage.Body))
            {
                return(null);
            }
            //Достанем текст письма и если оно в html то приведем его в нормальный вид
            var text = emailMessage.IsBodyHtml
                ? _htmlConverterService.ConvertHtml(emailMessage.Body)
                : emailMessage.Body;

            return(text);
        }
Exemplo n.º 30
0
        public void RemovePart(IBodyPart part, bool drop)
        {
            DebugTools.AssertNotNull(part);

            var slotName = _parts.FirstOrDefault(x => x.Value == part).Key;

            if (string.IsNullOrEmpty(slotName))
            {
                return;
            }

            RemovePart(slotName, drop);
        }