public CSComponent(CSComponent c) { avalable = c.avalable; enabled = c.enabled; componentGraphics = c.componentGraphics; isFavourite = c.isFavourite; drawCount = c.drawCount; objType = c.objType; IsDragDropPlacement = c.IsDragDropPlacement; Name = c.Name; }
public CSComponentCopy(CSComponentCopy c) { component = c.component; position = c.position; this.Color = c.Color; this.isVisible = c.isVisible; this.localIndex = c.localIndex; this.parent = c.parent; this.size = c.size; this.Texture = c.Texture; }
public void RegisterComponent(Components.Component comp) { CSComponent c = new CSComponent(); IO.Log.Write(" Adding " + comp.Graphics.GetCSToolTip() + " to ComponentSelector"); c.Texture = ResourceManager.Load <Texture2D>(comp.Graphics.GetIconName()); c.objType = comp.GetType(); c.instance = comp; c.componentGraphics = comp.Graphics; c.jointCoords0cw = comp.GetJointCoords(Components.Component.Rotation.cw0); c.jointCoords90cw = comp.GetJointCoords(Components.Component.Rotation.cw90); c.jointCoords180cw = comp.GetJointCoords(Components.Component.Rotation.cw180); c.jointCoords270cw = comp.GetJointCoords(Components.Component.Rotation.cw270); c.Name = comp.Graphics.GetCSToolTip(); c.IsDragDropPlacement = (comp is Components.Properties.IDragDropPlacable); /* * if (c.jointCoords0cw.Length % 2 == 1) * c.jointCoords0cw = new int[0]; * else * for (int i = 0; i < c.jointCoords0cw.Length; i++) * c.jointCoords0cw[i] = c.jointCoords0cw[i] - Math.Abs(c.jointCoords0cw[i] % 8); * * if (c.jointCoords90cw.Length % 2 == 1) * c.jointCoords90cw = new int[0]; * else * for (int i = 0; i < c.jointCoords90cw.Length; i++) * c.jointCoords90cw[i] = c.jointCoords90cw[i] - Math.Abs(c.jointCoords90cw[i] % 8); * * if (c.jointCoords180cw.Length % 2 == 1) * c.jointCoords180cw = new int[0]; * else * for (int i = 0; i < c.jointCoords180cw.Length; i++) * c.jointCoords180cw[i] = c.jointCoords180cw[i] - Math.Abs(c.jointCoords180cw[i] % 8); * * if (c.jointCoords270cw.Length % 2 == 1) * c.jointCoords270cw = new int[0]; * else * for (int i = 0; i < c.jointCoords270cw.Length; i++) * c.jointCoords270cw[i] = c.jointCoords270cw[i] - Math.Abs(c.jointCoords270cw[i] % 8);//*/ //comp.typeID = (short)components.Count; Components.ComponentsManager.TypeIDs.Add(comp.GetType(), (short)Components.ComponentsManager.TypeIDs.Count); components.Add(c); }
public void RemoveComponent(CSFolder parent, CSComponent component) { if (parent == null) { for (int i = 0; i < rootTiles.Count; i++) { if (rootTiles[i] is CSComponentCopy && (rootTiles[i] as CSComponentCopy).component == component) { if (rootTiles[i].position == selectedComponent.position) { ResetSelection(); } allTiles.Remove(rootTiles[i]); rootTiles.RemoveAt(i); break; } } for (int i = 0; i < rootTiles.Count; i++) { rootTiles[i].localIndex = i; } } else { for (int i = 0; i < parent.Tiles.Count; i++) { if (parent.Tiles[i] is CSComponentCopy && (parent.Tiles[i] as CSComponentCopy).component == component) { if (parent.Tiles[i].position == selectedComponent.position) { ResetSelection(); } allTiles.Remove(parent.Tiles[i]); parent.Tiles.RemoveAt(i); break; } } for (int i = 0; i < parent.Tiles.Count; i++) { parent.Tiles[i].localIndex = i; } } }
public void AddComponent(CSFolder parent, CSComponent component) { var copy = new CSComponentCopy(component); copy.parent = parent; if (parent == null) { copy.Position = new Vector2(4, 4 + rootTiles.Count * 40); copy.localIndex = rootTiles.Count; copy.isVisible = true; rootTiles.Add(copy); } else { copy.Position = new Vector2(6 + parent.position.X + 40, 4 + parent.Tiles.Count * 40); copy.localIndex = parent.Tiles.Count; copy.isVisible = false; parent.Tiles.Add(copy); } copy.Color = Color.White; allTiles.Add(copy); }
public CSComponentCopy(CSComponent c) { component = c; Texture = c.Texture; }
public void RemoveComponent(CSFolder parent, CSComponent component) { if (parent == null) { for (int i = 0; i < rootTiles.Count; i++) { if (rootTiles[i] is CSComponentCopy && (rootTiles[i] as CSComponentCopy).component == component) { if (rootTiles[i].position == selectedComponent.position) ResetSelection(); allTiles.Remove(rootTiles[i]); rootTiles.RemoveAt(i); break; } } for (int i = 0; i < rootTiles.Count; i++) { rootTiles[i].localIndex = i; } } else { for (int i = 0; i < parent.Tiles.Count; i++) { if (parent.Tiles[i] is CSComponentCopy && (parent.Tiles[i] as CSComponentCopy).component == component) { if (parent.Tiles[i].position == selectedComponent.position) ResetSelection(); allTiles.Remove(parent.Tiles[i]); parent.Tiles.RemoveAt(i); break; } } for (int i = 0; i < parent.Tiles.Count; i++) { parent.Tiles[i].localIndex = i; } } }
public void RegisterComponent(Components.Component comp) { CSComponent c = new CSComponent(); IO.Log.Write(" Adding " + comp.Graphics.GetCSToolTip() + " to ComponentSelector"); c.Texture = ResourceManager.Load<Texture2D>(comp.Graphics.GetIconName()); c.objType = comp.GetType(); c.instance = comp; c.componentGraphics = comp.Graphics; c.jointCoords0cw = comp.GetJointCoords(Components.Component.Rotation.cw0); c.jointCoords90cw = comp.GetJointCoords(Components.Component.Rotation.cw90); c.jointCoords180cw = comp.GetJointCoords(Components.Component.Rotation.cw180); c.jointCoords270cw = comp.GetJointCoords(Components.Component.Rotation.cw270); c.Name = comp.Graphics.GetCSToolTip(); c.IsDragDropPlacement = (comp is Components.Properties.IDragDropPlacable); /* if (c.jointCoords0cw.Length % 2 == 1) c.jointCoords0cw = new int[0]; else for (int i = 0; i < c.jointCoords0cw.Length; i++) c.jointCoords0cw[i] = c.jointCoords0cw[i] - Math.Abs(c.jointCoords0cw[i] % 8); if (c.jointCoords90cw.Length % 2 == 1) c.jointCoords90cw = new int[0]; else for (int i = 0; i < c.jointCoords90cw.Length; i++) c.jointCoords90cw[i] = c.jointCoords90cw[i] - Math.Abs(c.jointCoords90cw[i] % 8); if (c.jointCoords180cw.Length % 2 == 1) c.jointCoords180cw = new int[0]; else for (int i = 0; i < c.jointCoords180cw.Length; i++) c.jointCoords180cw[i] = c.jointCoords180cw[i] - Math.Abs(c.jointCoords180cw[i] % 8); if (c.jointCoords270cw.Length % 2 == 1) c.jointCoords270cw = new int[0]; else for (int i = 0; i < c.jointCoords270cw.Length; i++) c.jointCoords270cw[i] = c.jointCoords270cw[i] - Math.Abs(c.jointCoords270cw[i] % 8);//*/ //comp.typeID = (short)components.Count; Components.ComponentsManager.TypeIDs.Add(comp.GetType(), (short)Components.ComponentsManager.TypeIDs.Count); components.Add(c); }
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); }
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); }