protected override void Impact(Thing hitThing)
        {
            Map map = base.Map;

            base.Impact(hitThing);
            if (hitThing != null)
            {
                if (hitThing is Building_BloodHub)
                {
                    Building_BloodHub hub           = hitThing as Building_BloodHub;
                    CompBloodTank     compBloodTank = hub.GetComp <CompBloodTank>();
                    if (compBloodTank != null)
                    {
                        compBloodTank.AddBlood(bloodAmount);
                    }
                }
                //int damageAmountBase = this.def.projectile.damageAmountBase;
                //ThingDef equipmentDef = this.equipmentDef;
                //DamageInfo dinfo = new DamageInfo(this.def.projectile.damageDef, damageAmountBase, this.ExactRotation.eulerAngles.y, this.launcher, null, equipmentDef);
                //hitThing.TakeDamage(dinfo);
            }
            else
            {
                //SoundDefOf.BulletImpactGround.PlayOneShot(new TargetInfo(base.Position, map, false));
                //MoteMaker.MakeStaticMote(this.ExactPosition, map, ThingDefOf.Mote_ShotHit_Dirt, 1f);
            }
        }
        public Building_BloodHub FindNearestHub()
        {
            Building_BloodHub parentCandidate = null;

            Map map = this.parent.MapHeld;

            if (map != null)
            {
                IEnumerable <Building_BloodHub> bloodHubs = map.listerBuildings.AllBuildingsColonistOfClass <Building_BloodHub>();
                if (bloodHubs != null)
                {
                    if (this.parent.Position != null)
                    {
                        float num = -1;
                        foreach (Building_BloodHub hub in bloodHubs)
                        {
                            if (hub.Position != null)
                            {
                                float num2 = hub.Position.DistanceToSquared(this.parent.Position);
                                if (num2 < num || parentCandidate == null)
                                {
                                    parentCandidate = hub;
                                    num             = num2;
                                }
                            }
                        }
                    }
                }
            }
            return(parentCandidate);
        }
Esempio n. 3
0
        public void SendBloodMist(Building_BloodHub hub)
        {
            BloodTank.DrawBlood(bloodMistAmount);
            Vector3 drawPos = this.DrawPos;
            Projectile_BloodMist projectile = (Projectile_BloodMist)GenSpawn.Spawn(ThingDef.Named("Uvhash_BloodMist"), this.PositionHeld, this.Map);

            projectile.bloodAmount = bloodMistAmount;
            projectile.Launch(this, drawPos, hub.Position, null);
            //hub.TryGetComp<CompBloodTank>().AddBlood(bloodMistAmount);
        }
Esempio n. 4
0
 public override void Tick()
 {
     base.Tick();
     if (BloodTank != null)
     {
         Building_BloodHub hub = BloodTank.FindNearestHub();
         if (hub != null)
         {
             if (BloodTank.TransmitsBloodNow)
             {
                 SendBloodMist(hub);
             }
         }
     }
 }