// Constructor public Patch(Wiring.Patch instance) { _instance = instance; _nodeList = new List<Node>(); _instanceIDToNodeMap = new Dictionary<int, Node>(); Rescan(); }
// Open the patcher window with a given patch. public static void OpenPatch(Wiring.Patch patchInstance) { var window = EditorWindow.GetWindow<PatcherWindow>("Patcher"); window._patch = new Patch(patchInstance); window._patchManager.Select(window._patch); window.Show(); }
// Constructor public Node(Wiring.NodeBase instance) { _instance = instance; _typeName = ObjectNames.NicifyVariableName(_instance.GetType().Name); _windowID = _windowCounter++; // Inlets and outlets _inlets = new List<Inlet>(); _outlets = new List<Outlet>(); InitializeInletsAndOutlets(); // Window position _serializedObject = new UnityEditor.SerializedObject(_instance); _serializedPosition = _serializedObject.FindProperty("_wiringNodePosition"); ValidatePosition(); }
private void Add(Wiring wiring) { if (wiring == null) { return; } foreach (var wire in wiring.Wires) { Add(wire); } if (_tabsAssociations.Count > 0) { SelectTab(_tabsAssociations[0].tab); } }
public static void Kill(int x, int y) { TileEntity tileEntity; if (!TileEntity.ByPosition.TryGetValue(new Point16(x, y), out tileEntity) || tileEntity.type != (byte)2) { return; } Wiring.blockPlayerTeleportationForOneIteration = ((TELogicSensor)tileEntity).logicCheck == TELogicSensor.LogicCheckType.PlayerAbove; if (((TELogicSensor)tileEntity).logicCheck == TELogicSensor.LogicCheckType.PlayerAbove && ((TELogicSensor)tileEntity).On) { Wiring.HitSwitch((int)tileEntity.Position.X, (int)tileEntity.Position.Y); } if (((TELogicSensor)tileEntity).logicCheck == TELogicSensor.LogicCheckType.Water && ((TELogicSensor)tileEntity).On) { Wiring.HitSwitch((int)tileEntity.Position.X, (int)tileEntity.Position.Y); } if (((TELogicSensor)tileEntity).logicCheck == TELogicSensor.LogicCheckType.Lava && ((TELogicSensor)tileEntity).On) { Wiring.HitSwitch((int)tileEntity.Position.X, (int)tileEntity.Position.Y); } if (((TELogicSensor)tileEntity).logicCheck == TELogicSensor.LogicCheckType.Honey && ((TELogicSensor)tileEntity).On) { Wiring.HitSwitch((int)tileEntity.Position.X, (int)tileEntity.Position.Y); } if (((TELogicSensor)tileEntity).logicCheck == TELogicSensor.LogicCheckType.Liquid && ((TELogicSensor)tileEntity).On) { Wiring.HitSwitch((int)tileEntity.Position.X, (int)tileEntity.Position.Y); } Wiring.blockPlayerTeleportationForOneIteration = false; if (TELogicSensor.inUpdateLoop) { TELogicSensor.markedIDsForRemoval.Add(tileEntity.ID); } else { TileEntity.ByPosition.Remove(new Point16(x, y)); TileEntity.ByID.Remove(tileEntity.ID); } }
public override void HitWire(int i, int j) { state = -state; int x = i - (Main.tile[i, j].frameX / 18) % 2; int y = j - (Main.tile[i, j].frameY / 18) % 3; Wiring.SkipWire(x, y); Wiring.SkipWire(x, y + 1); Wiring.SkipWire(x, y + 2); Wiring.SkipWire(x + 1, y); Wiring.SkipWire(x + 1, y + 1); Wiring.SkipWire(x + 1, y + 2); for (int l = x; l < x + 2; l++) { for (int m = y; m < y + 3; m++) { if (Main.tile[l, m] == null) { Main.tile[l, m] = new Tile(); } if (Main.tile[l, m].active() && Main.tile[l, m].type == Type) { if (Main.tile[l, m].frameY < 56) { Main.tile[l, m].frameY += 56; } else if (Main.tile[l, m].frameY < 112) { Main.tile[l, m].frameY -= 56; } if (Main.tile[l, m].frameY >= 112) { if (Main.tile[l, m].frameY < 168) { Main.tile[l, m].frameY += 56; } else { Main.tile[l, m].frameY -= 56; } } } } } }
/// <summary> /// Rotates the wheel, forward or backwards. /// </summary> /// <param name="forward">If true, rotates the wheel counterclockwise</param> public void Rotate(bool forward = true) { int offset = forward ? 1 : -1; Indexing.Rotate(offset); Wiring.Rotate(offset); if (_raiseHitNotch) { HitNotch?.Invoke(this, forward); _raiseHitNotch = false; } else if (IsTurnOver()) { _raiseHitNotch = true; } }
//From Wiring.cs public override void HitWire(int i, int j) { Tile tile = Main.tile[i, j]; int num145 = tile.frameY / 18; int num144 = j - num145; short num143 = 18; if (tile.frameX > 0) { num143 = -18; } Main.tile[i, num144].frameX += num143; Main.tile[i, num144 + 1].frameX += num143; Wiring.SkipWire(i, num144); Wiring.SkipWire(i, num144 + 1); NetMessage.SendTileSquare(-1, i, j, 2); }
/// <summary> /// The read console seed file csv. /// </summary> /// <param name="seed"> /// The seed. /// </param> /// <param name="pathToCSV"> /// The path to csv. /// </param> /// <param name="links"> /// The links. /// </param> /// <returns> /// The <see cref="Seed"/>. /// </returns> private static Seed ReadConsoleSeedFileCSV(Seed seed, string pathToCSV, Dictionary <string, List <Links> > links) { if (File.Exists(pathToCSV)) { var rows = File.ReadLines(pathToCSV).Select(line => line.Split(',')).ToList(); foreach (var row in rows) { var aDevice = row[0]; var aIf = row[1]; var zDevice = row[0 + 2]; var zIf = row[1 + 2]; var cont = false; if (links.ContainsKey(aDevice)) { foreach (var link in links[aDevice]) { if (link.Equals(aIf, zDevice, zIf)) { Console.Error.WriteLine($"{aDevice} found in Links.csv with {aIf} connected to {zDevice}:{zIf}"); cont = true; } } } if (cont) { continue; } var wiring = new Wiring( new Start( aDevice, aIf), new End( zDevice, zIf), new DevicePattern(WiringType.Serial), Models.Action.Add); seed.Wiring.Add(wiring); } return(seed); } else { Console.WriteLine($"Failed to load csv file."); } return(null); }
public override void RightClick(int i, int j) { if (Main.netMode == 0) { Wiring.TripWire(i, j, 1, 1); } else { ModPacket packet = NetRouter.GetPacketTo(this, mod); packet.Write((Int16)i); packet.Write((Int16)j); packet.Send(); } mod.GetModWorld <ButtonDelayWorld>().setPoint(new Point16(i, j)); Main.PlaySound(SoundID.MenuTick); }
public override void HitWire(int i, int j) { // Find the coordinates of top left tile square through math int y = j - Main.tile[i, j].frameY / 18; int x = i - Main.tile[i, j].frameX / 18; Wiring.SkipWire(x, y); Wiring.SkipWire(x, y + 1); Wiring.SkipWire(x, y + 2); Wiring.SkipWire(x + 1, y); Wiring.SkipWire(x + 1, y + 1); Wiring.SkipWire(x + 1, y + 2); // We add 16 to x to spawn right between the 2 tiles. We also want to right on the ground in the y direction. int spawnX = x * 16 + 16; int spawnY = (y + 3) * 16; // This example shows both item spawning code and npc spawning code, you can use whichever code suits your mod // If you want to make an NPC spawning statue, see below. int npcIndex = -1; // 30 is the time before it can be used again. NPC.MechSpawn checks nearby for other spawns to prevent too many spawns. 3 in immediate vicinity, 6 nearby, 10 in world. int critter; if (Main.LocalPlayer.GetModPlayer <CalValEXPlayer>().ZoneAstral) { critter = ModContent.NPCType <Blightolemur>(); } else { critter = ModContent.NPCType <Violemur>(); } if (Wiring.CheckMech(x, y, 30) && NPC.MechSpawn((float)spawnX, (float)spawnY, (critter))) { npcIndex = NPC.NewNPC(spawnX, spawnY - 12, (critter)); } if (npcIndex >= 0) { Main.npc[npcIndex].value = 0f; Main.npc[npcIndex].npcSlots = 0f; // Prevents Loot if NPCID.Sets.NoEarlymodeLootWhenSpawnedFromStatue and !Main.HardMode or NPCID.Sets.StatueSpawnedDropRarity != -1 and NextFloat() >= NPCID.Sets.StatueSpawnedDropRarity or killed by traps. // Prevents CatchNPC Main.npc[npcIndex].SpawnedFromStatue = true; } }
public override void HitWire(int i, int j) { // Find the coordinates of top left tile square through math int y = j - (Main.tile[i, j].frameY / 18); int x = i - (Main.tile[i, j].frameX / 18); Wiring.SkipWire(x, y); Wiring.SkipWire(x, y + 1); Wiring.SkipWire(x, y + 2); Wiring.SkipWire(x + 1, y); Wiring.SkipWire(x + 1, y + 1); Wiring.SkipWire(x + 1, y + 2); if (Wiring.CheckMech(x, y, 30)) { Main.time = 32400.1; } }
public override void HitWire(int i, int j) { Tile tile = Framing.GetTileSafely(i, j); //Initial tile int newX = i - tile.frameX % 54 / 18; //Adjustments int newY = j - tile.frameY % 54 / 18; tile = Framing.GetTileSafely(newX, newY); //Top-left tile for (int k = 0; k < 3; k++) //Changes frames properly { for (int l = 0; l < 3; ++l) { Main.tile[newX + k, newY + l].frameX += (short)(tile.frameX >= 54 ? -54 : 54); Wiring.SkipWire(newX + k, newY + l); } } }
public override void HitWire(int i, int j) { Tile tile = Framing.GetTileSafely(i, j); int newY = j - tile.frameY % 36 / 18; tile = Framing.GetTileSafely(i, newY); Main.NewText("G: " + tile.frameX); for (int l = 0; l < 2; --l) { Main.tile[i, newY + l].frameX += (short)(tile.frameX >= 18 ? -18 : 18); Wiring.SkipWire(i, newY + l); } Main.NewText("G: " + tile.frameX); }
public override void HitWire(int i, int j) { TEWirelessTeleporter TE; if (!TryGetTE(i, j, out TE)) { return; } Wiring.SkipWire(TE.Position.X - 1, TE.Position.Y); Wiring.SkipWire(TE.Position.X, TE.Position.Y); Wiring.SkipWire(TE.Position.X + 1, TE.Position.Y); if (TE.isLocked) { TE.Teleport(); } }
public void ReceiveTripWire(BinaryReader reader, int from) { // TODO: Find out what happens if player 0 leaves if (from != 0) { return; } var x = reader.ReadInt32(); var y = reader.ReadInt32(); if (WireMod.Debug) { WireMod.Instance.Logger.Info($"{from} Received TripWire: x {x}, y {y}"); } Wiring.TripWire(x, y, 1, 1); }
public override bool NewRightClick(int i, int j) { if (Main.netMode == 0) { Wiring.TripWire(i, j, 1, 1); } else { ModPacket packet = NetRouter.GetPacketTo(this, mod); packet.Write((Int16)i); packet.Write((Int16)j); packet.Send(); } ModContent.GetInstance <ButtonDelayWorld>().setPoint(new Point16(i, j)); Main.PlaySound(SoundID.MenuTick); return(true); }
void ActivateReceiver(Point16 receiver) { if (WirelessUtils.IsReceiver(receiver)) { Wiring.TripWire(receiver.X, receiver.Y, 1, 1); Tile tile = Main.tile[receiver.X, receiver.Y]; if (tile.TileType == ModContent.TileType <Tiles.WirelessTransceiver>() && WirelessSystem.Links.ContainsKey(receiver)) { if (WirelessUtils.IsReceiver(WirelessSystem.Links[receiver])) { Wiring.TripWire(WirelessSystem.Links[receiver].X, WirelessSystem.Links[receiver].Y, 1, 1); } } } else { SyncRemoveLink(receiver); } }
public Message(Settings s) { _mode = ConstructorMode.Settings; _settings = s; _machine = new Machine(_settings); Wiring.Current = Wiring.Default(); if (_settings.ParentSettings != null) { if (_settings.ParentSettings.Wiring != null) { Wiring.Current = _settings.ParentSettings.Wiring; } } MessageKey = RandomUtil.GetRandomAlpha(5); }
public override void HitWire(int i, int j) { Tile tile = Main.tile[i, j]; int topY = j - tile.frameY / 18 % 3; short frameAdjustment = (short)(tile.frameX > 0 ? -18 * 2 : 18 * 2); Main.tile[i, topY].frameX += frameAdjustment; Main.tile[i, topY + 1].frameX += frameAdjustment; Main.tile[i + 1, topY].frameX += frameAdjustment; Main.tile[i + 1, topY + 1].frameX += frameAdjustment; //Main.tile[i, topY + 2].frameX += frameAdjustment; Wiring.SkipWire(i, topY); Wiring.SkipWire(i, topY + 1); Wiring.SkipWire(i + 1, topY); Wiring.SkipWire(i + 1, topY + 1); //Wiring.SkipWire(i, topY + 2); NetMessage.SendTileSquare(-1, i, topY + 1, 2, TileChangeType.None); NetMessage.SendTileSquare(-1, i + 1, topY + 1, 2, TileChangeType.None); }
public override void HitWire(int i, int j) { int x = i - Main.tile[i, j].frameX / 18 % 3; int y = j - Main.tile[i, j].frameY / 18 % 4; for (int l = x; l < x + 3; l++) { for (int m = y; m < y + 4; m++) { if (Main.tile[l, m] == null) { Main.tile[l, m] = new Tile(); } if (Main.tile[l, m].active() && Main.tile[l, m].type == Type) { if (Main.tile[l, m].frameY < 72) { Main.tile[l, m].frameY += 72; } else { Main.tile[l, m].frameY -= 72; } } } } if (Wiring.running) { Wiring.SkipWire(x, y); Wiring.SkipWire(x, y + 1); Wiring.SkipWire(x, y + 2); Wiring.SkipWire(x, y + 3); Wiring.SkipWire(x + 1, y); Wiring.SkipWire(x + 1, y + 1); Wiring.SkipWire(x + 1, y + 2); Wiring.SkipWire(x + 1, y + 3); Wiring.SkipWire(x + 2, y); Wiring.SkipWire(x + 2, y + 1); Wiring.SkipWire(x + 2, y + 2); Wiring.SkipWire(x + 2, y + 3); } NetMessage.SendTileSquare(-1, x, y + 1, 3); }
public override void HitWire(int i, int j) { Tile tile = Main.tile[i, j]; int topY = j - tile.frameY / 18 % 3; short frameAdjustment = (short)(tile.frameX > 0 ? -18 : 18); Main.tile[i, topY].frameX += frameAdjustment; Main.tile[i, topY + 1].frameX += frameAdjustment; Main.tile[i, topY + 2].frameX += frameAdjustment; Wiring.SkipWire(i, topY); Wiring.SkipWire(i, topY + 1); Wiring.SkipWire(i, topY + 2); // Avoid trying to send packets in singleplayer. if (Main.netMode != NetmodeID.SinglePlayer) { NetMessage.SendTileSquare(-1, i, topY + 1, 3, TileChangeType.None); } }
public override void RightClick(int i, int j) { Point16 origin = GetOrigin(i, j); Point16 topLeft = origin - tileObjectData.Origin; if (Main.netMode == 0) { Wiring.TripWire(topLeft.X, topLeft.Y, 2, 2); } else { ModPacket packet = NetRouter.GetPacketTo(this, mod); packet.Write(topLeft.X); packet.Write(topLeft.Y); packet.Send(); } mod.GetModWorld <ButtonDelayWorld>().setPoint(topLeft); Main.PlaySound(SoundID.MenuTick); }
public static void Kill(int x, int y) { if (TileEntity.ByPosition.TryGetValue(new Point16(x, y), out var value) && value.type == _myEntityID) { Wiring.blockPlayerTeleportationForOneIteration = ((TELogicSensor)value).logicCheck == LogicCheckType.PlayerAbove; bool flag = false; if (((TELogicSensor)value).logicCheck == LogicCheckType.PlayerAbove && ((TELogicSensor)value).On) { flag = true; } else if (((TELogicSensor)value).logicCheck == LogicCheckType.Water && ((TELogicSensor)value).On) { flag = true; } else if (((TELogicSensor)value).logicCheck == LogicCheckType.Lava && ((TELogicSensor)value).On) { flag = true; } else if (((TELogicSensor)value).logicCheck == LogicCheckType.Honey && ((TELogicSensor)value).On) { flag = true; } else if (((TELogicSensor)value).logicCheck == LogicCheckType.Liquid && ((TELogicSensor)value).On) { flag = true; } if (flag) { Wiring.HitSwitch(value.Position.X, value.Position.Y); NetMessage.SendData(59, -1, -1, null, value.Position.X, value.Position.Y); } Wiring.blockPlayerTeleportationForOneIteration = false; if (inUpdateLoop) { markedIDsForRemoval.Add(value.ID); return; } TileEntity.ByPosition.Remove(new Point16(x, y)); TileEntity.ByID.Remove(value.ID); } }
private static void UpdateEndInternal() { TELogicSensor.inUpdateLoop = false; foreach (Tuple <Point16, bool> tripPoint in TELogicSensor.tripPoints) { Wiring.blockPlayerTeleportationForOneIteration = tripPoint.Item2; Wiring.HitSwitch((int)tripPoint.Item1.X, (int)tripPoint.Item1.Y); } Wiring.blockPlayerTeleportationForOneIteration = false; TELogicSensor.tripPoints.Clear(); foreach (int key in TELogicSensor.markedIDsForRemoval) { TileEntity tileEntity; if (TileEntity.ByID.TryGetValue(key, out tileEntity) && (int)tileEntity.type == 2) { TileEntity.ByID.Remove(key); } TileEntity.ByPosition.Remove(tileEntity.Position); } TELogicSensor.markedIDsForRemoval.Clear(); }
public void ChangeState(bool onState, bool TripWire) { if (onState != this.On && !SanityCheck()) { return; } Main.tile[base.Position.X, base.Position.Y].frameX = (short)(onState ? 18 : 0); this.On = onState; GetFrame(); if (Main.netMode == 2) { NetMessage.SendTileSquare(-1, base.Position.X, base.Position.Y, 1, TileChangeType.None); } if (TripWire && Main.netMode != 1) { Wiring.TripWire(base.Position.X, base.Position.Y, 1, 1); } }
public static void Use(int i, int j) { Tile tile = Main.tile[i, j]; int num6 = Main.tile[i, j].frameX / 18 * -1; int num5 = Main.tile[i, j].frameY / 18 * -1; num6 %= 4; if (num6 < -1) { num6 += 2; } num6 += i; num5 += j; Main.PlaySound(28, i * 16, j * 16, 0); Wiring.TripWire(num6, num5, 2, 2); int num = i; if (tile.frameX % 36 != 0) { num--; } }
public override void HitWire(int i, int j) { //Top left tile int x = i - Main.tile[i, j].frameX % animationFrameWidth / 18; int y = j - Main.tile[i, j].frameY % animationFrameHeight / 18; Wiring.SkipWire(x, y); Wiring.SkipWire(x, y + 1); Wiring.SkipWire(x + 1, y); Wiring.SkipWire(x + 1, y + 1); Wiring.SkipWire(x + 2, y); Wiring.SkipWire(x + 2, y + 1); bool activate = Main.tile[x, y].frameX != 0; for (int l = x; l < x + 3; l++) { for (int m = y; m < y + 2; m++) { if (Main.tile[l, m] == null) { Main.tile[l, m] = new Tile(); } if (Main.tile[l, m].active() && Main.tile[l, m].type == Type) { if (activate) { Main.tile[l, m].frameX -= animationFrameWidth; } else { Main.tile[l, m].frameX += animationFrameWidth; } } } } NetMessage.SendTileSquare(-1, x + 1, y + 1, 3); }
public static void PutBallInCup_Actual(Point hitLocation, int plr, int numberOfHits, int projid) { if (numberOfHits != 0) { Wiring.HitSwitch(hitLocation.X, hitLocation.Y); NetMessage.SendData(59, -1, -1, null, hitLocation.X, hitLocation.Y); EmitGolfballExplosion(hitLocation.ToWorldCoordinates(8f, 0f)); string key = "Game.BallBounceResultGolf_Single"; if (numberOfHits != 1) { key = "Game.BallBounceResultGolf_Plural"; } NetworkText networkText = NetworkText.FromKey(key, Main.player[plr].name, NetworkText.FromKey(Lang.GetProjectileName(projid).Key), numberOfHits); if (Main.netMode == 0 || Main.netMode == 1) { Main.NewText(networkText.ToString(), byte.MaxValue, 240, 20); } else if (Main.netMode == 2) { ChatHelper.BroadcastChatMessage(networkText, new Color(255, 240, 20)); } } }
private int GetOutput() { if (!int.TryParse(this.Value, out var val)) { return(-1); } if (!this.Pins["In"][0].IsConnected()) { return(-1); } if (this.Pins["In"][0].DataType != "bool") { return(-1); } if (!int.TryParse(this.Pins["In"][0].GetValue(), out var in0)) { return(-1); } if ((in0 <= 0 && val > 0) || (in0 > 0 && val <= 0)) { Wiring.blockPlayerTeleportationForOneIteration = true; if (Main.netMode != NetmodeID.MultiplayerClient) { Wiring.TripWire(this.Pins["Out"][0].Location.X, this.Pins["Out"][0].Location.Y, 1, 1); } else { Wiring.TripWire(this.Pins["Out"][0].Location.X, this.Pins["Out"][0].Location.Y, 1, 1); WireMod.PacketHandler.SendTripWire(256, Main.myPlayer, this.Pins["Out"][0].Location.X, this.Pins["Out"][0].Location.Y); } } this.Value = in0.ToString(); return(in0); }
public override void HitWire(int i, int j) { int x = i - (Main.tile[i, j].frameX / 18) % 3; int y = j - (Main.tile[i, j].frameY / 18) % 3; Wiring.SkipWire(x, y); Wiring.SkipWire(x, y + 1); Wiring.SkipWire(x, y + 2); Wiring.SkipWire(x + 1, y); Wiring.SkipWire(x + 1, y + 1); Wiring.SkipWire(x + 1, y + 2); Wiring.SkipWire(x + 2, y); Wiring.SkipWire(x + 2, y + 1); Wiring.SkipWire(x + 2, y + 2); for (int l = x; l < x + 3; l++) { for (int m = y; m < y + 3; m++) { if (Main.tile[l, m].liquid > 0) { Main.PlaySound(19, x * 16, y * 16, 1); Main.tile[l, m].liquid = 0; Main.tile[l, m].lava(false); Main.tile[l, m].honey(false); WorldGen.SquareTileFrame(l, m, false); if (Main.netMode == 1) { NetMessage.sendWater(l, m); } else { Liquid.AddWater(l, m); } } } } }
public static bool BeginTripWire(int left, int top, int width, int height) { if (!Active || Thread.CurrentThread.Name == wireThreadName) { VisualizerWorld.AddStart(new Rectangle(left, top, width, height)); return(true); } if (Running) { if (queuedWireTrips.Count < maxQueuedTrips) { queuedWireTrips.Enqueue(new Rectangle(left, top, width, height)); } return(false); } VisualizerWorld.ResetSegments(); Running = true; Thread wireThread = new Thread(delegate(object rand) { Main.rand = (UnifiedRandom)rand; //Main.rand is ThreadStatic, but we need it for faulty gates Wiring.TripWire(left, top, width, height); Running = false; mainWait.Set(); }); wireThread.IsBackground = true; wireThread.Name = wireThreadName; wireThread.Start(Main.rand); mainWait.WaitOne(); return(false); }
public override void Update(GameTime gameTime) { if (!this.GetPinIn(0).IsConnected()) { this.Settings["Value"] = "-1"; return; } ; if (!int.TryParse(this.Settings["Value"], out var val) || !int.TryParse(this.GetPinIn(0).GetValue(), out var in0)) { this.Settings["Value"] = "-2"; return; } if ((in0 <= 0 && val > 0) || (in0 > 0 && val <= 0)) { if (this.Settings["Trigger"] == Triggers[2] || // Enter and Exit (in0 == 1 && this.Settings["Trigger"] == Triggers[1]) || // Enter Only (in0 == 0 && this.Settings["Trigger"] == Triggers[0])) // Exit Only { Wiring.blockPlayerTeleportationForOneIteration = true; if (Main.netMode != NetmodeID.MultiplayerClient) { Wiring.TripWire(this.GetPinOut(0).Location.X, this.GetPinOut(0).Location.Y, 1, 1); } else { Wiring.TripWire(this.GetPinOut(0).Location.X, this.GetPinOut(0).Location.Y, 1, 1); WireMod.PacketHandler.SendTripWire(256, Main.myPlayer, this.GetPinOut(0).Location.X, this.GetPinOut(0).Location.Y); } } } this.Settings["Value"] = in0.ToString(); }
public DisambiguateMovieBookingHandler(WorkflowInstanceRepository instanceRepository, Wiring.IStateMachineMapper stateMachineMapper) { this.instanceRepository = instanceRepository; this.stateMachineMapper = stateMachineMapper; }
// Add a node instance to the patch. public void AddNodeInstance(Wiring.NodeBase nodeInstance) { // Append to the hierarchy. nodeInstance.transform.parent = _instance.transform; // Register to this patch representation. var node = new Node(nodeInstance); _nodeList.Add(node); _instanceIDToNodeMap.Add(nodeInstance.GetInstanceID(), node); }
// Open the patcher window with a given patch. public static void OpenPatch(Wiring.Patch patch) { var window = EditorWindow.GetWindow<PatcherWindow>("Patcher"); window.Initialize(patch); window.Show(); }
// Get an editor representation of the given node. public Node GetNodeOfInstance(Wiring.NodeBase instance) { return _instanceIDToNodeMap[instance.GetInstanceID()]; }
// Check if this is a representation of the given patch instance. public bool IsRepresentationOf(Wiring.Patch instance) { return _instance == instance; }
// Initializer (called from OpenPatch) void Initialize(Wiring.Patch patch) { hideFlags = HideFlags.HideAndDontSave; _graph = Graph.Create(patch); _graphGUI = _graph.GetEditor(); }
// Try to create a link between two nodes. // Returns true if the link is established successfully. public static bool TryLinkNodes( Wiring.NodeBase nodeFrom, UnityEventBase triggerEvent, Wiring.NodeBase nodeTo, MethodInfo targetMethod ) { // Determine the type of the target action. var actionType = GetUnityActionToInvokeMethod(targetMethod); if (actionType == null) return false; // invalid target method type // Create an action that is bound to the target method. var targetAction = Delegate.CreateDelegate( actionType, nodeTo, targetMethod ); if (triggerEvent is UnityEvent) { // The trigger event has no parameter. // Add the action to the event with a default parameter. if (actionType == typeof(UnityAction)) { UnityEventTools.AddVoidPersistentListener( triggerEvent, (UnityAction)targetAction ); return true; } if (actionType == typeof(UnityAction<float>)) { UnityEventTools.AddFloatPersistentListener( triggerEvent, (UnityAction<float>)targetAction, 1.0f ); return true; } } else if (triggerEvent is UnityEvent<float>) { // The trigger event has a float parameter. // Then the target method should have a float parameter too. if (actionType == typeof(UnityAction<float>)) { // Add the action to the event. UnityEventTools.AddPersistentListener( (UnityEvent<float>)triggerEvent, (UnityAction<float>)targetAction ); return true; } } else if (triggerEvent is UnityEvent<Vector3>) { // The trigger event has a Vector3 parameter. // Then the target method should have a Vector3 parameter too. if (actionType == typeof(UnityAction<Vector3>)) { // Add the action to the event. UnityEventTools.AddPersistentListener( (UnityEvent<Vector3>)triggerEvent, (UnityAction<Vector3>)targetAction ); return true; } } else if (triggerEvent is UnityEvent<Quaternion>) { // The trigger event has a Quaternion parameter. // Then the target method should have a Quaternion parameter too. if (actionType == typeof(UnityAction<Quaternion>)) { // Add the action to the event. UnityEventTools.AddPersistentListener( (UnityEvent<Quaternion>)triggerEvent, (UnityAction<Quaternion>)targetAction ); return true; } } else if (triggerEvent is UnityEvent<Color>) { // The trigger event has a color parameter. // Then the target method should have a color parameter too. if (actionType == typeof(UnityAction<Color>)) { // Add the action to the event. UnityEventTools.AddPersistentListener( (UnityEvent<Color>)triggerEvent, (UnityAction<Color>)targetAction ); return true; } } return false; // trigger-target mismatch }
// Remove a link between two nodes. public static void RemoveLinkNodes( Wiring.NodeBase nodeFrom, UnityEventBase triggerEvent, Wiring.NodeBase nodeTo, MethodInfo targetMethod ) { var methodName = targetMethod.Name; var eventCount = triggerEvent.GetPersistentEventCount(); for (var i = 0; i < eventCount; i++) { if (nodeTo == triggerEvent.GetPersistentTarget(i) && methodName == triggerEvent.GetPersistentMethodName(i)) { UnityEventTools.RemovePersistentListener(triggerEvent, i); break; } } }
// Initializer (called from the Create method) void Initialize(Wiring.NodeBase runtimeInstance) { hideFlags = HideFlags.DontSave; // Object references _runtimeInstance = runtimeInstance; _serializedObject = new UnityEditor.SerializedObject(runtimeInstance); _serializedPosition = _serializedObject.FindProperty("_wiringNodePosition"); // Basic information name = runtimeInstance.GetInstanceID().ToString(); position = new Rect(_serializedPosition.vector2Value, Vector2.zero); // Slot initialization PopulateSlots(); }
// Initializer (called from the Create method) void Initialize(Wiring.Patch patch) { hideFlags = HideFlags.HideAndDontSave; _patchInstanceID = patch != null ? patch.GetInstanceID() : 0; }
// Check if this is a representation of a given instance. public bool IsRepresentationOf(Wiring.NodeBase instance) { return _instance == instance; }
// Factory method static public Node Create(Wiring.NodeBase runtimeInstance) { var node = CreateInstance<Node>(); node.Initialize(runtimeInstance); return node; }
// Factory method static public Graph Create(Wiring.Patch patch) { var graph = CreateInstance<Graph>(); graph.Initialize(patch); return graph; }