2024-04-17 23:57:18 +00:00
|
|
|
|
using System;
|
|
|
|
|
using System.Collections.Generic;
|
|
|
|
|
using System.Linq;
|
|
|
|
|
using System.Text;
|
|
|
|
|
using System.Threading.Tasks;
|
2024-04-22 01:49:24 +00:00
|
|
|
|
using UnityEngine;
|
2024-04-17 23:57:18 +00:00
|
|
|
|
using Verse;
|
|
|
|
|
|
|
|
|
|
namespace Rimworld_Animations
|
|
|
|
|
{
|
|
|
|
|
public class GroupAnimationDef : Def
|
|
|
|
|
{
|
|
|
|
|
public int numActors;
|
|
|
|
|
public List<AnimationStage> animationStages;
|
|
|
|
|
public List<BaseGroupAnimationContext> contexts;
|
2024-04-22 01:49:24 +00:00
|
|
|
|
public List<AnimationOffsetDef> offsetDefs;
|
2024-04-17 23:57:18 +00:00
|
|
|
|
|
|
|
|
|
|
|
|
|
|
public bool canAnimationBeUsed(List<Pawn> actors, out int reorder)
|
|
|
|
|
{
|
2024-04-23 20:53:13 +00:00
|
|
|
|
if (RJWAnimationSettings.debugMode)
|
2024-04-18 22:32:31 +00:00
|
|
|
|
{
|
|
|
|
|
Log.Message("[anims] Checking if " + defName + " is valid animation");
|
|
|
|
|
}
|
|
|
|
|
|
2024-04-17 23:57:18 +00:00
|
|
|
|
|
|
|
|
|
foreach (BaseGroupAnimationContext context in contexts)
|
|
|
|
|
{
|
|
|
|
|
if (context.CanAnimationBeUsed(actors, out reorder))
|
|
|
|
|
{
|
|
|
|
|
return true;
|
|
|
|
|
}
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
reorder = 0;
|
|
|
|
|
return false;
|
|
|
|
|
}
|
2024-04-18 22:32:31 +00:00
|
|
|
|
|
|
|
|
|
public List<AnimationDef> GetAllAnimationsForActor(int actor, int seed, int reorder = 0)
|
|
|
|
|
{
|
|
|
|
|
List<AnimationDef> animations = new List<AnimationDef>();
|
|
|
|
|
int actorNumber = (actor + reorder) % numActors;
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
foreach (AnimationStage stage in animationStages)
|
|
|
|
|
{
|
|
|
|
|
//add all new animations to list of animations
|
|
|
|
|
animations.AddRange(stage.GetAnimations(actorNumber, seed));
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
return animations;
|
|
|
|
|
}
|
2024-04-22 01:49:24 +00:00
|
|
|
|
|
2024-04-23 20:53:13 +00:00
|
|
|
|
public bool GetOffset(int actor, Pawn pawn, out Vector3? position, out int? rotation, int reorder = 0)
|
2024-04-22 01:49:24 +00:00
|
|
|
|
{
|
2024-04-23 20:53:13 +00:00
|
|
|
|
|
|
|
|
|
position = null;
|
|
|
|
|
rotation = null;
|
|
|
|
|
|
2024-04-22 01:49:24 +00:00
|
|
|
|
//element at or default to stop errors
|
2024-04-23 20:53:13 +00:00
|
|
|
|
if (offsetDefs == null) return false;
|
|
|
|
|
if ((actor + reorder) % numActors >= offsetDefs.Count) return false;
|
|
|
|
|
if (offsetDefs[(actor + reorder) % numActors].FindOffset(pawn, out BaseAnimationOffset animationOffset))
|
|
|
|
|
{
|
|
|
|
|
position = animationOffset.getOffset(pawn);
|
|
|
|
|
rotation = animationOffset.getRotation(pawn);
|
|
|
|
|
return true;
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
return false;
|
2024-04-22 01:49:24 +00:00
|
|
|
|
}
|
2024-04-17 23:57:18 +00:00
|
|
|
|
}
|
|
|
|
|
}
|