internal static void OnComponentMoved(Components.Component c) { if (onComponentMoved != null) { onComponentMoved.Invoke(c); } }
internal static void OnComponentRemovedByPlayer(Components.Component c) { if (onComponentRemovedByPlayer != null) { onComponentRemovedByPlayer.Invoke(c); } }
internal static void OnComponentRemoved(Components.Component c) { if (c is Components.Properties.ICollidable) { (c as Components.Properties.ICollidable).UnRegisterColliders(); } if (onComponentRemoved != null) { onComponentRemoved.Invoke(c); } }
public override int[] GetJointCoords(Component.Rotation r) { switch (r) { case Rotation.cw0: return new int[] { JointLocs0cw[0], JointLocs0cw[1], JointLocs0cw[2], JointLocs0cw[3], JointLocs0cw[4], JointLocs0cw[5] }; case Rotation.cw90: case Rotation.cw180: case Rotation.cw270: default: return new int[0]; } }
internal static void OnComponentPlacedByPlayer(Components.Component c) { if (c is Components.Properties.ICollidable) { (c as Components.Properties.ICollidable).RegisterColliders(); } Sound.SoundPlayer.ComponentPlaced(); if (onComponentPlacedByPlayer != null) { onComponentPlacedByPlayer.Invoke(c); } }
public override int[] GetJointCoords(Component.Rotation r) { switch (r) { case Rotation.cw0: return new int[] { JointLocs0cw[0], JointLocs0cw[1] }; case Rotation.cw90: break; case Rotation.cw180: break; case Rotation.cw270: break; default: break; } return base.GetJointCoords(r); }
public String GetMapOverlayToolTip(Component c = null) { if (c == null) { return ((float)((int)(Joints[0].SendingVoltage * 10)) / 10f).ToString() + " V"; } else { if (c is Properties.IMagnetic) { float l = (c as Properties.IMagnetic).GetFieldForce(Graphics.Center.X, Graphics.Center.Y).Length() / MaxMagnetForce; l = l > 1 ? 1 : l < 0 ? 0 : l; return ((float)((int)(MaxVoltage * l * 10)) / 10f).ToString() + " V"; } else { return "0 V"; } } }
public String GetMapOverlayToolTip(Component c = null) { if (c == null) { return ((int)((Logics as Logics.PhotoresistorLogics).Brightness * 100)).ToString() + " %"; } else { if (!(c is Properties.ILightEmitting)) return "0 %"; else return ((int)((c as Properties.ILightEmitting).GetBrightness(Graphics.Center.X, Graphics.Center.Y) * 100)).ToString() + " %"; } }
/// <summary> /// Sets point to a specificvalue /// </summary> /// <param name="x">X</param> /// <param name="y">Y</param> /// <param name="v">Value</param> public void SetPoint(Component sender, float x, float y) { int divider = 64 * MicroWorld.Graphics.GUI.GridDraw.Step; GetChunk(x, y).data[(int)Math.Abs(x % divider) / 8, (int)Math.Abs(y % divider) / 8] = (short)(sender == null ? 0 : sender.typeID); }
public bool IsInRange(Component c) { return Math.Sqrt(Math.Pow(c.Graphics.Position.X + c.Graphics.GetSize().X / 2 - Graphics.Position.X - Graphics.GetSize().X / 2, 2) + Math.Pow(c.Graphics.Position.Y + c.Graphics.GetSize().Y / 2 - Graphics.Position.Y - Graphics.GetSize().Y / 2, 2)) < Luminosity; }
public override void Remove() { if (!IsRemovable) return; for (int i = 0; i < Joints.Length; i++) { Joints[i].IsRemovable = true; Joints[i].ContainingComponents.Remove(this); } W.IsRemovable = true; W.Remove(); for (int i = 0; i < Joints.Length; i++) { Joints[i].CanRemove = true; if (Joints[i].ConnectedWires.Count == 0) { Joints[i].Remove(); } } var a = connector; connectedComponent = null; if (a != null) a.Disconnect();//leave this as is. prevents stack overflow base.Remove(); }
public void Disconnect() { connector = null; connectedComponent = null; }
public RotatableConnector(Component c1, Component c2) { _connectedComponent1 = c1; _connectedComponent2 = c2; constructor(); }
void GlobalEvents_onComponentRemovedByPlayer(Component sender) { if (sender is MovementDetector) UpdateLasers(); }
void GlobalEvents_onComponentMoved(Component sender) { UpdateLasers(); }
public void Disconnect() { if (ConnectedComponent1 is Properties.IRotator) (ConnectedComponent1 as Properties.IRotator).Disconnect(); if (ConnectedComponent1 is Properties.IRotatable) (ConnectedComponent1 as Properties.IRotatable).Disconnect(); if (ConnectedComponent2 is Properties.IRotator) (ConnectedComponent2 as Properties.IRotator).Disconnect(); if (ConnectedComponent2 is Properties.IRotatable) (ConnectedComponent2 as Properties.IRotatable).Disconnect(); ConnectedComponent1 = null; ConnectedComponent2 = null; Remove(); }
public override void PostLoad() { base.PostLoad(); ConnectedComponent1 = ComponentsManager.GetComponent(c1); ConnectedComponent2 = ComponentsManager.GetComponent(c2); }
public override void PostLoad() { base.PostLoad(); if (con != Int32.MinValue && con != -1) { connectedComponent = ComponentsManager.GetComponent(com); connector = ComponentsManager.GetComponent(con) as RotatableConnector; } }
public void GetStruck(Component origin, float voltage, int time) { (Logics as Logics.AdvancedJointLogics).AddSource(new Logics.AdvancedJointLogics.VoltageSource(time, voltage)); }
public override void Remove() { if (!IsRemovable) return; var a = connector; connectedComponent = null; if (a != null) a.Disconnect();//leave this as is. prevents stack overflow base.Remove(); }
public void Connect(Component c, RotatableConnector rc) { connector = rc; connectedComponent = c; }
public bool CanConnect(Component c) { return connectedComponent == null; }
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); } }
void GlobalEvents_onComponentMoved(Component sender) { UpdateComponentsList(); }
public bool CanConnect(Component c) { return connector == null && c is Properties.IRotatable; }
void GlobalEvents_onComponentRemovedByPlayer(Component sender) { UpdateComponentsList(); }
/// <summary> /// Sets a line to a specific value /// </summary> /// <param name="x1"></param> /// <param name="y1"></param> /// <param name="x2"></param> /// <param name="y2"></param> /// <param name="v"></param> public void SetLine(Component sender, float x1, float y1, float x2, float y2) { short v = (short)(sender == null ? 0 : sender.typeID); if (y1 > y2) { float t = y1; y1 = y2; y2 = t; } if (x1 > x2) { float t = x1; x1 = x2; x2 = t; } if (x1 == x2) { for (int y = (int)y1; y < (int)y2; y++) { SetPoint(x1, y, v); } } if (y1 == y2) { for (int x = (int)x1; x < (int)x2; x++) { SetPoint(x, y1, v); } } else { if (Math.Abs(x1 - x2) > Math.Abs(y1 - y2))//dx>dy { for (float x = x1; x != x2; x += Math.Sign(x2 - x1)) { float y = y1 + (y2 - y1) * (x / (x2 - x1)); SetPoint(x, y, v); } } else//dx<dy { for (float y = y1; y != y2; y += Math.Sign(y2 - y1)) { float x = x1 + (x2 - x1) * (y / (y2 - y1)); SetPoint(x, y, v); } } } }
public String GetMapOverlayToolTip(Component c = null) { if (c == null) { return W.IsConnected ? "Connected" : "Disconnected"; } else { if (c is Properties.IMagnetic) { return (c as Properties.IMagnetic).GetFieldForce(Graphics.Center.X, Graphics.Center.Y).Length() > (Logics as Logics.ReedSwitchLogics).RequiredField ? "Connected" : "Disconnected"; } else { return "Disconnected"; } } }
/// <summary> /// Sets rectangle to a specific value /// </summary> /// <param name="x">X</param> /// <param name="y">Y</param> /// <param name="w">W</param> /// <param name="h">H</param> /// <param name="v">Value</param> public void SetRectangle(Component sender, float x, float y, float w, float h) { //if (x < 0 && x + w >= 0) // w++; //if (y < 0 && y + h >= 0) // h++; /* int divider = 64 * MicroWorld.Graphics.GUI.GridDraw.Step; if ((int)(x / divider) == (int)((x + w) / divider) && (int)(y / divider) == (int)((y + h) / divider)) { var c = GetChunk(x, y); int dx = (int)(x % divider) / 8; int dy = (int)(y % divider) / 8; for (int i = 0; i < w / MicroWorld.Graphics.GUI.GridDraw.Step; i++) { for (int j = 0; j < h / MicroWorld.Graphics.GUI.GridDraw.Step; j++) { c.data[dx + i, dy + j] = v; } } } else //*/ //{ //TODO short v = (short)(sender == null ? 0 : sender.typeID); for (int i = 0; i < w; i += 8) { for (int j = 0; j < h; j += 8) { SetPoint(x + i, y + j, v); } } //} }
public override void SetRotation(Component.Rotation rot) { if (rot.GetHashCode() > 1) rot = (Component.Rotation)(rot.GetHashCode() - 2); base.SetRotation(rot); }