mirror of
https://gitgud.io/c0ffeeeeeeee/rimworld-animations.git
synced 2024-08-15 00:43:45 +00:00
Compare commits
2 commits
abb3c1fe18
...
0e9419b039
Author | SHA1 | Date | |
---|---|---|---|
|
0e9419b039 | ||
|
96986104d5 |
14 changed files with 235 additions and 5 deletions
Binary file not shown.
21
1.5/Defs/VoiceDefs/VoiceDef_Human.xml
Normal file
21
1.5/Defs/VoiceDefs/VoiceDef_Human.xml
Normal file
|
@ -0,0 +1,21 @@
|
|||
<?xml version="1.0" encoding="utf-8" ?>
|
||||
<Defs>
|
||||
<Rimworld_Animations.VoiceDef>
|
||||
<defName>Voice_HumanFemale</defName>
|
||||
<race>Human</race>
|
||||
<gender>Female</gender>
|
||||
<sounds>
|
||||
<!-- <li><key>Moan</key><value>FemaleMoanSoundDefHere</value></li> -->
|
||||
</sounds>
|
||||
</Rimworld_Animations.VoiceDef>
|
||||
|
||||
<Rimworld_Animations.VoiceDef>
|
||||
<defName>Voice_HumanMale</defName>
|
||||
<race>Human</race>
|
||||
<gender>Male</gender>
|
||||
<sounds>
|
||||
<!-- <li><key>Moan</key><value>MaleMoanSoundDefHere</value></li> -->
|
||||
</sounds>
|
||||
</Rimworld_Animations.VoiceDef>
|
||||
|
||||
</Defs>
|
16
1.5/Defs/VoiceDefs/VoiceDef_Orassan.xml
Normal file
16
1.5/Defs/VoiceDefs/VoiceDef_Orassan.xml
Normal file
|
@ -0,0 +1,16 @@
|
|||
<?xml version="1.0" encoding="utf-8" ?>
|
||||
<Defs>
|
||||
<!--
|
||||
<Rimworld_Animations.VoiceDef>
|
||||
<defName>Voice_Orassan</defName>
|
||||
<race>Alien_Orassan</race>
|
||||
<gender>Male</gender>
|
||||
<traitDefs>
|
||||
<li>Wimpy</li>
|
||||
</traitDefs>
|
||||
<sounds>
|
||||
<li><key>Moan</key><value>CatMoans</value></li>
|
||||
</sounds>
|
||||
</Rimworld_Animations.VoiceDef>
|
||||
-->
|
||||
</Defs>
|
6
1.5/Defs/VoiceDefs/VoiceTagDef.xml
Normal file
6
1.5/Defs/VoiceDefs/VoiceTagDef.xml
Normal file
|
@ -0,0 +1,6 @@
|
|||
<?xml version="1.0" encoding="utf-8" ?>
|
||||
<Defs>
|
||||
<Rimworld_Animations.VoiceTagDef>
|
||||
<defName>Moan</defName>
|
||||
</Rimworld_Animations.VoiceTagDef>
|
||||
</Defs>
|
|
@ -22,6 +22,23 @@ namespace Rimworld_Animations
|
|||
return base.OffsetAtTick(tick, parms);
|
||||
}
|
||||
|
||||
public VoiceTagDef voiceAtTick(int tick)
|
||||
{
|
||||
|
||||
Verse.Keyframe keyframe2 = this.part.keyframes[this.part.keyframes.Count - 1];
|
||||
foreach (Verse.Keyframe keyframe in this.part.keyframes)
|
||||
{
|
||||
if (tick == keyframe.tick)
|
||||
{
|
||||
return (keyframe as ExtendedKeyframe).voice;
|
||||
}
|
||||
|
||||
}
|
||||
|
||||
return null;
|
||||
|
||||
}
|
||||
|
||||
public SoundDef soundAtTick(int tick)
|
||||
{
|
||||
|
||||
|
|
|
@ -52,7 +52,7 @@ namespace Rimworld_Animations
|
|||
{
|
||||
if (context.AnimationPriority() > priority)
|
||||
{
|
||||
//get highest priority context for fitting animation
|
||||
//get highest priority context for fitting animation, and its reorder
|
||||
priority = context.AnimationPriority();
|
||||
reorder = context.AnimationReorder();
|
||||
|
||||
|
|
|
@ -13,6 +13,7 @@ namespace Rimworld_Animations
|
|||
public int? variant;
|
||||
public Rot4 rotation = Rot4.North;
|
||||
public SoundDef sound = null;
|
||||
public VoiceTagDef voice = null;
|
||||
public bool visible = true;
|
||||
}
|
||||
}
|
||||
|
|
|
@ -19,11 +19,11 @@ namespace Rimworld_Animations {
|
|||
|
||||
private List<AnimationDef> animationQueue;
|
||||
private BaseExtendedAnimatorAnchor anchor;
|
||||
private int? rotation;
|
||||
private Vector3? offset;
|
||||
private bool isAnimating = false;
|
||||
private VoiceDef voice;
|
||||
|
||||
|
||||
private bool isAnimating = false;
|
||||
|
||||
public bool IsAnimating
|
||||
{
|
||||
get
|
||||
|
@ -40,6 +40,8 @@ namespace Rimworld_Animations {
|
|||
}
|
||||
}
|
||||
|
||||
private Vector3? offset;
|
||||
|
||||
public Vector3? Offset
|
||||
{
|
||||
get
|
||||
|
@ -52,6 +54,8 @@ namespace Rimworld_Animations {
|
|||
}
|
||||
}
|
||||
|
||||
private int? rotation;
|
||||
|
||||
public int? Rotation
|
||||
{
|
||||
get
|
||||
|
@ -90,6 +94,15 @@ namespace Rimworld_Animations {
|
|||
|
||||
}
|
||||
|
||||
public override void PostSpawnSetup(bool respawningAfterLoad)
|
||||
{
|
||||
if (voice == null)
|
||||
{
|
||||
AssignNewVoice();
|
||||
}
|
||||
|
||||
}
|
||||
|
||||
public Vector3 getAnchor()
|
||||
{
|
||||
return anchor.getDrawPos();
|
||||
|
@ -184,6 +197,7 @@ namespace Rimworld_Animations {
|
|||
Scribe_Values.Look<int>(ref this.animationTicks, "animations_ticks", 0);
|
||||
Scribe_Collections.Look<AnimationDef>(ref animationQueue, "animations_queue");
|
||||
Scribe_Deep.Look<BaseExtendedAnimatorAnchor>(ref this.anchor, "animations_anchor");
|
||||
Scribe_Defs.Look<VoiceDef>(ref this.voice, "animations_voice");
|
||||
|
||||
}
|
||||
|
||||
|
@ -233,6 +247,29 @@ namespace Rimworld_Animations {
|
|||
|
||||
}
|
||||
|
||||
public void AssignNewVoice()
|
||||
{
|
||||
//all voice options
|
||||
List<VoiceDef> voiceOptions =
|
||||
DefDatabase<VoiceDef>.AllDefsListForReading
|
||||
.FindAll(voiceDef => voiceDef.VoiceFitsPawn(pawn));
|
||||
|
||||
//all voice options, with priority (for traitdef specific voices)
|
||||
List<VoiceDef> voiceOptionsWithPriority =
|
||||
voiceOptions.FindAll(voiceDef => voiceDef.takesPriority);
|
||||
|
||||
if (!voiceOptionsWithPriority.NullOrEmpty())
|
||||
{
|
||||
voice = voiceOptionsWithPriority.RandomElementByWeight(x => x.randomChanceFactor);
|
||||
|
||||
}
|
||||
else if (!voiceOptions.NullOrEmpty())
|
||||
{
|
||||
voice = voiceOptions.RandomElementByWeight(x => x.randomChanceFactor);
|
||||
}
|
||||
|
||||
}
|
||||
|
||||
public void CheckAndPlaySounds()
|
||||
{
|
||||
|
||||
|
@ -247,9 +284,32 @@ namespace Rimworld_Animations {
|
|||
sound.PlayOneShot(new TargetInfo(pawn.Position, pawn.Map));
|
||||
}
|
||||
|
||||
//play voice sounds
|
||||
VoiceTagDef voiceTag = animWorker.voiceAtTick(rootNode.tree.AnimationTick);
|
||||
if (voiceTag != null)
|
||||
{
|
||||
if (voice != null && voice.sounds.ContainsKey(voiceTag))
|
||||
{
|
||||
voice.sounds[voiceTag].PlayOneShot(new TargetInfo(pawn.Position, pawn.Map));
|
||||
}
|
||||
|
||||
else if (pawn.RaceProps.Humanlike && RJWAnimationSettings.playHumanlikeVoicesAsDefault)
|
||||
{
|
||||
//play default voice
|
||||
VoiceDef pawnDefaultVoice = (pawn.gender == Gender.Male ? VoiceDefOf.Voice_HumanMale : VoiceDefOf.Voice_HumanFemale);
|
||||
if (pawnDefaultVoice.sounds.ContainsKey(voiceTag))
|
||||
{
|
||||
pawnDefaultVoice.sounds[voiceTag].PlayOneShot(new TargetInfo(pawn.Position, pawn.Map));
|
||||
}
|
||||
|
||||
|
||||
}
|
||||
|
||||
}
|
||||
|
||||
}
|
||||
|
||||
//check rootnodes and children
|
||||
if (rootNode?.children != null)
|
||||
{
|
||||
foreach (PawnRenderNode node in rootNode?.children)
|
||||
|
@ -262,6 +322,25 @@ namespace Rimworld_Animations {
|
|||
sound.PlayOneShot(new TargetInfo(pawn.Position, pawn.Map));
|
||||
}
|
||||
|
||||
//play voice sounds
|
||||
VoiceTagDef voiceTag = childrenAnimWorker.voiceAtTick(rootNode.tree.AnimationTick);
|
||||
if (voiceTag != null)
|
||||
{
|
||||
if (voice != null && voice.sounds.ContainsKey(voiceTag))
|
||||
{
|
||||
voice.sounds[voiceTag].PlayOneShot(new TargetInfo(pawn.Position, pawn.Map));
|
||||
}
|
||||
else if (pawn.RaceProps.Humanlike && RJWAnimationSettings.playHumanlikeVoicesAsDefault)
|
||||
{
|
||||
|
||||
VoiceDef pawnDefaultVoice = (pawn.gender == Gender.Male ? VoiceDefOf.Voice_HumanMale : VoiceDefOf.Voice_HumanFemale);
|
||||
if (pawnDefaultVoice.sounds.ContainsKey(voiceTag))
|
||||
{
|
||||
pawnDefaultVoice.sounds[voiceTag].PlayOneShot(new TargetInfo(pawn.Position, pawn.Map));
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
}
|
||||
}
|
||||
}
|
||||
|
@ -269,6 +348,9 @@ namespace Rimworld_Animations {
|
|||
|
||||
}
|
||||
|
||||
|
||||
|
||||
|
||||
public bool AnimationMakesUseOfProp(AnimationPropDef animationProp)
|
||||
{
|
||||
// never true if not animating; anim props shouldn't be attached
|
||||
|
|
|
@ -14,6 +14,9 @@ namespace Rimworld_Animations {
|
|||
public static bool orgasmQuiver, rapeShiver, soundOverride = true, hearts = true, controlGenitalRotation = false,
|
||||
PlayAnimForNonsexualActs = true;
|
||||
|
||||
//probably move this setting to a different mod menu if moving rjw parts of code
|
||||
public static bool playHumanlikeVoicesAsDefault = true;
|
||||
|
||||
public static bool offsetTab = false, debugMode = false;
|
||||
public static float shiverIntensity = 2f;
|
||||
|
||||
|
@ -21,6 +24,7 @@ namespace Rimworld_Animations {
|
|||
|
||||
base.ExposeData();
|
||||
|
||||
Scribe_Values.Look(ref playHumanlikeVoicesAsDefault, "RJWAnimations-playHumanlikeVoicesAsDefault", true);
|
||||
Scribe_Values.Look(ref debugMode, "RJWAnimations-AnimsDebugMode", false);
|
||||
Scribe_Values.Look(ref offsetTab, "RJWAnimations-EnableOffsetTab", false);
|
||||
Scribe_Values.Look(ref controlGenitalRotation, "RJWAnimations-controlGenitalRotation", false);
|
||||
|
@ -55,6 +59,7 @@ namespace Rimworld_Animations {
|
|||
listingStandard.CheckboxLabeled("RimAnim_HeartsDuringLovin".Translate(), ref RJWAnimationSettings.hearts);
|
||||
listingStandard.CheckboxLabeled("RimAnim_PlayNonsexual".Translate(), ref RJWAnimationSettings.PlayAnimForNonsexualActs);
|
||||
listingStandard.CheckboxLabeled("RimAnim_AnimManagerTab".Translate(), ref RJWAnimationSettings.offsetTab);
|
||||
listingStandard.CheckboxLabeled("RimAnim_HumanlikeVoicesDefault".Translate(), ref RJWAnimationSettings.playHumanlikeVoicesAsDefault);
|
||||
listingStandard.Label("RimAnim_ShiverIntensity".Translate() + RJWAnimationSettings.shiverIntensity);
|
||||
RJWAnimationSettings.shiverIntensity = listingStandard.Slider(RJWAnimationSettings.shiverIntensity, 0.0f, 12f);
|
||||
|
||||
|
|
39
1.5/Source/Voices/VoiceDef.cs
Normal file
39
1.5/Source/Voices/VoiceDef.cs
Normal file
|
@ -0,0 +1,39 @@
|
|||
using RimWorld;
|
||||
using System;
|
||||
using System.Collections.Generic;
|
||||
using System.Linq;
|
||||
using System.Text;
|
||||
using System.Threading.Tasks;
|
||||
using Verse;
|
||||
|
||||
namespace Rimworld_Animations
|
||||
{
|
||||
public class VoiceDef : Def
|
||||
{
|
||||
|
||||
public ThingDef race;
|
||||
public Gender gender = Gender.None;
|
||||
public List<TraitDef> traits = new List<TraitDef>();
|
||||
public bool takesPriority = false;
|
||||
public float randomChanceFactor = 1;
|
||||
|
||||
public Dictionary<VoiceTagDef, SoundDef> sounds = new Dictionary<VoiceTagDef, SoundDef>();
|
||||
|
||||
public bool VoiceFitsPawn(Pawn pawn)
|
||||
{
|
||||
|
||||
//doesn't match race
|
||||
if (pawn.def != race) return false;
|
||||
|
||||
//doesn't match gender
|
||||
if (gender != Gender.None && pawn.gender != gender) return false;
|
||||
|
||||
//if traits list is not empty, and pawn doesn't have any of the designated traits, doesn't match
|
||||
if (!traits.Empty() && !traits.Any(trait => pawn.story.traits.HasTrait(trait))) return false;
|
||||
|
||||
return true;
|
||||
|
||||
}
|
||||
|
||||
}
|
||||
}
|
22
1.5/Source/Voices/VoiceDefOf.cs
Normal file
22
1.5/Source/Voices/VoiceDefOf.cs
Normal file
|
@ -0,0 +1,22 @@
|
|||
using RimWorld;
|
||||
using rjw;
|
||||
using System;
|
||||
using System.Collections.Generic;
|
||||
using System.Linq;
|
||||
using System.Text;
|
||||
using System.Threading.Tasks;
|
||||
|
||||
namespace Rimworld_Animations
|
||||
{
|
||||
[DefOf]
|
||||
public static class VoiceDefOf
|
||||
{
|
||||
static VoiceDefOf()
|
||||
{
|
||||
DefOfHelper.EnsureInitializedInCtor(typeof(VoiceDefOf));
|
||||
}
|
||||
|
||||
public static VoiceDef Voice_HumanMale;
|
||||
public static VoiceDef Voice_HumanFemale;
|
||||
}
|
||||
}
|
13
1.5/Source/Voices/VoiceTagDef.cs
Normal file
13
1.5/Source/Voices/VoiceTagDef.cs
Normal file
|
@ -0,0 +1,13 @@
|
|||
using System;
|
||||
using System.Collections.Generic;
|
||||
using System.Linq;
|
||||
using System.Text;
|
||||
using System.Threading.Tasks;
|
||||
using Verse;
|
||||
|
||||
namespace Rimworld_Animations
|
||||
{
|
||||
public class VoiceTagDef : Def
|
||||
{
|
||||
}
|
||||
}
|
|
@ -11,6 +11,7 @@
|
|||
<RimAnim_PlayNonsexual>Play animation for nonsexual acts (handholding, makeout)</RimAnim_PlayNonsexual>
|
||||
<RimAnim_AnimManagerTab>Enable Animation Manager Tab</RimAnim_AnimManagerTab>
|
||||
<RimAnim_ShiverIntensity>Shiver/Quiver Intensity (default 2): </RimAnim_ShiverIntensity>
|
||||
<RimAnim_HumanlikeVoicesDefault>Play humanlike voices by default</RimAnim_HumanlikeVoicesDefault>
|
||||
<RimAnim_DebugMode>Debug Mode</RimAnim_DebugMode>
|
||||
|
||||
<!-- Main Tab Window -->
|
||||
|
@ -19,4 +20,5 @@
|
|||
<RimAnims_CopyToClipboard>Copy Offset to Clipboard</RimAnims_CopyToClipboard>
|
||||
<RimAnims_ShareSettings>Paste offset values in OffsetDef, or share in Discord</RimAnims_ShareSettings>
|
||||
|
||||
|
||||
</LanguageData>
|
|
@ -134,6 +134,9 @@
|
|||
<Compile Include="1.5\Source\RenderSubWorkers\PawnRenderSubWorker_ChangeOffset.cs" />
|
||||
<Compile Include="1.5\Source\Patches\RJWPatches\RJWAnimationSettings.cs" />
|
||||
<Compile Include="1.5\Source\Utilities\AnimationUtility.cs" />
|
||||
<Compile Include="1.5\Source\Voices\VoiceDef.cs" />
|
||||
<Compile Include="1.5\Source\Voices\VoiceDefOf.cs" />
|
||||
<Compile Include="1.5\Source\Voices\VoiceTagDef.cs" />
|
||||
<Compile Include="Properties\AssemblyInfo.cs" />
|
||||
</ItemGroup>
|
||||
<ItemGroup>
|
||||
|
@ -193,6 +196,9 @@
|
|||
<Content Include="1.5\Defs\TexPathVariantsDefs\TexPathVariants_Xray_Inside.xml" />
|
||||
<Content Include="1.5\Defs\TexPathVariantsDefs\TexPathVariants_XrayPenis_Horse.xml" />
|
||||
<Content Include="1.5\Defs\AnimationDefs\Cowgirl\TexPathVariants_Cowgirl.xml" />
|
||||
<Content Include="1.5\Defs\VoiceDefs\VoiceDef_Human.xml" />
|
||||
<Content Include="1.5\Defs\VoiceDefs\VoiceDef_Orassan.xml" />
|
||||
<Content Include="1.5\Defs\VoiceDefs\VoiceTagDef.xml" />
|
||||
<Content Include="1.5\Patches\AnimationPatchHSK.xml" />
|
||||
<Content Include="1.5\Patches\AnimationPatch_CompExtendedAnimator.xml" />
|
||||
<Content Include="1.5\Patches\AnimationPatch_PawnRenderTree_OffsetSubWorker.xml" />
|
||||
|
|
Loading…
Reference in a new issue