mirror of
				https://gitgud.io/AbstractConcept/rimworld-animation-studio.git
				synced 2024-08-15 00:43:27 +00:00 
			
		
		
		
	Code refactor
This commit is contained in:
		
							parent
							
								
									cd4711a8e5
								
							
						
					
					
						commit
						757badf4f6
					
				
					 517 changed files with 2534 additions and 2221 deletions
				
			
		
										
											Binary file not shown.
										
									
								
							| 
						 | 
				
			
			@ -67,34 +67,32 @@
 | 
			
		|||
    <Compile Include="Assets\Scripts\AdvancedPolygonCollider\AdvancedPolygonColliderUtilities.cs" />
 | 
			
		||||
    <Compile Include="Assets\Scripts\AnimationComponents\Actor.cs" />
 | 
			
		||||
    <Compile Include="Assets\Scripts\AnimationComponents\ActorAddon.cs" />
 | 
			
		||||
    <Compile Include="Assets\Scripts\AnimationComponents\AlienRaceDef.cs" />
 | 
			
		||||
    <Compile Include="Assets\Scripts\AnimationComponents\AlienRaceOffset.cs" />
 | 
			
		||||
    <Compile Include="Assets\Scripts\AnimationComponents\AnimationClips\AnimationClip.cs" />
 | 
			
		||||
    <Compile Include="Assets\Scripts\AnimationComponents\AnimationClips\PawnAnimationClip.cs" />
 | 
			
		||||
    <Compile Include="Assets\Scripts\AnimationComponents\AnimationClips\ThingAnimationClip.cs" />
 | 
			
		||||
    <Compile Include="Assets\Scripts\AnimationComponents\AddonKeyFrame.cs" />
 | 
			
		||||
    <Compile Include="Assets\Scripts\AnimationComponents\AnimationDef.cs" />
 | 
			
		||||
    <Compile Include="Assets\Scripts\AnimationComponents\AnimationStage.cs" />
 | 
			
		||||
    <Compile Include="Assets\Scripts\AnimationComponents\BodyTypeOffset.cs" />
 | 
			
		||||
    <Compile Include="Assets\Scripts\AnimationComponents\ButtonWithKeyCode.cs" />
 | 
			
		||||
    <Compile Include="Assets\Scripts\AnimationComponents\Chaser.cs" />
 | 
			
		||||
    <Compile Include="Assets\Scripts\AnimationComponents\Defs.cs" />
 | 
			
		||||
    <Compile Include="Assets\Scripts\AnimationComponents\KeyFrames\AddonKeyFrame.cs" />
 | 
			
		||||
    <Compile Include="Assets\Scripts\AnimationComponents\KeyFrames\Keyframe.cs" />
 | 
			
		||||
    <Compile Include="Assets\Scripts\AnimationComponents\KeyFrames\PawnKeyframe.cs" />
 | 
			
		||||
    <Compile Include="Assets\Scripts\AnimationComponents\KeyFrames\ThingKeyFrame.cs" />
 | 
			
		||||
    <Compile Include="Assets\Scripts\AnimationComponents\PawnAnimationClip.cs" />
 | 
			
		||||
    <Compile Include="Assets\Scripts\AnimationComponents\PawnKeyframe.cs" />
 | 
			
		||||
    <Compile Include="Assets\Scripts\AnimationComponents\PawnRaceDef.cs" />
 | 
			
		||||
    <Compile Include="Assets\Scripts\AnimationComponents\PawnRaceOffset.cs" />
 | 
			
		||||
    <Compile Include="Assets\Scripts\Data\Constants.cs" />
 | 
			
		||||
    <Compile Include="Assets\Scripts\Data\DefaultTags.cs" />
 | 
			
		||||
    <Compile Include="Assets\Scripts\Data\Enums.cs" />
 | 
			
		||||
    <Compile Include="Assets\Scripts\DefParents\AnimationDefs.cs" />
 | 
			
		||||
    <Compile Include="Assets\Scripts\DefParents\PawnRaceDefs.cs" />
 | 
			
		||||
    <Compile Include="Assets\Scripts\Extensions\IListExtensions.cs" />
 | 
			
		||||
    <Compile Include="Assets\Scripts\Extensions\ObjectExtensions.cs" />
 | 
			
		||||
    <Compile Include="Assets\Scripts\Extensions\TransformExtensions.cs" />
 | 
			
		||||
    <Compile Include="Assets\Scripts\Extensions\Vector3Extension.cs" />
 | 
			
		||||
    <Compile Include="Assets\Scripts\GUI\ActorAddonCard.cs" />
 | 
			
		||||
    <Compile Include="Assets\Scripts\GUI\ActorBody.cs" />
 | 
			
		||||
    <Compile Include="Assets\Scripts\GUI\ActorBodyPart.cs" />
 | 
			
		||||
    <Compile Include="Assets\Scripts\GUI\ActorCard.cs" />
 | 
			
		||||
    <Compile Include="Assets\Scripts\GUI\ActorKeyframeCard.cs" />
 | 
			
		||||
    <Compile Include="Assets\Scripts\GUI\ActorManipulator.cs" />
 | 
			
		||||
    <Compile Include="Assets\Scripts\GUI\Actors\ActorBody.cs" />
 | 
			
		||||
    <Compile Include="Assets\Scripts\GUI\Actors\ActorBodyPart.cs" />
 | 
			
		||||
    <Compile Include="Assets\Scripts\GUI\AddSoundDefButton.cs" />
 | 
			
		||||
    <Compile Include="Assets\Scripts\GUI\AnimationDefCard.cs" />
 | 
			
		||||
    <Compile Include="Assets\Scripts\GUI\AnimationTimeline.cs" />
 | 
			
		||||
    <Compile Include="Assets\Scripts\GUI\Cards\ActorAddonCard.cs" />
 | 
			
		||||
    <Compile Include="Assets\Scripts\GUI\Cards\ActorCard.cs" />
 | 
			
		||||
    <Compile Include="Assets\Scripts\GUI\Cards\ActorKeyframeCard.cs" />
 | 
			
		||||
    <Compile Include="Assets\Scripts\GUI\Cards\AnimationDefCard.cs" />
 | 
			
		||||
    <Compile Include="Assets\Scripts\GUI\Cards\StageCard.cs" />
 | 
			
		||||
    <Compile Include="Assets\Scripts\GUI\DialogBoxes\ConsoleMessagesDialog.cs" />
 | 
			
		||||
    <Compile Include="Assets\Scripts\GUI\DialogBoxes\DialogBox.cs" />
 | 
			
		||||
    <Compile Include="Assets\Scripts\GUI\DialogBoxes\RaceSettingsDialog.cs" />
 | 
			
		||||
| 
						 | 
				
			
			@ -112,14 +110,18 @@
 | 
			
		|||
    <Compile Include="Assets\Scripts\GUI\KeyframeSlider.cs" />
 | 
			
		||||
    <Compile Include="Assets\Scripts\GUI\LinearScale.cs" />
 | 
			
		||||
    <Compile Include="Assets\Scripts\GUI\QuiverToggle.cs" />
 | 
			
		||||
    <Compile Include="Assets\Scripts\GUI\RequiresAnimationDef.cs" />
 | 
			
		||||
    <Compile Include="Assets\Scripts\GUI\SelectActorLayerButton.cs" />
 | 
			
		||||
    <Compile Include="Assets\Scripts\GUI\SelectRaceDropdown.cs" />
 | 
			
		||||
    <Compile Include="Assets\Scripts\GUI\SnapToKeyframe.cs" />
 | 
			
		||||
    <Compile Include="Assets\Scripts\GUI\StageCard.cs" />
 | 
			
		||||
    <Compile Include="Assets\Scripts\GUI\Tooltip.cs" />
 | 
			
		||||
    <Compile Include="Assets\Scripts\Graphics\DirectionalGraphic.cs" />
 | 
			
		||||
    <Compile Include="Assets\Scripts\GUI\SelfContained\ActorManipulator.cs" />
 | 
			
		||||
    <Compile Include="Assets\Scripts\GUI\SelfContained\ButtonWithKeyCode.cs" />
 | 
			
		||||
    <Compile Include="Assets\Scripts\GUI\SelfContained\Chaser.cs" />
 | 
			
		||||
    <Compile Include="Assets\Scripts\GUI\SelfContained\RequiresAnimationDef.cs" />
 | 
			
		||||
    <Compile Include="Assets\Scripts\GUI\SelfContained\SnapToKeyframe.cs" />
 | 
			
		||||
    <Compile Include="Assets\Scripts\GUI\SexProps\SexProp.cs" />
 | 
			
		||||
    <Compile Include="Assets\Scripts\GUI\SexProps\SexPropManager.cs" />
 | 
			
		||||
    <Compile Include="Assets\Scripts\GUI\Tooltips\Tooltip.cs" />
 | 
			
		||||
    <Compile Include="Assets\Scripts\GUI\Tooltips\TooltipMessage.cs" />
 | 
			
		||||
    <Compile Include="Assets\Scripts\Graphics\MultiDirectionalGraphic.cs" />
 | 
			
		||||
    <Compile Include="Assets\Scripts\Graphics\SingleGraphic.cs" />
 | 
			
		||||
    <Compile Include="Assets\Scripts\Keybinds\Keybind.cs" />
 | 
			
		||||
    <Compile Include="Assets\Scripts\Keybinds\KeybindConfig.cs" />
 | 
			
		||||
    <Compile Include="Assets\Scripts\Managers\AnimationController.cs" />
 | 
			
		||||
| 
						 | 
				
			
			@ -127,17 +129,14 @@
 | 
			
		|||
    <Compile Include="Assets\Scripts\Managers\CameraController.cs" />
 | 
			
		||||
    <Compile Include="Assets\Scripts\Managers\InputManager.cs" />
 | 
			
		||||
    <Compile Include="Assets\Scripts\Managers\StageCardManager.cs" />
 | 
			
		||||
    <Compile Include="Assets\Scripts\Math\Constants\Constants.cs" />
 | 
			
		||||
    <Compile Include="Assets\Scripts\Math\Constants\Enums.cs" />
 | 
			
		||||
    <Compile Include="Assets\Scripts\Math\CurvePoint.cs" />
 | 
			
		||||
    <Compile Include="Assets\Scripts\Math\GenMath.cs" />
 | 
			
		||||
    <Compile Include="Assets\Scripts\Math\SimpleCurve.cs" />
 | 
			
		||||
    <Compile Include="Assets\Scripts\SexProp.cs" />
 | 
			
		||||
    <Compile Include="Assets\Scripts\SexPropManager.cs" />
 | 
			
		||||
    <Compile Include="Assets\Scripts\Singleton.cs" />
 | 
			
		||||
    <Compile Include="Assets\Scripts\Strings\NumberValidator.cs" />
 | 
			
		||||
    <Compile Include="Assets\Scripts\Utilities\PawnUtility.cs" />
 | 
			
		||||
    <Compile Include="Assets\Scripts\Utilities\XmlUtility.cs" />
 | 
			
		||||
    <Compile Include="Assets\Scripts\Workspace\EventsManager.cs" />
 | 
			
		||||
    <Compile Include="Assets\Scripts\Workspace\HistoricRecord.cs" />
 | 
			
		||||
    <Compile Include="Assets\Scripts\Workspace\Workspace.cs" />
 | 
			
		||||
    <Compile Include="Assets\StandaloneFileBrowser\IStandaloneFileBrowser.cs" />
 | 
			
		||||
| 
						 | 
				
			
			@ -146,7 +145,7 @@
 | 
			
		|||
    <Compile Include="Assets\StandaloneFileBrowser\StandaloneFileBrowserLinux.cs" />
 | 
			
		||||
    <Compile Include="Assets\StandaloneFileBrowser\StandaloneFileBrowserMac.cs" />
 | 
			
		||||
    <Compile Include="Assets\StandaloneFileBrowser\StandaloneFileBrowserWindows.cs" />
 | 
			
		||||
    <None Include="Assets\StreamingAssets\alienRaceDefs.xml" />
 | 
			
		||||
    <None Include="Assets\StreamingAssets\pawnRaceDefs.xml" />
 | 
			
		||||
    <None Include="Assets\StreamingAssets\AnimationDefs\newAnimationDef.xml" />
 | 
			
		||||
    <None Include="Assets\StreamingAssets\keybindConfig.xml" />
 | 
			
		||||
    <None Include="Assets\StreamingAssets\customTags.xml" />
 | 
			
		||||
| 
						 | 
				
			
			
 | 
			
		|||
							
								
								
									
										6
									
								
								Assembly-CSharp.csproj.user
									
										
									
									
									
										Normal file
									
								
							
							
						
						
									
										6
									
								
								Assembly-CSharp.csproj.user
									
										
									
									
									
										Normal file
									
								
							| 
						 | 
				
			
			@ -0,0 +1,6 @@
 | 
			
		|||
<?xml version="1.0" encoding="utf-8"?>
 | 
			
		||||
<Project ToolsVersion="Current" xmlns="http://schemas.microsoft.com/developer/msbuild/2003">
 | 
			
		||||
  <PropertyGroup>
 | 
			
		||||
    <ProjectView>ProjectFiles</ProjectView>
 | 
			
		||||
  </PropertyGroup>
 | 
			
		||||
</Project>
 | 
			
		||||
| 
						 | 
				
			
			@ -647,6 +647,9 @@ MonoBehaviour:
 | 
			
		|||
  m_Script: {fileID: 11500000, guid: 20b2be62d5fdc4b4992cede005ec2aee, type: 3}
 | 
			
		||||
  m_Name: 
 | 
			
		||||
  m_EditorClassIdentifier: 
 | 
			
		||||
  stageName: {fileID: 1575336727571200468}
 | 
			
		||||
  stageNameField: {fileID: 8975510041719035916}
 | 
			
		||||
  banner: {fileID: 8402660926707036654}
 | 
			
		||||
--- !u!1 &5467517697077698744
 | 
			
		||||
GameObject:
 | 
			
		||||
  m_ObjectHideFlags: 0
 | 
			
		||||
| 
						 | 
				
			
			
 | 
			
		|||
										
											
												File diff suppressed because it is too large
												Load diff
											
										
									
								
							| 
						 | 
				
			
			@ -1,5 +1,5 @@
 | 
			
		|||
fileFormatVersion: 2
 | 
			
		||||
guid: 20033872660014f4295d8ac40800a707
 | 
			
		||||
guid: ff71352a02fb53440a35dbeabb9ebc87
 | 
			
		||||
folderAsset: yes
 | 
			
		||||
DefaultImporter:
 | 
			
		||||
  externalObjects: {}
 | 
			
		||||
