Пример #1
0
        /// <summary>
        /// sets all the adaptors that are not connected to be invisble (only the side that's not connected to this part)
        /// also sets adaptor.isUnconnected to the respective value
        ///
        /// TODO: this is a bit of a hack, should come back to this and clean it up
        /// </summary>
        public void ToggleAdaptorVisibility()
        {
            var Hider = new MaterialHider(); //instantiate new hider

            if (AdaptorConnections == null)  //sometimes this isn't initialized for some reason...
            {
                AdaptorConnections = new Dictionary <WeaponPart, Adaptor>();
            }

            if (Adaptors == null) //there are parts that don't have any adaptors (for example a silencer or something like that)
            {
                return;
            }

            foreach (Adaptor a in Adaptors)
            {
                if (!AdaptorConnections.ContainsValue(a)) //adaptor isn't connected
                {
                    a.isUnconnected = true;

                    if (a.ChildPartTransform == null)
                    {
                        continue;
                    }

                    Hider.HideHierarchy(a.ChildPartTransform.gameObject, this.PartID); //hide the unconnected side and set id as this.partid, so we can selectively turn back on
                                                                                       //only the adaptor that belongs to this part instead of the whole hierarchy below our adaptor
                }
                else
                {
                    a.isUnconnected = false;
                }
            }
        }
Пример #2
0
        /// <summary>
        /// removes a child from this part
        /// </summary>
        /// <param name="child">the child to remove </param>
        public void RemoveChild(WeaponPart child)
        {
            //checks
            if (!Children.Contains(child))//if part is no child
            {
                return;
            }

            //remove child
            Children.Remove(child);
            Adaptor a = AdaptorConnections[child];

            AdaptorConnections.Remove(child);

            if (a != null) //better nullcheck it
            {
                //hide adaptor again
                MaterialHider hider = new MaterialHider();
                hider.HideHierarchy(a.ChildPartTransform.gameObject, this.PartID);
                a.isUnconnected = true;
            }
        }