void Explode(ExplosiveInfo info) { var colliders = Physics2D.OverlapCircleAll(info.GameObject.transform.position, EXPLOSIVE_RADIUS_HUMANOID); foreach (var c in colliders) { if (c.gameObject.CompareTag("humanoid")) { } else if (Vector2.Distance(c.gameObject.transform.position, info.GameObject.transform.position) < EXPLOSIVE_RADIUS_BREAKABLE) { BreakableController.Instance.HitObject(c.gameObject, info.ItemInfo.UID); } else { Debug.Log(Vector2.Distance(c.gameObject.transform.position, info.GameObject.transform.position)); } } }
private void CreateExplosive(ExplosiveType type, BasePlayer player) { ExplosiveInfo info = explosiveInfo[type]; BaseEntity entity = GameManager.server.CreateEntity(info.PrefabName, player.transform.position + new Vector3(0, 1.5f, 0), new Quaternion(), true); entity.OwnerID = player.userID; entity.creatorEntity = player; TimedExplosive explosive = entity.GetComponent <TimedExplosive>(); explosive.timerAmountMax = info.Fuse; explosive.timerAmountMin = info.Fuse; explosive.explosionRadius = info.Radius; explosive.damageTypes = new List <Rust.DamageTypeEntry> { new Rust.DamageTypeEntry { amount = info.Damage, type = Rust.DamageType.Explosion } }; explosive.Spawn(); }