public static BlastUnit GenerateUnit(string domain, long address, int precision, int alignment) { // Randomly selects a memory operation according to the selected algorithm if (domain == null) { return(null); } BlastTarget pipeStart = RtcCore.GetBlastTarget(); MemoryInterface mi = MemoryDomains.GetInterface(domain); MemoryInterface startmi = MemoryDomains.GetInterface(pipeStart.Domain); long safeAddress = address - (address % precision) + alignment; long safePipeStartAddress = pipeStart.Address - (pipeStart.Address % precision) + alignment; if (safeAddress > mi.Size - precision && mi.Size > precision) { safeAddress = mi.Size - (2 * precision) + alignment; //If we're out of range, hit the last aligned address } if (safePipeStartAddress > startmi.Size - precision && startmi.Size > precision) { safePipeStartAddress = startmi.Size - (2 * precision) + alignment; //If we're out of range, hit the last aligned address } return(new BlastUnit(StoreType.CONTINUOUS, StoreTime.PREEXECUTE, domain, safeAddress, pipeStart.Domain, safePipeStartAddress, precision, mi.BigEndian, 0, 0)); }
private void Update() { if (Screen.lockCursor && BrickManager.Instance.IsLoaded) { VerifyCamera(); VerifyLocalController(); VerifyExplosionMatch(); RaycastHit hit2; if (installing) { deltaTime += Time.deltaTime; if (!CanInstall() || !custom_inputs.Instance.GetButton("K_ACTION") || !GetInstallTarget(out RaycastHit hit)) { installing = false; deltaTime = 0f; P2PManager.Instance.SendPEER_INSTALLING_BOMB(installing: false); GetComponent <Weapon>().EndFireSound(); } else if (deltaTime >= installTime) { BlastTarget component = hit.transform.gameObject.GetComponent <BlastTarget>(); if (null == component) { Debug.LogError("Fail to get BlastTarget Component from core objs"); } else { explosionMatch.Step = ExplosionMatch.STEP.INSTALL_TRY; installing = false; deltaTime = 0f; P2PManager.Instance.SendPEER_INSTALLING_BOMB(installing: false); GetComponent <Weapon>().EndFireSound(); CSNetManager.Instance.Sock.SendCS_BM_INSTALL_BOMB_REQ(component.Spot, hit.point, hit.normal); } } } else if (CanInstall() && custom_inputs.Instance.GetButton("K_ACTION") && GetInstallTarget(out hit2)) { installing = true; deltaTime = 0f; localCtrl.CancelSpeedUp(); GetComponent <Weapon>().StartFireSound(); P2PManager.Instance.SendPEER_INSTALLING_BOMB(installing: true); } EnsureVisibility(); } }