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 animationStages; public List contexts; public List offsetDefs; public bool canAnimationBeUsed(List actors, out int reorder) { if (RJWAnimationSettings.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 GetAllAnimationsForActor(int actor, int seed, int reorder = 0) { List animations = new List(); 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 bool GetOffset(int actor, Pawn pawn, out Vector3? position, out int? rotation, int reorder = 0) { position = null; rotation = null; //element at or default to stop errors 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; } } }