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 override void PostExposeData() { base.PostExposeData(); Scribe_Values.Look <float>(ref this.storedBlood, "storedBlood", 0f, false); CompProperties_BloodTank props = this.Props; if (this.storedBlood > props.storedBloodMax) { this.storedBlood = props.storedBloodMax; } Thing thing = null; if (Scribe.mode == LoadSaveMode.Saving && this.connectParent != null) { thing = this.connectParent.parent; } Scribe_References.Look <Thing>(ref thing, "parentThing", false); if (thing != null) { this.connectParent = ((ThingWithComps)thing).GetComp <CompBloodTank>(); } if (Scribe.mode == LoadSaveMode.PostLoadInit && this.connectParent != null) { //this.ConnectToTransmitter(this.connectParent, true); } }
public void SetUpConnections() { Map map = this.parent.MapHeld; if (map != null) { if (this.parent != null) { //Hubs need generators if (this.parent is Building_BloodHub) { IEnumerable <Building_BloodCollector> bloodTanks = map.listerBuildings.AllBuildingsColonistOfClass <Building_BloodCollector>(); if (bloodTanks != null) { foreach (Building_BloodCollector current in bloodTanks) { if (current.TryGetComp <CompBloodTank>() != null) { connectChildren.Add(current.TryGetComp <CompBloodTank>()); } } } } //Tanks / Blood users need hubs else { connectParent = FindNearestHub().TryGetComp <CompBloodTank>(); } } } }
public virtual void LostConnectChild(CompBloodTank tank) { if (tank != null) { if (this.connectChildren != null && this.connectChildren.Count > 0) { if (this.connectChildren.Contains(tank)) { this.connectChildren.Remove(tank); } } } }
public virtual void LostConnectParent() { this.connectParent = null; //this.parent.Map.powerNetManager.Notify_ConnectorWantsConnect(this); }
public virtual void ResetBloodVars() { this.connectParent = null; this.connectChildren = null; }