Table of Contents

Struct OpinionModifier

Namespace
Core.Diplomacy
Assembly
Core.dll

ENGINE LAYER - Individual opinion modifier affecting relations between countries

Architecture:

  • Fixed-size struct for deterministic serialization
  • Decays linearly over time (value * (1 - elapsed/decayRate))
  • Fully decayed modifiers removed automatically

Memory: ~20 bytes per modifier (aligned)

Example Usage: var modifier = new OpinionModifier { modifierTypeID = OpinionModifierTypes.DeclaredWar, value = FixedPoint64.FromInt(-50), appliedTick = currentTick, decayRate = 3600 // 10 years (360 ticks/year) };

// Calculate current value after 5 years: FixedPoint64 current = modifier.CalculateCurrentValue(currentTick); // Returns -25 (50% decay after half the decay period)

[Serializable]
public struct OpinionModifier

Fields

appliedTick

Tick when this modifier was applied Used to calculate decay over time

public int appliedTick

Field Value

int

decayRate

Ticks until full decay (0 = permanent modifier) Example: 3600 ticks = 10 years (360 days/year)

public int decayRate

Field Value

int

modifierTypeID

Type of modifier (game-specific, e.g., DeclaredWar, StoleProvince) Maps to OpinionModifierTypes enum in GAME layer

public ushort modifierTypeID

Field Value

ushort

value

Base opinion value change (-200 to +200) Negative = worsens opinion, Positive = improves opinion

public FixedPoint64 value

Field Value

FixedPoint64

Methods

CalculateCurrentValue(int)

Calculate current value with decay applied Linear decay: value * (1 - timeElapsed / decayRate)

public FixedPoint64 CalculateCurrentValue(int currentTick)

Parameters

currentTick int

Returns

FixedPoint64

IsFullyDecayed(int)

Check if this modifier is fully decayed

public bool IsFullyDecayed(int currentTick)

Parameters

currentTick int

Returns

bool