// Token: 0x0600005E RID: 94 RVA: 0x00004008 File Offset: 0x00002208 public override void DrawWornExtras() { if (this.ShieldState == ShieldState.Active && this.ShouldDisplay) { float num = Mathf.Lerp(1.2f, 1.55f, this.energy); Vector3 vector = base.Wearer.Drawer.DrawPos; vector.y = Altitudes.AltitudeFor(AltitudeLayer.MoteOverhead); int num2 = Find.TickManager.TicksGame - this.lastAbsorbDamageTick; if (num2 < 8) { float num3 = (float)(8 - num2) / 8f * 0.05f; vector += this.impactAngleVect * num3; num -= num3; } Rand.PushState(); float angle = (float)Rand.Range(0, 360); Rand.PopState(); Vector3 s = new Vector3(num + base.Wearer.Drawer.renderer.graphics.nakedGraphic.drawSize.x, 1f, num + base.Wearer.Drawer.renderer.graphics.nakedGraphic.drawSize.y); Matrix4x4 matrix = default(Matrix4x4); matrix.SetTRS(vector, Quaternion.AngleAxis(angle, Vector3.up), s); Graphics.DrawMesh(MeshPool.plane10, matrix, AdvShieldBelt.BubbleMat, 0); } }
// Token: 0x0600005E RID: 94 RVA: 0x00004008 File Offset: 0x00002208 public override void DrawWornExtras() { if (this.cloakMode == CloakMode.On && this.ShouldDisplay) { // Wearer.Graphic.color.a = 0.25f; //Wearer.Drawer.renderer.graphics.pawn.DefaultGraphic.color.a = 0.25f; float num = Mathf.Lerp(1.2f, 1.55f, this.energy); Vector3 vector = base.Wearer.Drawer.DrawPos; vector.y = Altitudes.AltitudeFor(AltitudeLayer.MoteOverhead); int num2 = Find.TickManager.TicksGame - this.lastAbsorbDamageTick; if (num2 < 8) { float num3 = (float)(8 - num2) / 8f * 0.05f; vector += this.impactAngleVect * num3; num -= num3; } float angle = 0f;// (float)Rand.Range(0, 360); Vector3 s = new Vector3(num, 1f, num); Matrix4x4 matrix = default(Matrix4x4); matrix.SetTRS(vector, Quaternion.AngleAxis(angle, Vector3.up), s); Graphics.DrawMesh(MeshPool.plane10, matrix, Cloakgen.BubbleMat, 0); } }
public void DrawLinesBetweenTargets() { Vector3 a = this.pawn.Position.ToVector3Shifted(); if (this.pawn.pather.curPath != null) { a = this.pawn.pather.Destination.CenterVector3; } else if (this.curJob != null && this.curJob.targetA.IsValid && (!this.curJob.targetA.HasThing || this.curJob.targetA.Thing.Spawned)) { GenDraw.DrawLineBetween(a, this.curJob.targetA.CenterVector3, Altitudes.AltitudeFor(AltitudeLayer.Item)); a = this.curJob.targetA.CenterVector3; } for (int i = 0; i < this.jobQueue.Count; i++) { if (this.jobQueue[i].job.targetA.IsValid && (!this.jobQueue[i].job.targetA.HasThing || this.jobQueue[i].job.targetA.Thing.Spawned)) { Vector3 centerVector = this.jobQueue[i].job.targetA.CenterVector3; GenDraw.DrawLineBetween(a, centerVector, Altitudes.AltitudeFor(AltitudeLayer.Item)); a = centerVector; } } }
public static void CalculateSelectionBracketPositionsWorld <T>(Vector3[] bracketLocs, T obj, Vector3 worldPos, Vector2 worldSize, Dictionary <T, float> selectTimes, Vector2 textureSize, float jumpDistanceFactor = 1f) { float num; float num2; if (!selectTimes.TryGetValue(obj, out num)) { num2 = 1f; } else { num2 = Mathf.Max(0f, 1f - (Time.realtimeSinceStartup - num) / 0.07f); } float num3 = num2 * 0.2f * jumpDistanceFactor; float num4 = 0.5f * (worldSize.x - textureSize.x) + num3; float num5 = 0.5f * (worldSize.y - textureSize.y) + num3; float y = Altitudes.AltitudeFor(AltitudeLayer.MetaOverlays); bracketLocs[0] = new Vector3(worldPos.x - num4, y, worldPos.z - num5); bracketLocs[1] = new Vector3(worldPos.x + num4, y, worldPos.z - num5); bracketLocs[2] = new Vector3(worldPos.x + num4, y, worldPos.z + num5); bracketLocs[3] = new Vector3(worldPos.x - num4, y, worldPos.z + num5); }
public override void Draw() { if (this.IsActive) { Vector3 vector = base.DrawPos; vector.y = Altitudes.AltitudeFor(AltitudeLayer.Blueprint); Vector3 s = new Vector3(matMagnitude, 2 * matMagnitude, matMagnitude); Quaternion quaternion = Quaternion.AngleAxis(Rotation.AsAngle, Vector3.up); Matrix4x4 matrix = default(Matrix4x4); float angle = this.ExactRotation; matrix.SetTRS(vector, Quaternion.AngleAxis(angle, Vector3.up), s); if (this.Rotation == Rot4.North) { Graphics.DrawMesh(MeshPool.plane10, matrix, TM_RenderQueue.mc_north, 0); } else if (this.Rotation == Rot4.South) { Graphics.DrawMesh(MeshPool.plane10, matrix, TM_RenderQueue.mc_south, 0); } else if (this.Rotation == Rot4.East) { Graphics.DrawMesh(MeshPool.plane10, matrix, TM_RenderQueue.mc_east, 0); } else if (this.Rotation == Rot4.West) { Graphics.DrawMesh(MeshPool.plane10, matrix, TM_RenderQueue.mc_west, 0); } else { Graphics.DrawMesh(MeshPool.plane10, matrix, TM_RenderQueue.mc_north, 0); } } else { base.Draw(); } }
//[ReloadMethod] public void DrawStretchParams(DoorExpandedDef thingDef, Vector3 drawPos, Rot4 rotation, out Mesh mesh, out Matrix4x4 matrix, float mod = 1, bool flipped = false) { base.Rotation = Building_Door.DoorRotationAt(base.Position, base.Map); bool verticalRotation = base.Rotation.IsHorizontal; Vector3 rotationVector = default(Vector3); if (!flipped) { rotationVector = new Vector3(0f, 0f, -1f); mesh = MeshPool.plane10; } else { rotationVector = new Vector3(0f, 0f, 1f); mesh = MeshPool.plane10Flip; } rotation.Rotate(RotationDirection.Clockwise); rotationVector = rotation.AsQuat * rotationVector; Vector3 graphicVector = drawPos; graphicVector.y = Altitudes.AltitudeFor(AltitudeLayer.DoorMoveable); graphicVector += rotationVector * (mod * 1.15f); //Vector3 scaleVector = new Vector3(thingDef.graphicData.drawSize.x, 1f, thingDef.graphicData.drawSize.y); float persMod = (thingDef.fixedPerspective) ? 2f : 1f; Vector3 scaleVector = (verticalRotation) ? new Vector3((thingDef.graphicData.drawSize.x * persMod) - mod * 1.3f, 1f, thingDef.graphicData.drawSize.y * persMod) : new Vector3((thingDef.graphicData.drawSize.x) - mod * 1.3f, 1f, thingDef.graphicData.drawSize.y); matrix = default(Matrix4x4); matrix.SetTRS(graphicVector, base.Rotation.AsQuat, scaleVector); }
public override void PostDraw() { base.PostDraw(); if (this.TicksLeft <= 0) { return; } Vector3 drawPos = this.parent.DrawPos; float num = ((float)this.parent.Map.Size.z - drawPos.z) * 1.41421354f; Vector3 a = Vector3Utility.FromAngleFlat(this.angle - 90f); Vector3 a2 = drawPos + a * num * 0.5f; a2.y = Altitudes.AltitudeFor(AltitudeLayer.MetaOverlays); float num2 = Mathf.Min((float)this.TicksPassed / 10f, 1f); Vector3 b = a * ((1f - num2) * num); float num3 = 0.975f + Mathf.Sin((float)this.TicksPassed * 0.3f) * 0.025f; if (this.TicksLeft < this.fadeOutDuration) { num3 *= (float)this.TicksLeft / (float)this.fadeOutDuration; } Color color = this.Props.color; color.a *= num3; CompOrbitalBeam.MatPropertyBlock.SetColor(ShaderPropertyIDs.Color, color); Matrix4x4 matrix = default(Matrix4x4); matrix.SetTRS(a2 + a * this.BeamEndHeight * 0.5f + b, Quaternion.Euler(0f, this.angle, 0f), new Vector3(this.Props.width, 1f, num)); Graphics.DrawMesh(MeshPool.plane10, matrix, CompOrbitalBeam.BeamMat, 0, null, 0, CompOrbitalBeam.MatPropertyBlock); Vector3 pos = drawPos + b; pos.y = Altitudes.AltitudeFor(AltitudeLayer.MetaOverlays); Matrix4x4 matrix2 = default(Matrix4x4); matrix2.SetTRS(pos, Quaternion.Euler(0f, this.angle, 0f), new Vector3(this.Props.width, 1f, this.BeamEndHeight)); Graphics.DrawMesh(MeshPool.plane10, matrix2, CompOrbitalBeam.BeamEndMat, 0, null, 0, CompOrbitalBeam.MatPropertyBlock); }
protected Mesh createCrossOut() { Mesh m = new Mesh(); float y = Altitudes.AltitudeFor(AltitudeLayer.MapDataOverlay); const float xPixelSize = 1f / 15f; const float zPixelSize = 1f / 15f; m.name = "CrossOut"; List <Vector3> vertices = new List <Vector3>(8); List <Color> colors = new List <Color>(8); int[] triangles = new int[12]; vertices.Add(new Vector3(xPixelSize * 3f, y, zPixelSize * 1f)); vertices.Add(new Vector3(xPixelSize * 14f, y, zPixelSize * 12f)); vertices.Add(new Vector3(xPixelSize * 12f, y, zPixelSize * 14f)); vertices.Add(new Vector3(xPixelSize * 1f, y, zPixelSize * 3f)); triangles[0] = 0; triangles[1] = 2; triangles[2] = 1; triangles[3] = 0; triangles[4] = 3; triangles[5] = 2; vertices.Add(new Vector3(xPixelSize * 1f, y, zPixelSize * 12f)); vertices.Add(new Vector3(xPixelSize * 3f, y, zPixelSize * 14f)); vertices.Add(new Vector3(xPixelSize * 14f, y, zPixelSize * 3f)); vertices.Add(new Vector3(xPixelSize * 12f, y, zPixelSize * 1f)); triangles[6] = 4; triangles[7] = 5; triangles[8] = 6; triangles[9] = 4; triangles[10] = 6; triangles[11] = 7; for (int i = 0; i < vertices.Count; i++) { colors.Add(Color.black); } m.SetVertices(vertices); m.SetColors(colors); m.SetTriangles(triangles, 0); return(m); }
public override void PostDraw() { //Log.Message("DrawComp"); base.PostDraw(); if (!IsActive() || !zzShieldShowVisually) { return; } Vector3 pos = this.parent.Position.ToVector3Shifted(); pos.y = Altitudes.AltitudeFor(AltitudeLayer.MoteOverhead); float alpha = this.Alpha(); int radius = ShieldRadius_Current; if (alpha > 0f) { Color value = Color.white; value.a *= alpha; Comp_ShieldGenerator.PropBlock.SetColor(ShaderPropertyIDs.Color, value); Matrix4x4 matrix = default(Matrix4x4); matrix.SetTRS(pos, Quaternion.identity, new Vector3(radius * 2.1f, 1f, radius * 2.1f)); Graphics.DrawMesh(MeshPool.plane10, matrix, Resources.Materials.ShieldMaterial, 0, null, 0, Comp_ShieldGenerator.PropBlock); } float coneAlpha = this.HitConeAlpha(); if (coneAlpha > 0f) { Color color = Color.white; color.a *= coneAlpha; Comp_ShieldGenerator.PropBlock.SetColor(ShaderPropertyIDs.Color, color); Matrix4x4 matrix2 = default(Matrix4x4); matrix2.SetTRS(pos, Quaternion.Euler(0f, this.lastInterceptAngle - 90f, 0f), new Vector3(radius * 2.3f, 1f, radius * 2.3f)); Graphics.DrawMesh(MeshPool.plane10, matrix2, Resources.Materials.ConeMaterial, 0, null, 0, Comp_ShieldGenerator.PropBlock); } //this.DrawShields(); }
new public static void DrawDropSpotShadow(Vector3 center, Rot4 rot, Material material, Vector2 shadowSize, int ticksToImpact) { if (rot.IsHorizontal) { Gen.Swap <float>(ref shadowSize.x, ref shadowSize.y); } ticksToImpact = Mathf.Max(ticksToImpact, 0); Vector3 pos = center; pos.y = Altitudes.AltitudeFor(AltitudeLayer.Shadows); float num = 1f + (float)ticksToImpact / 100f; Vector3 s = new Vector3(num * shadowSize.x, 1f, num * shadowSize.y); Color white = Color.white; if (ticksToImpact > 150) { white.a = Mathf.InverseLerp(200f, 150f, (float)ticksToImpact); } TM_Skyfaller.shadowPropertyBlock.SetColor(ShaderPropertyIDs.Color, white); Matrix4x4 matrix = default(Matrix4x4); matrix.SetTRS(pos, rot.AsQuat, s); Graphics.DrawMesh(MeshPool.plane10Back, matrix, material, 0, null, 0, TM_Skyfaller.shadowPropertyBlock); }
public override void DrawExtraSelectionOverlays() // Draw at range less than 1.42 tiles { float range = this.GunCompEq.PrimaryVerb.verbProps.range; if (range < 90f) { GenDraw.DrawRadiusRing(base.Position, range); } float minRange = AttackVerb.verbProps.minRange; // Changed to minRange instead of EffectiveMinRange if (minRange < 90f && minRange > 0.1f) { GenDraw.DrawRadiusRing(base.Position, minRange); } if (this.WarmingUp) { int degreesWide = (int)((float)this.burstWarmupTicksLeft * 0.5f); GenDraw.DrawAimPie(this, this.CurrentTarget, degreesWide, def.size.x * 0.5f); } if (this.forcedTarget.IsValid && (!this.forcedTarget.HasThing || this.forcedTarget.Thing.Spawned)) { Vector3 b; if (this.forcedTarget.HasThing) { b = this.forcedTarget.Thing.TrueCenter(); } else { b = this.forcedTarget.Cell.ToVector3Shifted(); } Vector3 a = this.TrueCenter(); b.y = Altitudes.AltitudeFor(AltitudeLayer.MetaOverlays); a.y = b.y; GenDraw.DrawLineBetween(a, b, Building_TurretGun.ForcedTargetLineMat); } }
public static void DrawParams(DoorExpandedDef thingDef, Vector3 drawPos, Rot4 rotation, out Mesh mesh, out Matrix4x4 matrix, float mod = 1, bool flipped = false) { bool verticalRotation = rotation.IsHorizontal; Vector3 rotationVector = default(Vector3); if (!flipped) { rotationVector = new Vector3(-1f, 0f, 0f); mesh = MeshPool.plane10; } else { rotationVector = new Vector3(1f, 0f, 0f); mesh = MeshPool.plane10Flip; } Quaternion rotQuat = rotation.AsQuat; rotationVector = rotQuat * rotationVector; Vector3 graphicVector = drawPos; graphicVector.y = Altitudes.AltitudeFor(AltitudeLayer.DoorMoveable); graphicVector += rotationVector * mod; //Vector3 scaleVector = new Vector3(thingDef.graphicData.drawSize.x, 1f, thingDef.graphicData.drawSize.y); float persMod = (thingDef.fixedPerspective) ? 2f : 1f; Vector3 scaleVector = (verticalRotation) ? new Vector3(thingDef.graphicData.drawSize.x * persMod, 1f, thingDef.graphicData.drawSize.y * persMod) : new Vector3(thingDef.graphicData.drawSize.x, 1f, thingDef.graphicData.drawSize.y); matrix = default(Matrix4x4); matrix.SetTRS(graphicVector, rotQuat, scaleVector); }
private void DrawTornadoPart(float distanceFromCenter, float initialAngle, float speedMultiplier, float colorMultiplier) { int ticksGame = Find.TickManager.TicksGame; float num = (float)(1.0 / distanceFromCenter); float num2 = (float)(25.0 * speedMultiplier * num); float num3 = (float)((initialAngle + (float)ticksGame * num2) % 360.0); Vector2 vector = this.realPosition.Moved(num3, this.AdjustedDistanceFromCenter(distanceFromCenter)); vector.y += (float)(distanceFromCenter * 4.0); vector.y += Tornado.ZOffsetBias; Vector3 a = new Vector3(vector.x, (float)(Altitudes.AltitudeFor(AltitudeLayer.Weather) + 0.046875 * Rand.Range(0f, 1f)), vector.y); float num4 = (float)(distanceFromCenter * 3.0); float num5 = 1f; if (num3 > 270.0) { num5 = GenMath.LerpDouble(270f, 360f, 0f, 1f, num3); } else if (num3 > 180.0) { num5 = GenMath.LerpDouble(180f, 270f, 1f, 0f, num3); } FloatRange partsDistanceFromCenter = Tornado.PartsDistanceFromCenter; float num6 = Mathf.Min((float)(distanceFromCenter / (partsDistanceFromCenter.max + 2.0)), 1f); float d = Mathf.InverseLerp(0.18f, 0.4f, num6); Vector3 a2 = new Vector3((float)(Mathf.Sin((float)((float)ticksGame / 1000.0 + (float)(base.thingIDNumber * 10))) * 2.0), 0f, 0f); a += a2 * d; float a3 = Mathf.Max((float)(1.0 - num6), 0f) * num5 * this.FadeInOutFactor; Color value = new Color(colorMultiplier, colorMultiplier, colorMultiplier, a3); Tornado.matPropertyBlock.SetColor(ShaderPropertyIDs.Color, value); Matrix4x4 matrix = Matrix4x4.TRS(a, Quaternion.Euler(0f, num3, 0f), new Vector3(num4, 1f, num4)); Graphics.DrawMesh(MeshPool.plane10, matrix, Tornado.TornadoMaterial, 0, null, 0, Tornado.matPropertyBlock); }
public override void Draw() { base.Draw(); Vector3 drawPos = base.Position.ToVector3Shifted(); // this.parent.DrawPos; drawPos.z = drawPos.z - 1.5f; float num = ((float)base.Map.Size.z - drawPos.z) * 1.41421354f; Vector3 a = Vector3Utility.FromAngleFlat(this.angle - 90f); Vector3 a2 = drawPos + a * num * 0.5f; a2.y = Altitudes.AltitudeFor(AltitudeLayer.MetaOverlays); float num2 = Mathf.Min((float)this.age / 10f, 1f); Vector3 b = a * ((1f - num2) * num); float num3 = 0.975f + Mathf.Sin((float)this.age * 0.3f) * 0.025f; if (this.TicksLeft > (this.timeToRaise * .2f)) { num3 *= (float)this.age / (this.timeToRaise * .8f); } Color arg_50_0 = colorInt.ToColor; Color color = arg_50_0; color.a *= num3; Projectile_Resurrection.MatPropertyBlock.SetColor(ShaderPropertyIDs.Color, color); Matrix4x4 matrix = default(Matrix4x4); matrix.SetTRS(a2 + a * this.radius * 0.5f + b, Quaternion.Euler(0f, this.angle, 0f), new Vector3(this.radius, 1f, num)); Graphics.DrawMesh(MeshPool.plane10, matrix, Projectile_Resurrection.BeamMat, 0, null, 0, Projectile_Resurrection.MatPropertyBlock); Vector3 pos = drawPos + b; pos.y = Altitudes.AltitudeFor(AltitudeLayer.MetaOverlays); Matrix4x4 matrix2 = default(Matrix4x4); matrix2.SetTRS(pos, Quaternion.Euler(0f, this.angle, 0f), new Vector3(this.radius, 1f, this.radius)); Graphics.DrawMesh(MeshPool.plane10, matrix2, Projectile_Resurrection.BeamEndMat, 0, null, 0, Projectile_Resurrection.MatPropertyBlock); }
public override void PostDraw() { Material avatar = null; Vector3 vector; Designator_AndroidToControl desi = null; bool isConnected = csm != null && csm.connected; if (Find.DesignatorManager.SelectedDesignator is Designator_AndroidToControl) { desi = (Designator_AndroidToControl)Find.DesignatorManager.SelectedDesignator; } if (desi != null && desi.fromSkyCloud) { avatar = Tex.SelectableSX; } if (isConnected) { if (controller != null) { avatar = Tex.RemotelyControlledNode; } } if (avatar != null) { vector = this.parent.TrueCenter(); vector.y = Altitudes.AltitudeFor(AltitudeLayer.MetaOverlays) + 0.28125f; vector.z += 1.4f; vector.x += this.parent.def.size.x / 2; Graphics.DrawMesh(MeshPool.plane08, vector, Quaternion.identity, avatar, 0); } }
public override void DrawWornExtras() { if (Wearer == null || !Wearer.Spawned) { return; } if (!drawShield) { return; } float num = 0f; Vector3 vector = this.Wearer.Drawer.DrawPos; vector.y = Altitudes.AltitudeFor(AltitudeLayer.Pawn); Vector3 s = new Vector3(1f, 1f, 1f); if (this.Wearer.Rotation == Rot4.North) { //vector.y = Altitudes.AltitudeFor(AltitudeLayer.Pawn); vector.x -= 0.1f; vector.z -= IsTall ? -0.1f : 0.2f; } else { if (this.Wearer.Rotation == Rot4.South) { //vector.y = Altitudes.AltitudeFor(AltitudeLayer.MoteOverhead); vector.y += 0.0375f; vector.x += 0.1f; vector.z -= IsTall ? -0.05f : 0.2f; } else { if (this.Wearer.Rotation == Rot4.East) { //vector.y = Altitudes.AltitudeFor(AltitudeLayer.Pawn); if (IsTall) { vector.x += 0.1f; } vector.z -= IsTall ? -0.05f : 0.2f; num = 22.5f; } else { if (this.Wearer.Rotation == Rot4.West) { //vector.y = Altitudes.AltitudeFor(AltitudeLayer.MoteOverhead); vector.y += 0.0425f; if (IsTall) { vector.x -= 0.1f; } vector.z -= IsTall ? -0.05f : 0.2f; num = 337.5f; } } } } Material mat = Graphic.GetColoredVersion(ShaderDatabase.Cutout, DrawColor, DrawColorTwo).MatSingle; Matrix4x4 matrix = default(Matrix4x4); matrix.SetTRS(vector, Quaternion.AngleAxis(num, Vector3.up), s); Graphics.DrawMesh(MeshPool.plane10, matrix, mat, 0); }
public static void DrawDoubleSwingParams(DoorExpandedDef thingDef, Vector3 drawPos, Rot4 rotation, out Mesh mesh, out Matrix4x4 matrix, float mod = 1, bool flipped = false) { bool verticalRotation = rotation.IsHorizontal; rotation = (rotation == Rot4.South) ? Rot4.North : rotation; Vector3 rotationVector = default(Vector3); mesh = null; if (!flipped) { rotationVector = new Vector3(-1f, 0f, 0f); if (verticalRotation) { rotationVector = new Vector3(1.4f, 0f, 1.1f); } mesh = MeshPool.plane10; } else { rotationVector = new Vector3(1f, 0f, 0f); if (verticalRotation) { rotationVector = new Vector3(-1.4f, 0f, 1.1f); } mesh = MeshPool.plane10Flip; } Quaternion rotQuat = rotation.AsQuat; if (verticalRotation) { rotQuat = (!flipped) ? Quaternion.AngleAxis(rotation.AsAngle + (mod * -100f), Vector3.up) : Quaternion.AngleAxis(rotation.AsAngle + (mod * 100f), Vector3.up); } rotationVector = rotQuat * rotationVector; Vector3 graphicVector = drawPos; graphicVector.y = Altitudes.AltitudeFor(AltitudeLayer.DoorMoveable); if (verticalRotation) { if (!flipped && rotation == Rot4.East || flipped && rotation == Rot4.West) { graphicVector.y = Altitudes.AltitudeFor(AltitudeLayer.BuildingOnTop); } } //if (!verticalRotation) //if (verticalRotation) mod *= 2f; graphicVector += rotationVector * mod; float persMod = (thingDef.fixedPerspective) ? 2f : 1f; Vector3 scaleVector = (verticalRotation) ? new Vector3(thingDef.graphicData.drawSize.x * persMod, 1f, thingDef.graphicData.drawSize.y * persMod) : new Vector3(thingDef.graphicData.drawSize.x, 1f, thingDef.graphicData.drawSize.y); matrix = default(Matrix4x4); matrix.SetTRS(graphicVector, rotQuat, scaleVector); }
//[ReloadMethod] public void DrawFrameParams(DoorExpandedDef thingDef, Vector3 drawPos, Rot4 rotation, bool split, out Mesh mesh, out Matrix4x4 matrix) { float d = (0f + 0.45f * 1) * thingDef.Size.x; bool verticalRotation = rotation.IsHorizontal; Vector3 rotationVector = default(Vector3); rotationVector = new Vector3(-1f, 0f, 0f); mesh = MeshPool.plane10; if (thingDef.doorFrameSplit != null) { if (rotation == Rot4.West) { //; rotationVector.x = 1f; //rotationVector.z *= -1f; //rotationVector.y *= -1f; } } Quaternion rotQuat = rotation.AsQuat; rotationVector = rotQuat * rotationVector; Vector3 graphicVector = drawPos; graphicVector.y = Altitudes.AltitudeFor(AltitudeLayer.Blueprint); if (rotation == Rot4.North || rotation == Rot4.South) { graphicVector.y = Altitudes.AltitudeFor(AltitudeLayer.PawnState); } if (!verticalRotation) { graphicVector.x += d; } if (rotation == Rot4.East) { graphicVector.z -= d; if (split) { graphicVector.y = Altitudes.AltitudeFor(AltitudeLayer.DoorMoveable); } } if (rotation == Rot4.West) { graphicVector.z += d; if (split) { graphicVector.y = Altitudes.AltitudeFor(AltitudeLayer.DoorMoveable); } } graphicVector += rotationVector * d; float persMod = (thingDef.fixedPerspective) ? 2f : 1f; Vector3 scaleVector = (verticalRotation) ? new Vector3(thingDef.doorFrame.drawSize.x * persMod, 1f, thingDef.doorFrame.drawSize.y * persMod) : new Vector3(thingDef.doorFrame.drawSize.x, 1f, thingDef.doorFrame.drawSize.y); Vector3 offset = thingDef.doorFrameOffset; if (thingDef.doorFrameSplit != null) { if (rotation == Rot4.West) { rotQuat = Quaternion.Euler(0, 270, 0); //new Quaternion(0, 0.7f, 0, -0.7f);// Euler(0, 270, 0); graphicVector.z -= 2.7f; mesh = MeshPool.plane10Flip; offset = thingDef.doorFrameSplitOffset; } } graphicVector += offset; matrix = default(Matrix4x4); matrix.SetTRS(graphicVector, rotQuat, scaleVector); }
public override void Draw() { this.exactPosition.y = Altitudes.AltitudeFor(this.def.altitudeLayer); base.Draw(); }
public static Vector3 DrawPosAt(ShipBase ship, int ticks, ShipBase_Traveling travelingShip = null) { if (ticks < 0) { ticks = 0; } Vector3 result = Gen.TrueCenter(ship); if (travelingShip != null) { result = Gen.TrueCenter(travelingShip.Position, travelingShip.containingShip.Rotation, travelingShip.containingShip.def.size, Altitudes.AltitudeFor(AltitudeLayer.FlyingItem)); } result += DropShipUtility.drawOffsetFor(ship, ticks, false); return(result); }
public override void Draw() { if (this.linkData.linkType < 0) { base.Draw(); return; } if (this.ShouldSingleDoor()) { foreach (var current in linkData.linkedDoors) { current.Nortify_UnLinked(this); } this.linkData.Reset(); base.Draw(); return; } float num = Mathf.Clamp01((float)this.visualTicksOpen / (float)base.TicksToOpenNow); float d = 0f + 0.95f * num; Vector3 vector = default(Vector3); Vector3 offset = default(Vector3); Mesh mesh; switch (this.linkData.linkType) { case (int)LinkDirection.Linking_Up: vector = new Vector3(0f, 0f, -1f); offset = new Vector3(0f, 0f, -0.5f); mesh = LD_MeshPool.Plane10Wide; base.Rotation = Rot4.East; break; case (int)LinkDirection.Linking_Right: vector = new Vector3(0f, 0f, 1f); offset = new Vector3(-0.5f, 0f, 0f); mesh = LD_MeshPool.Plane10FlipWide; base.Rotation = Rot4.North; break; case (int)LinkDirection.Linking_Down: vector = new Vector3(0f, 0f, 1f); offset = new Vector3(0f, 0f, 0.5f); mesh = LD_MeshPool.Plane10FlipWide; base.Rotation = Rot4.East; break; case (int)LinkDirection.Linking_Left: vector = new Vector3(0f, 0f, -1f); offset = new Vector3(0.5f, 0f, 0f); mesh = LD_MeshPool.Plane10Wide; base.Rotation = Rot4.North; break; default: Log.Warning("LinkableDoor:default."); vector = new Vector3(0f, 0f, -1f); mesh = LD_MeshPool.Plane10Wide; break; } Rot4 rotation = base.Rotation; rotation.Rotate(RotationDirection.Clockwise); vector = rotation.AsQuat * vector; Vector3 vector2 = this.DrawPos; vector2.y = Altitudes.AltitudeFor(AltitudeLayer.DoorMoveable); vector2 += offset + vector * d; Graphics.DrawMesh(mesh, vector2, base.Rotation.AsQuat, this.Graphic.MatAt(base.Rotation, null), 0); base.Comps_PostDraw(); }
protected Mesh createArrow(Direction8Way direction) { Mesh m = new Mesh(); float y = Altitudes.AltitudeFor(AltitudeLayer.MapDataOverlay); const float xPixelSize = 1f / 15f; const float zPixelSize = 1f / 15f; List <Vector3> vertices = new List <Vector3>(7); List <Color> colors = new List <Color>(7); int[] triangles = new int[9]; switch (direction) { case Direction8Way.South: m.name = "ArrowSouth"; //stem vertices.Add(new Vector3(xPixelSize * 7f, y, zPixelSize * 5f)); vertices.Add(new Vector3(xPixelSize * 8f, y, zPixelSize * 5f)); vertices.Add(new Vector3(xPixelSize * 8f, y, zPixelSize * 3f)); vertices.Add(new Vector3(xPixelSize * 7f, y, zPixelSize * 3f)); //head vertices.Add(new Vector3(xPixelSize * 5f, y, zPixelSize * 3f)); vertices.Add(new Vector3(xPixelSize * 10f, y, zPixelSize * 3f)); vertices.Add(new Vector3(xPixelSize * 7.5f, y, zPixelSize * 0f)); break; case Direction8Way.North: m.name = "ArrowNorth"; //stem vertices.Add(new Vector3(xPixelSize * 8f, y, zPixelSize * 12f)); vertices.Add(new Vector3(xPixelSize * 8f, y, zPixelSize * 10f)); vertices.Add(new Vector3(xPixelSize * 7f, y, zPixelSize * 10f)); vertices.Add(new Vector3(xPixelSize * 7f, y, zPixelSize * 12f)); //head vertices.Add(new Vector3(xPixelSize * 7.5f, y, zPixelSize * 15f)); vertices.Add(new Vector3(xPixelSize * 10f, y, zPixelSize * 12f)); vertices.Add(new Vector3(xPixelSize * 5f, y, zPixelSize * 12f)); break; case Direction8Way.East: m.name = "ArrowEast"; //stem vertices.Add(new Vector3(xPixelSize * 10f, y, zPixelSize * 8f)); vertices.Add(new Vector3(xPixelSize * 12f, y, zPixelSize * 8f)); vertices.Add(new Vector3(xPixelSize * 12f, y, zPixelSize * 7f)); vertices.Add(new Vector3(xPixelSize * 10f, y, zPixelSize * 7f)); //head vertices.Add(new Vector3(xPixelSize * 12f, y, zPixelSize * 5f)); vertices.Add(new Vector3(xPixelSize * 12f, y, zPixelSize * 10f)); vertices.Add(new Vector3(xPixelSize * 15f, y, zPixelSize * 7.5f)); break; case Direction8Way.West: m.name = "ArrowWest"; //stem vertices.Add(new Vector3(xPixelSize * 5f, y, zPixelSize * 7f)); vertices.Add(new Vector3(xPixelSize * 3f, y, zPixelSize * 7f)); vertices.Add(new Vector3(xPixelSize * 3f, y, zPixelSize * 8f)); vertices.Add(new Vector3(xPixelSize * 5f, y, zPixelSize * 8f)); //head vertices.Add(new Vector3(xPixelSize * 3f, y, zPixelSize * 5f)); vertices.Add(new Vector3(xPixelSize * 0f, y, zPixelSize * 7.5f)); vertices.Add(new Vector3(xPixelSize * 3f, y, zPixelSize * 10f)); break; case Direction8Way.NorthEast: m.name = "NorthEast"; //stem vertices.Add(new Vector3(xPixelSize * 10f, y, zPixelSize * 11f)); vertices.Add(new Vector3(xPixelSize * 12f, y, zPixelSize * 13f)); vertices.Add(new Vector3(xPixelSize * 13f, y, zPixelSize * 12f)); vertices.Add(new Vector3(xPixelSize * 11f, y, zPixelSize * 10f)); //head vertices.Add(new Vector3(xPixelSize * 11f, y, zPixelSize * 14f)); vertices.Add(new Vector3(xPixelSize * 14f, y, zPixelSize * 14f)); vertices.Add(new Vector3(xPixelSize * 14f, y, zPixelSize * 11f)); break; case Direction8Way.NorthWest: m.name = "NorthWest"; //stem vertices.Add(new Vector3(xPixelSize * 5f, y, zPixelSize * 11f)); vertices.Add(new Vector3(xPixelSize * 4f, y, zPixelSize * 10f)); vertices.Add(new Vector3(xPixelSize * 2f, y, zPixelSize * 12f)); vertices.Add(new Vector3(xPixelSize * 3f, y, zPixelSize * 13f)); //head vertices.Add(new Vector3(xPixelSize * 1f, y, zPixelSize * 11f)); vertices.Add(new Vector3(xPixelSize * 1f, y, zPixelSize * 14f)); vertices.Add(new Vector3(xPixelSize * 4f, y, zPixelSize * 14f)); break; case Direction8Way.SouthEast: m.name = "SouthEast"; //stem vertices.Add(new Vector3(xPixelSize * 10f, y, zPixelSize * 4f)); vertices.Add(new Vector3(xPixelSize * 11f, y, zPixelSize * 5f)); vertices.Add(new Vector3(xPixelSize * 13f, y, zPixelSize * 3f)); vertices.Add(new Vector3(xPixelSize * 12f, y, zPixelSize * 2f)); //head vertices.Add(new Vector3(xPixelSize * 11f, y, zPixelSize * 1f)); vertices.Add(new Vector3(xPixelSize * 14f, y, zPixelSize * 4f)); vertices.Add(new Vector3(xPixelSize * 14f, y, zPixelSize * 1f)); break; case Direction8Way.SouthWest: m.name = "SouthWest"; //stem vertices.Add(new Vector3(xPixelSize * 4f, y, zPixelSize * 5f)); vertices.Add(new Vector3(xPixelSize * 5f, y, zPixelSize * 4f)); vertices.Add(new Vector3(xPixelSize * 3f, y, zPixelSize * 2f)); vertices.Add(new Vector3(xPixelSize * 2f, y, zPixelSize * 3f)); //head vertices.Add(new Vector3(xPixelSize * 4f, y, zPixelSize * 1f)); vertices.Add(new Vector3(xPixelSize * 1f, y, zPixelSize * 1f)); vertices.Add(new Vector3(xPixelSize * 1f, y, zPixelSize * 4f)); break; default: m.name = "ArrowNorth"; //stem vertices.Add(new Vector3(xPixelSize * 7f, y, zPixelSize * 10f)); vertices.Add(new Vector3(xPixelSize * 8f, y, zPixelSize * 10f)); vertices.Add(new Vector3(xPixelSize * 8f, y, zPixelSize * 12f)); vertices.Add(new Vector3(xPixelSize * 7f, y, zPixelSize * 12f)); //head vertices.Add(new Vector3(xPixelSize * 5f, y, zPixelSize * 12f)); vertices.Add(new Vector3(xPixelSize * 10f, y, zPixelSize * 12f)); vertices.Add(new Vector3(xPixelSize * 7.5f, y, zPixelSize * 15f)); break; } triangles[0] = 0; triangles[1] = 1; triangles[2] = 2; triangles[3] = 0; triangles[4] = 2; triangles[5] = 3; triangles[6] = vertices.Count - 3; triangles[7] = vertices.Count - 2; triangles[8] = vertices.Count - 1; for (int i = 0; i < vertices.Count; i++) { colors.Add(Color.black); } m.SetVertices(vertices); m.SetColors(colors); m.SetTriangles(triangles, 0); return(m); }
public override void DrawAt(Vector3 drawLoc) { if (!Spawned) { base.DrawAt(drawLoc); return; } wheelLoc = drawLoc; bodyLoc = drawLoc; //Vertical if (Rotation.AsInt % 2 == 0) { wheelLoc.y = Altitudes.AltitudeFor(AltitudeLayer.Item) + 0.02f; } //horizontal if (axlesComp.HasAxles() && Rotation.AsInt % 2 == 1) { wheelLoc.y = Altitudes.AltitudeFor(AltitudeLayer.Pawn) + 0.04f; bodyLoc.y = Altitudes.AltitudeFor(AltitudeLayer.Pawn) + 0.03f; Vector2 drawSize = def.graphic.drawSize; int num = Rotation == Rot4.West ? -1 : 1; Vector3 vector3 = new Vector3(1f * drawSize.x, 1f, 1f * drawSize.y); Quaternion asQuat = Rotation.AsQuat; float x = 1f * Mathf.Sin(num * (wheelRotation * 0.05f) % (2 * Mathf.PI)); float z = 1f * Mathf.Cos(num * (wheelRotation * 0.05f) % (2 * Mathf.PI)); asQuat.SetLookRotation(new Vector3(x, 0f, z), Vector3.up); wheel_shake = (float)((Math.Sin(tick_time) + Math.Abs(Math.Sin(tick_time))) / 40.0); wheelLoc.z = wheelLoc.z + wheel_shake; Vector3 mountThingLoc = drawLoc; mountThingLoc.y = Altitudes.AltitudeFor(AltitudeLayer.Pawn) + 0.06f; Vector3 mountThingOffset = new Vector3(0, 0, 1).RotatedBy(Rotation.AsAngle); List <Vector3> list; if (axlesComp.GetAxleLocations(drawSize, num, out list)) { foreach (Vector3 current in list) { Matrix4x4 matrix = default(Matrix4x4); matrix.SetTRS(wheelLoc + current, asQuat, vector3); Graphics.DrawMesh(MeshPool.plane10, matrix, graphic_Wheel_Single.MatAt(Rotation), 0); } } } base.DrawAt(bodyLoc); if (vehicleComp.compProps.specialShadowData != null) { if (shadowGraphic == null) { shadowGraphic = new Graphic_Shadow(vehicleComp.compProps.specialShadowData); } shadowGraphic.Draw(drawLoc, Rot4.North, this); } }
public void DrawImplant() {// this.Pawn bool selected = Find.Selector.SelectedObjects.Contains(this.Pawn); HediffComp_DrawImplant comp = this; string direction = ""; float angle = 0f; float offset = 0f; float yvalue = Pawn.Drawer.DrawPos.y; Vector3 drawPos = Pawn.Drawer.DrawPos; drawPos.y = Altitudes.AltitudeFor((AltitudeLayer)17); Vector3 s = new Vector3(1.5f, 1.5f, 1.5f); PawnRenderer pawnRenderer = this.Pawn.Drawer.renderer; Rot4 rot = LayingFacing(); if (Pawn.CarriedBy != null) { #if DEBUG if (selected) { Log.Message(string.Format("{0} carried by {1} drawpos {2} modified to {3}", Pawn.Name, Pawn.CarriedBy.Name, drawPos, Pawn.CarriedBy.DrawPos)); } #endif drawPos.z = Pawn.CarriedBy.DrawPos.z; drawPos.x = Pawn.CarriedBy.DrawPos.x; } if (Pawn.InBed()) { if (Pawn.CurrentBed().Rotation == Rot4.South) { #if DEBUG if (selected) { Log.Message(string.Format("{0}", Pawn.CurrentBed().Rotation.ToStringHuman())); } #endif drawPos -= pawnRenderer.BaseHeadOffsetAt(Rot4.South); } else if (Pawn.CurrentBed().Rotation == Rot4.North) { #if DEBUG if (selected) { Log.Message(string.Format("{0}", Pawn.CurrentBed().Rotation.ToStringHuman())); } #endif drawPos -= pawnRenderer.BaseHeadOffsetAt(Rot4.North); } else if (Pawn.CurrentBed().Rotation == Rot4.East) { #if DEBUG if (selected) { Log.Message(string.Format("{0}", Pawn.CurrentBed().Rotation.ToStringHuman())); } #endif drawPos.x += 0.3f; } else if (Pawn.CurrentBed().Rotation == Rot4.West) { #if DEBUG if (selected) { Log.Message(string.Format("{0}", Pawn.CurrentBed().Rotation.ToStringHuman())); } #endif drawPos.x -= 0.3f; } drawPos.y = yvalue; #if DEBUG if (selected) { Log.Message(string.Format("{0} in bed {1} drawpos modified to {2}", Pawn.Name, Pawn.InBed(), drawPos)); } #endif } if (offset < 0) { drawPos.y -= offset; } else { drawPos.y += offset; } if (Pawn.Downed) { angle = pawnRenderer.wiggler.downedAngle; if (Pawn.CarriedBy != null) { #if DEBUG if (selected) { Log.Message(string.Format("{0} carried by {1} angle {2} modified to {3}", Pawn.Name, Pawn.CarriedBy.Name, angle, Pawn.CarriedBy.carryTracker.CarriedThing.Rotation.AsAngle)); } #endif angle = Pawn.CarriedBy.carryTracker.CarriedThing.Rotation.AsAngle; } if (Pawn.InBed()) { if (Pawn.CurrentBed().Rotation == Rot4.South) { angle = 0f; } else if (Pawn.CurrentBed().Rotation == Rot4.North) { angle = 180f; } else if (Pawn.CurrentBed().Rotation == Rot4.East) { angle = 270; } else if (Pawn.CurrentBed().Rotation == Rot4.West) { angle = 90; } // angle = Pawn.CurrentBed().Rotation.AsAngle; } if (Pawn.kindDef.race == YautjaDefOf.RRY_Alien_Yautja) { s = new Vector3(2f, 1.5f, 2f); if (rot.ToStringHuman() == "West" || rot == Rot4.West) { //drawPos.z -= 0.15f; // drawPos.x += 0.25f; } else { // drawPos.x += 0.25f; } } } #if DEBUG if (selected) { Log.Message(string.Format("{0}'s {1}, Rot:{2}, offset:{3}, x:{4}, z:{5}", Pawn.Label, this.parent.def.label, rot, offset, drawPos.x, drawPos.z)); Log.Message(string.Format("Rot ToStringHuman:{1}, FacingCell:{2}, AsVector2:{3}, AsByte:{4}, AsAngle:{5}", rot, rot.ToStringHuman(), rot.FacingCell, rot.AsVector2, rot.AsByte, rot.AsAngle)); } #endif Material matSingle = comp.ImplantMaterial(Pawn, rot); Matrix4x4 matrix = default(Matrix4x4); matrix.SetTRS(drawPos, Quaternion.AngleAxis(angle, Vector3.up), s); Graphics.DrawMesh(rot == Rot4.West ? MeshPool.plane10Flip : MeshPool.plane10, matrix, matSingle, 0); }
public void DrawOverlays(string PatronName, Pawn corrpawn) { bodyMesh = MeshPool.humanlikeBodySet.MeshAt(corrpawn.Rotation); headMesh = MeshPool.humanlikeHeadSet.MeshAt(corrpawn.Rotation); if (corrpawn.story == null) { btype = BodyType.Undefined; } else { btype = corrpawn.story.bodyType; } HeadGraphic = GetHeadGraphic(corrpawn, PatronName); BodyGraphic = GetBodyOverlay(btype, PatronName); bodydrawpos = corrpawn.Drawer.DrawPos; headvec = corrpawn.Drawer.renderer.BaseHeadOffsetAt(corrpawn.Rotation); headdrawpos = bodydrawpos + headvec; headMat = HeadGraphic.MatAt(corrpawn.Rotation); bodyMat = BodyGraphic.MatAt(corrpawn.Rotation); if (corrpawn.Rotation == Rot4.North) { headMesh = MeshPool.plane03; bodyMesh = MeshPool.humanlikeBodySet.MeshAt(corrpawn.Rotation); } else { headMesh = MeshPool.humanlikeBodySet.MeshAt(corrpawn.Rotation); bodyMesh = MeshPool.humanlikeBodySet.MeshAt(corrpawn.Rotation); } bodydrawpos.y += 0.0019f; if (corrpawn.Rotation == Rot4.North) { headdrawpos.y += 0.0f; } else { headdrawpos.y += 0.051f; } if (corrpawn.Downed || corrpawn.Dead) { headMat = HeadGraphic.MatAt(LayingFacingDet(corrpawn)); bodyMat = BodyGraphic.MatAt(LayingFacingDet(corrpawn)); if (corrpawn.Dead) { num = corrpawn.Corpse.InnerPawn.Drawer.renderer.wiggler.downedAngle; } else { num = corrpawn.Drawer.renderer.wiggler.downedAngle; } if (corrpawn.thingIDNumber % 4 == 3) { headMesh = MeshPool.plane10Flip; } quat = Quaternion.AngleAxis(num, Vector3.up); Vector3 newPos = quat * headvec; headdrawpos = corrpawn.Drawer.DrawPos + newPos; bodydrawpos = corrpawn.Drawer.DrawPos; bodydrawpos.y = Altitudes.AltitudeFor(AltitudeLayer.LayingPawn) + 0.001f; if (corrpawn.Dead) { if (corrpawn.Drawer != null && corrpawn.Corpse != null) { Vector3 headvecD = corrpawn.Drawer.renderer.BaseHeadOffsetAt(corrpawn.Corpse.Rotation); Vector3 newPosD = quat * headvecD; headdrawpos = corrpawn.Corpse.DrawPos + newPosD; } quat = Quaternion.AngleAxis(num, Vector3.up); bodydrawpos = corrpawn.Corpse.DrawPos; bodydrawpos.y -= 0.05f; } } if (corrpawn.CarriedBy != null) { Pawn pepe = corrpawn.CarriedBy; Vector3 vec = corrpawn.CarriedBy.DrawPos; Vector3 newPos = quat * headvec; vec.x += 0.5f; bodydrawpos = vec; headdrawpos = bodydrawpos + newPos; } Building_Bed bbed = corrpawn.CurrentBed(); if (bbed != null && corrpawn.RaceProps.Humanlike) { RenderBody = false; Rot4 rotation = bbed.Rotation; num = bbed.Rotation.AsAngle; AltitudeLayer altLayer = (AltitudeLayer)Mathf.Max((int)bbed.def.altitudeLayer, 15); Vector3 a = this.cpawn.Position.ToVector3ShiftedWithAltitude(altLayer); float d = -this.cpawn.Drawer.renderer.BaseHeadOffsetAt(Rot4.South).z; Vector3 a2 = rotation.FacingCell.ToVector3(); headdrawpos = a + a2 * d; headdrawpos.y += 0.01f; headMat = HeadGraphic.MatAt(LayingFacingDet(corrpawn)); } Vector3 s = new Vector3(1.0f, 1.0f, 1.0f); Matrix4x4 matrixHead = default(Matrix4x4); Matrix4x4 matrixBody = default(Matrix4x4); matrixHead.SetTRS(headdrawpos, Quaternion.AngleAxis(num, Vector3.up), s); matrixBody.SetTRS(bodydrawpos, Quaternion.AngleAxis(num, Vector3.up), s); Graphics.DrawMesh(headMesh, headdrawpos, Quaternion.AngleAxis(num, Vector3.up), headMat, 45); if (RenderBody) { Graphics.DrawMesh(bodyMesh, bodydrawpos, Quaternion.AngleAxis(num, Vector3.up), bodyMat, 40); } PortraitsCache.SetDirty(corrpawn); }
public override void DrawWornExtras() { // base.DrawWornExtras(); if (this.ShouldDisplay) { // base.DrawWornExtras(); float num = 0f; Vector3 vector = this.Wearer.Drawer.DrawPos; // vector.y = Altitudes.AltitudeFor(AltitudeLayer.Pawn); Vector3 s = new Vector3(1f, 1f, 1f); if (this.Wearer.Rotation == Rot4.North) { vector.y = Altitudes.AltitudeFor(AltitudeLayer.Item); vector.x -= 0.2f; vector.z -= 0.2f; } else { if (this.Wearer.Rotation == Rot4.South) { vector.y = Altitudes.AltitudeFor(AltitudeLayer.Pawn); vector.y += 0.033f; vector.x += 0.2f; vector.z -= 0.2f; } else { if (this.Wearer.Rotation == Rot4.East) { vector.y = Altitudes.AltitudeFor(AltitudeLayer.Pawn); vector.z = 0.2f; num = 90f; } else { if (this.Wearer.Rotation == Rot4.West) { vector.y = Altitudes.AltitudeFor(AltitudeLayer.MoteOverhead); vector.z -= 0.2f; num = 270f; } } } } // colorable = def.colorable; // if (shield as Shield.ColorableShield != null) // make sure it actually IS a MyCoolNewGun, HAS the code, etc: //{ // use the thingdef: // var def = shield.def as Shield.ColorableShield; // colorable = def.colorable; // or access directly: // var myBool = ((myNamespace.MyCustomDef_ThingDef)weapon.def).myNewBool; // this will throw an exception if somehow the weapon isn't a MyCoolNewGun! // use the defs, etc // this works in beta 0.18.1722 // } if (shieldMat == null) { shieldMat = MaterialPool.MatFrom(def.graphicData.texPath); } Matrix4x4 matrix = default(Matrix4x4); matrix.SetTRS(vector, Quaternion.AngleAxis(num, Vector3.up), s); Graphics.DrawMesh(MeshPool.plane10, matrix, shieldMat, 0); } }
public override void Tick() { if (base.Spawned) { if (this.sustainer == null) { Log.Error("DustDevil sustainer is null."); this.CreateSustainer(); } this.sustainer.Maintain(); this.UpdateSustainerVolume(); base.GetComp <CompWindSource>().wind = 5f * this.FadeInOutFactor; if (this.leftFadeOutTicks > 0) { this.leftFadeOutTicks--; if (this.leftFadeOutTicks == 0) { this.Destroy(DestroyMode.Vanish); } } else { if (DustDevil.directionNoise == null) { DustDevil.directionNoise = new Perlin(0.0020000000949949026, 2.0, 0.5, 4, 1948573612, QualityMode.Medium); } this.direction += (float)DustDevil.directionNoise.GetValue((double)Find.TickManager.TicksAbs, (double)((float)(this.thingIDNumber % 500) * 1000f), 0.0) * 0.78f; this.realPosition = this.realPosition.Moved(this.direction, 0.0283333343f); IntVec3 intVec = new Vector3(this.realPosition.x, 0f, this.realPosition.y).ToIntVec3(); if (intVec.InBounds(base.Map)) { base.Position = intVec; if (this.IsHashIntervalTick(15)) { this.DamageCloseThings(); } if (Rand.MTBEventOccurs(15f, 1f, 1f)) { this.DamageFarThings(); } if (this.ticksLeftToDisappear > 0) { this.ticksLeftToDisappear--; if (this.ticksLeftToDisappear == 0) { this.leftFadeOutTicks = 120; Messages.Message("MessageDustDevilDissipated".Translate(), new TargetInfo(base.Position, base.Map, false), MessageTypeDefOf.PositiveEvent); } } if (this.IsHashIntervalTick(4) && !this.CellImmuneToDamage(base.Position)) { float num = Rand.Range(0.6f, 1f); MoteMaker.ThrowTornadoDustPuff(new Vector3(this.realPosition.x, 0f, this.realPosition.y) { y = Altitudes.AltitudeFor(AltitudeLayer.MoteOverhead) } +Vector3Utility.RandomHorizontalOffset(1.5f), base.Map, Rand.Range(1.5f, 3f), new Color(num, num, num)); } } else { this.leftFadeOutTicks = 120; Messages.Message("MessageDustDevilLeftMap".Translate(), new TargetInfo(base.Position, base.Map, false), MessageTypeDefOf.PositiveEvent); } } } }
public static void Postfix() { if (WorldRendererUtility.WorldRenderedNow == false) { Map map = Find.CurrentMap; if (map == null) { return; } List <Pawn> selectedPawns = Find.Selector.SelectedPawns; if (selectedPawns == null) { return; } CellRect currentView = Find.CameraDriver.CurrentViewRect; foreach (Pawn pawn in selectedPawns) { CompMeeseeksMemory memory = pawn.GetComp <CompMeeseeksMemory>(); if (memory == null) { continue; } foreach (SavedTargetInfo target in memory.jobTargets) { if (currentView.Contains(target.target.Cell)) { Matrix4x4 matrix = new Matrix4x4(); Vector3 position = new Vector3(target.Cell.x + 0.25f, Altitudes.AltitudeFor(AltitudeLayer.MoteOverhead), target.target.Cell.z + 0.75f); Vector3 scale = new Vector3(0.5f, 1.0f, 0.5f); matrix.SetTRS(position, Quaternion.identity, scale); Graphics.DrawMesh(MeshPool.plane10, matrix, TargetMarker, 0); } } } } }
public override void Draw() { if (this.linkable.IsSingle) { base.Draw(); return; } if (LinkGroupUtility.ShouldSingle(base.Position, base.Map)) { LinkGroupUtility.DetachGroupAround(this.linkable); base.Draw(); return; } base.Rotation = this.linkable.LineDirection; float num = Mathf.Clamp01((float)this.ticksSinceOpen / (float)base.TicksToOpenNow); float[] move = { 0, 0 }; int index; switch (this.linkable.PosTag) { case PositionTag.LeftSide: this.linkable.CommonField = 1f * num; move[0] = this.GetMoveOffset(PositionTag.LeftSide); index = 0; break; case PositionTag.RightSide: this.linkable.CommonField = 1f * num; move[0] = this.GetMoveOffset(PositionTag.RightSide); index = 1; break; case PositionTag.LeftBorder | PositionTag.LeftSide: this.linkable.CommonField = (1f - ProtrudedDoorOffset) * num; move[0] = this.GetMoveOffset(PositionTag.LeftSide); move[1] = move[0]; index = 2; break; case PositionTag.RightBorder | PositionTag.RightSide: this.linkable.CommonField = (1f - ProtrudedDoorOffset) * num; move[0] = this.GetMoveOffset(PositionTag.RightSide); move[1] = move[0]; index = 3; break; case PositionTag.Center: this.linkable.CommonField = (0.5f - ProtrudedDoorOffset) * num; move[0] = this.GetMoveOffset(PositionTag.LeftSide); move[1] = this.GetMoveOffset(PositionTag.RightSide); index = 4; break; default: Log.Error("[LinkableDoors] default"); index = 0; break; } Vector3[] coefficients = LD_MeshPool.doorMeshPosSet[index].coefficients; Vector3[] offsets = LD_MeshPool.doorMeshPosSet[index].offsets; Mesh[] meshes = LD_MeshPool.doorMeshPosSet[index].meshes; Rot4 rotation = base.Rotation; rotation.Rotate(RotationDirection.Clockwise); Quaternion quat = rotation.AsQuat; for (int i = 0; i < 2; i++) { if (meshes[i] != null) { Vector3 vector = this.DrawPos; vector.y = Altitudes.AltitudeFor(AltitudeLayer.DoorMoveable) + offsets[i].y; Vector3 vector2 = quat * coefficients[i]; Vector3 vector3 = quat * offsets[i]; vector += vector3 + vector2 * move[i]; Graphics.DrawMesh(meshes[i], vector, base.Rotation.AsQuat, this.Graphic.MatAt(base.Rotation, null), 0); } } base.Comps_PostDraw(); }
protected override IEnumerable <Toil> MakeNewToils() { QualityCategory fishingEquipmentQuality = QualityCategory.Normal; float catchSomethingThreshold = 0f; Building_FishingPier fishingPier = this.TargetThingA as Building_FishingPier; Passion passion = Passion.None; int fishingDuration = 1000; const float skillGainPerTick = 0.15f; float skillGainFactor = 0f; this.AddEndCondition(() => { var targ = this.pawn.jobs.curJob.GetTarget(fishingPierIndex).Thing; if (targ is Building && !targ.Spawned) { return(JobCondition.Incompletable); } return(JobCondition.Ongoing); }); this.FailOnBurningImmobile(fishingPierIndex); // Bill giver or product burning in carry phase. yield return(Toils_Reserve.Reserve(fishingPierIndex)); float statValue = this.pawn.GetStatValue(Util_FishIndustry.FishingSpeedDef, true); fishingDuration = (int)Math.Round((double)(800f / statValue)); yield return(Toils_Goto.GotoThing(fishingPierIndex, fishingPier.riverCell).FailOnDespawnedOrNull(fishingPierIndex)); Toil verifyFisherHasFishingEquipmentToil = new Toil() { initAction = () => { if ((this.pawn.equipment.Primary != null) && (this.pawn.equipment.Primary.def == Util_FishIndustry.HarpoonDef)) { this.fishingEquipment = FishingEquipment.Harpoon; this.pawn.equipment.Primary.TryGetQuality(out fishingEquipmentQuality); } foreach (Apparel apparel in this.pawn.apparel.WornApparel) { if (apparel.def == Util_FishIndustry.FishingRodDef) { this.fishingEquipment = FishingEquipment.FishingRod; apparel.TryGetQuality(out fishingEquipmentQuality); break; } } if (this.fishingEquipment == FishingEquipment.NoEquipment) { this.pawn.jobs.EndCurrentJob(JobCondition.Incompletable); } } }; yield return(verifyFisherHasFishingEquipmentToil); Toil fishToil = new Toil() { initAction = () => { ThingDef moteDef = null; switch (fishingEquipment) { case FishingEquipment.FishingRod: if (fishingPier.Rotation == Rot4.North) { moteDef = Util_FishIndustry.MoteFishingRodNorthDef; } else if (fishingPier.Rotation == Rot4.East) { moteDef = Util_FishIndustry.MoteFishingRodEastDef; } else if (fishingPier.Rotation == Rot4.South) { moteDef = Util_FishIndustry.MoteFishingRodSouthDef; } else { moteDef = Util_FishIndustry.MoteFishingRodWestDef; } break; } if (moteDef != null) { fishingEquipmentMote = (MoteThrown)ThingMaker.MakeThing(moteDef); fishingEquipmentMote.exactPosition = fishingPier.fishingSpotCell.ToVector3Shifted(); fishingEquipmentMote.exactPosition.y = Altitudes.AltitudeFor(AltitudeLayer.VisEffects); GenSpawn.Spawn(fishingEquipmentMote, fishingPier.fishingSpotCell); } WorkTypeDef fishingWorkDef = DefDatabase <WorkTypeDef> .GetNamed("Fishing"); passion = this.pawn.skills.MaxPassionOfRelevantSkillsFor(fishingWorkDef); if (passion == Passion.None) { skillGainFactor = 0.3f; } else if (passion == Passion.Minor) { skillGainFactor = 1f; } else { skillGainFactor = 1.5f; } }, tickAction = () => { switch (fishingEquipment) { case FishingEquipment.FishingRod: fishingEquipmentMote.Maintain(); break; case FishingEquipment.Harpoon: if (Find.TickManager.TicksGame % GenTicks.TickRareInterval == 0) { Bullet thrownHarpoon = GenSpawn.Spawn(Util_FishIndustry.HarpoonDef.Verbs.First().projectileDef, this.pawn.Position) as Bullet; TargetInfo targetCell = new TargetInfo(fishingPier.fishingSpotCell + new IntVec3(Rand.RangeInclusive(-1, 1), 0, Rand.RangeInclusive(0, 2)).RotatedBy(fishingPier.Rotation)); thrownHarpoon.Launch(this.pawn, targetCell); } break; } this.pawn.Drawer.rotator.FaceCell(fishingPier.fishingSpotCell); if (passion == Passion.Minor) { this.pawn.needs.joy.GainJoy(NeedTunings.JoyPerXpForPassionMinor, JoyKindDefOf.Work); } else if (passion == Passion.Major) { this.pawn.needs.joy.GainJoy(NeedTunings.JoyPerXpForPassionMajor, JoyKindDefOf.Work); } SkillDef fishingSkillDef = DefDatabase <SkillDef> .GetNamed("Fishing"); this.pawn.skills.Learn(fishingSkillDef, skillGainPerTick * skillGainFactor); }, defaultDuration = fishingDuration, defaultCompleteMode = ToilCompleteMode.Delay }; yield return(fishToil.WithProgressBarToilDelay(fishingPierIndex)); yield return(verifyFisherHasFishingEquipmentToil); // Could be dropped during fishToil. Toil computeChanceToCatchToil = new Toil() { initAction = () => { float fishingSkillLevel = 0f; WorkTypeDef fishingWorkDef = DefDatabase <WorkTypeDef> .GetNamed("Fishing"); fishingSkillLevel = this.pawn.skills.AverageOfRelevantSkillsFor(fishingWorkDef); float fishingEquipmentQualityFactor = (float)fishingEquipmentQuality / (float)QualityCategory.Legendary; float fishingSkillFactor = fishingSkillLevel / 20f; float snowFactor = 1 - Find.SnowGrid.GetDepth(fishingPier.fishingSpotCell); float fishingEquipmentOffset = 0f; switch (this.fishingEquipment) { case FishingEquipment.Harpoon: fishingEquipmentOffset = 0.2f; break; case FishingEquipment.FishingRod: fishingEquipmentOffset = 0.5f; break; } catchSomethingThreshold = ((fishingEquipmentOffset * fishingEquipmentQualityFactor) + 0.4f * fishingSkillFactor) * (0.25f + 0.75f * snowFactor); // Reframe min and max chance (min 5%, max 75 % chance of success). catchSomethingThreshold = catchSomethingThreshold * 0.75f; catchSomethingThreshold = Math.Max(catchSomethingThreshold, 0.05f); }, defaultCompleteMode = ToilCompleteMode.Instant }; yield return(computeChanceToCatchToil); Toil catchFishToil = new Toil() { initAction = () => { Job curJob = this.pawn.jobs.curJob; Thing fishingCatch = null; bool catchIsSuccessful = Rand.Value <= catchSomethingThreshold; if (catchIsSuccessful == false) { MoteThrower.ThrowDrift(this.pawn.Position, ThingDefOf.Mote_IncapIcon); this.pawn.jobs.EndCurrentJob(JobCondition.Incompletable); return; } float catchSelectorValue = Rand.Value; if (catchSelectorValue > 0.04f) { // Catch a fish. TerrainDef fishSpotType = Find.TerrainGrid.TerrainAt(fishingPier.fishingSpotCell); List <ThingDef> fishSpeciesList = null; ThingDef_FishSpeciesProperties.AquaticEnvironment aquaticEnvironment; ThingDef_FishSpeciesProperties.LivingTime livingTime; float fishSpeciesTotalCommonality = 0f; float fishSpeciesCommonalitySum = 0f; // Aquatic environment. if (fishSpotType == TerrainDef.Named("Marsh")) { aquaticEnvironment = ThingDef_FishSpeciesProperties.AquaticEnvironment.Marsh; } else { aquaticEnvironment = ThingDef_FishSpeciesProperties.AquaticEnvironment.Sea; } // Day time. if (SkyManager.CurSkyGlow >= 0.4f) { livingTime = ThingDef_FishSpeciesProperties.LivingTime.Day; } else { livingTime = ThingDef_FishSpeciesProperties.LivingTime.Night; } fishSpeciesList = Util_FishIndustry.GetFishSpeciesList(aquaticEnvironment, livingTime); fishSpeciesTotalCommonality = Util_FishIndustry.GetFishSpeciesTotalCommonality(aquaticEnvironment, livingTime); float randomSelector = Rand.Range(0f, fishSpeciesTotalCommonality); ThingDef selectedFishSpecies = null; for (int fishSpeciesIndex = 0; fishSpeciesIndex < fishSpeciesList.Count; fishSpeciesIndex++) { ThingDef_FishSpeciesProperties currentFishSpecies = fishSpeciesList[fishSpeciesIndex] as ThingDef_FishSpeciesProperties; fishSpeciesCommonalitySum += currentFishSpecies.commonality; if (randomSelector <= fishSpeciesCommonalitySum) { selectedFishSpecies = currentFishSpecies; break; } } fishingCatch = GenSpawn.Spawn(selectedFishSpecies, this.pawn.Position); fishingCatch.stackCount = (selectedFishSpecies as ThingDef_FishSpeciesProperties).catchQuantity; fishingPier.fishStock--; } else if (catchSelectorValue > 0.02) { fishingCatch = GenSpawn.Spawn(Util_FishIndustry.OysterDef, this.pawn.Position); fishingCatch.stackCount = Rand.RangeInclusive(5, 27); } else { float bonusCatchValue = Rand.Value; if (bonusCatchValue < 0.01f) { // Really small chance to find a sunken treasure!!! fishingCatch = GenSpawn.Spawn(ThingDefOf.Gold, this.pawn.Position); fishingCatch.stackCount = Rand.RangeInclusive(58, 289); Thing treasureSilver = GenSpawn.Spawn(ThingDefOf.Silver, fishingPier.middleCell); treasureSilver.stackCount = Rand.RangeInclusive(237, 2154); string eventText = this.pawn.Name.ToStringShort.CapitalizeFirst() + " has found a sunken treasure while fishing! What a good catch!\n"; Find.LetterStack.ReceiveLetter("Sunken treasure!", eventText, LetterType.Good, this.pawn.Position); } else if (bonusCatchValue < 0.02f) { // Really small chance to find a complete power armor set + sniper or charge rifle. Thing powerArmor = GenSpawn.Spawn(ThingDef.Named("Apparel_PowerArmor"), this.pawn.Position); fishingCatch = powerArmor; // Used to carry the power armor. Thing powerArmorHelmet = GenSpawn.Spawn(ThingDef.Named("Apparel_PowerArmorHelmet"), this.pawn.Position); Thing rifle = null; if (Rand.Value < 0.5f) { rifle = GenSpawn.Spawn(ThingDef.Named("Gun_ChargeRifle"), this.pawn.Position); } else { rifle = GenSpawn.Spawn(ThingDef.Named("Gun_SniperRifle"), this.pawn.Position); } CompQuality qualityComp = powerArmor.TryGetComp <CompQuality>(); if (qualityComp != null) { qualityComp.SetQuality(QualityCategory.Masterwork, ArtGenerationContext.Outsider); } qualityComp = powerArmorHelmet.TryGetComp <CompQuality>(); if (qualityComp != null) { qualityComp.SetQuality(QualityCategory.Masterwork, ArtGenerationContext.Outsider); } qualityComp = rifle.TryGetComp <CompQuality>(); if (qualityComp != null) { qualityComp.SetQuality(QualityCategory.Masterwork, ArtGenerationContext.Outsider); } Faction faction = Find.FactionManager.FirstFactionOfDef(FactionDefOf.SpacerHostile); Pawn deadMarine = PawnGenerator.GeneratePawn(PawnKindDefOf.SpaceSoldier, faction); GenSpawn.Spawn(deadMarine, fishingPier.bankCell); HealthUtility.GiveInjuriesToKill(deadMarine); List <Thing> thingsList = deadMarine.Position.GetThingList(); foreach (Thing thing in thingsList) { if (thing.def.defName.Contains("Corpse")) { CompRottable rotComp = thing.TryGetComp <CompRottable>(); if (rotComp != null) { rotComp.rotProgress = 20f * 60000f; // 20 days so the corpse is dessicated. } } } string eventText = this.pawn.Name.ToStringShort.CapitalizeFirst() + " has cought a dead body while fishing!\n\n'This is really disgusting but look at his gear! This guy was probably a Mining & Co. security member. I wonder what happend to him...'\n"; Find.LetterStack.ReceiveLetter("Dead marine", eventText, LetterType.Good, this.pawn.Position); } else { // Find a small amount of gold. fishingCatch = GenSpawn.Spawn(ThingDefOf.Gold, this.pawn.Position); fishingCatch.stackCount = Rand.RangeInclusive(1, 7); } // TODO: add chance to get hurt by a tailteeth (missing finger or even hand!). } IntVec3 storageCell; if (StoreUtility.TryFindBestBetterStoreCellFor(fishingCatch, this.pawn, StoragePriority.Unstored, this.pawn.Faction, out storageCell, true)) { this.pawn.carrier.TryStartCarry(fishingCatch); curJob.targetB = storageCell; curJob.targetC = fishingCatch; curJob.maxNumToCarry = 99999; } else { this.pawn.jobs.EndCurrentJob(JobCondition.Succeeded); } } }; yield return(catchFishToil); // Reserve the product and storage cell. yield return(Toils_Reserve.Reserve(TargetIndex.B)); yield return(Toils_Reserve.Reserve(TargetIndex.C)); Toil carryToCell = Toils_Haul.CarryHauledThingToCell(TargetIndex.B); yield return(carryToCell); yield return(Toils_Haul.PlaceHauledThingInCell(TargetIndex.B, carryToCell, true)); yield return(Toils_Reserve.Release(fishingPierIndex)); }