Show / Hide Table of Contents

Class PowerGrid

Represents a power grid. A PowerGrid is a collection of PowerGridComponents that all share the same energy type. A power grid is always fully connected. The three major operations on a power grid are Join(PowerGridComponent, PowerGridComponent), DisconnectAndSplit(PowerGridComponent), and Tick(). PowerGrid is not thread safe.

Inheritance
System.Object
PowerGrid
Implements
IController
IViewController
IHasUniversalID
Namespace: Eco.Gameplay.PowerGrids
Assembly: Eco.Gameplay.dll
Syntax
public class PowerGrid : Object, IController, IViewController, IHasUniversalID
Remarks

A PowerGrid automatically registers itself to PowerGridManager when it is constructed. To de-register the PowerGrid, use the Cleanup() function. Internally, the PowerGridComponents are stored as an undirected graph in adjacency set representation. PowerGrids are not stored. They are re-constructed every time the server loads the world.

Constructors

PowerGrid(PowerGridComponent)

Declaration
public PowerGrid(PowerGridComponent component)
Parameters
Type Name Description
PowerGridComponent component

Fields

EnergyType

Declaration
public readonly IPowerEnergyType EnergyType
Field Value
Type Description
IPowerEnergyType

Properties

ComponentCount

Declaration
public int ComponentCount { get; }
Property Value
Type Description
System.Int32

Components

Declaration
public IEnumerable<PowerGridComponent> Components { get; }
Property Value
Type Description
System.Collections.Generic.IEnumerable<PowerGridComponent>

ControllerID

Declaration
public ref int ControllerID { get; }
Property Value
Type Description
System.Int32

Efficiency

Declaration
public float Efficiency { get; }
Property Value
Type Description
System.Single

EnergyDemand

Declaration
public float EnergyDemand { get; }
Property Value
Type Description
System.Single

EnergySupply

Declaration
public float EnergySupply { get; }
Property Value
Type Description
System.Single

EnergyTypeName

Declaration
public string EnergyTypeName { get; }
Property Value
Type Description
System.String

Load

Declaration
public float Load { get; }
Property Value
Type Description
System.Single

Methods

Cleanup()

Clears internal storage and removes this power grid from PowerGridManager, which will stop ticking this power grid. Call this function when the power grid should be destroyed.

Declaration
public void Cleanup()

DisconnectAndSplit(PowerGridComponent)

Remove a component from the power grid. Detect whether removing the component breaks the connected-ness of the power grid connection graph. If that is the case, split this power grid into multiple grids based on connected components.

Declaration
public void DisconnectAndSplit(PowerGridComponent disconnectComponent)
Parameters
Type Name Description
PowerGridComponent disconnectComponent

IsEmpty()

Declaration
public bool IsEmpty()
Returns
Type Description
System.Boolean

Join(PowerGridComponent, PowerGridComponent)

Add current to target's power grid and mark them as connected.

Declaration
public static void Join(PowerGridComponent current, PowerGridComponent target)
Parameters
Type Name Description
PowerGridComponent current
PowerGridComponent target

Tick()

Tick the power grid, update the stored power supply and demand. All power grids tick in parallel, so no race conditions allowed here.

Declaration
public void Tick()

TryAccumulate(Single, out Single)

Declaration
public bool TryAccumulate(float requestedAmount, out float accumulated)
Parameters
Type Name Description
System.Single requestedAmount
System.Single accumulated
Returns
Type Description
System.Boolean

Implements

IController
IViewController
IHasUniversalID

Extension Methods

TagUtils.TagNames(Object, Boolean)
TagUtils.TagDisplayNames(Object, Boolean)
ClientSetViewExtensions.SetClassOfProperty(Object, Player, String, String, Int32)
TypeTooltipExtensions.UILinkGeneric(Object)
☀
☾
In This Article
Back to top
Copyright (c) Strange Loop Games 2021
☀
☾