using UnityEngine;
using System.Collections.Generic;
using System.Linq;
using Verse.Sound;
using Verse;

namespace RimWorld{
public class Bullet : Projectile
{
	protected override void Impact(Thing hitThing)
	{
		var map = Map; // before Impact!

		base.Impact(hitThing);
		
		var impact = new BattleLogEntry_RangedImpact(launcher, hitThing, intendedTarget, equipmentDef, def);
		Find.BattleLog.Add(impact);

		if( hitThing != null )
		{
			int dmgAmount = def.projectile.damageAmountBase;
			DamageInfo dinfo = new DamageInfo(def.projectile.damageDef, dmgAmount, angle: ExactRotation.eulerAngles.y, instigator: launcher, weapon: equipmentDef);
			hitThing.TakeDamage(dinfo).InsertIntoLog(impact);
		}
		else
		{
			SoundDefOf.BulletImpactGround.PlayOneShot(new TargetInfo(Position, map));
			MoteMaker.MakeStaticMote(ExactPosition, map, ThingDefOf.Mote_ShotHit_Dirt);

			if( Position.GetTerrain(map).takeSplashes )
			{
				MoteMaker.MakeWaterSplash(ExactPosition, map, Mathf.Sqrt(def.projectile.damageAmountBase) * MoteSplash.SizeGunfire, MoteSplash.VelocityGunfire);
			}
		}
	}
}

/*
public class BulletIncendiary : Bullet
{
protected override void Impact(Thing hitThing)
{
	base.Impact(hitThing);

	if( hitThing != null )
		hitThing.TryAttachFire(0.2f);
	else
	{
		GenSpawn.Spawn( ThingDefOf.Puddle_Fuel, Position);

		FireUtility.TryStartFireIn(Position, 0.2f);
	}

	MoteThrower.ThrowStatic(Position, ThingDefOf.Mote_ShotFlash, 6f );
	MoteThrower.ThrowMicroSparks(Position.ToVector3Shifted());
}
}*/
}