public virtual void NextWeapon() { int index = weapons.IndexOf(currentWeapon); //increment weapon or go to start of weapons list index = index + 1; while (index <= weapons.Count) { if (index >= weapons.Count) { index = 0; break; } if (weapons[index] != null) { break; } index++; } currentWeapon = weapons[index]; //log if a remote player switched weapons if (this != GameObject.GetCameraTarget()) { string otherName = this.GetOwner().GetName(); string weapType = currentWeapon.GetTypeOf(); Log.getLog().addEvent(otherName + " switched to weapon of type " + weapType); } }