Exemplo n.º 1
0
 public override void Click(Entity entity, ItemStack item)
 {
     if (!(entity is HumanoidEntity))
     {
         // TODO: non-humanoid support
         return;
     }
     HumanoidEntity character = (HumanoidEntity)entity;
     double fireRate = FireRate * item.GetAttributeF("firerate_mod", 1f);
     if (item.Datum != 0 && !character.WaitingForClickRelease && (character.TheRegion.GlobalTickTime - character.LastGunShot >= fireRate))
     {
         double spread = Spread * item.GetAttributeF("spread_mod", 1f);
         double speed = Speed * item.GetAttributeF("speed_mod", 1f);
         int shots = (int)((double)Shots * item.GetAttributeF("shots_mod", 1f));
         for (int i = 0; i < shots; i++)
         {
             BulletEntity be = new BulletEntity(character.TheRegion);
             be.SetPosition(character.GetEyePosition()); // TODO: ItemPosition?
             be.NoCollide.Add(character.EID);
             Location ang = character.Direction;
             ang.Yaw += Utilities.UtilRandom.NextDouble() * spread * 2 - spread;
             ang.Pitch += Utilities.UtilRandom.NextDouble() * spread * 2 - spread;
             be.SetVelocity(Utilities.ForwardVector_Deg(ang.Yaw, ang.Pitch) * speed);
             be.Size = RoundSize;
             be.Damage = ImpactDamage;
             be.SplashSize = SplashSize;
             be.SplashDamage = SplashMaxDamage;
             character.TheRegion.SpawnEntity(be);
         }
         if (ShotPerClick)
         {
             character.WaitingForClickRelease = true;
         }
         character.LastGunShot = character.TheRegion.GlobalTickTime;
         item.Datum -= 1;
         if (character is PlayerEntity)
         {
             ((PlayerEntity)character).Network.SendPacket(new SetItemPacketOut(character.Items.Items.IndexOf(item), item));
         }
     }
     else if (item.Datum == 0 && !character.WaitingForClickRelease)
     {
         Reload(character, item);
     }
 }
Exemplo n.º 2
0
 public BulletEntityTag(BulletEntity ent)
 {
     Internal = ent;
 }