-
-
Notifications
You must be signed in to change notification settings - Fork 2
Quick References
Blanc Faye edited this page May 17, 2021
·
8 revisions
The mod itself uses the API to implement the Beam Drone (LaserDrone1
) which is a custom entity along with its custom attack (FireLaser
). This custom drone also has Option Support. Use it for reference on using the API.
myCustomDronesList = DroneCatalog.Initialize("com.awesome.mod.guid", someConfigFile);
DroneCatalog.SetupAll(myCustomDronesList);
public class MyCustomDrone : Drone<MyCustomDrone>
// This will only work after DroneCatalog.Initialize() is done
MyCustomDrone drone = MyCustomDrone.instance;
drone.enabled; // true or false
protected override void SetupConfig()
{
base.SetupConfig();
// other code
}
// For PostSetup, it is ideal to call the base method last
protected override void PostSetup()
{
// other code
base.PostSetup();
}
GradiusOption.instance.FireForAllOptions(droneBody, (option, behavior, target, direction) =>
{
new BulletAttack
{
owner = droneBody.gameObject,
weapon = option,
// remember to multiply damageMultiplier so that the config option
// for GradiusOption is respected for your custom drone
damage = damage * coefficient * GradiusOption.instance.damageMultiplier,
// do the same for force
force = force * GradiusOption.instance.damageMultiplier,
// other initialization here
}.Fire();
});
// ChargeState.cs
// One may store effect data or child locators in OptionBehavior behavior through
// the Data Dictionary so that they can be accessed in between states or classes
public override OnEnter()
{
OptionBehavior behavior = option.GetComponent<OptionBehavior>();
behavior.unityData["MuzzleEffect"] = UnityEngine.Object.Instantiate(myPrefab);
myPrefab.someField = true;
}
// FiringState.cs
public override FixedUpdate()
{
OptionBehavior behavior = option.GetComponent<OptionBehavior>();
// Access the stored data for usage
GameObject myEffect = (GameObject)behavior.unityData["MuzzleEffect"];
myEffect.someField = false;
}
Home | API Documentation | API References | Features | Contact | Changelog