Пример #1
0
        public override void PostLoad()
        {
            base.PostLoad();

            ConnectedComponent1 = ComponentsManager.GetComponent(c1);
            ConnectedComponent2 = ComponentsManager.GetComponent(c2);
        }
Пример #2
0
        public void DrawGhost(MicroWorld.Graphics.Renderer renderer, int x1, int y1, int x2, int y2)
        {
            var c = ComponentsManager.GetComponent(x1, y1);

            if (c != null)
            {
                x1 = (int)(c.Graphics.Position.X + c.Graphics.GetSize().X / 2);
                y1 = (int)(c.Graphics.Position.Y + c.Graphics.GetSize().Y / 2);
            }
            else
            {
                return;
            }
            var c2 = ComponentsManager.GetComponent(x2, y2);

            if (c2 != null)
            {
                x2 = (int)(c2.Graphics.Position.X + c2.Graphics.GetSize().X / 2);
                y2 = (int)(c2.Graphics.Position.Y + c2.Graphics.GetSize().Y / 2);
            }
            if (c2 == null || c2 is Properties.IRotator || c2 is Properties.IRotatable)
            {
                (Graphics as Graphics.RotatableConnectorGraphics).DrawConnector(x1, y1, x2, y2, renderer, 0.6f);
                Components.Graphics.RotatableConnectorGraphics.DrawBorder(new Vector2(x1, y1), new Vector2(x2, y2), renderer);
            }
        }
Пример #3
0
        public override void PostLoad()
        {
            base.PostLoad();

            ConnectedWires.Clear();
            if (connectedWiresData != null && connectedWiresData != "")
            {
                var a = connectedWiresData.Split(';');
                for (int i = 0; i < a.Length; i++)
                {
                    ConnectedWires.Add(ComponentsManager.GetComponent(Convert.ToInt32(a[i])) as Wire);
                }
            }

            /*
             * ContainingComponents.Clear();
             * if (containingComponentsData != null && containingComponentsData != "")
             * {
             *  var a = containingComponentsData.Split(';');
             *  for (int i = 0; i < a.Length; i++)
             *  {
             *      ContainingComponents.Add(ComponentsManager.GetComponent(Convert.ToInt32(a[i])) as Wire);
             *  }
             * }//*/
        }
Пример #4
0
        public override void PostLoad()
        {
            base.PostLoad();

            if (con != Int32.MinValue && con != -1)
            {
                connectedComponent = ComponentsManager.GetComponent(com);
                connector          = ComponentsManager.GetComponent(con) as RotatableConnector;
            }
        }
Пример #5
0
        /// <summary>
        /// Check for things like shared Joints
        /// </summary>
        /// <returns></returns>
        public virtual bool IsMovable()
        {
            if (!IsRemovable)
            {
                return(false);
            }
            var   a = getJoints();
            Joint t;

            for (int i = 0; i < a.Length; i++)
            {
                t = ComponentsManager.GetComponent(a[i]) as Joint;
                if (t.ContainingComponents.Count > 1)
                {
                    return(false);
                }
            }
            return(true);
        }
Пример #6
0
        public override void PostLoad()
        {
            base.PostLoad();

            Joints[0]  = (Joint)Components.ComponentsManager.GetComponent(j0);
            Joints[1]  = (Joint)Components.ComponentsManager.GetComponent(j1);
            W          = (Wire)Components.ComponentsManager.GetComponent(w);
            Resistance = res;
            if (com != -1)
            {
                connectedComponent = ComponentsManager.GetComponent(com);
                connector          = ComponentsManager.GetComponent(con) as RotatableConnector;
            }

            for (int i = 0; i < Joints.Length; i++)
            {
                Joints[i].ContainingComponents.Add(this);
            }
        }
Пример #7
0
        public override void PostLoad()
        {
            base.PostLoad();

            containsComponents = new Component[contains.Count];
            components.Clear();
            for (int i = 0; i < contains.Count; i++)
            {
                containsComponents[i] = ComponentsManager.GetComponent(contains[i]);
                components.Add(containsComponents[i]);

                if (origPos != null)
                {
                    tppushed.Add(components[i].Graphics.PushPosition());
                    components[i].Graphics.PopPosition(PushedPositions[i]);
                }
            }
            contains.Clear();

            RegisterColliders();
        }
Пример #8
0
        public override void PostLoad()
        {
            base.PostLoad();

            J1 = (Joint)ComponentsManager.GetComponent(j1);
            J2 = (Joint)ComponentsManager.GetComponent(j2);

            if (dp != null)
            {
                var a = dp.Split(';');
                var g = Graphics as Graphics.WireGraphics;
                g.DrawPath.Clear();
                g.IgnoreNextPathFinder = true;
                for (int i = 0; i < a.Length; i += 2)
                {
                    g.DrawPath.Add(new Vector2((float)Convert.ToDouble(a[i]), (float)Convert.ToDouble(a[i + 1])));
                }
            }

            (Graphics as Graphics.WireGraphics).GenerateElectrons();
            updateVoltageCurrent();
        }
Пример #9
0
        public Wire(int id1, int id2)
        {
            Component t = ComponentsManager.GetComponent(id1);

            if (t == null || !(t is Joint))
            {
                J1 = new Joint();
            }
            else
            {
                J1 = (Joint)t;
            }

            t = ComponentsManager.GetComponent(id2);
            if (t == null || !(t is Joint))
            {
                J2 = new Joint();
            }
            else
            {
                J2 = (Joint)t;
            }
            constructor();
        }