blob: a58bdb18f06da01c2ad4cdd23eaf00752c6e91d3 (
plain)
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
|
using MurderGame;
using Sandbox;
using System;
public partial class DroppedWeapon : AnimatedEntity
{
public int Ammo { get; set; }
public Type WeaponType { get; set; }
public DroppedWeapon(Weapon weapon) : this()
{
Ammo = weapon.Ammo;
WeaponType = weapon.GetType();
}
public DroppedWeapon()
{
Tags.Add("droppedweapon");
PhysicsEnabled = true;
UsePhysicsCollision = true;
EnableSelfCollisions = true;
EnableSolidCollisions = true;
}
public override void StartTouch( Entity other )
{
if ( !Game.IsServer ) return;
if ( !other.Tags.Has( "livingplayer" ) ) return;
MurderGame.Player player = (MurderGame.Player)other;
if ( player.Inventory== null || player.Inventory.PrimaryWeapon != null || !player.Inventory.AllowPickup) return;
Weapon instance = TypeLibrary.Create<Weapon>( WeaponType );
instance.Ammo = Ammo;
player.Inventory.SetPrimaryWeapon( instance );
Delete();
}
}
|