public void test_setting_a_wire_to_high_should_result_in_the_wire_being_high() { var wire = new Wire(); wire.SetHigh(); AssertIsHigh(wire, "wire not high after setting it to high"); }
/// <summary> /// 构造方法 /// </summary> /// <params name="wire"></params> public WireInfoEntering(Wire wire) { // 初始化主窗体变量 Wire = wire; InitializeComponent(); // 加载需要修改的导线数据 var wirePoints = WirePoint.FindAllByProperty("wire.id", wire.id); if (wirePoints.Length > 0) { for (var i = 0; i < wirePoints.Length; i++) { dgrdvWire.Rows.Add(); dgrdvWire[0, i].Value = wirePoints[i].name; dgrdvWire[1, i].Value = wirePoints[i].coordinate_x; dgrdvWire[2, i].Value = wirePoints[i].coordinate_y; dgrdvWire[3, i].Value = wirePoints[i].coordinate_z; dgrdvWire[4, i].Value = wirePoints[i].left_distance; dgrdvWire[5, i].Value = wirePoints[i].right_distance; dgrdvWire[6, i].Value = wirePoints[i].top_distance; dgrdvWire[7, i].Value = wirePoints[i].bottom_distance; } } txtWireName.Text = wire.name; txtWireLevel.Text = wire.level; dtpMeasureDate.Value = wire.measure_date; cboVobserver.Text = wire.observer; cboVobserver.Text = wire.observer; cboCounter.Text = wire.counter; cboCounter.Text = wire.counter; dtpCountDate.Value = wire.count_date; cboChecker.Text = wire.checker; cboChecker.Text = wire.checker; dtpCheckDate.Value = wire.check_date; }
void OnMouseDrag() { if (!currentWire) currentWire = Wire.create(this); if (currentTerminal == null) currentWire.Drag(MyCommon.GetMousePosition()); else currentWire.Drag(currentTerminal.transform.position); }
public static Wire create(Terminal startTerminal) { Transform container = Instantiate(Dummy.transform) as Transform; currentWire = container.GetComponent(typeof(Wire)) as Wire; currentWire.Start(); currentWire.connection1 = startTerminal; return currentWire; }
public static void DestroyAll() { if (wires == null) return; foreach (Wire w in wires) { Destroy(w.gameObject); } currentWire = null; wires.Clear(); }
public void CheckWiringCompat(Wire w) { Node ThisNode = w.GetNode(this); //If this node can only be wired once, make sure a wire for it doesn't already exist if (ThisNode.CanOnlyBeWiredOnce()) { foreach (Wire test in WiredTo) { if (test.GetNode(this) == ThisNode) { throw new Exception("Invalid wiring attempted; tronic " + this + " has wire " + test + " and was trying to add wire " + w + " which re-wires node " + ThisNode); } } } }
private static Wire SetupOrGate(Action<Wire,Wire> initWires=null,Action<Wire,Wire> afterOrInit=null) { var in1 = new Wire(); var in2 = new Wire(); var @out = new Wire(); if(initWires!=null) { initWires(in1,in2); } new OrGate(in1,in2,@out); if(afterOrInit!=null) { afterOrInit(in1,in2); } return @out; }
void OnMouseUp() { if (currentTerminal == null || currentTerminal == this) { Wire.destroyCurrent(); Levels.currentLevel.connectionFail(1); } else { if (parent.CheckConnection(this, currentTerminal) && currentTerminal.parent.CheckConnection(currentTerminal, this)) { WireGrid.addWire(this, currentTerminal); Levels.currentLevel.connectionMade(); Wire.confirmCurrent(); } else { Wire.destroyCurrent(); Levels.currentLevel.connectionFail(2); } } currentWire = null; }
private static void AttachToGate(IEnumerable<string> wireNames, Gate gate) { foreach (var wireName in wireNames) { if (Wires.Count(x => x.Name == wireName) > 0) gate.Wires.Add(Wires.First(x => x.Name == wireName)); else { ushort hardValue; if (ushort.TryParse(wireName, out hardValue)) { var wire = new EndWire(hardValue); Wires.Add(wire); gate.Wires.Add(wire); } else if (!string.IsNullOrEmpty(wireName)) { var wire = new Wire {Name = wireName}; Wires.Add(wire); gate.Wires.Add(wire); } } } }
protected override void Init(Lifetime lifetime) { base.Init(lifetime); var serializationContext = SerializationContext; using (UsingLocalChange()) { Advise(lifetime, it => { if (!IsLocalChange) { return; } AssertNullability(it.Key); if (it.Kind != AddUpdateRemove.Remove) { AssertNullability(it.NewValue); } if (!OptimizeNested && it.Kind != AddUpdateRemove.Remove) { it.NewValue.IdentifyPolymorphic(Proto.Identities, Proto.Identities.Next(RdId)); } Wire.Send(RdId, SendContext.Of(serializationContext, it, this), (sendContext, stream) => { var sContext = sendContext.SzrCtx; var evt = sendContext.Event; var me = sendContext.This; var versionedFlag = me.IsMaster ? 1 << versionedFlagShift : 0; stream.Write(versionedFlag | (int)evt.Kind); var version = ++me.myNextVersion; if (me.IsMaster) { me.myPendingForAck[evt.Key] = version; stream.Write(version); } me.WriteKeyDelegate(sContext, stream, evt.Key); if (evt.Kind != AddUpdateRemove.Remove) { me.WriteValueDelegate(sContext, stream, evt.NewValue); } SendTrace?.Log($"{me} :: {evt.Kind} :: key = {evt.Key.PrintToString()}" + (me.IsMaster ? " :: version = " + version : "") + (evt.Kind != AddUpdateRemove.Remove ? " :: value = " + evt.NewValue.PrintToString() : "")); }); }); } Wire.Advise(lifetime, this); if (!OptimizeNested) //means values must be bindable { this.View(lifetime, (lf, k, v) => { v.BindPolymorphic(lf, this, "[" + k + "]"); }); } }
private void AwaitPulseCancel(Wire wire) { WiresSystem.SetData(wire.Owner, PowerWireActionKey.Pulsed, false); SetPower(wire.Owner, false); }
private bool XY(Wire wire) { if (Vector == wire.Vector) { return true; } return false; }
public NOT(Wire input) : base(input) { output = gateOperation(); }
private void NewElecCompFromListIndex(int Index) { switch (Index) { case 0: Resistance r = new Resistance(); elecCompSet.AddCompAndShow(r, Mycanvas); r.Move(100, 100); break; case 1: Capacity c = new Capacity(); elecCompSet.AddCompAndShow(c, Mycanvas); c.Move(100, 100); break; case 2: Wire w = new Wire(); elecCompSet.AddCompAndShow(w, Mycanvas); w.Move(100, 100); break; case 3: Inductance i = new Inductance(); elecCompSet.AddCompAndShow(i, Mycanvas); i.Move(100, 100); break; case 4: OhmMeter o = new OhmMeter(); elecCompSet.AddCompAndShow(o, Mycanvas); o.Move(100, 100); break; case 5: VoltMeter ee = new VoltMeter(); elecCompSet.AddCompAndShow(ee, Mycanvas); ee.Move(100, 100); break; case 6: ElecGround eg = new ElecGround(); elecCompSet.AddCompAndShow(eg, Mycanvas); eg.Move(100, 100); break; case 7: oscilloscopeData myOscilloscopeData = new oscilloscopeData(Brushes.Red, oscilloscopeData.Volt_Index, myOscilloscope.m_SyncContext); Probe pb = new Probe(Brushes.Red, myOscilloscopeData); if (!myOscilloscope.IsVisible) { myOscilloscope.Show(); } myOscilloscope.AddData(myOscilloscopeData); myOscilloscope.SyncSettings(); elecCompSet.AddCompAndShow(pb, Mycanvas); pb.Move(100, 100); break; case 8: myOscilloscopeData = new oscilloscopeData(Brushes.Blue, oscilloscopeData.Volt_Index, myOscilloscope.m_SyncContext); pb = new Probe(Brushes.Blue, myOscilloscopeData); if (!myOscilloscope.IsVisible) { myOscilloscope.Show(); } myOscilloscope.AddData(myOscilloscopeData); myOscilloscope.SyncSettings(); elecCompSet.AddCompAndShow(pb, Mycanvas); pb.Move(100, 100); break; case 9: Power p = new Power(); elecCompSet.AddCompAndShow(p, Mycanvas); p.Move(100, 100); break; case 10: ACPower ap = new ACPower(0, 0.1, 10); elecCompSet.AddCompAndShow(ap, Mycanvas); ap.Move(100, 100); break; } }
public static bool LoadCustomEntity(EntityData entityData, Level level) { LevelData levelData = level.Session.LevelData; Vector2 offset = new Vector2(levelData.Bounds.Left, levelData.Bounds.Top); if (Everest.Events.Level.LoadEntity(level, levelData, offset, entityData)) { return(true); } if (EntityLoaders.TryGetValue(entityData.Name, out EntityLoader loader)) { Entity loaded = loader(level, levelData, offset, entityData); if (loaded != null) { level.Add(loaded); return(true); } } if (entityData.Name == "everest/spaceController") { level.Add(new SpaceController()); return(true); } // The following entities have hardcoded "attributes." // Everest allows custom maps to set them. if (entityData.Name == "spinner") { if (level.Session.Area.ID == 3 || (level.Session.Area.ID == 7 && level.Session.Level.StartsWith("d-")) || entityData.Bool("dust")) { level.Add(new DustStaticSpinner(entityData, offset)); return(true); } CrystalColor color = CrystalColor.Blue; if (level.Session.Area.ID == 5) { color = CrystalColor.Red; } else if (level.Session.Area.ID == 6) { color = CrystalColor.Purple; } else if (level.Session.Area.ID == 10) { color = CrystalColor.Rainbow; } else if ("core".Equals(entityData.Attr("color"), StringComparison.InvariantCultureIgnoreCase)) { color = (CrystalColor)(-1); } else if (!Enum.TryParse(entityData.Attr("color"), true, out color)) { color = CrystalColor.Blue; } level.Add(new CrystalStaticSpinner(entityData, offset, color)); return(true); } if (entityData.Name == "trackSpinner") { if (level.Session.Area.ID == 10 || entityData.Bool("star")) { level.Add(new StarTrackSpinner(entityData, offset)); return(true); } else if (level.Session.Area.ID == 3 || (level.Session.Area.ID == 7 && level.Session.Level.StartsWith("d-")) || entityData.Bool("dust")) { level.Add(new DustTrackSpinner(entityData, offset)); return(true); } level.Add(new BladeTrackSpinner(entityData, offset)); return(true); } if (entityData.Name == "rotateSpinner") { if (level.Session.Area.ID == 10 || entityData.Bool("star")) { level.Add(new StarRotateSpinner(entityData, offset)); return(true); } else if (level.Session.Area.ID == 3 || (level.Session.Area.ID == 7 && level.Session.Level.StartsWith("d-")) || entityData.Bool("dust")) { level.Add(new DustRotateSpinner(entityData, offset)); return(true); } level.Add(new BladeRotateSpinner(entityData, offset)); return(true); } if (entityData.Name == "checkpoint" && entityData.Position == Vector2.Zero && !entityData.Bool("allowOrigin")) { // Workaround for mod levels with old versions of Ahorn containing a checkpoint at (0, 0): // Create the checkpoint and avoid the start position update in orig_Load. level.Add(new Checkpoint(entityData, offset)); return(true); } if (entityData.Name == "cloud") { patch_Cloud cloud = new Cloud(entityData, offset) as patch_Cloud; if (entityData.Has("small")) { cloud.Small = entityData.Bool("small"); } level.Add(cloud); return(true); } if (entityData.Name == "cobweb") { patch_Cobweb cobweb = new Cobweb(entityData, offset) as patch_Cobweb; if (entityData.Has("color")) { cobweb.OverrideColors = entityData.Attr("color")?.Split(',').Select(s => Calc.HexToColor(s)).ToArray(); } level.Add(cobweb); return(true); } if (entityData.Name == "movingPlatform") { patch_MovingPlatform platform = new MovingPlatform(entityData, offset) as patch_MovingPlatform; if (entityData.Has("texture")) { platform.OverrideTexture = entityData.Attr("texture"); } level.Add(platform); return(true); } if (entityData.Name == "sinkingPlatform") { patch_SinkingPlatform platform = new SinkingPlatform(entityData, offset) as patch_SinkingPlatform; if (entityData.Has("texture")) { platform.OverrideTexture = entityData.Attr("texture"); } level.Add(platform); return(true); } if (entityData.Name == "crumbleBlock") { patch_CrumblePlatform platform = new CrumblePlatform(entityData, offset) as patch_CrumblePlatform; if (entityData.Has("texture")) { platform.OverrideTexture = entityData.Attr("texture"); } level.Add(platform); return(true); } if (entityData.Name == "wire") { Wire wire = new Wire(entityData, offset); if (entityData.Has("color")) { wire.Color = entityData.HexColor("color"); } level.Add(wire); return(true); } return(false); }
private void FindPath(Wire wire) { if (wire.WireData[0] != 0) { YUp.Clear(); if (!wire.BYAdd) { YAdd(wire); } } if (wire.WireData[1] != 0) { XLeft.Clear(); if (!wire.BXSub) { XSub(wire); } } if (wire.WireData[2] != 0) { YDown.Clear(); if (!wire.BYSub) { YSub(wire); } } if (wire.WireData[3] != 0) { XRight.Clear(); if (!wire.BXAdd) { XAdd(wire); } } }
static void Main(string[] args) { if (args.Contains("-OFast")) { Step = 10; } if (args.Contains("-OMax")) { Step = 1; } if (args.Contains("-debug")) { DrawAstar = true; } //string file = "test_D_O"; string file = "test_D_O"; //string file = "lut_00BB_D_O"; //string file = "lut_00AB_D_O"; if (args.Length > 0) { file = args[0]; } var mainNetwork = new Mnet(); mainNetwork.ReadMnetFile(file + @".MNET"); //Удаление GNDS var gnds = mainNetwork.nodes.Where(t => t.NodeType == "GND" && !mainNetwork.wires.Any(t2=>t2.SrcName == t.NodeName)).ToList(); foreach (var node in gnds) { var wires = mainNetwork.wires.Where(t => t.SrcName == node.NodeName).ToList(); foreach (var wire in wires) mainNetwork.wires.Remove(wire); mainNetwork.nodes.Remove(node); } mainNetwork.wireGroups = new List<WireGroup>(); //Перевести соеденения DUP в группы Console.WriteLine("Конвертирование DUP"); var dupList = mainNetwork.nodes.Where(t => t.NodeType.Contains("DUP")).ToList(); //Обьеденение DUP List<Node> list = dupList; var dupdupWires = mainNetwork.wires.Where(t => list.FirstOrDefault(a => a.NodeName == t.SrcName) != null && list.FirstOrDefault(a => a.NodeName == t.DistName) != null); while (dupdupWires.Any()) { var wire = dupdupWires.First(); var firstDup = dupList.First(a => a.NodeName == wire.SrcName); var secondDup = dupList.First(a => a.NodeName == wire.DistName); var fromSecondWires = mainNetwork.wires.Where(t => t.SrcName == secondDup.NodeName).ToList(); foreach (var w in fromSecondWires) { w.SrcName = firstDup.NodeName; } mainNetwork.wires.Remove(wire); mainNetwork.nodes.Remove(secondDup); } var orList = mainNetwork.nodes.Where(t => t.NodeType.Contains("OR")).ToList(); dupList = mainNetwork.nodes.Where(t => t.NodeType.Contains("DUP")).ToList(); //Обьеденение OR var opt = true; while (opt) { opt = false; var OrToOrWires = new List<Wire>(); foreach (var node in orList) { foreach (var node2 in orList) { OrToOrWires.AddRange(mainNetwork.wires.Where(t => t.SrcName == node.NodeName && node2.NodeName == t.DistName)); } } if (OrToOrWires.Count > 0) { opt = true; foreach (var wire in OrToOrWires) { var fromor = mainNetwork.nodes.First(t => t.NodeName == wire.SrcName); var toor = mainNetwork.nodes.First(t => t.NodeName == wire.DistName); var wires = new List<Wire>(); wires.AddRange(mainNetwork.wires.Where(t => t.DistName == fromor.NodeName)); wires.AddRange(mainNetwork.wires.Where(t => t.DistName == toor.NodeName)); wires.Remove(wire); foreach (var w in wires) { w.DistName = wire.DistName; } mainNetwork.wires.Remove(wire); mainNetwork.nodes.Remove(fromor); } } else { } } //Создание Dummy обьектов //Поиск соеденений подходящих под DUMMY var dupToOrWires = new List<Wire>(); foreach (var node in dupList) { foreach (var node2 in orList) { dupToOrWires.AddRange(mainNetwork.wires.Where(t => t.SrcName == node.NodeName && node2.NodeName == t.DistName)); } } //Поиск обратных связей foreach (var node in orList) { foreach (var node2 in dupList) { dupToOrWires.AddRange(mainNetwork.wires.Where(t => t.SrcName == node.NodeName && node2.NodeName == t.DistName)); } } //Создание DUMMY int dummynum = 0; foreach (var wire in dupToOrWires) { mainNetwork.nodes.Add(new Node { NodeName = "DUMMY_" + dummynum, NodeType = "DUMMY" }); var newWire = new Wire { SrcName = "DUMMY_" + dummynum, SrcPort = "O0", DistName = wire.DistName, DistPort = wire.DistPort }; wire.DistName = "DUMMY_" + dummynum; wire.DistPort = "I0"; mainNetwork.wires.Add(newWire); dummynum++; } //Преобразование DUP В wireGroup dupList = mainNetwork.nodes.Where(t => t.NodeType.Contains("DUP")).ToList(); var delinwirelist = new List<Wire>(); var deloutwirelist = new List<Wire>(); foreach (Node node in dupList) { string targetNodeName = node.NodeName; var inWires = mainNetwork.wires.Where(t => t.DistName == targetNodeName).ToList(); var outWires = mainNetwork.wires.Where(t => t.SrcName == targetNodeName).ToList(); foreach (var t in outWires) { t.SrcName = inWires.First().SrcName; t.SrcPort = inWires.First().SrcPort; } mainNetwork.wireGroups.Add(new WireGroup { GroupName = node.NodeName, WList = outWires,groupType = "DUP" }); delinwirelist.AddRange(inWires); deloutwirelist.AddRange(outWires); } //Преобразование OR в WireGroup orList = mainNetwork.nodes.Where(t => t.NodeType.Contains("OR")).ToList(); foreach (Node node in orList) { string targetNodeName = node.NodeName; var inWires = mainNetwork.wires.Where(t => t.DistName == targetNodeName).ToList(); var outWires = mainNetwork.wires.Where(t => t.SrcName == targetNodeName).ToList(); foreach (var t in inWires) { t.DistName = outWires.First().DistName; t.DistPort = outWires.First().DistPort; } mainNetwork.wireGroups.Add(new WireGroup { GroupName = node.NodeName, WList = inWires,groupType = "OR" }); delinwirelist.AddRange(outWires); deloutwirelist.AddRange(inWires); } //Удаление соеденений foreach (var t in delinwirelist) mainNetwork.wires.Remove(t); foreach (var t in dupList) mainNetwork.nodes.Remove(t); foreach (var t in orList) mainNetwork.nodes.Remove(t); //loadnodes Console.WriteLine("Загрузка темплейтов"); var mcNodes = new RouteUtils.Node[mainNetwork.nodes.Count]; for (int i = 0; i < mainNetwork.nodes.Count; i++) { mcNodes[i] = new RouteUtils.Node(mainNetwork.nodes[i].NodeType + ".binhl") { NodeName = mainNetwork.nodes[i].NodeName }; mainNetwork.nodes[i].McNode = mcNodes[i]; } Console.WriteLine("OK"); //Place nodes int placeLayer; int baseSize; PlaceOptimal(mainNetwork, mcNodes, out placeLayer, out baseSize); //Удаление оставшихся соеденений foreach (var t in deloutwirelist) mainNetwork.wires.Remove(t); Console.WriteLine("Размещение ОК"); var cpoints = new List<Cpoint>(); //CreateCpointList for (int i = 0; i < mainNetwork.nodes.Count; i++) { cpoints.AddRange(mcNodes[i].InPorts.Select(t => new Cpoint { BaseX = t.PosX + mainNetwork.nodes[i].X, BaseY = t.PosY + mainNetwork.nodes[i].Y, PointName = mainNetwork.nodes[i].NodeName + "-" + t.Name, Indat = true })); cpoints.AddRange(mcNodes[i].OutPorts.Select(t => new Cpoint { BaseX = t.PosX + mainNetwork.nodes[i].X, BaseY = t.PosY + mainNetwork.nodes[i].Y, PointName = mainNetwork.nodes[i].NodeName + "-" + t.Name, Indat = false })); } SortWire(cpoints, mainNetwork, baseSize); var mcWires = new RouteUtils.Wire[mainNetwork.wires.Count]; //Draw wires in layer int totalLayers = 0; for (int j = 0; j < 24; j++) { int currentWireLayer = j * 2 + 1; if (j > 4) currentWireLayer += 5; if (j > 9) currentWireLayer += 5; if (j > 14) currentWireLayer += 5; int currentRealLayer = placeLayer - 1 - j * 2; if (j > 4) currentRealLayer -= 2; if (j > 9) currentRealLayer -= 2; if (j > 14) currentRealLayer -= 2; int wireNum = 0; var wireMask = new char[baseSize, baseSize]; //Разводка групп bool canplace = true; while (canplace) { //Разводка Группы //Поиск лучшей группы для разводки foreach (WireGroup group in mainNetwork.wireGroups) { if (!group.Placed) { group.weight = 0; group.CanPlace = true; foreach (Wire wire in group.WList) { //Поиск точек входа выхода Cpoint startPoint = FindCpoint(wire.SrcName + "-" + wire.SrcPort, cpoints); Cpoint endPoint = FindCpoint(wire.DistName + "-" + wire.DistPort, cpoints); //Маскировка неиспользуемых точек; foreach (Cpoint cpoint in cpoints) { if (cpoint.UsedLayer == 0) DrawAtMask(wireMask, cpoint.BaseX, cpoint.BaseY + currentWireLayer, 1, 2); } //Отмена маскировки на конечных точках соеденения startPoint.BaseY += currentWireLayer; endPoint.BaseY += currentWireLayer; UnmaskCpoint(wireMask, startPoint); UnmaskCpoint(wireMask, endPoint); var aStarTable = CalcAstar(baseSize, wireMask, startPoint, endPoint); //CalcAstar startPoint.BaseY -= currentWireLayer; endPoint.BaseY -= currentWireLayer; int weight = aStarTable[endPoint.BaseX, endPoint.BaseY + currentWireLayer]; if (weight == 0) group.CanPlace = false; group.weight += weight; wire.len = weight; if (DrawAstar) RenderATable(wire + ".png", aStarTable, baseSize, startPoint, endPoint); } } } var bestGroup = mainNetwork.wireGroups.Where(q => q.CanPlace && !q.Placed).OrderBy(t => t.weight).FirstOrDefault(); //Разводка if (bestGroup != null) { Console.ForegroundColor = ConsoleColor.Green; Console.WriteLine("Разводка группы {0} из {1} соеденений", bestGroup.GroupName,bestGroup.WList.Count); Console.ForegroundColor = ConsoleColor.White; bestGroup.Placed = true; bestGroup.WList = bestGroup.WList.OrderBy(t => t.len).ToList(); bestGroup.WList.Reverse(); foreach (Wire wire in bestGroup.WList) { Cpoint startPoint = FindCpoint(wire.SrcName + "-" + wire.SrcPort, cpoints); Cpoint endPoint = FindCpoint(wire.DistName + "-" + wire.DistPort, cpoints); if (bestGroup.groupType == "OR") { endPoint = FindCpoint(wire.SrcName + "-" + wire.SrcPort, cpoints); startPoint = FindCpoint(wire.DistName + "-" + wire.DistPort, cpoints); } //Маскировка неиспользуемых точек; foreach (Cpoint cpoint in cpoints) { if (cpoint.UsedLayer == 0) DrawAtMask(wireMask, cpoint.BaseX, cpoint.BaseY + currentWireLayer, 1, 2); } //Отмена маскировки на конечных точках соеденения startPoint.BaseY += currentWireLayer; endPoint.BaseY += currentWireLayer; UnmaskCpoint(wireMask, startPoint); UnmaskCpoint(wireMask, endPoint); var aStarTable = CalcAstar(baseSize, wireMask, startPoint, endPoint); MultiWareAstarUpdate(aStarTable, bestGroup); List<int> wpx; List<int> wpy; bool placed = TryPlaceWire(startPoint, endPoint, aStarTable, out wpx, out wpy); if (placed) { //WireRemask wire.WirePoints = new List<WirePoint>(); for (int i = 0; i < wpx.Count; i++) { wire.WirePoints.Add(new WirePoint { x = wpx[i], y = wpy[i], z = currentRealLayer }); } wire.WirePoints.Reverse(); startPoint.UsedLayer = currentWireLayer; endPoint.UsedLayer = currentWireLayer; wire.Placed = true; } //startPoint.BaseY -= 1; //endPoint.BaseY -= 1; startPoint.BaseY -= currentWireLayer; endPoint.BaseY -= currentWireLayer; wireNum++; //RenderATable(wire + ".png", aStarTable, baseSize, startPoint, endPoint); } foreach (Wire wire in bestGroup.WList) { foreach (var point in wire.WirePoints) { DrawAtMask(wireMask, point.x, point.y, 1, 1); } if (bestGroup.groupType == "OR") { wire.WirePoints.Reverse(); } } } else { canplace = false; } } //Разводка Соеденений for (int i = 0; i < mainNetwork.wires.Count; i++) { int mink = 999999; int bestN = 0; for (int k = 0; k < mainNetwork.wires.Count; k++) { if (!mainNetwork.wires[k].Placed) { int bw = FindBestWireToRoute(mainNetwork, baseSize, cpoints, currentWireLayer, currentRealLayer, k, mcWires, wireMask); if (mink > bw && bw != 0) { mink = bw; bestN = k; } } } if (!mainNetwork.wires[bestN].Placed) { List<int> wpx; List<int> wpy; PlaceWire(mainNetwork, baseSize, cpoints, currentWireLayer, currentRealLayer, bestN, mcWires, wireMask, out wpx, out wpy); if (mainNetwork.wires[bestN].Placed) { Console.ForegroundColor = ConsoleColor.Green; wireNum++; Console.WriteLine(mainNetwork.wires[bestN].ToString()); } else { i = mainNetwork.wires.Count; Console.ForegroundColor = ConsoleColor.White; } } else { i = mainNetwork.wires.Count; } } Console.WriteLine("Разведено в текущем слое:" + wireNum); if (wireNum > 0) { totalLayers++; } else { break; } } Console.WriteLine("Всего Слоев:" + totalLayers); var outNode = new RouteUtils.Node("OUT", baseSize, baseSize, placeLayer + 10); //OutNode.PlaceAnotherNode(new RouteUtils.Node("DUP23.binhl"), 0, 0, 0); for (int i = 0; i < mainNetwork.nodes.Count; i++) { outNode.PlaceAnotherNode(mcNodes[i], mainNetwork.nodes[i].X, mainNetwork.nodes[i].Y, mainNetwork.nodes[i].Z); } //LongCpoint foreach (Cpoint cpoint in cpoints) { if (cpoint.UsedLayer >= 10) { cpoint.UsedLayer -= 4; outNode.DataMatrix[cpoint.BaseX, cpoint.BaseY + 12, placeLayer - 11] = "W"; if (cpoint.Indat) outNode.DataMatrix[cpoint.BaseX, cpoint.BaseY + 12, placeLayer - 10] = "^"; else outNode.DataMatrix[cpoint.BaseX, cpoint.BaseY + 12, placeLayer - 10] = "v"; outNode.DataMatrix[cpoint.BaseX, cpoint.BaseY + 13, placeLayer - 11] = "W"; outNode.DataMatrix[cpoint.BaseX, cpoint.BaseY + 13, placeLayer - 10] = "#"; outNode.DataMatrix[cpoint.BaseX, cpoint.BaseY + 14, placeLayer - 11] = "W"; outNode.DataMatrix[cpoint.BaseX, cpoint.BaseY + 14, placeLayer - 10] = "#"; } if (cpoint.UsedLayer >= 22) { cpoint.UsedLayer -= 3; outNode.DataMatrix[cpoint.BaseX, cpoint.BaseY + 27, placeLayer - 23] = "W"; if (cpoint.Indat) outNode.DataMatrix[cpoint.BaseX, cpoint.BaseY + 27, placeLayer - 22] = "^"; else outNode.DataMatrix[cpoint.BaseX, cpoint.BaseY + 27, placeLayer - 22] = "v"; outNode.DataMatrix[cpoint.BaseX, cpoint.BaseY + 28, placeLayer - 23] = "W"; outNode.DataMatrix[cpoint.BaseX, cpoint.BaseY + 28, placeLayer - 22] = "#"; outNode.DataMatrix[cpoint.BaseX, cpoint.BaseY + 29, placeLayer - 23] = "W"; outNode.DataMatrix[cpoint.BaseX, cpoint.BaseY + 29, placeLayer - 22] = "#"; } if (cpoint.UsedLayer >= 34) { cpoint.UsedLayer -= 3; outNode.DataMatrix[cpoint.BaseX, cpoint.BaseY + 42, placeLayer - 35] = "W"; if (cpoint.Indat) outNode.DataMatrix[cpoint.BaseX, cpoint.BaseY + 42, placeLayer - 34] = "^"; else outNode.DataMatrix[cpoint.BaseX, cpoint.BaseY + 42, placeLayer - 34] = "v"; outNode.DataMatrix[cpoint.BaseX, cpoint.BaseY + 43, placeLayer - 35] = "W"; outNode.DataMatrix[cpoint.BaseX, cpoint.BaseY + 43, placeLayer - 34] = "#"; outNode.DataMatrix[cpoint.BaseX, cpoint.BaseY + 44, placeLayer - 35] = "W"; outNode.DataMatrix[cpoint.BaseX, cpoint.BaseY + 44, placeLayer - 34] = "#"; } for (int j = 0; j < cpoint.UsedLayer; j++) { if (j <= 10) { outNode.DataMatrix[cpoint.BaseX, cpoint.BaseY + j + 1, placeLayer - j - 1] = "w"; outNode.DataMatrix[cpoint.BaseX, cpoint.BaseY + j + 1, placeLayer - j - 0] = "#"; } if (j > 10 && j <= 22) { outNode.DataMatrix[cpoint.BaseX, cpoint.BaseY + j + 4, placeLayer - j - 1] = "w"; outNode.DataMatrix[cpoint.BaseX, cpoint.BaseY + j + 4, placeLayer - j - 0] = "#"; } if (j > 22 && j <= 34) { outNode.DataMatrix[cpoint.BaseX, cpoint.BaseY + j + 7, placeLayer - j - 1] = "w"; outNode.DataMatrix[cpoint.BaseX, cpoint.BaseY + j + 7, placeLayer - j - 0] = "#"; } if (j > 34) { outNode.DataMatrix[cpoint.BaseX, cpoint.BaseY + j + 10, placeLayer - j - 1] = "w"; outNode.DataMatrix[cpoint.BaseX, cpoint.BaseY + j + 10, placeLayer - j - 0] = "#"; } } } //PlaceReapiters for (int i = 0; i < mainNetwork.wires.Count; i++) { mcWires[i].PlaceRepeaters(); } //Установка репитеров для групп foreach (var group in mainNetwork.wireGroups) { group.PlaceRepitors(); } //Установка групп соеденений //SyncWires var wiresToSync = new List<RouteUtils.Wire>(); for (int i = 0; i < mainNetwork.wires.Count; i++) { if (mainNetwork.wires[i].DistPort == "clk") { wiresToSync.Add(mcWires[i]); } } int syncLen = wiresToSync.Select(t => t.CalcRepCount()).Concat(new[] {0}).Max(); foreach (RouteUtils.Wire wire in wiresToSync) { wire.RepCompincate(syncLen - wire.CalcRepCount()); wire.Synced = true; } foreach (var group in mainNetwork.wireGroups) { foreach (var wire in group.WList) { foreach (var point in wire.WirePoints) { outNode.DataMatrix[point.x, point.y, point.z] = "S"; if (wire.repError) outNode.DataMatrix[point.x, point.y, point.z] = "W"; outNode.DataMatrix[point.x, point.y, point.z + 1] = "#"; if (point.Repiter) outNode.DataMatrix[point.x, point.y, point.z + 1] = point.RepVapl; } } } //отрисовка ошибочного соеденения foreach (var group in mainNetwork.wireGroups) { foreach (var wire in group.WList) { if (wire.repError) { Console.ForegroundColor = ConsoleColor.Red; Console.WriteLine(wire); Console.ForegroundColor = ConsoleColor.White; foreach (var point in wire.WirePoints) { outNode.DataMatrix[point.x, point.y, point.z] = "S"; if (wire.repError) outNode.DataMatrix[point.x, point.y, point.z] = "W"; outNode.DataMatrix[point.x, point.y, point.z + 1] = "#"; if (point.Repiter) outNode.DataMatrix[point.x, point.y, point.z + 1] = point.RepVapl; } } } } //PlaceWires for (int i = 0; i < mainNetwork.wires.Count; i++) { if (mainNetwork.wires[i].Placed) { for (int j = 0; j < mcWires[i].WirePointX.Length; j++) { if (mcWires[i].Synced) { outNode.DataMatrix[mcWires[i].WirePointX[j], mcWires[i].WirePointY[j], mcWires[i].WirePointZ[j]] = "S"; } else { outNode.DataMatrix[mcWires[i].WirePointX[j], mcWires[i].WirePointY[j], mcWires[i].WirePointZ[j]] = "w"; } if (mcWires[i].Rep[j]) { outNode.DataMatrix[mcWires[i].WirePointX[j], mcWires[i].WirePointY[j], mcWires[i].WirePointZ[j] + 1] = mcWires[i].RepNp[j]; } else { outNode.DataMatrix[mcWires[i].WirePointX[j], mcWires[i].WirePointY[j], mcWires[i].WirePointZ[j] + 1] = "#"; } } } } //Обрезка Console.WriteLine("Обрезка рабочей Облости"); var outNodeO = CutOutputNode(placeLayer, baseSize, outNode); //Маркировка портов ввода вывода outNodeO.InPorts = mainNetwork.nodes.Where(t => t.NodeType == "INPort").Select(t => new InPort(t.NodeName, t.X + 1, t.Y)).ToArray(); outNodeO.OutPorts = mainNetwork.nodes.Where(t => t.NodeType == "OUTPort").Select(t => new OutPort(t.NodeName, t.X + 1, t.Y)).ToArray(); Console.WriteLine("Экспорт"); outNodeO.Export(file + ".binhl"); }
private void XAdd(Wire wire) { wire.BXAdd = true; if (wire.Vector.X < GameConfig.WidthX - 1) { var v = wire.Vector + new IntVector(1, 0); var w = WireDictionary[v]; if (Clears.Contains(w) && w.WireData[1] != 0) { XRight.Add(wire); if (w.WireData[3] != 0) { if (!w.BXAdd) { XAdd(w); } } } } if (XRight.Count >= 1) { ThunderSprite sp; if (Thunders.Count - 1 > _thunderindex) { sp = Thunders[_thunderindex]; } else { sp = new ThunderSprite(); AddChild(sp, 9); Thunders.Add(sp); } _thunderindex++; sp.Points.Clear(); sp.AddPoint(new Vector2(wire.Vector.X * 94 + 94 / 2 + GameConfig.RelativeOrigin.X, 768 - (wire.Vector.Y * 94 + 47 + GameConfig.RelativeOrigin.Y))); sp.EndPoint(new Vector2(wire.Vector.X * 94 + 94 / 2 + GameConfig.RelativeOrigin.X + XRight.Count * 94 / 2, 768 - (wire.Vector.Y * 94 + 47 + GameConfig.RelativeOrigin.Y))); sp.Visible = true; } }
public void test_new_wire_is_low() { var wire = new Wire(); AssertIsLow(wire, "a new wire should be low"); }
private void AssertIsLow(Wire wire,string msg) { Assert.IsFalse(@wire.IsHigh, "Wire is high. " + msg); }
private void AssertIsHigh(Wire wire, string msg) { Assert.IsTrue(@wire.IsHigh, "Wire is low. " + msg); }
// Called from LoadLevel, patched via MonoModRules.PatchLevelLoader public static bool LoadCustomEntity(EntityData entityData, Level level) { LevelData levelData = level.Session.LevelData; Vector2 offset = new Vector2(levelData.Bounds.Left, levelData.Bounds.Top); if (Everest.Events.Level.LoadEntity(level, levelData, offset, entityData)) { return(true); } // Everest comes with a few core utility entities out of the box. if (entityData.Name == "everest/spaceController") { level.Add(new SpaceController()); return(true); } if (entityData.Name == "everest/spaceControllerBlocker") { level.Add(new SpaceControllerBlocker()); return(true); } if (entityData.Name == "everest/flagTrigger") { level.Add(new FlagTrigger(entityData, offset)); return(true); } if (entityData.Name == "everest/changeInventoryTrigger") { level.Add(new ChangeInventoryTrigger(entityData, offset)); return(true); } if (entityData.Name == "everest/coreMessage") { level.Add(new CustomCoreMessage(entityData, offset)); return(true); } if (entityData.Name == "everest/memorial") { level.Add(new CustomMemorial(entityData, offset)); return(true); } if (entityData.Name == "everest/npc") { level.Add(new CustomNPC(entityData, offset, new EntityID(levelData.Name, entityData.ID))); return(true); } if (entityData.Name == "everest/dialogTrigger" || entityData.Name == "dialog/dialogtrigger" || entityData.Name == "cavern/dialogtrigger") { level.Add(new DialogCutsceneTrigger(entityData, offset, new EntityID(levelData.Name, entityData.ID))); return(true); } if (entityData.Name == "everest/crystalShatterTrigger" || entityData.Name == "outback/destroycrystalstrigger") { level.Add(new CrystalShatterTrigger(entityData, offset)); return(true); } if (entityData.Name == "everest/completeAreaTrigger" || entityData.Name == "outback/completeareatrigger") { level.Add(new CompleteAreaTrigger(entityData, offset)); return(true); } if (entityData.Name == "everest/lavaBlockerTrigger" || entityData.Name == "cavern/lavablockertrigger") { level.Add(new LavaBlockerTrigger(entityData, offset)); return(true); } if (entityData.Name == "everest/coreModeTrigger" || entityData.Name == "cavern/coremodetrigger") { level.Add(new CoreModeTrigger(entityData, offset)); return(true); } // The following entities have hardcoded "attributes." // Everest allows custom maps to set them. if (entityData.Name == "spinner") { if (level.Session.Area.ID == 3 || (level.Session.Area.ID == 7 && level.Session.Level.StartsWith("d-")) || entityData.Bool("dust")) { level.Add(new DustStaticSpinner(entityData, offset)); return(true); } CrystalColor color = CrystalColor.Blue; if (level.Session.Area.ID == 5) { color = CrystalColor.Red; } else if (level.Session.Area.ID == 6) { color = CrystalColor.Purple; } else if ("core".Equals(entityData.Attr("color"), StringComparison.InvariantCultureIgnoreCase)) { color = (CrystalColor)(-1); } else if (!Enum.TryParse(entityData.Attr("color"), true, out color)) { color = CrystalColor.Blue; } level.Add(new CrystalStaticSpinner(entityData, offset, color)); return(true); } if (entityData.Name == "trackSpinner") { if (level.Session.Area.ID == 3 || (level.Session.Area.ID == 7 && level.Session.Level.StartsWith("d-")) || entityData.Bool("dust")) { level.Add(new DustTrackSpinner(entityData, offset)); return(true); } level.Add(new BladeTrackSpinner(entityData, offset)); return(true); } if (entityData.Name == "rotateSpinner") { if (level.Session.Area.ID == 3 || (level.Session.Area.ID == 7 && level.Session.Level.StartsWith("d-")) || entityData.Bool("dust")) { level.Add(new DustRotateSpinner(entityData, offset)); return(true); } level.Add(new BladeRotateSpinner(entityData, offset)); return(true); } if (entityData.Name == "checkpoint" && entityData.Position == Vector2.Zero && !entityData.Bool("allowOrigin")) { // Workaround for mod levels with old versions of Ahorn containing a checkpoint at (0, 0): // Create the checkpoint and avoid the start position update in orig_Load. level.Add(new Checkpoint(entityData, offset)); return(true); } if (entityData.Name == "triggerSpikesOriginalUp") { level.Add(new TriggerSpikesOriginal(entityData, offset, TriggerSpikesOriginal.Directions.Up)); return(true); } if (entityData.Name == "triggerSpikesOriginalDown") { level.Add(new TriggerSpikesOriginal(entityData, offset, TriggerSpikesOriginal.Directions.Down)); return(true); } if (entityData.Name == "triggerSpikesOriginalLeft") { level.Add(new TriggerSpikesOriginal(entityData, offset, TriggerSpikesOriginal.Directions.Left)); return(true); } if (entityData.Name == "triggerSpikesOriginalRight") { level.Add(new TriggerSpikesOriginal(entityData, offset, TriggerSpikesOriginal.Directions.Right)); return(true); } if (entityData.Name == "darkChaserEnd") { level.Add(new BadelineOldsiteEnd(entityData, offset)); return(true); } if (entityData.Name == "cloud") { patch_Cloud cloud = new Cloud(entityData, offset) as patch_Cloud; if (entityData.Has("small")) { cloud.Small = entityData.Bool("small"); } level.Add(cloud); return(true); } if (entityData.Name == "cobweb") { patch_Cobweb cobweb = new Cobweb(entityData, offset) as patch_Cobweb; if (entityData.Has("color")) { cobweb.OverrideColor = entityData.HexColor("color"); } level.Add(cobweb); return(true); } if (entityData.Name == "movingPlatform") { patch_MovingPlatform platform = new MovingPlatform(entityData, offset) as patch_MovingPlatform; if (entityData.Has("texture")) { platform.OverrideTexture = entityData.Attr("texture"); } level.Add(platform); return(true); } if (entityData.Name == "sinkingPlatform") { patch_SinkingPlatform platform = new SinkingPlatform(entityData, offset) as patch_SinkingPlatform; if (entityData.Has("texture")) { platform.OverrideTexture = entityData.Attr("texture"); } level.Add(platform); return(true); } if (entityData.Name == "crumbleBlock") { patch_CrumblePlatform platform = new CrumblePlatform(entityData, offset) as patch_CrumblePlatform; if (entityData.Has("texture")) { platform.OverrideTexture = entityData.Attr("texture"); } level.Add(platform); return(true); } if (entityData.Name == "wire") { Wire wire = new Wire(entityData, offset); if (entityData.Has("color")) { wire.Color = entityData.HexColor("color"); } level.Add(wire); return(true); } return(false); }
public override StatusLightData?GetStatusLightData(Wire wire) => null;
public void OnPlugIn(Wire wire, Jackable jack) { Jackable a_jack = wire.plug_a.GetComponent <WireGrabObject>().currently_plugged_in_to; Jackable b_jack = wire.plug_b.GetComponent <WireGrabObject>().currently_plugged_in_to; if (a_jack == null || b_jack == null) { var thisCall = activeCalls.Find(a => (a_jack == null) ? a.Caller == b_jack.id : a.Caller == a_jack.id); if (thisCall != null) { if (jack.id == thisCall.Caller) { jack.set_light_state(1); } } } else { Jackable otherEndOfWire = jack.id == a_jack.id ? b_jack : a_jack; var thisCall = activeCalls.Find(a => a.Caller == a_jack.id || a.Caller == b_jack.id); if (thisCall != null) { if (jack.id == thisCall.Caller) { jack.set_light_state(1); otherEndOfWire.set_light_state(1); } else { if (otherEndOfWire.id == thisCall.Caller) { jack.set_light_state(1); } } } if (thisCall != null) { if (jack.id == -1 || otherEndOfWire.id == -1) { OnBellConnection(thisCall); if (thisCall.call.state == IncomingCalls.CallState.unanswered) { thisCall.call.state = IncomingCalls.CallState.answered; } } else if (jack.id == thisCall.Callee || otherEndOfWire.id == thisCall.Callee) { OnSuccessfulConnection(thisCall); thisCall.call.state = IncomingCalls.CallState.connected; } else { jack.set_light_state(0); otherEndOfWire.set_light_state(0); OnBadConnection(thisCall); } } } }
protected override void VisitWire(Wire wire) { }
private void RefreshData() { var wires = Wire.FindAll(); gcWireInfo.DataSource = wires; }
public static void GrayWiresOut(Wire wire) { wire.Opacity = .5; }
// Instantiates all components that make up the given clip, and connects them up with wires // The components are parented under a single "holder" object, which is returned from the function static ChipSaveData LoadChip(SavedChip chipToLoad, Dictionary <string, Chip> previouslyLoadedChips, Wire wirePrefab) { ChipSaveData loadedChipData = new ChipSaveData(); int numComponents = chipToLoad.savedComponentChips.Length; loadedChipData.componentChips = new Chip[numComponents]; loadedChipData.chipName = chipToLoad.name; loadedChipData.chipColour = chipToLoad.colour; loadedChipData.chipNameColour = chipToLoad.nameColour; loadedChipData.creationIndex = chipToLoad.creationIndex; // Spawn component chips (the chips used to create this chip) // These will have been loaded already, and stored in the previouslyLoadedChips dictionary for (int i = 0; i < numComponents; i++) { SavedComponentChip componentToLoad = chipToLoad.savedComponentChips[i]; string componentName = componentToLoad.chipName; Vector2 pos = new Vector2((float)componentToLoad.posX, (float)componentToLoad.posY); if (!previouslyLoadedChips.ContainsKey(componentName)) { Debug.LogError("Failed to load sub component: " + componentName + " While loading " + chipToLoad.name); } Chip loadedComponentChip = GameObject.Instantiate(previouslyLoadedChips[componentName], pos, Quaternion.identity); loadedChipData.componentChips[i] = loadedComponentChip; // Load input pin names for (int inputIndex = 0; inputIndex < componentToLoad.inputPins.Length; inputIndex++) { loadedChipData.componentChips[i].inputPins[inputIndex].pinName = componentToLoad.inputPins[inputIndex].name; } // Load output pin names for (int ouputIndex = 0; ouputIndex < componentToLoad.outputPinNames.Length; ouputIndex++) { loadedChipData.componentChips[i].outputPins[ouputIndex].pinName = componentToLoad.outputPinNames[ouputIndex]; } } // Connect pins with wires for (int chipIndex = 0; chipIndex < chipToLoad.savedComponentChips.Length; chipIndex++) { Chip loadedComponentChip = loadedChipData.componentChips[chipIndex]; for (int inputPinIndex = 0; inputPinIndex < loadedComponentChip.inputPins.Length; inputPinIndex++) { SavedInputPin savedPin = chipToLoad.savedComponentChips[chipIndex].inputPins[inputPinIndex]; Pin pin = loadedComponentChip.inputPins[inputPinIndex]; // If this pin should receive input from somewhere, then wire it up to that pin if (savedPin.parentChipIndex != -1) { Pin connectedPin = loadedChipData.componentChips[savedPin.parentChipIndex].outputPins[savedPin.parentChipOutputIndex]; pin.cyclic = savedPin.isCylic; Pin.TryConnect(connectedPin, pin); //if (Pin.TryConnect (connectedPin, pin)) { //Wire loadedWire = GameObject.Instantiate (wirePrefab, parent : chipHolder); //loadedWire.Connect (connectedPin, loadedComponentChip.inputPins[inputPinIndex]); //} } } } return(loadedChipData); }
private void Stream( ArrayList data, Wire wire ) { data.Add( new Snoop.Data.ClassSeparator( typeof( Wire ) ) ); data.Add( new Snoop.Data.Object( "Flex pipe type", wire.ConnectorManager ) ); data.Add( new Snoop.Data.Int( "Ground conductor num", wire.GroundConductorNum ) ); data.Add( new Snoop.Data.Int( "Hot conductor num", wire.HotConductorNum ) ); data.Add( new Snoop.Data.Int( "Neutral conductor num", wire.NeutralConductorNum ) ); data.Add( new Snoop.Data.String( "Wiring type", wire.WiringType.ToString() ) ); }
public void SendConnect(int to, int from, int srcX, int srcY, int destX, int destY, Wire wire) { var packet = GetPacket(Connect, from); packet.Write(srcX); packet.Write(srcY); packet.Write(destX); packet.Write(destY); packet.Write(wire.Points.Count); foreach (var point in wire.Points) { packet.Write((int)point.X); packet.Write((int)point.Y); } packet.Send(to, from); }
private bool FindFour(Wire wire) { if (XAdd(wire)) { return true; } if (YAdd(wire)) { return true; } if (XYAdd(wire)) { return true; } if (XY(wire)) { return true; } return false; }
public void LoadWire(Wire wire) { wire.transform.parent = wireHolder; allWires.Add(wire); wiresByChipInputPin.Add(wire.ChipInputPin, wire); }
public Key(uint field, Wire wireType) { this.Field = field; this.WireType = wireType; }
public override void Disconnect(Wire wire) { OutputConnections.Remove(wire); }
public override void OnWireReceived(UnsafeReader stream) { var header = stream.ReadInt(); var msgVersioned = (header >> versionedFlagShift) != 0; var opType = header & ((1 << versionedFlagShift) - 1); var version = msgVersioned ? stream.ReadLong() : 0L; var key = ReadKeyDelegate(SerializationContext, stream); if (opType == Ack) { string error = null; if (!msgVersioned) { error = "Received ACK while msg hasn't versioned flag set"; } else if (!IsMaster) { error = "Received ACK when not a Master"; } else if (!myPendingForAck.TryGetValue(key, out var pendingVersion)) { error = "No pending for ACK"; } else if (pendingVersion < version) { error = $"Pending version `{pendingVersion}` < ACK version `{version}`"; } // Good scenario else if (pendingVersion == version) { myPendingForAck.Remove(key); } //else do nothing, silently drop var isError = !string.IsNullOrEmpty(error); if (ourLogReceived.IsTraceEnabled() || isError) { ourLogReceived.LogFormat(isError ? LoggingLevel.ERROR : LoggingLevel.TRACE, "{0} :: ACK :: key = {1} :: version = {2}{3}", this, key.PrintToString(), version, isError ? " >> " + error : ""); } } else { using (UsingDebugInfo()) { var kind = (AddUpdateRemove)opType; switch (kind) { case AddUpdateRemove.Add: case AddUpdateRemove.Update: var value = ReadValueDelegate(SerializationContext, stream); ReceiveTrace?.Log($"{this} :: {kind} :: key = {key.PrintToString()}" + (msgVersioned ? " :: version = " + version : "") + $" :: value = {value.PrintToString()}" ); if (msgVersioned || !IsMaster || !myPendingForAck.ContainsKey(key)) { myMap[key] = value; } else { ReceiveTrace?.Log(">> CHANGE IGNORED"); } break; case AddUpdateRemove.Remove: ReceiveTrace?.Log($"{this} :: {kind} :: key = {key.PrintToString()}" + (msgVersioned ? " :: version = " + version : "") ); if (msgVersioned || !IsMaster || !myPendingForAck.ContainsKey(key)) { myMap.Remove(key); } else { ReceiveTrace?.Log(">> CHANGE IGNORED"); } break; default: throw new ArgumentOutOfRangeException(kind.ToString()); } } if (msgVersioned) { Wire.Send(RdId, (innerWriter) => { innerWriter.Write((1 << versionedFlagShift) | Ack); innerWriter.Write(version); WriteKeyDelegate.Invoke(SerializationContext, innerWriter, key); SendTrace?.Log($"{this} :: ACK :: key = {key.PrintToString()} :: version = {version}"); }); if (IsMaster) { ourLogReceived.Error("Both ends are masters: {0}", Location); } } } }
public override bool ContainsConnection(Wire wire) { return(OutputConnections.Contains(wire)); }
public ProtoBuiltin(string name, Wire wire, string csType) { ProtoName = name; wireType = wire; base.CsType = csType; }
public void AddConnectedWire(Wire wire) { connectedWires.Add(wire); }
/// <summary> /// Provides public access specifically for getting the connectors associated to a wire. /// </summary> /// <param name="wireElement">The Wire element.</param> /// <returns>A set of connectors.</returns> /// <remarks>Wires in Revit are annotation elements that aren't currently exported. As such, we want to get their /// connection information to connect the elements at each of the wire together via a bi-directional port.</remarks> public static ConnectorSet GetConnectorsForWire(Wire wireElement) { return(GetConnectors(wireElement)); }
public void RemoveConnectedWire(Wire wire) { connectedWires.Remove(wire); }
void Awake() { wire = wireHolder.Wire; TryGetComponent <Slider>(out slider); wireHolder.SetNewWire += (newWire) => wire = newWire; }
public bool HasWire(Wire wire) { return(connectedWires.Contains(wire) ? true : false); }
bool IDfirNodeVisitor <bool> .VisitWire(Wire wire) { VisitWire(wire); return(true); }
public void StartRound(LevelData levelData, bool mirrorLevel = false, SubmarineInfo startOutpost = null, SubmarineInfo endOutpost = null) { MirrorLevel = mirrorLevel; if (SubmarineInfo == null) { DebugConsole.ThrowError("Couldn't start game session, submarine not selected."); return; } if (SubmarineInfo.IsFileCorrupted) { DebugConsole.ThrowError("Couldn't start game session, submarine file corrupted."); return; } if (SubmarineInfo.SubmarineElement.Elements().Count() == 0) { DebugConsole.ThrowError("Couldn't start game session, saved submarine is empty. The submarine file may be corrupted."); return; } LevelData = levelData; Submarine.Unload(); Submarine = Submarine.MainSub = new Submarine(SubmarineInfo); foreach (Submarine sub in Submarine.GetConnectedSubs()) { sub.TeamID = CharacterTeamType.Team1; foreach (Item item in Item.ItemList) { if (item.Submarine != sub) { continue; } foreach (WifiComponent wifiComponent in item.GetComponents <WifiComponent>()) { wifiComponent.TeamID = sub.TeamID; } } } foreach (Mission mission in GameMode.Missions) { // setting level for missions that may involve difficulty-related submarine creation mission.SetLevel(levelData); } if (Submarine.MainSubs[1] == null) { var enemySubmarineInfo = GameMode is PvPMode ? SubmarineInfo : GameMode.Missions.FirstOrDefault(m => m.EnemySubmarineInfo != null)?.EnemySubmarineInfo; if (enemySubmarineInfo != null) { Submarine.MainSubs[1] = new Submarine(enemySubmarineInfo, true); } } if (GameMain.NetworkMember?.ServerSettings?.LockAllDefaultWires ?? false) { foreach (Item item in Item.ItemList) { if (item.Submarine == Submarine.MainSubs[0] || (Submarine.MainSubs[1] != null && item.Submarine == Submarine.MainSubs[1])) { Wire wire = item.GetComponent <Wire>(); if (wire != null && !wire.NoAutoLock && wire.Connections.Any(c => c != null)) { wire.Locked = true; } } } } Level level = null; if (levelData != null) { level = Level.Generate(levelData, mirrorLevel, startOutpost, endOutpost); } InitializeLevel(level); #if CLIENT if (GameMode is CampaignMode) { SteamAchievementManager.OnBiomeDiscovered(levelData.Biome); } var existingRoundSummary = GUIMessageBox.MessageBoxes.Find(mb => mb.UserData is RoundSummary)?.UserData as RoundSummary; if (existingRoundSummary?.ContinueButton != null) { existingRoundSummary.ContinueButton.Visible = true; } RoundSummary = new RoundSummary(Submarine.Info, GameMode, Missions, StartLocation, EndLocation); if (!(GameMode is TutorialMode) && !(GameMode is TestGameMode)) { GUI.AddMessage("", Color.Transparent, 3.0f, playSound: false); if (EndLocation != null) { GUI.AddMessage(levelData.Biome.DisplayName, Color.Lerp(Color.CadetBlue, Color.DarkRed, levelData.Difficulty / 100.0f), 5.0f, playSound: false); GUI.AddMessage(TextManager.AddPunctuation(':', TextManager.Get("Destination"), EndLocation.Name), Color.CadetBlue, playSound: false); if (missions.Count > 1) { string joinedMissionNames = string.Join(", ", missions.Select(m => m.Name)); GUI.AddMessage(TextManager.AddPunctuation(':', TextManager.Get("Mission"), joinedMissionNames), Color.CadetBlue, playSound: false); } else { var mission = missions.FirstOrDefault(); GUI.AddMessage(TextManager.AddPunctuation(':', TextManager.Get("Mission"), mission?.Name ?? TextManager.Get("None")), Color.CadetBlue, playSound: false); } } else { GUI.AddMessage(TextManager.AddPunctuation(':', TextManager.Get("Location"), StartLocation.Name), Color.CadetBlue, playSound: false); } } GUI.PreventPauseMenuToggle = false; HintManager.OnRoundStarted(); #endif }
public override void GestureEnd(CircuitEditor editor, Vector2d endOffset) { // FIXME: Do l-shaped wire addition var diff = editor.RoundDistToGrid(endOffset); if (Math.Abs(diff.X) > Math.Abs(diff.Y)) { // FIXME: We shouldn't rely on the constructor to flip negative diffs // because we are going to remove that so we should do it ourselves here. // Here we are drawing a horizontal line CurrentWire = new Wire(DragStartPos, diff.X, Circuit.Direction.Horizontal); } else { //This should be a vertical line CurrentWire = new Wire(DragStartPos, diff.Y, Circuit.Direction.Vertical); } DraggingWire = false; if (CurrentWire.Length != 0) { // Here we should figure out if we are modifying an existing wire. // Because adding wires handles merging wires that go in the same // direction, we only want to detect the case where we are shrinking // a wire. This is easy, because we only need to check that we grabbed // one end of the wire and the the other end is inside the wire we want // to shrink. Wire?modifying = null; bool movingEnd = false; foreach (var bWire in editor.Scene.Wires.WiresList) { if (CurrentWire.Direction != bWire.Direction) { continue; } // We do 'IsPointInsideWire' because we don't want to detect the case // where we are dragging a wire left from a junction to create a new wire. // What would happen if we used 'IsPointOnWire' is that the start pos would // be equal and at the same time 'CurrentWire.Pos' would be on the wire, // making us think that we want to edit the wire while we don't want to. if (DragStartPos == bWire.Pos && bWire.IsPointInsideWire(CurrentWire.EndPos)) { modifying = bWire; movingEnd = false; } else if (DragStartPos == bWire.EndPos && bWire.IsPointInsideWire(CurrentWire.Pos)) { modifying = bWire; movingEnd = true; } else if (CurrentWire == bWire) { // If they are the same wire we want to remove the bWire modifying = bWire; } } // If there there more than one endpoint at the start position // We don't want to modify a wire, we want to create a new one // If there was only one point we check that we actually want to // modify that wire (ie modifying is not null). if (modifying is Wire modify) { // Here we are modifying an existing wire. // So we should figure out how the wire should be modified. // If the wire is deleted we need to check for places where we should merge // other connecting wires. The creation of the remove transaction should // probably be created in a Wires.CreateRemoveWireTransaction(...). Wire modifiedWire = modify; if (movingEnd == false) { // Here we are moving the start poistion of the wire. diff = CurrentWire.EndPos - modify.Pos; modifiedWire.Pos = CurrentWire.EndPos; modifiedWire.Length -= diff.ManhattanDistance; } else { // Here we only need to change the length of the wire. diff = modify.EndPos - CurrentWire.Pos; modifiedWire.Length -= diff.ManhattanDistance; } if (modifiedWire.Length > 0) { // FIMXE: Figure out if there are any edge-cases when modifying wires like this. // One of the cases is where the modified wire should split another already // existing wire. WireTransaction?modifyTransaction = editor.Scene.Wires.CreateModifyWireTransaction(modify, modifiedWire); if (modifyTransaction != null) { editor.Scene.PushTransaction(modifyTransaction); //Console.WriteLine($"Modified existing wire! ({modify}) -> ({modifiedWire})\n{modifyTransaction}\n"); } } else { // Here we should remove the wire completely var deleteTransaction = editor.Scene.Wires.CreateRemoveWireTransaction(modify); editor.Scene.PushTransaction(deleteTransaction); //Console.WriteLine($"Deleted wire! ({modify})\n{deleteTransaction}\n"); } } else { var transaction = editor.Scene.Wires.CreateAddWireTransaction(CurrentWire); if (transaction != null) { editor.Scene.PushTransaction(transaction); //Console.WriteLine($"End wire!\n{transaction}\n"); } else { //Console.WriteLine($"No wire created!\n"); } } } else { //Console.WriteLine($"Zero length wire!\n\n"); } editor.DrawingArea.QueueDraw(); }
protected abstract void VisitWire(Wire wire);
public Wire Create(int wireType) { if (wireType == 795) { var name = "Tension Wire Test Drake 795 ACSR"; var totalCrossSection = 0.00046844; var initialWireDiameter = 0.0281432; var finalWireDiameter = 0.0281432; var initialWireLinearWeight = 15.9657; var finalWireLinearWeight = 15.9657; var maxRatedStrength = 68000; var outerElasticity = 44126400000; var outerThermalCoefficient = 0.00002304; var coreElasticity = 25510600000; var coreThermalCoefficient = 0.00001152; var outerStressStrainList = new List <double> { -8363341, 305493595.6, -96556939.03, -2.59367e8, 2.11504e8 }; var outerCreepList = new List <double> { -3756263.8, 147732585.6, -129912395.9, 3.7887e7, 0 }; var coreStressStrainList = new List <double> { -477806.7, 2.66338e8, 27565929.1, -3.1518e8, 1.92309e8 }; var coreCreepList = new List <double> { 324743.1, 249668124.8, 84125691.63, -4.99125e8, 3.19489e8 }; var startingTension = 22500.0; var startingTemp = 15; var startingSpanLength = 50; var startingElevation = 0.0; var startingTensionType = true; var material = WireMaterial.ACSR; var wire = Wire.Create(name, totalCrossSection, initialWireDiameter, finalWireDiameter, initialWireLinearWeight, finalWireLinearWeight, maxRatedStrength, outerElasticity, outerThermalCoefficient, coreElasticity, coreThermalCoefficient, outerStressStrainList, outerCreepList, coreStressStrainList, coreCreepList, startingTension, startingTemp, startingSpanLength, startingElevation, startingTensionType, material); return(wire); } if (wireType == 556) { var name = "Tension Wire Test 556 AAC"; var totalCrossSection = 0.0002818704; var initialWireDiameter = 0.0217424; var finalWireDiameter = 0.0217424; var initialWireLinearWeight = 7.60926; var finalWireLinearWeight = 7.60926; var maxRatedStrength = 43370; var outerElasticity = 61605437000; var outerThermalCoefficient = 0.00002304; var coreElasticity = 0; var coreThermalCoefficient = 0; var outerStressStrainList = new List <double> { 0, 483543118, -3.58196e+8, -2.29416e+8, 2.30271e+8 }; var outerCreepList = new List <double> { 0, 202416285, -14775465, -144390007, 1.63682e+8 }; var coreStressStrainList = new List <double> { 0, 0, 0, 0, 0 }; var coreCreepList = new List <double> { 0, 0, 0, 0, 0 }; var startingTension = 3000.0; var startingTemp = 10.0; var startingSpanLength = 50; var startingElevation = 0.0; var startingTensionType = true; var material = WireMaterial.ACSR; var wire = Wire.Create(name, totalCrossSection, initialWireDiameter, finalWireDiameter, initialWireLinearWeight, finalWireLinearWeight, maxRatedStrength, outerElasticity, outerThermalCoefficient, coreElasticity, coreThermalCoefficient, outerStressStrainList, outerCreepList, coreStressStrainList, coreCreepList, startingTension, startingTemp, startingSpanLength, startingElevation, startingTensionType, material); return(wire); } if (wireType == 557) { var name = "CIMA 556.5 ASC"; var totalCrossSection = 0.0002818704; var initialWireDiameter = 0.0217424; var finalWireDiameter = 0.0217424; var initialWireLinearWeight = 7.60342; var finalWireLinearWeight = 7.60342; var maxRatedStrength = 43370; var outerElasticity = 59294913000; var outerThermalCoefficient = 0.00002304; var coreElasticity = 0; var coreThermalCoefficient = 0; var outerStressStrainList = new List <double> { 0, 483543118, -3.58196e+8, -2.29416e+8, 2.30271e+8 }; var outerCreepList = new List <double> { 0, 202416285, -14775465, -144390007, 1.63682e+8 }; var coreStressStrainList = new List <double> { 0, 0, 0, 0, 0 }; var coreCreepList = new List <double> { 0, 0, 0, 0, 0 }; var startingTension = 4492; var startingTemp = 0.0; var startingSpanLength = 45; var startingElevation = 77.942; var startingTensionType = false; var material = WireMaterial.ACSR; var wire = Wire.Create(name, totalCrossSection, initialWireDiameter, finalWireDiameter, initialWireLinearWeight, finalWireLinearWeight, maxRatedStrength, outerElasticity, outerThermalCoefficient, coreElasticity, coreThermalCoefficient, outerStressStrainList, outerCreepList, coreStressStrainList, coreCreepList, startingTension, startingTemp, startingSpanLength, startingElevation, startingTensionType, material); return(wire); } if (wireType == 1) { var name = "fake data for testing"; var totalCrossSection = 0.0002818704; var initialWireDiameter = 0.0217424; var finalWireDiameter = 0.02455; var initialWireLinearWeight = 4.63; var finalWireLinearWeight = 4.63; var maxRatedStrength = 43370; var outerElasticity = 61605437000; var outerThermalCoefficient = 0.00002304; var coreElasticity = 0; var coreThermalCoefficient = 0; var outerStressStrainList = new List <double> { 0, 483543118, -3.58196e+8, -2.29416e+8, 2.30271e+8 }; var outerCreepList = new List <double> { 0, 202416285, -14775465, -144390007, 1.63682e+8 }; var coreStressStrainList = new List <double> { 0, 0, 0, 0, 0 }; var coreCreepList = new List <double> { 0, 0, 0, 0, 0 }; var startingTension = 3000.0; var startingTemp = 10.0; var startingSpanLength = 50; var startingElevation = 0.0; var startingTensionType = true; var material = WireMaterial.ACSR; var wire = Wire.Create(name, totalCrossSection, initialWireDiameter, finalWireDiameter, initialWireLinearWeight, finalWireLinearWeight, maxRatedStrength, outerElasticity, outerThermalCoefficient, coreElasticity, coreThermalCoefficient, outerStressStrainList, outerCreepList, coreStressStrainList, coreCreepList, startingTension, startingTemp, startingSpanLength, startingElevation, startingTensionType, material); return(wire); } if (wireType == 4) { var name = "Duplex ACSR"; var totalCrossSection = 0.000024645; var initialWireDiameter = 0.0136; var finalWireDiameter = 0.0136; var initialWireLinearWeight = 1.667; var finalWireLinearWeight = 1.667; var maxRatedStrength = 8140; var outerElasticity = 5.15728e+8; var outerThermalCoefficient = 0.00002304; var coreElasticity = 2.82685e+8; var coreThermalCoefficient = 0.00001152; var outerStressStrainList = new List <double> { -4977325.3, 550906965.7, -923741655.75, 766269536, -2.40269e+8 }; var outerCreepList = new List <double> { 4249238.9, 1.6826e+8, -292057782.1, 3.56321e+8, -1.8642e+8 }; var coreStressStrainList = new List <double> { 2036021.8, 2.21866e+8, 375982146.8, -917857670, 5.23664e+8 }; var coreCreepList = new List <double> { 2036021.8, 2.21866e+8, 375982146.8, -917857670, 5.23664e+8 }; var startingTension = 2849.0; var startingTemp = 15.0; var startingSpanLength = 40; var startingElevation = 0.0; var startingTensionType = true; var material = WireMaterial.ACSR; var wire = Wire.Create(name, totalCrossSection, initialWireDiameter, finalWireDiameter, initialWireLinearWeight, finalWireLinearWeight, maxRatedStrength, outerElasticity, outerThermalCoefficient, coreElasticity, coreThermalCoefficient, outerStressStrainList, outerCreepList, coreStressStrainList, coreCreepList, startingTension, startingTemp, startingSpanLength, startingElevation, startingTensionType, material); return(wire); } else { var name = "General Wire Data"; var totalCrossSection = 0.00046844; var initialWireDiameter = 0.0281432; var finalWireDiameter = 0.0281432; var initialWireLinearWeight = 15.9657; var finalWireLinearWeight = 15.9657; var maxRatedStrength = 68000; var outerElasticity = 44126400000; var outerThermalCoefficient = 0.00002304; var coreElasticity = 25510600000; var coreThermalCoefficient = 0.00001152; var outerStressStrainList = new List <double> { -8363341, 305493595.6, -96556939.03, -2.59367e8, 2.11504e8 }; var outerCreepList = new List <double> { -3756263.8, 147732585.6, -129912395.9, 3.7887e7, 0 }; var coreStressStrainList = new List <double> { -477806.7, 2.66338e8, 27565929.1, -3.1518e8, 1.92309e8 }; var coreCreepList = new List <double> { 324743.1, 249668124.8, 84125691.63, -4.99125e8, 3.19489e8 }; var startingTension = 22500.0; var startingTemp = 15; var startingSpanLength = 50; var startingElevation = 0.0; var startingTensionType = true; var material = WireMaterial.ACSR; var wire = Wire.Create(name, totalCrossSection, initialWireDiameter, finalWireDiameter, initialWireLinearWeight, finalWireLinearWeight, maxRatedStrength, outerElasticity, outerThermalCoefficient, coreElasticity, coreThermalCoefficient, outerStressStrainList, outerCreepList, coreStressStrainList, coreCreepList, startingTension, startingTemp, startingSpanLength, startingElevation, startingTensionType, material); return(wire); } }
public void OutData(Wire wire) { Chessboard[wire.Vector.X, wire.Vector.Y] = 0; WireDictionary.Remove(wire.Vector); Wires.Remove(wire); }
public static void GrayWiresOut_Reverse(Wire wire) { wire.Opacity = 1; }
static void KeyWriter(string stream, int id, Wire wire, CodeWriter cw) { uint n = ((uint)id << 3) | ((uint)wire); cw.Comment("Key for field: " + id + ", " + wire); //cw.WriteLine("ProtocolParser.WriteUInt32(" + stream + ", " + n + ");"); VarintWriter(stream, n, cw); }
/// <summary> /// Provides public access specifically for getting the connectors associated to a wire. /// </summary> /// <param name="wireElement">The Wire element.</param> /// <returns>A set of connectors.</returns> /// <remarks>Wires in Revit are annotation elements that aren't currently exported. As such, we want to get their /// connection information to connect the elements at each of the wire together via a bi-directional port.</remarks> public static ConnectorSet GetConnectorsForWire(Wire wireElement) { return GetConnectors(wireElement); }
public void Init() { for (int i = 0; i < GameConfig.HightY; i++) { for (int j = 0; j < GameConfig.WidthX; j++) { var wire = new Wire(new IntVector(j, -1)); wire.Drop(j); } } for (int i = 0; i < GameConfig.HightY; i++) { var lint = new Lint(new IntVector(GameConfig.WidthX, i)); _rightLints.Add(lint); } for (int i = 0; i < GameConfig.HightY; i++) { var lint = new Lint(new IntVector(-1, i)); _leftLints.Add(lint); } for (int i = 1; i < GameConfig.WidthX; i++) { for (int j = 1; j < GameConfig.HightY; j++) { new RevolutionAnchor(new IntVector(i, j)); } } RunAction(MGSequence.Actions(MGDelay.ActionWithDuration(1), MGCallFunc.ActionWithTarget(WireIsChange))); }
private bool XAdd(Wire wire) { if (Vector == (wire.Vector + new IntVector(1, 0))) { return true; } return false; }
void Start() { if (Dummy == null) Dummy = this; else { } LR = GetComponent(typeof(LineRenderer)) as LineRenderer; LR.SetVertexCount(5); if (connection1 != null) { for (int i = 0; i < 5; i++) LR.SetPosition(i, connection1.transform.position); } }
private bool YAdd(Wire wire) { if (Vector == wire.Vector + new IntVector(0, 1)) { return true; } return false; }
public ProtoBuiltin(string name, Wire wire, string csType) { ProtoName = name; WireType = wire; base.CsType = csType; }
/// <summary> /// Update the pin external connectivity of the connecting group</summary> /// <param name="wire">Wire that has been added or removed in the DOM node tree</param> private void UpdateGroupPinConnectivity(Wire wire) { if (wire.InputElement == null || wire.OutputElement == null) return; var updatedNodes = new List<DomNode>(); // need to update the pin external connectivity of the connecting group if (CircuitUtil.IsGroupTemplateInstance(wire.InputElement.DomNode)) { updatedNodes.Add(CircuitUtil.GetGroupTemplate(wire.InputElement.DomNode).DomNode); UpdateTemplateInfo(CircuitUtil.GetGroupTemplate(wire.InputElement.DomNode)); } else if (wire.InputElement.DomNode.Is<Group>()) { updatedNodes.Add(wire.InputElement.DomNode); wire.InputElement.DomNode.Cast<Group>().UpdateGroupPinInfo(); } if (CircuitUtil.IsGroupTemplateInstance(wire.OutputElement.DomNode)) { updatedNodes.Add(CircuitUtil.GetGroupTemplate(wire.OutputElement.DomNode).DomNode); UpdateTemplateInfo(CircuitUtil.GetGroupTemplate(wire.OutputElement.DomNode)); } else if (wire.OutputElement.DomNode.Is<Group>()) { updatedNodes.Add(wire.OutputElement.DomNode); wire.OutputElement.DomNode.Cast<Group>().UpdateGroupPinInfo(); } // let's assume all the updated groups have changed connectivity, and notify the graph adaptors foreach (var group in updatedNodes) { var editingContext = group.As<CircuitEditingContext>(); if (editingContext != null) editingContext.NotifyObjectChanged(group); } }
private void YSub(Wire wire) { wire.BYSub = true; if (wire.Vector.Y > 0) { var v = wire.Vector - new IntVector(0, 1); var w = WireDictionary[v]; if (Clears.Contains(w) && w.WireData[0] != 0) { YDown.Add(wire); if (w.WireData[2] != 0) { if (!w.BYSub) { YSub(w); } } } } if (YDown.Count >= 1) { ThunderSprite sp; if (Thunders.Count - 1 > _thunderindex) { sp = Thunders[_thunderindex]; } else { sp = new ThunderSprite(); AddChild(sp, 9); Thunders.Add(sp); } _thunderindex++; sp.Points.Clear(); sp.AddPoint(new Vector2(wire.Vector.X * 94 + 94 / 2 + GameConfig.RelativeOrigin.X, 768 - (wire.Vector.Y * 94 + 47 + GameConfig.RelativeOrigin.Y))); sp.EndPoint(new Vector2(wire.Vector.X * 94 + 94 / 2 + GameConfig.RelativeOrigin.X, 768 - (wire.Vector.Y * 94 + 47 - YDown.Count * 94 / 2 + GameConfig.RelativeOrigin.Y))); sp.Visible = true; } }
public static void destroyCurrent() { Destroy(currentWire.gameObject); currentWire = null; }