Untitled
unknown
csharp
5 months ago
2.6 kB
2
Indexable
namespace SeaRam { public class SeaRamBullet : MonoBehaviour { private ZNetView m_nview; private Rigidbody m_body; private Transform m_bulletBody; private ParticleSystem m_impactEffect; private float m_timeout = 3f; private float m_bulletSpeed = 20f; private void Awake() { m_nview = GetComponent<ZNetView>(); m_bulletBody = transform.Find("demister_ball"); m_impactEffect = transform.Find("BulletImpact").GetComponent<ParticleSystem>(); } private void Update() { if (m_nview == null || !m_nview.IsValid()) return; if (m_body == null) { m_body = GetComponent<Rigidbody>(); if(m_body != null) { m_bulletSpeed = SeaRamPlugin.DevTest.Value.x; m_body.WakeUp(); m_body.AddForce(transform.forward * m_bulletSpeed, ForceMode.VelocityChange); CancelInvoke(nameof(DestroyNow)); InvokeRepeating(nameof(DestroyNow), m_timeout, 1f); } } } private void OnCollisionEnter(Collision collision) { m_bulletBody.gameObject.SetActive(false); m_impactEffect.Play(); m_body.velocity = Vector3.zero; CancelInvoke(nameof(DestroyNow)); InvokeRepeating(nameof(DestroyNow), 0.1f, 1f); } public void DestroyNow() { if (m_nview != null) { if (m_nview.IsValid()) { if (!m_nview.HasOwner()) { m_nview.ClaimOwnership(); } if (m_nview.IsOwner()) { ZNetScene.instance.Destroy(gameObject); } } } else { UnityEngine.Object.Destroy(gameObject); } } } public class SRCBullet { public static GameObject gatlingBullet = new GameObject(); public static void CreateClone(AssetBundle assetBundle, CustomLocalization localization) { gatlingBullet = SRH.LoadAssetBundle(assetBundle, "searam_bullet"); gatlingBullet.AddComponent<SeaRamBullet>(); PrefabManager.Instance.AddPrefab(gatlingBullet); } } }
Editor is loading...
Leave a Comment