Ejemplo n.º 1
0
        public static void SpawnGrenade(Vector3 position, ItemType id, float fusedur = -1, ReferenceHub player = null)
        {
            if (!InventoryItemLoader.AvailableItems.TryGetValue(id, out var itemBase) || !(itemBase is ThrowableItem throwableItem))
            {
                return;
            }

            ThrownProjectile thrownProjectile = UnityEngine.Object.Instantiate(throwableItem.Projectile);
            TimeGrenade      timeGrenade      = thrownProjectile as TimeGrenade;

            if (thrownProjectile.TryGetComponent <Rigidbody>(out var rigidbody))
            {
                rigidbody.position = position;
            }

            thrownProjectile.PreviousOwner = new Footprinting.Footprint(player ?? ReferenceHub.HostHub);

            if (fusedur != -1)
            {
                timeGrenade._fuseTime = fusedur;
            }

            NetworkServer.Spawn(thrownProjectile.gameObject);

            thrownProjectile.ServerActivate();
        }
Ejemplo n.º 2
0
 /// <summary>
 /// Inits the <see cref="CollisionHandler"/> object.
 /// </summary>
 /// <param name="owner">The grenade owner.</param>
 /// <param name="grenade">The grenade component.</param>
 public void Init(GameObject owner, ThrownProjectile grenade)
 {
     Owner       = owner;
     Grenade     = (EffectGrenade)grenade;
     initialized = true;
 }