public void TestToString() { string guid = "0123456789abcdef9876543210fedcba"; NetworkHash128 hash = NetworkHash128.Parse(guid); Assert.That(hash.ToString(), Is.EqualTo(guid)); }
private void Start() { pSender = this.GetComponent <PlayerMessageSender>(); mConnection = this.GetComponent <NetworkIdentity>().connectionToClient; ClientScene.RegisterPrefab(bulletPrefab, NetworkHash128.Parse(bulletPrefab.name)); ClientScene.RegisterPrefab(_lineRenderer.gameObject, NetworkHash128.Parse(_lineRenderer.gameObject.name)); //FindObjectOfType<customNetworkManager>().OnClientConnect(mConnection); if (isLocalPlayer) //If I'm the local player { Cursor.lockState = CursorLockMode.Locked; _transform = this.transform; //get my transform and keep a reference to it. _rigidbody = this.GetComponent <Rigidbody>(); _camera = this.GetComponentInChildren <Camera>(); _cameraTransform = _camera.transform; mainCamera = Camera.main; //get the main camera and disable it mainCamera.gameObject.SetActive(false); } else //If im not the local player { _transform = this.transform; _rigidbody = this.GetComponent <Rigidbody>(); _camera = this.GetComponentInChildren <Camera>(); _camera.enabled = false; //turn the camera off. _camera.GetComponent <AudioListener>().enabled = false; //disable the camera } }
void RpcRegisterWeapon() { if (currWeapon.GetComponent <NetworkIdentity>() == null) { currWeapon.AddComponent <NetworkIdentity>(); } ClientScene.RegisterPrefab(currWeapon, NetworkHash128.Parse(currWeapon.name)); CmdSpawnFix(currWeapon); }
public void Register() { var hash128 = NetworkHash128.Parse(this.SpawnId); ClientScene.RegisterSpawnHandler( hash128, this.OnClientSpawn, this.OnClientUnSpawn ); }
public override void Configure(GameObject gameObject) { //Configure game object: this.OnConfigure(gameObject); //Make object online: var hash128 = NetworkHash128.Parse(this.SpawnId); OregoNetworkUtils.SpawnObject(gameObject, hash128); }
public override GameObject Create() { //Create object: var gameObject = base.Create(); //Make object online: var hash128 = NetworkHash128.Parse(this.SpawnId); OregoNetworkUtils.SpawnObject(gameObject, hash128); return(gameObject); }
private static void RegisterClientPrefabsNStuff() { foreach (HashStruct h in thingsToHash) { if ((h.prefab.GetComponent <NetworkIdentity>() != null)) { h.prefab.GetComponent <NetworkIdentity>().SetFieldValue <NetworkHash128>("m_AssetId", nullHash); } ClientScene.RegisterPrefab(h.prefab, NetworkHash128.Parse(MakeHash(h.goName + h.callPath + h.callMember + h.callLine.ToString()))); } }
private static void RegisterClientPrefabsNStuff() { foreach (var h in ThingsToHash) { if (h.Prefab.GetComponent <NetworkIdentity>() != null) { h.Prefab.GetComponent <NetworkIdentity>().SetFieldValue("m_AssetId", NullHash); } ClientScene.RegisterPrefab(h.Prefab, NetworkHash128.Parse(MakeHash(h.GoName + h.CallPath + h.CallMember + h.CallLine))); } }
// Use this for initialization void Start() { List <NetworkObject> objectPool = spawnManager.ObjectPool; foreach (NetworkObject obj in objectPool) { NetworkHash128 typeId = NetworkHash128.Parse(obj._object.name); typeIdList.Add(typeId); } spawnManager.SetTypeIdToObjectPool(typeIdList); }
private static void RegisterClientPrefabsNStuff(On.RoR2.Networking.GameNetworkManager.orig_OnStartClient orig, RoR2.Networking.GameNetworkManager self, UnityEngine.Networking.NetworkClient newClient) { orig(self, newClient); foreach (HashStruct h in thingsToHash) { if (h.prefab.HasComponent <NetworkIdentity>()) { h.prefab.GetComponent <NetworkIdentity>().SetFieldValue <NetworkHash128>("m_AssetId", nullHash); } ClientScene.RegisterPrefab(h.prefab, NetworkHash128.Parse(MakeHash(h.goName + h.callPath + h.callMember + h.callLine.ToString()))); } }
public static GameObject PrefabFromGameObject(GameObject gameObject, [System.Runtime.CompilerServices.CallerMemberName] string memberName = "", [System.Runtime.CompilerServices.CallerFilePath] string sourceFilePath = "", [System.Runtime.CompilerServices.CallerLineNumber] int sourceLineNumber = 0) { var prefab = UnityEngine.Object.Instantiate(gameObject, prefabParent.transform); var networkId = prefab.GetComponent <NetworkIdentity>(); if (networkId) { networkId.m_AssetId = NetworkHash128.Parse(Hash128.Compute(sourceLineNumber + memberName + sourceFilePath).ToString()); } return(prefab); }
private static void GameNetworkManager_OnStartClient(On.RoR2.Networking.GameNetworkManager.orig_OnStartClient orig, GameNetworkManager self, NetworkClient newClient) { orig(self, newClient); ClientScene.RegisterPrefab(TwisterPrefab, NetworkHash128.Parse("9725011d8b662d98")); ClientScene.RegisterPrefab(GravBombPrefab, NetworkHash128.Parse("6d803141bb60b3f7")); ClientScene.RegisterPrefab(AsteroidProjectilePrefab, NetworkHash128.Parse("34eddec13b017082")); //For convenience: pre-generated random IDs that can be used later //164497abc3b46e41 //bfd424a1ac1b07ce //7c3cba1b92427f72 //0ab8e989d1c6c999 //0e90dedbde0f4b5a //a2177e2b92a917c3 //0327fff31597212d //6cd812cea49b73c5 }
public void TestParse() { string guid = "0123456789abcdef9876543210fedcba"; NetworkHash128 hash = NetworkHash128.Parse(guid); Assert.That(hash.i0, Is.EqualTo(0x01)); Assert.That(hash.i1, Is.EqualTo(0x23)); Assert.That(hash.i2, Is.EqualTo(0x45)); Assert.That(hash.i3, Is.EqualTo(0x67)); Assert.That(hash.i4, Is.EqualTo(0x89)); Assert.That(hash.i5, Is.EqualTo(0xab)); Assert.That(hash.i6, Is.EqualTo(0xcd)); Assert.That(hash.i7, Is.EqualTo(0xef)); Assert.That(hash.i8, Is.EqualTo(0x98)); Assert.That(hash.i9, Is.EqualTo(0x76)); Assert.That(hash.i10, Is.EqualTo(0x54)); Assert.That(hash.i11, Is.EqualTo(0x32)); Assert.That(hash.i12, Is.EqualTo(0x10)); Assert.That(hash.i13, Is.EqualTo(0xfe)); Assert.That(hash.i14, Is.EqualTo(0xdc)); Assert.That(hash.i15, Is.EqualTo(0xba)); }
public static NetworkHash128 FlagAssetId(int flag) { var id = "07e810adf1a9f1a9f1a9"; return(NetworkHash128.Parse(id + flag.ToString("x4"))); }
private void AssignAssetId(Object prefab) { var path = AssetDatabase.GetAssetPath(prefab); assetId = NetworkHash128.Parse(AssetDatabase.AssetPathToGUID(path)); }