Skip to content
This repository has been archived by the owner on Nov 3, 2022. It is now read-only.

Commit

Permalink
Added meme code and fixed Flecks
Browse files Browse the repository at this point in the history
  • Loading branch information
juanosarg committed Jul 19, 2021
1 parent 7cda4ca commit 8425eb6
Show file tree
Hide file tree
Showing 14 changed files with 196 additions and 7 deletions.
Binary file modified 1.3/Assemblies/VFECore.dll
Binary file not shown.
Original file line number Diff line number Diff line change
Expand Up @@ -45,7 +45,7 @@ public override void CompTick()
//Only work on not dead, not downed, not psychically immune colonists
if (!pawn.Dead && !pawn.Downed && pawn.GetStatValue(StatDefOf.PsychicSensitivity, true) > 0f)
{
MoteMaker.MakeAttachedOverlay(this.parent, ThingDef.Named("Mote_PsycastPsychicEffect"), Vector3.zero, 1f, -1f);
FleckMaker.AttachedOverlay(this.parent, DefDatabase<FleckDef>.GetNamed("PsycastPsychicEffect"), Vector3.zero, 1f, -1f);
pawn.health.AddHediff(HediffDef.Named(Props.hediff));
}
}
Expand Down
2 changes: 1 addition & 1 deletion Source/VFECore/AnimalBehaviours/Comps/CompMindEffecter.cs
Original file line number Diff line number Diff line change
Expand Up @@ -46,7 +46,7 @@ public override void CompTick()
{
Find.TickManager.slower.SignalForceNormalSpeedShort();
SoundDefOf.PsychicPulseGlobal.PlayOneShot(new TargetInfo(this.parent.Position, this.parent.Map, false));
MoteMaker.MakeAttachedOverlay(this.parent, ThingDef.Named("Mote_PsycastPsychicEffect"), Vector3.zero, 1f, -1f);
FleckMaker.AttachedOverlay(this.parent, DefDatabase<FleckDef>.GetNamed("PsycastPsychicEffect"), Vector3.zero, 1f, -1f);
pawn.mindState.mentalStateHandler.TryStartMentalState(DefDatabase<MentalStateDef>.GetNamed(Props.mentalState, true), null, true, false, null, false);
}
}
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -51,7 +51,7 @@ public override void CompTick()
{

SoundDefOf.PsychicPulseGlobal.PlayOneShot(new TargetInfo(this.parent.Position, this.parent.Map, false));
MoteMaker.MakeAttachedOverlay(this.parent, ThingDef.Named("Mote_PsycastPsychicEffect"), Vector3.zero, 1f, -1f);
FleckMaker.AttachedOverlay(this.parent, DefDatabase<FleckDef>.GetNamed("PsycastPsychicEffect"), Vector3.zero, 1f, -1f);
}
//Regenerate wounds
if (pawn.health != null)
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -50,7 +50,7 @@ public override void CompTick()
{
Find.TickManager.slower.SignalForceNormalSpeedShort();
SoundDefOf.PsychicPulseGlobal.PlayOneShot(new TargetInfo(this.parent.Position, this.parent.Map, false));
MoteMaker.MakeAttachedOverlay(this.parent, ThingDef.Named("Mote_PsycastPsychicEffect"), Vector3.zero, 1f, -1f);
FleckMaker.AttachedOverlay(this.parent, DefDatabase<FleckDef>.GetNamed("PsycastPsychicEffect"), Vector3.zero, 1f, -1f);
}
if (!Props.conditionalOnWellBeing)
{
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -45,7 +45,7 @@ public override void Notify_PawnDied()
if (resurrectionsLeft > 1)
{
SoundDefOf.PsychicPulseGlobal.PlayOneShot(new TargetInfo(this.parent.pawn.Corpse.Position, this.parent.pawn.Corpse.Map, false));
MoteMaker.MakeAttachedOverlay(this.parent.pawn.Corpse, ThingDef.Named("Mote_PsycastPsychicEffect"), Vector3.zero, 1f, -1f);
FleckMaker.AttachedOverlay(this.parent.pawn, DefDatabase<FleckDef>.GetNamed("PsycastPsychicEffect"), Vector3.zero, 1f, -1f);
ResurrectionUtility.Resurrect(this.parent.pawn.Corpse.InnerPawn);
resurrectionsLeft--;
}
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -52,7 +52,7 @@ public override void CompPostTick(ref float severityAdjustment)
{
Find.TickManager.slower.SignalForceNormalSpeedShort();
SoundDefOf.PsychicPulseGlobal.PlayOneShot(new TargetInfo(this.parent.pawn.Position, this.parent.pawn.Map, false));
MoteMaker.MakeAttachedOverlay(this.parent.pawn, ThingDef.Named("Mote_PsycastPsychicEffect"), Vector3.zero, 1f, -1f);
FleckMaker.AttachedOverlay(this.parent.pawn, DefDatabase<FleckDef>.GetNamed("PsycastPsychicEffect"), Vector3.zero, 1f, -1f);
}
if (!Props.conditionalOnWellBeing)
{
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -113,7 +113,8 @@ public override void Notify_PawnDied()
if (map != null)
{
SoundDefOf.PsychicPulseGlobal.PlayOneShot(new TargetInfo(this.parent.pawn.Corpse.Position, this.parent.pawn.Corpse.Map, false));
MoteMaker.MakeAttachedOverlay(this.parent.pawn.Corpse, ThingDef.Named("Mote_PsycastPsychicEffect"), Vector3.zero, 1f, -1f);
FleckMaker.AttachedOverlay(this.parent.pawn.Corpse, DefDatabase<FleckDef>.GetNamed("PsycastPsychicEffect"), Vector3.zero, 1f, -1f);

ResurrectionUtility.Resurrect(this.parent.pawn.Corpse.InnerPawn);

}
Expand Down
21 changes: 21 additions & 0 deletions Source/VFECore/Memes/DefModExtensions/ExtendedMemeProperties.cs
Original file line number Diff line number Diff line change
@@ -0,0 +1,21 @@
using System;
using System.Collections.Generic;
using System.Linq;
using System.Text;
using Verse;
using RimWorld;
using System.Reflection;
using System.Reflection.Emit;


namespace VanillaMemesExpanded
{

public class ExtendedMemeProperties : DefModExtension
{

public string neededMeme;

}

}
17 changes: 17 additions & 0 deletions Source/VFECore/Memes/Defs/StartingItemsByIdeologyDef.cs
Original file line number Diff line number Diff line change
@@ -0,0 +1,17 @@
using System;
using System.Collections.Generic;
using System.Linq;
using System.Text;
using System.Threading.Tasks;
using RimWorld;
using Verse;

namespace VanillaMemesExpanded
{
public class StartingItemsByIdeologyDef : Def
{

public MemeDef associatedMeme;
public ThingSetMakerDef thingSetMaker;
}
}
Original file line number Diff line number Diff line change
@@ -0,0 +1,38 @@
using System;
using System.Collections.Generic;
using System.Linq;
using System.Text;
using RimWorld;
using Verse;
using UnityEngine;
using RimWorld.Planet;

namespace VanillaMemesExpanded
{
public class GameComponent_IdeologicalGoodies : GameComponent
{

public bool sentOncePerGame = false;

public GameComponent_IdeologicalGoodies(Game game)
{

}

public override void ExposeData()
{
base.ExposeData();

Scribe_Values.Look<bool>(ref this.sentOncePerGame, "sentOncePerGame", false, true);


}




}


}

Original file line number Diff line number Diff line change
@@ -0,0 +1,53 @@
using HarmonyLib;
using RimWorld;
using System.Reflection;
using Verse;
using System.Reflection.Emit;
using System.Collections.Generic;
using UnityEngine;
using System.Linq;
using System;
using Verse.AI;

namespace VanillaMemesExpanded
{

[HarmonyPatch(typeof(Dialog_ChooseMemes))]
[HarmonyPatch("GetFirstIncompatibleMemePair")]
public static class VanillaMemesExpanded_Dialog_ChooseMemes_GetFirstIncompatibleMemePair_Patch
{
[HarmonyPostfix]
public static void DetectIfRequiredMeme(ref List<MemeDef> ___newMemes, ref Pair<MemeDef, MemeDef> __result)

{
List<MemeDef> memesTemp = ___newMemes;
for (int i = 0; i < ___newMemes.Count; i++)
{
ExtendedMemeProperties extendedMemeProps = ___newMemes[i].GetModExtension<ExtendedMemeProperties>();
if (extendedMemeProps != null)
{

List<MemeDef> structureMemeDefs = (from k in DefDatabase<MemeDef>.AllDefsListForReading
where k.category == MemeCategory.Structure && memesTemp.Contains(k)
select k).ToList();

foreach (MemeDef memeDef in structureMemeDefs)
{
if (___newMemes[i].GetModExtension<ExtendedMemeProperties>().neededMeme != memeDef.defName)
{

__result = new Pair<MemeDef, MemeDef>(___newMemes[i], memeDef);
}
}
}





}


}
}
}
Original file line number Diff line number Diff line change
@@ -0,0 +1,54 @@
using System;
using System.Collections.Generic;
using System.Linq;
using System.Text;
using RimWorld;
using Verse;
using UnityEngine;
using RimWorld.Planet;

namespace VanillaMemesExpanded
{
public class MapComponent_IdeologicalGoodies : MapComponent
{



public MapComponent_IdeologicalGoodies(Map map) : base(map)
{

}



public override void FinalizeInit()
{
base.FinalizeInit();
if (!Current.Game.GetComponent<GameComponent_IdeologicalGoodies>().sentOncePerGame)
{

List<Thing> things = new List<Thing>();

foreach (StartingItemsByIdeologyDef startingItems in DefDatabase<StartingItemsByIdeologyDef>.AllDefsListForReading)
{
if (Current.Game.World.factionManager.OfPlayer.ideos.PrimaryIdeo.HasMeme(startingItems.associatedMeme))
{
things = startingItems.thingSetMaker.root.Generate();
}

}
if (things.Count > 0) { DropPodUtility.DropThingsNear(MapGenerator.PlayerStartSpot, map, things, 110); }


Current.Game.GetComponent<GameComponent_IdeologicalGoodies>().sentOncePerGame = true;
}


}


}


}

5 changes: 5 additions & 0 deletions Source/VFECore/VFECore.csproj
Original file line number Diff line number Diff line change
Expand Up @@ -521,6 +521,11 @@
<Compile Include="Furniture\Utility\StoneTypeSettableUtility.cs" />
<Compile Include="GlobalSettings.cs" />
<Compile Include="GlobalSettingsUtilities.cs" />
<Compile Include="Memes\DefModExtensions\ExtendedMemeProperties.cs" />
<Compile Include="Memes\Defs\StartingItemsByIdeologyDef.cs" />
<Compile Include="Memes\GameComponent\GameComponent_IdeologicalGoodies.cs" />
<Compile Include="Memes\Harmony\Dialog_ChooseMemes_GetFirstIncompatibleMemePair_Patch.cs" />
<Compile Include="Memes\MapComponent\MapComponent_IdeologicalGoodies.cs" />
<Compile Include="VFECore\Apparels\Apparel_ShieldBubble.cs" />
<Compile Include="VFECore\Buildings\Building_BedMachine.cs" />
<Compile Include="VFECore\Buildings\Building_MechTurretGun.cs" />
Expand Down

0 comments on commit 8425eb6

Please sign in to comment.