public BaseMountable SpawnMountPoint(MountPointInfo mountToSpawn, Model model) { Vector3 vector = Quaternion.Euler(mountToSpawn.rot) * Vector3.forward; Vector3 pos = mountToSpawn.pos; Vector3 up = Vector3.up; if (mountToSpawn.bone != "") { pos = model.FindBone(mountToSpawn.bone).transform.position + base.transform.TransformDirection(mountToSpawn.pos); vector = base.transform.TransformDirection(vector); up = base.transform.up; } BaseEntity baseEntity = GameManager.server.CreateEntity(mountToSpawn.prefab.resourcePath, pos, Quaternion.LookRotation(vector, up)); BaseMountable baseMountable = baseEntity as BaseMountable; if (baseMountable != null) { if (mountToSpawn.bone != "") { baseMountable.SetParent(this, mountToSpawn.bone, true, true); } else { baseMountable.SetParent(this); } baseMountable.Spawn(); mountToSpawn.mountable = baseMountable; } else { Debug.LogError("MountPointInfo prefab is not a BaseMountable. Cannot spawn mount point."); if (baseEntity != null) { baseEntity.Kill(); } } return(baseMountable); }
public void GeneratePrefab() { entity = (BaseMountable)GameManager.server.CreateEntity(controller.car.chairRef.resourcePath, controller.transform.position); entity.enableSaving = false; entity.skinID = (ulong)1169930802; entity.Spawn(); entity.maxMountDistance = 2f; Destroy(entity.GetComponent <DestroyOnGroundMissing>()); Destroy(entity.GetComponent <GroundWatch>()); entity.GetComponent <MeshCollider>().convex = true; InvisibleMount invisibleMount = entity.gameObject.AddComponent <InvisibleMount>(); invisibleMount.MountPosition = this; entity.SetParent(controller.car); entity.transform.localPosition = offset; }