コード例 #1
0
        public override void Initialize()
        {
            IO.Log.Write("        CS initializing...");
            MicroWorld.Graphics.GUI.ClickabilityOverlay.RegisterExtension(Components.ClickableComponents.Instance);

            ClickabilityOverlay.RegisterExtension(this);

            ShouldBeScaled = false;
            Layer = 500;

            MicroWorld.Components.Cursor cs = new MicroWorld.Components.Cursor();
            RegisterComponent(cs);
            cursor = components[0];
            cursor.drawCount = false;

            MicroWorld.Components.RotatableConnector rc = new MicroWorld.Components.RotatableConnector();
            RegisterComponent(rc);

            MicroWorld.Components.Joint j = new MicroWorld.Components.Joint();
            RegisterComponent(j);
            MicroWorld.Components.Joint._TypeID = j.typeID;

            MicroWorld.Components.Wire w = new MicroWorld.Components.Wire();
            RegisterComponent(w);
            Components.Wire.TypeID = Components.ComponentsManager.TypeIDs[typeof(Components.Wire)];

            MicroWorld.Components.Core cr = new MicroWorld.Components.Core();
            RegisterComponent(cr);

            MicroWorld.Components.PulseCore cr2 = new MicroWorld.Components.PulseCore();
            RegisterComponent(cr2);

            //MicroWorld.Components.PipeJoint pj = new MicroWorld.Components.PipeJoint();
            //RegisterComponent(pj);

            //MicroWorld.Components.Pipe p = new MicroWorld.Components.Pipe();
            //RegisterComponent(p);

            for (int i = 0; i < MicroWorld.Components.ComponentsManager.RegisteredComponents.Count; i++)
            {
                Type t = MicroWorld.Components.ComponentsManager.RegisteredComponents[i];
                MicroWorld.Components.Component comp = (MicroWorld.Components.Component)Activator.CreateInstance(t);
                if (comp.Graphics.ShouldDisplayInCS())
                    RegisterComponent(comp);
                else
                    Components.ComponentsManager.TypeIDs.Add(comp.GetType(), (short)Components.ComponentsManager.TypeIDs.Count);

                try
                {
                    var a = comp.GetType().GetMethod("StaticInit");
                    if (a != null)
                        a.Invoke(null, null);
                }
                catch { };
            }

            GenerateStructure();
            selectedComponent = rootTiles[0] as CSComponentCopy;

            GlobalEvents.onComponentRemovedByPlayer += new GlobalEvents.ComponentEventHandler(GlobalEvents_onComponentRemovedByPlayer);
        }
コード例 #2
0
        public override void Initialize()
        {
            IO.Log.Write("        CS initializing...");
            MicroWorld.Graphics.GUI.ClickabilityOverlay.RegisterExtension(Components.ClickableComponents.Instance);

            ClickabilityOverlay.RegisterExtension(this);

            ShouldBeScaled = false;
            Layer          = 500;

            MicroWorld.Components.Cursor cs = new MicroWorld.Components.Cursor();
            RegisterComponent(cs);
            cursor           = components[0];
            cursor.drawCount = false;

            MicroWorld.Components.RotatableConnector rc = new MicroWorld.Components.RotatableConnector();
            RegisterComponent(rc);

            MicroWorld.Components.Joint j = new MicroWorld.Components.Joint();
            RegisterComponent(j);
            MicroWorld.Components.Joint._TypeID = j.typeID;

            MicroWorld.Components.Wire w = new MicroWorld.Components.Wire();
            RegisterComponent(w);
            Components.Wire.TypeID = Components.ComponentsManager.TypeIDs[typeof(Components.Wire)];

            MicroWorld.Components.Core cr = new MicroWorld.Components.Core();
            RegisterComponent(cr);

            MicroWorld.Components.PulseCore cr2 = new MicroWorld.Components.PulseCore();
            RegisterComponent(cr2);

            //MicroWorld.Components.PipeJoint pj = new MicroWorld.Components.PipeJoint();
            //RegisterComponent(pj);

            //MicroWorld.Components.Pipe p = new MicroWorld.Components.Pipe();
            //RegisterComponent(p);

            for (int i = 0; i < MicroWorld.Components.ComponentsManager.RegisteredComponents.Count; i++)
            {
                Type t = MicroWorld.Components.ComponentsManager.RegisteredComponents[i];
                MicroWorld.Components.Component comp = (MicroWorld.Components.Component)Activator.CreateInstance(t);
                if (comp.Graphics.ShouldDisplayInCS())
                {
                    RegisterComponent(comp);
                }
                else
                {
                    Components.ComponentsManager.TypeIDs.Add(comp.GetType(), (short)Components.ComponentsManager.TypeIDs.Count);
                }

                try
                {
                    var a = comp.GetType().GetMethod("StaticInit");
                    if (a != null)
                    {
                        a.Invoke(null, null);
                    }
                }
                catch { };
            }

            GenerateStructure();
            selectedComponent = rootTiles[0] as CSComponentCopy;

            GlobalEvents.onComponentRemovedByPlayer += new GlobalEvents.ComponentEventHandler(GlobalEvents_onComponentRemovedByPlayer);
        }