public static void ClearBehaviors(this ICurio curio) { foreach (var behavior in curio.GetBehaviors()) { behavior.Remove(); } }
public static void RemoveBehaviors(this ICurio curio, Predicate <Behavior> predicate) { foreach (var behavior in curio.GetBehaviors()) { if (predicate(behavior)) { behavior.Remove(); } } }
bool PerformSpecialAction() { var world = Curio.GetWorld(); var orientable = Curio.GetBehavior <BehaviorOrientable>(); var delta = world.PlayerCurio.GetVisualTarget() - Curio.GetVisualTarget(); var distance = delta.Length(); var attacks = Curio.GetBehaviors <IGruntAttack>().Shuffle(Random).OrderByDescending(x => x.Priority); foreach (var attack in attacks) { if (attack.CanUse()) { attack.Perform(); return(true); } } return(false); }
public static BehaviorActionHolder GetActionHolder(this ICurio curio, ActionSlot type) { return(curio.GetBehaviors <BehaviorActionHolder>().FirstOrDefault(x => x.Type == type)); }
public static Vector2 GetOffset(this ICurio curio) { return(curio.GetBehaviors().OfType <IOffseted>().OrderBy(x => x.GetOffsetPriority()).Aggregate(Vector2.Zero, (x, y) => x + y.GetOffset())); }
public static ColorMatrix GetColor(this ICurio curio) { return(curio.GetBehaviors().OfType <IColored>().OrderBy(x => x.GetColorPriority()).Aggregate(ColorMatrix.Identity, (x, y) => x * y.GetColor())); }