public static void DrawInteractionCell(ThingDef tDef, IntVec3 center, Rot4 placingRot) { if (tDef.hasInteractionCell) { IntVec3 c = ThingUtility.InteractionCellWhenAt(tDef, center, placingRot, Find.CurrentMap); Vector3 vector = c.ToVector3ShiftedWithAltitude(AltitudeLayer.MetaOverlays); if (c.InBounds(Find.CurrentMap)) { Building edifice = c.GetEdifice(Find.CurrentMap); if (edifice != null && edifice.def.building != null && edifice.def.building.isSittable) { return; } } if (tDef.interactionCellGraphic == null && tDef.interactionCellIcon != null) { ThingDef thingDef = tDef.interactionCellIcon; if (thingDef.blueprintDef != null) { thingDef = thingDef.blueprintDef; } tDef.interactionCellGraphic = thingDef.graphic.GetColoredVersion(ShaderTypeDefOf.EdgeDetect.Shader, InteractionCellIntensity, Color.white); } if (tDef.interactionCellGraphic != null) { Rot4 rot = (!tDef.interactionCellIconReverse) ? placingRot : placingRot.Opposite; tDef.interactionCellGraphic.DrawFromDef(vector, rot, tDef.interactionCellIcon); } else { Graphics.DrawMesh(MeshPool.plane10, vector, Quaternion.identity, InteractionCellMaterial, 0); } } }
public virtual bool TryAbsorbStack(Thing other, bool respectStackLimit) { if (!CanStackWith(other)) { return(false); } int num = ThingUtility.TryAbsorbStackNumToTake(this, other, respectStackLimit); if (def.useHitPoints) { HitPoints = Mathf.CeilToInt((float)(HitPoints * stackCount + other.HitPoints * num) / (float)(stackCount + num)); } stackCount += num; other.stackCount -= num; StealAIDebugDrawer.Notify_ThingChanged(this); if (Spawned) { Map.listerMergeables.Notify_ThingStackChanged(this); } if (other.stackCount <= 0) { other.Destroy(); return(true); } return(false); }
public override void Destroy(DestroyMode mode = DestroyMode.Vanish) { bool spawned = base.Spawned; Map map = base.Map; SmoothableWallUtility.Notify_BuildingDestroying(this, mode); this.GetLord()?.Notify_BuildingLost(this); base.Destroy(mode); InstallBlueprintUtility.CancelBlueprintsFor(this); if (spawned) { switch (mode) { case DestroyMode.Deconstruct: SoundDefOf.Building_Deconstructed.PlayOneShot(new TargetInfo(base.Position, map)); break; case DestroyMode.KillFinalize: DoDestroyEffects(map); break; } } if (spawned) { ThingUtility.CheckAutoRebuildOnDestroyed(this, mode, map, def); } }
public void Notify_TerrainDestroyed(IntVec3 c) { if (CanRemoveTopLayerAt(c)) { TerrainDef terrainDef = TerrainAt(c); RemoveTopLayer(c, doLeavings: false); if (terrainDef.destroyBuildingsOnDestroyed) { c.GetFirstBuilding(map)?.Kill(); } if (terrainDef.destroyEffectWater != null && TerrainAt(c) != null && TerrainAt(c).IsWater) { Effecter effecter = terrainDef.destroyEffectWater.Spawn(); effecter.Trigger(new TargetInfo(c, map), new TargetInfo(c, map)); effecter.Cleanup(); } else if (terrainDef.destroyEffect != null) { Effecter effecter2 = terrainDef.destroyEffect.Spawn(); effecter2.Trigger(new TargetInfo(c, map), new TargetInfo(c, map)); effecter2.Cleanup(); } ThingUtility.CheckAutoRebuildTerrainOnDestroyed(terrainDef, c, map); } }
public static void DrawInteractionCell(ThingDef tDef, IntVec3 center, Rot4 placingRot) { if (tDef.hasInteractionCell) { Vector3 position = ThingUtility.InteractionCellWhenAt(tDef, center, placingRot, Find.VisibleMap).ToVector3ShiftedWithAltitude(AltitudeLayer.MetaOverlays); Graphics.DrawMesh(MeshPool.plane10, position, Quaternion.identity, GenDraw.InteractionCellMaterial, 0); } }
public override bool TryAbsorbStack(Thing other, bool respectStackLimit) { if (!this.CanStackWith(other)) { return(false); } int count = ThingUtility.TryAbsorbStackNumToTake(this, other, respectStackLimit); if (this.comps != null) { for (int i = 0; i < this.comps.Count; i++) { this.comps[i].PreAbsorbStack(other, count); } } return(base.TryAbsorbStack(other, respectStackLimit)); }
public override void Destroy(DestroyMode mode = DestroyMode.Vanish) { bool spawned = base.Spawned; Map map = base.Map; SmoothableWallUtility.Notify_BuildingDestroying(this, mode); base.Destroy(mode); InstallBlueprintUtility.CancelBlueprintsFor(this); if (mode == DestroyMode.Deconstruct && spawned) { SoundDefOf.Building_Deconstructed.PlayOneShot(new TargetInfo(base.Position, map, false)); } if (spawned) { ThingUtility.CheckAutoRebuildOnDestroyed(this, mode, map, this.def); } }
public virtual bool TryAbsorbStack(Thing other, bool respectStackLimit) { if (!this.CanStackWith(other)) { return(false); } int num = ThingUtility.TryAbsorbStackNumToTake(this, other, respectStackLimit); if (this.def.useHitPoints) { this.HitPoints = Mathf.CeilToInt((float)(this.HitPoints * this.stackCount + other.HitPoints * num) / (float)(this.stackCount + num)); } this.stackCount += num; other.stackCount -= num; StealAIDebugDrawer.Notify_ThingChanged(this); if (other.stackCount <= 0) { other.Destroy(DestroyMode.Vanish); return(true); } return(false); }
public override void Destroy(DestroyMode mode = DestroyMode.Vanish) { bool wasSpawned = Spawned; var map = Map; // before Destroy()! // before Destroy(); the math is easier to do here SmoothableWallUtility.Notify_BuildingDestroying(this, mode); base.Destroy(mode); // (buildings can be reinstalled) InstallBlueprintUtility.CancelBlueprintsFor(this); if (mode == DestroyMode.Deconstruct && wasSpawned) { SoundDefOf.Building_Deconstructed.PlayOneShot(new TargetInfo(Position, map)); } if (wasSpawned) { ThingUtility.CheckAutoRebuildOnDestroyed(this, mode, map, def); } }
public static DamageDef PrimaryMeleeWeaponDamageType(ThingDef thing) { return(ThingUtility.PrimaryMeleeWeaponDamageType(thing.tools)); }