🔟 Values

From Cosmoteer Wiki
Modding/Components/Values
Jump to navigation Jump to search
CalloutIconWarning.png
Work in Progress
This page is currently WORK IN PROGRESS. Some things may be missing.

Feel free to contribute and don't worry about perfection - other editors can make corrections if necessary. Just get creating!

CalloutIconNote.png
Info
This entire page was updated with information gained from analysing the "Cosmoteer.dll" assembly for the "0.26.1d_steam" game version.

A value is a component that can be used to store and possibly transfer a number. It can be referenced to that end.

Technically, values implement the IPartComponentValue interface; here is it's definition:

Field list of IPartComponentValue
Name Type Description
ValueChanged event EventHandler<EventArgs> Invoked when the Value property changes.
Value float {get;} Gets the current value.

They have strong ties to 🔮Buffs.

Component list

Here is a list of components that can provide a value:

Components and inheritance
Name Category Short description

(click component for more details)

Code reference

(what's this?)

Inherits from
BaseResourceStorage 📦 Resource The base class for part sub-components that hold resources which can be used by other sub-components.


The provided value is the current (fulness) factor.

Cosmoteer.Ships.Parts.Resources.BaseResourceConverter PartComponent
BeamEmitter ⚙️ Other A weapon emitter that emits a straight beam. Cosmoteer.Ships.Parts.Weapons.BeamEmitter Emitter
BeamRegulator ⚙️ Other Regulates an output value based on the length of a beam. Cosmoteer.Ships.Parts.Weapons.BeamRegulator PartComponent
DistanceThreshold ↔️ Distance A part component that toggles on and off and provides a value depending on the distance provided by another component relative to a set distance. Cosmoteer.Ships.Parts.Logic.DistanceThreshold OperationalPartComponent
FtlDrive 🚀 Movement Allows the ship to perform FTL jumps. Cosmoteer.Ships.Parts.FltDrive OperationalPartComponent
BuffableValue 🔟 Value A part sub-component that provides a value that can be modified by a buff. Cosmoteer.Ships.Parts.Logic.PartBuffableValue PartComponent
ConstructionTracker ⚙️ Other Tracks the construction progress of a part. Cosmoteer.Ships.Parts.Logic.PartConstructionTracker OperationalPartComponent
DebugValue 🔟 Value A part value component whose value can be changed via the part debugger. Cosmoteer.Ships.Parts.Logic.PartDebugValue PartComponent
MultiValue 🔟 Value A part sub-component that combines multiple other value components into a single value component. Cosmoteer.Ships.Parts.Logic.PartMultiValue PartComponent
RoofOpacityValue 🔟 Value A part sub-component that provides the roof opacity as a value. Cosmoteer.Ships.Parts.Logic.PartRoofOpacityValue PartComponent
StaticValue 🔟 Value A part sub-component that stores a single unchanging float value usable by other components. Cosmoteer.Ships.Parts.Logic.PartStaticValue PartComponent
Stopwatch ⏲️ Timer A part sub-component that counts up at a rate based off a time scale multiplier. Cosmoteer.Ships.Parts.Logic.PartStopwatch OperationalPartComponent
Timer ⏲️ Timer A part sub-component that triggers after a certain amount of time. Cosmoteer.Ships.Parts.Logic.PartTimer OperationalPartComponent
ValueAccumulator 🔟 Value A part sub-component that accumulates and dissipates a value based on its state. Cosmoteer.Ships.Parts.Logic.PartValueAccumuletor OperationalPartComponent
ValueLerp 🔟 Value A part sub-component that

(this is the description for this component provided with the game) (todo)[1]

Cosmoteer.Ships.Parts.Logic.PartValueLerp PartComponent
ValueProxy 🔗 Proxy A part sub-component that acts as a proxy to a value component in another part. Cosmoteer.Ships.Parts.Logic.PartValueProxy PartComponent
ValueTween 🔟 Value A part sub-component that tweens from one value to the next based off on off state Cosmoteer.Ships.Parts.Logic.PartValueTween OperationalPartComponent
RailgunProjectile 🎯Projectile A chainable component that when operational accelerates in a direction and causes a trigger when it reaches the end. Cosmoteer.Ships.Parts.Weapons.RailgunProjectile OperationalChainablePartComponent
ResourceConverter 📦 Resource A part sub-component that converts from one type of resource to another. Cosmoteer.Ships.Parts.Resources.ResourceConverter OperationalPartComponent
Thruster (modding) 🚀 Movement A part sub-component that exerts a controlled force on the ship as determined by its activation level.


The provided value is the current output factor.

Cosmoteer.Ships.Parts.Thrusters.Thruster OperationalChainablePartComponent
Weapon (modding) ⚙️ Other The base class for all types of weapon components.


The provided value is the reload progress (0 => just started to reload, 1 => finished reloading).
Cosmoteer.Ships.Parts.Weapons.Weapon OperationalChainablePartComponent

Incomplete interface implementation

Because the IPartComponentValue interface has more than 1 field, there are places where it colud make sense to NOT implement the entire interface.

In this particular case, the event field "ValueChanged" wasn't fully implemented in all of the components listed above; instead the game will throw the NotSupportedException exception (and then crash "gracefully").

This means that the components listed below should NOT be referencing the few components that are labeled as having incomplete interface implementation or any classes derived from them.

Component Type Field Name
Arc Shield DrainResourcesFrom
BeamRegulator Emitter
BuffProvider BuffMultiplier
ContinuosEffects FactorMediaEffectsIntensityWith
Graphics AnimationSpeedFactor
MultiValue Values
MultiValue ViaBuffs / ComponentIDs
ResourceSprites AnimationSpeedFactor
ThresholdToggle ValueFrom
ThresholdTrigger AmountFrom
TransformLerp ValueFrom
ValueLerp InputValue
ValueProxy ProxyRules / ProxyableComponents

Component specification

BuffableValue

Code location (what's this?): Cosmoteer.Ships.Parts.Logic.PartBuffableValue

A part sub-component that provides a value that can be modified by a buff.

Inherits from PartComponent.

Parameters for BuffableValue (List excluding inhereted parameters)
Name Type Required? Buffable? Default value Description
Value BuffableFloat - Yes 1f The value, that will be provided by this component.

Examples

Example form thruster_rocket_nozzle.rules:

InvThrustBuffValue
{
	Type = BuffableValue
	Value = { BaseValue=1; BuffType=RocketThrust; BuffMode=Divide; }
}

DebugValue

Code location (what's this?): Cosmoteer.Ships.Parts.Logic.PartDebugValue

A part value component whose value can be changed via the part debugger.

Inherits from PartComponent.

Parameters for DebugValue (List excluding inhereted parameters)
Name Type Required? Buffable? Default value Description
DefaultValue float - - 0f The value, that will be provided by this component.

Examples

CalloutIconWarning.pngWork in Progress
This subsection is currently work-in-progress: Some things may be missing.

Feel free to contribute to make it better!

MultiValue

Code location (what's this?): Cosmoteer.Ships.Parts.Logic.PartMultiValue

A part sub-component that combines multiple other value components into a single value component.

It will also pull the values of provided buffs (in the "ViaBuffs" parameter) and process them as if they're additional values.

Inherits from PartComponent.

Parameters for MultiValue (List excluding inhereted parameters)
Name Type Required? Buffable? Default value Description
Values ID<PartComponentRules>[]? - - no values to combine List of input components that will provide the multiple values we want to combine.
ViaBuffs BuffMultiProxyRules? - - no buffs to combine Specification of which buffs include as more values we want to combine.
Mode MultiValueMode Yes - - Specifies how the multiple values are combined into one value.
Abs bool - - false Makes the value positive ( = takes the absolute value of the value).
Negate bool - - false Negates the value.
Invert bool - - false Inverts the value.

Here is some C# pseudo-code describing how Abs, Negate & Invert options interact:

float PostProcessValue(float value_after_mode_processing){
    float value = value_after_mode_processing;
    if (Abs) {
    	value = abs(value);
    }
    if (Invert) {
    	value = 1f - value;
    }
    if (Negate) {
    	value = -value;
    }
    return value;
}

The result of this pseudo-function is provided as the value of this component.

MultiValueMode

Code location (what's this?): Cosmoteer.Ships.Parts.Logic.MultiValueMode

It's a special enum that specifies how the multiple values are combined into one value.

Defined MultiValueMode values
Name Value Usage
Add 0 Adds all the values together.
Multiply 1 Multiplies all the values together.
Min 2 Selects the smallest available value.
Max 3 Selects the bigest available value.

Examples

Example from tractor_beam_emitter.rules :

AbsBeamRegulator
{
	Type = MultiValue
	Values = [BeamRegulatorProxy]
	Mode = Add
	Abs = true
}

RoofOpacityValue

Code location (what's this?): Cosmoteer.Ships.Parts.Logic.PartRoofOpacityValue

A part sub-component that provides the roof opacity as a value.

Inherits from PartComponent.

Parameters for RoofOpacityValue (List excluding inhereted parameters)
Name Type Required? Buffable? Default value Description
InputRange Range<float> - - [0f, 1f] The range to reverse linearly interpolate the roof opacity value.
OutputRange Range<float> - - [0f, 1f] The range to linearly interpolate the result of "InputRange" parameter processing.

Examples

CalloutIconWarning.pngWork in Progress
This subsection is currently work-in-progress: Some things may be missing.

Feel free to contribute to make it better!

StaticValue

Code location (what's this?): Cosmoteer.Ships.Parts.Logic.PartStaticValue

A part sub-component that stores a single unchanging float value usable by other components.

Inherits from PartComponent.

Parameters for StaticValue (List excluding inhereted parameters)
Name Type Required? Buffable? Default value Description
Value float Yes - - The value, that will be provided by this component.

Examples

CalloutIconWarning.pngWork in Progress
This subsection is currently work-in-progress: Some things may be missing.

Feel free to contribute to make it better!

ValueAccumulator

Code location (what's this?): Cosmoteer.Ships.Parts.Logic.PartValueAccumulator

A part sub-component that accumulates and dissipates a value based on its state.

Inherits from OperationalPartComponent.

Parameters for ValueAccumulator (List excluding inhereted parameters)
Name Type Required? Buffable? Default value Description
AccumulatingToggle ID<PartComponentRules>? - - - The toggle that determines the operational state of the accumulator.
BaseValue float - - 0f The value the accumulator starts at and moves towards when toggle off.
AccumulationRate BuffableFloat - Yes 0f The rate at which the value accumulates when toggled on.
DissipationRate BuffableFloat - Yes 0f The rate at which the value moves towards "BaseValue" when toggled off.
NonOperationalBehaviour AccumulatorBehaviour - - Nothing The accumulator's behaviour while it is non-operational.
MinValue BuffableFloat? - Yes effectively: no lower bound The lowest value that the accumulator can reach.
MaxValue BuffableFloat? - Yes effectively: no upper bound The highest value that the accumulator can reach.
AccumulationTriggers AccumulationTriggerRules[] - - no discrete modification triggers Discrete value modification triggers.

AccumulatorBehaviour

Code location (what's this?): Cosmoteer.Ships.Parts.Logic.PartValueAccumulatorRules.AccumulatorBehaviour

It's a special enum that specifies how an accumulator behaves.

Defined AccumulatorBehaviour values
Name Value Usage
Nothing 0 The accucmulator does nothing.
Dissipate 1 The accumulator dissipates towards "BaseValue".
Reset 2 The accumulator gets set to "BaseValue".

AccumulationTriggerRules

Code location (what's this?): Cosmoteer.Ships.Parts.Logic.PartValueAccumulatorRules.AccumulationTriggerRules

It's a special calss that specifies how an accumulator should behave when a trigger gets fired. AccumulationTriggerRules doesn't inherit from any class.

Parameters for AccumulationTriggerRules
Name Type Required? Buffable? Default value Description
Trigger ID<PartComponentRules> Yes - - The toggle that determines the operational state of the accumulator.
Value BuffableFloat Yes - - The rate at which the value accumulates when toggled on.
Operation TriggerOpperation - - Accumulate Whether this trigger acts accumulation, dissipation, or directly sets the value.
AllowWhenOn bool - - true Whether this trigger activates when the accumulator is on.
AllowWhenOff bool - - true Whether this trigger activates when the accumulator is off.
AllowWhenOperational bool - - true Whether this trigger activates when the accumulator is operational.
AllowWhenNonOperational bool - - true Whether this trigger activates when the accumulator is non-operational.

TriggerOpperation

Code location (what's this?): Cosmoteer.Ships.Parts.Logic.PartValueAccumulatorRules.TriggerOperation

It's a special enum that specifies how an accumulator behaves.

Defined TriggerOpperation values
Name Value Usage
Accumulate 0 The accucmulator increments by the provided value.
Dissipate 1 The accumulator dissipates towards "BaseValue" by the provided value at the most.
Set 2 The accumulator gets set to the provided value.

Examples

Take a look at the notes section

CalloutIconWarning.pngWork in Progress
This subsection is currently work-in-progress: Some things may be missing.

Feel free to contribute to make it better!

ValueLerp

Code location (what's this?): Cosmoteer.Ships.Parts.Logic.PartValueLerp

A part sub-component that

(this is the description for this component provided with the game) (todo)[2]

Inherits from PartComponent.

Parameters for ValueLerp (List excluding inhereted parameters)
Name Type Required? Buffable? Default value Description
InputValue ID<PartComponentRules> Yes - - The value to linearly interpolate.
InputRange Range<BuffableFloat> - Yes [0f, 1f] The range to reverse linearly interpolate the input value.
OutputRange Range<BuffableFloat> - Yes [0f, 1f] The range to linearly interpolate the result of "InputRange" parameter processing.
ClampInput bool - - true Should the result of the "InputRange" parameter processing be calamped to the provided range.
ClampOutput bool - - true Should the result be calamped to the provided range.

Examples

CalloutIconWarning.pngWork in Progress
This subsection is currently work-in-progress: Some things may be missing.

Feel free to contribute to make it better!

ValueTween

Code location (what's this?): Cosmoteer.Ships.Parts.Logic.PartValueTween

A part sub-component that tweens from one value to the next based off on off state

This component helps with ramping up the fire rate of the Chaingun. You can use it for similar purposes.

Inherits from OperationalPartComponent.

Parameters for ValueTween (List excluding inhereted parameters)
Name Type Required? Buffable? Default value Description
IsOnToggle ID<PartComponentRules>? Yes - - The toggle that determines the operational state of this component.
OffValue float - - 0f The value this component moves towards when toggle off.
OnValue float - - 1f The value this component moves towards when toggle on.
StartingValue float? - - effectively:

Either OnValue or OffValue,

depending on the state of the isOnToggle

The value this component starts at.
OnTweenDuration float Yes - - The time for the component's value to transition from OffValue to OnValue.
OffTweenDuration float Yes - - The time for the component's value to transition from OnValue to OffValue.

Examples

2 examples from chaingun.rules :

RateOfFireTween
{
	Type = ValueTween
	OffValue = 1
	OnValue = 10.5 //30 shots per second if base value 0.35
	OnTweenDuration = 10
	OffTweenDuration = (&OnTweenDuration) / 2 //cooldown is half the ramp up
	IsOnToggle = GunIsFiring
}
ShellChangingValueTween
{
	Type = ValueTween
	OnTweenDuration = 1.2
	OffTweenDuration = 1.2
	IsOnToggle = ShellShouldOpen
}

Notes

Moving numbers between Buffs and Values

It's important to bring up how to move numbers between a Buff and a Value. Some operations are easier with 🔮Buffs, others with Values.

If you have a Buff and want a Value, most values are implemented as BuffableFloats.

The BuffableValue component is the most straightforward way to move a Buff into a Value.

If you have a Value and want a Buff, use a SelfBuffProvider. Make sure your component is capable of receiving the buff, as usual.

Taking a value delta and a derivative
.rules code
// These components demonstrate how to calculate a differential for a value that updates on regular intervals.
// This roughly achieves the following algorithm:
//   DifferentialValue = CurrentValue - PrevValue
//   PrevValue = CurrentValue
// Once you have the differential, calculating the derivative should be as simple as dividing by your update interval.

// Component ordering is somewhat important here. Cosmoteer loads components in the order they are defined in the rules file.
// This means that when a trigger fires, for example, earlier components will process it before later components.

// Note that this requires the component to be able to receive 2 additional buffs, for transferring values between components.
// These buffs are named CurrentValueBuff and ValueDeltaBuff here. It's recommended to simply have `CombineMode = Add` on both of these buffs.
// ValueDeltaBuff specifically needs `CombineMode = Add` so that it can properly compute the difference between current and previous value.

// This should trigger on a regular interval. The example uses a timer that updates every physics tick.
// Replace with your trigger component name.
UpdateTrigger
{
	Type = Timer
	Duration = 1/30
	AutoStart = true
	Repeats = true
}

// This is the Value component that you want to take derivative of.
// Replace with your value component name.
CurrentValue
{
	// ...
}

// Converts the current value to a buff, for use in a BuffableFloat down the line
CurrentValueToBuff
{
	Type = SelfBuffProvider
	BuffType = CurrentValueBuff
	BuffMultiplier = CurrentValue
}

// Converts the current value to the delta buff. This, combined with PrevValueToDeltaBuff below, computes the differential in buff space.
CurrentValueToDeltaBuff
{
	Type = SelfBuffProvider
	BuffType = ValueDeltaBuff
	BuffMultiplier = CurrentValue
}

// If the change in CurrentValue is triggered by UpdateTrigger, this component is needed here
// to ensure that CurrentValue updates before saving the differential.
SaveDeltaTrigger
{
	Type = TriggerProxy
	ComponentID = UpdateTrigger
}

// This is the output.
// The differential is stored in an accumulator to isolate it from changes in other value components.
DifferentialValue
{
	Type = ValueAccumulator
	AccumulationTriggers
	[
		{
			Trigger = SaveDeltaTrigger
			Operation = Set
			Value = { BaseValue = 1; BuffType = ValueDeltaBuff; BuffMode = Multiply; }
		}
	]
}

// This trigger proxy is placed below the other components to ensure that computing and saving DifferentialValue happens before writing CurrentValue to PrevValue.
SavePrevValueTrigger
{
	Type = TriggerProxy
	ComponentID = UpdateTrigger
}

// Store the previous value into an accumulator for the next update.
PrevValue
{
	Type = ValueAccumulator
	AccumulationTriggers
	[
		{
			Trigger = SavePrevValueTrigger
			Operation = Set
			Value = { BaseValue = 1; BuffType = CurrentValueBuff; BuffMode = Multiply; }
		}
	]
}

// Negate the previous value and add it to the delta buff. This, combined with CurrentValueToDeltaBuff above, computes the differential in buff space.
PrevValueToDeltaBuff
{
	Type = SelfBuffProvider
	BuffType = ValueDeltaBuff
	BuffAmount = -1
	BuffMultiplier = PrevValue
}

See also

  1. todo: come up with a compleated description for this component and inform Walt about this)
  2. todo: come up with a compleated description for this component and inform Walt about this)