Repository navigation
Components
The Components system provides a flexible and extensible framework for modeling all equipment and internal systems that can be installed in units. This includes weapons, engines, actuators, internal components, ammunition, and specialized equipment. The system supports multi-location mounting, component-specific state management, and dynamic component creation through a provider pattern.
The Component class serves as the abstract base for all installable items.
Components are organized into logical categories:
-
Actuators: Movement-related components (
ShoulderActuator,UpperArmActuator, etc.) -
Internal: Critical systems (
Gyro,LifeSupport,Cockpit,Sensors) -
Engines: Power systems with variable configurations (
Enginewith different types) - Weapons: Combat systems with ammunition dependencies
-
Equipment: General equipment (
HeatSink,JumpJets, etc.)
Immutable definitions separate static properties from runtime state.
- ActuatorDefinition: Single-slot, non-removable actuators
- InternalDefinition: Critical systems with variable health points
- EquipmentDefinition: General equipment with configurable properties
- EngineDefinition: Variable-size engines based on type
- WeaponDefinition: Combat systems with damage and range properties
- AmmoDefinition: Linked to specific weapon types
Persistent state representation for serialization and restoration.
Polymorphic state data for specialized components:
Examples:
-
EngineStateData: Engine type and rating -
AmmoStateData: Ammunition count and type
Components can span multiple locations through CriticalSlotAssignment.
- Slot Validation: Check availability and contiguity requirements
- Assignment Creation: Create slot assignments for each location
- Component Registration: Add component to affected unit parts
- State Synchronization: Update component mounting status
- XL Engine: 6 slots in Center Torso + 2 slots each in side torsos
Comprehensive status tracking.
Status is dynamically calculated based on (with semantics):
- Destroyed: Component’s own HP reduced to zero (in any location)
- Lost: Location destroyed causing loss of assigned slots for the component
- Removed: Explicitly unmounted/detached during refit
- Activation state (manual control)
Centralized component creation and definition management.
Default implementation providing:
- Definition Registry: Static definitions for all component types
- Factory Methods: Component instantiation with state restoration
Unit parts manage component mounting and slot allocation:
- Automatic Assignment: Find available consecutive slots
- Manual Assignment: Use specified slots with validation
- Conflict Detection: Prevent overlapping assignments
- Destruction Handling: Component loss when location destroyed
Variable-size components with type-specific behavior:
- Fusion Engine: 6 slots in Center Torso
- XL Fusion: 6 CT + 2 slots each in side torsos
- Light Engine: 4 slots in Center Torso
- Heat Integration: Built-in heat sink capacity
Combat components with ammunition dependencies:
- Damage Calculation: Range-based damage modification
- Heat Generation: Firing heat accumulation
- Ammunition Tracking: Linked ammo components
- Explosion Risk: Ammunition explosion mechanics
Critical systems with special destruction effects:
- Cockpit: Pilot death on destruction
- Gyro: Movement penalties when damaged
- Life Support: Heat-based pilot damage
- Sensors: Targeting penalties
Movement-enabling components:
- Arm Actuators: Weapon accuracy modifiers
- Leg Actuators: Movement capability
- Default Mounting: Predefined slot assignments
Component instantiation during unit creation.
External data loading through MtfDataProvider:
-
Component Mapping: String names to
MakaMekComponentenum - Size Calculation: Dynamic sizing based on component type
- State Data Creation: Component-specific data generation
-
Enum Extension: Add to
MakaMekComponentenum -
Definition Creation: Create appropriate
ComponentDefinition - Component Class: Implement component-specific behavior
- Provider Registration: Add to factory and definition dictionaries
-
State Data: Create
ComponentSpecificDataif needed
-
Override Methods:
Hit(),Activate(),Deactivate() -
Special Properties:
CanExplode,GetExplosionDamage() -
State Persistence:
GetSpecificData()
- Damage System: Component hit resolution
- Heat System: Heat generation and dissipation
- Movement System: Actuator and engine integration
- Combat System: Weapon and ammunition mechanics
The MakaMek Components system provides a robust, extensible framework for modeling all equipment and systems within game units:
- Flexible Architecture: Support for diverse component types and behaviors
- Multi-Location Support: Components can span multiple unit locations
- State Management: Comprehensive status tracking and persistence
- Provider Pattern: Centralized creation and definition management
- Integration: Seamless interaction with unit parts and game systems
The system is designed for extensibility, allowing easy addition of new component types while maintaining consistency and performance across the entire component ecosystem.