mirror of
https://gitgud.io/c0ffeeeeeeee/rimworld-animations.git
synced 2024-08-15 00:43:45 +00:00
62 lines
1.8 KiB
C#
62 lines
1.8 KiB
C#
using System;
|
|
using System.Collections.Generic;
|
|
using System.Linq;
|
|
using System.Text;
|
|
using System.Threading.Tasks;
|
|
using UnityEngine;
|
|
using Verse;
|
|
|
|
namespace Rimworld_Animations
|
|
{
|
|
public class GroupAnimationDef : Def
|
|
{
|
|
public int numActors;
|
|
public List<AnimationStage> animationStages;
|
|
public List<BaseGroupAnimationContext> contexts;
|
|
public List<AnimationOffsetDef> offsetDefs;
|
|
|
|
|
|
public bool canAnimationBeUsed(List<Pawn> actors, out int reorder)
|
|
{
|
|
if (AnimationSettings.debugMode)
|
|
{
|
|
Log.Message("[anims] Checking if " + defName + " is valid animation");
|
|
}
|
|
|
|
|
|
foreach (BaseGroupAnimationContext context in contexts)
|
|
{
|
|
if (context.CanAnimationBeUsed(actors, out reorder))
|
|
{
|
|
return true;
|
|
}
|
|
}
|
|
|
|
reorder = 0;
|
|
return false;
|
|
}
|
|
|
|
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;
|
|
}
|
|
|
|
public Vector3? GetOffset(int actor, Pawn pawn, int reorder = 0)
|
|
{
|
|
//element at or default to stop errors
|
|
if (offsetDefs == null) return null;
|
|
if ((actor + reorder) % numActors >= offsetDefs.Count) return null;
|
|
return offsetDefs[(actor + reorder) % numActors].FindOffset(pawn);
|
|
}
|
|
}
|
|
}
|