private void HandleInput() { if (Input.GetMouseButtonDown(0)) { isGrappling = true; } if (Input.GetMouseButton(0)) { if (isGrappling) { isGrappling = false; var clickResult = OnClicked?.Invoke(player.transform.position); if (clickResult.HasValue) { var joint = clickResult.Value.Item1; joint.connectedBody = player; OnAttach?.Invoke(joint.transform.position); TravelAmount = clickResult.Value.Item2 + 1; OnScore?.Invoke(TravelAmount); } } } if (Input.GetMouseButtonUp(0)) { OnRelease?.Invoke(); } }
public OverlayReference Attach(RenderFragment overlayContent, OverlayConfig overlayConfig) { _sequenceNumber++; var overlayReference = new OverlayReference(_sequenceNumber); _overlayReferences.Add(overlayReference); overlayConfig.OverlayRef = overlayReference.OverlayReferenceId; OnAttach?.Invoke(overlayContent, overlayConfig); return(overlayReference); }
/// <summary> /// 附加显示 /// </summary> public void Attach(Point dragStartPoint) { this.startPoint = dragStartPoint.Round(this.PointDecimals); AdornerLayer adornerLayer = AdornerLayer.GetAdornerLayer(this.host); if (adornerLayer != null) { adornerLayer.Add(this); OnAttach?.Invoke(this, this.getEventArgs()); if (!this.IsMouseCaptured) { this.CaptureMouse(); } } }
public virtual void AttachTo(IDCLEntity entity, System.Type overridenAttachedType = null) { if (attachedEntities.Contains(entity)) { return; } System.Type thisType = overridenAttachedType != null ? overridenAttachedType : GetType(); entity.AddSharedComponent(thisType, this); attachedEntities.Add(entity); entity.OnRemoved += OnEntityRemoved; OnAttach?.Invoke(entity); }
public void Attach(bool playAudio) { if (isFitted) { return; } transform.parent = attachmentPoint.transform; transform.localPosition = Vector3.zero; transform.localEulerAngles = Vector3.zero; StartCoroutine(FixParent(attachmentPoint.transform)); StartCoroutine(LateAttach(playAudio)); if (boltParent != null) { boltParent.SetActive(true); } OnAttach?.Invoke(); }
public override void Attach(Response response, dynamic arguments) { switch (DebugAdapterStatus) { case DebugAdapterStatusEnum.WaitingForEngineReady: throw new InvalidOperationException("Attach failed, engine is waiting for Launch"); case DebugAdapterStatusEnum.BreakPointHit: case DebugAdapterStatusEnum.StepComplete: case DebugAdapterStatusEnum.AsyncBreakHit: case DebugAdapterStatusEnum.ExceptionOccured: throw new InvalidOperationException($"Attach failed, engine is busy. Status={DebugAdapterStatus}"); case DebugAdapterStatusEnum.Ready: ManualResetEventSlim mse = new ManualResetEventSlim(false); postAsyncBreakAction = mse.Set; postConfigurationDoneAction = () => //continue the script excution when VSCode configuration is done { debuggingService.Step(JavaScriptDiagStepType.JsDiagStepTypeContinue); }; debuggingService.RequestAsyncBreak(); SendOutput("AsyncBreak request sent, waiting for engine response"); mse.Wait(); SendOutput("AsyncBreak hit, continue Attach progress"); break; default: break; } OnAdapterMessage?.Invoke(this, "[Attach]"); OnAttach?.Invoke(this, arguments); sourceMap.Clear(); if (arguments.sourceMap != null) { foreach (var item in arguments.sourceMap) { sourceMap.Add((string)item.name, (string)item.value); } } SendResponse(response); }
public bool TryAttachToDarkSouls(out string errorMsg) { errorMsg = null; Process selectedProcess = null; Process[] _allProcesses = Process.GetProcesses(); try { var potentialProcesses = new List <Process>(); foreach (Process proc in _allProcesses) { if (proc.MainWindowTitle.ToUpper().Equals("DARK SOULS")) { potentialProcesses.Add(proc); } } if (potentialProcesses.Count == 0) { errorMsg = "Unable to find any process likely to be Dark Souls (i.e. has \"DARK SOULS\" in the title bar)."; return(false); } else if (potentialProcesses.Count == 1) { selectedProcess = potentialProcesses[0]; } else if (potentialProcesses.Count >= 2) { var mostObviousChoice = potentialProcesses.FirstOrDefault(x => x.ProcessName.ToUpper() == "DARKSOULS"); if (mostObviousChoice != default(Process)) { selectedProcess = mostObviousChoice; potentialProcesses.Clear(); potentialProcesses.Add(selectedProcess); Console.WriteLine("Note: Multiple candidates found for Dark Souls process, but the one named \"DARKSOULS\" was chosen automatically."); } else { var purgedList = new List <Process>(); foreach (var p in potentialProcesses) { //Set this process as the active process for the Kernel32 read/write functions in Hook to use SetHandle((IntPtr)Kernel.OpenProcess(Kernel.PROCESS_ALL_ACCESS, false, p.Id)); //Run the hook check. CheckHook(); //If CheckHook() fails, the process will be detached afterward. If it's still attached, add it to the list of still-valid processes. if (Attached) { purgedList.Add(p); } else { ReleaseHandle(); } } potentialProcesses = purgedList; } if (potentialProcesses.Count == 0) { errorMsg = "Found one or more processes likely to be Dark Souls (i.e. had \"DARK SOULS\" in the title bar)\n" + "but none of them passed the byte matching check and as such none were confirmed as valid.\n" + "Obviously, if you're running a valid Dark Souls process currently and get this message, there is a bug that needs to be fixed."; return(false); } else if (potentialProcesses.Count == 1) { selectedProcess = potentialProcesses[0]; } else if (potentialProcesses.Count >= 2) { errorMsg = $"Found {potentialProcesses.Count} valid Dark Souls processes running. Impossible to know which one you want to hook to\n" + "(and impossible to ask you which one you want to hook to, since they all have the same name).\nPlease close all but 1 and try again." + "\n\nNote: If you need to have multiple instances of the game open for \"educational purposes\", then you can make the executable you\n" + "want to hook to named \"DARKSOULS.exe\" and it will be chosen instead of showing this error message."; return(false); } } if (selectedProcess != null) { ProcessID = selectedProcess.Id; SetHandle((IntPtr)Kernel.OpenProcess(Kernel.PROCESS_ALL_ACCESS, false, selectedProcess.Id)); CheckHook(); Dictionary <string, List <uint> > modulesInputDict = new Dictionary <string, List <uint> >(); if (Attached) { foreach (ProcessModule dll in selectedProcess.Modules) { string indexName = dll.ModuleName.ToUpper(); if (modulesInputDict.ContainsKey(indexName)) { modulesInputDict[indexName].Add((uint)dll.BaseAddress); } else { modulesInputDict.Add(indexName, new uint[] { (uint)dll.BaseAddress }.ToList()); } } } ModuleOffsets = new ReadOnlyDictionary <string, List <uint> >(modulesInputDict); } else { errorMsg = "Could not find any valid Dark Souls process."; ReleaseHandle(); return(false); } if (!Attached) { errorMsg = "Found Dark Souls process but failed to attach to it.\nTry explicitly running your program (or scripting environment) as an administrator."; ReleaseHandle(); return(false); } else { OnAttach?.Invoke(); return(true); } } catch (Exception e) { errorMsg = "Encountered the following exception while trying to attach to Dark Souls process:\n\n" + e.Message; return(false); } finally { foreach (var p in _allProcesses) { p?.Dispose(); } } }
private void IPCOnOpen(object sender, EventArgs e) { OnAttach?.Invoke(sender, new EventArgs()); }
protected override void Attach() { OnAttach?.Invoke(this, new EventArgs()); }