public override void CompTick() { base.CompTick(); //Tools.Warn(" >>>TICK begin<<< ", prcDebug); Tools.Warn(" >>>TICK begin tp:" + Registry.Count + "<<< "); if (HasSpot) { if (Tools.TwoTicksOneTrue()) { //foreach(Building cur in Registry) for (int i = Registry.Count - 1; i >= 0; i--) { Building cur = Registry[i]; if ((!ToolsBuilding.CheckBuilding(cur)) || (!ToolsBuilding.CheckPower(cur)) || !InRangeSpot(cur)) { Comp_LTF_TpSpot comp_LTF_TpSpot = cur?.TryGetComp <Comp_LTF_TpSpot>(); if (comp_LTF_TpSpot != null) { comp_LTF_TpSpot.ResetFacility(); } RemoveSpot(cur); } } } IndexCorrecter(); } // Tools.Warn(" >>>TICK end<<< ", prcDebug); Tools.Warn(" >>>TICK end " + Registry.Count + "<<< "); }
public static Material Status2OverlayMaterial(Comp_LTF_TpSpot comp, bool FactionMajority, bool debug = false) { Material Answer = null; string checkIf = string.Empty; // Nothing if (comp.HasNothing) { checkIf = "nothing gfx"; Tools.Warn(checkIf, debug); return(null); } // something if (comp.HasHumanoid) { checkIf = "humanoid f:" + FactionMajority; Answer = ((FactionMajority) ? (HumanoidFaction) : (Humanoid)); } else if (comp.HasAnimal) { checkIf = "animal f:" + FactionMajority; Answer = ((FactionMajority) ? (AnimalFaction) : (Animal)); } else { checkIf = "Item f:" + FactionMajority; Answer = ((FactionMajority) ? (ItemFaction) : (Item)); } Tools.Warn(checkIf, debug); return(Answer); }
/* * public static Material Status2UnderlayMaterial(Comp_LTF_TpSpot comp, bool debug = false) * { * Material Answer = null; * string what = "Gfx - Under: "; * * if (comp.StatusReady) * { * Answer = SomethingM; * Tools.Warn(what + "something",debug); * return Answer; * } * * if ((comp.HasNothing) && (comp.HasPoweredFacility)) * { * Answer = NothingM; * Tools.Warn(what + "nothing", debug); * return Answer; * } * * if (comp.HasItems) * { * Answer = NotReadyM; * Tools.Warn(what + "notready", debug); * return Answer; * } * * Tools.Warn(what+"null", debug); * return Answer; * } */ public static Material Status2UnderlayMaterial(Comp_LTF_TpSpot comp, bool debug = false) { Material Answer = null; string what = "Gfx - Under: "; switch (comp.myWay) { case MyWay.Way.Out: Answer = WayOutM; break; case MyWay.Way.In: Answer = WayInM; break; case MyWay.Way.Swap: Answer = WaySwapM; break; default: return(null); } if (comp.TpSequenceBegin) { Answer = InitOrderM; } Tools.Warn(what + "null", debug); return(Answer); }
public static Material Status2UnderlayMaterial(Comp_LTF_TpSpot comp, bool debug = false) { Material Answer = null; string what = "Gfx - Under: "; if (comp.StatusReady) { Answer = SomethingM; Tools.Warn(what + "something", debug); return(Answer); } if ((comp.HasNothing) && (comp.HasPoweredFacility)) { Answer = NothingM; Tools.Warn(what + "nothing", debug); return(Answer); } if (comp.HasItems) { Answer = NotReadyM; Tools.Warn(what + "notready", debug); return(Answer); } Tools.Warn(what + "null", debug); return(Answer); }
public override void PostDrawExtraSelectionOverlays() { // Draw range circle if (range > 0f) { float CircleRadius = 0f; //CircleRadius = ((IsMiniStation)?():()); if (IsMiniStation) { CircleRadius = 1; } else { CircleRadius = (range / 2) + 1; } GenDraw.DrawRadiusRing(this.parent.Position, CircleRadius); } // Not drawing if bench is empty or has no power if ((Registry.NullOrEmpty()) || (!GotThePower)) { return; } // selected spot comp Comp_LTF_TpSpot comp = CurrentSpot?.TryGetComp <Comp_LTF_TpSpot>(); if (comp == null) { return; } // not drawing lines with spot without power/facility if ((comp.requiresPower && !comp.HasPower)) { return; } if ((comp.requiresBench && !comp.HasPoweredFacility)) { return; } // Line from workstation to spot (in range) GenDraw.DrawLineBetween(this.parent.TrueCenter(), CurrentSpot.TrueCenter(), comp.WayColoring); if (comp.IsLinked) { // Line from spot to spot GenDraw.DrawLineBetween(CurrentSpot.TrueCenter(), comp.twin.TrueCenter(), comp.WayColoring); // Wish we could make it more noticeable } }
private Comp_LTF_TpSpot getTpSpot(Thing thing) { Building building = thing as Building; if (building == null) { return(null); } Comp_LTF_TpSpot tpSpot = null; tpSpot = building.TryGetComp <Comp_LTF_TpSpot>(); return(tpSpot); }
public void ShowReport() { StringBuilder stringBuilder = new StringBuilder(); String buffer = string.Empty; stringBuilder.AppendLine("| Workstation registry |"); stringBuilder.AppendLine("+-------------------------+"); if (!Registry.NullOrEmpty()) { stringBuilder.AppendLine(">>> " + Registry.Count.ToString("D2") + " records." + "\n"); } else { stringBuilder.AppendLine("Empty."); } if (!Registry.NullOrEmpty()) { int i = 1; foreach (Building cur in Registry) { string report = string.Empty; report = i.ToString("D2") + ". " + cur.LabelShort + Tools.PosStr(cur.Position); Comp_LTF_TpSpot compSpot = cur?.TryGetComp <Comp_LTF_TpSpot>(); if ((compSpot != null) && compSpot.IsLinked) { // " <=> " report += " " + compSpot.WayArrowLabeling + " "; report += compSpot.twin.Label + Tools.PosStr(compSpot.twin.Position); } else { report += " Orphan spot!"; } stringBuilder.AppendLine(report); i++; } } Dialog_MessageBox window = new Dialog_MessageBox(stringBuilder.ToString(), null, null, null, null, null, false); Find.WindowStack.Add(window); }
public static Material Status2WarningMaterial(Comp_LTF_TpSpot comp, bool debug = false) { Material Answer = null; string checkIf = string.Empty; // no facility if (comp.StatusNoFacility) { checkIf = "no facility gfx"; Tools.Warn(checkIf, debug); return(MyGfx.FacilityM); } // no facility power if (!comp.HasPoweredFacility) { checkIf = "no facility power gfx"; Tools.Warn(checkIf, debug); return(MyGfx.FacilityPowerM); } // cooldown if (comp.StatusChillin) { checkIf = "cooldown gfx"; Tools.Warn(checkIf, debug); return(MyGfx.CooldownM); } // overwieght if (comp.StatusOverweight) { checkIf = "overweight gfx"; Tools.Warn(checkIf, debug); return(MyGfx.OverweightM); } checkIf += "everything fine;no warning"; Tools.Warn(checkIf, debug); return(Answer); }
public static void BrowseWay(this Way MyWay, Comp_LTF_TpSpot compTwin) { MyWay = MyWay.NextWay(compTwin.IsOrphan); switch (MyWay) { case Way.Out: compTwin.myWay = Way.In; break; case Way.In: compTwin.myWay = Way.Out; break; case Way.Swap: compTwin.myWay = Way.Swap; break; case Way.No: compTwin.myWay = Way.No; break; } }
public static float TheoricBestRange(Comp_LTF_TpSpot comp1, Comp_LTF_TpSpot comp2) { return(Mathf.Max(comp1?.range ?? 0, comp2?.range ?? 0)); }
public override IEnumerable <Gizmo> CompGetGizmosExtra() { if (HasQuality) { Texture2D qualityMat = ToolsGizmo.Quality2Mat(compQuality); float qualitySize = ToolsGizmo.Quality2Size(compQuality); yield return(new Command_Action { //icon = ContentFinder<Texture2D>.Get("UI/Commands/CancelRegistry", true), icon = qualityMat, iconDrawScale = qualitySize, defaultLabel = "Quality matters", defaultDesc = QualityLog(), action = delegate { Tools.Warn("rip quality button", prcDebug); } }); } if (GotThePower) { { Texture2D myMat = MyGizmo.EmptyStatus2Gizmo(IsEmpty, IsFull); String myLabel = "Registry"; String Grammar = ((MoreThanOne) ? ("s") : ("")); String myDesc = Tools.CapacityString(Registry.Count, FacilityCapacity) + ' ' + TpSpotName + "."; if (IsEmpty || IsFull) { myDesc += ".Registry is " + ((IsEmpty) ? ("empty") : ("full")); if (IsEmpty) { myDesc += "\nBuild a " + TpSpotName + " in its range."; } if (IsFull) { myDesc += "\nNo additional " + TpSpotName + " will be managed."; } } myDesc += "\nLists " + Registry.Count + " teleporter" + Grammar; yield return(new Command_Action { icon = myMat, defaultLabel = myLabel, defaultDesc = myDesc, action = new Action(this.ShowReport), }); } if (HasSpot) { Comp_LTF_TpSpot comp = CurrentSpot?.TryGetComp <Comp_LTF_TpSpot>(); if (comp != null) { if (comp.ValidWay) { String WayName = comp.WayNaming; Texture2D myGizmo = null; //if (comp.StatusReady && comp.IsLinked && !comp.compTwin.StatusChillin) /* * if (comp.StatusReady && comp.IsLinked) * myGizmo = comp.WayGizmoing; * else * myGizmo = comp.IssueGizmoing; */ myGizmo = comp.WayGizmoing; if (comp.IsLinked) { if (comp.compTwin.StatusChillin) { myGizmo = comp.compTwin.IssueGizmoing; } } String myLabel = "Cast " + WayName; String myDesc = comp.WayDescription; //+ "\n" + comp.StatusLogNoUpdate; //Action todo = ShowReport; Action todo = delegate { Tools.Warn("rip action on no way", prcDebug); }; if (comp.IsOrphan || comp.StatusChillin || comp.compTwin.StatusChillin) { if (comp.IsOrphan) { myDesc = "Selected spot is orphan. You need to link it to another."; } else if (comp.StatusChillin) { myDesc = "Selected spot has some cooldown."; } else if (comp.compTwin.StatusChillin) { myDesc = "Selected spot twin has some cooldown."; } } else if (comp.MyWay == Comp_LTF_TpSpot.Way.Out) { todo = comp.OrderOut; } else if (comp.MyWay == Comp_LTF_TpSpot.Way.In) { todo = comp.OrderIn; } //todo = comp.compTwin.OrderOut; //todo = comp.OrderIn; else if (comp.MyWay == Comp_LTF_TpSpot.Way.Swap) { todo = comp.OrderSwap; } /* * else if (comp.MyWay == Comp_LTF_TpSpot.Way.No) * todo = ShowReport; */ yield return(new Command_Action { icon = myGizmo, defaultLabel = myLabel, defaultDesc = myDesc, action = new Action(todo), }); } else { Tools.Warn("gizmo should not be this way", prcDebug); } } else { Tools.Warn("gizmo should not be this way", prcDebug); } } Tools.Warn("Gizmo browse records", prcDebug); if (MoreThanOne) { Texture2D myMat = MyGizmo.NextTpGz; String myLabel = Tools.CapacityString(GizmoIndex + 1, Registry.Count) + Tools.PosStr(CurrentSpot.Position); //String Grammar = ((MoreThanOne) ? ("s") : ("")); String myDesc = "Browse " + Registry.Count + " records"; yield return(new Command_Action { icon = myMat, defaultLabel = myLabel, defaultDesc = myDesc, action = new Action(NextIndex), }); } } if (Prefs.DevMode) { // Debug process yield return(new Command_Action { icon = ((prcDebug) ? (MyGizmo.DebugOnGz) : (MyGizmo.DebugOffGz)), defaultLabel = "prc: " + Tools.DebugStatus(prcDebug), defaultDesc = "process debug", action = delegate { prcDebug = Tools.WarnBoolToggle(prcDebug, "debug " + building.Label); } }); // Debug gfx yield return(new Command_Action { icon = ((gfxDebug) ? (MyGizmo.DebugOnGz) : (MyGizmo.DebugOffGz)), defaultLabel = "gfx: " + Tools.DebugStatus(gfxDebug), defaultDesc = "gfx debug", action = delegate { gfxDebug = Tools.WarnBoolToggle(gfxDebug, "debug " + building.Label); } }); //debug log + hax activate if (prcDebug) { yield return new Command_Action { //icon = ContentFinder<Texture2D>.Get("UI/Commands/HaxReady", true), icon = MyGizmo.DebugLogGz, defaultLabel = "hax " + Tools.DebugStatus(Hax), defaultDesc = "$5,000 for you advert here.", action = delegate { Hax = Tools.WarnBoolToggle(Hax, "hax " + building.Label); } } } ; // Hax Progress if (prcDebug && Hax) { } // Hax quality if (prcDebug && Hax && HasQuality) { if (!ToolsQuality.BestQuality(compQuality)) { yield return new Command_Action { defaultLabel = compQuality.Quality.GetLabelShort() + "->" + ToolsQuality.BetterQuality(compQuality), defaultDesc = "Better quality", //icon = ContentFinder<Texture2D>.Get("UI/Commands/HaxReady", true), icon = MyGizmo.HaxBetterGz, action = delegate { BetterQuality(); } } } ; if (!ToolsQuality.WorstQuality(compQuality)) { yield return new Command_Action { defaultDesc = "Worse quality", defaultLabel = compQuality.Quality.GetLabelShort() + "->" + ToolsQuality.WorseQuality(compQuality), icon = MyGizmo.HaxWorseGz, action = delegate { WorseQuality(); } } } ; } } }
public override void DrawWorker(Vector3 loc, Rot4 rot, ThingDef thingDef, Thing thing, float extraRotation) { if (!isInitialized) { Init(); } if (thingDef == null) { Log.ErrorOnce("slide DrawWorker with null thingDef: " + loc, 3427324); return; } if (this.subGraphics == null) { Log.ErrorOnce("Graphic_slide has no subgraphics " + thingDef, 358773632); return; } if (thing.def.defName != "LTF_TpSpot" && thing.def.defName != "LTF_TpCatcher" && thing.def.defName != "LTF_TpBed" && thing.def.defName != "LTF_TpBox" ) { Tools.Warn("slide show for tp spot only", true); return; } Comp_LTF_TpSpot comp = null; comp = getTpSpot(thing); if (comp == null) { Tools.Warn("Cant find tpspot comp", true); return; } if (frameI >= frameMax) { Unset(); if ((comp.TeleportItemAnimActive) || (comp.TpSequenceEnd)) { //if ((comp.TeleportItemAnimActive) || (comp.TeleportItemAnimEnd)) //if ((tpSpot.TeleportItemAnimBegin) || (tpSpot.TeleportItemAnimActive)) comp.NextAnim(); } if (comp.TeleportItemAnimNa) { comp.slideShowOn = false; } return; } Graphic graphic = this.subGraphics[frameI]; Vector3 dotS = new Vector3(1f, 1f, 1f); Vector3 drawPos = thing.DrawPos; if (drawPos == null) { Log.Warning("null pos draw"); return; } // higher than ground to be visible drawPos.y += 4; //drawPos.y += 0.046875f; //Vector3 dotPos = thing.Position.ToVector3Shifted(); Matrix4x4 matrix = default(Matrix4x4); //matrix.SetTRS(drawPos, (extraRotation != 0)?(Quaternion.AngleAxis(extraRotation, Vector3.up)):Quaternion.identity, dotS); matrix.SetTRS(loc, (extraRotation != 0) ? (Quaternion.AngleAxis(extraRotation, Vector3.up)) : Quaternion.identity, dotS); Material material = FadedMaterialPool.FadedVersionOf(graphic.MatSingle, comp.myOpacity); Graphics.DrawMesh(MeshPool.plane10, matrix, graphic.MatSingle, 0); //Log.Warning("Drew " + frameI + "/" + frameMax); //Tools.Warn("2tick1true:"+ Tools.TwoTicksOneTrue(5), true); if (comp.IncFrameSlower() == 0) { frameI += 1; comp.SetFrameSlower(); } }
public override void DoEffectOn(Pawn user, Thing target) { //Tools.Warn(">>> DoEffectOn <<<", true); Building tpSpot1 = (Building)target; Building tpSpot2 = user.CurJob.targetA.Thing as Building; // check building if (!ToolsBuilding.CheckBuilding(tpSpot1) || !ToolsBuilding.CheckBuilding(tpSpot2)) { Tools.Warn("//Null spot", true); return; } // comp validity string Spot1Valid = Comp_LTF_TpSpot.ValidTpSpot(tpSpot1); if (!Spot1Valid.NullOrEmpty()) { Messages.Message(Spot1Valid, this.parent, MessageTypeDefOf.TaskCompletion); return; } string Spot2Valid = Comp_LTF_TpSpot.ValidTpSpot(tpSpot2); if (!Spot2Valid.NullOrEmpty()) { Messages.Message(Spot2Valid, this.parent, MessageTypeDefOf.TaskCompletion); return; } // both catchers //if (tpSpot1.def.defName == "LTF_TpCatcher" && tpSpot2.def.defName == "LTF_TpCatcher") // At least 1 tpspot if (!Comp_LTF_TpSpot.AtLeastOneTpSpot(tpSpot1, tpSpot2)) { Messages.Message("At least one of the two spots must be powered.", this.parent, MessageTypeDefOf.TaskCompletion); return; } // targeting itself if (tpSpot1 == tpSpot2) { Messages.Message(tpSpot1.Label + " can not target itself", this.parent, MessageTypeDefOf.TaskCompletion); return; } // comp !null Comp_LTF_TpSpot spot1Comp = tpSpot1.TryGetComp <Comp_LTF_TpSpot>(); Comp_LTF_TpSpot spot2Comp = tpSpot2.TryGetComp <Comp_LTF_TpSpot>(); if ((spot1Comp == null) || (spot2Comp == null)) { Tools.Warn("// Not comp", true); return; } Tools.Warn("Trying to register: " + tpSpot2.Label + " in " + tpSpot1.Label, spot1Comp.prcDebug); // tp spot without powered facility //if ((spot1Comp.requiresPower) && (!spot1Comp.HasPoweredFacility)) /* * if ((spot1Comp.requiresPower) && (!spot1Comp.HasPoweredFacility)) * { * Messages.Message(tpSpot1.Label + " requires a powered facility to be linked", this.parent, MessageTypeDefOf.TaskCompletion); * return; * } */ float distance = tpSpot1.Position.DistanceTo(tpSpot2.Position); float bestRange = ToolsBuilding.TheoricBestRange(spot1Comp, spot2Comp); Tools.Warn("dist:" + distance + " ; range:" + bestRange, spot1Comp.prcDebug); if (distance > bestRange) { Messages.Message(tpSpot2.Label + " is out of range (distance : " + distance + ", max : " + bestRange + ")", this.parent, MessageTypeDefOf.TaskCompletion); return; } bool didSomething = spot1Comp.CreateLink(tpSpot2, spot2Comp); Messages.Message( Tools.OkStr(didSomething) + ' ' + tpSpot1.Label + spot1Comp.MyCoordinates + " was " + ((didSomething) ? ("") : ("not ")) + "linked to " + tpSpot2.Label + spot2Comp.MyCoordinates , this.parent, MessageTypeDefOf.TaskCompletion); Tools.Warn(Tools.OkStr(didSomething) + "registered: " + tpSpot2.Label + " in " + tpSpot1.Label, spot1Comp.prcDebug); }