protected void Awake() { item = this.GetComponent <Item>(); module = item.data.GetModule <ItemModuleBlasterBolt>(); despawnTime = module.despawnTime; item.OnCollisionEvent += CollisionHandler; }
protected void Awake() { item = GetComponent <Item>(); module = item.data.GetModule <ItemModuleBlasterBolt>(); body = GetComponent <Rigidbody>(); ResetValues(); body.freezeRotation = module.lockRotation; if (!string.IsNullOrEmpty(module.effectID)) { trail = item.GetCustomReference(module.effectID).GetComponent <TrailRenderer>(); light = item.GetCustomReference(module.effectID).GetComponent <Light>(); if (light != null) { light.color = Utils.UpdateHue(light.color, module.boltHue); } if (trail != null) { trail.material.SetColor("_Color", Utils.UpdateHue(trail.material.GetColor("_Color"), module.boltHue)); } } foreach (CollisionHandler collisionHandler in item.collisionHandlers) { foreach (Damager damager in collisionHandler.damagers) { originalDamagers.Add(damager.data); } collisionHandler.OnCollisionStartEvent += CollisionHandler; collisionHandler.checkMinVelocity = false; } if (module.colliderScale > 0 && !Mathf.Approximately(module.colliderScale, 1.0f)) { var colliders = item.GetComponentsInChildren <Collider>(); for (int i = 0, l = colliders.Count(); i < l; i++) { var colTrans = colliders[i].transform; var colScale = colTrans.localScale; colTrans.localScale = new Vector3(colScale.x * module.colliderScale, colScale.y * module.colliderScale, colScale.z * module.colliderScale); } } }