Hi
@AshenWaltz
I have been working on custom tactics and behaviors and this is how I approached this problem.
First, as skoomy said, it is better to inherit from an existing Behavior so the formation is properly set in the part of the code you cannot reach.
If you inherit classes such as BehaviorDefend or BehaviorCharge, there will be a public constructor taking the formation parameter.
This is the start of my CustomBehavior class:
C#:
internal class CustomBehavior : BehaviorDefend
{
public CustomBehavior(Formation formation) : base(formation)
{
}
// more stuff
}
Then, I create my own Formation attribute inside my CustomBehavior to be able to mess around with the formation methods and attributes.
(this attribute will basically be a duplicate of the unreachable one)
This is in my CustomBehavior class:
C#:
private void DoStuffExample()
{
Formation.MovementOrder = MovementOrder.MovementOrderAdvance;
Formation.FacingOrder = FacingOrder.FacingOrderLookAtEnemy;
Formation.ArrangementOrder = ArrangementOrder.ArrangementOrderShieldWall;
Formation.FiringOrder = FiringOrder.FiringOrderFireAtWill;
Formation.WeaponUsageOrder = WeaponUsageOrder.WeaponUsageOrderUseAny;
Formation.ApplyActionOnEachUnit(ProcessAgent);
}
public Formation Formation;
Then, when I assign this behavior to a formation (in a Tactic class), I set the attribute.
This is in my CustomTactic class:
C#:
CustomBehavior behavior = _mainInfantry.AI.SetBehaviorWeight<CustomBehavior>(1f);
behavior.Formation = _mainInfantry;
Hope it helps.