public override IEnumerable <KeyValuePair <_Condition, Func <Vector3, Pawn, Thing, List <FloatMenuOption> > > > GetFloatMenus() { List <KeyValuePair <_Condition, Func <Vector3, Pawn, Thing, List <FloatMenuOption> > > > floatMenus = new List <KeyValuePair <_Condition, Func <Vector3, Pawn, Thing, List <FloatMenuOption> > > >(); _Condition zombieCondition = new _Condition(_ConditionType.IsType, typeof(Zombie)); Func <Vector3, Pawn, Thing, List <FloatMenuOption> > zombieFunc = delegate(Vector3 clickPos, Pawn pawn, Thing curThing) { List <FloatMenuOption> opts = null; if (curThing is Zombie target && target.Downed) { if (REDataCache.GetFirstBrainChip(pawn.MapHeld) is Thing brainChip) { opts = new List <FloatMenuOption>(); if (target.installedBrainChip) { //Do nothing } else if (!pawn.CanReach(target, PathEndMode.OnCell, Danger.Deadly, false, TraverseMode.ByPawn)) { opts.Add(new FloatMenuOption("RE_CannotInstallBrainchip".Translate() + " (" + "NoPath".Translate() + ")", null, MenuOptionPriority.Default, null, null, 0f, null, null)); } else if (!pawn.CanReserve(target, 1)) { opts.Add(new FloatMenuOption("RE_CannotInstallBrainchip".Translate() + ": " + "Reserved".Translate(), null, MenuOptionPriority.Default, null, null, 0f, null, null)); } else if (!pawn.CanReach(brainChip, PathEndMode.OnCell, Danger.Deadly, false, TraverseMode.ByPawn)) { opts.Add(new FloatMenuOption("RE_CannotInstallBrainchip".Translate() + " (" + "NoPath".Translate() + ")", null, MenuOptionPriority.Default, null, null, 0f, null, null)); } else if (!pawn.CanReserve(brainChip, 1)) { opts.Add(new FloatMenuOption("RE_CannotInstallBrainchip".Translate() + ": " + "Reserved".Translate(), null, MenuOptionPriority.Default, null, null, 0f, null, null)); } else { Action action = delegate { Job job = new Job(DefDatabase <JobDef> .GetNamed("RE_InstallBrainChip"), target, brainChip); job.count = 1; pawn.jobs.TryTakeOrderedJob(job); }; opts.Add(new FloatMenuOption("RE_InstallBrainChip".Translate( brainChip.LabelCap, target.LabelShortCap ), action, MenuOptionPriority.High, null, target, 0f, null, null)); } return(opts); } } return(null); }; KeyValuePair <_Condition, Func <Vector3, Pawn, Thing, List <FloatMenuOption> > > curSec = new KeyValuePair <_Condition, Func <Vector3, Pawn, Thing, List <FloatMenuOption> > >(zombieCondition, zombieFunc); floatMenus.Add(curSec); return(floatMenus); }
GetFloatMenus() { List <KeyValuePair <_Condition, Func <Vector3, Pawn, Thing, List <FloatMenuOption> > > > floatMenus = new List <KeyValuePair <_Condition, Func <Vector3, Pawn, Thing, List <FloatMenuOption> > > >(); _Condition madnessCondition = new _Condition(_ConditionType.IsType, typeof(Pawn)); Func <Vector3, Pawn, Thing, List <FloatMenuOption> > madnessFunc = delegate(Vector3 clickPos, Pawn pawn, Thing curThing) { if (!Cthulhu.Utility.IsCultsLoaded()) { List <FloatMenuOption> opts = null; Pawn target = curThing as Pawn; if (pawn == target) { if (Cthulhu.Utility.HasSanityLoss(pawn)) { opts = new List <FloatMenuOption>(); Action action = delegate { var newMentalState = (Rand.Value > 0.05) ? DefDatabase <MentalStateDef> .AllDefs.InRandomOrder() .FirstOrDefault(x => x.IsAggro == false) : MentalStateDefOf.Berserk; Cthulhu.Utility.DebugReport("Selected mental state: " + newMentalState.label); if (pawn.Drafted) { pawn.drafter.Drafted = false; } pawn.ClearMind(); pawn.pather.StopDead(); if (!pawn.mindState.mentalStateHandler.TryStartMentalState(newMentalState)) { Messages.Message("ROM_TradedSanityLossForMadnessFailed".Translate(pawn.LabelShort), pawn, MessageTypeDefOf.RejectInput); return; } Messages.Message("ROM_TradedSanityLossForMadness".Translate(pawn.LabelShort), pawn, MessageTypeDefOf.ThreatSmall); Cthulhu.Utility.RemoveSanityLoss(pawn); }; opts.Add(new FloatMenuOption("ROM_TradeSanityForMadness".Translate(), action, MenuOptionPriority.High, null, target, 0f, null, null)); return(opts); } } } return(null); }; KeyValuePair <_Condition, Func <Vector3, Pawn, Thing, List <FloatMenuOption> > > curSec = new KeyValuePair <_Condition, Func <Vector3, Pawn, Thing, List <FloatMenuOption> > >(madnessCondition, madnessFunc); floatMenus.Add(curSec); return(floatMenus); }
bool c_instante = true; // Variavel auxiliar para controle do instante. /// <summary> /// Construtor sem paremetro dos estados dos efeitos /// </summary> public StatesEffect() { this.condition = _Condition.None; this.effectsRemove = _EffectsRemove.None; this.reservedValue = 0; this.value = 0; this.cooldownEffects = 0f; this.c_cooldownEffects = 0f; this.instante = false; }
/// <summary> /// Construtor com parametro dos estados dos efeitos /// </summary> /// <param name="_effect"></param> public StatesEffect(StatesEffect _effect) { this.condition = _effect.condition; this.effectsRemove = _effect.effectsRemove; this.reservedValue = _effect.reservedValue; this.value = _effect.value; this.cooldownEffects = _effect.cooldownEffects; this.c_cooldownEffects = 0f; this.instante = _effect.instante; }
public SingleValueParam(_Condition Data, BaseParam Info) { InitializeComponent(); this.Data = Data; this.Block.BorderBrush = (Info.required) ? new SolidColorBrush(Colors.Red) : new SolidColorBrush(Colors.Black); ParamName.Text = Data.Property; if (Data.Operation == "Default") { OperationType.Visibility = System.Windows.Visibility.Collapsed; } else { foreach (var item in OperationList) { OperationType.Items.Add(item); } OperationType.SelectedIndex = OperationList.IndexOf(Data.Operation); } textValue = (Info.paramTemplates == null || Info.paramTemplates.Count == 0); if (textValue) { this.Value.Visibility = System.Windows.Visibility.Visible; this.ValueList.Visibility = System.Windows.Visibility.Collapsed; this.Value.Text = Data.Value; } else { this.Value.Visibility = System.Windows.Visibility.Collapsed; this.ValueList.Visibility = System.Windows.Visibility.Visible; Guid curValueId; bool PossibleValuesIsGuid = Guid.TryParse(Data.Value, out curValueId); foreach (var item in Info.paramTemplates) { ComboBoxItem cbItem = new ComboBoxItem(); cbItem.Content = item.Value; cbItem.DataContext = item; if (PossibleValuesIsGuid && item.Key == curValueId) { cbItem.IsSelected = true; } if (!PossibleValuesIsGuid && item.Value == Data.Value) { cbItem.IsSelected = true; } this.ValueList.Items.Add(cbItem); } } }
public MultiValueParam(_Condition Data, BaseParam Info) { InitializeComponent(); this.Data = Data; this.Block.BorderBrush = (Info.required) ? new SolidColorBrush(Colors.Red) : new SolidColorBrush(Colors.Black); Dictionary <Guid, string> ValueList = new Dictionary <Guid, string>(); var buffer = Data.Value.Split(new char[] { ';' }, StringSplitOptions.RemoveEmptyEntries); foreach (var item in buffer) { ValueList.Add(new Guid(item), Info.paramTemplates[new Guid(item)]); } dataContext = new MultiValueParamData(Data.Property, Data.Operation, ValueList, Info.paramTemplates); this.DataContext = dataContext; }
public override IEnumerable <KeyValuePair <_Condition, Func <Vector3, Pawn, Thing, List <FloatMenuOption> > > > GetFloatMenus() { List <KeyValuePair <_Condition, Func <Vector3, Pawn, Thing, List <FloatMenuOption> > > > FloatMenus = new List <KeyValuePair <_Condition, Func <Vector3, Pawn, Thing, List <FloatMenuOption> > > >(); _Condition feedCondition = new _Condition(_ConditionType.IsType, typeof(Pawn)); Func <Vector3, Pawn, Thing, List <FloatMenuOption> > feedFunc = delegate(Vector3 clickPos, Pawn pawn, Thing curThing) { List <FloatMenuOption> opts = new List <FloatMenuOption>(); bool pawnIsVampire = pawn.IsVampire(); if (pawnIsVampire && curThing is Pawn victim && victim != pawn && !victim.RaceProps.IsMechanoid) { CompVampire selVampComp = pawn.GetComp <CompVampire>(); int curBloodVictim = victim?.BloodNeed()?.CurBloodPoints ?? 0; int curBloodActor = pawn?.BloodNeed()?.CurBloodPoints ?? 0; bool victimIsVampire = victim.IsVampire(); // FEED ////////////////////////// if (!victimIsVampire || (selVampComp?.Bloodline?.canFeedOnVampires ?? false)) { Action action = delegate { Job job = new Job(VampDefOf.ROMV_Feed, victim); job.count = 1; pawn.jobs.TryTakeOrderedJob(job); }; opts.Add(new FloatMenuOption("ROMV_Feed".Translate(new object[] { victim.LabelCap }) + (curBloodVictim == 1 ? new TaggedString(" ") + "ROMV_LethalWarning".Translate() : new TaggedString("")), action, MenuOptionPriority.High, null, victim)); // SIP ////////////////////////// if (curBloodVictim > 1) { Action action2 = delegate { Job job = new Job(VampDefOf.ROMV_Sip, victim); job.count = 1; pawn.jobs.TryTakeOrderedJob(job); }; opts.Add(new FloatMenuOption("ROMV_Sip".Translate(new object[] { victim.LabelCap }), action2, MenuOptionPriority.High, null, victim)); } } ; if (!victimIsVampire && (victim?.RaceProps?.Humanlike ?? false)) { //EMBRACE ///////////////////// if (selVampComp.Thinblooded) { opts.Add(new FloatMenuOption("ROMV_CannotEmbrace".Translate(new object[] { victim.LabelCap } +" (" + "ROMV_Thinblooded".Translate() + ")"), null, MenuOptionPriority.High, null, victim)); } else { Action actionTwo = delegate { Job job = new Job(VampDefOf.ROMV_Embrace, victim); job.count = 1; pawn.jobs.TryTakeOrderedJob(job); }; opts.Add(new FloatMenuOption("ROMV_Embrace".Translate(new object[] { victim.LabelCap }), actionTwo, MenuOptionPriority.High, null, victim)); } //GIVE BLOOD (Ghoul) //////////////////// if (curBloodActor > 0) { Action actionThree = delegate { Job job = new Job(VampDefOf.ROMV_GhoulBloodBond, victim); job.count = 1; pawn.jobs.TryTakeOrderedJob(job); }; opts.Add(new FloatMenuOption( "ROMV_GiveVitae".Translate() + (!victim.IsGhoul() ? new TaggedString(" (") + "ROMV_CreateGhoul".Translate() + ")" : new TaggedString("")), actionThree, MenuOptionPriority.High, null, victim)); } } //Diablerie //////////////////// if (victimIsVampire) { Action action = delegate { Job job = new Job(VampDefOf.ROMV_FeedVampire, victim); job.count = 1; job.playerForced = true; pawn.jobs.TryTakeOrderedJob(job); }; opts.Add(new FloatMenuOption("ROMV_FeedVampire".Translate(new object[] { victim.LabelCap }), action, MenuOptionPriority.High, null, victim)); Action action2 = delegate { Job job = new Job(VampDefOf.ROMV_Diablerie, victim); job.count = 1; job.playerForced = true; pawn.jobs.TryTakeOrderedJob(job); }; string benefitWarning = (selVampComp.Generation <= victim.VampComp().Generation) ? new TaggedString(" ") + "ROMV_DiablerieNoBenefit".Translate() : new TaggedString(""); opts.Add(new FloatMenuOption("ROMV_Diablerie".Translate(new object[] { victim.LabelCap }) + benefitWarning, action2, MenuOptionPriority.High, null, victim)); } } return(opts); }; KeyValuePair <_Condition, Func <Vector3, Pawn, Thing, List <FloatMenuOption> > > curSec = new KeyValuePair <_Condition, Func <Vector3, Pawn, Thing, List <FloatMenuOption> > >(feedCondition, feedFunc); FloatMenus.Add(curSec); return(FloatMenus); }
GetFloatMenus() { var floatMenus = new List <KeyValuePair <_Condition, Func <Vector3, Pawn, Thing, List <FloatMenuOption> > > >(); var silverCondition = new _Condition(_ConditionType.IsType, typeof(ThingWithComps)); List <FloatMenuOption> silverFunc(Vector3 clickPos, Pawn pawn, Thing curThing) { var target = curThing as ThingWithComps; if (!(target?.def?.IsWeapon ?? false)) { return(null); } if (!(pawn?.Map?.listerBuildings ?.AllBuildingsColonistOfDef(DefDatabase <ThingDef> .GetNamed("TableMachining"))? .FirstOrDefault(x => x is Building_WorkTable) is Building_WorkTable machiningTable)) { return(null); } if (target.IsSilverTreated()) { return(null); } if (!target.def.IsRangedWeapon) { return(null); } var opts = new List <FloatMenuOption>(); if (!pawn.CanReach(target, PathEndMode.OnCell, Danger.Deadly)) { opts.Add(new FloatMenuOption( "ROM_CannotApplySilverTreatment".Translate() + " (" + "NoPath".Translate() + ")", null)); return(opts); } if (!pawn.CanReserve(target)) { opts.Add(new FloatMenuOption( "ROM_CannotApplySilverTreatment".Translate() + ": " + "Reserved".Translate(), null)); return(opts); } if (!pawn.CanReach(machiningTable, PathEndMode.OnCell, Danger.Deadly)) { opts.Add(new FloatMenuOption( "ROM_CannotApplySilverTreatment".Translate() + " (" + "ROM_NoPathToMachiningTable".Translate() + ")", null)); return(opts); } if (!pawn.CanReserve(machiningTable)) { opts.Add(new FloatMenuOption( "ROM_CannotApplySilverTreatment".Translate() + ": " + "ROM_MachiningTableReserved".Translate(), null)); return(opts); } if (pawn.Map.resourceCounter.Silver < SilverTreatedUtility.AmountRequired(target)) { opts.Add(new FloatMenuOption( "ROM_CannotApplySilverTreatment".Translate() + ": " + "ROM_NeedsSilver".Translate(SilverTreatedUtility.AmountRequired(target)), null)); return(opts); } void action() { var job = new Job(WWDefOf.ROM_ApplySilverTreatment, target, SilverTreatedUtility.FindSilver(pawn), machiningTable) { count = SilverTreatedUtility.AmountRequired(target) }; pawn.jobs.ClearQueuedJobs(); pawn.jobs.TryTakeOrderedJob(job); } opts.Add(new FloatMenuOption( "ROM_ApplySilverTreatment".Translate(target.LabelCap, SilverTreatedUtility.AmountRequired(target)), action, MenuOptionPriority.High, null, target)); return(opts); } var curSec = new KeyValuePair <_Condition, Func <Vector3, Pawn, Thing, List <FloatMenuOption> > >(silverCondition, silverFunc); floatMenus.Add(curSec); return(floatMenus); }
public override IEnumerable <KeyValuePair <_Condition, Func <Vector3, Pawn, Thing, List <FloatMenuOption> > > > GetFloatMenus() { List <KeyValuePair <_Condition, Func <Vector3, Pawn, Thing, List <FloatMenuOption> > > > FloatMenus = new List <KeyValuePair <_Condition, Func <Vector3, Pawn, Thing, List <FloatMenuOption> > > >(); _Condition curCondition = new _Condition(_ConditionType.IsType, typeof(ThingWithComps)); Func <Vector3, Pawn, Thing, List <FloatMenuOption> > curFunc = delegate(Vector3 clickPos, Pawn pawn, Thing curThing) { List <FloatMenuOption> opts = new List <FloatMenuOption>(); if (curThing is ThingWithComps groundThing && groundThing.GetComp <CompInstalledPart>() is CompInstalledPart groundPart) { if (pawn.equipment != null) { //Remove "Equip" option from right click. if (groundThing.GetComp <CompEquippable>() != null) { var optToRemove = opts.FirstOrDefault((x) => x.Label.Contains(groundThing.Label)); if (optToRemove != null) { opts.Remove(optToRemove); } } string text = "CompInstalledPart_Install".Translate(); opts.Add(new FloatMenuOption(text, delegate { CompProperties_InstalledPart props = groundPart.Props; if (props != null) { if (props.allowedToInstallOn != null && props.allowedToInstallOn.Count > 0) { SoundDefOf.TickTiny.PlayOneShotOnCamera(null); Find.Targeter.BeginTargeting(new TargetingParameters { canTargetPawns = true, canTargetBuildings = true, mapObjectTargetsMustBeAutoAttackable = false, validator = delegate(TargetInfo targ) { if (!targ.HasThing) { return(false); } return(props.allowedToInstallOn.Contains(targ.Thing.def)); } }, delegate(LocalTargetInfo target) { groundThing.SetForbidden(false); groundPart.GiveInstallJob(pawn, target.Thing); }, null, null, null); } else { Log.ErrorOnce("CompInstalledPart :: allowedToInstallOn list needs to be defined in XML.", 3242); } } }, MenuOptionPriority.Default, null, null, 29f, null, null)); } } return(opts); }; KeyValuePair <_Condition, Func <Vector3, Pawn, Thing, List <FloatMenuOption> > > curSec = new KeyValuePair <_Condition, Func <Vector3, Pawn, Thing, List <FloatMenuOption> > >(curCondition, curFunc); FloatMenus.Add(curSec); return(FloatMenus); }
GetFloatMenus() { var FloatMenus = new List <KeyValuePair <_Condition, Func <Vector3, Pawn, Thing, List <FloatMenuOption> > > >(); var curCondition = new _Condition(_ConditionType.ThingHasComp, typeof(CompSlottedBonus)); List <FloatMenuOption> CurFunc(Vector3 clickPos, Pawn pawn, Thing curThing) { //Log.Message("Patch is loaded"); var opts = new List <FloatMenuOption>(); List <IThingHolder> holders = new List <IThingHolder>(); pawn.GetChildHolders(holders); var allThings = new List <Thing>(); holders.ForEach(x => allThings.AddRange(x.GetDirectlyHeldThings().ToList())); foreach (var item in allThings) { if (item is ThingWithComps slotLoadable && slotLoadable.AllComps.FirstOrDefault(x => x is CompSlotLoadable) is CompSlotLoadable compSlotLoadable) { var c = clickPos.ToIntVec3(); //var thingList = c.GetThingList(pawn.Map); foreach (var slot in compSlotLoadable.Slots) { var loadableThing = (slot.CanLoad(curThing.def)) ? curThing : null; if (loadableThing != null) { FloatMenuOption itemSlotLoadable; var labelShort = loadableThing.Label; if (!pawn.health.capacities.CapableOf(PawnCapacityDefOf.Manipulation)) { itemSlotLoadable = new FloatMenuOption( "CannotEquip".Translate(labelShort) + " (" + "Incapable".Translate() + ")", null, MenuOptionPriority.Default, null, null, 0f, null, null); } else if (!pawn.CanReach(loadableThing, PathEndMode.ClosestTouch, Danger.Deadly)) { itemSlotLoadable = new FloatMenuOption( "CannotEquip".Translate(labelShort) + " (" + "NoPath".Translate() + ")", null, MenuOptionPriority.Default, null, null, 0f, null, null); } else if (!pawn.CanReserve(loadableThing, 1)) { itemSlotLoadable = new FloatMenuOption( "CannotEquip".Translate(labelShort) + " (" + "ReservedBy".Translate(pawn.Map.physicalInteractionReservationManager .FirstReserverOf(loadableThing).LabelShort) + ")", null, MenuOptionPriority.Default, null, null, 0f, null, null); } else { var text2 = "Equip".Translate(labelShort); itemSlotLoadable = new FloatMenuOption(text2, delegate { loadableThing.SetForbidden(false, true); pawn.jobs.TryTakeOrderedJob(new Job( DefDatabase <JobDef> .GetNamed("GatherSlotItem"), loadableThing)); MoteMaker.MakeStaticMote(loadableThing.DrawPos, loadableThing.Map, ThingDefOf.Mote_FeedbackEquip, 1f); //PlayerKnowledgeDatabase.KnowledgeDemonstrated(ConceptDefOf.EquippingWeapons, KnowledgeAmount.Total); }, MenuOptionPriority.High, null, null, 0f, null, null); } opts.Add(itemSlotLoadable); } } return(opts); } } return(opts); } KeyValuePair <_Condition, Func <Vector3, Pawn, Thing, List <FloatMenuOption> > > curSec = new KeyValuePair <_Condition, Func <Vector3, Pawn, Thing, List <FloatMenuOption> > >(curCondition, CurFunc); FloatMenus.Add(curSec); return(FloatMenus); }
public override IEnumerable <KeyValuePair <_Condition, Func <Vector3, Pawn, Thing, List <FloatMenuOption> > > > GetFloatMenus() { List <KeyValuePair <_Condition, Func <Vector3, Pawn, Thing, List <FloatMenuOption> > > > floatMenus = new List <KeyValuePair <_Condition, Func <Vector3, Pawn, Thing, List <FloatMenuOption> > > >(); _Condition straitjacketCondition = new _Condition(_ConditionType.IsType, typeof(Pawn)); Func <Vector3, Pawn, Thing, List <FloatMenuOption> > straitjacketFunc = delegate(Vector3 clickPos, Pawn pawn, Thing curThing) { List <FloatMenuOption> opts = new List <FloatMenuOption>(); Pawn target = curThing as Pawn; if (pawn != target && !pawn.Dead && !pawn.Downed) { IntVec3 c = clickPos.ToIntVec3(); if (target?.RaceProps?.Humanlike ?? false) { //Let's proceed if our 'actor' is capable of manipulation if (pawn.health.capacities.CapableOf(PawnCapacityDefOf.Manipulation)) { //Does the target have a straitjacket? //We can help them remove the straitjacket. if (target?.apparel?.WornApparel?.FirstOrDefault(x => x.def == StraitjacketDefOf.ROM_Straitjacket) != null) { if (!pawn.CanReach(c, PathEndMode.OnCell, Danger.Deadly, false, TraverseMode.ByPawn)) { opts.Add(new FloatMenuOption("CannotRemoveStraitjacket".Translate() + " (" + "NoPath".Translate() + ")", null, MenuOptionPriority.Default, null, null, 0f, null, null)); } else if (!pawn.CanReserve(target, 1)) { opts.Add(new FloatMenuOption("CannotRemoveStraitjacket".Translate() + ": " + "Reserved".Translate(), null, MenuOptionPriority.Default, null, null, 0f, null, null)); } else { Action action = delegate { Job job = new Job(StraitjacketDefOf.ROM_TakeOffStraitjacket, target); job.count = 1; pawn.jobs.TryTakeOrderedJob(job); }; opts.Add(new FloatMenuOption("RemoveStraitjacket".Translate(new object[] { target.LabelCap }), action, MenuOptionPriority.High, null, target, 0f, null, null)); } } //We can put one on! else { if (pawn.Map.listerThings.ThingsInGroup(ThingRequestGroup.Apparel).FirstOrDefault((Thing x) => x.def == StraitjacketDefOf.ROM_Straitjacket) != null) { if (!pawn.CanReach(c, PathEndMode.OnCell, Danger.Deadly, false, TraverseMode.ByPawn)) { opts.Add(new FloatMenuOption("CannotForceStraitjacket".Translate() + " (" + "NoPath".Translate() + ")", null, MenuOptionPriority.Default, null, null, 0f, null, null)); } else if (!pawn.CanReserve(target, 1)) { opts.Add(new FloatMenuOption("CannotForceStraitjacket".Translate() + ": " + "Reserved".Translate(), null, MenuOptionPriority.Default, null, null, 0f, null, null)); } else { Action action = delegate { Thing straitjacket = GenClosest.ClosestThingReachable(pawn.Position, pawn.Map, ThingRequest.ForDef(StraitjacketDefOf.ROM_Straitjacket), PathEndMode.Touch, TraverseParms.For(pawn)); Job job = new Job(StraitjacketDefOf.ROM_ForceIntoStraitjacket, target, straitjacket); job.count = 1; job.locomotionUrgency = LocomotionUrgency.Sprint; pawn.jobs.TryTakeOrderedJob(job); }; opts.Add(new FloatMenuOption("ForceStraitjacketUpon".Translate(new object[] { target.LabelCap }), action, MenuOptionPriority.High, null, target, 0f, null, null)); } } } } } return(opts); } return(null); }; KeyValuePair <_Condition, Func <Vector3, Pawn, Thing, List <FloatMenuOption> > > curSec = new KeyValuePair <_Condition, Func <Vector3, Pawn, Thing, List <FloatMenuOption> > > (straitjacketCondition, straitjacketFunc); floatMenus.Add(curSec); return(floatMenus); }
public override IEnumerable <KeyValuePair <_Condition, Func <Vector3, Pawn, Thing, List <FloatMenuOption> > > > GetFloatMenus() { List <KeyValuePair <_Condition, Func <Vector3, Pawn, Thing, List <FloatMenuOption> > > > FloatMenus = new List <KeyValuePair <_Condition, Func <Vector3, Pawn, Thing, List <FloatMenuOption> > > >(); _Condition curCondition = new _Condition(_ConditionType.IsType, typeof(ThingWithComps)); Func <Vector3, Pawn, Thing, List <FloatMenuOption> > curFunc = delegate(Vector3 clickPos, Pawn pawn, Thing curThing) { List <FloatMenuOption> opts = new List <FloatMenuOption>(); ThingWithComps slotLoadable = curThing as ThingWithComps; if (slotLoadable != null && slotLoadable.GetComp <CompSlotLoadable>() is CompSlotLoadable compSlotLoadable) { IntVec3 c = clickPos.ToIntVec3(); List <Thing> thingList = c.GetThingList(pawn.Map); foreach (SlotLoadable slot in compSlotLoadable.Slots) { Thing loadableThing = thingList.FirstOrDefault((Thing y) => slot.CanLoad(y.def)); if (loadableThing != null) { FloatMenuOption itemSlotLoadable; string labelShort = loadableThing.Label; if (!pawn.health.capacities.CapableOf(PawnCapacityDefOf.Manipulation)) { itemSlotLoadable = new FloatMenuOption("CannotEquip".Translate(new object[] { labelShort }) + " (" + "Incapable".Translate() + ")", null, MenuOptionPriority.Default, null, null, 0f, null, null); } else if (!pawn.CanReach(loadableThing, PathEndMode.ClosestTouch, Danger.Deadly)) { itemSlotLoadable = new FloatMenuOption("CannotEquip".Translate(new object[] { labelShort }) + " (" + "NoPath".Translate() + ")", null, MenuOptionPriority.Default, null, null, 0f, null, null); } else if (!pawn.CanReserve(loadableThing, 1)) { itemSlotLoadable = new FloatMenuOption("CannotEquip".Translate(new object[] { labelShort }) + " (" + "ReservedBy".Translate(new object[] { pawn.Map.physicalInteractionReservationManager.FirstReserverOf(loadableThing).LabelShort }) + ")", null, MenuOptionPriority.Default, null, null, 0f, null, null); } else { string text2 = "Equip".Translate(new object[] { labelShort }); itemSlotLoadable = new FloatMenuOption(text2, delegate { loadableThing.SetForbidden(false, true); pawn.jobs.TryTakeOrderedJob(new Job(DefDatabase <JobDef> .GetNamed("GatherSlotItem"), loadableThing)); MoteMaker.MakeStaticMote(loadableThing.DrawPos, loadableThing.Map, ThingDefOf.Mote_FeedbackEquip, 1f); //PlayerKnowledgeDatabase.KnowledgeDemonstrated(ConceptDefOf.EquippingWeapons, KnowledgeAmount.Total); }, MenuOptionPriority.High, null, null, 0f, null, null); } opts.Add(itemSlotLoadable); } } } return(opts); }; KeyValuePair <_Condition, Func <Vector3, Pawn, Thing, List <FloatMenuOption> > > curSec = new KeyValuePair <_Condition, Func <Vector3, Pawn, Thing, List <FloatMenuOption> > >(curCondition, curFunc); FloatMenus.Add(curSec); return(FloatMenus); }
public override IEnumerable <KeyValuePair <_Condition, Func <Vector3, Pawn, Thing, List <FloatMenuOption> > > > GetFloatMenus() { List <KeyValuePair <_Condition, Func <Vector3, Pawn, Thing, List <FloatMenuOption> > > > floatMenus = new List <KeyValuePair <_Condition, Func <Vector3, Pawn, Thing, List <FloatMenuOption> > > >(); _Condition silverCondition = new _Condition(_ConditionType.IsType, typeof(ThingWithComps)); Func <Vector3, Pawn, Thing, List <FloatMenuOption> > silverFunc = delegate(Vector3 clickPos, Pawn pawn, Thing curThing) { List <FloatMenuOption> opts = null; ThingWithComps target = curThing as ThingWithComps; if ((target?.def?.IsWeapon ?? false)) { if (pawn?.Map?.listerBuildings?.AllBuildingsColonistOfDef(DefDatabase <ThingDef> .GetNamed("TableMachining"))? .FirstOrDefault(x => x is Building_WorkTable) is Building_WorkTable machiningTable) { opts = new List <FloatMenuOption>(); if (target.IsSilverTreated()) { //Do nothing } else if (!pawn.CanReach(target, PathEndMode.OnCell, Danger.Deadly, false, TraverseMode.ByPawn)) { opts.Add(new FloatMenuOption("ROM_CannotApplySilverTreatment".Translate() + " (" + "NoPath".Translate() + ")", null, MenuOptionPriority.Default, null, null, 0f, null, null)); } else if (!pawn.CanReserve(target, 1)) { opts.Add(new FloatMenuOption("ROM_CannotApplySilverTreatment".Translate() + ": " + "Reserved".Translate(), null, MenuOptionPriority.Default, null, null, 0f, null, null)); } else if (!pawn.CanReach(machiningTable, PathEndMode.OnCell, Danger.Deadly, false, TraverseMode.ByPawn)) { opts.Add(new FloatMenuOption("ROM_CannotApplySilverTreatment".Translate() + " (" + "ROM_NoPathToMachiningTable".Translate() + ")", null, MenuOptionPriority.Default, null, null, 0f, null, null)); } else if (!pawn.CanReserve(machiningTable, 1)) { opts.Add(new FloatMenuOption("ROM_CannotApplySilverTreatment".Translate() + ": " + "ROM_MachiningTableReserved".Translate(), null, MenuOptionPriority.Default, null, null, 0f, null, null)); } else if (pawn.Map.resourceCounter.Silver < SilverTreatedUtility.AmountRequired(target)) { opts.Add(new FloatMenuOption("ROM_CannotApplySilverTreatment".Translate() + ": " + "ROM_NeedsSilver".Translate(SilverTreatedUtility.AmountRequired(target)), null, MenuOptionPriority.Default, null, null, 0f, null, null)); } else { Action action = delegate { Job job = new Job(WWDefOf.ROM_ApplySilverTreatment, target, SilverTreatedUtility.FindSilver(pawn), machiningTable); job.count = SilverTreatedUtility.AmountRequired(target); pawn.jobs.TryTakeOrderedJob(job); }; opts.Add(new FloatMenuOption("ROM_ApplySilverTreatment".Translate(new object[] { target.LabelCap, SilverTreatedUtility.AmountRequired(target) }), action, MenuOptionPriority.High, null, target, 0f, null, null)); } return(opts); } } return(null); }; KeyValuePair <_Condition, Func <Vector3, Pawn, Thing, List <FloatMenuOption> > > curSec = new KeyValuePair <_Condition, Func <Vector3, Pawn, Thing, List <FloatMenuOption> > >(silverCondition, silverFunc); floatMenus.Add(curSec); return(floatMenus); }
GetFloatMenus() { var curCondition = new _Condition(_ConditionType.ThingHasComp, typeof(CompSlottedBonus));
GetFloatMenus() { var curCondition = new _Condition(_ConditionType.IsType, typeof(ThingWithComps));
GetFloatMenus() { var floatMenus = new List <KeyValuePair <_Condition, Func <Vector3, Pawn, Thing, List <FloatMenuOption> > > >(); var madnessCondition = new _Condition(_ConditionType.IsType, typeof(Pawn)); List <FloatMenuOption> madnessFunc(Vector3 clickPos, Pawn pawn, Thing curThing) { var target = curThing as Pawn; if (pawn != target) { return(null); } if (!Utility.HasSanityLoss(pawn)) { return(null); } var opts = new List <FloatMenuOption>(); void action() { var newMentalState = Rand.Value > 0.05 ? DefDatabase <MentalStateDef> .AllDefs.InRandomOrder() .FirstOrDefault(x => x.IsAggro == false) : MentalStateDefOf.Berserk; Utility.DebugReport("Selected mental state: " + newMentalState?.label); if (pawn != null && pawn.Drafted) { pawn.drafter.Drafted = false; } pawn?.ClearMind(); pawn?.pather.StopDead(); if (pawn != null && !pawn.mindState.mentalStateHandler.TryStartMentalState(newMentalState)) { Messages.Message("ROM_TradedSanityLossForMadnessFailed".Translate(pawn.LabelShort), pawn, MessageTypeDefOf.RejectInput); return; } Messages.Message("ROM_TradedSanityLossForMadness".Translate(pawn?.LabelShort), pawn, MessageTypeDefOf.ThreatSmall); Utility.RemoveSanityLoss(pawn); } opts.Add(new FloatMenuOption("ROM_TradeSanityForMadness".Translate(), action, MenuOptionPriority.High, null, target)); return(opts); } var curSec = new KeyValuePair <_Condition, Func <Vector3, Pawn, Thing, List <FloatMenuOption> > >(madnessCondition, madnessFunc); floatMenus.Add(curSec); return(floatMenus); }