public void UpdatePacks() { if (enableDebug && multiThreaded) { //Log.Message("Thread started."); } IEnumerable <Pawn> pawnsOnMap = RimValiUtility.AllPawnsOfRaceInWorld(AvaliDefs.RimVali).Where <Pawn>(x => RimValiUtility.GetPackSize(x) < maxSize); foreach (Pawn pawn in pawnsOnMap) { //Log.Message(pawn.Faction.Name); //Log.Message(pawn.Name.ToString() + " updatePacks()"); PackComp comp = pawn.TryGetComp <PackComp>(); if (!(comp == null)) { //Pull the comp info from the pawn SimpleCurve ageCurve = comp.Props.packGenChanceOverAge; //Tells us that this pawn has had a pack if (enableDebug) { //Log.Message("Attempting to make pack.. [Base pack]"); } //Makes the pack. //Log.Message("EiPackHandlerFromPackDriverMapComp started."); packs = RimValiUtility.EiPackHandler(packs, pawn, racesInPacks, maxSize); } } }
public void UpdatePacks() { IEnumerable <Pawn> pawnsOnMap = RimValiUtility.AllPawnsOfRaceOnMap(AvaliDefs.RimVali, map).Where(x => (RimValiUtility.GetPackSize(x, x.TryGetComp <PackComp>().Props.relation) < maxSize) & racesInPacks.Contains(x.def)); foreach (Pawn pawn in pawnsOnMap) { PackComp comp = pawn.TryGetComp <PackComp>(); if (!(comp == null)) { //Pull the comp info from the pawn PawnRelationDef relationDef = comp.Props.relation; SimpleCurve ageCurve = comp.Props.packGenChanceOverAge; if (RimValiUtility.GetPackSize(pawn, relationDef) == 1) { //Tells us that this pawn has had a pack if (enableDebug) { Log.Message("Attempting to make pack.. [Base pack]"); } //Makes the pack. RimValiUtility.KeoBuildMakePack(pawn, relationDef, racesInPacks, maxSize); } } } }
public void UpdateSharedRoomThought(Pawn pawn) { if (pawn.Awake()) { AvaliThoughtDriver avaliThoughtDriver = pawn.TryGetComp <AvaliThoughtDriver>(); if (RimValiUtility.CheckIfPackmatesInRoom(pawn)) { RimValiUtility.AddThought(pawn, avaliThoughtDriver.Props.inSameRoomThought); } else { RimValiUtility.RemoveThought(pawn, avaliThoughtDriver.Props.inSameRoomThought); } } else { AvaliThoughtDriver avaliThoughtDriver = pawn.TryGetComp <AvaliThoughtDriver>(); if (RimValiUtility.PackInBedroom(pawn)) { RimValiUtility.AddThought(pawn, avaliThoughtDriver.Props.sharedBedroomThought); } else { RimValiUtility.AddThought(pawn, avaliThoughtDriver.Props.sleptApartThought); } } }
public void UpdatePawns(Map map) { IEnumerable <Pawn> pawns = RimValiUtility.CheckAllPawnsInMapAndFaction(map, Faction.OfPlayer).Where(x => x.def == AvaliDefs.RimVali); foreach (Pawn pawn in pawns) { AvaliThoughtDriver avaliThoughtDriver = pawn.TryGetComp <AvaliThoughtDriver>(); PackComp packComp = pawn.TryGetComp <PackComp>(); if (!(avaliThoughtDriver == null)) { if (pawn.def == AvaliDefs.RimVali) { if (RimValiUtility.GetPackSize(pawn, avaliThoughtDriver.Props.relationDef) > 1) { PawnRelationDef relationDef = avaliThoughtDriver.Props.relationDef; UpdateSharedRoomThought(pawn, relationDef, avaliThoughtDriver.Props.inSameRoomThought); UpdateBedRoomThought(pawn, relationDef, avaliThoughtDriver.Props.sharedBedroomThought, avaliThoughtDriver.Props.sleptApartThought); } } } if (!(packComp == null)) { if (packComp.Props.canHaveAloneThought) { UpdateThought(pawn, packComp.Props.relation, packComp.Props.aloneThought); } } } }
public virtual AvaliPack GetPack(Pawn pawn) { AvaliPack pack = null; pack = RimValiUtility.GetPack(pawn); return(pack); }
private void SendDrop() { GenDate.DayOfYear(ticks, Find.WorldGrid.LongLatOf(map.Tile).x); List <Thing> thingList = new List <Thing>(); thingList.Add(ThingMaker.MakeThing(AvaliDefs.AvaliNexus)); Scribe_Values.Look(ref hasDropped, "hasDropped", false); Map target = map; List <Faction> newFactions = new List <Faction>(); IntVec3 intVec3 = DropCellFinder.TradeDropSpot(target); if (RimValiUtility.PawnOfRaceCount(Faction.OfPlayer, AvaliDefs.RimVali) >= 5 && !hasDropped) { hasDropped = true; for (int a = 0; a < random.Next(2, 5); a++) { Faction faction = FactionGenerator.NewGeneratedFaction(AvaliDefs.AvaliFaction); faction.Name = "IlluminateFactionName".Translate() + ": #" + a.ToString(); faction.SetRelationDirect(Faction.OfPlayer, FactionRelationKind.Ally); newFactions.Add(faction); } DropPodUtility.DropThingsNear(intVec3, target, (IEnumerable <Thing>)thingList); ChoiceLetter choiceLetter = LetterMaker.MakeLetter("IlluminateAirdrop".Translate(), "AirdropEventDesc".Translate(), AvaliMod.AvaliDefs.IlluminateAirdrop, newFactions[random.Next(newFactions.Count)]); Find.LetterStack.ReceiveLetter(choiceLetter, null); } }
public void AddThought(ThoughtDef thought, PawnRelationDef relationDef, Pawn pawn) { if (RimValiUtility.GetPackSize(pawn, relationDef) == 1 && packLossEnabled) { RimValiUtility.AddThought(pawn, thought); } }
public override void DoWindowContents(Rect inRect) { bool flag = false; if (Event.current.type == EventType.KeyDown && Event.current.keyCode == KeyCode.Return) { flag = true; Event.current.Use(); } Text.Font = GameFont.Medium; string text = "Pack name: "; Widgets.Label(new Rect(15f, 15f, 500f, 50f), text); Text.Font = GameFont.Small; string text2 = Widgets.TextField(new Rect(15f, 50f, inRect.width / 2f - 20f, 35f), this.curPackName); if (text2.Length < 30 && CharacterCardUtility.ValidNameRegex.IsMatch(text2)) { this.curPackName = text2; } if (Widgets.ButtonText(new Rect(inRect.width / 2f + 20f, inRect.height - 35f, inRect.width / 2f - 20f, 35f), "OK", true, true, true) || flag) { if (string.IsNullOrEmpty(this.curPackName)) { this.curPackName = RimValiUtility.GetPack(pawn).name; } RimValiUtility.GetPack(pawn).name = this.curPackName; Find.WindowStack.TryRemove(this, true); } }
public Dialog_NamePack(Pawn pawn) { this.pawn = pawn; this.curPackName = RimValiUtility.GetPack(pawn).name; this.forcePause = true; this.absorbInputAroundWindow = true; this.closeOnClickedOutside = true; this.closeOnAccept = false; }
public void UpdateBedRoomThought(Pawn pawn, PawnRelationDef relationDef, ThoughtDef togetherThought, ThoughtDef aloneThought) { if (RimValiUtility.CheckIfBedRoomHasPackmates(pawn, relationDef)) { RimValiUtility.AddThought(pawn, togetherThought); } else { RimValiUtility.RemoveThought(pawn, aloneThought); } }
protected override bool TryExecuteWorker(IncidentParms parms) { List<Thing> thingList = new List<Thing>(); thingList.Add(ThingMaker.MakeThing(AvaliDefs.AvaliNanoForge)); Map target = (Map)parms.target; IntVec3 intVec3 = DropCellFinder.TradeDropSpot(target); if (RimValiUtility.PawnOfRaceCount(Faction.OfPlayer, AvaliDefs.RimVali) >= 5 && !hasDropped) { hasDropped = true; DropPodUtility.DropThingsNear(intVec3, target, (IEnumerable<Thing>)thingList); this.SendStandardLetter("Illuminate Airdrop", "Illuminate Airdrop", AvaliDefs.IlluminateAirdrop,parms, (LookTargets)new TargetInfo(intVec3, target, false), (NamedArgument[])Array.Empty<NamedArgument>()); } return true; }
public Pawn PawnToUpload() { ThingWithComps parent = this.parent; List <Pawn> pawns = RimValiUtility.CheckAllPawnsInMapAndFaction(parent.Map, parent.Faction).ToList <Pawn>(); foreach (Pawn pawn in pawns) { PhysicalInteractionReservationManager physicalInteractionReservationManager = new PhysicalInteractionReservationManager(); if (physicalInteractionReservationManager.IsReservedBy(pawn, this.parent) == true) { return(pawn); } } return(null); }
public void UpdateSharedRoomThought(Pawn pawn, PawnRelationDef relationDef, ThoughtDef thought) { if (pawn.Awake()) { AvaliThoughtDriver avaliThoughtDriver = pawn.TryGetComp <AvaliThoughtDriver>(); if (RimValiUtility.CheckIfPackmatesInRoom(pawn, relationDef)) { RimValiUtility.AddThought(pawn, thought); } else { RimValiUtility.RemoveThought(pawn, thought); } } }
public void UpdatePackLoss(Pawn pawn) { AvaliThoughtDriver thoughtComp = pawn.TryGetComp <AvaliThoughtDriver>(); PackComp packComp = pawn.TryGetComp <PackComp>(); if (packComp.ticksSinceLastInpack == 0 && (RimValiUtility.GetPackWithoutSelf(pawn) == null || RimValiUtility.GetPackWithoutSelf(pawn).size < 2)) { packComp.ticksSinceLastInpack = Find.TickManager.TicksGame; } else if (RimValiUtility.GetPackWithoutSelf(pawn) != null && RimValiUtility.GetPackWithoutSelf(pawn).size > 1) { packComp.ticksSinceLastInpack = 0; } }
static AvaliShaderDatabase() { string dir = RimValiUtility.dir; Log.Message(dir); string path = dir + "/RimValiAssetBundles/shader"; AssetBundle bundle = RimValiUtility.shaderLoader(path); Tricolor = (Shader)bundle.LoadAsset("assets/resources/materials/avalishader.shader"); if (!(Tricolor == null)) { Log.Message(Tricolor.name); Log.Message("Load worked!"); } }
public void UpdatePawns(Map map) { AvaliPackDriver AvaliPackDriver = Current.Game.GetComponent <AvaliPackDriver>(); IEnumerable <Pawn> pawns = RimValiUtility.CheckAllPawnsInMapAndFaction(map, Faction.OfPlayer).Where(x => AvaliPackDriver.racesInPacks.Contains(x.def)); IEnumerable <AvaliPack> packs = AvaliPackDriver.packs; foreach (Pawn pawn in pawns) { AvaliThoughtDriver avaliThoughtDriver = pawn.TryGetComp <AvaliThoughtDriver>(); PackComp packComp = pawn.TryGetComp <PackComp>(); if (!(avaliThoughtDriver == null)) { //Log.Message("Pawn has pack comp, moving to next step..."); if (AvaliPackDriver.packs == null || AvaliPackDriver.packs.Count == 0) { //Log.Message("How did we get here? [Pack list was 0 or null]"); return; } AvaliPack pawnPack = null; //This errors out when pawns dont have a pack, in rare cases. That is bad. This stops it from doing that. try { pawnPack = pawn.GetPack(); } catch { return; } //Log.Message("Tried to get packs pack, worked."); if (pawnPack == null) { //Log.Message("How did we get here? [Pack was null.]"); break; } foreach (Pawn packmate in pawnPack.pawns) { Thought_Memory thought_Memory2 = (Thought_Memory)ThoughtMaker.MakeThought(packComp.Props.togetherThought); if (!(packmate == pawn) && packmate != null && pawn != null) { bool bubble; if (!thought_Memory2.TryMergeWithExistingMemory(out bubble)) { //Log.Message("Adding thought to pawn."); pawn.needs.mood.thoughts.memories.TryGainMemory(thought_Memory2, packmate); } } } } } }
public static bool AllowDropWhenPawnCountMet(IncidentParms parms, List <ThingDef> things, ThingDef race, int requiredCount) { List <Thing> thingList = new List <Thing>(); foreach (ThingDef thingDef in things) { thingList.Add(ThingMaker.MakeThing(thingDef)); } Map target = (Map)parms.target; IntVec3 intVec3 = DropCellFinder.TradeDropSpot(target); if (RimValiUtility.PawnOfRaceCount(Faction.OfPlayer, race) >= requiredCount) { DropPodUtility.DropThingsNear(intVec3, target, (IEnumerable <Thing>)thingList); } return(true); }
public static bool CheckIfPackmatesInRoom(Pawn pawn, PawnRelationDef relationDef) { Room room = pawn.GetRoom(); if (!(room == null) && (pawn.Position.Roofed(pawn.Map))) { IEnumerable <Pawn> pawns = RimValiUtility.GetPackPawns(pawn, relationDef); foreach (Pawn packmate in pawns) { if (packmate.GetRoom(RegionType.Set_Passable) == room) { return(true); } } } return(false); }
public void MakeNewPacks() { if (enableDebug && multiThreaded) { Log.Message("Thread started."); } IEnumerable <Pawn> pawnsOnMap = RimValiUtility.AllPawnsOfRaceOnMap(AvaliDefs.RimVali, map).Where <Pawn>(x => RimValiUtility.GetPackSize(x, x.TryGetComp <PackComp>().Props.relation) < maxSize); foreach (Pawn pawn in pawnsOnMap) { PackComp comp = pawn.TryGetComp <PackComp>(); if (!(comp == null)) { //Pull the comp info from the pawn PawnRelationDef relationDef = comp.Props.relation; SimpleCurve ageCurve = comp.Props.packGenChanceOverAge; //Tells us that this pawn has had a pack if (enableDebug) { Log.Message("Attempting to make pack.. [New/added pack]"); } //Makes the pack. foreach (Pawn packmate in pawnsOnMap) { //RimValiUtility.KeoBuildMakeBasePack(pawn, relationDef, racesInPacks, maxSize); RimValiUtility.EiBuildMakeBasePack(pawn, relationDef, racesInPacks, maxSize, packs); if (RimValiUtility.GetPackSize(pawn, relationDef) <= 0) { RimValiUtility.EiBuildMakeBasePack(pawn, relationDef, racesInPacks, maxSize, packs); } else { RimValiUtility.EiBuildMakeBasePack(pawn, relationDef, racesInPacks, maxSize, packs); } if (RimValiUtility.GetPackSize(pawn, relationDef) == maxSize) { break; } } } } }
public void UpdatePawns(Map map) { List <ThingDef> races = RimvaliPotentialPackRaces.potentialPackRaces.ToList <ThingDef>(); IEnumerable <Pawn> pawns = RimValiUtility.CheckAllPawnsInMapAndFaction(map, Faction.OfPlayer); foreach (Pawn pawn in pawns) { if (pawn.IsHashIntervalTick(120)) { AvaliThoughtDriver avaliThoughtDriver = pawn.TryGetComp <AvaliThoughtDriver>(); if (pawn.def == AvaliDefs.RimVali) { if (RimValiUtility.GetPackSize(pawn, avaliThoughtDriver.Props.relationDef) > 0) { PawnRelationDef relationDef = avaliThoughtDriver.Props.relationDef; UpdateSharedRoomThought(pawn, relationDef, avaliThoughtDriver.Props.inSameRoomThought); UpdateBedRoomThought(pawn, relationDef, avaliThoughtDriver.Props.sharedBedroomThought, avaliThoughtDriver.Props.sleptApartThought); } } } } }