public static HumanoidVisualLayers?ToHumanoidLayer(this SharedBodyPartComponent part)
 {
     return(part.PartType switch
     {
         BodyPartType.Other => null,
         BodyPartType.Torso => HumanoidVisualLayers.Chest,
         BodyPartType.Head => HumanoidVisualLayers.Head,
         BodyPartType.Arm => part.Symmetry switch
         {
             BodyPartSymmetry.None => null,
             BodyPartSymmetry.Left => HumanoidVisualLayers.LArm,
             BodyPartSymmetry.Right => HumanoidVisualLayers.RArm,
             _ => throw new ArgumentOutOfRangeException()
         },
Exemple #2
0
        private void UpdateBodyPartBox(SharedBodyPartComponent part, string slotName)
        {
            BodyPartLabel.Text = $"{Loc.GetString(slotName)}: {Loc.GetString(part.Owner.Name)}";

            // TODO BODY Part damage
            if (part.Owner.TryGetComponent(out IDamageableComponent? damageable))
            {
                BodyPartHealth.Text = Loc.GetString("body-scanner-display-body-part-damage-text", ("damage", damageable.TotalDamage));
            }

            MechanismList.Clear();

            foreach (var mechanism in part.Mechanisms)
            {
                MechanismList.AddItem(mechanism.Name);
            }
        }
        private void UpdateBodyPartBox(SharedBodyPartComponent part, string slotName)
        {
            var entMan = IoCManager.Resolve <IEntityManager>();

            BodyPartLabel.Text = $"{Loc.GetString(slotName)}: {Loc.GetString(entMan.GetComponent<MetaDataComponent>(part.Owner).EntityName)}";

            // TODO BODY Part damage
            if (entMan.TryGetComponent(part.Owner, out DamageableComponent? damageable))
            {
                BodyPartHealth.Text = Loc.GetString("body-scanner-display-body-part-damage-text", ("damage", damageable.TotalDamage));
            }

            MechanismList.Clear();

            foreach (var mechanism in part.Mechanisms)
            {
                MechanismList.AddItem(mechanism.Name);
            }
        }
Exemple #4
0
        protected override void OnAddedToPartInBody(SharedBodyComponent body, SharedBodyPartComponent part)
        {
            base.OnAddedToPartInBody(body, part);

            HandleMind(body.Owner, Owner);
        }
Exemple #5
0
        protected override void OnAddedToPart(SharedBodyPartComponent part)
        {
            base.OnAddedToPart(part);

            HandleMind(part.Owner, Owner);
        }
 protected virtual void OnRemovedFromPartInBody(SharedBodyComponent oldBody, SharedBodyPartComponent oldPart)
 {
 }
Exemple #7
0
 public RemovedFromPartEvent(SharedBodyPartComponent old)
 {
     Old = old;
 }
 protected override bool CanAddPart(string slotId, SharedBodyPartComponent part)
 {
     return(base.CanAddPart(slotId, part) &&
            _partContainer.CanInsert(part.Owner));
 }
            protected override void OnAddedToPart(SharedBodyPartComponent part)
            {
                base.OnAddedToPart(part);

                WasAddedToPart = true;
            }
Exemple #10
0
 public AddedToPartEvent(SharedBodyPartComponent part)
 {
     Part = part;
 }
 /// <summary>
 ///     Called when the parent mechanism is added into a part that is not attached to a body.
 ///     For instance, adding a brain to a dismembered head.
 ///     DO NOT CALL THIS DIRECTLY FROM OUTSIDE BODY SYSTEM CODE!
 /// </summary>
 /// <param name="part">
 ///     The part that the containing mechanism was added to.
 /// </param>
 public abstract void AddedToPart(SharedBodyPartComponent part);
 /// <summary>
 ///     Called when the parent mechanism is added to a part that is attached to a body.
 ///     For instance, adding a brain to a head that is attached to a body.
 ///     DO NOT CALL THIS DIRECTLY FROM OUTSIDE BODY SYSTEM CODE!
 /// </summary>
 /// <param name="body">
 ///     The body that the containing mechanism was added to.
 /// </param>
 /// <param name="part">
 ///     The part that the containing mechanism was added to.
 /// </param>
 public abstract void AddedToPartInBody(SharedBodyComponent body, SharedBodyPartComponent part);
 /// <summary>
 ///     Called when the parent mechanism is removed from a part that is attached to a body.
 ///     For instance, removing a brain from a head that is attached to a body.
 ///     DO NOT CALL THIS DIRECTLY FROM OUTSIDE BODY SYSTEM CODE!
 /// </summary>
 /// <param name="oldBody">
 ///     The body that the containing mechanism was removed from.
 /// </param>
 /// <param name="oldPart">
 ///     The part that the containing mechanism was removed from.
 /// </param>
 public abstract void RemovedFromPartInBody(SharedBodyComponent oldBody, SharedBodyPartComponent oldPart);
 /// <summary>
 ///     Called when the parent mechanism is removed from a part that is not attached to a body.
 ///     For instance, removing a brain from a dismembered head.
 ///     DO NOT CALL THIS DIRECTLY FROM OUTSIDE BODY SYSTEM CODE!
 /// </summary>
 /// <param name="old">
 ///     The part that the containing mechanism was removed from.
 /// </param>
 public abstract void RemovedFromPart(SharedBodyPartComponent old);
        public static IEnumerable <HumanoidVisualLayers> ToHumanoidLayers(this SharedBodyPartComponent part)
        {
            switch (part.PartType)
            {
            case BodyPartType.Other:
                yield break;

            case BodyPartType.Torso:
                yield return(HumanoidVisualLayers.Chest);

                break;

            case BodyPartType.Head:
                yield return(HumanoidVisualLayers.Head);

                yield return(HumanoidVisualLayers.Eyes);

                yield return(HumanoidVisualLayers.FacialHair);

                yield return(HumanoidVisualLayers.Hair);

                yield return(HumanoidVisualLayers.StencilMask);

                break;

            case BodyPartType.Arm:
                switch (part.Symmetry)
                {
                case BodyPartSymmetry.None:
                    yield break;

                case BodyPartSymmetry.Left:
                    yield return(HumanoidVisualLayers.LArm);

                    break;

                case BodyPartSymmetry.Right:
                    yield return(HumanoidVisualLayers.RArm);

                    break;

                default:
                    yield break;
                }
                yield break;

            case BodyPartType.Hand:
                switch (part.Symmetry)
                {
                case BodyPartSymmetry.None:
                    yield break;

                case BodyPartSymmetry.Left:
                    yield return(HumanoidVisualLayers.LHand);

                    break;

                case BodyPartSymmetry.Right:
                    yield return(HumanoidVisualLayers.RHand);

                    break;

                default:
                    yield break;
                }
                yield break;

            case BodyPartType.Leg:
                switch (part.Symmetry)
                {
                case BodyPartSymmetry.None:
                    yield break;

                case BodyPartSymmetry.Left:
                    yield return(HumanoidVisualLayers.LLeg);

                    break;

                case BodyPartSymmetry.Right:
                    yield return(HumanoidVisualLayers.RLeg);

                    break;

                default:
                    yield break;
                }
                yield break;

            case BodyPartType.Foot:
                switch (part.Symmetry)
                {
                case BodyPartSymmetry.None:
                    yield break;

                case BodyPartSymmetry.Left:
                    yield return(HumanoidVisualLayers.LFoot);

                    break;

                case BodyPartSymmetry.Right:
                    yield return(HumanoidVisualLayers.RFoot);

                    break;

                default:
                    yield break;
                }
                yield break;

            default:
                yield break;
            }
        }
Exemple #16
0
        protected override void OnRemovedFromPart(SharedBodyPartComponent old)
        {
            base.OnRemovedFromPart(old);

            HandleMind(Owner, old.Owner);
        }
            protected override void OnAddedToPartInBody(SharedBodyComponent body, SharedBodyPartComponent part)
            {
                base.OnAddedToPartInBody(body, part);

                WasAddedToPartInBody = true;
            }
Exemple #18
0
        protected override void OnRemovedFromPartInBody(SharedBodyComponent oldBody, SharedBodyPartComponent oldPart)
        {
            base.OnRemovedFromPartInBody(oldBody, oldPart);

            HandleMind(oldBody.Owner, Owner);
        }
            protected override void OnRemovedFromPart(SharedBodyPartComponent old)
            {
                base.OnRemovedFromPart(old);

                WasRemovedFromPart = true;
            }
Exemple #20
0
 public AddedToPartInBodyEvent(SharedBodyComponent body, SharedBodyPartComponent part)
 {
     Body = body;
     Part = part;
 }
            protected override void OnRemovedFromPartInBody(SharedBodyComponent oldBody, SharedBodyPartComponent oldPart)
            {
                base.OnRemovedFromPartInBody(oldBody, oldPart);

                WasRemovedFromPartInBody = true;
            }
Exemple #22
0
 public RemovedFromPartInBodyEvent(SharedBodyComponent oldBody, SharedBodyPartComponent oldPart)
 {
     OldBody = oldBody;
     OldPart = oldPart;
 }
 protected virtual void OnAddedToPartInBody(SharedBodyComponent body, SharedBodyPartComponent part)
 {
 }
        protected override void OnAddPart(BodyPartSlot slot, SharedBodyPartComponent part)
        {
            base.OnAddPart(slot, part);

            _partContainer.Insert(part.Owner);
        }
 public bool CanAddPart(SharedBodyPartComponent part)
 {
     return(Part == null && part.PartType == PartType);
 }
 protected virtual void OnAddedToPart(SharedBodyPartComponent part)
 {
 }
 protected virtual void OnRemovedFromPart(SharedBodyPartComponent old)
 {
 }