| 
						 | 
				
			
			@ -8,80 +8,143 @@ namespace RimWorldAnimationStudio
 | 
			
		|||
{
 | 
			
		||||
    public class Actor
 | 
			
		||||
    {
 | 
			
		||||
        [XmlArray("defNames"), XmlArrayItem("li")] public List<string> defNames = new List<string>();
 | 
			
		||||
        [XmlArray("bodyDefTypes"), XmlArrayItem("li")] public List<string> bodyDefTypes = new List<string>();
 | 
			
		||||
        [XmlArray("requiredGender"), XmlArrayItem("li")] public List<string> requiredGender = new List<string>();
 | 
			
		||||
        [XmlArray("requiredGenitals"), XmlArrayItem("li")] public List<string> requiredGenitals = new List<string>();      
 | 
			
		||||
        [XmlArray("raceOffsets"), XmlArrayItem("li")] public List<AlienRaceOffset> raceOffsets = new List<AlienRaceOffset>();
 | 
			
		||||
        [XmlArray("blacklistedRaces"), XmlArrayItem("li")] public List<string> blacklistedRaces = new List<string>();      
 | 
			
		||||
        // Data to/from animationDef
 | 
			
		||||
        [XmlArray("defNames"), XmlArrayItem("li")] public List<string> defNames;
 | 
			
		||||
        [XmlArray("bodyDefTypes"), XmlArrayItem("li")] public List<string> bodyDefTypes;
 | 
			
		||||
        [XmlArray("requiredGenitals"), XmlArrayItem("li")] public List<string> requiredGenitals;      
 | 
			
		||||
        [XmlArray("raceOffsets"), XmlArrayItem("li")] public List<PawnRaceOffset> raceOffsets;
 | 
			
		||||
        [XmlArray("tags"), XmlArrayItem("li")] public List<string> tags;
 | 
			
		||||
        public BodyTypeOffset bodyTypeOffset;
 | 
			
		||||
        public bool? initiator = false;
 | 
			
		||||
        public bool? controlGenitalAngle;
 | 
			
		||||
        public bool? isFucking;
 | 
			
		||||
        public bool? isFucked;
 | 
			
		||||
 | 
			
		||||
        [XmlIgnore] public ActorGender gender;
 | 
			
		||||
        [XmlIgnore] private AlienRaceDef alienRaceDef;
 | 
			
		||||
 | 
			
		||||
        public BodyTypeOffset bodyTypeOffset = new BodyTypeOffset();
 | 
			
		||||
        public bool initiator = false;
 | 
			
		||||
        public bool controlGenitalAngle;
 | 
			
		||||
        public bool isFucking;
 | 
			
		||||
        public bool isFucked;
 | 
			
		||||
 | 
			
		||||
        [XmlIgnore] public string bodyType = "Male";
 | 
			
		||||
 | 
			
		||||
        // Data serialization control
 | 
			
		||||
        public bool ShouldSerializedefNames() { return defNames.NotNullOrEmpty(); }
 | 
			
		||||
        public bool ShouldSerializebodyDefTypes() { return bodyDefTypes.NotNullOrEmpty(); }
 | 
			
		||||
        public bool ShouldSerializerequiredGender() { return requiredGender.NotNullOrEmpty(); }
 | 
			
		||||
        public bool ShouldSerializerequiredGenitals() { return requiredGenitals.NotNullOrEmpty(); }
 | 
			
		||||
        public bool ShouldSerializeraceOffsets() { return raceOffsets.NotNullOrEmpty(); }
 | 
			
		||||
        public bool ShouldSerializeblacklistedRaces() { return blacklistedRaces.NotNullOrEmpty(); }
 | 
			
		||||
        public bool ShouldSerializetags() { return tags.NotNullOrEmpty(); }
 | 
			
		||||
        public bool ShouldSerializeinitiator() { return initiator; }
 | 
			
		||||
        public bool ShouldSerializecontrolGenitalAngle() { return controlGenitalAngle; }
 | 
			
		||||
        public bool ShouldSerializeisFucking() { return isFucking; }
 | 
			
		||||
        public bool ShouldSerializeisFucked() { return isFucked; }
 | 
			
		||||
        public bool ShouldSerializebodyTypeOffset() { return bodyTypeOffset?.AllOffsetsEmpty() == false; }
 | 
			
		||||
        public bool ShouldSerializeinitiator() { return initiator == true; }
 | 
			
		||||
        public bool ShouldSerializecontrolGenitalAngle() { return controlGenitalAngle == true; }
 | 
			
		||||
        public bool ShouldSerializeisFucking() { return isFucking == true; }
 | 
			
		||||
        public bool ShouldSerializeisFucked() { return isFucked == true; }
 | 
			
		||||
 | 
			
		||||
        public AlienRaceDef GetAlienRaceDef()
 | 
			
		||||
        // Data helper functions
 | 
			
		||||
        [XmlIgnore] public List<string> DefNames 
 | 
			
		||||
        { 
 | 
			
		||||
            if (alienRaceDef == null)
 | 
			
		||||
            { alienRaceDef = AlienRaceDefs.GetNamed("Human"); }
 | 
			
		||||
 | 
			
		||||
            return alienRaceDef;
 | 
			
		||||
            get { return defNames.NullOrEmpty() ? defNames = new List<string>() : defNames; } 
 | 
			
		||||
            set { defNames = value.NotNullOrEmpty() ? value : null; EventsManager.OnActorChanged(this); } 
 | 
			
		||||
        }
 | 
			
		||||
 | 
			
		||||
        public void SetAlienRaceDef(string alienRaceDefName)
 | 
			
		||||
        [XmlIgnore] public List<string> BodyDefTypes 
 | 
			
		||||
        { 
 | 
			
		||||
            AlienRaceDef alienRaceDef = AlienRaceDefs.GetNamed(alienRaceDefName);
 | 
			
		||||
 | 
			
		||||
            if (alienRaceDef != null)
 | 
			
		||||
            { this.alienRaceDef = alienRaceDef; }
 | 
			
		||||
            get { return bodyDefTypes.NullOrEmpty() ? bodyDefTypes = new List<string>() : bodyDefTypes; } 
 | 
			
		||||
            set { bodyDefTypes = value.NotNullOrEmpty() ? value : null; EventsManager.OnActorChanged(this); }
 | 
			
		||||
        }
 | 
			
		||||
 | 
			
		||||
        public Vector3 GetAlienRaceOffset()
 | 
			
		||||
        [XmlIgnore] public List<string> RequiredGenitals 
 | 
			
		||||
        { 
 | 
			
		||||
            if (alienRaceDef == null)
 | 
			
		||||
            { alienRaceDef = AlienRaceDefs.GetNamed("Human"); }
 | 
			
		||||
            get { return requiredGenitals.NullOrEmpty() ? requiredGenitals = new List<string>() : requiredGenitals; } 
 | 
			
		||||
            set { requiredGenitals = value.NotNullOrEmpty() ? value : null; EventsManager.OnActorChanged(this); }
 | 
			
		||||
        }
 | 
			
		||||
 | 
			
		||||
            AlienRaceOffset raceOffset = raceOffsets.FirstOrDefault(x => x.defName == alienRaceDef.defName);
 | 
			
		||||
        [XmlIgnore] public List<PawnRaceOffset> RaceOffsets { 
 | 
			
		||||
            get { return raceOffsets.NullOrEmpty() ? raceOffsets = new List<PawnRaceOffset>() : raceOffsets; } 
 | 
			
		||||
            set { raceOffsets = value.NotNullOrEmpty() ? value : null; EventsManager.OnActorChanged(this); }
 | 
			
		||||
        }
 | 
			
		||||
 | 
			
		||||
        [XmlIgnore] public List<string> Tags 
 | 
			
		||||
        { 
 | 
			
		||||
            get { return tags.NullOrEmpty() ? tags = new List<string>() : tags; } 
 | 
			
		||||
            set { tags = value.NotNullOrEmpty() ? value : null; EventsManager.OnActorChanged(this); } 
 | 
			
		||||
        }
 | 
			
		||||
 | 
			
		||||
        [XmlIgnore] public BodyTypeOffset BodyTypeOffset
 | 
			
		||||
        { 
 | 
			
		||||
            get { return bodyTypeOffset == null ? bodyTypeOffset = new BodyTypeOffset() : bodyTypeOffset; } 
 | 
			
		||||
            set { bodyTypeOffset = value; EventsManager.OnActorChanged(this); } 
 | 
			
		||||
        }
 | 
			
		||||
 | 
			
		||||
        [XmlIgnore] public bool Initiator 
 | 
			
		||||
        { 
 | 
			
		||||
            get { return initiator == true; } 
 | 
			
		||||
            set { if (value) { initiator = true; } else initiator = null; EventsManager.OnActorChanged(this); } 
 | 
			
		||||
        }
 | 
			
		||||
 | 
			
		||||
        [XmlIgnore] public bool ControlGenitalAngle
 | 
			
		||||
        { 
 | 
			
		||||
            get { return controlGenitalAngle == true; } 
 | 
			
		||||
            set { if (value) { controlGenitalAngle = true; } else controlGenitalAngle = null; EventsManager.OnActorChanged(this); }
 | 
			
		||||
        }
 | 
			
		||||
 | 
			
		||||
        [XmlIgnore] public bool IsFucking 
 | 
			
		||||
        { 
 | 
			
		||||
            get { return isFucking == true; } 
 | 
			
		||||
            set { if (value) { isFucking = true; } else isFucking = null; EventsManager.OnActorChanged(this); }
 | 
			
		||||
        }
 | 
			
		||||
 | 
			
		||||
        [XmlIgnore] public bool IsFucked
 | 
			
		||||
        { 
 | 
			
		||||
            get { return isFucked == true; } 
 | 
			
		||||
            set { if (value) { isFucked = true; } else isFucked = null; EventsManager.OnActorChanged(this); } 
 | 
			
		||||
        }
 | 
			
		||||
 | 
			
		||||
        // Local data
 | 
			
		||||
        [XmlIgnore] public string bodyType = "Male";
 | 
			
		||||
        [XmlIgnore] private PawnRaceDef pawnRaceDef;
 | 
			
		||||
 | 
			
		||||
        // Methods
 | 
			
		||||
        public PawnRaceDef GetPawnRaceDef()
 | 
			
		||||
        {
 | 
			
		||||
            if (pawnRaceDef == null)
 | 
			
		||||
            { pawnRaceDef = PawnRaceDefs.GetNamed("Human"); }
 | 
			
		||||
 | 
			
		||||
            return pawnRaceDef;
 | 
			
		||||
        }
 | 
			
		||||
 | 
			
		||||
        public void SetPawnRaceDef(string pawnRaceDefName)
 | 
			
		||||
        {
 | 
			
		||||
            PawnRaceDef pawnRaceDef = PawnRaceDefs.GetNamed(pawnRaceDefName);
 | 
			
		||||
 | 
			
		||||
            if (pawnRaceDef != null)
 | 
			
		||||
            { 
 | 
			
		||||
                this.pawnRaceDef = pawnRaceDef;
 | 
			
		||||
                EventsManager.OnActorChanged(this);
 | 
			
		||||
            }
 | 
			
		||||
        }
 | 
			
		||||
 | 
			
		||||
        public Vector3 GetPawnRaceOffset()
 | 
			
		||||
        {
 | 
			
		||||
            if (pawnRaceDef == null)
 | 
			
		||||
            { pawnRaceDef = PawnRaceDefs.GetNamed("Human"); }
 | 
			
		||||
 | 
			
		||||
            PawnRaceOffset raceOffset = RaceOffsets.FirstOrDefault(x => x.defName == pawnRaceDef.defName);
 | 
			
		||||
            
 | 
			
		||||
            if (raceOffset == null)
 | 
			
		||||
            {
 | 
			
		||||
                raceOffset = new AlienRaceOffset(alienRaceDef.defName);
 | 
			
		||||
                raceOffsets.Add(raceOffset);               
 | 
			
		||||
                raceOffset = new PawnRaceOffset(pawnRaceDef.defName);
 | 
			
		||||
                RaceOffsets.Add(raceOffset);               
 | 
			
		||||
            }
 | 
			
		||||
 | 
			
		||||
            return raceOffset.GetOffset();
 | 
			
		||||
        }
 | 
			
		||||
 | 
			
		||||
        public void SetAlienRaceOffset(Vector2 offset)
 | 
			
		||||
        public void SetPawnRaceOffset(Vector2 offset)
 | 
			
		||||
        {
 | 
			
		||||
            if (alienRaceDef == null)
 | 
			
		||||
            if (pawnRaceDef == null)
 | 
			
		||||
            { return; }
 | 
			
		||||
 | 
			
		||||
            AlienRaceOffset raceOffset = raceOffsets.FirstOrDefault(x => x.defName == alienRaceDef.defName);
 | 
			
		||||
            PawnRaceOffset raceOffset = RaceOffsets.FirstOrDefault(x => x.defName == pawnRaceDef.defName);
 | 
			
		||||
 | 
			
		||||
            if (raceOffset == null)
 | 
			
		||||
            {
 | 
			
		||||
                raceOffset = new AlienRaceOffset(alienRaceDef.defName);
 | 
			
		||||
                raceOffsets.Add(raceOffset);
 | 
			
		||||
                raceOffset = new PawnRaceOffset(pawnRaceDef.defName);
 | 
			
		||||
                RaceOffsets.Add(raceOffset);
 | 
			
		||||
 | 
			
		||||
                EventsManager.OnActorChanged(this);
 | 
			
		||||
            }
 | 
			
		||||
 | 
			
		||||
            raceOffset.SetOffset(offset);
 | 
			
		||||
| 
						 | 
				
			
			@ -89,46 +152,25 @@ namespace RimWorldAnimationStudio
 | 
			
		|||
 | 
			
		||||
        public Vector3 GetFinalTransformOffset()
 | 
			
		||||
        {
 | 
			
		||||
            Vector3 offset = GetAlienRaceOffset() + (GetAlienRaceDef().isHumanoid ? bodyTypeOffset.GetOffset(bodyType) : new Vector3());
 | 
			
		||||
            Vector3 offset = GetPawnRaceOffset() + (GetPawnRaceDef().isHumanoid ? BodyTypeOffset.GetOffset(bodyType) : new Vector3());
 | 
			
		||||
 | 
			
		||||
            return new Vector3(offset.x, offset.z, offset.y);
 | 
			
		||||
        }
 | 
			
		||||
 | 
			
		||||
        public void ValidateData()
 | 
			
		||||
        {
 | 
			
		||||
            bodyDefTypes = bodyDefTypes.Intersect(Tags.bodyDefTypes.Concat(CustomTags.bodyDefTypes))?.ToList();
 | 
			
		||||
            requiredGenitals = requiredGenitals.Intersect(Tags.bodyParts.Concat(CustomTags.bodyParts))?.ToList();
 | 
			
		||||
            raceOffsets = raceOffsets.Except(raceOffsets.Where(x => x.OffsetIsZero()))?.ToList();
 | 
			
		||||
        }
 | 
			
		||||
 | 
			
		||||
        public bool MakeNew()
 | 
			
		||||
        {
 | 
			
		||||
            if (Workspace.animationDef == null)
 | 
			
		||||
            { Debug.LogWarning("Cannot make new actor - there is no AnimationDef"); return false; }
 | 
			
		||||
 | 
			
		||||
            Workspace.animationDef.actors.Add(this);
 | 
			
		||||
            Workspace.actorID = Workspace.animationDef.actors.Count - 1;
 | 
			
		||||
 | 
			
		||||
            foreach (AnimationStage stage in Workspace.animationDef.animationStages)
 | 
			
		||||
            {
 | 
			
		||||
                PawnAnimationClip clip = new PawnAnimationClip();
 | 
			
		||||
 | 
			
		||||
                if (clip.MakeNew())
 | 
			
		||||
                { 
 | 
			
		||||
                    stage.animationClips.Add(clip);
 | 
			
		||||
                    stage.Initialize();
 | 
			
		||||
                    stage.OnPostLoad();
 | 
			
		||||
                }
 | 
			
		||||
            }
 | 
			
		||||
 | 
			
		||||
            return true;
 | 
			
		||||
        }
 | 
			
		||||
 | 
			
		||||
        public int GetActorID()
 | 
			
		||||
        {
 | 
			
		||||
            if (Workspace.animationDef == null) return -1;
 | 
			
		||||
 | 
			
		||||
            return Workspace.animationDef.actors.IndexOf(this);
 | 
			
		||||
            return Workspace.animationDef.Actors.IndexOf(this);
 | 
			
		||||
        }
 | 
			
		||||
 | 
			
		||||
        // Pre-save / post-load
 | 
			
		||||
        public void OnPreSave()
 | 
			
		||||
        {
 | 
			
		||||
            BodyDefTypes = BodyDefTypes.Intersect(DefaultTags.bodyDefTypes.Concat(CustomTags.bodyDefTypes))?.ToList();
 | 
			
		||||
            RequiredGenitals = RequiredGenitals.Intersect(DefaultTags.bodyParts.Concat(CustomTags.bodyParts))?.ToList();
 | 
			
		||||
            RaceOffsets = RaceOffsets.Except(RaceOffsets.Where(x => x.OffsetIsZero()))?.ToList();
 | 
			
		||||
        }
 | 
			
		||||
 | 
			
		||||
        public void OnPostLoad() { }
 | 
			
		||||
    }
 | 
			
		||||
}
 | 
			
		||||
| 
						 | 
				
			
			
 | 
			
		|||
| 
						 | 
				
			
			@ -1,5 +1,5 @@
 | 
			
		|||
fileFormatVersion: 2
 | 
			
		||||
guid: ca7cd67490c5773499bff5c06907bdf7
 | 
			
		||||
guid: 63a9fd7a0256e9849bc2bc07403528e8
 | 
			
		||||
MonoImporter:
 | 
			
		||||
  externalObjects: {}
 | 
			
		||||
  serializedVersion: 2
 | 
			
		||||
| 
						 | 
				
			
			
 | 
			
		|||
| 
						 | 
				
			
			@ -4,28 +4,69 @@ using System.Linq;
 | 
			
		|||
using System.Text;
 | 
			
		||||
using System.Threading.Tasks;
 | 
			
		||||
using System.Xml.Serialization;
 | 
			
		||||
using UnityEngine;
 | 
			
		||||
 | 
			
		||||
namespace RimWorldAnimationStudio
 | 
			
		||||
{
 | 
			
		||||
    public class ActorAddon
 | 
			
		||||
    {
 | 
			
		||||
        // Data to/from animationDef
 | 
			
		||||
        public string addonName;
 | 
			
		||||
        public int anchoringActor;
 | 
			
		||||
        public int? anchoringActor;
 | 
			
		||||
        public string anchorName;
 | 
			
		||||
        public string layer = "Pawn";
 | 
			
		||||
        public float scale;
 | 
			
		||||
        public bool render;
 | 
			
		||||
        public float? scale;
 | 
			
		||||
        public bool? render;
 | 
			
		||||
 | 
			
		||||
        // Data helper functions
 | 
			
		||||
        [XmlIgnore] public string AddonName
 | 
			
		||||
        {
 | 
			
		||||
            get { return addonName; }
 | 
			
		||||
            set { addonName = value; }
 | 
			
		||||
        }
 | 
			
		||||
 | 
			
		||||
        [XmlIgnore] public int AnchoringActor
 | 
			
		||||
        {
 | 
			
		||||
            get { return anchoringActor.HasValue ? anchoringActor.Value : 0; }
 | 
			
		||||
            set { anchoringActor = value; EventsManager.OnActorAddonChanged(this); }
 | 
			
		||||
        }
 | 
			
		||||
 | 
			
		||||
        [XmlIgnore] public string AnchorName
 | 
			
		||||
        {
 | 
			
		||||
            get { return anchorName; }
 | 
			
		||||
            set { anchorName = value; EventsManager.OnActorAddonChanged(this); }
 | 
			
		||||
        }
 | 
			
		||||
 | 
			
		||||
        [XmlIgnore] public string Layer
 | 
			
		||||
        {
 | 
			
		||||
            get { return layer; }
 | 
			
		||||
            set { layer = value; EventsManager.OnActorAddonChanged(this); }
 | 
			
		||||
        }
 | 
			
		||||
 | 
			
		||||
        [XmlIgnore] public float Scale
 | 
			
		||||
        {
 | 
			
		||||
            get { return scale.HasValue ? scale.Value : 0f; }
 | 
			
		||||
            set { scale = value; EventsManager.OnActorAddonChanged(this); }
 | 
			
		||||
        }
 | 
			
		||||
 | 
			
		||||
        [XmlIgnore] public bool Render
 | 
			
		||||
        {
 | 
			
		||||
            get { return render == true; }
 | 
			
		||||
            set { render = value; EventsManager.OnActorAddonChanged(this); }
 | 
			
		||||
        }
 | 
			
		||||
 | 
			
		||||
        // Simple curves
 | 
			
		||||
        [XmlIgnore] public SimpleCurve PosX = new SimpleCurve();
 | 
			
		||||
        [XmlIgnore] public SimpleCurve PosZ = new SimpleCurve();
 | 
			
		||||
        [XmlIgnore] public SimpleCurve Rotation = new SimpleCurve();
 | 
			
		||||
 | 
			
		||||
        // Constructors
 | 
			
		||||
        public ActorAddon() { }
 | 
			
		||||
 | 
			
		||||
        public ActorAddon(string addonName, float scale = 1f)
 | 
			
		||||
        {
 | 
			
		||||
            this.addonName = addonName;
 | 
			
		||||
            this.scale = scale;
 | 
			
		||||
            this.AddonName = addonName;
 | 
			
		||||
            this.Scale = scale;
 | 
			
		||||
        }
 | 
			
		||||
    }
 | 
			
		||||
}
 | 
			
		||||
| 
						 | 
				
			
			
 | 
			
		|||
| 
						 | 
				
			
			@ -1,5 +1,5 @@
 | 
			
		|||
fileFormatVersion: 2
 | 
			
		||||
guid: f4d87003a570d5241affe4170ae91045
 | 
			
		||||
guid: 3759e796f4f62b044b9a652e746d79a1
 | 
			
		||||
MonoImporter:
 | 
			
		||||
  externalObjects: {}
 | 
			
		||||
  serializedVersion: 2
 | 
			
		||||
| 
						 | 
				
			
			
 | 
			
		|||
							
								
								
									
										49
									
								
								Assets/Scripts/AnimationComponents/AddonKeyFrame.cs
									
										
									
									
									
										Normal file
									
								
							
							
						
						
									
										49
									
								
								Assets/Scripts/AnimationComponents/AddonKeyFrame.cs
									
										
									
									
									
										Normal file
									
								
							| 
						 | 
				
			
			@ -0,0 +1,49 @@
 | 
			
		|||
using System.Collections.Generic;
 | 
			
		||||
using System.Xml;
 | 
			
		||||
using System.Xml.Serialization;
 | 
			
		||||
using UnityEngine;
 | 
			
		||||
 | 
			
		||||
namespace RimWorldAnimationStudio
 | 
			
		||||
{
 | 
			
		||||
    public class AddonKeyframe
 | 
			
		||||
    {
 | 
			
		||||
        // Data to/from animationDef
 | 
			
		||||
        public string addonName;
 | 
			
		||||
        public float? posX;
 | 
			
		||||
        public float? posZ;
 | 
			
		||||
        public float? rotation;
 | 
			
		||||
 | 
			
		||||
        // Data helper functions
 | 
			
		||||
        [XmlIgnore] public string AddonName 
 | 
			
		||||
        {  
 | 
			
		||||
            get { return addonName; } 
 | 
			
		||||
            set { addonName = value; } 
 | 
			
		||||
        }
 | 
			
		||||
 | 
			
		||||
        [XmlIgnore] public float PosX
 | 
			
		||||
        {
 | 
			
		||||
            get { return posX.HasValue ? posX.Value : 0f; }
 | 
			
		||||
            set { posX = value; EventsManager.OnAddonKeyframeChanged(this); }
 | 
			
		||||
        }
 | 
			
		||||
 | 
			
		||||
        [XmlIgnore] public float PosZ
 | 
			
		||||
        {
 | 
			
		||||
            get { return posZ.HasValue ? posZ.Value : 0f; }
 | 
			
		||||
            set { posZ = value; EventsManager.OnAddonKeyframeChanged(this); }
 | 
			
		||||
        }
 | 
			
		||||
 | 
			
		||||
        [XmlIgnore] public float Rotation
 | 
			
		||||
        {
 | 
			
		||||
            get { return rotation.HasValue ? rotation.Value : 0f; }
 | 
			
		||||
            set { rotation = value; EventsManager.OnAddonKeyframeChanged(this); }
 | 
			
		||||
        }
 | 
			
		||||
 | 
			
		||||
        // Constructors
 | 
			
		||||
        public AddonKeyframe() { }
 | 
			
		||||
 | 
			
		||||
        public AddonKeyframe(string addonName)
 | 
			
		||||
        {
 | 
			
		||||
            this.AddonName = addonName;
 | 
			
		||||
        }
 | 
			
		||||
    }
 | 
			
		||||
}
 | 
			
		||||
| 
						 | 
				
			
			@ -1,5 +1,5 @@
 | 
			
		|||
fileFormatVersion: 2
 | 
			
		||||
guid: 60509e7cd8e74e6419c5c93304440a17
 | 
			
		||||
guid: 339d47b209f50f545a84a8e8c7948ae1
 | 
			
		||||
MonoImporter:
 | 
			
		||||
  externalObjects: {}
 | 
			
		||||
  serializedVersion: 2
 | 
			
		||||
| 
						 | 
				
			
			@ -1,20 +0,0 @@
 | 
			
		|||
using System.Collections.Generic;
 | 
			
		||||
using System.Xml;
 | 
			
		||||
using System.Xml.Serialization;
 | 
			
		||||
 | 
			
		||||
namespace RimWorldAnimationStudio
 | 
			
		||||
{
 | 
			
		||||
    public abstract class AnimationClip
 | 
			
		||||
    {
 | 
			
		||||
        public string layer = "Pawn";
 | 
			
		||||
        public List<string> tags;
 | 
			
		||||
 | 
			
		||||
        public virtual int duration { get { return 0; } }
 | 
			
		||||
 | 
			
		||||
        public abstract void BuildSimpleCurves();
 | 
			
		||||
 | 
			
		||||
        public bool ShouldSerializetags() { return tags.NotNullOrEmpty(); }
 | 
			
		||||
 | 
			
		||||
        public virtual void ValidateData() { }
 | 
			
		||||
    }
 | 
			
		||||
}
 | 
			
		||||
| 
						 | 
				
			
			@ -1,230 +0,0 @@
 | 
			
		|||
using System;
 | 
			
		||||
using System.Collections.Generic;
 | 
			
		||||
using System.Linq;
 | 
			
		||||
using System.Xml;
 | 
			
		||||
using System.Xml.Serialization;
 | 
			
		||||
using UnityEngine;
 | 
			
		||||
 | 
			
		||||
namespace RimWorldAnimationStudio
 | 
			
		||||
{
 | 
			
		||||
    public class PawnAnimationClip : AnimationClip
 | 
			
		||||
    {
 | 
			
		||||
        [XmlArray("addons"), XmlArrayItem("li")] public List<ActorAddon> _addons = new List<ActorAddon>();
 | 
			
		||||
        [XmlIgnore] public List<ActorAddon> addons = new List<ActorAddon>();
 | 
			
		||||
 | 
			
		||||
        [XmlAttribute("Class")] public string className = "Rimworld_Animations.PawnAnimationClip";
 | 
			
		||||
        [XmlArray("keyframes"), XmlArrayItem("li")] public List<PawnKeyframe> keyframes = new List<PawnKeyframe>();
 | 
			
		||||
 | 
			
		||||
        [XmlIgnore] public Dictionary<int, bool> quiver = new Dictionary<int, bool>();
 | 
			
		||||
        [XmlIgnore] public SimpleCurve GenitalAngle = new SimpleCurve();
 | 
			
		||||
        [XmlIgnore] public SimpleCurve BodyAngle = new SimpleCurve();
 | 
			
		||||
        [XmlIgnore] public SimpleCurve HeadAngle = new SimpleCurve();
 | 
			
		||||
        [XmlIgnore] public SimpleCurve HeadBob = new SimpleCurve();
 | 
			
		||||
        [XmlIgnore] public SimpleCurve BodyOffsetX = new SimpleCurve();
 | 
			
		||||
        [XmlIgnore] public SimpleCurve BodyOffsetZ = new SimpleCurve();
 | 
			
		||||
        [XmlIgnore] public SimpleCurve HeadFacing = new SimpleCurve();
 | 
			
		||||
        [XmlIgnore] public SimpleCurve BodyFacing = new SimpleCurve();
 | 
			
		||||
 | 
			
		||||
        public override int duration { get { return keyframes.Max(x => x.atTick.Value); } }
 | 
			
		||||
 | 
			
		||||
        public override void BuildSimpleCurves()
 | 
			
		||||
        {
 | 
			
		||||
            BodyAngle.Clear();
 | 
			
		||||
            HeadAngle.Clear();
 | 
			
		||||
            BodyOffsetX.Clear();
 | 
			
		||||
            BodyOffsetZ.Clear();
 | 
			
		||||
            HeadFacing.Clear();
 | 
			
		||||
            BodyFacing.Clear();
 | 
			
		||||
            HeadBob.Clear();
 | 
			
		||||
            GenitalAngle.Clear();
 | 
			
		||||
 | 
			
		||||
            foreach (ActorAddon addon in addons)
 | 
			
		||||
            {
 | 
			
		||||
                addon.PosX.Clear();
 | 
			
		||||
                addon.PosZ.Clear();
 | 
			
		||||
                addon.Rotation.Clear();
 | 
			
		||||
            }
 | 
			
		||||
 | 
			
		||||
            int keyframePosition = 0;
 | 
			
		||||
            int duration = 0;
 | 
			
		||||
 | 
			
		||||
            keyframes[keyframes.Count - 1].tickDuration = 1;
 | 
			
		||||
 | 
			
		||||
            foreach (PawnKeyframe frame in keyframes)
 | 
			
		||||
            { duration += frame.tickDuration; }
 | 
			
		||||
 | 
			
		||||
            for (int i = 0; i < keyframes.Count; i++)
 | 
			
		||||
            {
 | 
			
		||||
                PawnKeyframe keyframe = keyframes[i];
 | 
			
		||||
 | 
			
		||||
                if (keyframe.atTick.HasValue)
 | 
			
		||||
                {
 | 
			
		||||
                    if (keyframe.HasValidKeyframeID() == false)
 | 
			
		||||
                    { keyframe.GenerateKeyframeID(Workspace.animationDef.animationStages[Workspace.stageID].animationClips.IndexOf(this)); }
 | 
			
		||||
 | 
			
		||||
                    BodyAngle.Add((float)keyframe.atTick / (float)duration, keyframe.bodyAngle, true);
 | 
			
		||||
                    HeadAngle.Add((float)keyframe.atTick / (float)duration, keyframe.headAngle, true);
 | 
			
		||||
                    BodyOffsetX.Add((float)keyframe.atTick / (float)duration, keyframe.bodyOffsetX, true);
 | 
			
		||||
                    BodyOffsetZ.Add((float)keyframe.atTick / (float)duration, keyframe.bodyOffsetZ, true);
 | 
			
		||||
                    HeadFacing.Add((float)keyframe.atTick / (float)duration, keyframe.headFacing, true);
 | 
			
		||||
                    BodyFacing.Add((float)keyframe.atTick / (float)duration, keyframe.bodyFacing, true);
 | 
			
		||||
                    HeadBob.Add((float)keyframe.atTick / (float)duration, keyframe.headBob, true);
 | 
			
		||||
                    GenitalAngle.Add((float)keyframe.atTick / (float)duration, keyframe.genitalAngle, true);
 | 
			
		||||
 | 
			
		||||
                    foreach (ActorAddon addon in addons)
 | 
			
		||||
                    {
 | 
			
		||||
                        if (keyframe.addonKeyframes.Any(x => x.addonName == addon.addonName) == false)
 | 
			
		||||
                        { keyframe.addonKeyframes.Add(new AddonKeyframe(addon.addonName)); }
 | 
			
		||||
 | 
			
		||||
                        addon.PosX.Add((float)keyframe.atTick / (float)duration, keyframe.GetAddonKeyframe(addon.addonName).posX, true);
 | 
			
		||||
                        addon.PosZ.Add((float)keyframe.atTick / (float)duration, keyframe.GetAddonKeyframe(addon.addonName).posZ, true);
 | 
			
		||||
                        addon.Rotation.Add((float)keyframe.atTick / (float)duration, keyframe.GetAddonKeyframe(addon.addonName).rotation, true);
 | 
			
		||||
                    }
 | 
			
		||||
 | 
			
		||||
                    if (i + 1 < keyframes.Count)
 | 
			
		||||
                    { keyframes[i].tickDuration = keyframes[i + 1].atTick.Value - keyframes[i].atTick.Value; }
 | 
			
		||||
                }
 | 
			
		||||
 | 
			
		||||
                else
 | 
			
		||||
                {
 | 
			
		||||
                    BodyAngle.Add((float)keyframePosition / (float)duration, keyframe.bodyAngle, true);
 | 
			
		||||
                    HeadAngle.Add((float)keyframePosition / (float)duration, keyframe.headAngle, true);
 | 
			
		||||
                    BodyOffsetX.Add((float)keyframePosition / (float)duration, keyframe.bodyOffsetX, true);
 | 
			
		||||
                    BodyOffsetZ.Add((float)keyframePosition / (float)duration, keyframe.bodyOffsetZ, true);
 | 
			
		||||
                    HeadFacing.Add((float)keyframePosition / (float)duration, keyframe.headFacing, true);
 | 
			
		||||
                    BodyFacing.Add((float)keyframePosition / (float)duration, keyframe.bodyFacing, true);
 | 
			
		||||
                    HeadBob.Add((float)keyframePosition / (float)duration, keyframe.headBob, true);
 | 
			
		||||
                    GenitalAngle.Add((float)keyframePosition / (float)duration, keyframe.genitalAngle, true);
 | 
			
		||||
 | 
			
		||||
                    foreach (ActorAddon addon in addons)
 | 
			
		||||
                    {
 | 
			
		||||
                        if (keyframe.addonKeyframes.Any(x => x.addonName == addon.addonName) == false)
 | 
			
		||||
                        { keyframe.addonKeyframes.Add(new AddonKeyframe(addon.addonName)); }
 | 
			
		||||
 | 
			
		||||
                        addon.PosX.Add((float)keyframePosition / (float)duration, keyframe.GetAddonKeyframe(addon.addonName).posX, true);
 | 
			
		||||
                        addon.PosZ.Add((float)keyframePosition / (float)duration, keyframe.GetAddonKeyframe(addon.addonName).posZ, true);
 | 
			
		||||
                        addon.Rotation.Add((float)keyframePosition / (float)duration, keyframe.GetAddonKeyframe(addon.addonName).rotation, true);
 | 
			
		||||
                    }
 | 
			
		||||
 | 
			
		||||
                    if (keyframe.tickDuration != 1 && keyframe.quiver.HasValue)
 | 
			
		||||
                    {
 | 
			
		||||
                        quiver.Add(keyframePosition, true);
 | 
			
		||||
                        quiver.Add(keyframePosition + keyframe.tickDuration - 1, false);
 | 
			
		||||
                    }
 | 
			
		||||
 | 
			
		||||
                    keyframe.atTick = keyframePosition + Constants.minTick;
 | 
			
		||||
                    keyframePosition += keyframe.tickDuration;
 | 
			
		||||
                }
 | 
			
		||||
            }
 | 
			
		||||
        }
 | 
			
		||||
 | 
			
		||||
        public void AddActorAddon(string addonName, float scale = 1f)
 | 
			
		||||
        {
 | 
			
		||||
            if (addons.Any(x => x.addonName == addonName) == false)
 | 
			
		||||
            { 
 | 
			
		||||
                addons.Add(new ActorAddon(addonName, scale));
 | 
			
		||||
            }
 | 
			
		||||
 | 
			
		||||
            foreach (PawnKeyframe keyframe in keyframes)
 | 
			
		||||
            {
 | 
			
		||||
                if (keyframe.addonKeyframes.Any(x => x.addonName == addonName) == false)
 | 
			
		||||
                { keyframe.addonKeyframes.Add(new AddonKeyframe(addonName)); }
 | 
			
		||||
            }
 | 
			
		||||
        }
 | 
			
		||||
 | 
			
		||||
        public void ShowOrHideActorAddon(string addonName, bool flag)
 | 
			
		||||
        {
 | 
			
		||||
            ActorAddon addon = GetActorAddon(addonName);
 | 
			
		||||
 | 
			
		||||
            if (addon != null)
 | 
			
		||||
            { addon.render = flag; }
 | 
			
		||||
        }
 | 
			
		||||
 | 
			
		||||
        public bool IsActorAddonVisible(string addonName)
 | 
			
		||||
        {
 | 
			
		||||
            ActorAddon addon = GetActorAddon(addonName);
 | 
			
		||||
 | 
			
		||||
            if (addon != null)
 | 
			
		||||
            { return addon.render; }
 | 
			
		||||
 | 
			
		||||
            return false;
 | 
			
		||||
        }
 | 
			
		||||
 | 
			
		||||
        public ActorAddon GetActorAddon(string addonName)
 | 
			
		||||
        {
 | 
			
		||||
            return addons.FirstOrDefault(x => x.addonName == addonName);
 | 
			
		||||
        }
 | 
			
		||||
 | 
			
		||||
        public override void ValidateData() 
 | 
			
		||||
        {
 | 
			
		||||
            _addons.Clear();
 | 
			
		||||
 | 
			
		||||
            foreach (ActorAddon addon in addons)
 | 
			
		||||
            {
 | 
			
		||||
                Debug.Log(addon.anchorName);
 | 
			
		||||
 | 
			
		||||
                if (addon.render)
 | 
			
		||||
                {
 | 
			
		||||
                    _addons.Add(addon);
 | 
			
		||||
                }
 | 
			
		||||
            }
 | 
			
		||||
        }
 | 
			
		||||
 | 
			
		||||
        public int GetOwningActorID()
 | 
			
		||||
        {
 | 
			
		||||
            if (Workspace.animationDef == null) return -1;
 | 
			
		||||
 | 
			
		||||
            return Workspace.animationDef.animationStages[Workspace.stageID].animationClips.IndexOf(this);
 | 
			
		||||
        }
 | 
			
		||||
 | 
			
		||||
        public bool MakeNew(int actorID = -1)
 | 
			
		||||
        {
 | 
			
		||||
            PawnKeyframe lastkeyframe = null;
 | 
			
		||||
 | 
			
		||||
            if (actorID >= 0)
 | 
			
		||||
            { lastkeyframe = Workspace.animationDef.animationStages[Workspace.stageID].animationClips[actorID]?.keyframes?.Last(); }
 | 
			
		||||
 | 
			
		||||
            if (lastkeyframe != null)
 | 
			
		||||
            {
 | 
			
		||||
                PawnKeyframe keyframeA = lastkeyframe.Copy();
 | 
			
		||||
                keyframeA.atTick = null;
 | 
			
		||||
                keyframeA.tickDuration = Constants.defaultAnimationClipLength - 1;
 | 
			
		||||
                keyframeA.GenerateKeyframeID(actorID);
 | 
			
		||||
                keyframes.Add(keyframeA);
 | 
			
		||||
 | 
			
		||||
                PawnKeyframe keyframeB = lastkeyframe.Copy();
 | 
			
		||||
                keyframeB.atTick = null;
 | 
			
		||||
                keyframeB.tickDuration = 1;
 | 
			
		||||
                keyframeB.GenerateKeyframeID(actorID);
 | 
			
		||||
                keyframes.Add(keyframeB);              
 | 
			
		||||
            }
 | 
			
		||||
 | 
			
		||||
            else
 | 
			
		||||
            {
 | 
			
		||||
                PawnKeyframe keyframeA = new PawnKeyframe();
 | 
			
		||||
                keyframeA.tickDuration = Constants.defaultAnimationClipLength - 1;
 | 
			
		||||
                keyframes.Add(keyframeA);
 | 
			
		||||
 | 
			
		||||
                PawnKeyframe keyframeB = new PawnKeyframe();
 | 
			
		||||
                keyframes.Add(keyframeB);
 | 
			
		||||
            }
 | 
			
		||||
 | 
			
		||||
            BuildSimpleCurves();
 | 
			
		||||
            return true;
 | 
			
		||||
        }
 | 
			
		||||
 | 
			
		||||
        public void OnPostLoad()
 | 
			
		||||
        {
 | 
			
		||||
            addons = _addons.Copy();
 | 
			
		||||
 | 
			
		||||
            foreach (PawnKeyframe keyframe in keyframes)
 | 
			
		||||
            {
 | 
			
		||||
                keyframe.OnPostLoad();
 | 
			
		||||
            }
 | 
			
		||||
 | 
			
		||||
            AddActorAddon("left hand", 0.667f);
 | 
			
		||||
            AddActorAddon("right hand", 0.667f);
 | 
			
		||||
            AddActorAddon("dildo");
 | 
			
		||||
        }
 | 
			
		||||
    }
 | 
			
		||||
}
 | 
			
		||||
| 
						 | 
				
			
			@ -1,53 +0,0 @@
 | 
			
		|||
using System.Collections.Generic;
 | 
			
		||||
using System.Linq;
 | 
			
		||||
using System.Xml;
 | 
			
		||||
using System.Xml.Serialization;
 | 
			
		||||
 | 
			
		||||
namespace RimWorldAnimationStudio
 | 
			
		||||
{
 | 
			
		||||
    public class ThingAnimationClip : AnimationClip
 | 
			
		||||
    {
 | 
			
		||||
        [XmlAttribute("Class")] public string className = "Rimworld_Animations.ThingAnimationClip";
 | 
			
		||||
        [XmlArray("keyframes"), XmlArrayItem("li")] public List<ThingKeyframe> keyframes = new List<ThingKeyframe>();
 | 
			
		||||
 | 
			
		||||
        [XmlIgnore] public SimpleCurve PositionX = new SimpleCurve();
 | 
			
		||||
        [XmlIgnore] public SimpleCurve PositionZ = new SimpleCurve();
 | 
			
		||||
        [XmlIgnore] public SimpleCurve Rotation = new SimpleCurve();
 | 
			
		||||
 | 
			
		||||
        public override int duration { get { return keyframes.Max(x => x.atTick.Value); } }
 | 
			
		||||
 | 
			
		||||
        public override void BuildSimpleCurves()
 | 
			
		||||
        {
 | 
			
		||||
            int duration = 0;
 | 
			
		||||
 | 
			
		||||
            //getting the length of the whole clip
 | 
			
		||||
            foreach (ThingKeyframe frame in keyframes)
 | 
			
		||||
            {
 | 
			
		||||
                duration += frame.tickDuration;
 | 
			
		||||
            }
 | 
			
		||||
 | 
			
		||||
            //guarantees loops don't get cut off mid-anim
 | 
			
		||||
            //this.duration = duration;
 | 
			
		||||
 | 
			
		||||
            int keyframePosition = 0;
 | 
			
		||||
            foreach (ThingKeyframe frame in keyframes)
 | 
			
		||||
            {
 | 
			
		||||
                if (frame.atTick.HasValue)
 | 
			
		||||
                {
 | 
			
		||||
                    PositionX.Add((float)frame.atTick / (float)duration, frame.positionX, true);
 | 
			
		||||
                    PositionZ.Add((float)frame.atTick / (float)duration, frame.positionZ, true);
 | 
			
		||||
                    Rotation.Add((float)frame.atTick / (float)duration, frame.rotation, true);
 | 
			
		||||
                }
 | 
			
		||||
 | 
			
		||||
                else
 | 
			
		||||
                {
 | 
			
		||||
                    PositionX.Add((float)keyframePosition / (float)duration, frame.positionX, true);
 | 
			
		||||
                    PositionZ.Add((float)keyframePosition / (float)duration, frame.positionZ, true);
 | 
			
		||||
                    Rotation.Add((float)keyframePosition / (float)duration, frame.rotation, true);
 | 
			
		||||
 | 
			
		||||
                    keyframePosition += frame.tickDuration;
 | 
			
		||||
                }
 | 
			
		||||
            }
 | 
			
		||||
        }
 | 
			
		||||
    }
 | 
			
		||||
}
 | 
			
		||||
| 
						 | 
				
			
			@ -1,4 +1,5 @@
 | 
			
		|||
using System.Collections.Generic;
 | 
			
		||||
using System;
 | 
			
		||||
using System.Collections.Generic;
 | 
			
		||||
using System.Linq;
 | 
			
		||||
using System.Xml;
 | 
			
		||||
using System.Xml.Serialization;
 | 
			
		||||
| 
						 | 
				
			
			@ -8,33 +9,163 @@ namespace RimWorldAnimationStudio
 | 
			
		|||
{
 | 
			
		||||
    public class AnimationDef
 | 
			
		||||
    {
 | 
			
		||||
        public string defName = "Undefined";
 | 
			
		||||
        public string label = "Undefined";
 | 
			
		||||
        // Data to/from animationDef
 | 
			
		||||
        public string defName;
 | 
			
		||||
        public string label;
 | 
			
		||||
        public bool sounds = true;
 | 
			
		||||
        [XmlArray("sexTypes"), XmlArrayItem("li")] public List<string> sexTypes;
 | 
			
		||||
        [XmlArray("interactionDefTypes"), XmlArrayItem("li")] public List<string> interactionDefTypes;
 | 
			
		||||
        [XmlArray("actors"), XmlArrayItem("li")] public List<Actor> actors;     
 | 
			
		||||
        [XmlArray("animationStages"), XmlArrayItem("li")] public List<AnimationStage> animationStages;
 | 
			
		||||
 | 
			
		||||
        [XmlArray("sexTypes"), XmlArrayItem("li")] public List<string> sexTypes = new List<string>();
 | 
			
		||||
        [XmlArray("interactionDefTypes"), XmlArrayItem("li")] public List<string> interactionDefTypes = new List<string>();
 | 
			
		||||
        [XmlArray("actors"), XmlArrayItem("li")] public List<Actor> actors = new List<Actor>();     
 | 
			
		||||
        [XmlArray("animationStages"), XmlArrayItem("li")] public List<AnimationStage> animationStages = new List<AnimationStage>();
 | 
			
		||||
        
 | 
			
		||||
        [XmlIgnore] public int animationTimeTicks { get { return animationStages.Sum(x => x.playTimeTicks); } }
 | 
			
		||||
        [XmlIgnore] public int animationTimeTicksQuick { get { return animationStages.Sum(x => x.playTimeTicksQuick); } }
 | 
			
		||||
 | 
			
		||||
        // Data serialization control
 | 
			
		||||
        public bool ShouldSerializesexTypes() { return sexTypes.NotNullOrEmpty(); }
 | 
			
		||||
        public bool ShouldSerializeinteractionDefTypes() { return interactionDefTypes.NotNullOrEmpty(); }
 | 
			
		||||
        public bool ShouldSerializeactors() { return actors.NotNullOrEmpty(); }
 | 
			
		||||
        public bool ShouldSerializeanimationStages() { return animationStages.NotNullOrEmpty(); }
 | 
			
		||||
 | 
			
		||||
        // Data helper functions
 | 
			
		||||
        [XmlIgnore] public string DefName
 | 
			
		||||
        {
 | 
			
		||||
            get { return defName != null && defName != "" ? defName : "newAnimation"; }
 | 
			
		||||
            set { defName = value; EventsManager.OnAnimationDefChanged(); }
 | 
			
		||||
        }
 | 
			
		||||
 | 
			
		||||
        [XmlIgnore] public string Label
 | 
			
		||||
        {
 | 
			
		||||
            get { return label != null && label != "" ? label : "newAnimation"; }
 | 
			
		||||
            set { label = value; EventsManager.OnAnimationDefChanged(); }
 | 
			
		||||
        }
 | 
			
		||||
 | 
			
		||||
        [XmlIgnore] public List<string> SexTypes
 | 
			
		||||
        {
 | 
			
		||||
            get { return sexTypes.NullOrEmpty() ? sexTypes = new List<string>() : sexTypes; }
 | 
			
		||||
            set { sexTypes = value.NotNullOrEmpty() ? value : null; EventsManager.OnAnimationDefChanged(); }
 | 
			
		||||
        }
 | 
			
		||||
 | 
			
		||||
        [XmlIgnore] public List<string> InteractionDefTypes
 | 
			
		||||
        {
 | 
			
		||||
            get { return interactionDefTypes.NullOrEmpty() ? interactionDefTypes = new List<string>() : interactionDefTypes; }
 | 
			
		||||
            set { interactionDefTypes = value.NotNullOrEmpty() ? value : null; EventsManager.OnAnimationDefChanged(); }
 | 
			
		||||
        }
 | 
			
		||||
 | 
			
		||||
        [XmlIgnore] public List<Actor> Actors
 | 
			
		||||
        {
 | 
			
		||||
            get { return actors.NullOrEmpty() ? actors = new List<Actor>() : actors; }
 | 
			
		||||
            set { actors = value.NotNullOrEmpty() ? value : null; EventsManager.OnAnimationDefChanged(); }
 | 
			
		||||
        }
 | 
			
		||||
 | 
			
		||||
        [XmlIgnore] public List<AnimationStage> AnimationStages
 | 
			
		||||
        {
 | 
			
		||||
            get { if (animationStages.NullOrEmpty()){ animationStages = new List<AnimationStage>(); } return animationStages; }
 | 
			
		||||
            set { animationStages = value.NotNullOrEmpty() ? value : null; EventsManager.OnAnimationDefChanged(); }
 | 
			
		||||
        }
 | 
			
		||||
 | 
			
		||||
        // Local data
 | 
			
		||||
        [XmlIgnore] public int animationTimeTicks { get { return AnimationStages.Sum(x => x.PlayTimeTicks); } }
 | 
			
		||||
        [XmlIgnore] public int animationTimeTicksQuick { get { return AnimationStages.Sum(x => x.PlayTimeTicksQuick); } }
 | 
			
		||||
 | 
			
		||||
        // Methods
 | 
			
		||||
        public void Initialize()
 | 
			
		||||
        {
 | 
			
		||||
            foreach (AnimationStage stage in animationStages)
 | 
			
		||||
            foreach (AnimationStage stage in AnimationStages)
 | 
			
		||||
            { stage.Initialize(); }
 | 
			
		||||
        }
 | 
			
		||||
 | 
			
		||||
        public void ValidateData()
 | 
			
		||||
        public void AddActor()
 | 
			
		||||
        {
 | 
			
		||||
            sexTypes = sexTypes.Intersect(Tags.sexTypes.Concat(CustomTags.sexTypes))?.ToList();
 | 
			
		||||
            interactionDefTypes = interactionDefTypes.Intersect(Tags.interactionDefTypes.Concat(CustomTags.interactionDefTypes))?.ToList();
 | 
			
		||||
            if (Workspace.animationDef.Actors.Count >= 8)
 | 
			
		||||
            {
 | 
			
		||||
                Debug.LogWarning("Cannot add actor - the animation can only contain a maximum of eight actors.");
 | 
			
		||||
                return;
 | 
			
		||||
            }
 | 
			
		||||
 | 
			
		||||
            Actor actor = new Actor();
 | 
			
		||||
            Actors.Add(actor);
 | 
			
		||||
 | 
			
		||||
            Workspace.ActorID = Workspace.animationDef.Actors.Count - 1;
 | 
			
		||||
 | 
			
		||||
            foreach (AnimationStage stage in Workspace.animationDef.AnimationStages)
 | 
			
		||||
            { stage.AddAnimationClip(Workspace.ActorID); }
 | 
			
		||||
 | 
			
		||||
            EventsManager.OnActorCountChanged();
 | 
			
		||||
            Workspace.RecordEvent("Actor addition");
 | 
			
		||||
        }
 | 
			
		||||
 | 
			
		||||
        public void RemoveActor()
 | 
			
		||||
        {
 | 
			
		||||
            if (Workspace.animationDef.Actors.Count == 1)
 | 
			
		||||
            {
 | 
			
		||||
                Debug.LogWarning("Cannot delete actor - the animation must contain at least one actor.");
 | 
			
		||||
                return;
 | 
			
		||||
            }
 | 
			
		||||
 | 
			
		||||
            foreach (AnimationStage stage in Workspace.animationDef.AnimationStages)
 | 
			
		||||
            { stage.AnimationClips.RemoveAt(Workspace.ActorID); }
 | 
			
		||||
 | 
			
		||||
            Workspace.animationDef.Actors.RemoveAt(Workspace.ActorID);
 | 
			
		||||
            Workspace.ActorID--;
 | 
			
		||||
 | 
			
		||||
            EventsManager.OnActorCountChanged();
 | 
			
		||||
            Workspace.RecordEvent("Actor deletion");
 | 
			
		||||
        }
 | 
			
		||||
 | 
			
		||||
        public void AddAnimationStage()
 | 
			
		||||
        {
 | 
			
		||||
            AnimationStage stage = new AnimationStage();
 | 
			
		||||
            AnimationStages.Add(stage);
 | 
			
		||||
 | 
			
		||||
            foreach (Actor actor in Workspace.animationDef.Actors)
 | 
			
		||||
            { stage.AddAnimationClip(actor.GetActorID()); }
 | 
			
		||||
 | 
			
		||||
            Initialize();
 | 
			
		||||
 | 
			
		||||
            Workspace.RecordEvent("Stage addition");
 | 
			
		||||
        }
 | 
			
		||||
 | 
			
		||||
        public void CloneAnimationStage()
 | 
			
		||||
        {
 | 
			
		||||
            AnimationStage stage = Workspace.GetCurrentAnimationStage().Copy();         
 | 
			
		||||
            stage.StageName += " (Clone)";
 | 
			
		||||
            stage.Initialize();
 | 
			
		||||
 | 
			
		||||
            Workspace.animationDef.AnimationStages.Insert(Workspace.StageID + 1, stage);
 | 
			
		||||
            Workspace.RecordEvent("Stage clone");
 | 
			
		||||
        }
 | 
			
		||||
 | 
			
		||||
        public void MoveAnimationStage(int startIndex, int delta)
 | 
			
		||||
        {
 | 
			
		||||
            if (startIndex + delta < 0 || startIndex + delta >= AnimationStages.Count) return;
 | 
			
		||||
 | 
			
		||||
            AnimationStage stage = AnimationStages[startIndex];
 | 
			
		||||
            AnimationStages[startIndex] = Workspace.animationDef.AnimationStages[startIndex + delta];
 | 
			
		||||
            AnimationStages[startIndex + delta] = stage;
 | 
			
		||||
 | 
			
		||||
            Workspace.StageID = startIndex + delta;
 | 
			
		||||
            Workspace.RecordEvent("Stage move");
 | 
			
		||||
        }
 | 
			
		||||
 | 
			
		||||
        public void RemoveAnimationStage()
 | 
			
		||||
        {
 | 
			
		||||
            if (Workspace.animationDef.AnimationStages.Count == 1)
 | 
			
		||||
            {
 | 
			
		||||
                Debug.LogWarning("Cannot delete animation stage - the animation must contain at least one animation stage.");
 | 
			
		||||
                return;
 | 
			
		||||
            }
 | 
			
		||||
 | 
			
		||||
            AnimationStages.RemoveAt(Workspace.StageID);
 | 
			
		||||
 | 
			
		||||
            Workspace.StageID--;
 | 
			
		||||
            Workspace.RecordEvent("Stage deletion");
 | 
			
		||||
        }
 | 
			
		||||
 | 
			
		||||
        // Pre-save / post-load
 | 
			
		||||
        public void OnPreSave()
 | 
			
		||||
        {
 | 
			
		||||
            SexTypes = SexTypes.Intersect(DefaultTags.sexTypes.Concat(CustomTags.sexTypes))?.ToList();
 | 
			
		||||
            InteractionDefTypes = InteractionDefTypes.Intersect(DefaultTags.interactionDefTypes.Concat(CustomTags.interactionDefTypes))?.ToList();
 | 
			
		||||
        }
 | 
			
		||||
 | 
			
		||||
        public void OnPostLoad() { }
 | 
			
		||||
    }
 | 
			
		||||
}
 | 
			
		||||
| 
						 | 
				
			
			
 | 
			
		|||
| 
						 | 
				
			
			@ -1,5 +1,5 @@
 | 
			
		|||
fileFormatVersion: 2
 | 
			
		||||
guid: 9cca833a1987a2749aa6e4d640d32266
 | 
			
		||||
guid: 37ec1f5f150928e42bda942fe97046b9
 | 
			
		||||
MonoImporter:
 | 
			
		||||
  externalObjects: {}
 | 
			
		||||
  serializedVersion: 2
 | 
			
		||||
| 
						 | 
				
			
			
 | 
			
		|||
| 
						 | 
				
			
			@ -1,4 +1,5 @@
 | 
			
		|||
using System.Collections.Generic;
 | 
			
		||||
using System;
 | 
			
		||||
using System.Collections.Generic;
 | 
			
		||||
using System.Linq;
 | 
			
		||||
using System.Xml;
 | 
			
		||||
using System.Xml.Serialization;
 | 
			
		||||
| 
						 | 
				
			
			@ -8,68 +9,145 @@ namespace RimWorldAnimationStudio
 | 
			
		|||
{
 | 
			
		||||
    public class AnimationStage
 | 
			
		||||
    {
 | 
			
		||||
        public string stageName = "NewStage";
 | 
			
		||||
        public int stageIndex = 0;
 | 
			
		||||
        public int playTimeTicks = 0;
 | 
			
		||||
        public int playTimeTicksQuick = 0;
 | 
			
		||||
        public bool isLooping = false;
 | 
			
		||||
        // Data to/from animationDef
 | 
			
		||||
        [SerializeField] private string stageName;
 | 
			
		||||
        [SerializeField] private int? playTimeTicks;
 | 
			
		||||
        [SerializeField] private int? playTimeTicksQuick;
 | 
			
		||||
        [SerializeField] private bool? isLooping;
 | 
			
		||||
        [SerializeField, XmlArray("animationClips"), XmlArrayItem("li")] public List<PawnAnimationClip> animationClips;
 | 
			
		||||
 | 
			
		||||
        [XmlArray("animationClips"), XmlArrayItem("li")] public List<PawnAnimationClip> animationClips = new List<PawnAnimationClip>();
 | 
			
		||||
        // Data serialization control
 | 
			
		||||
        public bool ShouldSerializeanimationClips() { return animationClips.NotNullOrEmpty(); }
 | 
			
		||||
 | 
			
		||||
        // Data helper functions
 | 
			
		||||
        [XmlIgnore] public string StageName
 | 
			
		||||
        {
 | 
			
		||||
            get { return stageName != null && stageName != "" ? stageName : "NewStage"; }
 | 
			
		||||
            set { stageName = value; EventsManager.OnAnimationStageChanged(this); }
 | 
			
		||||
        }
 | 
			
		||||
 | 
			
		||||
        [XmlIgnore] public int PlayTimeTicks
 | 
			
		||||
        {
 | 
			
		||||
            get { return playTimeTicks.HasValue ? playTimeTicks.Value : 0; }
 | 
			
		||||
            set { playTimeTicks = value; EventsManager.OnAnimationStageChanged(this); }
 | 
			
		||||
        }
 | 
			
		||||
 | 
			
		||||
        [XmlIgnore] public int PlayTimeTicksQuick
 | 
			
		||||
        {
 | 
			
		||||
            get { return playTimeTicksQuick.HasValue ? playTimeTicksQuick.Value : 0; }
 | 
			
		||||
            set { playTimeTicksQuick = value; EventsManager.OnAnimationStageChanged(this); }
 | 
			
		||||
        }
 | 
			
		||||
 | 
			
		||||
        [XmlIgnore] public bool IsLooping
 | 
			
		||||
        {
 | 
			
		||||
            get { return isLooping == true; }
 | 
			
		||||
            set { isLooping = value; EventsManager.OnAnimationStageChanged(this); }
 | 
			
		||||
        }
 | 
			
		||||
 | 
			
		||||
        [XmlIgnore] public List<PawnAnimationClip> AnimationClips
 | 
			
		||||
        {
 | 
			
		||||
            get { return animationClips.NullOrEmpty() ? animationClips = new List<PawnAnimationClip>() : animationClips; }
 | 
			
		||||
            set { animationClips = value.NotNullOrEmpty() ? value : null; EventsManager.OnAnimationStageChanged(this); }
 | 
			
		||||
        }
 | 
			
		||||
 | 
			
		||||
        // Local data
 | 
			
		||||
        [XmlIgnore] public int stageWindowSize = -1;
 | 
			
		||||
 | 
			
		||||
        // Methods
 | 
			
		||||
        public void Initialize()
 | 
			
		||||
        {
 | 
			
		||||
            foreach (PawnAnimationClip clip in animationClips)
 | 
			
		||||
            foreach (PawnAnimationClip clip in AnimationClips)
 | 
			
		||||
            {
 | 
			
		||||
                clip.BuildSimpleCurves();
 | 
			
		||||
 | 
			
		||||
                // Select playTimeTicks as longest playtime of all the animations
 | 
			
		||||
                if (clip.duration > playTimeTicks)
 | 
			
		||||
                { playTimeTicks = clip.duration; }
 | 
			
		||||
            }
 | 
			
		||||
                if (clip.duration > PlayTimeTicks)
 | 
			
		||||
                { PlayTimeTicks = clip.duration; }
 | 
			
		||||
            }
 | 
			
		||||
 | 
			
		||||
        public void ValidateData()
 | 
			
		||||
        {
 | 
			
		||||
            // Sort keyframes by atTick
 | 
			
		||||
            foreach (PawnAnimationClip clip in animationClips)
 | 
			
		||||
            { clip.keyframes = clip.keyframes.OrderBy(x => x.atTick).ToList(); }
 | 
			
		||||
            PlayTimeTicksQuick = PlayTimeTicks;
 | 
			
		||||
        }
 | 
			
		||||
 | 
			
		||||
        public int GetStageID()
 | 
			
		||||
        {
 | 
			
		||||
            if (Workspace.animationDef == null) return -1;
 | 
			
		||||
 | 
			
		||||
            return Workspace.animationDef.animationStages.IndexOf(this);
 | 
			
		||||
            return Workspace.animationDef.AnimationStages.IndexOf(this);
 | 
			
		||||
        }
 | 
			
		||||
 | 
			
		||||
        public bool MakeNew()
 | 
			
		||||
        public void StretchStageWindow(int newStageWindowSize)
 | 
			
		||||
        {
 | 
			
		||||
            if (Workspace.animationDef == null)
 | 
			
		||||
            { Debug.LogWarning("Cannot make new animation stage - there is no AnimationDef"); return false; }
 | 
			
		||||
            float scale = (float)newStageWindowSize / Workspace.StageWindowSize;
 | 
			
		||||
 | 
			
		||||
            Workspace.animationDef.animationStages.Add(this);
 | 
			
		||||
            foreach (PawnAnimationClip clip in Workspace.animationDef.AnimationStages[Workspace.StageID].AnimationClips)
 | 
			
		||||
            {
 | 
			
		||||
                foreach (PawnKeyframe keyframe in clip.Keyframes)
 | 
			
		||||
                {
 | 
			
		||||
                    keyframe.TickDuration = Mathf.RoundToInt(keyframe.TickDuration * scale);
 | 
			
		||||
                    keyframe.atTick = null;
 | 
			
		||||
                }
 | 
			
		||||
 | 
			
		||||
            foreach (Actor actor in Workspace.animationDef.actors)
 | 
			
		||||
                clip.BuildSimpleCurves();
 | 
			
		||||
            }
 | 
			
		||||
        }
 | 
			
		||||
 | 
			
		||||
        public void ResizeStageWindow(int newStageWindowSize)
 | 
			
		||||
        {
 | 
			
		||||
            Workspace.GetCurrentAnimationStage().stageWindowSize = newStageWindowSize;
 | 
			
		||||
            Workspace.GetCurrentAnimationStage().PlayTimeTicks = newStageWindowSize * Workspace.stageLoopsNormal;
 | 
			
		||||
            Workspace.GetCurrentAnimationStage().PlayTimeTicksQuick = newStageWindowSize * Workspace.stageLoopsQuick;
 | 
			
		||||
        }
 | 
			
		||||
 | 
			
		||||
        public void AddAnimationClip(int actorID = -1)
 | 
			
		||||
        {
 | 
			
		||||
            PawnAnimationClip clip = new PawnAnimationClip();
 | 
			
		||||
            PawnKeyframe lastkeyframe = null;
 | 
			
		||||
 | 
			
		||||
                if (clip.MakeNew(actor.GetActorID()))
 | 
			
		||||
                { animationClips.Add(clip); }
 | 
			
		||||
            if (actorID >= 0)
 | 
			
		||||
            { lastkeyframe = Workspace.GetPawnAnimationClip(actorID)?.Keyframes?.Last(); }
 | 
			
		||||
 | 
			
		||||
            if (lastkeyframe != null)
 | 
			
		||||
            {
 | 
			
		||||
                PawnKeyframe keyframeA = lastkeyframe.Copy();
 | 
			
		||||
                keyframeA.atTick = null;
 | 
			
		||||
                keyframeA.TickDuration = Constants.defaultAnimationClipLength - 1;
 | 
			
		||||
                keyframeA.GenerateKeyframeID(actorID);
 | 
			
		||||
 | 
			
		||||
                clip.Keyframes.Add(keyframeA);
 | 
			
		||||
 | 
			
		||||
                PawnKeyframe keyframeB = lastkeyframe.Copy();
 | 
			
		||||
                keyframeB.atTick = null;
 | 
			
		||||
                keyframeB.TickDuration = 1;
 | 
			
		||||
                keyframeB.GenerateKeyframeID(actorID);
 | 
			
		||||
 | 
			
		||||
                clip.Keyframes.Add(keyframeB);
 | 
			
		||||
            }
 | 
			
		||||
 | 
			
		||||
            Initialize();
 | 
			
		||||
            playTimeTicksQuick = playTimeTicks;
 | 
			
		||||
            else
 | 
			
		||||
            {
 | 
			
		||||
                PawnKeyframe keyframeA = new PawnKeyframe();
 | 
			
		||||
                keyframeA.TickDuration = Constants.defaultAnimationClipLength - 1;
 | 
			
		||||
 | 
			
		||||
            return true;
 | 
			
		||||
                clip.Keyframes.Add(keyframeA);
 | 
			
		||||
 | 
			
		||||
                PawnKeyframe keyframeB = new PawnKeyframe();
 | 
			
		||||
 | 
			
		||||
                clip.Keyframes.Add(keyframeB);
 | 
			
		||||
            }
 | 
			
		||||
 | 
			
		||||
            clip.BuildSimpleCurves();
 | 
			
		||||
        }
 | 
			
		||||
 | 
			
		||||
        // Pre-save / post-load
 | 
			
		||||
        public void OnPreSave()
 | 
			
		||||
        {
 | 
			
		||||
            foreach (PawnAnimationClip clip in AnimationClips)
 | 
			
		||||
            { clip.Keyframes = clip.Keyframes.OrderBy(x => x.atTick).ToList(); }
 | 
			
		||||
        }
 | 
			
		||||
 | 
			
		||||
        public void OnPostLoad()
 | 
			
		||||
        {
 | 
			
		||||
            foreach (PawnAnimationClip clip in animationClips)
 | 
			
		||||
            {
 | 
			
		||||
                clip.OnPostLoad();
 | 
			
		||||
            }
 | 
			
		||||
            foreach (PawnAnimationClip clip in AnimationClips)
 | 
			
		||||
            { clip.OnPostLoad(); }
 | 
			
		||||
        }
 | 
			
		||||
    }
 | 
			
		||||
}
 | 
			
		||||
| 
						 | 
				
			
			
 | 
			
		|||
| 
						 | 
				
			
			@ -1,5 +1,5 @@
 | 
			
		|||
fileFormatVersion: 2
 | 
			
		||||
guid: 4d62c568c0ad7ea4ba7ddd3b9aa6d0e9
 | 
			
		||||
guid: 9270822a570a06f41afa00e169af500c
 | 
			
		||||
MonoImporter:
 | 
			
		||||
  externalObjects: {}
 | 
			
		||||
  serializedVersion: 2
 | 
			
		||||
| 
						 | 
				
			
			
 | 
			
		|||
| 
						 | 
				
			
			@ -1,6 +1,5 @@
 | 
			
		|||
using System.Reflection;
 | 
			
		||||
using UnityEngine;
 | 
			
		||||
//using Microsoft.Toolkit.Uwp.UI;
 | 
			
		||||
 | 
			
		||||
namespace RimWorldAnimationStudio
 | 
			
		||||
{
 | 
			
		||||
| 
						 | 
				
			
			@ -12,6 +11,11 @@ namespace RimWorldAnimationStudio
 | 
			
		|||
        public string Hulk;
 | 
			
		||||
        public string Fat;
 | 
			
		||||
 | 
			
		||||
        public bool AllOffsetsEmpty()
 | 
			
		||||
        {
 | 
			
		||||
            return string.IsNullOrEmpty(Male) && string.IsNullOrEmpty(Female) && string.IsNullOrEmpty(Thin) && string.IsNullOrEmpty(Hulk) && string.IsNullOrEmpty(Fat);
 | 
			
		||||
        }
 | 
			
		||||
 | 
			
		||||
        public void SetOffset(string bodyType, Vector2 bodyOffset)
 | 
			
		||||
        {
 | 
			
		||||
            FieldInfo bodyTypeOffsetInfo = typeof(BodyTypeOffset).GetField(bodyType);
 | 
			
		||||
| 
						 | 
				
			
			
 | 
			
		|||
| 
						 | 
				
			
			@ -1,5 +1,5 @@
 | 
			
		|||
fileFormatVersion: 2
 | 
			
		||||
guid: 6db04cc11995126429fb12578d6620d7
 | 
			
		||||
guid: 1dfd90f8aa6d0e04086e2b4983d42ab6
 | 
			
		||||
MonoImporter:
 | 
			
		||||
  externalObjects: {}
 | 
			
		||||
  serializedVersion: 2
 | 
			
		||||
| 
						 | 
				
			
			
 | 
			
		|||
| 
						 | 
				
			
			@ -1,11 +0,0 @@
 | 
			
		|||
fileFormatVersion: 2
 | 
			
		||||
guid: 92804390faa29b945818e67cf808b49c
 | 
			
		||||
MonoImporter:
 | 
			
		||||
  externalObjects: {}
 | 
			
		||||
  serializedVersion: 2
 | 
			
		||||
  defaultReferences: []
 | 
			
		||||
  executionOrder: 0
 | 
			
		||||
  icon: {instanceID: 0}
 | 
			
		||||
  userData: 
 | 
			
		||||
  assetBundleName: 
 | 
			
		||||
  assetBundleVariant: 
 | 
			
		||||
| 
						 | 
				
			
			@ -1,21 +0,0 @@
 | 
			
		|||
using System.Collections.Generic;
 | 
			
		||||
using System.Xml;
 | 
			
		||||
using System.Xml.Serialization;
 | 
			
		||||
 | 
			
		||||
namespace RimWorldAnimationStudio
 | 
			
		||||
{
 | 
			
		||||
    public class AddonKeyframe
 | 
			
		||||
    {
 | 
			
		||||
        public string addonName;
 | 
			
		||||
        public float posX;
 | 
			
		||||
        public float posZ;
 | 
			
		||||
        public float rotation;
 | 
			
		||||
        
 | 
			
		||||
        public AddonKeyframe() { }
 | 
			
		||||
 | 
			
		||||
        public AddonKeyframe(string addonName)
 | 
			
		||||
        {
 | 
			
		||||
            this.addonName = addonName;
 | 
			
		||||
        }
 | 
			
		||||
    }
 | 
			
		||||
}
 | 
			
		||||
| 
						 | 
				
			
			@ -1,19 +0,0 @@
 | 
			
		|||
using System.Collections.Generic;
 | 
			
		||||
using System.Xml;
 | 
			
		||||
using System.Xml.Serialization;
 | 
			
		||||
 | 
			
		||||
namespace RimWorldAnimationStudio
 | 
			
		||||
{
 | 
			
		||||
    public class Keyframe
 | 
			
		||||
    {
 | 
			
		||||
        [XmlIgnore] public int? atTick;
 | 
			
		||||
 | 
			
		||||
        public int tickDuration = 1;    
 | 
			
		||||
        public string soundEffect;
 | 
			
		||||
        public List<string> tags = new List<string>();
 | 
			
		||||
 | 
			
		||||
        public bool ShouldSerializetags() { return tags.NotNullOrEmpty(); }
 | 
			
		||||
 | 
			
		||||
        public virtual void ValidateData() { }
 | 
			
		||||
    }
 | 
			
		||||
}
 | 
			
		||||
| 
						 | 
				
			
			@ -1,11 +0,0 @@
 | 
			
		|||
fileFormatVersion: 2
 | 
			
		||||
guid: c909440fcfe86c14c9e363377896367c
 | 
			
		||||
MonoImporter:
 | 
			
		||||
  externalObjects: {}
 | 
			
		||||
  serializedVersion: 2
 | 
			
		||||
  defaultReferences: []
 | 
			
		||||
  executionOrder: 0
 | 
			
		||||
  icon: {instanceID: 0}
 | 
			
		||||
  userData: 
 | 
			
		||||
  assetBundleName: 
 | 
			
		||||
  assetBundleVariant: 
 | 
			
		||||
| 
						 | 
				
			
			@ -1,85 +0,0 @@
 | 
			
		|||
using System;
 | 
			
		||||
using System.Collections.Generic;
 | 
			
		||||
using System.Linq;
 | 
			
		||||
using System.Xml;
 | 
			
		||||
using System.Xml.Serialization;
 | 
			
		||||
using UnityEngine;
 | 
			
		||||
using UnityEngine.UI;
 | 
			
		||||
 | 
			
		||||
namespace RimWorldAnimationStudio
 | 
			
		||||
{
 | 
			
		||||
    public class PawnKeyframe : Keyframe
 | 
			
		||||
    {
 | 
			
		||||
        public float bodyAngle;
 | 
			
		||||
        public float headAngle;
 | 
			
		||||
        public float headBob;
 | 
			
		||||
        public float bodyOffsetX;
 | 
			
		||||
        public float bodyOffsetZ;
 | 
			
		||||
        public float headFacing = 2;
 | 
			
		||||
        public float bodyFacing = 2;
 | 
			
		||||
 | 
			
		||||
        public float genitalAngle;
 | 
			
		||||
        public bool? quiver;
 | 
			
		||||
 | 
			
		||||
        [XmlArray("addonKeyframes"), XmlArrayItem("li")] public List<AddonKeyframe> _addonKeyframes = new List<AddonKeyframe>();
 | 
			
		||||
        
 | 
			
		||||
        [XmlIgnore] public List<AddonKeyframe> addonKeyframes = new List<AddonKeyframe>();
 | 
			
		||||
        [XmlIgnore] public int keyframeID;
 | 
			
		||||
        [XmlIgnore] public int actorID = -1;
 | 
			
		||||
 | 
			
		||||
        public bool ShouldSerializegenitalAngle() { return genitalAngle != 0; }
 | 
			
		||||
        public bool ShouldSerializequiver() { return quiver != null; }
 | 
			
		||||
 | 
			
		||||
        public override void ValidateData()
 | 
			
		||||
        {
 | 
			
		||||
            soundEffect = Tags.soundDefs.Concat(CustomTags.soundDefs).Contains(soundEffect) ? soundEffect : null;
 | 
			
		||||
 | 
			
		||||
            _addonKeyframes.Clear();
 | 
			
		||||
 | 
			
		||||
            foreach (AddonKeyframe addonKeyframe in addonKeyframes)
 | 
			
		||||
            {
 | 
			
		||||
                ActorAddon addon = Workspace.Instance.GetAnimationClipThatOwnsKeyframe(keyframeID, out int clipID).GetActorAddon(addonKeyframe.addonName);
 | 
			
		||||
 | 
			
		||||
                if (addon.render)
 | 
			
		||||
                { _addonKeyframes.Add(addonKeyframe.Copy()); }
 | 
			
		||||
            }
 | 
			
		||||
        }
 | 
			
		||||
 | 
			
		||||
        public void OnPostLoad()
 | 
			
		||||
        {
 | 
			
		||||
            addonKeyframes.Clear();
 | 
			
		||||
 | 
			
		||||
            foreach (AddonKeyframe addonKeyframe in _addonKeyframes)
 | 
			
		||||
            {
 | 
			
		||||
                addonKeyframes.Add(addonKeyframe.Copy());
 | 
			
		||||
            }
 | 
			
		||||
        }
 | 
			
		||||
 | 
			
		||||
        public void GenerateKeyframeID(int actorID)
 | 
			
		||||
        {
 | 
			
		||||
            this.actorID = actorID;
 | 
			
		||||
            int _keyframeID = UnityEngine.Random.Range(100000, 1000000);
 | 
			
		||||
 | 
			
		||||
            if (Workspace.animationDef.animationStages.Any(x => x.animationClips.Any(y => y.keyframes.Any(z => z.keyframeID == _keyframeID))))
 | 
			
		||||
            {
 | 
			
		||||
                GenerateKeyframeID(actorID);
 | 
			
		||||
                return;
 | 
			
		||||
            }
 | 
			
		||||
 | 
			
		||||
            keyframeID = _keyframeID;
 | 
			
		||||
        }
 | 
			
		||||
 | 
			
		||||
        public bool HasValidKeyframeID()
 | 
			
		||||
        { return keyframeID >= 100000 && keyframeID < 1000000; }
 | 
			
		||||
 | 
			
		||||
        public KeyframeSlider GetKeyframeSlider()
 | 
			
		||||
        {
 | 
			
		||||
            return Selectable.allSelectablesArray.FirstOrDefault(x => x.GetComponent<KeyframeSlider>()?.keyframeID == keyframeID)?.GetComponent< KeyframeSlider>();
 | 
			
		||||
        }
 | 
			
		||||
 | 
			
		||||
        public AddonKeyframe GetAddonKeyframe(string addonName)
 | 
			
		||||
        {
 | 
			
		||||
            return addonKeyframes.FirstOrDefault(x => x.addonName == addonName);
 | 
			
		||||
        }
 | 
			
		||||
    }
 | 
			
		||||
}
 | 
			
		||||
| 
						 | 
				
			
			@ -1,13 +0,0 @@
 | 
			
		|||
using System.Collections.Generic;
 | 
			
		||||
using System.Xml;
 | 
			
		||||
using System.Xml.Serialization;
 | 
			
		||||
 | 
			
		||||
namespace RimWorldAnimationStudio
 | 
			
		||||
{
 | 
			
		||||
    public class ThingKeyframe : Keyframe
 | 
			
		||||
    {
 | 
			
		||||
        public float positionX;
 | 
			
		||||
        public float positionZ;
 | 
			
		||||
        public float rotation;
 | 
			
		||||
    }
 | 
			
		||||
}
 | 
			
		||||
| 
						 | 
				
			
			@ -1,11 +0,0 @@
 | 
			
		|||
fileFormatVersion: 2
 | 
			
		||||
guid: 48d6c7ac273c73b498a8bf4c33fda2fc
 | 
			
		||||
MonoImporter:
 | 
			
		||||
  externalObjects: {}
 | 
			
		||||
  serializedVersion: 2
 | 
			
		||||
  defaultReferences: []
 | 
			
		||||
  executionOrder: 0
 | 
			
		||||
  icon: {instanceID: 0}
 | 
			
		||||
  userData: 
 | 
			
		||||
  assetBundleName: 
 | 
			
		||||
  assetBundleVariant: 
 | 
			
		||||
							
								
								
									
										390
									
								
								Assets/Scripts/AnimationComponents/PawnAnimationClip.cs
									
										
									
									
									
										Normal file
									
								
							
							
						
						
									
										390
									
								
								Assets/Scripts/AnimationComponents/PawnAnimationClip.cs
									
										
									
									
									
										Normal file
									
								
							| 
						 | 
				
			
			@ -0,0 +1,390 @@
 | 
			
		|||
using System;
 | 
			
		||||
using System.Collections.Generic;
 | 
			
		||||
using System.Linq;
 | 
			
		||||
using System.Xml;
 | 
			
		||||
using System.Xml.Serialization;
 | 
			
		||||
using UnityEngine;
 | 
			
		||||
 | 
			
		||||
namespace RimWorldAnimationStudio
 | 
			
		||||
{
 | 
			
		||||
    public class PawnAnimationClip
 | 
			
		||||
    {
 | 
			
		||||
        // Data to/from animationDef
 | 
			
		||||
        public string layer = "Pawn";
 | 
			
		||||
        [XmlArray("addons"), XmlArrayItem("li")] public List<ActorAddon> addons;
 | 
			
		||||
        [XmlAttribute("Class")] public string className = "Rimworld_Animations.PawnAnimationClip";
 | 
			
		||||
        [XmlArray("keyframes"), XmlArrayItem("li")] public List<PawnKeyframe> keyframes;
 | 
			
		||||
        [XmlArray("tags"), XmlArrayItem("li")] public List<string> tags;
 | 
			
		||||
 | 
			
		||||
        // Data serialization control
 | 
			
		||||
        public bool ShouldSerializeaddons() { return addons.Where(x => x.Render)?.Any() == true; }
 | 
			
		||||
        public bool ShouldSerializekeyframes() { return keyframes.NotNullOrEmpty(); }
 | 
			
		||||
        public bool ShouldSerializetags() { return tags.NotNullOrEmpty(); }
 | 
			
		||||
 | 
			
		||||
        // Data helper functions
 | 
			
		||||
        [XmlIgnore] public string Layer
 | 
			
		||||
        {
 | 
			
		||||
            get { return layer; }
 | 
			
		||||
            set { layer = value; EventsManager.OnPawnAnimationClipChanged(this); }
 | 
			
		||||
        }
 | 
			
		||||
 | 
			
		||||
        [XmlIgnore] public List<ActorAddon> Addons
 | 
			
		||||
        {
 | 
			
		||||
            get { return addons.NullOrEmpty() ? addons = new List<ActorAddon>() : addons; }
 | 
			
		||||
            set { addons = value.NotNullOrEmpty() ? value : null; EventsManager.OnPawnAnimationClipChanged(this); }
 | 
			
		||||
        }
 | 
			
		||||
 | 
			
		||||
        [XmlIgnore] public List<PawnKeyframe> Keyframes
 | 
			
		||||
        {
 | 
			
		||||
            get { return keyframes.NullOrEmpty() ? keyframes = new List<PawnKeyframe>() : keyframes; }
 | 
			
		||||
            set { keyframes = value.NotNullOrEmpty() ? value : null; EventsManager.OnPawnAnimationClipChanged(this); }
 | 
			
		||||
        }
 | 
			
		||||
 | 
			
		||||
        [XmlIgnore]
 | 
			
		||||
        public List<string> Tags
 | 
			
		||||
        {
 | 
			
		||||
            get { return tags.NullOrEmpty() ? tags = new List<string>() : tags; }
 | 
			
		||||
            set { tags = value.NotNullOrEmpty() ? value : null; EventsManager.OnPawnAnimationClipChanged(this); }
 | 
			
		||||
        }
 | 
			
		||||
 | 
			
		||||
        // Local data
 | 
			
		||||
        [XmlIgnore] public int duration { get { return Keyframes.Max(x => x.atTick.Value); } }
 | 
			
		||||
        
 | 
			
		||||
        [XmlIgnore] public SimpleCurve GenitalAngle = new SimpleCurve();
 | 
			
		||||
        [XmlIgnore] public SimpleCurve BodyAngle = new SimpleCurve();
 | 
			
		||||
        [XmlIgnore] public SimpleCurve HeadAngle = new SimpleCurve();
 | 
			
		||||
        [XmlIgnore] public SimpleCurve HeadBob = new SimpleCurve();
 | 
			
		||||
        [XmlIgnore] public SimpleCurve BodyOffsetX = new SimpleCurve();
 | 
			
		||||
        [XmlIgnore] public SimpleCurve BodyOffsetZ = new SimpleCurve();
 | 
			
		||||
        [XmlIgnore] public SimpleCurve HeadFacing = new SimpleCurve();
 | 
			
		||||
        [XmlIgnore] public SimpleCurve BodyFacing = new SimpleCurve();
 | 
			
		||||
        
 | 
			
		||||
        // Methods
 | 
			
		||||
        public void BuildSimpleCurves()
 | 
			
		||||
        {
 | 
			
		||||
            // Clear simple curve data
 | 
			
		||||
            BodyAngle.Clear();
 | 
			
		||||
            HeadAngle.Clear();
 | 
			
		||||
            BodyOffsetX.Clear();
 | 
			
		||||
            BodyOffsetZ.Clear();
 | 
			
		||||
            HeadFacing.Clear();
 | 
			
		||||
            BodyFacing.Clear();
 | 
			
		||||
            HeadBob.Clear();
 | 
			
		||||
            GenitalAngle.Clear();
 | 
			
		||||
 | 
			
		||||
            foreach (ActorAddon addon in Addons)
 | 
			
		||||
            {
 | 
			
		||||
                addon.PosX.Clear();
 | 
			
		||||
                addon.PosZ.Clear();
 | 
			
		||||
                addon.Rotation.Clear();
 | 
			
		||||
            }
 | 
			
		||||
 | 
			
		||||
            // Start
 | 
			
		||||
            int keyframePosition = 0;
 | 
			
		||||
            int duration = 0;
 | 
			
		||||
 | 
			
		||||
            Keyframes[Keyframes.Count - 1].TickDuration = 1;
 | 
			
		||||
 | 
			
		||||
            foreach (PawnKeyframe frame in Keyframes)
 | 
			
		||||
            { duration += frame.TickDuration; }
 | 
			
		||||
 | 
			
		||||
            for (int i = 0; i < Keyframes.Count; i++)
 | 
			
		||||
            {
 | 
			
		||||
                PawnKeyframe keyframe = Keyframes[i];
 | 
			
		||||
 | 
			
		||||
                if (keyframe.atTick.HasValue)
 | 
			
		||||
                {
 | 
			
		||||
                    if (keyframe.HasValidKeyframeID() == false)
 | 
			
		||||
                    { keyframe.GenerateKeyframeID(Workspace.animationDef.AnimationStages[Workspace.StageID].AnimationClips.IndexOf(this)); }
 | 
			
		||||
 | 
			
		||||
                    BodyAngle.Add((float)keyframe.atTick / (float)duration, keyframe.BodyAngle, true);
 | 
			
		||||
                    HeadAngle.Add((float)keyframe.atTick / (float)duration, keyframe.HeadAngle, true);
 | 
			
		||||
                    BodyOffsetX.Add((float)keyframe.atTick / (float)duration, keyframe.BodyOffsetX, true);
 | 
			
		||||
                    BodyOffsetZ.Add((float)keyframe.atTick / (float)duration, keyframe.BodyOffsetZ, true);
 | 
			
		||||
                    HeadFacing.Add((float)keyframe.atTick / (float)duration, keyframe.HeadFacing, true);
 | 
			
		||||
                    BodyFacing.Add((float)keyframe.atTick / (float)duration, keyframe.BodyFacing, true);
 | 
			
		||||
                    HeadBob.Add((float)keyframe.atTick / (float)duration, keyframe.HeadBob, true);
 | 
			
		||||
                    GenitalAngle.Add((float)keyframe.atTick / (float)duration, keyframe.GenitalAngle, true);
 | 
			
		||||
 | 
			
		||||
                    foreach (ActorAddon addon in Addons)
 | 
			
		||||
                    {
 | 
			
		||||
                        if (keyframe.AddonKeyframes.Any(x => x.AddonName == addon.AddonName) == false)
 | 
			
		||||
                        { keyframe.AddonKeyframes.Add(new AddonKeyframe(addon.AddonName)); }
 | 
			
		||||
 | 
			
		||||
                        addon.PosX.Add((float)keyframe.atTick / (float)duration, keyframe.GetAddonKeyframe(addon.AddonName).PosX, true);
 | 
			
		||||
                        addon.PosZ.Add((float)keyframe.atTick / (float)duration, keyframe.GetAddonKeyframe(addon.AddonName).PosZ, true);
 | 
			
		||||
                        addon.Rotation.Add((float)keyframe.atTick / (float)duration, keyframe.GetAddonKeyframe(addon.AddonName).Rotation, true);
 | 
			
		||||
                    }
 | 
			
		||||
 | 
			
		||||
                    if (i + 1 < Keyframes.Count)
 | 
			
		||||
                    { Keyframes[i].TickDuration = Keyframes[i + 1].atTick.Value - Keyframes[i].atTick.Value; }
 | 
			
		||||
                }
 | 
			
		||||
 | 
			
		||||
                else
 | 
			
		||||
                {
 | 
			
		||||
                    BodyAngle.Add((float)keyframePosition / (float)duration, keyframe.BodyAngle, true);
 | 
			
		||||
                    HeadAngle.Add((float)keyframePosition / (float)duration, keyframe.HeadAngle, true);
 | 
			
		||||
                    BodyOffsetX.Add((float)keyframePosition / (float)duration, keyframe.BodyOffsetX, true);
 | 
			
		||||
                    BodyOffsetZ.Add((float)keyframePosition / (float)duration, keyframe.BodyOffsetZ, true);
 | 
			
		||||
                    HeadFacing.Add((float)keyframePosition / (float)duration, keyframe.HeadFacing, true);
 | 
			
		||||
                    BodyFacing.Add((float)keyframePosition / (float)duration, keyframe.BodyFacing, true);
 | 
			
		||||
                    HeadBob.Add((float)keyframePosition / (float)duration, keyframe.HeadBob, true);
 | 
			
		||||
                    GenitalAngle.Add((float)keyframePosition / (float)duration, keyframe.GenitalAngle, true);
 | 
			
		||||
 | 
			
		||||
                    foreach (ActorAddon addon in Addons)
 | 
			
		||||
                    {
 | 
			
		||||
                        if (keyframe.AddonKeyframes.Any(x => x.AddonName == addon.AddonName) == false)
 | 
			
		||||
                        { keyframe.AddonKeyframes.Add(new AddonKeyframe(addon.AddonName)); }
 | 
			
		||||
 | 
			
		||||
                        addon.PosX.Add((float)keyframePosition / (float)duration, keyframe.GetAddonKeyframe(addon.AddonName).PosX, true);
 | 
			
		||||
                        addon.PosZ.Add((float)keyframePosition / (float)duration, keyframe.GetAddonKeyframe(addon.AddonName).PosZ, true);
 | 
			
		||||
                        addon.Rotation.Add((float)keyframePosition / (float)duration, keyframe.GetAddonKeyframe(addon.AddonName).Rotation, true);
 | 
			
		||||
                    }
 | 
			
		||||
 | 
			
		||||
                    keyframe.atTick = keyframePosition + Constants.minTick;
 | 
			
		||||
                    keyframePosition += keyframe.TickDuration;
 | 
			
		||||
                }
 | 
			
		||||
            }
 | 
			
		||||
        }
 | 
			
		||||
 | 
			
		||||
        public void AddActorAddon(string addonName, float scale = 1f)
 | 
			
		||||
        {
 | 
			
		||||
            if (Addons.Any(x => x.AddonName == addonName) == false)
 | 
			
		||||
            { 
 | 
			
		||||
                Addons.Add(new ActorAddon(addonName, scale));
 | 
			
		||||
            }
 | 
			
		||||
 | 
			
		||||
            foreach (PawnKeyframe keyframe in Keyframes)
 | 
			
		||||
            {
 | 
			
		||||
                if (keyframe.AddonKeyframes.Any(x => x.AddonName == addonName) == false)
 | 
			
		||||
                { keyframe.AddonKeyframes.Add(new AddonKeyframe(addonName)); }
 | 
			
		||||
            }
 | 
			
		||||
        }
 | 
			
		||||
 | 
			
		||||
        public void ShowOrHideActorAddon(string addonName, bool flag)
 | 
			
		||||
        {
 | 
			
		||||
            ActorAddon addon = GetActorAddon(addonName);
 | 
			
		||||
 | 
			
		||||
            if (addon != null)
 | 
			
		||||
            { addon.Render = flag; }
 | 
			
		||||
        }
 | 
			
		||||
 | 
			
		||||
        public bool IsActorAddonVisible(string addonName)
 | 
			
		||||
        {
 | 
			
		||||
            ActorAddon addon = GetActorAddon(addonName);
 | 
			
		||||
 | 
			
		||||
            if (addon != null)
 | 
			
		||||
            { return addon.Render; }
 | 
			
		||||
 | 
			
		||||
            return false;
 | 
			
		||||
        }
 | 
			
		||||
 | 
			
		||||
        public ActorAddon GetActorAddon(string addonName)
 | 
			
		||||
        {
 | 
			
		||||
            return Addons.FirstOrDefault(x => x.AddonName == addonName);
 | 
			
		||||
        }
 | 
			
		||||
 | 
			
		||||
        public int GetOwningActorID()
 | 
			
		||||
        {
 | 
			
		||||
            if (Workspace.animationDef == null) return -1;
 | 
			
		||||
 | 
			
		||||
            return Workspace.GetCurrentAnimationStage().AnimationClips.IndexOf(this);
 | 
			
		||||
        }
 | 
			
		||||
 | 
			
		||||
        public void AddPawnKeyframe()
 | 
			
		||||
        {
 | 
			
		||||
            PawnAnimationClip clip = Workspace.GetCurrentPawnAnimationClip();
 | 
			
		||||
            List<PawnKeyframe> keyframes = clip?.Keyframes;
 | 
			
		||||
 | 
			
		||||
            if (clip == null || keyframes == null)
 | 
			
		||||
            { Debug.LogWarning("Cannot add pawn keyframe - the AnimationDef is invalid"); return; }
 | 
			
		||||
 | 
			
		||||
            if (keyframes.FirstOrDefault(x => x.atTick == Workspace.StageTick) != null)
 | 
			
		||||
            { Debug.LogWarning("Cannot add pawn keyframe - a keyframe already exists at this tick"); return; }
 | 
			
		||||
 | 
			
		||||
            float clipPercent = (float)(Workspace.StageTick % clip.duration) / clip.duration;
 | 
			
		||||
 | 
			
		||||
            PawnKeyframe keyframe = new PawnKeyframe();
 | 
			
		||||
            keyframe.BodyAngle = clip.BodyAngle.Evaluate(clipPercent);
 | 
			
		||||
            keyframe.HeadAngle = clip.HeadAngle.Evaluate(clipPercent);
 | 
			
		||||
            keyframe.HeadBob = clip.HeadBob.Evaluate(clipPercent);
 | 
			
		||||
            keyframe.BodyOffsetX = clip.BodyOffsetX.Evaluate(clipPercent);
 | 
			
		||||
            keyframe.BodyOffsetZ = clip.BodyOffsetZ.Evaluate(clipPercent);
 | 
			
		||||
            keyframe.HeadFacing = (int)clip.HeadFacing.Evaluate(clipPercent);
 | 
			
		||||
            keyframe.BodyFacing = (int)clip.BodyFacing.Evaluate(clipPercent);
 | 
			
		||||
            keyframe.GenitalAngle = clip.GenitalAngle.Evaluate(clipPercent);
 | 
			
		||||
 | 
			
		||||
            keyframe.atTick = Workspace.StageTick;
 | 
			
		||||
 | 
			
		||||
            PawnKeyframe nextKeyframe = keyframes.FirstOrDefault(x => x.atTick > Workspace.StageTick);
 | 
			
		||||
 | 
			
		||||
            if (nextKeyframe != null)
 | 
			
		||||
            { keyframes.Insert(keyframes.IndexOf(nextKeyframe), keyframe); }
 | 
			
		||||
 | 
			
		||||
            else
 | 
			
		||||
            { keyframes.Add(keyframe); }
 | 
			
		||||
 | 
			
		||||
            clip.BuildSimpleCurves();
 | 
			
		||||
 | 
			
		||||
            Workspace.RecordEvent("Keyframe addition");
 | 
			
		||||
        }
 | 
			
		||||
 | 
			
		||||
        public void ClonePawnKeyframe()
 | 
			
		||||
        {
 | 
			
		||||
            List<PawnKeyframe> keyframesToClone = Workspace.GetPawnKeyframesByID(Workspace.keyframeID);
 | 
			
		||||
 | 
			
		||||
            foreach (PawnKeyframe keyframe in keyframesToClone)
 | 
			
		||||
            {
 | 
			
		||||
                PawnAnimationClip clip = Workspace.GetAnimationClipThatOwnsKeyframe(keyframe.keyframeID, out int clipID);
 | 
			
		||||
 | 
			
		||||
                if (clip == null)
 | 
			
		||||
                { Debug.LogWarning("Cannot clone pawn keyframe - no clip owns this keyframe"); continue; }
 | 
			
		||||
 | 
			
		||||
                if (clip.Keyframes.FirstOrDefault(x => x.atTick == Workspace.StageTick) != null)
 | 
			
		||||
                { Debug.LogWarning("Cannot clone pawn keyframe - a keyframe already exists at this tick"); return; }
 | 
			
		||||
 | 
			
		||||
                PawnKeyframe cloneFrame = keyframe.Copy();
 | 
			
		||||
                cloneFrame.GenerateKeyframeID(clipID);
 | 
			
		||||
                cloneFrame.atTick = Workspace.StageTick;
 | 
			
		||||
 | 
			
		||||
                PawnKeyframe nextKeyframe = clip.Keyframes.FirstOrDefault(x => x.atTick > Workspace.StageTick);
 | 
			
		||||
 | 
			
		||||
                if (nextKeyframe != null)
 | 
			
		||||
                { clip.Keyframes.Insert(clip.Keyframes.IndexOf(nextKeyframe), cloneFrame); }
 | 
			
		||||
 | 
			
		||||
                else
 | 
			
		||||
                { clip.Keyframes.Add(cloneFrame); }
 | 
			
		||||
 | 
			
		||||
                clip.BuildSimpleCurves();
 | 
			
		||||
            }
 | 
			
		||||
 | 
			
		||||
            Workspace.RecordEvent("Keyframe clone");
 | 
			
		||||
        }
 | 
			
		||||
 | 
			
		||||
        public void CopyPawnKeyframes()
 | 
			
		||||
        {
 | 
			
		||||
            Workspace.copiedKeyframes.Clear();
 | 
			
		||||
 | 
			
		||||
            List<PawnKeyframe> keyframesToClone = Workspace.GetPawnKeyframesByID(Workspace.keyframeID);
 | 
			
		||||
 | 
			
		||||
            foreach (PawnKeyframe keyframe in keyframesToClone)
 | 
			
		||||
            { Workspace.copiedKeyframes.Add(keyframe.Copy()); }
 | 
			
		||||
        }
 | 
			
		||||
 | 
			
		||||
        public void PastePawnKeyframes()
 | 
			
		||||
        {
 | 
			
		||||
            int originalWindowSize = Workspace.StageWindowSize;
 | 
			
		||||
 | 
			
		||||
            List<int> actorsInvolved = Workspace.copiedKeyframes.Select(x => x.actorID)?.ToList();
 | 
			
		||||
            actorsInvolved = actorsInvolved?.Distinct()?.ToList();
 | 
			
		||||
 | 
			
		||||
            if (actorsInvolved.NullOrEmpty()) { Debug.Log("Cannot paste keyframes - there were no copied keyframes to paste"); return; }
 | 
			
		||||
            if (actorsInvolved.Count > 1 && actorsInvolved.Contains(Workspace.ActorID) == false) { Debug.Log("Cannot paste keyframes - keyframes copied across multiple timelines can only be pasted back into these source timelines"); return; }
 | 
			
		||||
 | 
			
		||||
            int earliestTick = actorsInvolved.Count == 1 ? Workspace.GetEarliestAtTickInCopiedKeyframes(actorsInvolved[0]) : Workspace.GetEarliestAtTickInCopiedKeyframes(Workspace.ActorID);
 | 
			
		||||
            if (earliestTick < 1) { Debug.Log("Unknown error occured during keyframe paste operation"); return; }
 | 
			
		||||
 | 
			
		||||
            foreach (PawnKeyframe copiedKeyframe in Workspace.copiedKeyframes)
 | 
			
		||||
            {
 | 
			
		||||
                int tickToPasteAt = Workspace.StageTick + (copiedKeyframe.atTick.Value - earliestTick);
 | 
			
		||||
 | 
			
		||||
                if (tickToPasteAt < 1) continue;
 | 
			
		||||
                if (tickToPasteAt > Workspace.StageWindowSize)
 | 
			
		||||
                {
 | 
			
		||||
                    if (Workspace.stretchKeyframes)
 | 
			
		||||
                    { Workspace.GetCurrentAnimationStage().ResizeStageWindow(tickToPasteAt); }
 | 
			
		||||
 | 
			
		||||
                    else continue;
 | 
			
		||||
                }
 | 
			
		||||
 | 
			
		||||
                int targetActorID = actorsInvolved.Count == 1 ? Workspace.ActorID : copiedKeyframe.actorID;
 | 
			
		||||
 | 
			
		||||
                if (Workspace.DoesPawnKeyframeExistAtTick(Workspace.StageID, targetActorID, tickToPasteAt))
 | 
			
		||||
                {
 | 
			
		||||
                    PawnKeyframe oldKeyframe = Workspace.animationDef.AnimationStages[Workspace.StageID].AnimationClips[targetActorID].Keyframes.First(x => x.atTick == tickToPasteAt);
 | 
			
		||||
                    RemovePawnKeyframe(targetActorID, oldKeyframe.keyframeID, true);
 | 
			
		||||
                }
 | 
			
		||||
 | 
			
		||||
                PawnKeyframe clonedKeyframe = copiedKeyframe.Copy();
 | 
			
		||||
                clonedKeyframe.GenerateKeyframeID(targetActorID);
 | 
			
		||||
                clonedKeyframe.atTick = tickToPasteAt;
 | 
			
		||||
 | 
			
		||||
                PawnAnimationClip clip = Workspace.animationDef.AnimationStages[Workspace.StageID].AnimationClips[targetActorID];
 | 
			
		||||
                PawnKeyframe nextKeyframe = clip.Keyframes.FirstOrDefault(x => x.atTick > tickToPasteAt);
 | 
			
		||||
 | 
			
		||||
                if (nextKeyframe != null)
 | 
			
		||||
                { clip.Keyframes.Insert(clip.Keyframes.IndexOf(nextKeyframe), clonedKeyframe); }
 | 
			
		||||
 | 
			
		||||
                else
 | 
			
		||||
                { clip.Keyframes.Add(clonedKeyframe); }
 | 
			
		||||
 | 
			
		||||
                clip.BuildSimpleCurves();
 | 
			
		||||
            }
 | 
			
		||||
 | 
			
		||||
            if (originalWindowSize != Workspace.StageWindowSize)
 | 
			
		||||
            {
 | 
			
		||||
                Workspace.GetCurrentAnimationStage().StretchStageWindow(originalWindowSize);
 | 
			
		||||
                Workspace.GetCurrentAnimationStage().ResizeStageWindow(originalWindowSize);
 | 
			
		||||
            }
 | 
			
		||||
 | 
			
		||||
            Workspace.RecordEvent("Keyframe pasted");
 | 
			
		||||
        }
 | 
			
		||||
 | 
			
		||||
        public void RemovePawnKeyframe()
 | 
			
		||||
        {
 | 
			
		||||
            foreach (int keyframeID in Workspace.keyframeID)
 | 
			
		||||
            {
 | 
			
		||||
                if (Workspace.GetAnimationClipThatOwnsKeyframe(keyframeID, out int clipID) != null)
 | 
			
		||||
                { RemovePawnKeyframe(clipID, keyframeID); }
 | 
			
		||||
            }
 | 
			
		||||
        }
 | 
			
		||||
 | 
			
		||||
        public void RemovePawnKeyframe(int actorID, int keyframeID, bool force = false)
 | 
			
		||||
        {
 | 
			
		||||
            PawnKeyframe keyframe = Workspace.GetPawnKeyframe(actorID, keyframeID);
 | 
			
		||||
            PawnAnimationClip clip = Workspace.animationDef.AnimationStages[Workspace.StageID].AnimationClips[actorID];
 | 
			
		||||
 | 
			
		||||
            if (keyframe == null || clip == null) return;
 | 
			
		||||
 | 
			
		||||
            if (keyframe.atTick == Constants.minTick && force == false)
 | 
			
		||||
            { Debug.LogWarning("Cannot delete key frame - the first key frame of an animation clip cannot be deleted"); return; }
 | 
			
		||||
 | 
			
		||||
            if (clip.Keyframes.Count <= 2 && force == false)
 | 
			
		||||
            { Debug.LogWarning("Cannot delete key frame - an animation clip must have two or more keyframes"); return; }
 | 
			
		||||
 | 
			
		||||
            clip.Keyframes.Remove(keyframe);
 | 
			
		||||
            clip.BuildSimpleCurves();
 | 
			
		||||
 | 
			
		||||
            Workspace.RecordEvent("Keyframe deletion");
 | 
			
		||||
        }
 | 
			
		||||
 | 
			
		||||
        public float GetStageTickPercentage()
 | 
			
		||||
        {
 | 
			
		||||
            return (float)(Workspace.StageTick % duration) / duration;
 | 
			
		||||
        }
 | 
			
		||||
 | 
			
		||||
        // Pre-save / post-load
 | 
			
		||||
        public void OnPreSave()
 | 
			
		||||
        {
 | 
			
		||||
            foreach (ActorAddon addon in Addons)
 | 
			
		||||
            {
 | 
			
		||||
                if (addon.Render)
 | 
			
		||||
                { addons.Add(addon); }
 | 
			
		||||
            }
 | 
			
		||||
        }
 | 
			
		||||
 | 
			
		||||
        public void OnPostLoad()
 | 
			
		||||
        {
 | 
			
		||||
            Addons = addons.Copy();
 | 
			
		||||
 | 
			
		||||
            foreach (PawnKeyframe keyframe in Keyframes)
 | 
			
		||||
            {
 | 
			
		||||
                keyframe.OnPostLoad();
 | 
			
		||||
            }
 | 
			
		||||
 | 
			
		||||
            AddActorAddon("left hand", 0.667f);
 | 
			
		||||
            AddActorAddon("right hand", 0.667f);
 | 
			
		||||
            AddActorAddon("dildo");
 | 
			
		||||
        }
 | 
			
		||||
    }
 | 
			
		||||
}
 | 
			
		||||
| 
						 | 
				
			
			@ -1,5 +1,5 @@
 | 
			
		|||
fileFormatVersion: 2
 | 
			
		||||
guid: b7f2dc95148378445919ef3ed8705c5d
 | 
			
		||||
guid: bd5a477338567fb4cbb26b913a52ca65
 | 
			
		||||
MonoImporter:
 | 
			
		||||
  externalObjects: {}
 | 
			
		||||
  serializedVersion: 2
 | 
			
		||||
							
								
								
									
										177
									
								
								Assets/Scripts/AnimationComponents/PawnKeyframe.cs
									
										
									
									
									
										Normal file
									
								
							
							
						
						
									
										177
									
								
								Assets/Scripts/AnimationComponents/PawnKeyframe.cs
									
										
									
									
									
										Normal file
									
								
							| 
						 | 
				
			
			@ -0,0 +1,177 @@
 | 
			
		|||
using System;
 | 
			
		||||
using System.Collections.Generic;
 | 
			
		||||
using System.Linq;
 | 
			
		||||
using System.Xml;
 | 
			
		||||
using System.Xml.Serialization;
 | 
			
		||||
using UnityEngine;
 | 
			
		||||
using UnityEngine.UI;
 | 
			
		||||
 | 
			
		||||
namespace RimWorldAnimationStudio
 | 
			
		||||
{
 | 
			
		||||
    public class PawnKeyframe
 | 
			
		||||
    {
 | 
			
		||||
        // Data to/from animationDef
 | 
			
		||||
        public float? bodyAngle;
 | 
			
		||||
        public float? headAngle;
 | 
			
		||||
        public float? headBob;
 | 
			
		||||
        public float? bodyOffsetX;
 | 
			
		||||
        public float? bodyOffsetZ;
 | 
			
		||||
        public int? headFacing;
 | 
			
		||||
        public int? bodyFacing;
 | 
			
		||||
        public float? genitalAngle;
 | 
			
		||||
        public bool? quiver;
 | 
			
		||||
        public int? tickDuration;
 | 
			
		||||
        public string soundEffect;
 | 
			
		||||
        public List<string> tags;
 | 
			
		||||
        [XmlArray("addonKeyframes"), XmlArrayItem("li")] public List<AddonKeyframe> addonKeyframes;
 | 
			
		||||
 | 
			
		||||
        // Data serialization control
 | 
			
		||||
        public bool ShouldSerializebodyAngle() { return bodyAngle.HasValue && bodyAngle.Value != 0f; }
 | 
			
		||||
        public bool ShouldSerializeheadAngle() { return headAngle.HasValue && headAngle.Value != 0f; }
 | 
			
		||||
        public bool ShouldSerializeheadBob() { return headBob.HasValue && headBob.Value != 0f; }
 | 
			
		||||
        public bool ShouldSerializebodyOffsetX() { return bodyOffsetX.HasValue && bodyOffsetX.Value != 0f; }
 | 
			
		||||
        public bool ShouldSerializebodyOffsetZ() { return bodyOffsetZ.HasValue && bodyOffsetZ.Value != 0f; }
 | 
			
		||||
        public bool ShouldSerializegenitalAngle() { return genitalAngle.HasValue && genitalAngle.Value != 0f; }
 | 
			
		||||
        public bool ShouldSerializequiver() { return quiver == true; }
 | 
			
		||||
        public bool ShouldSerializetags() { return tags.NotNullOrEmpty(); }
 | 
			
		||||
        public bool ShouldSerializeaddonKeyframes() { return addonKeyframes.NotNullOrEmpty(); }
 | 
			
		||||
 | 
			
		||||
        // Data helper functions
 | 
			
		||||
        [XmlIgnore] public float BodyAngle
 | 
			
		||||
        {
 | 
			
		||||
            get { return bodyAngle.HasValue ? bodyAngle.Value : 0f; }
 | 
			
		||||
            set { bodyAngle = value; EventsManager.OnPawnKeyframeChanged(this); }
 | 
			
		||||
        }
 | 
			
		||||
 | 
			
		||||
        [XmlIgnore] public float HeadAngle
 | 
			
		||||
        {
 | 
			
		||||
            get { return headAngle.HasValue ? headAngle.Value : (float)(headAngle = 0f); }
 | 
			
		||||
            set { headAngle = value; EventsManager.OnPawnKeyframeChanged(this); }
 | 
			
		||||
        }
 | 
			
		||||
 | 
			
		||||
        [XmlIgnore] public float HeadBob
 | 
			
		||||
        {
 | 
			
		||||
            get { return headBob.HasValue ? headBob.Value : (float)(headBob = 0f); }
 | 
			
		||||
            set { headBob = value; EventsManager.OnPawnKeyframeChanged(this); }
 | 
			
		||||
        }
 | 
			
		||||
 | 
			
		||||
        [XmlIgnore] public float BodyOffsetX
 | 
			
		||||
        {
 | 
			
		||||
            get { return bodyOffsetX.HasValue ? bodyOffsetX.Value : (float)(bodyOffsetX = 0f); }
 | 
			
		||||
            set { bodyOffsetX = value; EventsManager.OnPawnKeyframeChanged(this); }
 | 
			
		||||
        }
 | 
			
		||||
 | 
			
		||||
        [XmlIgnore] public float BodyOffsetZ
 | 
			
		||||
        {
 | 
			
		||||
            get { return bodyOffsetZ.HasValue ? bodyOffsetZ.Value : (float)(bodyOffsetZ = 0f); }
 | 
			
		||||
            set { bodyOffsetZ = value; EventsManager.OnPawnKeyframeChanged(this); }
 | 
			
		||||
        }
 | 
			
		||||
 | 
			
		||||
        [XmlIgnore] public int HeadFacing
 | 
			
		||||
        {
 | 
			
		||||
            get { return headFacing.HasValue ? headFacing.Value : (int)(headFacing = 2); }
 | 
			
		||||
            set { headFacing = value; EventsManager.OnPawnKeyframeChanged(this); }
 | 
			
		||||
        }
 | 
			
		||||
 | 
			
		||||
        [XmlIgnore] public int BodyFacing
 | 
			
		||||
        {
 | 
			
		||||
            get { return bodyFacing.HasValue ? bodyFacing.Value : (int)(bodyFacing = 2); }
 | 
			
		||||
            set { bodyFacing = value; EventsManager.OnPawnKeyframeChanged(this); }
 | 
			
		||||
        }
 | 
			
		||||
 | 
			
		||||
        [XmlIgnore] public float GenitalAngle
 | 
			
		||||
        {
 | 
			
		||||
            get { return genitalAngle.HasValue ? genitalAngle.Value : (float)(genitalAngle = 0f); }
 | 
			
		||||
            set { genitalAngle = value; EventsManager.OnPawnKeyframeChanged(this); }
 | 
			
		||||
        }
 | 
			
		||||
 | 
			
		||||
        [XmlIgnore] public bool Quiver
 | 
			
		||||
        {
 | 
			
		||||
            get { return quiver == true; }
 | 
			
		||||
            set { quiver = value; EventsManager.OnPawnKeyframeChanged(this); }
 | 
			
		||||
        }
 | 
			
		||||
 | 
			
		||||
        [XmlIgnore] public int TickDuration
 | 
			
		||||
        {
 | 
			
		||||
            get { return tickDuration.HasValue ? tickDuration.Value : (int)(tickDuration = 0); }
 | 
			
		||||
            set { tickDuration = value; EventsManager.OnPawnKeyframeChanged(this); }
 | 
			
		||||
        }
 | 
			
		||||
 | 
			
		||||
        [XmlIgnore] public string SoundEffect
 | 
			
		||||
        {
 | 
			
		||||
            get { return soundEffect; }
 | 
			
		||||
            set { soundEffect = value; EventsManager.OnPawnKeyframeChanged(this); }
 | 
			
		||||
        }
 | 
			
		||||
 | 
			
		||||
        [XmlIgnore] public List<string> Tags
 | 
			
		||||
        {
 | 
			
		||||
            get { return tags.NullOrEmpty() ? tags = new List<string>() : tags; }
 | 
			
		||||
            set { tags = value.NotNullOrEmpty() ? value : null; EventsManager.OnPawnKeyframeChanged(this); }
 | 
			
		||||
        }
 | 
			
		||||
 | 
			
		||||
        [XmlIgnore] public List<AddonKeyframe> AddonKeyframes
 | 
			
		||||
        {
 | 
			
		||||
            get { return addonKeyframes.NullOrEmpty() ? addonKeyframes = new List<AddonKeyframe>() : addonKeyframes; }
 | 
			
		||||
            set { addonKeyframes = value.NotNullOrEmpty()? value : null; EventsManager.OnPawnKeyframeChanged(this); }
 | 
			
		||||
        }
 | 
			
		||||
 | 
			
		||||
        // Local data
 | 
			
		||||
        [XmlIgnore] public int keyframeID;
 | 
			
		||||
        [XmlIgnore] public int actorID = -1;
 | 
			
		||||
        [XmlIgnore] public int? atTick;
 | 
			
		||||
 | 
			
		||||
        // Methods
 | 
			
		||||
        public void GenerateKeyframeID(int actorID)
 | 
			
		||||
        {
 | 
			
		||||
            this.actorID = actorID;
 | 
			
		||||
            int _keyframeID = UnityEngine.Random.Range(100000, 1000000);
 | 
			
		||||
 | 
			
		||||
            if (Workspace.animationDef.AnimationStages.Any(x => x.AnimationClips.Any(y => y.Keyframes.Any(z => z.keyframeID == _keyframeID))))
 | 
			
		||||
            {
 | 
			
		||||
                GenerateKeyframeID(actorID);
 | 
			
		||||
                return;
 | 
			
		||||
            }
 | 
			
		||||
 | 
			
		||||
            keyframeID = _keyframeID;
 | 
			
		||||
        }
 | 
			
		||||
 | 
			
		||||
        public bool HasValidKeyframeID()
 | 
			
		||||
        { return keyframeID >= 100000 && keyframeID < 1000000; }
 | 
			
		||||
 | 
			
		||||
        public KeyframeSlider GetKeyframeSlider()
 | 
			
		||||
        {
 | 
			
		||||
            return Selectable.allSelectablesArray.FirstOrDefault(x => x.GetComponent<KeyframeSlider>()?.keyframeID == keyframeID)?.GetComponent< KeyframeSlider>();
 | 
			
		||||
        }
 | 
			
		||||
 | 
			
		||||
        public AddonKeyframe GetAddonKeyframe(string addonName)
 | 
			
		||||
        {
 | 
			
		||||
            return AddonKeyframes.FirstOrDefault(x => x.AddonName == addonName);
 | 
			
		||||
        }
 | 
			
		||||
 | 
			
		||||
        // Pre-save / post-load
 | 
			
		||||
        public void OnPreSave()
 | 
			
		||||
        {
 | 
			
		||||
            SoundEffect = DefaultTags.soundDefs.Concat(CustomTags.soundDefs).Contains(SoundEffect) ? SoundEffect : null;
 | 
			
		||||
 | 
			
		||||
            addonKeyframes.Clear();
 | 
			
		||||
 | 
			
		||||
            foreach (AddonKeyframe addonKeyframe in AddonKeyframes)
 | 
			
		||||
            {
 | 
			
		||||
                ActorAddon addon = Workspace.GetAnimationClipThatOwnsKeyframe(keyframeID, out int clipID).GetActorAddon(addonKeyframe.AddonName);
 | 
			
		||||
 | 
			
		||||
                if (addon.Render)
 | 
			
		||||
                { addonKeyframes.Add(addonKeyframe.Copy()); }
 | 
			
		||||
            }
 | 
			
		||||
        }
 | 
			
		||||
 | 
			
		||||
        public void OnPostLoad()
 | 
			
		||||
        {
 | 
			
		||||
            AddonKeyframes.Clear();
 | 
			
		||||
 | 
			
		||||
            foreach (AddonKeyframe addonKeyframe in addonKeyframes)
 | 
			
		||||
            {
 | 
			
		||||
                AddonKeyframes.Add(addonKeyframe.Copy());
 | 
			
		||||
            }
 | 
			
		||||
        }
 | 
			
		||||
    }
 | 
			
		||||
}
 | 
			
		||||
| 
						 | 
				
			
			@ -1,5 +1,5 @@
 | 
			
		|||
fileFormatVersion: 2
 | 
			
		||||
guid: fe4a7d5f472a25945bac2d1892a4e2fa
 | 
			
		||||
guid: c8ced38490f6b174984453dc3336a543
 | 
			
		||||
MonoImporter:
 | 
			
		||||
  externalObjects: {}
 | 
			
		||||
  serializedVersion: 2
 | 
			
		||||
| 
						 | 
				
			
			@ -9,8 +9,9 @@ using UnityEngine;
 | 
			
		|||
namespace RimWorldAnimationStudio
 | 
			
		||||
{
 | 
			
		||||
    [Serializable]
 | 
			
		||||
    public class AlienRaceDef
 | 
			
		||||
    public class PawnRaceDef
 | 
			
		||||
    {
 | 
			
		||||
        // Local data
 | 
			
		||||
        public string defName;
 | 
			
		||||
        public bool isHumanoid = true;
 | 
			
		||||
        public float scale = 1f;
 | 
			
		||||
| 
						 | 
				
			
			@ -18,13 +19,15 @@ namespace RimWorldAnimationStudio
 | 
			
		|||
        public List<MultiDirectionalGraphic> bodyTypeGraphics = new List<MultiDirectionalGraphic>();
 | 
			
		||||
        public MultiDirectionalGraphic headGraphics = new MultiDirectionalGraphic();
 | 
			
		||||
 | 
			
		||||
        public AlienRaceDef() { }
 | 
			
		||||
        // Constructors
 | 
			
		||||
        public PawnRaceDef() { }
 | 
			
		||||
 | 
			
		||||
        public AlienRaceDef(string defName)
 | 
			
		||||
        public PawnRaceDef(string defName)
 | 
			
		||||
        {
 | 
			
		||||
            this.defName = defName;
 | 
			
		||||
        }
 | 
			
		||||
 | 
			
		||||
        // Methods
 | 
			
		||||
        public Sprite GetHeadGraphic(CardinalDirection facing)
 | 
			
		||||
        {
 | 
			
		||||
            if (HasValidHeadGraphicPath(facing) == false)
 | 
			
		||||
| 
						 | 
				
			
			@ -1,5 +1,5 @@
 | 
			
		|||
fileFormatVersion: 2
 | 
			
		||||
guid: c4a44c0d3b9937c48b2ae8501126227e
 | 
			
		||||
guid: 187aef38ea296184b93265071536969c
 | 
			
		||||
MonoImporter:
 | 
			
		||||
  externalObjects: {}
 | 
			
		||||
  serializedVersion: 2
 | 
			
		||||
| 
						 | 
				
			
			@ -5,21 +5,25 @@ using UnityEngine;
 | 
			
		|||
namespace RimWorldAnimationStudio
 | 
			
		||||
{
 | 
			
		||||
    [Serializable]
 | 
			
		||||
    public class AlienRaceOffset
 | 
			
		||||
    public class PawnRaceOffset
 | 
			
		||||
    {
 | 
			
		||||
        // Local data
 | 
			
		||||
        public string defName = "Human";
 | 
			
		||||
        public string offset = "(0, 0)";
 | 
			
		||||
 | 
			
		||||
        // SHoulda serialize
 | 
			
		||||
        public bool ShouldSerializedefName() { return OffsetIsZero() == false; }
 | 
			
		||||
        public bool ShouldSerializeoffset() { return OffsetIsZero() == false; }
 | 
			
		||||
 | 
			
		||||
        public AlienRaceOffset() { }
 | 
			
		||||
        // Constructors
 | 
			
		||||
        public PawnRaceOffset() { }
 | 
			
		||||
 | 
			
		||||
        public AlienRaceOffset(string defName)
 | 
			
		||||
        public PawnRaceOffset(string defName)
 | 
			
		||||
        {
 | 
			
		||||
            this.defName = defName;
 | 
			
		||||
        }
 | 
			
		||||
 | 
			
		||||
        // Methods
 | 
			
		||||
        public void SetOffset(Vector2 raceOffset)
 | 
			
		||||
        {
 | 
			
		||||
            offset = "(" + raceOffset.x + ", " + raceOffset.y + ")";
 | 
			
		||||
| 
						 | 
				
			
			@ -1,5 +1,5 @@
 | 
			
		|||
fileFormatVersion: 2
 | 
			
		||||
guid: 5b8a2db320a85494c882518c143b73f7
 | 
			
		||||
guid: 24eafaf092974414ca90bfd4a8d2e4ba
 | 
			
		||||
MonoImporter:
 | 
			
		||||
  externalObjects: {}
 | 
			
		||||
  serializedVersion: 2
 | 
			
		||||
							
								
								
									
										41
									
								
								Assets/Scripts/Data/Constants.cs
									
										
									
									
									
										Normal file
									
								
							
							
						
						
									
										41
									
								
								Assets/Scripts/Data/Constants.cs
									
										
									
									
									
										Normal file
									
								
							| 
						 | 
				
			
			@ -0,0 +1,41 @@
 | 
			
		|||
using System.Collections.Generic;
 | 
			
		||||
using System.Linq;
 | 
			
		||||
using System.Xml.Serialization;
 | 
			
		||||
using UnityEngine;
 | 
			
		||||
 | 
			
		||||
namespace RimWorldAnimationStudio
 | 
			
		||||
{
 | 
			
		||||
    public static class Constants
 | 
			
		||||
    {
 | 
			
		||||
        // Project data
 | 
			
		||||
        public static string currentVersion = "0.0.0";
 | 
			
		||||
        public static string projectHome = "https://gitgud.io/AbstractConcept/rimworld-animation-studio";
 | 
			
		||||
        public static string projectWiki = "https://gitgud.io/AbstractConcept/rimworld-animation-studio/-/wikis/home";
 | 
			
		||||
 | 
			
		||||
        // Actions
 | 
			
		||||
        public static float actionRepeatSpeed = 0.250f;
 | 
			
		||||
 | 
			
		||||
        // Animation defaults
 | 
			
		||||
        public static int defaultAnimationClipLength = 600;
 | 
			
		||||
        public static int minTick = 1;
 | 
			
		||||
        public static int minAnimationClipLength = 5;
 | 
			
		||||
        public static int maxAnimationClipLength = 9999;
 | 
			
		||||
 | 
			
		||||
        // Colors used
 | 
			
		||||
        public static Color ColorWhite = new Color(1f, 1f, 1f);
 | 
			
		||||
        public static Color ColorGreen = new Color(0f, 1f, 0f);
 | 
			
		||||
        public static Color ColorGoldYellow = new Color(1f, 0.85f, 0f);
 | 
			
		||||
        public static Color ColorDarkGold = new Color(0.75f, 0.64f, 0f);
 | 
			
		||||
        public static Color ColorLightGrey = new Color(0.9f, 0.9f, 0.9f);
 | 
			
		||||
        public static Color ColorMidGrey = new Color(0.75f, 0.75f, 0.75f);
 | 
			
		||||
        public static Color ColorGrey = new Color(0.5f, 0.5f, 0.5f);
 | 
			
		||||
        public static Color ColorDarkGrey = new Color(0.2f, 0.2f, 0.2f);
 | 
			
		||||
        public static Color ColorPink = new Color(1.0f, 0.5f, 0.5f);
 | 
			
		||||
        public static Color ColorOrange = new Color(1.0f, 0.7f, 0.0f);
 | 
			
		||||
        public static Color ColorRichOrange = new Color(1.0f, 0.4f, 0.1f);
 | 
			
		||||
        public static Color ColorCyan = new Color(0.0f, 1.0f, 1.0f);
 | 
			
		||||
        public static Color ColorPurple = new Color(0.85f, 0.0f, 1.0f);
 | 
			
		||||
        public static Color ColorGhost = new Color(0.5f, 0f, 0f, 0.5f);
 | 
			
		||||
        public static Color ColorRed = new Color(0.9f, 0f, 0f);
 | 
			
		||||
    }
 | 
			
		||||
}
 | 
			
		||||
| 
						 | 
				
			
			@ -1,43 +1,15 @@
 | 
			
		|||
using System.Collections.Generic;
 | 
			
		||||
using System;
 | 
			
		||||
using System.Collections.Generic;
 | 
			
		||||
using System.Linq;
 | 
			
		||||
using System.Text;
 | 
			
		||||
using System.Threading.Tasks;
 | 
			
		||||
using System.Xml.Serialization;
 | 
			
		||||
using UnityEngine;
 | 
			
		||||
 | 
			
		||||
namespace RimWorldAnimationStudio
 | 
			
		||||
{
 | 
			
		||||
    public static class Constants
 | 
			
		||||
    public static class DefaultTags
 | 
			
		||||
    {
 | 
			
		||||
        public static string currentVersion = "0.0.0";
 | 
			
		||||
        public static string projectHome = "https://gitgud.io/AbstractConcept/rimworld-animation-studio";
 | 
			
		||||
        public static string projectWiki = "https://gitgud.io/AbstractConcept/rimworld-animation-studio/-/wikis/home";
 | 
			
		||||
 | 
			
		||||
        public static float actionRepeatSpeed = 0.250f;
 | 
			
		||||
 | 
			
		||||
        public static int defaultAnimationClipLength = 600;
 | 
			
		||||
        public static int minTick = 1;
 | 
			
		||||
        public static int minAnimationClipLength = 5;
 | 
			
		||||
        public static int maxAnimationClipLength = 9999;
 | 
			
		||||
 | 
			
		||||
        public static Color ColorWhite = new Color(1f, 1f, 1f);
 | 
			
		||||
        public static Color ColorGreen = new Color(0f, 1f, 0f);
 | 
			
		||||
        public static Color ColorGoldYellow = new Color(1f, 0.85f, 0f);
 | 
			
		||||
        public static Color ColorDarkGold = new Color(0.75f, 0.64f, 0f);
 | 
			
		||||
        public static Color ColorLightGrey = new Color(0.9f, 0.9f, 0.9f);
 | 
			
		||||
        public static Color ColorMidGrey = new Color(0.75f, 0.75f, 0.75f);
 | 
			
		||||
        public static Color ColorGrey = new Color(0.5f, 0.5f, 0.5f);
 | 
			
		||||
        public static Color ColorDarkGrey = new Color(0.2f, 0.2f, 0.2f);
 | 
			
		||||
        public static Color ColorPink = new Color(1.0f, 0.5f, 0.5f);
 | 
			
		||||
        public static Color ColorOrange = new Color(1.0f, 0.7f, 0.0f);
 | 
			
		||||
        public static Color ColorRichOrange = new Color(1.0f, 0.4f, 0.1f);
 | 
			
		||||
        public static Color ColorCyan = new Color(0.0f, 1.0f, 1.0f);
 | 
			
		||||
        public static Color ColorPurple = new Color(0.85f, 0.0f, 1.0f);
 | 
			
		||||
        public static Color ColorGhost = new Color(0.5f, 0f, 0f, 0.5f);
 | 
			
		||||
        public static Color ColorRed = new Color(0.9f, 0f, 0f);
 | 
			
		||||
    }
 | 
			
		||||
 | 
			
		||||
    public static class Tags
 | 
			
		||||
    {
 | 
			
		||||
        public static List<string> defNames = new List<string>() { "Human", "Wolf_Timber", "Horse"};
 | 
			
		||||
        public static List<string> defNames = new List<string>() { "Human", "Wolf_Timber", "Horse" };
 | 
			
		||||
        public static List<string> bodyParts = new List<string>() { "Penis", "Vagina", "Anus", "Breasts", "Mouth" };
 | 
			
		||||
        public static List<string> bodyDefTypes = new List<string>() { "Human", "Bird", "BeetleLike", "BeetleLikeWithClaw", "MechanicalCentipede", "MechanicalTermite", "Lancer", "Pikeman", "Monkey", "QuadrupedAnimalWithClawsTailAndJowl", "QuadrupedAnimalWithHooves", "QuadrupedAnimalWithHoovesAndHorn", "QuadrupedAnimalWithHoovesAndHump", "QuadrupedAnimalWithHoovesAndTusks", "QuadrupedAnimalWithHoovesTusksAndTrunk", "QuadrupedAnimalWithPaws", "QuadrupedAnimalWithPawsAndTail", "Scyther", "Snake", "TurtleLike" };
 | 
			
		||||
        public static List<string> sexTypes = new List<string>() { "None", "Vaginal", "Anal", "Oral", "Masturbation", "DoublePenetration", "Boobjob", "Handjob", "Footjob", "Fingering", "Scissoring", "MutualMasturbation", "Fisting", "MechImplant", "Rimming", "Fellatio", "Cunnilingus", "Sixtynine" };
 | 
			
		||||
| 
						 | 
				
			
			@ -69,49 +41,4 @@ namespace RimWorldAnimationStudio
 | 
			
		|||
        [XmlArray("soundDefs"), XmlArrayItem("li")] public List<string> soundDefs = new List<string>();
 | 
			
		||||
        [XmlArray("bodyTypes"), XmlArrayItem("li")] public static List<string> bodyTypes = new List<string>();
 | 
			
		||||
    }
 | 
			
		||||
 | 
			
		||||
    public static class AlienRaceDefs
 | 
			
		||||
    {
 | 
			
		||||
        public static List<AlienRaceDef> allDefs = new List<AlienRaceDef>();
 | 
			
		||||
 | 
			
		||||
        public static AlienRaceDef GetNamed(string alienRaceDef)
 | 
			
		||||
        {
 | 
			
		||||
            return allDefs.FirstOrDefault(x => x.defName == alienRaceDef);
 | 
			
		||||
        }
 | 
			
		||||
 | 
			
		||||
        public static void AddDef(AlienRaceDef alienRaceDef)
 | 
			
		||||
        {
 | 
			
		||||
            if (allDefs.Any(x => x.defName == alienRaceDef.defName)) return;
 | 
			
		||||
 | 
			
		||||
            allDefs.Add(alienRaceDef);
 | 
			
		||||
        }
 | 
			
		||||
 | 
			
		||||
        public static void OnLoad()
 | 
			
		||||
        {
 | 
			
		||||
            List<string> allTags = Tags.bodyTypes.Concat(CustomTags.bodyTypes).ToList();
 | 
			
		||||
            allTags.Add("None");
 | 
			
		||||
 | 
			
		||||
            List<CardinalDirection> facings = new List<CardinalDirection>() { CardinalDirection.North, CardinalDirection.East, CardinalDirection.South };
 | 
			
		||||
            string path;
 | 
			
		||||
            
 | 
			
		||||
            foreach (AlienRaceDef alienRaceDef in allDefs)
 | 
			
		||||
            {
 | 
			
		||||
                foreach (CardinalDirection facing in facings)
 | 
			
		||||
                {
 | 
			
		||||
                    foreach (string bodyType in allTags)
 | 
			
		||||
                    {
 | 
			
		||||
                        path = alienRaceDef.GetBodyTypeGraphicPath(facing, bodyType);
 | 
			
		||||
                      
 | 
			
		||||
                        if (path != null && path != "")
 | 
			
		||||
                        { alienRaceDef.SetBodyTypeGraphicPath(path, facing, bodyType); }
 | 
			
		||||
                    }
 | 
			
		||||
 | 
			
		||||
                    path = alienRaceDef.GetHeadGraphicPath(facing);
 | 
			
		||||
 | 
			
		||||
                    if (path != null && path != "")
 | 
			
		||||
                    { alienRaceDef.SetHeadGraphicPath(path, facing); }
 | 
			
		||||
                }
 | 
			
		||||
            }
 | 
			
		||||
        }
 | 
			
		||||
    }
 | 
			
		||||
}
 | 
			
		||||
| 
						 | 
				
			
			@ -1,5 +1,5 @@
 | 
			
		|||
fileFormatVersion: 2
 | 
			
		||||
guid: aeb406e171f70f14f88980439239ca59
 | 
			
		||||
guid: d2a4f1a7ea83f0544a350664fba7fc49
 | 
			
		||||
MonoImporter:
 | 
			
		||||
  externalObjects: {}
 | 
			
		||||
  serializedVersion: 2
 | 
			
		||||
| 
						 | 
				
			
			@ -1,5 +1,5 @@
 | 
			
		|||
fileFormatVersion: 2
 | 
			
		||||
guid: d3f1c8d8d1b51a147b17f5510eebb2cf
 | 
			
		||||
guid: c9a9e093aedeac24687d421f33a98e94
 | 
			
		||||
folderAsset: yes
 | 
			
		||||
DefaultImporter:
 | 
			
		||||
  externalObjects: {}
 | 
			
		||||
| 
						 | 
				
			
			@ -1,11 +1,14 @@
 | 
			
		|||
using System.Collections.Generic;
 | 
			
		||||
using System.Xml;
 | 
			
		||||
using System;
 | 
			
		||||
using System.Collections.Generic;
 | 
			
		||||
using System.Linq;
 | 
			
		||||
using System.Text;
 | 
			
		||||
using System.Threading.Tasks;
 | 
			
		||||
using System.Xml.Serialization;
 | 
			
		||||
 | 
			
		||||
namespace RimWorldAnimationStudio
 | 
			
		||||
{
 | 
			
		||||
    [XmlRoot("Defs", IsNullable = false)]
 | 
			
		||||
    public class Defs
 | 
			
		||||
    public class AnimationDefs
 | 
			
		||||
    {
 | 
			
		||||
        [XmlElement("Rimworld_Animations.AnimationDef")]
 | 
			
		||||
        public List<AnimationDef> animationDefs = new List<AnimationDef>();
 | 
			
		||||
| 
						 | 
				
			
			@ -1,5 +1,5 @@
 | 
			
		|||
fileFormatVersion: 2
 | 
			
		||||
guid: a3449cf2dd7e0444bbc5a7b654cf10c5
 | 
			
		||||
guid: 6e65e28553800cf489ca2b0bc7e37408
 | 
			
		||||
MonoImporter:
 | 
			
		||||
  externalObjects: {}
 | 
			
		||||
  serializedVersion: 2
 | 
			
		||||
							
								
								
									
										53
									
								
								Assets/Scripts/DefParents/PawnRaceDefs.cs
									
										
									
									
									
										Normal file
									
								
							
							
						
						
									
										53
									
								
								Assets/Scripts/DefParents/PawnRaceDefs.cs
									
										
									
									
									
										Normal file
									
								
							| 
						 | 
				
			
			@ -0,0 +1,53 @@
 | 
			
		|||
using System;
 | 
			
		||||
using System.Collections.Generic;
 | 
			
		||||
using System.Linq;
 | 
			
		||||
using System.Text;
 | 
			
		||||
using System.Threading.Tasks;
 | 
			
		||||
 | 
			
		||||
namespace RimWorldAnimationStudio
 | 
			
		||||
{
 | 
			
		||||
    public static class PawnRaceDefs
 | 
			
		||||
    {
 | 
			
		||||
        public static List<PawnRaceDef> allDefs = new List<PawnRaceDef>();
 | 
			
		||||
 | 
			
		||||
        public static PawnRaceDef GetNamed(string pawnRaceDef)
 | 
			
		||||
        {
 | 
			
		||||
            return allDefs.FirstOrDefault(x => x.defName == pawnRaceDef);
 | 
			
		||||
        }
 | 
			
		||||
 | 
			
		||||
        public static void AddDef(PawnRaceDef pawnRaceDef)
 | 
			
		||||
        {
 | 
			
		||||
            if (allDefs.Any(x => x.defName == pawnRaceDef.defName)) return;
 | 
			
		||||
 | 
			
		||||
            allDefs.Add(pawnRaceDef);
 | 
			
		||||
        }
 | 
			
		||||
 | 
			
		||||
        public static void OnLoad()
 | 
			
		||||
        {
 | 
			
		||||
            List<string> allTags = DefaultTags.bodyTypes.Concat(CustomTags.bodyTypes).ToList();
 | 
			
		||||
            allTags.Add("None");
 | 
			
		||||
 | 
			
		||||
            List<CardinalDirection> facings = new List<CardinalDirection>() { CardinalDirection.North, CardinalDirection.East, CardinalDirection.South };
 | 
			
		||||
            string path;
 | 
			
		||||
 | 
			
		||||
            foreach (PawnRaceDef pawnRaceDef in allDefs)
 | 
			
		||||
            {
 | 
			
		||||
                foreach (CardinalDirection facing in facings)
 | 
			
		||||
                {
 | 
			
		||||
                    foreach (string bodyType in allTags)
 | 
			
		||||
                    {
 | 
			
		||||
                        path = pawnRaceDef.GetBodyTypeGraphicPath(facing, bodyType);
 | 
			
		||||
 | 
			
		||||
                        if (string.IsNullOrEmpty(path) == false)
 | 
			
		||||
                        { pawnRaceDef.SetBodyTypeGraphicPath(path, facing, bodyType); }
 | 
			
		||||
                    }
 | 
			
		||||
 | 
			
		||||
                    path = pawnRaceDef.GetHeadGraphicPath(facing);
 | 
			
		||||
 | 
			
		||||
                    if (string.IsNullOrEmpty(path) == false)
 | 
			
		||||
                    { pawnRaceDef.SetHeadGraphicPath(path, facing); }
 | 
			
		||||
                }
 | 
			
		||||
            }
 | 
			
		||||
        }
 | 
			
		||||
    }
 | 
			
		||||
}
 | 
			
		||||
							
								
								
									
										11
									
								
								Assets/Scripts/DefParents/PawnRaceDefs.cs.meta
									
										
									
									
									
										Normal file
									
								
							
							
						
						
									
										11
									
								
								Assets/Scripts/DefParents/PawnRaceDefs.cs.meta
									
										
									
									
									
										Normal file
									
								
							| 
						 | 
				
			
			@ -0,0 +1,11 @@
 | 
			
		|||
fileFormatVersion: 2
 | 
			
		||||
guid: 53e7f97b4bb5a3441884e4795d7e9391
 | 
			
		||||
MonoImporter:
 | 
			
		||||
  externalObjects: {}
 | 
			
		||||
  serializedVersion: 2
 | 
			
		||||
  defaultReferences: []
 | 
			
		||||
  executionOrder: 0
 | 
			
		||||
  icon: {instanceID: 0}
 | 
			
		||||
  userData: 
 | 
			
		||||
  assetBundleName: 
 | 
			
		||||
  assetBundleVariant: 
 | 
			
		||||
| 
						 | 
				
			
			@ -1,135 +0,0 @@
 | 
			
		|||
using System.Collections;
 | 
			
		||||
using System.Collections.Generic;
 | 
			
		||||
using System.Linq;
 | 
			
		||||
using UnityEngine;
 | 
			
		||||
using UnityEngine.UI;
 | 
			
		||||
 | 
			
		||||
namespace RimWorldAnimationStudio
 | 
			
		||||
{
 | 
			
		||||
    public class ActorCard : MonoBehaviour
 | 
			
		||||
    {
 | 
			
		||||
        //public Dropdown genderDropdown;
 | 
			
		||||
        public Dropdown bodyTypeDropdown;
 | 
			
		||||
        public InputField bodyOffsetXField;
 | 
			
		||||
        public InputField bodyOffsetZField;
 | 
			
		||||
        public InputField raceOffsetXField;
 | 
			
		||||
        public InputField raceOffsetZField;
 | 
			
		||||
        public Toggle initiatorToggle;
 | 
			
		||||
        public Dropdown selectActorLayerDropdown;
 | 
			
		||||
 | 
			
		||||
        public void Initialize()
 | 
			
		||||
        {
 | 
			
		||||
            Actor actor = Workspace.animationDef.actors[Workspace.actorID];
 | 
			
		||||
            string bodyType = bodyTypeDropdown.options[bodyTypeDropdown.value].text;
 | 
			
		||||
            bodyType = bodyType == null || bodyType == "" ? "Male" : bodyType;
 | 
			
		||||
 | 
			
		||||
            initiatorToggle.isOn = actor.initiator;
 | 
			
		||||
            bodyOffsetXField.text = actor.bodyTypeOffset.GetOffset(bodyType).x.ToString();
 | 
			
		||||
            bodyOffsetZField.text = actor.bodyTypeOffset.GetOffset(bodyType).z.ToString();
 | 
			
		||||
        }
 | 
			
		||||
 | 
			
		||||
        public void OnBodyTypeChanged()
 | 
			
		||||
        {
 | 
			
		||||
            if (Workspace.animationDef == null) return;
 | 
			
		||||
 | 
			
		||||
            Actor actor = Workspace.animationDef.actors[Workspace.actorID];
 | 
			
		||||
 | 
			
		||||
            string bodyType = bodyTypeDropdown.options[bodyTypeDropdown.value].text;
 | 
			
		||||
            bodyType = bodyType == null || bodyType == "" ? "Male" : bodyType;
 | 
			
		||||
           
 | 
			
		||||
            Workspace.animationDef.actors[Workspace.actorID].bodyType = bodyType;
 | 
			
		||||
 | 
			
		||||
            bodyOffsetXField.text = actor.bodyTypeOffset.GetOffset(bodyType).x.ToString();
 | 
			
		||||
            bodyOffsetZField.text = actor.bodyTypeOffset.GetOffset(bodyType).z.ToString();
 | 
			
		||||
        }
 | 
			
		||||
 | 
			
		||||
        public void OnValueChanged()
 | 
			
		||||
        {
 | 
			
		||||
            if (Workspace.animationDef == null) return;
 | 
			
		||||
 | 
			
		||||
            Actor actor = Workspace.animationDef.actors[Workspace.actorID];
 | 
			
		||||
 | 
			
		||||
            string bodyType = bodyTypeDropdown.options[bodyTypeDropdown.value].text;
 | 
			
		||||
            bodyType = bodyType == null || bodyType == "" ? "Male" : bodyType;
 | 
			
		||||
 | 
			
		||||
            float.TryParse(bodyOffsetXField.text, out float x);
 | 
			
		||||
            float.TryParse(bodyOffsetZField.text, out float z);
 | 
			
		||||
            actor.bodyTypeOffset.SetOffset(bodyType, new Vector2(x, z));
 | 
			
		||||
 | 
			
		||||
            actor.initiator = initiatorToggle.isOn;
 | 
			
		||||
 | 
			
		||||
            //switch (genderDropdown.value)
 | 
			
		||||
            //{
 | 
			
		||||
            //    case 0: actor.requiredGender = new List<string>() { "Female" }; break;
 | 
			
		||||
            //    case 2: actor.requiredGender = new List<string>() { "Male" }; break;
 | 
			
		||||
            //    default: actor.requiredGender = null; break;
 | 
			
		||||
            //}
 | 
			
		||||
 | 
			
		||||
            float.TryParse(raceOffsetXField.text, out x);
 | 
			
		||||
            float.TryParse(raceOffsetZField.text, out z);
 | 
			
		||||
            actor.SetAlienRaceOffset(new Vector2(x, z));
 | 
			
		||||
 | 
			
		||||
            Workspace.Instance.RecordEvent("Actor body offset data");
 | 
			
		||||
        }
 | 
			
		||||
 | 
			
		||||
        public void OnActorLayerChange()
 | 
			
		||||
        {
 | 
			
		||||
            PawnAnimationClip clip = Workspace.Instance.GetCurrentPawnAnimationClip();
 | 
			
		||||
 | 
			
		||||
            if (clip == null) return;
 | 
			
		||||
            clip.layer = selectActorLayerDropdown.captionText.text;
 | 
			
		||||
 | 
			
		||||
            Workspace.Instance.RecordEvent("Actor render layer " + clip.layer);
 | 
			
		||||
        }
 | 
			
		||||
 | 
			
		||||
        public void Update()
 | 
			
		||||
        {
 | 
			
		||||
            if (Workspace.animationDef == null) return;
 | 
			
		||||
 | 
			
		||||
            if (Workspace.actorID >= AnimationController.Instance.actorBodies.GetComponentsInChildren<ActorBody>().Count())
 | 
			
		||||
            { Debug.Log("Waiting for actors to initialize..."); return; }
 | 
			
		||||
 | 
			
		||||
            Actor actor = Workspace.animationDef.actors[Workspace.actorID];
 | 
			
		||||
            ActorBody actorBody = AnimationController.Instance.actorBodies.GetComponentsInChildren<ActorBody>()[Workspace.actorID];
 | 
			
		||||
            PawnAnimationClip clip = Workspace.Instance.GetCurrentPawnAnimationClip();
 | 
			
		||||
 | 
			
		||||
            string bodyType = actor.bodyType;
 | 
			
		||||
            bodyType = bodyType == null || bodyType == "" ? "Male" : bodyType;
 | 
			
		||||
                
 | 
			
		||||
            bodyTypeDropdown.value = bodyTypeDropdown.options.IndexOf(bodyTypeDropdown.options.First(x => x.text == bodyType));
 | 
			
		||||
 | 
			
		||||
            if (bodyOffsetXField.isFocused == false)
 | 
			
		||||
            { bodyOffsetXField.text = actor.bodyTypeOffset.GetOffset(bodyType).x.ToString(); }
 | 
			
		||||
 | 
			
		||||
            if (bodyOffsetZField.isFocused == false)
 | 
			
		||||
            { bodyOffsetZField.text = actor.bodyTypeOffset.GetOffset(bodyType).z.ToString(); }
 | 
			
		||||
 | 
			
		||||
            bodyTypeDropdown.interactable = actor.GetAlienRaceDef().isHumanoid;
 | 
			
		||||
            bodyOffsetXField.interactable = actor.GetAlienRaceDef().isHumanoid;
 | 
			
		||||
            bodyOffsetZField.interactable = actor.GetAlienRaceDef().isHumanoid;
 | 
			
		||||
 | 
			
		||||
            if (raceOffsetXField.isFocused == false)
 | 
			
		||||
            { raceOffsetXField.text = actor.GetAlienRaceOffset().x.ToString(); }
 | 
			
		||||
 | 
			
		||||
            if (raceOffsetZField.isFocused == false)
 | 
			
		||||
            { raceOffsetZField.text = actor.GetAlienRaceOffset().z.ToString(); }
 | 
			
		||||
 | 
			
		||||
            initiatorToggle.isOn = actor.initiator;
 | 
			
		||||
 | 
			
		||||
            //if (actor.requiredGender.NotNullOrEmpty() && actor.requiredGender.Contains("Female"))
 | 
			
		||||
            //{ genderDropdown.SetValueWithoutNotify(0); }
 | 
			
		||||
 | 
			
		||||
            //else if (actor.requiredGender.NotNullOrEmpty() && actor.requiredGender.Contains("Male"))
 | 
			
		||||
            //{ genderDropdown.SetValueWithoutNotify(2); }
 | 
			
		||||
 | 
			
		||||
            //else
 | 
			
		||||
            //{ genderDropdown.SetValueWithoutNotify(1); }
 | 
			
		||||
           
 | 
			
		||||
            for (int i = 0; i < selectActorLayerDropdown.options.Count; i++)
 | 
			
		||||
            {
 | 
			
		||||
                if (selectActorLayerDropdown.options[i].text == clip.layer)
 | 
			
		||||
                { selectActorLayerDropdown.SetValueWithoutNotify(i); }
 | 
			
		||||
            }
 | 
			
		||||
        }
 | 
			
		||||
    }
 | 
			
		||||
}
 | 
			
		||||
							
								
								
									
										8
									
								
								Assets/Scripts/GUI/Actors.meta
									
										
									
									
									
										Normal file
									
								
							
							
						
						
									
										8
									
								
								Assets/Scripts/GUI/Actors.meta
									
										
									
									
									
										Normal file
									
								
							| 
						 | 
				
			
			@ -0,0 +1,8 @@
 | 
			
		|||
fileFormatVersion: 2
 | 
			
		||||
guid: f3c96477ef8cc42468ea6a39764a2e81
 | 
			
		||||
folderAsset: yes
 | 
			
		||||
DefaultImporter:
 | 
			
		||||
  externalObjects: {}
 | 
			
		||||
  userData: 
 | 
			
		||||
  assetBundleName: 
 | 
			
		||||
  assetBundleVariant: 
 | 
			
		||||
| 
						 | 
				
			
			@ -26,20 +26,17 @@ namespace RimWorldAnimationStudio
 | 
			
		|||
 | 
			
		||||
        public void Update()
 | 
			
		||||
        {
 | 
			
		||||
            if (Workspace.actorID == actorID && Workspace.selectedBodyPart == null)
 | 
			
		||||
            if (Workspace.ActorID == actorID && Workspace.selectedBodyPart == null)
 | 
			
		||||
            { bodyRenderer.color = Constants.ColorGreen; }
 | 
			
		||||
 | 
			
		||||
            else
 | 
			
		||||
            { bodyRenderer.color = Constants.ColorWhite; }
 | 
			
		||||
 | 
			
		||||
            foreach (ActorAddon addon in Workspace.animationDef.animationStages[Workspace.stageID].animationClips[actorID].addons)
 | 
			
		||||
            foreach (ActorAddon addon in Workspace.GetCurrentAnimationStage().AnimationClips[actorID].Addons)
 | 
			
		||||
            {
 | 
			
		||||
                ActorBodyPart bodyPart = GetComponentsInChildren<ActorBodyPart>(true).FirstOrDefault(x => x.addonName == addon.addonName);
 | 
			
		||||
                bodyPart?.gameObject?.SetActive(addon.render);         
 | 
			
		||||
                ActorBodyPart bodyPart = GetComponentsInChildren<ActorBodyPart>(true).FirstOrDefault(x => x.addonName == addon.AddonName);
 | 
			
		||||
                bodyPart?.gameObject?.SetActive(addon.Render);         
 | 
			
		||||
            }
 | 
			
		||||
 | 
			
		||||
            //headRenderer.gameObject.SetActive(Workspace.animationDef.actors[actorID].GetAlienRaceDef().isHumanoid);
 | 
			
		||||
            //appendageRenderer.gameObject.SetActive(Workspace.animationDef.actors[actorID].requiredGenitals.Any(x => x == "Penis") || Workspace.animationDef.actors[actorID].isFucking);
 | 
			
		||||
        }
 | 
			
		||||
 | 
			
		||||
        public void OnPointerClick(PointerEventData eventData)
 | 
			
		||||
| 
						 | 
				
			
			@ -54,7 +51,7 @@ namespace RimWorldAnimationStudio
 | 
			
		|||
        {
 | 
			
		||||
            Activate();
 | 
			
		||||
 | 
			
		||||
            PawnKeyframe keyframe = Workspace.Instance.GetCurrentPawnKeyframe(true);
 | 
			
		||||
            PawnKeyframe keyframe = Workspace.GetCurrentPawnKeyframe(true);
 | 
			
		||||
 | 
			
		||||
            if (keyframe == null)
 | 
			
		||||
            { Debug.LogWarning("Cannot alter actor - no keyframe data available"); return; }
 | 
			
		||||
| 
						 | 
				
			
			@ -66,14 +63,14 @@ namespace RimWorldAnimationStudio
 | 
			
		|||
 | 
			
		||||
            if (Workspace.actorManipulationMode == ActorManipulationMode.Pan)
 | 
			
		||||
            {
 | 
			
		||||
                keyframe.bodyOffsetX = mousePosition.x - delta.x - Workspace.animationDef.actors[actorID].GetFinalTransformOffset().x;
 | 
			
		||||
                keyframe.bodyOffsetZ = mousePosition.y - delta.y - Workspace.animationDef.actors[actorID].GetFinalTransformOffset().y;
 | 
			
		||||
                keyframe.BodyOffsetX = mousePosition.x - delta.x - Workspace.animationDef.Actors[actorID].GetFinalTransformOffset().x;
 | 
			
		||||
                keyframe.BodyOffsetZ = mousePosition.y - delta.y - Workspace.animationDef.Actors[actorID].GetFinalTransformOffset().y;
 | 
			
		||||
            }
 | 
			
		||||
 | 
			
		||||
            else if (Workspace.actorManipulationMode == ActorManipulationMode.Rotate)
 | 
			
		||||
            {
 | 
			
		||||
                float angle = -Vector2.SignedAngle(Vector2.down, (Vector2)mousePosition - (Vector2)transform.position);
 | 
			
		||||
                keyframe.bodyAngle = angle;
 | 
			
		||||
                keyframe.BodyAngle = angle;
 | 
			
		||||
            }
 | 
			
		||||
 | 
			
		||||
            else if (Workspace.actorManipulationMode == ActorManipulationMode.Face)
 | 
			
		||||
| 
						 | 
				
			
			@ -82,22 +79,22 @@ namespace RimWorldAnimationStudio
 | 
			
		|||
                int facing = -Mathf.RoundToInt(angle / 90f );
 | 
			
		||||
                facing = facing < 0 ? facing + 4 : facing;
 | 
			
		||||
 | 
			
		||||
                keyframe.bodyFacing = facing;
 | 
			
		||||
                keyframe.BodyFacing = facing;
 | 
			
		||||
            }
 | 
			
		||||
 | 
			
		||||
            PawnAnimationClip clip = Workspace.Instance.GetPawnAnimationClip(actorID);
 | 
			
		||||
            PawnAnimationClip clip = Workspace.GetPawnAnimationClip(actorID);
 | 
			
		||||
            clip.BuildSimpleCurves();
 | 
			
		||||
        }
 | 
			
		||||
 | 
			
		||||
        public void OnEndDrag(PointerEventData eventData)
 | 
			
		||||
        {
 | 
			
		||||
            Workspace.Instance.RecordEvent("Actor position / orientation");
 | 
			
		||||
            Workspace.RecordEvent("Actor position / orientation");
 | 
			
		||||
            delta = Vector3.zero;
 | 
			
		||||
        }
 | 
			
		||||
 | 
			
		||||
        public void Activate()
 | 
			
		||||
        {
 | 
			
		||||
            Workspace.actorID = actorID;
 | 
			
		||||
            Workspace.ActorID = actorID;
 | 
			
		||||
            Workspace.selectedBodyPart = null;
 | 
			
		||||
        }
 | 
			
		||||
    }
 | 
			
		||||
| 
						 | 
				
			
			@ -16,9 +16,14 @@ namespace RimWorldAnimationStudio
 | 
			
		|||
 | 
			
		||||
        private Vector3 delta = new Vector3();
 | 
			
		||||
 | 
			
		||||
        public void Start()
 | 
			
		||||
        {
 | 
			
		||||
            //Workspace.onActorChanged.AddListener(delegate { });
 | 
			
		||||
        }
 | 
			
		||||
 | 
			
		||||
        public void Update()
 | 
			
		||||
        {
 | 
			
		||||
            if ((Workspace.actorID == parent.actorID && Workspace.selectedBodyPart == null) || Workspace.selectedBodyPart == this)
 | 
			
		||||
            if ((Workspace.ActorID == parent.actorID && Workspace.selectedBodyPart == null) || Workspace.selectedBodyPart == this)
 | 
			
		||||
            { bodyPartRenderer.color = Constants.ColorGreen; }
 | 
			
		||||
 | 
			
		||||
            else
 | 
			
		||||
| 
						 | 
				
			
			@ -37,7 +42,7 @@ namespace RimWorldAnimationStudio
 | 
			
		|||
        {
 | 
			
		||||
            Activate();
 | 
			
		||||
 | 
			
		||||
            PawnKeyframe keyframe = Workspace.Instance.GetCurrentPawnKeyframe(true);
 | 
			
		||||
            PawnKeyframe keyframe = Workspace.GetCurrentPawnKeyframe(true);
 | 
			
		||||
 | 
			
		||||
            if (keyframe == null)
 | 
			
		||||
            { Debug.LogWarning("Cannot alter actor - no keyframe data available"); return; }
 | 
			
		||||
| 
						 | 
				
			
			@ -50,19 +55,19 @@ namespace RimWorldAnimationStudio
 | 
			
		|||
            if (addonName != null && addonName != "")
 | 
			
		||||
            {
 | 
			
		||||
                AddonKeyframe addonKeyframe = keyframe.GetAddonKeyframe(addonName);
 | 
			
		||||
                ActorAddon addon = Workspace.Instance.GetCurrentPawnAnimationClip().GetActorAddon(addonName);
 | 
			
		||||
                ActorAddon addon = Workspace.GetCurrentPawnAnimationClip().GetActorAddon(addonName);
 | 
			
		||||
 | 
			
		||||
                if (Workspace.actorManipulationMode == ActorManipulationMode.Pan)
 | 
			
		||||
                {
 | 
			
		||||
                    Vector3 anchor;
 | 
			
		||||
 | 
			
		||||
                    ActorBody anchoringActorBody = AnimationController.Instance.actorBodies.GetComponentsInChildren<ActorBody>()?.FirstOrDefault(x => x.actorID == addon.anchoringActor); 
 | 
			
		||||
                    ActorBody anchoringActorBody = AnimationController.Instance.actorBodies.GetComponentsInChildren<ActorBody>()?.FirstOrDefault(x => x.actorID == addon.AnchoringActor); 
 | 
			
		||||
                    Vector3 bodyPos = new Vector3(anchoringActorBody.transform.position.x, anchoringActorBody.transform.position.y, 0);
 | 
			
		||||
                    AlienRaceDef alienRaceDef = Workspace.animationDef.actors[addon.anchoringActor].GetAlienRaceDef();
 | 
			
		||||
                    Actor anchoringActor = Workspace.animationDef.actors[addon.anchoringActor];
 | 
			
		||||
                    int bodyFacing = (int)Workspace.animationDef.animationStages[Workspace.stageID].animationClips[addon.anchoringActor].BodyFacing.Evaluate((float)AnimationController.Instance.stageTick / Workspace.StageWindowSize);
 | 
			
		||||
                    PawnRaceDef pawnRaceDef = Workspace.animationDef.Actors[addon.AnchoringActor].GetPawnRaceDef();
 | 
			
		||||
                    Actor anchoringActor = Workspace.animationDef.Actors[addon.AnchoringActor];
 | 
			
		||||
                    int bodyFacing = (int)Workspace.GetCurrentAnimationStage().AnimationClips[addon.AnchoringActor].BodyFacing.Evaluate((float)Workspace.StageTick / Workspace.StageWindowSize);
 | 
			
		||||
 | 
			
		||||
                    switch (addon.anchorName)
 | 
			
		||||
                    switch (addon.AnchorName)
 | 
			
		||||
                    {
 | 
			
		||||
                        case "torso": anchor = bodyPos; break;
 | 
			
		||||
                        case "head": anchor = new Vector3(anchoringActorBody.transform.Find("ActorHead").position.x, anchoringActorBody.transform.Find("ActorHead").position.y, 0); break;
 | 
			
		||||
| 
						 | 
				
			
			@ -74,8 +79,8 @@ namespace RimWorldAnimationStudio
 | 
			
		|||
 | 
			
		||||
                    transform.position = new Vector3(mousePosition.x, mousePosition.y, 0f);
 | 
			
		||||
 
 | 
			
		||||
                    addonKeyframe.posX = transform.position.x - anchor.x;
 | 
			
		||||
                    addonKeyframe.posZ = transform.position.y - anchor.y;
 | 
			
		||||
                    addonKeyframe.PosX = transform.position.x - anchor.x;
 | 
			
		||||
                    addonKeyframe.PosZ = transform.position.y - anchor.y;
 | 
			
		||||
 | 
			
		||||
                    ActorKeyframeCard.Instance.transform.GetComponentsInChildren<ActorAddonCard>()?.FirstOrDefault(x => x.addonName == addonName)?.OnKeyframeValueChanged();
 | 
			
		||||
                }
 | 
			
		||||
| 
						 | 
				
			
			@ -83,7 +88,7 @@ namespace RimWorldAnimationStudio
 | 
			
		|||
                else if (Workspace.actorManipulationMode == ActorManipulationMode.Rotate)
 | 
			
		||||
                {
 | 
			
		||||
                    float angle = -Vector2.SignedAngle(Vector2.down, (Vector2)mousePosition - (Vector2)transform.position);
 | 
			
		||||
                    addonKeyframe.rotation = angle;
 | 
			
		||||
                    addonKeyframe.Rotation = angle;
 | 
			
		||||
                }
 | 
			
		||||
 | 
			
		||||
                else if (Workspace.actorManipulationMode == ActorManipulationMode.Face)
 | 
			
		||||
| 
						 | 
				
			
			@ -106,13 +111,13 @@ namespace RimWorldAnimationStudio
 | 
			
		|||
                    Vector3 localPosB = transform.localPosition;
 | 
			
		||||
                    transform.localPosition = localPosA;
 | 
			
		||||
 | 
			
		||||
                    keyframe.headBob += localPosB.y - localPosA.y;
 | 
			
		||||
                    keyframe.HeadBob += localPosB.y - localPosA.y;
 | 
			
		||||
                }
 | 
			
		||||
 | 
			
		||||
                else if (Workspace.actorManipulationMode == ActorManipulationMode.Rotate)
 | 
			
		||||
                {
 | 
			
		||||
                    float angle = -Vector2.SignedAngle(Vector2.down, (Vector2)mousePosition - (Vector2)transform.position);
 | 
			
		||||
                    keyframe.headAngle = angle;
 | 
			
		||||
                    keyframe.HeadAngle = angle;
 | 
			
		||||
                }
 | 
			
		||||
 | 
			
		||||
                else if (Workspace.actorManipulationMode == ActorManipulationMode.Face)
 | 
			
		||||
| 
						 | 
				
			
			@ -121,7 +126,7 @@ namespace RimWorldAnimationStudio
 | 
			
		|||
                    int facing = -Mathf.RoundToInt(angle / 90f);
 | 
			
		||||
                    facing = facing < 0 ? facing + 4 : facing;
 | 
			
		||||
 | 
			
		||||
                    keyframe.headFacing = facing;
 | 
			
		||||
                    keyframe.HeadFacing = facing;
 | 
			
		||||
                }
 | 
			
		||||
            }
 | 
			
		||||
 | 
			
		||||
| 
						 | 
				
			
			@ -130,25 +135,25 @@ namespace RimWorldAnimationStudio
 | 
			
		|||
                if (Workspace.actorManipulationMode == ActorManipulationMode.Rotate)
 | 
			
		||||
                {
 | 
			
		||||
                    float angle = -Vector2.SignedAngle(Vector2.up, (Vector2)mousePosition - (Vector2)transform.position);
 | 
			
		||||
                    keyframe.genitalAngle = angle;
 | 
			
		||||
                    keyframe.GenitalAngle = angle;
 | 
			
		||||
 | 
			
		||||
                    Workspace.animationDef.actors[Workspace.actorID].controlGenitalAngle = Workspace.animationDef.animationStages.Any(x => x.animationClips[Workspace.actorID].keyframes.Any(y => y.genitalAngle != 0));
 | 
			
		||||
                    Workspace.GetCurrentActor().ControlGenitalAngle = Workspace.animationDef.AnimationStages.Any(x => x.AnimationClips[Workspace.ActorID].Keyframes.Any(y => y.GenitalAngle != 0));
 | 
			
		||||
                }
 | 
			
		||||
            }
 | 
			
		||||
 | 
			
		||||
            PawnAnimationClip clip = Workspace.Instance.GetPawnAnimationClip(parent.actorID);
 | 
			
		||||
            PawnAnimationClip clip = Workspace.GetPawnAnimationClip(parent.actorID);
 | 
			
		||||
            clip.BuildSimpleCurves();
 | 
			
		||||
        }
 | 
			
		||||
 | 
			
		||||
        public void OnEndDrag(PointerEventData eventData)
 | 
			
		||||
        {
 | 
			
		||||
            Workspace.Instance.RecordEvent("Actor position / orientation");
 | 
			
		||||
            Workspace.RecordEvent("Actor position / orientation");
 | 
			
		||||
            delta = Vector3.zero;
 | 
			
		||||
        }
 | 
			
		||||
 | 
			
		||||
        public void Activate()
 | 
			
		||||
        {
 | 
			
		||||
            Workspace.actorID = parent.actorID;
 | 
			
		||||
            Workspace.ActorID = parent.actorID;
 | 
			
		||||
            Workspace.selectedBodyPart = this;
 | 
			
		||||
        }
 | 
			
		||||
    }
 | 
			
		||||
| 
						 | 
				
			
			@ -16,10 +16,10 @@ namespace RimWorldAnimationStudio
 | 
			
		|||
 | 
			
		||||
        void Update()
 | 
			
		||||
        {
 | 
			
		||||
            PawnKeyframe keyframe = Workspace.Instance.GetCurrentOrPreviousKeyframe(Workspace.actorID);
 | 
			
		||||
            PawnKeyframe keyframe = Workspace.GetCurrentOrPreviousKeyframe(Workspace.ActorID);
 | 
			
		||||
    
 | 
			
		||||
            if (keyframe != null)
 | 
			
		||||
            { text.text = keyframe.soundEffect == null || keyframe.soundEffect == "" ? "None" : keyframe.soundEffect; }
 | 
			
		||||
            { text.text = keyframe.SoundEffect == null || keyframe.SoundEffect == "" ? "None" : keyframe.SoundEffect; }
 | 
			
		||||
 | 
			
		||||
            else 
 | 
			
		||||
            { text.text = "None"; }
 | 
			
		||||
| 
						 | 
				
			
			
 | 
			
		|||
| 
						 | 
				
			
			@ -1,39 +0,0 @@
 | 
			
		|||
using System;
 | 
			
		||||
using System.Collections.Generic;
 | 
			
		||||
using System.Linq;
 | 
			
		||||
using System.Text;
 | 
			
		||||
using System.Threading.Tasks;
 | 
			
		||||
using UnityEngine;
 | 
			
		||||
using UnityEngine.UI;
 | 
			
		||||
 | 
			
		||||
namespace RimWorldAnimationStudio
 | 
			
		||||
{
 | 
			
		||||
    public class AnimationDefCard : MonoBehaviour
 | 
			
		||||
    {
 | 
			
		||||
        public InputField defNameField;
 | 
			
		||||
        public InputField labelField;
 | 
			
		||||
        //public Toggle playSoundsToggle;
 | 
			
		||||
 | 
			
		||||
        public void Update()
 | 
			
		||||
        {
 | 
			
		||||
            if (Workspace.animationDef == null) return;
 | 
			
		||||
 | 
			
		||||
            if (defNameField.isFocused == false)
 | 
			
		||||
            { defNameField.text = Workspace.animationDef.defName; }
 | 
			
		||||
 | 
			
		||||
            if (labelField.isFocused == false)
 | 
			
		||||
            { labelField.text = Workspace.animationDef.label; }
 | 
			
		||||
 | 
			
		||||
            //playSoundsToggle.isOn = Workspace.animationDef.sounds;
 | 
			
		||||
        }
 | 
			
		||||
 | 
			
		||||
        public void UpdateAnimationDef()
 | 
			
		||||
        {
 | 
			
		||||
            Workspace.animationDef.defName = defNameField.text;
 | 
			
		||||
            Workspace.animationDef.label = labelField.text;
 | 
			
		||||
            //Workspace.animationDef.sounds = playSoundsToggle.isOn;
 | 
			
		||||
 | 
			
		||||
            Workspace.Instance.MakeHistoricRecord("AnimationDef update");
 | 
			
		||||
        }
 | 
			
		||||
    }
 | 
			
		||||
}
 | 
			
		||||
| 
						 | 
				
			
			@ -21,13 +21,13 @@ namespace RimWorldAnimationStudio
 | 
			
		|||
            anchorTransform = transform.parent;
 | 
			
		||||
            this.actorID = actorID;
 | 
			
		||||
 | 
			
		||||
            PawnAnimationClip clip = Workspace.Instance.GetPawnAnimationClip(actorID);
 | 
			
		||||
            PawnAnimationClip clip = Workspace.GetPawnAnimationClip(actorID);
 | 
			
		||||
            clip.BuildSimpleCurves();
 | 
			
		||||
 | 
			
		||||
            foreach (KeyframeSlider slider in GetComponentsInChildren<KeyframeSlider>())
 | 
			
		||||
            { RemovePawnKeyFrame(slider.keyframeID);}
 | 
			
		||||
 | 
			
		||||
            foreach (PawnKeyframe keyframe in clip.keyframes)
 | 
			
		||||
            foreach (PawnKeyframe keyframe in clip.Keyframes)
 | 
			
		||||
            { AddPawnKeyFrame(keyframe.keyframeID); }
 | 
			
		||||
 | 
			
		||||
            /*int keyframeCount = clip.keyframes.Count;
 | 
			
		||||
| 
						 | 
				
			
			@ -66,7 +66,7 @@ namespace RimWorldAnimationStudio
 | 
			
		|||
 | 
			
		||||
        public void Update()
 | 
			
		||||
        {
 | 
			
		||||
            if (Workspace.actorID == actorID)
 | 
			
		||||
            if (Workspace.ActorID == actorID)
 | 
			
		||||
            { GetComponent<Image>().color = Constants.ColorGoldYellow; }
 | 
			
		||||
 | 
			
		||||
            else
 | 
			
		||||
| 
						 | 
				
			
			@ -91,27 +91,27 @@ namespace RimWorldAnimationStudio
 | 
			
		|||
 | 
			
		||||
        public bool MoveAnimationTimeline(int startIndex, int delta)
 | 
			
		||||
        {
 | 
			
		||||
            if (startIndex + delta < 0 || startIndex + delta >= Workspace.animationDef.animationStages[Workspace.stageID].animationClips.Count)
 | 
			
		||||
            if (startIndex + delta < 0 || startIndex + delta >= Workspace.GetCurrentAnimationStage().AnimationClips.Count)
 | 
			
		||||
            { Debug.Log("Cannot move animation timeline - movement would exceed bounds"); return false; }
 | 
			
		||||
 | 
			
		||||
            Actor actor = Workspace.animationDef.actors[startIndex];
 | 
			
		||||
            Workspace.animationDef.actors[startIndex] = Workspace.animationDef.actors[startIndex + delta];
 | 
			
		||||
            Workspace.animationDef.actors[startIndex + delta] = actor;
 | 
			
		||||
            Actor actor = Workspace.animationDef.Actors[startIndex];
 | 
			
		||||
            Workspace.animationDef.Actors[startIndex] = Workspace.animationDef.Actors[startIndex + delta];
 | 
			
		||||
            Workspace.animationDef.Actors[startIndex + delta] = actor;
 | 
			
		||||
 | 
			
		||||
            PawnAnimationClip clip = Workspace.Instance.GetPawnAnimationClip(startIndex);
 | 
			
		||||
            Workspace.animationDef.animationStages[Workspace.stageID].animationClips[startIndex] = Workspace.animationDef.animationStages[Workspace.stageID].animationClips[startIndex + delta];
 | 
			
		||||
            Workspace.animationDef.animationStages[Workspace.stageID].animationClips[startIndex + delta] = clip;
 | 
			
		||||
            PawnAnimationClip clip = Workspace.GetPawnAnimationClip(startIndex);
 | 
			
		||||
            Workspace.GetCurrentAnimationStage().AnimationClips[startIndex] = Workspace.GetCurrentAnimationStage().AnimationClips[startIndex + delta];
 | 
			
		||||
            Workspace.GetCurrentAnimationStage().AnimationClips[startIndex + delta] = clip;
 | 
			
		||||
 | 
			
		||||
            Workspace.actorID = startIndex + delta;
 | 
			
		||||
            Workspace.ActorID = startIndex + delta;
 | 
			
		||||
 | 
			
		||||
            Workspace.Instance.RecordEvent("Timeline move");
 | 
			
		||||
            Workspace.RecordEvent("Timeline move");
 | 
			
		||||
 | 
			
		||||
            return true;
 | 
			
		||||
        }
 | 
			
		||||
 | 
			
		||||
        public void OnPointerClick(PointerEventData eventData)
 | 
			
		||||
        {
 | 
			
		||||
            Workspace.actorID = actorID;
 | 
			
		||||
            Workspace.ActorID = actorID;
 | 
			
		||||
            Workspace.keyframeID.Clear();
 | 
			
		||||
        }
 | 
			
		||||
    }
 | 
			
		||||
| 
						 | 
				
			
			
 | 
			
		|||
							
								
								
									
										8
									
								
								Assets/Scripts/GUI/Cards.meta
									
										
									
									
									
										Normal file
									
								
							
							
						
						
									
										8
									
								
								Assets/Scripts/GUI/Cards.meta
									
										
									
									
									
										Normal file
									
								
							| 
						 | 
				
			
			@ -0,0 +1,8 @@
 | 
			
		|||
fileFormatVersion: 2
 | 
			
		||||
guid: c026d569e32726d4eb8821db713d0aac
 | 
			
		||||
folderAsset: yes
 | 
			
		||||
DefaultImporter:
 | 
			
		||||
  externalObjects: {}
 | 
			
		||||
  userData: 
 | 
			
		||||
  assetBundleName: 
 | 
			
		||||
  assetBundleVariant: 
 | 
			
		||||
| 
						 | 
				
			
			@ -27,25 +27,25 @@ namespace RimWorldAnimationStudio
 | 
			
		|||
        public void OnFieldValueChanged()
 | 
			
		||||
        {
 | 
			
		||||
            if (Workspace.animationDef == null) return;
 | 
			
		||||
            PawnAnimationClip clip = Workspace.Instance.GetCurrentPawnAnimationClip();
 | 
			
		||||
            PawnKeyframe keyframe = Workspace.Instance.GetCurrentPawnKeyframe(true);
 | 
			
		||||
            PawnAnimationClip clip = Workspace.GetCurrentPawnAnimationClip();
 | 
			
		||||
            PawnKeyframe keyframe = Workspace.GetCurrentPawnKeyframe(true);
 | 
			
		||||
 | 
			
		||||
            keyframe.GetAddonKeyframe(addonName).posX = float.Parse(xOffsetField.text);
 | 
			
		||||
            keyframe.GetAddonKeyframe(addonName).posZ = float.Parse(zOffsetField.text);
 | 
			
		||||
            keyframe.GetAddonKeyframe(addonName).rotation = float.Parse(rotationField.text);
 | 
			
		||||
            keyframe.GetAddonKeyframe(addonName).PosX = float.Parse(xOffsetField.text);
 | 
			
		||||
            keyframe.GetAddonKeyframe(addonName).PosZ = float.Parse(zOffsetField.text);
 | 
			
		||||
            keyframe.GetAddonKeyframe(addonName).Rotation = float.Parse(rotationField.text);
 | 
			
		||||
 | 
			
		||||
            clip.BuildSimpleCurves();
 | 
			
		||||
            Workspace.Instance.RecordEvent("Actor addon position / orientation");
 | 
			
		||||
            Workspace.RecordEvent("Actor addon position / orientation");
 | 
			
		||||
        }
 | 
			
		||||
 | 
			
		||||
        public void OnKeyframeValueChanged()
 | 
			
		||||
        {
 | 
			
		||||
            if (Workspace.animationDef == null) return;
 | 
			
		||||
            PawnAnimationClip clip = Workspace.Instance.GetCurrentPawnAnimationClip();
 | 
			
		||||
            PawnAnimationClip clip = Workspace.GetCurrentPawnAnimationClip();
 | 
			
		||||
 | 
			
		||||
            xOffsetField.SetTextWithoutNotify(clip.GetActorAddon(addonName).PosX.Evaluate((float)AnimationController.Instance.stageTick / Workspace.StageWindowSize).ToString());
 | 
			
		||||
            zOffsetField.SetTextWithoutNotify(clip.GetActorAddon(addonName).PosZ.Evaluate((float)AnimationController.Instance.stageTick / Workspace.StageWindowSize).ToString());
 | 
			
		||||
            rotationField.SetTextWithoutNotify(clip.GetActorAddon(addonName).Rotation.Evaluate((float)AnimationController.Instance.stageTick / Workspace.StageWindowSize).ToString());
 | 
			
		||||
            xOffsetField.SetTextWithoutNotify(clip.GetActorAddon(addonName).PosX.Evaluate((float)Workspace.StageTick / Workspace.StageWindowSize).ToString());
 | 
			
		||||
            zOffsetField.SetTextWithoutNotify(clip.GetActorAddon(addonName).PosZ.Evaluate((float)Workspace.StageTick / Workspace.StageWindowSize).ToString());
 | 
			
		||||
            rotationField.SetTextWithoutNotify(clip.GetActorAddon(addonName).Rotation.Evaluate((float)Workspace.StageTick / Workspace.StageWindowSize).ToString());
 | 
			
		||||
        }
 | 
			
		||||
    }
 | 
			
		||||
}
 | 
			
		||||
							
								
								
									
										124
									
								
								Assets/Scripts/GUI/Cards/ActorCard.cs
									
										
									
									
									
										Normal file
									
								
							
							
						
						
									
										124
									
								
								Assets/Scripts/GUI/Cards/ActorCard.cs
									
										
									
									
									
										Normal file
									
								
							| 
						 | 
				
			
			@ -0,0 +1,124 @@
 | 
			
		|||
using System.Collections;
 | 
			
		||||
using System.Collections.Generic;
 | 
			
		||||
using System.Linq;
 | 
			
		||||
using UnityEngine;
 | 
			
		||||
using UnityEngine.UI;
 | 
			
		||||
 | 
			
		||||
namespace RimWorldAnimationStudio
 | 
			
		||||
{
 | 
			
		||||
    public class ActorCard : MonoBehaviour
 | 
			
		||||
    {
 | 
			
		||||
        public Toggle initiatorToggle;
 | 
			
		||||
        public Dropdown selectActorLayerDropdown;
 | 
			
		||||
        public Dropdown bodyTypeDropdown;
 | 
			
		||||
        public InputField bodyOffsetXField;
 | 
			
		||||
        public InputField bodyOffsetZField;
 | 
			
		||||
        public Dropdown raceDropdown;
 | 
			
		||||
        public InputField raceOffsetXField;
 | 
			
		||||
        public InputField raceOffsetZField;
 | 
			
		||||
 | 
			
		||||
        private Actor actor { get { return Workspace.GetCurrentActor(); } }
 | 
			
		||||
        private PawnAnimationClip clip { get { return Workspace.GetCurrentPawnAnimationClip(); } }
 | 
			
		||||
 | 
			
		||||
        public void Awake()
 | 
			
		||||
        {
 | 
			
		||||
            UpdateRaceDropdown();
 | 
			
		||||
        }
 | 
			
		||||
 | 
			
		||||
        public void Start()
 | 
			
		||||
        {
 | 
			
		||||
            // General events
 | 
			
		||||
            EventsManager.onAnimationDefChanged.AddListener(delegate { UpdateGUI(); });
 | 
			
		||||
            EventsManager.onActorIDChanged.AddListener(delegate { UpdateGUI(); });
 | 
			
		||||
            EventsManager.onDefNamesChanged.AddListener(delegate { UpdateRaceDropdown(); });
 | 
			
		||||
 | 
			
		||||
            // Local events
 | 
			
		||||
            initiatorToggle.onValueChanged.AddListener(delegate {
 | 
			
		||||
                actor.initiator = initiatorToggle.isOn;
 | 
			
		||||
                Workspace.RecordEvent("Change in actor sex initiator status ");
 | 
			
		||||
            });
 | 
			
		||||
 | 
			
		||||
            selectActorLayerDropdown.onValueChanged.AddListener(delegate { 
 | 
			
		||||
                clip.Layer = selectActorLayerDropdown.options[selectActorLayerDropdown.value].text;
 | 
			
		||||
                Workspace.RecordEvent("Change in actor render layer");
 | 
			
		||||
            });
 | 
			
		||||
 | 
			
		||||
            bodyTypeDropdown.onValueChanged.AddListener(delegate { OnDropdownChanged(); });
 | 
			
		||||
            bodyOffsetXField.onEndEdit.AddListener(delegate { OnInputFieldChanged(); });
 | 
			
		||||
            bodyOffsetZField.onEndEdit.AddListener(delegate { OnInputFieldChanged(); });
 | 
			
		||||
 | 
			
		||||
            raceDropdown.onValueChanged.AddListener(delegate { OnDropdownChanged(); });
 | 
			
		||||
            raceOffsetXField.onEndEdit.AddListener(delegate { OnInputFieldChanged(); });
 | 
			
		||||
            raceOffsetZField.onEndEdit.AddListener(delegate { OnInputFieldChanged(); });
 | 
			
		||||
 | 
			
		||||
            // Initialize         
 | 
			
		||||
            UpdateGUI();
 | 
			
		||||
        }
 | 
			
		||||
 | 
			
		||||
        public void OnInputFieldChanged()
 | 
			
		||||
        {
 | 
			
		||||
            string bodyType = bodyTypeDropdown.options[bodyTypeDropdown.value].text;
 | 
			
		||||
            bodyType = string.IsNullOrEmpty(bodyType) ? "Male" : bodyType;
 | 
			
		||||
 | 
			
		||||
            float.TryParse(bodyOffsetXField.text, out float x);
 | 
			
		||||
            float.TryParse(bodyOffsetZField.text, out float z);
 | 
			
		||||
            actor.BodyTypeOffset.SetOffset(bodyType, new Vector2(x, z));
 | 
			
		||||
 | 
			
		||||
            float.TryParse(raceOffsetXField.text, out x);
 | 
			
		||||
            float.TryParse(raceOffsetZField.text, out z);
 | 
			
		||||
            actor.SetPawnRaceOffset(new Vector2(x, z));
 | 
			
		||||
 | 
			
		||||
            Workspace.RecordEvent("Actor offset");
 | 
			
		||||
        }
 | 
			
		||||
 | 
			
		||||
        public void OnDropdownChanged()
 | 
			
		||||
        {
 | 
			
		||||
            actor.bodyType = bodyTypeDropdown.options[bodyTypeDropdown.value].text;
 | 
			
		||||
           
 | 
			
		||||
            if (raceDropdown.options[raceDropdown.value].text != actor.GetPawnRaceDef().defName)
 | 
			
		||||
            { Workspace.selectedBodyPart = null; }
 | 
			
		||||
 | 
			
		||||
            actor.SetPawnRaceDef(raceDropdown.options[raceDropdown.value].text);
 | 
			
		||||
 | 
			
		||||
            Workspace.RecordEvent("Actor body type/race change");
 | 
			
		||||
 | 
			
		||||
            UpdateGUI();
 | 
			
		||||
        }
 | 
			
		||||
 | 
			
		||||
        public void UpdateRaceDropdown()
 | 
			
		||||
        {
 | 
			
		||||
            raceDropdown.ClearOptions();
 | 
			
		||||
            int index = raceDropdown.value;
 | 
			
		||||
 | 
			
		||||
            IEnumerable<string> optionsList = DefaultTags.defNames.Concat(CustomTags.defNames);
 | 
			
		||||
            foreach (string defName in optionsList)
 | 
			
		||||
            { raceDropdown.options.Add(new Dropdown.OptionData(defName)); }
 | 
			
		||||
 | 
			
		||||
            raceDropdown.value = Mathf.Clamp(index, 0, raceDropdown.options.Count - 1);
 | 
			
		||||
        }
 | 
			
		||||
 | 
			
		||||
        public void UpdateGUI()
 | 
			
		||||
        {
 | 
			
		||||
            initiatorToggle.isOn = actor.Initiator;
 | 
			
		||||
 | 
			
		||||
            string layer = clip.Layer;
 | 
			
		||||
            selectActorLayerDropdown.SetValueWithoutNotify(selectActorLayerDropdown.options.FindIndex(x => x.text == layer));
 | 
			
		||||
 | 
			
		||||
            string bodyType = actor.bodyType;
 | 
			
		||||
            bodyTypeDropdown.SetValueWithoutNotify(bodyTypeDropdown.options.FindIndex(x => x.text == bodyType));
 | 
			
		||||
 | 
			
		||||
            bodyOffsetXField.SetTextWithoutNotify(string.Format("{0:0.000}", actor.BodyTypeOffset.GetOffset(bodyType).x.ToString()));
 | 
			
		||||
            bodyOffsetZField.SetTextWithoutNotify(string.Format("{0:0.000}", actor.BodyTypeOffset.GetOffset(bodyType).z.ToString()));
 | 
			
		||||
 | 
			
		||||
            bodyTypeDropdown.interactable = actor.GetPawnRaceDef().isHumanoid;
 | 
			
		||||
            bodyOffsetXField.interactable = actor.GetPawnRaceDef().isHumanoid;
 | 
			
		||||
            bodyOffsetZField.interactable = actor.GetPawnRaceDef().isHumanoid;
 | 
			
		||||
 | 
			
		||||
            string race = actor.GetPawnRaceDef().defName;
 | 
			
		||||
            raceDropdown.SetValueWithoutNotify(raceDropdown.options.FindIndex(x => x.text == race));
 | 
			
		||||
 | 
			
		||||
            raceOffsetXField.SetTextWithoutNotify(string.Format("{0:0.000}", actor.GetPawnRaceOffset().x.ToString()));
 | 
			
		||||
            raceOffsetZField.SetTextWithoutNotify(string.Format("{0:0.000}", actor.GetPawnRaceOffset().z.ToString()));
 | 
			
		||||
        }
 | 
			
		||||
    }
 | 
			
		||||
}
 | 
			
		||||
| 
						 | 
				
			
			@ -30,18 +30,18 @@ namespace RimWorldAnimationStudio
 | 
			
		|||
 | 
			
		||||
        public void OnValueChanged()
 | 
			
		||||
        {
 | 
			
		||||
            PawnKeyframe keyframe = Workspace.Instance.GetCurrentPawnKeyframe(true);
 | 
			
		||||
            PawnKeyframe keyframe = Workspace.GetCurrentPawnKeyframe(true);
 | 
			
		||||
 | 
			
		||||
            keyframe.bodyOffsetX = float.Parse(positionXField.text);
 | 
			
		||||
            keyframe.bodyOffsetZ = float.Parse(positionZField.text);
 | 
			
		||||
            keyframe.bodyAngle = float.Parse(rotationField.text);
 | 
			
		||||
            keyframe.headBob = float.Parse(headBobField.text);
 | 
			
		||||
            keyframe.headAngle = float.Parse(headRotationField.text);
 | 
			
		||||
            keyframe.genitalAngle = float.Parse(appendageRotationField.text);
 | 
			
		||||
            keyframe.BodyOffsetX = float.Parse(positionXField.text);
 | 
			
		||||
            keyframe.BodyOffsetZ = float.Parse(positionZField.text);
 | 
			
		||||
            keyframe.BodyAngle = float.Parse(rotationField.text);
 | 
			
		||||
            keyframe.HeadBob = float.Parse(headBobField.text);
 | 
			
		||||
            keyframe.HeadAngle = float.Parse(headRotationField.text);
 | 
			
		||||
            keyframe.GenitalAngle = float.Parse(appendageRotationField.text);
 | 
			
		||||
 | 
			
		||||
            Workspace.animationDef.actors[Workspace.actorID].controlGenitalAngle = keyframe.genitalAngle != 0;
 | 
			
		||||
            Workspace.Instance.GetPawnAnimationClip(Workspace.actorID).BuildSimpleCurves();
 | 
			
		||||
            Workspace.Instance.RecordEvent("Actor position / orientation");
 | 
			
		||||
            Workspace.animationDef.Actors[Workspace.ActorID].ControlGenitalAngle = keyframe.GenitalAngle != 0;
 | 
			
		||||
            Workspace.GetPawnAnimationClip(Workspace.ActorID).BuildSimpleCurves();
 | 
			
		||||
            Workspace.RecordEvent("Actor position / orientation");
 | 
			
		||||
        }
 | 
			
		||||
 | 
			
		||||
        public void AdjustActor(Vector2 deltaOffset)
 | 
			
		||||
| 
						 | 
				
			
			@ -59,50 +59,50 @@ namespace RimWorldAnimationStudio
 | 
			
		|||
 | 
			
		||||
        public void MoveActor(Vector2 deltaOffset)
 | 
			
		||||
        {
 | 
			
		||||
            PawnKeyframe keyframe = Workspace.Instance.GetCurrentPawnKeyframe(true);
 | 
			
		||||
            PawnKeyframe keyframe = Workspace.GetCurrentPawnKeyframe(true);
 | 
			
		||||
 
 | 
			
		||||
            if (Workspace.selectedBodyPart == null)
 | 
			
		||||
            {
 | 
			
		||||
                keyframe.bodyOffsetX += deltaOffset.x;
 | 
			
		||||
                keyframe.bodyOffsetZ += deltaOffset.y;
 | 
			
		||||
                keyframe.BodyOffsetX += deltaOffset.x;
 | 
			
		||||
                keyframe.BodyOffsetZ += deltaOffset.y;
 | 
			
		||||
            }
 | 
			
		||||
 | 
			
		||||
            else if (Workspace.selectedBodyPart.isHead)
 | 
			
		||||
            { keyframe.headBob += deltaOffset.y; }
 | 
			
		||||
            { keyframe.HeadBob += deltaOffset.y; }
 | 
			
		||||
 | 
			
		||||
            Workspace.Instance.GetCurrentPawnAnimationClip().BuildSimpleCurves();
 | 
			
		||||
            Workspace.Instance.RecordEvent("Actor position / orientation");
 | 
			
		||||
            Workspace.GetCurrentPawnAnimationClip().BuildSimpleCurves();
 | 
			
		||||
            Workspace.RecordEvent("Actor position / orientation");
 | 
			
		||||
        }
 | 
			
		||||
 | 
			
		||||
        public void RotateActor(float deltaAngle)
 | 
			
		||||
        {
 | 
			
		||||
            PawnKeyframe keyframe = Workspace.Instance.GetCurrentPawnKeyframe(true);
 | 
			
		||||
            PawnKeyframe keyframe = Workspace.GetCurrentPawnKeyframe(true);
 | 
			
		||||
 | 
			
		||||
            if (Workspace.selectedBodyPart == null)
 | 
			
		||||
            { keyframe.bodyAngle += deltaAngle; }
 | 
			
		||||
            { keyframe.BodyAngle += deltaAngle; }
 | 
			
		||||
 | 
			
		||||
            else if (Workspace.selectedBodyPart.isHead)
 | 
			
		||||
            { keyframe.headAngle += deltaAngle; }
 | 
			
		||||
            { keyframe.HeadAngle += deltaAngle; }
 | 
			
		||||
 | 
			
		||||
            else
 | 
			
		||||
            { keyframe.genitalAngle -= deltaAngle; }
 | 
			
		||||
            { keyframe.GenitalAngle -= deltaAngle; }
 | 
			
		||||
 | 
			
		||||
            Workspace.Instance.GetCurrentPawnAnimationClip().BuildSimpleCurves();
 | 
			
		||||
            Workspace.Instance.RecordEvent("Actor position / orientation");
 | 
			
		||||
            Workspace.GetCurrentPawnAnimationClip().BuildSimpleCurves();
 | 
			
		||||
            Workspace.RecordEvent("Actor position / orientation");
 | 
			
		||||
        }
 | 
			
		||||
 | 
			
		||||
        public void FaceActor(int facing)
 | 
			
		||||
        {
 | 
			
		||||
            PawnKeyframe keyframe = Workspace.Instance.GetCurrentPawnKeyframe(true);
 | 
			
		||||
            PawnKeyframe keyframe = Workspace.GetCurrentPawnKeyframe(true);
 | 
			
		||||
           
 | 
			
		||||
            if (Workspace.selectedBodyPart == null)
 | 
			
		||||
            { keyframe.bodyFacing = facing; }
 | 
			
		||||
            { keyframe.BodyFacing = facing; }
 | 
			
		||||
 | 
			
		||||
            else if (Workspace.selectedBodyPart.isHead)
 | 
			
		||||
            { keyframe.headFacing = facing; }
 | 
			
		||||
            { keyframe.HeadFacing = facing; }
 | 
			
		||||
 | 
			
		||||
            Workspace.Instance.GetCurrentPawnAnimationClip().BuildSimpleCurves();
 | 
			
		||||
            Workspace.Instance.RecordEvent("Actor position / orientation");
 | 
			
		||||
            Workspace.GetCurrentPawnAnimationClip().BuildSimpleCurves();
 | 
			
		||||
            Workspace.RecordEvent("Actor position / orientation");
 | 
			
		||||
        }
 | 
			
		||||
    }
 | 
			
		||||
}
 | 
			
		||||
							
								
								
									
										39
									
								
								Assets/Scripts/GUI/Cards/AnimationDefCard.cs
									
										
									
									
									
										Normal file
									
								
							
							
						
						
									
										39
									
								
								Assets/Scripts/GUI/Cards/AnimationDefCard.cs
									
										
									
									
									
										Normal file
									
								
							| 
						 | 
				
			
			@ -0,0 +1,39 @@
 | 
			
		|||
using System;
 | 
			
		||||
using System.Collections.Generic;
 | 
			
		||||
using System.Linq;
 | 
			
		||||
using System.Text;
 | 
			
		||||
using System.Threading.Tasks;
 | 
			
		||||
using UnityEngine;
 | 
			
		||||
using UnityEngine.UI;
 | 
			
		||||
 | 
			
		||||
namespace RimWorldAnimationStudio
 | 
			
		||||
{
 | 
			
		||||
    public class AnimationDefCard : MonoBehaviour
 | 
			
		||||
    {
 | 
			
		||||
        public InputField defNameField;
 | 
			
		||||
        public InputField labelField;
 | 
			
		||||
 | 
			
		||||
        public void Start()
 | 
			
		||||
        {
 | 
			
		||||
            EventsManager.onAnimationDefChanged.AddListener(delegate { UpdateInputFields(); });
 | 
			
		||||
 | 
			
		||||
            defNameField.onEndEdit.AddListener(delegate { 
 | 
			
		||||
                Workspace.animationDef.DefName = defNameField.text;
 | 
			
		||||
                Workspace.MakeHistoricRecord("AnimationDef update");
 | 
			
		||||
            });
 | 
			
		||||
 | 
			
		||||
            labelField.onEndEdit.AddListener(delegate {
 | 
			
		||||
                Workspace.animationDef.Label = labelField.text;
 | 
			
		||||
                Workspace.MakeHistoricRecord("AnimationDef update");
 | 
			
		||||
            });
 | 
			
		||||
 | 
			
		||||
            UpdateInputFields();
 | 
			
		||||
        }
 | 
			
		||||
 | 
			
		||||
        public void UpdateInputFields()
 | 
			
		||||
        {
 | 
			
		||||
            defNameField.SetTextWithoutNotify(Workspace.animationDef.DefName);
 | 
			
		||||
            labelField.SetTextWithoutNotify(Workspace.animationDef.Label);
 | 
			
		||||
        }
 | 
			
		||||
    }
 | 
			
		||||
}
 | 
			
		||||
							
								
								
									
										63
									
								
								Assets/Scripts/GUI/Cards/StageCard.cs
									
										
									
									
									
										Normal file
									
								
							
							
						
						
									
										63
									
								
								Assets/Scripts/GUI/Cards/StageCard.cs
									
										
									
									
									
										Normal file
									
								
							| 
						 | 
				
			
			@ -0,0 +1,63 @@
 | 
			
		|||
using System.Collections;
 | 
			
		||||
using System.Collections.Generic;
 | 
			
		||||
using UnityEngine;
 | 
			
		||||
using UnityEngine.UI;
 | 
			
		||||
using UnityEngine.EventSystems;
 | 
			
		||||
 | 
			
		||||
namespace RimWorldAnimationStudio
 | 
			
		||||
{
 | 
			
		||||
    public class StageCard : MonoBehaviour, IPointerClickHandler
 | 
			
		||||
    {
 | 
			
		||||
        public Text stageName;
 | 
			
		||||
        public InputField stageNameField;
 | 
			
		||||
        public Image banner;
 | 
			
		||||
 | 
			
		||||
        public void OnNameChange()
 | 
			
		||||
        {
 | 
			
		||||
            stageName.text = stageNameField.text;
 | 
			
		||||
            stageNameField.gameObject.SetActive(false);
 | 
			
		||||
 | 
			
		||||
            Workspace.GetCurrentAnimationStage().StageName = stageName.text;
 | 
			
		||||
            Workspace.RecordEvent("Stage renamed");
 | 
			
		||||
        }
 | 
			
		||||
 | 
			
		||||
        public void OnMoveStage(int delta)
 | 
			
		||||
        {        
 | 
			
		||||
            int siblingCount = transform.parent.childCount;
 | 
			
		||||
            int index = Mathf.Clamp(transform.GetSiblingIndex() + delta, 0, siblingCount - 1);
 | 
			
		||||
 | 
			
		||||
            transform.SetSiblingIndex(index);         
 | 
			
		||||
        }
 | 
			
		||||
 | 
			
		||||
        public void Initialize(string stageName)
 | 
			
		||||
        {
 | 
			
		||||
            this.stageName.text = stageName;
 | 
			
		||||
        }
 | 
			
		||||
 | 
			
		||||
        public void Update()
 | 
			
		||||
        {
 | 
			
		||||
            if (Workspace.StageID == transform.GetSiblingIndex())
 | 
			
		||||
            { banner.gameObject.SetActive(true); }
 | 
			
		||||
 | 
			
		||||
            else
 | 
			
		||||
            { 
 | 
			
		||||
                banner.gameObject.SetActive(false);
 | 
			
		||||
                stageNameField.gameObject.SetActive(false);
 | 
			
		||||
            }
 | 
			
		||||
        }
 | 
			
		||||
 | 
			
		||||
        public void OnPointerClick(PointerEventData eventData)
 | 
			
		||||
        {
 | 
			
		||||
            if (eventData.clickCount >= 2)
 | 
			
		||||
            {
 | 
			
		||||
                stageNameField.text = stageName.text;
 | 
			
		||||
                stageNameField.gameObject.SetActive(true);
 | 
			
		||||
            }
 | 
			
		||||
 | 
			
		||||
            if (Workspace.StageID != transform.GetSiblingIndex())
 | 
			
		||||
            { Workspace.RecordEvent("Stage selected"); }
 | 
			
		||||
 | 
			
		||||
            Workspace.StageID = transform.GetSiblingIndex();
 | 
			
		||||
        }
 | 
			
		||||
    }
 | 
			
		||||
}
 | 
			
		||||
| 
						 | 
				
			
			@ -67,9 +67,9 @@ namespace RimWorldAnimationStudio
 | 
			
		|||
            if (field?.text == null || field.text == "")
 | 
			
		||||
            { return; }
 | 
			
		||||
 | 
			
		||||
            AlienRaceDefs.AddDef(new AlienRaceDef(field.text));
 | 
			
		||||
            PawnRaceDefs.AddDef(new PawnRaceDef(field.text));
 | 
			
		||||
 | 
			
		||||
            ApplicationManager.Instance.SaveAlienRaceDefs();
 | 
			
		||||
            ApplicationManager.Instance.SavePawnRaceDefs();
 | 
			
		||||
            Initialize(true);
 | 
			
		||||
        }
 | 
			
		||||
 | 
			
		||||
| 
						 | 
				
			
			
 | 
			
		|||
| 
						 | 
				
			
			@ -21,21 +21,21 @@ namespace RimWorldAnimationStudio
 | 
			
		|||
        {
 | 
			
		||||
            Reset();
 | 
			
		||||
         
 | 
			
		||||
            AlienRaceDef alienRaceDef = GetCurrentRaceDef();
 | 
			
		||||
            if (alienRaceDef == null) return;
 | 
			
		||||
            PawnRaceDef pawnRaceDef = GetCurrentRaceDef();
 | 
			
		||||
            if (pawnRaceDef == null) return;
 | 
			
		||||
 | 
			
		||||
            isHumanoidToggle.SetIsOnWithoutNotify(alienRaceDef.isHumanoid);
 | 
			
		||||
            isHumanoidToggle.SetIsOnWithoutNotify(pawnRaceDef.isHumanoid);
 | 
			
		||||
 | 
			
		||||
            Text bodyGraphicsTitle = AddCloneObjectToParent(raceSettingsWindow, 2).GetComponent<Text>();
 | 
			
		||||
            bodyGraphicsTitle.text = "Body graphic filepaths";
 | 
			
		||||
 | 
			
		||||
            List<string> allTags = alienRaceDef.isHumanoid ? Tags.bodyTypes : new List<string>() { "None" };
 | 
			
		||||
            List<string> allTags = pawnRaceDef.isHumanoid ? DefaultTags.bodyTypes : new List<string>() { "None" };
 | 
			
		||||
 | 
			
		||||
            foreach (string bodyType in allTags)
 | 
			
		||||
            {
 | 
			
		||||
                string _bodyType = bodyType;
 | 
			
		||||
 | 
			
		||||
                if (alienRaceDef.isHumanoid)
 | 
			
		||||
                if (pawnRaceDef.isHumanoid)
 | 
			
		||||
                {
 | 
			
		||||
                    Text bodyTypeTitle = AddCloneObjectToParent(raceSettingsWindow, 2).GetComponent<Text>();
 | 
			
		||||
                    bodyTypeTitle.text = bodyType;
 | 
			
		||||
| 
						 | 
				
			
			@ -49,15 +49,15 @@ namespace RimWorldAnimationStudio
 | 
			
		|||
                    filepath.GetComponent<Text>().text = facing.ToString();
 | 
			
		||||
                    filepath.transform.Find("FilepathButton").GetComponent<Button>().onClick.AddListener(delegate
 | 
			
		||||
                    {
 | 
			
		||||
                        SetBodyTypeGraphicPath(alienRaceDef, facing, _bodyType);
 | 
			
		||||
                        SetBodyTypeGraphicPath(pawnRaceDef, facing, _bodyType);
 | 
			
		||||
                    });
 | 
			
		||||
                    filepath.transform.FindDeepChild("FilepathLabel").GetComponent<Text>().text = alienRaceDef.GetBodyTypeGraphicPath(facing, _bodyType);
 | 
			
		||||
                    filepath.transform.FindDeepChild("FilepathLabel").GetComponent<Text>().text = pawnRaceDef.GetBodyTypeGraphicPath(facing, _bodyType);
 | 
			
		||||
                }
 | 
			
		||||
 | 
			
		||||
                AddCloneObjectToParent(raceSettingsWindow, 3);
 | 
			
		||||
            }
 | 
			
		||||
 | 
			
		||||
            if (alienRaceDef.isHumanoid)
 | 
			
		||||
            if (pawnRaceDef.isHumanoid)
 | 
			
		||||
            {
 | 
			
		||||
                Text headGraphics = AddCloneObjectToParent(raceSettingsWindow, 2).GetComponent<Text>();
 | 
			
		||||
                headGraphics.text = "Head graphic filepaths";
 | 
			
		||||
| 
						 | 
				
			
			@ -70,15 +70,15 @@ namespace RimWorldAnimationStudio
 | 
			
		|||
                    filepath.GetComponent<Text>().text = facing.ToString();
 | 
			
		||||
                    filepath.transform.Find("FilepathButton").GetComponent<Button>().onClick.AddListener(delegate
 | 
			
		||||
                    {
 | 
			
		||||
                        SetHeadGraphicPath(alienRaceDef, facing);
 | 
			
		||||
                        SetHeadGraphicPath(pawnRaceDef, facing);
 | 
			
		||||
                    });
 | 
			
		||||
                    filepath.transform.FindDeepChild("FilepathLabel").GetComponent<Text>().text = alienRaceDef.GetHeadGraphicPath(facing);
 | 
			
		||||
                    filepath.transform.FindDeepChild("FilepathLabel").GetComponent<Text>().text = pawnRaceDef.GetHeadGraphicPath(facing);
 | 
			
		||||
                }
 | 
			
		||||
 | 
			
		||||
                AddCloneObjectToParent(raceSettingsWindow, 3);
 | 
			
		||||
            }
 | 
			
		||||
 | 
			
		||||
            scaleField.text = string.Format("{0:0.000}", alienRaceDef.scale.ToString());
 | 
			
		||||
            scaleField.text = string.Format("{0:0.000}", pawnRaceDef.scale.ToString());
 | 
			
		||||
        }
 | 
			
		||||
 | 
			
		||||
        public void Reset()
 | 
			
		||||
| 
						 | 
				
			
			@ -88,53 +88,53 @@ namespace RimWorldAnimationStudio
 | 
			
		|||
 | 
			
		||||
        public void SetIsHumanoid()
 | 
			
		||||
        {
 | 
			
		||||
            AlienRaceDef alienRaceDef = GetCurrentRaceDef();
 | 
			
		||||
            if (alienRaceDef == null) return;
 | 
			
		||||
            PawnRaceDef pawnRaceDef = GetCurrentRaceDef();
 | 
			
		||||
            if (pawnRaceDef == null) return;
 | 
			
		||||
 | 
			
		||||
            alienRaceDef.isHumanoid = isHumanoidToggle.isOn;
 | 
			
		||||
            pawnRaceDef.isHumanoid = isHumanoidToggle.isOn;
 | 
			
		||||
 | 
			
		||||
            Initialize();
 | 
			
		||||
        }
 | 
			
		||||
 | 
			
		||||
        public void SetHeadGraphicPath(AlienRaceDef alienRaceDef, CardinalDirection direction)
 | 
			
		||||
        public void SetHeadGraphicPath(PawnRaceDef pawnRaceDef, CardinalDirection direction)
 | 
			
		||||
        {
 | 
			
		||||
            var paths = StandaloneFileBrowser.OpenFilePanel("Select texture File", "", "png", false);
 | 
			
		||||
 | 
			
		||||
            if (paths == null || paths.Any() == false || File.Exists(paths[0]) == false)
 | 
			
		||||
            { Debug.LogWarning("Selected file was null or invalid"); return; }
 | 
			
		||||
 | 
			
		||||
            alienRaceDef.SetHeadGraphicPath(paths[0], direction);
 | 
			
		||||
            pawnRaceDef.SetHeadGraphicPath(paths[0], direction);
 | 
			
		||||
 | 
			
		||||
            Initialize();
 | 
			
		||||
        }
 | 
			
		||||
 | 
			
		||||
        public void SetBodyTypeGraphicPath(AlienRaceDef alienRaceDef, CardinalDirection direction, string bodyType)
 | 
			
		||||
        public void SetBodyTypeGraphicPath(PawnRaceDef pawnRaceDef, CardinalDirection direction, string bodyType)
 | 
			
		||||
        {
 | 
			
		||||
            var paths = StandaloneFileBrowser.OpenFilePanel("Select texture File", "", "png", false);
 | 
			
		||||
 | 
			
		||||
            if (paths == null || paths.Any() == false || File.Exists(paths[0]) == false)
 | 
			
		||||
            { Debug.LogWarning("Selected file was null or invalid"); return; }
 | 
			
		||||
 | 
			
		||||
            alienRaceDef.SetBodyTypeGraphicPath(paths[0], direction, bodyType);
 | 
			
		||||
            pawnRaceDef.SetBodyTypeGraphicPath(paths[0], direction, bodyType);
 | 
			
		||||
 | 
			
		||||
            Initialize();
 | 
			
		||||
        }
 | 
			
		||||
 | 
			
		||||
        public AlienRaceDef GetCurrentRaceDef()
 | 
			
		||||
        public PawnRaceDef GetCurrentRaceDef()
 | 
			
		||||
        {
 | 
			
		||||
            string alienRaceDefName = raceSelectDropdown.value < raceSelectDropdown.options.Count ? raceSelectDropdown.options[raceSelectDropdown.value].text : "Human";
 | 
			
		||||
            if (alienRaceDefName == null || alienRaceDefName == "") alienRaceDefName = "Human";
 | 
			
		||||
            string pawnRaceDefName = raceSelectDropdown.value < raceSelectDropdown.options.Count ? raceSelectDropdown.options[raceSelectDropdown.value].text : "Human";
 | 
			
		||||
            if (pawnRaceDefName == null || pawnRaceDefName == "") pawnRaceDefName = "Human";
 | 
			
		||||
 | 
			
		||||
            return AlienRaceDefs.GetNamed(alienRaceDefName);
 | 
			
		||||
            return PawnRaceDefs.GetNamed(pawnRaceDefName);
 | 
			
		||||
        }
 | 
			
		||||
 | 
			
		||||
        public void SetRaceScale()
 | 
			
		||||
        {
 | 
			
		||||
            AlienRaceDef alienRaceDef = GetCurrentRaceDef();
 | 
			
		||||
            if (alienRaceDef == null) return;
 | 
			
		||||
            PawnRaceDef pawnRaceDef = GetCurrentRaceDef();
 | 
			
		||||
            if (pawnRaceDef == null) return;
 | 
			
		||||
 | 
			
		||||
            float scale = float.Parse(scaleField.text);
 | 
			
		||||
            alienRaceDef.scale = Mathf.Clamp(scale, 0.05f, 100f);
 | 
			
		||||
            pawnRaceDef.scale = Mathf.Clamp(scale, 0.05f, 100f);
 | 
			
		||||
        }
 | 
			
		||||
    }
 | 
			
		||||
}
 | 
			
		||||
| 
						 | 
				
			
			
 | 
			
		|||
| 
						 | 
				
			
			@ -33,11 +33,11 @@ namespace RimWorldAnimationStudio
 | 
			
		|||
        public override void Initialize(bool addedNewTag = false)
 | 
			
		||||
        {
 | 
			
		||||
            if (Workspace.animationDef == null) return;
 | 
			
		||||
            PawnAnimationClip clip = Workspace.animationDef.animationStages[Workspace.stageID].animationClips[Workspace.actorID];
 | 
			
		||||
            PawnAnimationClip clip = Workspace.GetCurrentPawnAnimationClip();
 | 
			
		||||
 | 
			
		||||
            if (clip?.GetActorAddon("left hand") != null)
 | 
			
		||||
            {
 | 
			
		||||
                switch (clip.GetActorAddon("left hand").anchorName)
 | 
			
		||||
                switch (clip.GetActorAddon("left hand").AnchorName)
 | 
			
		||||
                {
 | 
			
		||||
                    case "torso": handLeftAnchor.value = 1; break;
 | 
			
		||||
                    case "head": handLeftAnchor.value = 2; break;
 | 
			
		||||
| 
						 | 
				
			
			@ -50,7 +50,7 @@ namespace RimWorldAnimationStudio
 | 
			
		|||
 | 
			
		||||
            if (clip?.GetActorAddon("right hand") != null)
 | 
			
		||||
            {
 | 
			
		||||
                switch (clip.GetActorAddon("right hand").anchorName)
 | 
			
		||||
                switch (clip.GetActorAddon("right hand").AnchorName)
 | 
			
		||||
                {
 | 
			
		||||
                    case "torso": handRightAnchor.value = 1; break;
 | 
			
		||||
                    case "head": handRightAnchor.value = 2; break;
 | 
			
		||||
| 
						 | 
				
			
			@ -63,7 +63,7 @@ namespace RimWorldAnimationStudio
 | 
			
		|||
 | 
			
		||||
            if (clip?.GetActorAddon("dildo") != null)
 | 
			
		||||
            {
 | 
			
		||||
                switch (clip.GetActorAddon("dildo").anchorName)
 | 
			
		||||
                switch (clip.GetActorAddon("dildo").AnchorName)
 | 
			
		||||
                {
 | 
			
		||||
                    case "torso": sexToyAnchor.value = 1; break;
 | 
			
		||||
                    case "head": sexToyAnchor.value = 2; break;
 | 
			
		||||
| 
						 | 
				
			
			@ -76,20 +76,20 @@ namespace RimWorldAnimationStudio
 | 
			
		|||
 | 
			
		||||
            if (clip?.GetActorAddon("left hand") != null)
 | 
			
		||||
            { 
 | 
			
		||||
                handLeftLayer.value = handLeftLayer.options.IndexOf(handLeftLayer.options.First(x => x.text == clip.GetActorAddon("left hand").layer));
 | 
			
		||||
                handLeftAnchoringPawn.text = clip.GetActorAddon("left hand").anchoringActor.ToString();
 | 
			
		||||
                handLeftLayer.value = handLeftLayer.options.IndexOf(handLeftLayer.options.First(x => x.text == clip.GetActorAddon("left hand").Layer));
 | 
			
		||||
                handLeftAnchoringPawn.text = clip.GetActorAddon("left hand").AnchoringActor.ToString();
 | 
			
		||||
            }
 | 
			
		||||
 | 
			
		||||
            if (clip?.GetActorAddon("right hand") != null)
 | 
			
		||||
            { 
 | 
			
		||||
                handRightLayer.value = handRightLayer.options.IndexOf(handRightLayer.options.First(x => x.text == clip.GetActorAddon("right hand").layer)); 
 | 
			
		||||
                handRightAnchoringPawn.text = clip.GetActorAddon("right hand").anchoringActor.ToString(); 
 | 
			
		||||
                handRightLayer.value = handRightLayer.options.IndexOf(handRightLayer.options.First(x => x.text == clip.GetActorAddon("right hand").Layer)); 
 | 
			
		||||
                handRightAnchoringPawn.text = clip.GetActorAddon("right hand").AnchoringActor.ToString(); 
 | 
			
		||||
            }
 | 
			
		||||
 | 
			
		||||
            if (clip?.GetActorAddon("dildo") != null)
 | 
			
		||||
            { 
 | 
			
		||||
                sexToyLayer.value = sexToyLayer.options.IndexOf(sexToyLayer.options.First(x => x.text == clip.GetActorAddon("dildo").layer));
 | 
			
		||||
                sexToyAnchoringPawn.text = clip.GetActorAddon("dildo").anchoringActor.ToString();
 | 
			
		||||
                sexToyLayer.value = sexToyLayer.options.IndexOf(sexToyLayer.options.First(x => x.text == clip.GetActorAddon("dildo").Layer));
 | 
			
		||||
                sexToyAnchoringPawn.text = clip.GetActorAddon("dildo").AnchoringActor.ToString();
 | 
			
		||||
            }
 | 
			
		||||
 | 
			
		||||
            handLeftToggle.isOn = clip.IsActorAddonVisible("left hand");
 | 
			
		||||
| 
						 | 
				
			
			@ -103,7 +103,7 @@ namespace RimWorldAnimationStudio
 | 
			
		|||
 | 
			
		||||
        public void OnToggleChanged()
 | 
			
		||||
        {
 | 
			
		||||
            PawnAnimationClip clip = Workspace.animationDef.animationStages[Workspace.stageID].animationClips[Workspace.actorID];
 | 
			
		||||
            PawnAnimationClip clip = Workspace.GetCurrentPawnAnimationClip();
 | 
			
		||||
 | 
			
		||||
            clip.ShowOrHideActorAddon("left hand", handLeftToggle.isOn);
 | 
			
		||||
            clip.ShowOrHideActorAddon("right hand", handRightToggle.isOn);
 | 
			
		||||
| 
						 | 
				
			
			@ -114,18 +114,18 @@ namespace RimWorldAnimationStudio
 | 
			
		|||
 | 
			
		||||
        public void OnValueChanged()
 | 
			
		||||
        {
 | 
			
		||||
            PawnAnimationClip clip = Workspace.animationDef.animationStages[Workspace.stageID].animationClips[Workspace.actorID];
 | 
			
		||||
            PawnAnimationClip clip = Workspace.GetCurrentPawnAnimationClip();
 | 
			
		||||
 | 
			
		||||
            if (clip?.GetActorAddon("left hand") != null)
 | 
			
		||||
            {
 | 
			
		||||
                switch (handLeftAnchor.value)
 | 
			
		||||
                {
 | 
			
		||||
                    case 1: clip.GetActorAddon("left hand").anchorName = "torso"; break;
 | 
			
		||||
                    case 2: clip.GetActorAddon("left hand").anchorName = "head"; break;
 | 
			
		||||
                    case 3: clip.GetActorAddon("left hand").anchorName = "groin"; break;
 | 
			
		||||
                    case 4: clip.GetActorAddon("left hand").anchorName = "left breast"; break;
 | 
			
		||||
                    case 5: clip.GetActorAddon("left hand").anchorName = "right breast"; break;
 | 
			
		||||
                    default: clip.GetActorAddon("left hand").anchorName = null; break;
 | 
			
		||||
                    case 1: clip.GetActorAddon("left hand").AnchorName = "torso"; break;
 | 
			
		||||
                    case 2: clip.GetActorAddon("left hand").AnchorName = "head"; break;
 | 
			
		||||
                    case 3: clip.GetActorAddon("left hand").AnchorName = "groin"; break;
 | 
			
		||||
                    case 4: clip.GetActorAddon("left hand").AnchorName = "left breast"; break;
 | 
			
		||||
                    case 5: clip.GetActorAddon("left hand").AnchorName = "right breast"; break;
 | 
			
		||||
                    default: clip.GetActorAddon("left hand").AnchorName = null; break;
 | 
			
		||||
                }
 | 
			
		||||
            }
 | 
			
		||||
 | 
			
		||||
| 
						 | 
				
			
			@ -133,12 +133,12 @@ namespace RimWorldAnimationStudio
 | 
			
		|||
            {
 | 
			
		||||
                switch (handRightAnchor.value)
 | 
			
		||||
                {
 | 
			
		||||
                    case 1: clip.GetActorAddon("right hand").anchorName = "torso"; break;
 | 
			
		||||
                    case 2: clip.GetActorAddon("right hand").anchorName = "head"; break;
 | 
			
		||||
                    case 3: clip.GetActorAddon("right hand").anchorName = "groin"; break;
 | 
			
		||||
                    case 4: clip.GetActorAddon("right hand").anchorName = "left breast"; break;
 | 
			
		||||
                    case 5: clip.GetActorAddon("right hand").anchorName = "right breast"; break;
 | 
			
		||||
                    default: clip.GetActorAddon("right hand").anchorName = null; break;
 | 
			
		||||
                    case 1: clip.GetActorAddon("right hand").AnchorName = "torso"; break;
 | 
			
		||||
                    case 2: clip.GetActorAddon("right hand").AnchorName = "head"; break;
 | 
			
		||||
                    case 3: clip.GetActorAddon("right hand").AnchorName = "groin"; break;
 | 
			
		||||
                    case 4: clip.GetActorAddon("right hand").AnchorName = "left breast"; break;
 | 
			
		||||
                    case 5: clip.GetActorAddon("right hand").AnchorName = "right breast"; break;
 | 
			
		||||
                    default: clip.GetActorAddon("right hand").AnchorName = null; break;
 | 
			
		||||
                }
 | 
			
		||||
            }
 | 
			
		||||
 | 
			
		||||
| 
						 | 
				
			
			@ -146,12 +146,12 @@ namespace RimWorldAnimationStudio
 | 
			
		|||
            {
 | 
			
		||||
                switch (sexToyAnchor.value)
 | 
			
		||||
                {
 | 
			
		||||
                    case 1: clip.GetActorAddon("dildo").anchorName = "torso"; break;
 | 
			
		||||
                    case 2: clip.GetActorAddon("dildo").anchorName = "head"; break;
 | 
			
		||||
                    case 3: clip.GetActorAddon("dildo").anchorName = "groin"; break;
 | 
			
		||||
                    case 4: clip.GetActorAddon("dildo").anchorName = "left breast"; break;
 | 
			
		||||
                    case 5: clip.GetActorAddon("dildo").anchorName = "right breast"; break;
 | 
			
		||||
                    default: clip.GetActorAddon("dildo").anchorName = null; break;
 | 
			
		||||
                    case 1: clip.GetActorAddon("dildo").AnchorName = "torso"; break;
 | 
			
		||||
                    case 2: clip.GetActorAddon("dildo").AnchorName = "head"; break;
 | 
			
		||||
                    case 3: clip.GetActorAddon("dildo").AnchorName = "groin"; break;
 | 
			
		||||
                    case 4: clip.GetActorAddon("dildo").AnchorName = "left breast"; break;
 | 
			
		||||
                    case 5: clip.GetActorAddon("dildo").AnchorName = "right breast"; break;
 | 
			
		||||
                    default: clip.GetActorAddon("dildo").AnchorName = null; break;
 | 
			
		||||
                }
 | 
			
		||||
            }
 | 
			
		||||
 | 
			
		||||
| 
						 | 
				
			
			@ -160,32 +160,32 @@ namespace RimWorldAnimationStudio
 | 
			
		|||
 | 
			
		||||
        public void OnLayerChanged()
 | 
			
		||||
        {
 | 
			
		||||
            PawnAnimationClip clip = Workspace.animationDef.animationStages[Workspace.stageID].animationClips[Workspace.actorID];
 | 
			
		||||
            PawnAnimationClip clip = Workspace.GetCurrentPawnAnimationClip();
 | 
			
		||||
 | 
			
		||||
            if (clip?.GetActorAddon("left hand") != null)
 | 
			
		||||
            { clip.GetActorAddon("left hand").layer = handLeftLayer.options[handLeftLayer.value].text; }
 | 
			
		||||
            { clip.GetActorAddon("left hand").Layer = handLeftLayer.options[handLeftLayer.value].text; }
 | 
			
		||||
 | 
			
		||||
            if (clip?.GetActorAddon("right hand") != null)
 | 
			
		||||
            { clip.GetActorAddon("right hand").layer = handRightLayer.options[handRightLayer.value].text; }
 | 
			
		||||
            { clip.GetActorAddon("right hand").Layer = handRightLayer.options[handRightLayer.value].text; }
 | 
			
		||||
 | 
			
		||||
            if (clip?.GetActorAddon("dildo") != null)
 | 
			
		||||
            { clip.GetActorAddon("dildo").layer = sexToyLayer.options[sexToyLayer.value].text; }
 | 
			
		||||
            { clip.GetActorAddon("dildo").Layer = sexToyLayer.options[sexToyLayer.value].text; }
 | 
			
		||||
 | 
			
		||||
            //Initialize();
 | 
			
		||||
        }
 | 
			
		||||
 | 
			
		||||
        public void OnAnchoringPawnChanged()
 | 
			
		||||
        {
 | 
			
		||||
            PawnAnimationClip clip = Workspace.animationDef.animationStages[Workspace.stageID].animationClips[Workspace.actorID];
 | 
			
		||||
            PawnAnimationClip clip = Workspace.GetCurrentPawnAnimationClip();
 | 
			
		||||
 | 
			
		||||
            if (clip?.GetActorAddon("left hand") != null)
 | 
			
		||||
            { 
 | 
			
		||||
                int i = int.Parse(handLeftAnchoringPawn.text);
 | 
			
		||||
                
 | 
			
		||||
                if (i < 0) { i = clip.GetOwningActorID(); }
 | 
			
		||||
                i = Mathf.Clamp(i, 0, Workspace.animationDef.actors.Count - 1);
 | 
			
		||||
                i = Mathf.Clamp(i, 0, Workspace.animationDef.Actors.Count - 1);
 | 
			
		||||
 | 
			
		||||
                clip.GetActorAddon("left hand").anchoringActor = i;
 | 
			
		||||
                clip.GetActorAddon("left hand").AnchoringActor = i;
 | 
			
		||||
                handLeftAnchoringPawn.SetTextWithoutNotify(i.ToString());
 | 
			
		||||
            }
 | 
			
		||||
 | 
			
		||||
| 
						 | 
				
			
			@ -194,9 +194,9 @@ namespace RimWorldAnimationStudio
 | 
			
		|||
                int i = int.Parse(handRightAnchoringPawn.text);
 | 
			
		||||
 | 
			
		||||
                if (i < 0) { i = clip.GetOwningActorID(); }
 | 
			
		||||
                i = Mathf.Clamp(i, 0, Workspace.animationDef.actors.Count - 1);
 | 
			
		||||
                i = Mathf.Clamp(i, 0, Workspace.animationDef.Actors.Count - 1);
 | 
			
		||||
 | 
			
		||||
                clip.GetActorAddon("right hand").anchoringActor = i;
 | 
			
		||||
                clip.GetActorAddon("right hand").AnchoringActor = i;
 | 
			
		||||
                handRightAnchoringPawn.SetTextWithoutNotify(i.ToString());
 | 
			
		||||
            }
 | 
			
		||||
 | 
			
		||||
| 
						 | 
				
			
			@ -205,9 +205,9 @@ namespace RimWorldAnimationStudio
 | 
			
		|||
                int i = int.Parse(sexToyAnchoringPawn.text);
 | 
			
		||||
 | 
			
		||||
                if (i < 0) { i = clip.GetOwningActorID(); }
 | 
			
		||||
                i = Mathf.Clamp(i, 0, Workspace.animationDef.actors.Count - 1);
 | 
			
		||||
                i = Mathf.Clamp(i, 0, Workspace.animationDef.Actors.Count - 1);
 | 
			
		||||
 | 
			
		||||
                clip.GetActorAddon("dildo").anchoringActor = i;
 | 
			
		||||
                clip.GetActorAddon("dildo").AnchoringActor = i;
 | 
			
		||||
                sexToyAnchoringPawn.SetTextWithoutNotify(i.ToString());
 | 
			
		||||
            }
 | 
			
		||||
        }
 | 
			
		||||
| 
						 | 
				
			
			
 | 
			
		|||
| 
						 | 
				
			
			@ -17,23 +17,23 @@ namespace RimWorldAnimationStudio
 | 
			
		|||
            Transform contentWindow = transform.FindDeepChild("Content");
 | 
			
		||||
            Reset();
 | 
			
		||||
 | 
			
		||||
            for (int i = 0; i < Tags.actorLayers.Count; i++)
 | 
			
		||||
            for (int i = 0; i < DefaultTags.actorLayers.Count; i++)
 | 
			
		||||
            {
 | 
			
		||||
                string actorLayer = Tags.actorLayers[i];
 | 
			
		||||
                string actorLayer = DefaultTags.actorLayers[i];
 | 
			
		||||
 | 
			
		||||
                Transform _optionToggle = AddCloneObjectToParent(contentWindow).transform;
 | 
			
		||||
                _optionToggle.Find("Text").GetComponent<Text>().text = actorLayer;
 | 
			
		||||
 | 
			
		||||
                Toggle toggleComp = _optionToggle.GetComponent<Toggle>();
 | 
			
		||||
                toggleComp.isOn = Workspace.Instance.GetCurrentPawnAnimationClip().layer == actorLayer;
 | 
			
		||||
                toggleComp.isOn = Workspace.GetCurrentPawnAnimationClip().Layer == actorLayer;
 | 
			
		||||
                toggleComp.onValueChanged.AddListener(delegate {
 | 
			
		||||
 | 
			
		||||
                    PawnAnimationClip clip = Workspace.Instance.GetCurrentPawnAnimationClip();
 | 
			
		||||
                    PawnAnimationClip clip = Workspace.GetCurrentPawnAnimationClip();
 | 
			
		||||
 | 
			
		||||
                    if (clip != null)
 | 
			
		||||
                    { clip.layer = actorLayer; }
 | 
			
		||||
                    { clip.Layer = actorLayer; }
 | 
			
		||||
                    
 | 
			
		||||
                    Workspace.Instance.RecordEvent("Actor layer set");
 | 
			
		||||
                    Workspace.RecordEvent("Actor layer set");
 | 
			
		||||
                });
 | 
			
		||||
 | 
			
		||||
                toggleComp.group = contentWindow.GetComponent<ToggleGroup>();
 | 
			
		||||
| 
						 | 
				
			
			
 | 
			
		|||
| 
						 | 
				
			
			@ -10,7 +10,7 @@ namespace RimWorldAnimationStudio
 | 
			
		|||
{
 | 
			
		||||
    public class SelectAnimationDialog : DialogBox
 | 
			
		||||
    {
 | 
			
		||||
        public void Initialize(Defs defs)
 | 
			
		||||
        public void Initialize(AnimationDefs defs)
 | 
			
		||||
        {
 | 
			
		||||
            Transform contentWindow = transform.FindDeepChild("Content");
 | 
			
		||||
            Reset();
 | 
			
		||||
| 
						 | 
				
			
			@ -20,7 +20,7 @@ namespace RimWorldAnimationStudio
 | 
			
		|||
                AnimationDef animationDef = defs.animationDefs[i];
 | 
			
		||||
 | 
			
		||||
                Transform _optionButton = AddCloneObjectToParent(contentWindow).transform;
 | 
			
		||||
                _optionButton.Find("Text").GetComponent<Text>().text = animationDef.defName;
 | 
			
		||||
                _optionButton.Find("Text").GetComponent<Text>().text = animationDef.DefName;
 | 
			
		||||
 | 
			
		||||
                Button buttonComp = _optionButton.GetComponent<Button>();
 | 
			
		||||
                buttonComp.onClick.AddListener(delegate { Pop(); ApplicationManager.Instance.LoadAnimation(animationDef); });
 | 
			
		||||
| 
						 | 
				
			
			
 | 
			
		|||
| 
						 | 
				
			
			@ -12,10 +12,10 @@ namespace RimWorldAnimationStudio
 | 
			
		|||
    {
 | 
			
		||||
        public override void Initialize(bool addedNewTag = false)
 | 
			
		||||
        {
 | 
			
		||||
            IEnumerable<string> allTags = Tags.bodyDefTypes.Concat(CustomTags.bodyDefTypes);
 | 
			
		||||
            IEnumerable<string> allTags = DefaultTags.bodyDefTypes.Concat(CustomTags.bodyDefTypes);
 | 
			
		||||
            string placeHolderText = "Enter new body def type...";
 | 
			
		||||
 | 
			
		||||
            Actor actor = Workspace.animationDef.actors[Workspace.actorID];
 | 
			
		||||
            Actor actor = Workspace.animationDef.Actors[Workspace.ActorID];
 | 
			
		||||
            Transform contentWindow = transform.FindDeepChild("Content");
 | 
			
		||||
            Reset();
 | 
			
		||||
 | 
			
		||||
| 
						 | 
				
			
			@ -27,16 +27,16 @@ namespace RimWorldAnimationStudio
 | 
			
		|||
                _optionToggle.Find("Text").GetComponent<Text>().text = tag;
 | 
			
		||||
 | 
			
		||||
                Toggle toggleComp = _optionToggle.GetComponent<Toggle>();
 | 
			
		||||
                toggleComp.isOn = actor.bodyDefTypes.Contains(tag);
 | 
			
		||||
                toggleComp.isOn = actor.BodyDefTypes.Contains(tag);
 | 
			
		||||
                toggleComp.onValueChanged.AddListener(delegate 
 | 
			
		||||
                {                     
 | 
			
		||||
                    if (toggleComp.isOn && actor.bodyDefTypes.Contains(tag) == false)
 | 
			
		||||
                    { actor.bodyDefTypes.Add(tag); }
 | 
			
		||||
                    if (toggleComp.isOn && actor.BodyDefTypes.Contains(tag) == false)
 | 
			
		||||
                    { actor.BodyDefTypes.Add(tag); }
 | 
			
		||||
 | 
			
		||||
                    else if (toggleComp.isOn == false && actor.bodyDefTypes.Contains(tag))
 | 
			
		||||
                    { actor.bodyDefTypes.Remove(tag); }
 | 
			
		||||
                    else if (toggleComp.isOn == false && actor.BodyDefTypes.Contains(tag))
 | 
			
		||||
                    { actor.BodyDefTypes.Remove(tag); }
 | 
			
		||||
 | 
			
		||||
                    Workspace.Instance.RecordEvent("Actor bodyDef type");
 | 
			
		||||
                    Workspace.RecordEvent("Actor bodyDef type");
 | 
			
		||||
                });
 | 
			
		||||
 | 
			
		||||
                if (CustomTags.bodyDefTypes.Contains(tag))
 | 
			
		||||
| 
						 | 
				
			
			@ -54,7 +54,7 @@ namespace RimWorldAnimationStudio
 | 
			
		|||
            _optionField.Find("Placeholder").GetComponent<Text>().text = placeHolderText;
 | 
			
		||||
 | 
			
		||||
            InputField fieldComp = _optionField.GetComponent<InputField>();
 | 
			
		||||
            fieldComp.onEndEdit.AddListener(delegate { AddCustomTag(fieldComp, ref Tags.bodyDefTypes, ref CustomTags.bodyDefTypes); });
 | 
			
		||||
            fieldComp.onEndEdit.AddListener(delegate { AddCustomTag(fieldComp, ref DefaultTags.bodyDefTypes, ref CustomTags.bodyDefTypes); });
 | 
			
		||||
        }
 | 
			
		||||
 | 
			
		||||
        public void Reset()
 | 
			
		||||
| 
						 | 
				
			
			
 | 
			
		|||
| 
						 | 
				
			
			@ -12,10 +12,10 @@ namespace RimWorldAnimationStudio
 | 
			
		|||
    {
 | 
			
		||||
        public override void Initialize(bool addedNewTag = false)
 | 
			
		||||
        {
 | 
			
		||||
            IEnumerable<string> allTags = Tags.bodyParts.Concat(CustomTags.bodyParts);
 | 
			
		||||
            IEnumerable<string> allTags = DefaultTags.bodyParts.Concat(CustomTags.bodyParts);
 | 
			
		||||
            string placeHolderText = "Enter new body part name...";
 | 
			
		||||
 | 
			
		||||
            Actor actor = Workspace.animationDef.actors[Workspace.actorID];
 | 
			
		||||
            Actor actor = Workspace.animationDef.Actors[Workspace.ActorID];
 | 
			
		||||
            Transform contentWindow = transform.FindDeepChild("Content");
 | 
			
		||||
            Reset();
 | 
			
		||||
 | 
			
		||||
| 
						 | 
				
			
			@ -23,15 +23,15 @@ namespace RimWorldAnimationStudio
 | 
			
		|||
            _appendageToggle.Find("Text").GetComponent<Text>().text = "Any appendage";
 | 
			
		||||
 | 
			
		||||
            Toggle appendageToggleComp = _appendageToggle.GetComponent<Toggle>();
 | 
			
		||||
            appendageToggleComp.isOn = actor.isFucking;
 | 
			
		||||
            appendageToggleComp.onValueChanged.AddListener(delegate { actor.isFucking = appendageToggleComp.isOn; Workspace.Instance.RecordEvent("Actor required body part");});
 | 
			
		||||
            appendageToggleComp.isOn = actor.IsFucking;
 | 
			
		||||
            appendageToggleComp.onValueChanged.AddListener(delegate { actor.IsFucking = appendageToggleComp.isOn; Workspace.RecordEvent("Actor required body part");});
 | 
			
		||||
 | 
			
		||||
            Transform _orificeToggle = AddCloneObjectToParent(contentWindow).transform;
 | 
			
		||||
            _orificeToggle.Find("Text").GetComponent<Text>().text = "Any orifice";
 | 
			
		||||
 | 
			
		||||
            Toggle orificeToggleComp = _orificeToggle.GetComponent<Toggle>();
 | 
			
		||||
            orificeToggleComp.isOn = actor.isFucked;
 | 
			
		||||
            orificeToggleComp.onValueChanged.AddListener(delegate { actor.isFucked = orificeToggleComp.isOn; Workspace.Instance.RecordEvent("Actor required body part"); });
 | 
			
		||||
            orificeToggleComp.isOn = actor.IsFucked;
 | 
			
		||||
            orificeToggleComp.onValueChanged.AddListener(delegate { actor.IsFucked = orificeToggleComp.isOn; Workspace.RecordEvent("Actor required body part"); });
 | 
			
		||||
 | 
			
		||||
            for (int i = 0; i < allTags.Count(); i++)
 | 
			
		||||
            {
 | 
			
		||||
| 
						 | 
				
			
			@ -41,16 +41,16 @@ namespace RimWorldAnimationStudio
 | 
			
		|||
                _optionToggle.Find("Text").GetComponent<Text>().text = tag;
 | 
			
		||||
 | 
			
		||||
                Toggle toggleComp = _optionToggle.GetComponent<Toggle>();
 | 
			
		||||
                toggleComp.isOn = actor.requiredGenitals.Contains(tag);
 | 
			
		||||
                toggleComp.isOn = actor.RequiredGenitals.Contains(tag);
 | 
			
		||||
                toggleComp.onValueChanged.AddListener(delegate
 | 
			
		||||
                { 
 | 
			
		||||
                    if (toggleComp.isOn && actor.requiredGenitals.Contains(tag) == false)
 | 
			
		||||
                    { actor.requiredGenitals.Add(tag); }
 | 
			
		||||
                    if (toggleComp.isOn && actor.RequiredGenitals.Contains(tag) == false)
 | 
			
		||||
                    { actor.RequiredGenitals.Add(tag); }
 | 
			
		||||
 | 
			
		||||
                    else if (toggleComp.isOn == false && actor.requiredGenitals.Contains(tag))
 | 
			
		||||
                    { actor.requiredGenitals.Remove(tag); }
 | 
			
		||||
                    else if (toggleComp.isOn == false && actor.RequiredGenitals.Contains(tag))
 | 
			
		||||
                    { actor.RequiredGenitals.Remove(tag); }
 | 
			
		||||
 | 
			
		||||
                    Workspace.Instance.RecordEvent("Actor required body part");
 | 
			
		||||
                    Workspace.RecordEvent("Actor required body part");
 | 
			
		||||
                });
 | 
			
		||||
 | 
			
		||||
                if (CustomTags.bodyParts.Contains(tag))
 | 
			
		||||
| 
						 | 
				
			
			@ -68,7 +68,7 @@ namespace RimWorldAnimationStudio
 | 
			
		|||
            _optionField.Find("Placeholder").GetComponent<Text>().text = placeHolderText;
 | 
			
		||||
 | 
			
		||||
            InputField fieldComp = _optionField.GetComponent<InputField>();
 | 
			
		||||
            fieldComp.onEndEdit.AddListener(delegate { AddCustomTag(fieldComp, ref Tags.bodyParts, ref CustomTags.bodyParts); });
 | 
			
		||||
            fieldComp.onEndEdit.AddListener(delegate { AddCustomTag(fieldComp, ref DefaultTags.bodyParts, ref CustomTags.bodyParts); });
 | 
			
		||||
        }
 | 
			
		||||
 | 
			
		||||
        public void Reset()
 | 
			
		||||
| 
						 | 
				
			
			
 | 
			
		|||
| 
						 | 
				
			
			@ -12,10 +12,10 @@ namespace RimWorldAnimationStudio
 | 
			
		|||
    {
 | 
			
		||||
        public override void Initialize(bool addedNewTag = false)
 | 
			
		||||
        {
 | 
			
		||||
            IEnumerable<string> allTags = Tags.defNames.Concat(CustomTags.defNames);
 | 
			
		||||
            IEnumerable<string> allTags = DefaultTags.defNames.Concat(CustomTags.defNames);
 | 
			
		||||
            string placeHolderText = "Enter new def name...";
 | 
			
		||||
 | 
			
		||||
            Actor actor = Workspace.animationDef.actors[Workspace.actorID];
 | 
			
		||||
            Actor actor = Workspace.animationDef.Actors[Workspace.ActorID];
 | 
			
		||||
            Transform contentWindow = transform.FindDeepChild("Content");
 | 
			
		||||
            Reset();
 | 
			
		||||
 | 
			
		||||
| 
						 | 
				
			
			@ -27,16 +27,16 @@ namespace RimWorldAnimationStudio
 | 
			
		|||
                _optionToggle.Find("Text").GetComponent<Text>().text = tag;
 | 
			
		||||
 | 
			
		||||
                Toggle toggleComp = _optionToggle.GetComponent<Toggle>();
 | 
			
		||||
                toggleComp.isOn = actor.defNames.Contains(tag);
 | 
			
		||||
                toggleComp.isOn = actor.DefNames.Contains(tag);
 | 
			
		||||
                toggleComp.onValueChanged.AddListener(delegate 
 | 
			
		||||
                {                     
 | 
			
		||||
                    if (toggleComp.isOn && actor.defNames.Contains(tag) == false)
 | 
			
		||||
                    { actor.defNames.Add(tag); }
 | 
			
		||||
                    if (toggleComp.isOn && actor.DefNames.Contains(tag) == false)
 | 
			
		||||
                    { actor.DefNames.Add(tag); }
 | 
			
		||||
 | 
			
		||||
                    else if (toggleComp.isOn == false && actor.defNames.Contains(tag))
 | 
			
		||||
                    { actor.defNames.Remove(tag); }
 | 
			
		||||
                    else if (toggleComp.isOn == false && actor.DefNames.Contains(tag))
 | 
			
		||||
                    { actor.DefNames.Remove(tag); }
 | 
			
		||||
 | 
			
		||||
                    Workspace.Instance.RecordEvent("Actor def name");
 | 
			
		||||
                    Workspace.RecordEvent("Actor def name");
 | 
			
		||||
                });
 | 
			
		||||
 | 
			
		||||
                if (CustomTags.defNames.Contains(tag))
 | 
			
		||||
| 
						 | 
				
			
			@ -56,7 +56,7 @@ namespace RimWorldAnimationStudio
 | 
			
		|||
            InputField fieldComp = _optionField.GetComponent<InputField>();
 | 
			
		||||
            fieldComp.onEndEdit.AddListener(delegate 
 | 
			
		||||
            {
 | 
			
		||||
                AddCustomTag(fieldComp, ref Tags.defNames, ref CustomTags.defNames);
 | 
			
		||||
                AddCustomTag(fieldComp, ref DefaultTags.defNames, ref CustomTags.defNames);
 | 
			
		||||
                AddCustomRace(fieldComp); 
 | 
			
		||||
            });
 | 
			
		||||
        }
 | 
			
		||||
| 
						 | 
				
			
			
 | 
			
		|||
| 
						 | 
				
			
			@ -12,7 +12,7 @@ namespace RimWorldAnimationStudio
 | 
			
		|||
    {
 | 
			
		||||
        public override void Initialize(bool addedNewTag = false)
 | 
			
		||||
        {
 | 
			
		||||
            IEnumerable<string> allTags = Tags.interactionDefTypes.Concat(CustomTags.interactionDefTypes);
 | 
			
		||||
            IEnumerable<string> allTags = DefaultTags.interactionDefTypes.Concat(CustomTags.interactionDefTypes);
 | 
			
		||||
            string placeHolderText = "Enter new interaction def type...";
 | 
			
		||||
 | 
			
		||||
            if (Workspace.animationDef == null) return;
 | 
			
		||||
| 
						 | 
				
			
			@ -28,16 +28,16 @@ namespace RimWorldAnimationStudio
 | 
			
		|||
                _optionToggle.Find("Text").GetComponent<Text>().text = tag;
 | 
			
		||||
 | 
			
		||||
                Toggle toggleComp = _optionToggle.GetComponent<Toggle>();
 | 
			
		||||
                toggleComp.isOn = Workspace.animationDef.interactionDefTypes.Contains(tag);
 | 
			
		||||
                toggleComp.isOn = Workspace.animationDef.InteractionDefTypes.Contains(tag);
 | 
			
		||||
                toggleComp.onValueChanged.AddListener(delegate 
 | 
			
		||||
                {              
 | 
			
		||||
                    if (toggleComp.isOn && Workspace.animationDef.interactionDefTypes.Contains(tag) == false)
 | 
			
		||||
                    { Workspace.animationDef.interactionDefTypes.Add(tag); }
 | 
			
		||||
                    if (toggleComp.isOn && Workspace.animationDef.InteractionDefTypes.Contains(tag) == false)
 | 
			
		||||
                    { Workspace.animationDef.InteractionDefTypes.Add(tag); }
 | 
			
		||||
 | 
			
		||||
                    else if (toggleComp.isOn == false && Workspace.animationDef.interactionDefTypes.Contains(tag))
 | 
			
		||||
                    { Workspace.animationDef.interactionDefTypes.Remove(tag); }
 | 
			
		||||
                    else if (toggleComp.isOn == false && Workspace.animationDef.InteractionDefTypes.Contains(tag))
 | 
			
		||||
                    { Workspace.animationDef.InteractionDefTypes.Remove(tag); }
 | 
			
		||||
 | 
			
		||||
                    Workspace.Instance.RecordEvent("Animation InteractionDef");
 | 
			
		||||
                    Workspace.RecordEvent("Animation InteractionDef");
 | 
			
		||||
                });
 | 
			
		||||
 | 
			
		||||
                if (CustomTags.interactionDefTypes.Contains(tag))
 | 
			
		||||
| 
						 | 
				
			
			@ -55,7 +55,7 @@ namespace RimWorldAnimationStudio
 | 
			
		|||
            _optionField.Find("Placeholder").GetComponent<Text>().text = placeHolderText;
 | 
			
		||||
 | 
			
		||||
            InputField fieldComp = _optionField.GetComponent<InputField>();
 | 
			
		||||
            fieldComp.onEndEdit.AddListener(delegate { AddCustomTag(fieldComp, ref Tags.interactionDefTypes, ref CustomTags.interactionDefTypes); });
 | 
			
		||||
            fieldComp.onEndEdit.AddListener(delegate { AddCustomTag(fieldComp, ref DefaultTags.interactionDefTypes, ref CustomTags.interactionDefTypes); });
 | 
			
		||||
        }
 | 
			
		||||
 | 
			
		||||
        public void Reset()
 | 
			
		||||
| 
						 | 
				
			
			
 | 
			
		|||
| 
						 | 
				
			
			@ -12,7 +12,7 @@ namespace RimWorldAnimationStudio
 | 
			
		|||
    {
 | 
			
		||||
        public override void Initialize(bool addedNewTag = false)
 | 
			
		||||
        {
 | 
			
		||||
            IEnumerable<string> allTags = Tags.sexTypes.Concat(CustomTags.sexTypes);
 | 
			
		||||
            IEnumerable<string> allTags = DefaultTags.sexTypes.Concat(CustomTags.sexTypes);
 | 
			
		||||
            string placeHolderText = "Enter new sex type...";
 | 
			
		||||
 | 
			
		||||
            if (Workspace.animationDef == null) return;
 | 
			
		||||
| 
						 | 
				
			
			@ -28,16 +28,16 @@ namespace RimWorldAnimationStudio
 | 
			
		|||
                _optionToggle.Find("Text").GetComponent<Text>().text = tag;
 | 
			
		||||
 | 
			
		||||
                Toggle toggleComp = _optionToggle.GetComponent<Toggle>();
 | 
			
		||||
                toggleComp.isOn = Workspace.animationDef.sexTypes.Contains(tag);
 | 
			
		||||
                toggleComp.isOn = Workspace.animationDef.SexTypes.Contains(tag);
 | 
			
		||||
                toggleComp.onValueChanged.AddListener(delegate 
 | 
			
		||||
                {                     
 | 
			
		||||
                    if (toggleComp.isOn && Workspace.animationDef.sexTypes.Contains(tag) == false)
 | 
			
		||||
                    { Workspace.animationDef.sexTypes.Add(tag); }
 | 
			
		||||
                    if (toggleComp.isOn && Workspace.animationDef.SexTypes.Contains(tag) == false)
 | 
			
		||||
                    { Workspace.animationDef.SexTypes.Add(tag); }
 | 
			
		||||
 | 
			
		||||
                    else if (toggleComp.isOn == false && Workspace.animationDef.sexTypes.Contains(tag))
 | 
			
		||||
                    { Workspace.animationDef.sexTypes.Remove(tag); }
 | 
			
		||||
                    else if (toggleComp.isOn == false && Workspace.animationDef.SexTypes.Contains(tag))
 | 
			
		||||
                    { Workspace.animationDef.SexTypes.Remove(tag); }
 | 
			
		||||
 | 
			
		||||
                    Workspace.Instance.RecordEvent("Animation sex type");
 | 
			
		||||
                    Workspace.RecordEvent("Animation sex type");
 | 
			
		||||
                });
 | 
			
		||||
 | 
			
		||||
                if (CustomTags.sexTypes.Contains(tag))
 | 
			
		||||
| 
						 | 
				
			
			@ -55,7 +55,7 @@ namespace RimWorldAnimationStudio
 | 
			
		|||
            _optionField.Find("Placeholder").GetComponent<Text>().text = placeHolderText;
 | 
			
		||||
 | 
			
		||||
            InputField fieldComp = _optionField.GetComponent<InputField>();
 | 
			
		||||
            fieldComp.onEndEdit.AddListener(delegate { AddCustomTag(fieldComp, ref Tags.sexTypes, ref CustomTags.sexTypes); });
 | 
			
		||||
            fieldComp.onEndEdit.AddListener(delegate { AddCustomTag(fieldComp, ref DefaultTags.sexTypes, ref CustomTags.sexTypes); });
 | 
			
		||||
        }
 | 
			
		||||
 | 
			
		||||
        public void Reset()
 | 
			
		||||
| 
						 | 
				
			
			
 | 
			
		|||
| 
						 | 
				
			
			@ -12,7 +12,7 @@ namespace RimWorldAnimationStudio
 | 
			
		|||
    {
 | 
			
		||||
        public override void Initialize(bool addedNewTag = false)
 | 
			
		||||
        {
 | 
			
		||||
            IEnumerable<string> allTags = Tags.soundDefs.Concat(CustomTags.soundDefs);
 | 
			
		||||
            IEnumerable<string> allTags = DefaultTags.soundDefs.Concat(CustomTags.soundDefs);
 | 
			
		||||
            string placeHolderText = "Enter new sound def...";
 | 
			
		||||
 | 
			
		||||
            if (Workspace.animationDef == null) return;
 | 
			
		||||
| 
						 | 
				
			
			@ -28,15 +28,15 @@ namespace RimWorldAnimationStudio
 | 
			
		|||
                _optionToggle.Find("Text").GetComponent<Text>().text = tag;
 | 
			
		||||
 | 
			
		||||
                Toggle toggleComp = _optionToggle.GetComponent<Toggle>();
 | 
			
		||||
                toggleComp.isOn = Workspace.Instance.GetCurrentOrPreviousKeyframe(Workspace.actorID)?.soundEffect == tag;
 | 
			
		||||
                toggleComp.isOn = Workspace.GetCurrentOrPreviousKeyframe(Workspace.ActorID)?.SoundEffect == tag;
 | 
			
		||||
                toggleComp.onValueChanged.AddListener(delegate 
 | 
			
		||||
                {
 | 
			
		||||
                    PawnKeyframe keyframe = Workspace.Instance.GetCurrentOrPreviousKeyframe(Workspace.actorID);
 | 
			
		||||
                    PawnKeyframe keyframe = Workspace.GetCurrentOrPreviousKeyframe(Workspace.ActorID);
 | 
			
		||||
 | 
			
		||||
                    if (keyframe != null)
 | 
			
		||||
                    { keyframe.soundEffect = tag; }
 | 
			
		||||
                    { keyframe.SoundEffect = tag; }
 | 
			
		||||
                    
 | 
			
		||||
                    Workspace.Instance.RecordEvent("Keyframe sound effect");
 | 
			
		||||
                    Workspace.RecordEvent("Keyframe sound effect");
 | 
			
		||||
                });
 | 
			
		||||
 | 
			
		||||
                if (CustomTags.soundDefs.Contains(tag))
 | 
			
		||||
| 
						 | 
				
			
			@ -56,7 +56,7 @@ namespace RimWorldAnimationStudio
 | 
			
		|||
            _optionField.Find("Placeholder").GetComponent<Text>().text = placeHolderText;
 | 
			
		||||
 | 
			
		||||
            InputField fieldComp = _optionField.GetComponent<InputField>();
 | 
			
		||||
            fieldComp.onEndEdit.AddListener(delegate { AddCustomTag(fieldComp, ref Tags.soundDefs, ref CustomTags.soundDefs); });
 | 
			
		||||
            fieldComp.onEndEdit.AddListener(delegate { AddCustomTag(fieldComp, ref DefaultTags.soundDefs, ref CustomTags.soundDefs); });
 | 
			
		||||
        }
 | 
			
		||||
 | 
			
		||||
        public void Reset()
 | 
			
		||||
| 
						 | 
				
			
			
 | 
			
		|||
| 
						 | 
				
			
			@ -28,19 +28,19 @@ namespace RimWorldAnimationStudio
 | 
			
		|||
        private int dragTickStart = -1;
 | 
			
		||||
 | 
			
		||||
        public KeyframeSlider linkedSlider;
 | 
			
		||||
        public Keyframe pivotKeyframe;
 | 
			
		||||
        public PawnKeyframe pivotKeyframe;
 | 
			
		||||
        public int linkedOffset;
 | 
			
		||||
 | 
			
		||||
        public void Initialize(AnimationTimeline timeline, int actorID, int keyframeID)
 | 
			
		||||
        {
 | 
			
		||||
            this.timeline = timeline;
 | 
			
		||||
            this.clip = Workspace.Instance.GetPawnAnimationClip(actorID);
 | 
			
		||||
            this.keyframe = Workspace.Instance.GetPawnKeyframe(actorID, keyframeID);
 | 
			
		||||
            this.clip = Workspace.GetPawnAnimationClip(actorID);
 | 
			
		||||
            this.keyframe = Workspace.GetPawnKeyframe(actorID, keyframeID);
 | 
			
		||||
 | 
			
		||||
            this.actorID = actorID;
 | 
			
		||||
            this.keyframeID = keyframeID;
 | 
			
		||||
 | 
			
		||||
            PawnKeyframe keyframe = Workspace.Instance.GetPawnKeyframe(actorID, keyframeID);
 | 
			
		||||
            PawnKeyframe keyframe = Workspace.GetPawnKeyframe(actorID, keyframeID);
 | 
			
		||||
            maxValue = Workspace.StageWindowSize;
 | 
			
		||||
            value = keyframe.atTick.Value;
 | 
			
		||||
           
 | 
			
		||||
| 
						 | 
				
			
			@ -85,7 +85,7 @@ namespace RimWorldAnimationStudio
 | 
			
		|||
 | 
			
		||||
        public int GetGhostFramesRequired()
 | 
			
		||||
        {
 | 
			
		||||
            if (Workspace.animationDef.animationStages[Workspace.stageID].isLooping == false)
 | 
			
		||||
            if (Workspace.animationDef.AnimationStages[Workspace.StageID].IsLooping == false)
 | 
			
		||||
            { return 0; }
 | 
			
		||||
 | 
			
		||||
            if (clip.duration <= 1)
 | 
			
		||||
| 
						 | 
				
			
			@ -96,7 +96,7 @@ namespace RimWorldAnimationStudio
 | 
			
		|||
 | 
			
		||||
        public void OnPointerClick(PointerEventData eventData)
 | 
			
		||||
        {
 | 
			
		||||
            Workspace.actorID = actorID;
 | 
			
		||||
            Workspace.ActorID = actorID;
 | 
			
		||||
            
 | 
			
		||||
            if (Input.GetKey(KeyCode.LeftControl) || Input.GetKey(KeyCode.LeftCommand))
 | 
			
		||||
            { Workspace.keyframeID.Add(keyframeID); }
 | 
			
		||||
| 
						 | 
				
			
			@ -105,19 +105,19 @@ namespace RimWorldAnimationStudio
 | 
			
		|||
            { Workspace.keyframeID = new List<int> { keyframeID }; }
 | 
			
		||||
 | 
			
		||||
            if (eventData.clickCount >= 2)
 | 
			
		||||
            { AnimationController.Instance.stageTick = keyframe.atTick.Value; }
 | 
			
		||||
            { Workspace.StageTick = keyframe.atTick.Value; }
 | 
			
		||||
        }
 | 
			
		||||
 | 
			
		||||
        public void OnBeginDrag(PointerEventData eventData)
 | 
			
		||||
        {
 | 
			
		||||
            Workspace.actorID = actorID;
 | 
			
		||||
            Workspace.ActorID = actorID;
 | 
			
		||||
            dragTimeStart = Time.unscaledTime;
 | 
			
		||||
            dragTickStart = keyframe.atTick.Value;
 | 
			
		||||
 | 
			
		||||
            if (Workspace.keyframeID.NullOrEmpty() || Workspace.keyframeID.Contains(keyframeID) == false)
 | 
			
		||||
            { Workspace.keyframeID = new List<int> { keyframeID }; }
 | 
			
		||||
 | 
			
		||||
            List<PawnKeyframe> selectedKeyframes = Workspace.Instance.GetPawnKeyframesByID(Workspace.keyframeID).Except(new List<PawnKeyframe>() { keyframe })?.ToList();
 | 
			
		||||
            List<PawnKeyframe> selectedKeyframes = Workspace.GetPawnKeyframesByID(Workspace.keyframeID).Except(new List<PawnKeyframe>() { keyframe })?.ToList();
 | 
			
		||||
 | 
			
		||||
            // Link other slected keyframes to the movement of this one
 | 
			
		||||
            if (selectedKeyframes.NotNullOrEmpty())
 | 
			
		||||
| 
						 | 
				
			
			@ -143,7 +143,7 @@ namespace RimWorldAnimationStudio
 | 
			
		|||
 | 
			
		||||
        public override void OnDrag(PointerEventData eventData)
 | 
			
		||||
        {
 | 
			
		||||
            Workspace.actorID = actorID;
 | 
			
		||||
            Workspace.ActorID = actorID;
 | 
			
		||||
 | 
			
		||||
            // The first keyframe can't be moved
 | 
			
		||||
            if (keyframe.atTick == Constants.minTick)
 | 
			
		||||
| 
						 | 
				
			
			@ -157,7 +157,7 @@ namespace RimWorldAnimationStudio
 | 
			
		|||
 | 
			
		||||
            // Snap to nearest keyframe (on another timeline)
 | 
			
		||||
            int targetTick = Workspace.FindClosestKeyFrameAtTick(keyframe.atTick.Value, Mathf.CeilToInt(Workspace.StageWindowSize * 0.01f), actorID);
 | 
			
		||||
            if (Input.GetKey(KeyCode.LeftShift) && Workspace.Instance.DoesPawnKeyframeExistAtTick(Workspace.stageID, actorID, targetTick) == false)
 | 
			
		||||
            if (Input.GetKey(KeyCode.LeftShift) && Workspace.DoesPawnKeyframeExistAtTick(Workspace.StageID, actorID, targetTick) == false)
 | 
			
		||||
            { value = (float)targetTick; }
 | 
			
		||||
 | 
			
		||||
            // Prevent other frames from being moved to the first keyframe
 | 
			
		||||
| 
						 | 
				
			
			@ -170,13 +170,13 @@ namespace RimWorldAnimationStudio
 | 
			
		|||
            if (keyframe.atTick == Constants.minTick)
 | 
			
		||||
            { value = Constants.minTick; return; }
 | 
			
		||||
 | 
			
		||||
            List<PawnKeyframe> keyframesToCheck = Workspace.Instance.GetPawnKeyframesAtTick(actorID, keyframe.atTick.Value);
 | 
			
		||||
            List<PawnKeyframe> keyframesToCheck = Workspace.GetAllPawnKeyframesAtTick(actorID, keyframe.atTick.Value);
 | 
			
		||||
            if (keyframesToCheck.NotNullOrEmpty())
 | 
			
		||||
            {
 | 
			
		||||
                foreach (PawnKeyframe _keyframe in keyframesToCheck)
 | 
			
		||||
                {
 | 
			
		||||
                    if (_keyframe != keyframe)
 | 
			
		||||
                    { AnimationController.Instance.RemovePawnKeyframe(actorID, _keyframe.keyframeID); }
 | 
			
		||||
                    { Workspace.GetCurrentPawnAnimationClip().RemovePawnKeyframe(actorID, _keyframe.keyframeID); }
 | 
			
		||||
                }
 | 
			
		||||
            }
 | 
			
		||||
 | 
			
		||||
| 
						 | 
				
			
			@ -189,14 +189,14 @@ namespace RimWorldAnimationStudio
 | 
			
		|||
 | 
			
		||||
                    if (linkedSlider.linkedSlider != null)
 | 
			
		||||
                    {
 | 
			
		||||
                        keyframesToCheck = Workspace.Instance.GetPawnKeyframesAtTick(actorID, linkedKeyframe.atTick.Value);
 | 
			
		||||
                        keyframesToCheck = Workspace.GetAllPawnKeyframesAtTick(actorID, linkedKeyframe.atTick.Value);
 | 
			
		||||
 | 
			
		||||
                        if (keyframesToCheck.NotNullOrEmpty() && keyframesToCheck.Count > 1)
 | 
			
		||||
                        {
 | 
			
		||||
                            foreach (PawnKeyframe _keyframe in keyframesToCheck)
 | 
			
		||||
                            {
 | 
			
		||||
                                if (_keyframe.keyframeID != linkedKeyframe.keyframeID)
 | 
			
		||||
                                { AnimationController.Instance.RemovePawnKeyframe(actorID, _keyframe.keyframeID); Debug.Log("delete"); }
 | 
			
		||||
                                { Workspace.GetCurrentPawnAnimationClip().RemovePawnKeyframe(actorID, _keyframe.keyframeID); Debug.Log("delete"); }
 | 
			
		||||
                            }
 | 
			
		||||
                        }
 | 
			
		||||
                    }
 | 
			
		||||
| 
						 | 
				
			
			@ -208,7 +208,7 @@ namespace RimWorldAnimationStudio
 | 
			
		|||
 | 
			
		||||
            interactable = false;
 | 
			
		||||
 | 
			
		||||
            Workspace.Instance.RecordEvent("Keyframe move");
 | 
			
		||||
            Workspace.RecordEvent("Keyframe move");
 | 
			
		||||
        }
 | 
			
		||||
 | 
			
		||||
        protected override void Update()
 | 
			
		||||
| 
						 | 
				
			
			@ -229,20 +229,20 @@ namespace RimWorldAnimationStudio
 | 
			
		|||
            { value = keyframe.atTick.Value; }
 | 
			
		||||
 | 
			
		||||
            // Update key color
 | 
			
		||||
            if (keyframe.atTick.HasValue && Workspace.keyframeID.Contains(keyframeID) && AnimationController.Instance.stageTick == keyframe.atTick.Value)
 | 
			
		||||
            if (keyframe.atTick.HasValue && Workspace.keyframeID.Contains(keyframeID) && Workspace.StageTick == keyframe.atTick.Value)
 | 
			
		||||
            { handleImage.color = Constants.ColorPurple; }
 | 
			
		||||
 | 
			
		||||
            else if (Workspace.keyframeID.Contains(keyframeID))
 | 
			
		||||
            { handleImage.color = Constants.ColorCyan; }
 | 
			
		||||
 | 
			
		||||
            else if (AnimationController.Instance.stageTick == keyframe.atTick.Value)
 | 
			
		||||
            else if (Workspace.StageTick == keyframe.atTick.Value)
 | 
			
		||||
            { handleImage.color = Constants.ColorPink; }
 | 
			
		||||
 | 
			
		||||
            else
 | 
			
		||||
            { handleImage.color = Constants.ColorGrey; }
 | 
			
		||||
 | 
			
		||||
            // Show sound symbol
 | 
			
		||||
            string soundDef = Workspace.Instance.GetPawnKeyframe(actorID, keyframeID)?.soundEffect;
 | 
			
		||||
            string soundDef = Workspace.GetPawnKeyframe(actorID, keyframeID)?.SoundEffect;
 | 
			
		||||
            soundIcon.SetActive(soundDef != null && soundDef != "" && soundDef != "None");
 | 
			
		||||
        }
 | 
			
		||||
 | 
			
		||||
| 
						 | 
				
			
			@ -253,7 +253,7 @@ namespace RimWorldAnimationStudio
 | 
			
		|||
            return (float)(keyframe.atTick.Value - pivotKeyframe.atTick.Value) / (dragTickStart - pivotKeyframe.atTick.Value);
 | 
			
		||||
        }
 | 
			
		||||
 | 
			
		||||
        public bool IsPivotKeyframe(Keyframe otherKeyframe)
 | 
			
		||||
        public bool IsPivotKeyframe(PawnKeyframe otherKeyframe)
 | 
			
		||||
        {
 | 
			
		||||
            return pivotKeyframe == otherKeyframe;
 | 
			
		||||
        }
 | 
			
		||||
| 
						 | 
				
			
			
 | 
			
		|||
| 
						 | 
				
			
			@ -9,18 +9,18 @@ namespace RimWorldAnimationStudio
 | 
			
		|||
    {
 | 
			
		||||
        public void Update()
 | 
			
		||||
        {
 | 
			
		||||
            PawnKeyframe keyframe = Workspace.Instance.GetCurrentOrPreviousKeyframe(Workspace.actorID);
 | 
			
		||||
            GetComponent<Toggle>().isOn = keyframe != null && keyframe.quiver.HasValue && keyframe.quiver.Value;
 | 
			
		||||
            PawnKeyframe keyframe = Workspace.GetCurrentOrPreviousKeyframe(Workspace.ActorID);
 | 
			
		||||
            GetComponent<Toggle>().isOn = keyframe != null && keyframe.Quiver;
 | 
			
		||||
        }
 | 
			
		||||
 | 
			
		||||
        public void OnValueChanged()
 | 
			
		||||
        {
 | 
			
		||||
            PawnKeyframe keyframe = Workspace.Instance.GetCurrentOrPreviousKeyframe(Workspace.actorID);
 | 
			
		||||
            PawnKeyframe keyframe = Workspace.GetCurrentOrPreviousKeyframe(Workspace.ActorID);
 | 
			
		||||
 | 
			
		||||
            if (keyframe != null)
 | 
			
		||||
            { keyframe.quiver = GetComponent<Toggle>().isOn; }
 | 
			
		||||
            { keyframe.Quiver = GetComponent<Toggle>().isOn; }
 | 
			
		||||
 | 
			
		||||
            Workspace.Instance.RecordEvent("Actor quiver");
 | 
			
		||||
            Workspace.RecordEvent("Actor quiver");
 | 
			
		||||
        }
 | 
			
		||||
    }
 | 
			
		||||
}
 | 
			
		||||
| 
						 | 
				
			
			
 | 
			
		|||
| 
						 | 
				
			
			@ -18,10 +18,10 @@ namespace RimWorldAnimationStudio
 | 
			
		|||
        {
 | 
			
		||||
            if (Workspace.animationDef == null) return;
 | 
			
		||||
 | 
			
		||||
            PawnAnimationClip clip = Workspace.Instance.GetCurrentPawnAnimationClip();
 | 
			
		||||
            PawnAnimationClip clip = Workspace.GetCurrentPawnAnimationClip();
 | 
			
		||||
    
 | 
			
		||||
            if (clip != null)
 | 
			
		||||
            { text.text = clip.layer; }
 | 
			
		||||
            { text.text = clip.Layer; }
 | 
			
		||||
 | 
			
		||||
            else 
 | 
			
		||||
            { text.text = "Pawn"; }
 | 
			
		||||
| 
						 | 
				
			
			
 | 
			
		|||
| 
						 | 
				
			
			@ -1,70 +0,0 @@
 | 
			
		|||
using System.Collections;
 | 
			
		||||
using System.Collections.Generic;
 | 
			
		||||
using System.Linq;
 | 
			
		||||
using UnityEngine;
 | 
			
		||||
using UnityEngine.UI;
 | 
			
		||||
 | 
			
		||||
namespace RimWorldAnimationStudio
 | 
			
		||||
{
 | 
			
		||||
    public class SelectRaceDropdown : MonoBehaviour
 | 
			
		||||
    {
 | 
			
		||||
        private Dropdown dropdown;
 | 
			
		||||
        private Text label;
 | 
			
		||||
 | 
			
		||||
        private int actorID = -1;
 | 
			
		||||
        private int hashcode = -1;
 | 
			
		||||
        
 | 
			
		||||
        public void OnEnable()
 | 
			
		||||
        {
 | 
			
		||||
            dropdown = GetComponent<Dropdown>();
 | 
			
		||||
            label = transform.Find("Label").GetComponent<Text>();
 | 
			
		||||
        }
 | 
			
		||||
 | 
			
		||||
        public void Update()
 | 
			
		||||
        {
 | 
			
		||||
            //if (Workspace.animationDef == null) return;
 | 
			
		||||
 | 
			
		||||
            //if (actorID != Workspace.actorID || hashcode != CustomTags.defNames.GetHashCode())
 | 
			
		||||
            //{ UpdateDropdown(); }
 | 
			
		||||
 | 
			
		||||
            if (hashcode != CustomTags.defNames.GetHashCode())
 | 
			
		||||
            { UpdateDropdown(); }
 | 
			
		||||
        }
 | 
			
		||||
 | 
			
		||||
        public void UpdateDropdown()
 | 
			
		||||
        {
 | 
			
		||||
            if (dropdown == null)
 | 
			
		||||
            { OnEnable(); }
 | 
			
		||||
 | 
			
		||||
            dropdown.ClearOptions();
 | 
			
		||||
 | 
			
		||||
            /*string alienRaceDefName = Workspace.animationDef.actors[Workspace.actorID].GetAlienRaceDef().defName;
 | 
			
		||||
            
 | 
			
		||||
            dropdown.ClearOptions();
 | 
			
		||||
            dropdown.options.Add(new Dropdown.OptionData(alienRaceDefName));*/
 | 
			
		||||
 | 
			
		||||
            IEnumerable<string> optionsList = Tags.defNames.Concat(CustomTags.defNames);
 | 
			
		||||
            foreach (string defName in optionsList)
 | 
			
		||||
            {
 | 
			
		||||
                //if (defName != alienRaceDefName)
 | 
			
		||||
                //{ dropdown.options.Add(new Dropdown.OptionData(defName)); }
 | 
			
		||||
 | 
			
		||||
                dropdown.options.Add(new Dropdown.OptionData(defName));
 | 
			
		||||
            }
 | 
			
		||||
 | 
			
		||||
            dropdown.value = 0;
 | 
			
		||||
            label.text = dropdown.options[0].text;
 | 
			
		||||
 | 
			
		||||
            //actorID = Workspace.actorID;
 | 
			
		||||
            hashcode = CustomTags.defNames.GetHashCode();
 | 
			
		||||
        }
 | 
			
		||||
 | 
			
		||||
        public void UpdateActorRace()
 | 
			
		||||
        {
 | 
			
		||||
            if (Workspace.animationDef == null) return;
 | 
			
		||||
 | 
			
		||||
            Workspace.animationDef.actors[Workspace.actorID].SetAlienRaceDef(label.text);
 | 
			
		||||
            Workspace.selectedBodyPart = null;
 | 
			
		||||
        }
 | 
			
		||||
    }
 | 
			
		||||
}
 | 
			
		||||
| 
						 | 
				
			
			@ -1,11 +0,0 @@
 | 
			
		|||
fileFormatVersion: 2
 | 
			
		||||
guid: 0ba5b69d448f9434ca7d74d4022f3dcd
 | 
			
		||||
MonoImporter:
 | 
			
		||||
  externalObjects: {}
 | 
			
		||||
  serializedVersion: 2
 | 
			
		||||
  defaultReferences: []
 | 
			
		||||
  executionOrder: 0
 | 
			
		||||
  icon: {instanceID: 0}
 | 
			
		||||
  userData: 
 | 
			
		||||
  assetBundleName: 
 | 
			
		||||
  assetBundleVariant: 
 | 
			
		||||
							
								
								
									
										8
									
								
								Assets/Scripts/GUI/SelfContained.meta
									
										
									
									
									
										Normal file
									
								
							
							
						
						
									
										8
									
								
								Assets/Scripts/GUI/SelfContained.meta
									
										
									
									
									
										Normal file
									
								
							| 
						 | 
				
			
			@ -0,0 +1,8 @@
 | 
			
		|||
fileFormatVersion: 2
 | 
			
		||||
guid: 96cc86ae315a7c34c91b9af2499fa23c
 | 
			
		||||
folderAsset: yes
 | 
			
		||||
DefaultImporter:
 | 
			
		||||
  externalObjects: {}
 | 
			
		||||
  userData: 
 | 
			
		||||
  assetBundleName: 
 | 
			
		||||
  assetBundleVariant: 
 | 
			
		||||
							
								
								
									
										8
									
								
								Assets/Scripts/GUI/SexProps.meta
									
										
									
									
									
										Normal file
									
								
							
							
						
						
									
										8
									
								
								Assets/Scripts/GUI/SexProps.meta
									
										
									
									
									
										Normal file
									
								
							| 
						 | 
				
			
			@ -0,0 +1,8 @@
 | 
			
		|||
fileFormatVersion: 2
 | 
			
		||||
guid: 9171c89c691f71d4eb37426db074efc8
 | 
			
		||||
folderAsset: yes
 | 
			
		||||
DefaultImporter:
 | 
			
		||||
  externalObjects: {}
 | 
			
		||||
  userData: 
 | 
			
		||||
  assetBundleName: 
 | 
			
		||||
  assetBundleVariant: 
 | 
			
		||||
Some files were not shown because too many files have changed in this diff Show more
		Loading…
	
	Add table
		Add a link
		
	
		Reference in a new issue