Example #1
0
        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);
                }
            }
        }
Example #2
0
        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);
                    }
                }
            }
        }
Example #3
0
 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);
         }
     }
 }
Example #4
0
        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);
                    }
                }
            }
        }
Example #5
0
        public virtual AvaliPack GetPack(Pawn pawn)
        {
            AvaliPack pack = null;

            pack = RimValiUtility.GetPack(pawn);
            return(pack);
        }
Example #6
0
        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);
            }
        }
Example #7
0
 public void AddThought(ThoughtDef thought, PawnRelationDef relationDef, Pawn pawn)
 {
     if (RimValiUtility.GetPackSize(pawn, relationDef) == 1 && packLossEnabled)
     {
         RimValiUtility.AddThought(pawn, thought);
     }
 }
Example #8
0
        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);
            }
        }
Example #9
0
 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;
 }
Example #10
0
 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);
     }
 }
Example #11
0
 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;
 }
Example #12
0
        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);
        }
Example #13
0
 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);
         }
     }
 }
Example #14
0
        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;
            }
        }
Example #15
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!");
            }
        }
Example #16
0
        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);
                            }
                        }
                    }
                }
            }
        }
Example #17
0
        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);
        }
Example #18
0
        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);
        }
Example #19
0
        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;
                        }
                    }
                }
            }
        }
Example #20
0
        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);
                        }
                    }
                }
            }
        }