private Vector3 AdjustOwnerLabelPosToAvoidOverlapping(Vector3 screenPos, int slotIndex) { Text.Font = GameFont.Tiny; Vector2 vector = Text.CalcSize(owners[slotIndex].LabelShort); float num = vector.x + 1f; Vector2 vector2 = DrawPos.MapToUIPosition(); float num2 = Mathf.Abs(screenPos.x - vector2.x); IntVec3 sleepingSlotPos = GetSleepingSlotPos(slotIndex); if (num > num2 * 2f) { float num3 = 0f; if (slotIndex == 0) { IntVec3 sleepingSlotPos2 = GetSleepingSlotPos(1); num3 = (float)sleepingSlotPos2.x; } else { IntVec3 sleepingSlotPos3 = GetSleepingSlotPos(0); num3 = (float)sleepingSlotPos3.x; } if ((float)sleepingSlotPos.x < num3) { screenPos.x -= (num - num2 * 2f) / 2f; } else { screenPos.x += (num - num2 * 2f) / 2f; } } return(screenPos); }
public override void DrawGUIOverlay() { if (DisplayEnabled) { var text = GenText.ToStringTemperature(lastDetectedTemperature); Text.Font = GameFont.Tiny; float halfHeight = Text.CalcSize(text).y * 0.25f; var ranges = Modes[TemperatureMode]; var normal = RangeLerp(lastDetectedTemperature, ranges.Item1, ranges.Item2); var position = DrawPos.MapToUIPosition(); position.y -= halfHeight; if (!isBlocked) { var labelColor = Color.Lerp(ColdColour, HotColour, normal); labelColor.r += 0.5f; // Brighten labelColor.g += 0.5f; // Brighten labelColor.b += 0.5f; // Brighten GenMapUI.DrawThingLabel(position, text, labelColor); } else { GenMapUI.DrawThingLabel(position, "Blocked!", Color.white); } } }
/* * public override void ExposeData() * { * base.ExposeData(); * Scribe_Values.Look(ref throwerOrigin, "throwerOrigin"); * } */ public override void SpawnSetup(Map map, bool respawningAfterLoad) { base.SpawnSetup(map, respawningAfterLoad); if (HasThrowSound) { ThrowSound.PlayOneShot(new TargetInfo(DrawPos.ToIntVec3(), Map)); } }
public override void Tick() { vehicle.CompVehicleLauncher.launchProtocol.Tick(); if (!DrawPos.InBounds(Map) && vehicle.CompVehicleLauncher.launchProtocol.TicksPassed > def.skyfaller.ticksToImpactRange.max) { ExitMap(); } }
protected override void Explode() { foreach (Pawn tmpPawn in this.tmpPawns) { tmpPawn.Position = DrawPos.ToIntVec3(); DamageInfo dinfo = new DamageInfo(DamageDefOf.Blunt, Mathf.RoundToInt(DamageAmount), 1f, instigator: this.Launcher); tmpPawn.TakeDamage(dinfo); } GenExplosion.DoExplosion(this.Position, this.Map, this.radius * 2f, this.def.projectile.damageDef, this.Launcher, Mathf.RoundToInt(DamageAmount), 1f, this.def.soundImpactDefault); base.Explode(); }
protected virtual void SustainArc() { if (arc == null) { arc = new BezierElectricArc(20); arc.Spawn(Map); } var basePos = DrawPos.WorldToFlat(); arc.P0 = basePos + new Vector2(0, 1.479f); arc.P3 = basePos + new Vector2(ForgeCellIndex == 0 ? 1.524f : -1.524f, 1.633f); arc.P1 = Vector2.Lerp(arc.P0, arc.P3, 0.3f) + new Vector2(0f, 0.65f); arc.P2 = Vector2.Lerp(arc.P0, arc.P3, 0.7f) + new Vector2(0f, 0.65f); arc.Amplitude = new Vector2(0, 0.28f); }
public override Vector2 GetFlatConnectionPoint() { // NESW are 0123 Vector2 root = DrawPos.WorldToFlat(); switch (Rotation.AsInt) { case 0: return(root + new Vector2(0, 0.6f)); case 1: return(root + new Vector2(0.508f, 0.028f)); case 2: return(root + new Vector2(0, -0.421f)); case 3: return(root + new Vector2(-0.508f, 0.028f)); } return(root); }
private Vector3 AdjustOwnerLabelPosToAvoidOverlapping(Vector3 screenPos, int slotIndex) { Text.Font = GameFont.Tiny; float num = Text.CalcSize(OwnersForReading[slotIndex].LabelShort).x + 1f; Vector2 vector = DrawPos.MapToUIPosition(); float num2 = Mathf.Abs(screenPos.x - vector.x); IntVec3 sleepingSlotPos = GetSleepingSlotPos(slotIndex); if (num > num2 * 2f) { float num3 = 0f; num3 = ((slotIndex != 0) ? ((float)GetSleepingSlotPos(0).x) : ((float)GetSleepingSlotPos(1).x)); if ((float)sleepingSlotPos.x < num3) { screenPos.x -= (num - num2 * 2f) / 2f; } else { screenPos.x += (num - num2 * 2f) / 2f; } } return(screenPos); }
protected override void TimeInterval(float deltaTime) { base.TimeInterval(deltaTime); if (Destroyed) { return; } if (!ImpactOccured) { if ((HasFlyingShadow && !IsFlying) || IsGroundShadowOnly) { ImpactOccured = true; StartSustainer(); Tools.Warn("Impact!", MoteSubEffectDebug); if (HasImpactMote) { this.ThrowImpactMote(); } if (exactPosition.ToIntVec3().GetTerrain(Map).IsWater) { if (MSE.HasWaterLandSound) { MSE.waterLandSound.PlayOneShot(new TargetInfo(DrawPos.ToIntVec3(), Map)); } if (MSE.makeWaterSplashOnImpact) { FleckMaker.WaterSplash(exactPosition, Map, 2, Speed * 2); } //MoteMaker.MakeWaterSplash(exactPosition, Map, 2, Speed * 2); if (MSE.destroyParentOnImpact) { this.Destroy(); } } else { if (MSE.HasGroundLandSound) { MSE.groundLandSound.PlayOneShot(new TargetInfo(DrawPos.ToIntVec3(), Map)); } } } } if (SustainerNeedsToStop) { StopSustainer(); } /* * Tools.Warn( * pawn.LabelShort + * " non moving projectile" + * " drawPos: " + DrawPos + * " exactPosition: " + exactPosition + * " Position: " + Position + * " MyPosition: " + MyPosition + * " targetBuildingCoordinates: " + targetBuildingCoordinates * , myDebug * );*/ if (ProjectileStoppedMovingForFirstTime) { /* * Tools.Warn( PawnLabel + " ProjectileStoppedMovingForFirstTime " + * " drawPos: " + DrawPos + " exactPosition: " + exactPosition + * " Position: " + Position + " MyPosition: " + MyPosition + * " targetBuildingCoordinates: " + targetBuildingCoordinates * , ThoughtDebug * ); */ LoggedCoordinates = true; //if (HasTargetingGameParentWithThoughts) { if (HasGameWithThrowThoughts) { //Tools.Warn(PawnLabel + " ProjectileStoppedMovingForFirstTime ", ThoughtDebug); if (IsPlayerPlayingTargetingGame) { //Tools.Warn(PawnLabel + " IsPlayerPlayingTargetingGame ", ThoughtDebug); float ThrowDistance = MyPawn.CalculateThrowDistance(targetBuildingCoordinates, MyPosition, ThoughtDebug); TG_parent.ComputeThrowQuality(ThrowDistance, ThoughtDebug); } } } }
// ================================== /// <summary> /// /// </summary> public override void Tick() { if (!instantiated) { //foreach (Thing thing in GetContainer()) //{ // thing.holder.owner = this; //} currentDriverSpeed = VehicleSpeed; instantiated = true; } base.Tick(); #region Headlights #if Headlights { if (Find.GlowGrid.GameGlowAt(Position - Rotation.FacingCell - Rotation.FacingCell) < 0.4f) { // TODO Add headlights to xml & move the flooder initialization to mountableComp if (mountableComp.Driver != null && !compVehicles.AnimalsCanDrive() && flooder == null) { flooder = new HeadLights(Position, Rotation, this); CustomGlowFloodManager.RegisterFlooder(flooder); CustomGlowFloodManager.RefreshGlowFlooders(); } if (mountableComp.Driver == null && flooder != null) { flooder.Clear(); CustomGlowFloodManager.DeRegisterGlower(flooder); CustomGlowFloodManager.RefreshGlowFlooders(); flooder = null; } // TODO optimized performance, lights only at night and when driver is mounted => light switch gizmo? if (flooder != null) { flooder.Position = Position + Rotation.FacingCell + Rotation.FacingCell; flooder.Orientation = Rotation; flooder.Clear(); flooder.CalculateGlowFlood(); } } if (mountableComp.Driver == null && flooder != null || flooder != null) { CustomGlowFloodManager.DeRegisterGlower(flooder); CustomGlowFloodManager.RefreshGlowFlooders(); flooder = null; } } #endif #endregion if (mountableComp.IsMounted) { if (refuelableComp != null) { if (mountableComp.Driver.Faction != Faction.OfPlayer) { if (!fueledByAI) { if (refuelableComp.FuelPercent < 0.550000011920929) { refuelableComp.Refuel( ThingMaker.MakeThing(refuelableComp.Props.fuelFilter.AllowedThingDefs.FirstOrDefault())); } else { fueledByAI = true; } } } } if (mountableComp.Driver.pather.Moving) // || mountableComp.Driver.drafter.pawn.pather.Moving) { if (!mountableComp.Driver.stances.FullBodyBusy && axlesComp.HasAxles()) { wheelRotation += currentDriverSpeed / 3f; tick_time += 0.01f * currentDriverSpeed / 5f; } if (mountableComp.Driver.Position.AdjacentTo8WayOrInside(mountableComp.Driver.pather.Destination.Cell) && axlesComp.HasAxles()) { // Make the breaks sound once and throw some dust if Driver comes to his destination if (!soundPlayed) { SoundDef.Named("VehicleATV_Ambience_Break").PlayOneShot(mountableComp.Driver.Position); MoteMaker.ThrowDustPuff(DrawPos, 0.8f); soundPlayed = true; } } else { soundPlayed = false; } // TODO move all variables like smoke amount and break sound to xml etc. if (Find.TerrainGrid.TerrainAt(DrawPos.ToIntVec3()).takeFootprints || Find.SnowGrid.GetDepth(DrawPos.ToIntVec3()) > 0.2f) { if (vehicleComp.LeaveTrail()) { Vector3 normalized = (DrawPos - _lastFootprintPlacePos).normalized; float rot = normalized.AngleFlat(); Vector3 loc = DrawPos + TrailOffset; if ((loc - _lastFootprintPlacePos).MagnitudeHorizontalSquared() > FootprintIntervalDist) { if (loc.ShouldSpawnMotesAt() && !MoteCounter.SaturatedLowPriority) { MoteThrown moteThrown = (MoteThrown)ThingMaker.MakeThing(ThingDef.Named("Mote_Trail_ATV")); moteThrown.exactRotation = rot; moteThrown.exactPosition = loc; GenSpawn.Spawn(moteThrown, loc.ToIntVec3()); _lastFootprintPlacePos = DrawPos; } } } if (axlesComp.HasAxles()) { MoteMaker.ThrowDustPuff(DrawPos + DustOffset, 0.15f + Mathf.InverseLerp(0, 50, currentDriverSpeed) * 0.6f); } else { MoteMaker.ThrowDustPuff(DrawPos + DustOffset, 0.15f + Mathf.InverseLerp(0, 50, VehicleSpeed) * 0.6f); } } } //Exhaustion fumes - basic // only fumes on vehicles with combustion and no animals driving if (!vehicleComp.MotorizedWithoutFuel() && !vehicleComp.AnimalsCanDrive()) { MoteMaker.ThrowSmoke(DrawPos + FumesOffset, 0.05f + currentDriverSpeed * 0.01f); } if (Find.TickManager.TicksGame - tickCheck >= tickCooldown) { if (mountableComp.Driver.pather.Moving) { if (!mountableComp.Driver.stances.FullBodyBusy) { if (refuelableComp != null) { refuelableComp.Notify_UsedThisTick(); } damagetick -= 1; if (axlesComp.HasAxles()) { currentDriverSpeed = ToolsForHaulUtility.GetMoveSpeed(mountableComp.Driver); } } if (breakdownableComp != null && breakdownableComp.BrokenDown || refuelableComp != null && !refuelableComp.HasFuel) { VehicleSpeed = 0.75f; } else { VehicleSpeed = DesiredSpeed; } tickCheck = Find.TickManager.TicksGame; } if (Position.InNoBuildEdgeArea() && despawnAtEdge && Spawned && (mountableComp.Driver.Faction != Faction.OfPlayer || mountableComp.Driver.MentalState.def == MentalStateDefOf.PanicFlee)) { DeSpawn(); } } } //if (Find.TickManager.TicksGame >= damagetick) //{ // TakeDamage(new DamageInfo(DamageDefOf.Deterioration, 1, null, null, null)); // damagetick = Find.TickManager.TicksGame + 3600; //} if (vehicleComp.tankLeaking) { if (Find.TickManager.TicksGame > _tankSpillTick) { if (refuelableComp.FuelPercent > _tankHitPos) { refuelableComp.ConsumeFuel(0.15f); FilthMaker.MakeFilth(Position, fuelDefName, LabelCap); _tankSpillTick = Find.TickManager.TicksGame + 15; } } } }
public override void Tick() { Position = DrawPos.ToIntVec3(); base.Tick(); }