Skip to content

Creating a Cyclops Charger

PrimeSonic edited this page Mar 26, 2021 · 5 revisions

Your Cyclops Charger is a new class where you will add all the code that will provide energy for the Cyclops to consume.

Create a new class that inherits from CyclopsCharger.

using MoreCyclopsUpgrades.API;
using MoreCyclopsUpgrades.API.Charging;

internal class MySubCharger : CyclopsCharger
{
    public MySubCharger(SubRoot subroot) : base(subroot)
    {
    }
}

There are 6 abstract members you will need to implement from here.

abstract Member Type Notes
TotalReserveEnergy get Property If the charger has its own store of energy, return the total available reserve power; Otherwise return 0f.
GenerateNewEnergy Method Produce power for the Cyclops using energy from the environment.
DrainReserveEnergy Method Produce power for the Cyclops taking energy from the limited, internal reserves of this charger.
StatusSprite Method The sprite to use for the power indicator icon. Only displayed when ShowStatusIcon is true.
StatusText Method Any short text to display under the power indicator icon. Only displayed when ShowStatusIcon is true.
StatusTextColor Method The color to use for the text displayed under the power indicator icon. Only displayed when ShowStatusIcon is true.

There is also a protected constructor that takes a SubRoot parameter which you will need to chain back to.

Implementing this class will get your charger working with the MCU Power Indicator Icons, which display realtime info about which chargers are currently providing the cyclops with energy.

You will have access to the follow public members from the CyclopsCharger and CyclopsStatusIcon parent classes

public Member Type Nodes
Cyclops readonly SubRoot Field A reference to the Cyclops that this Charger is attached to.
ShowStatusIcon bool get Property Indicates if this charger's power indicator icon will be displayed.
Returns true if ProvidingPower or HasReservePower are true.
ProvidingPower bool get Property Indicates if this charger is actively providing energy to the Cyclops in this cycle.
HasReservePower bool get Property Indicates if this charger has reserve power that can be used when needed.

Remember: You should not be charging the Cyclops directly from here.
Leave that up to MoreCyclopsUpgrades to manage.

For some sample code, you can check out the Cyclops Simple Solar Charger.

Clone this wiki locally
  翻译: