How to use RTS KIT features modules in my own?

If you’re inherited your custom module from the core Module class as it shown in previous section, you can get access to the other modules by Unit component, it contains method to get any other modules, if they added to the unit:

using UnityEngine;
using InsaneSystems.RTSStarterKit;

public class CustomModule : Module
{
  void Start()
  {
    SelfUnit.GetModule<Damageable>().TakeDamage(25); // will damage a unit with 25 damage value.

    if (SelfUnit.TryGetModule<Attackable>(out var attackable))
      Debug.Log(attackable.AttackTarget); // will print attack target of the Attackable module, if unit has it.

    // etc, check API Reference for more info
  }
}

You can use TryGetModule method, if you are not sure that it exist on a unit object.

To send a new order to a unit, use SelfUnit.AddOrder method. You can send move, follow and attack orders:

var moveOrder = new MovePositionOrder();
moveOrder.Position = new Vector3(32, 0, 32);

SelfUnit.AddOrder(moveOrder);