# Goal To map out the Vanilla+ Framework for easier understanding. https://steamcommunity.com/sharedfiles/filedetails/?id=2915780227 # Observeations - vanilla+ missiles update frequently, 300 turrets firing every 1s = +150kb/s per player - keen vanilla gatling turrets are potentially bottlenecked by the "Shoot" action checking every frame for stuff like conveyors power etc ## VanillaPlusFramework.cs ### Class: VanillaPlusFramework ### Attributes - `[MySessionComponentDescriptor]`: Specifies the update order for the session component. ### Static Fields - **`DisabledBlocks`**: A dictionary tracking blocks that have been temporarily disabled. ### Methods #### `LoadData()` - Registers message handlers and event listeners for mod messages and explosions. - Initializes communication tools. #### `OnExplosion(ref MyExplosionInfo explosionInfo)` - Custom logic for handling explosions, adjusting the hit entity and explosion parameters. #### `UnloadData()` - Unregisters message handlers and event listeners. - Cleans up communication tools. #### `OnModMessageReceived(object message)` - Deserializes incoming mod messages and routes them to the relevant part of the framework, like missiles, turrets, or visual effects. - Handles various types of `VPFDefinition` such as `VPFAmmoDefinition`, `VPFTurretDefinition`, and `VPFVisualEffectsDefinition`. `VanillaPlusFramework.cs` acts as the backbone of the VanillaPlusFramework, managing key aspects of the mod's functionality, including handling custom explosions and integrating different components of the framework through message handling. # API/ ## API/ModAPI.cs - Empty # Beams/ ## Beams/BeamDefinition.cs - `MaxTrajectory`: Maximum trajectory length of the beam. - `MinReflectChance` and `MaxReflectChance`: Minimum and maximum chance of the beam reflecting off surfaces. - `MinReflectAngle` and `MaxReflectAngle`: Minimum and maximum angles at which the beam can reflect. - `ReflectDamage`: Damage inflicted when the beam reflects. - `PenetrationDamage`: Damage inflicted when the beam penetrates an object. - `PlayerDamage`: Damage inflicted on players. - `ExplosiveDamage`: Damage inflicted in the form of an explosion. - `ExplosiveRadius`: The radius of the explosion. - `ExplosionFlags`: Flags or settings related to the explosion behavior. - `EndOfLifeEffect`: The effect that occurs when the beam reaches the end of its life. - `EndOfLifeSound`: The sound played when the beam reaches the end of its life. - `BWT_Stats`: Statistics related to the beam weapon's logic or behavior. - `PD_Stats`: Statistics related to proximity detonation logic, if applicable. - `EMP_Stats`: Statistics related to electromagnetic pulse (EMP) logic, if applicable. - `JDI_Stats`: Statistics related to jump drive inhibition logic, if applicable. - `SCI_Stats`: A list of statistics related to special componentry interaction logic. ## Beams/Beams.cs - `[MySessionComponentDescriptor]`: This class is marked with a session component descriptor, indicating that it extends the game's session component functionality. - `MaxLayers`: An integer representing the maximum number of layers for beam reflections. - `m_DetectedMissiles`: A list of detected missiles. - `Random`: An instance of `MyRandom` used for generating random numbers. - `GenerateBeam()`: A method for generating a beam, taking various parameters including position, direction, velocity, and a `BeamDefinition` structure to define the beam's properties. - `OurHitInfo`: A nested struct implementing the `IHitInfo` interface, used to store hit information. - `GetRicochetProbability()`: A method to calculate the probability of a beam ricocheting based on impact angle and specified parameters. - `ShouldReflect()`: A method to determine if a beam should reflect based on probabilities and impact angles. - `DoDamageToEntity()`: A method to apply damage to a target entity and calculate remaining damage. - `CheckMissilesInSphere()`: A method to check for nearby missiles in a specified bounding sphere and apply damage to them. - `AttemptDamageMissile()`: A method to attempt to damage a nearby missile. # Definitions/ ## Definitions/AmmoDefinitionDefinitions.cs ### Enums - `IdType`: Specifies if the companion string points to a SubtypeId or TypeId. - `DamageType`: Specifies the type of damage (Percent or Damage). - `GuidanceType`: Specifies how a guided missile acquires a target (None, LockOn, TurretTarget, DesignatedPosition, OneTimeRaycast). ### Structures - `DoubleArray`: A workaround structure for serialization limitations. - `EMP_Logic`: Defines the behavior of EMP effects, including radius and time disabled. - `GuidanceLock_Logic`: Contains variables controlling guided missile behavior, including homing functions, decoy chances, and allowed guidance types. - `ProximityDetonation_Logic`: Defines behavior for proximity detonation including anti-missile damage and detonation radius. - `JumpDriveInhibition_Logic`: Defines behavior for jump drive power drain on hit. - `BeamWeaponType_Logic`: Defines characteristics for beam weapons, including active time, damage falloff, and visual properties. - `SpecialComponentryInteraction_Logic`: Defines interactions with specific components, including damage type, disable time, and radius of effect. ### Class - `VPFAmmoDefinition`: The primary class containing definitions for different types of ammunition, incorporating the structures for various special behaviors (EMP effects, guidance systems, proximity detonation, etc.). Each ammunition type is defined with a unique subtype name and a series of optional properties related to its behavior in the game. ## Definitions/DefinitionTools.cs ### `ConvertToDoubleArrayList(double[,] array)`` - **Description**: Converts a 2D array into a list of `DoubleArray` structures, overcoming the ProtoBuf's limitations regarding multidimensional or nested arrays. - **Parameters**: `double[,] array` - The 2D array to be converted. - **Returns**: `List<DoubleArray>` - A list of `DoubleArray` structs, each containing one array extracted from the original 2D array. ### `FunctionOutput(double x, List<DoubleArray> function)` - **Description**: Calculates the output for a given input `x` from a piecewise polynomial function defined in the given List of `DoubleArray`. - **Parameters**: - `double x` - The input value. - `List<DoubleArray> function` - The piecewise polynomial function defined as a list of `DoubleArray`. - **Returns**: `double` - The output of the function at the input `x`. ### `DefinitionToMessage(VPFDefinition def)` - **Description**: Serializes a framework definition object into a byte array for transmission or storage. - **Parameters**: `VPFDefinition def` - The framework definition to serialize. - **Returns**: `byte[]` - An array of bytes representing the serialized object. ### Notes - The class and its methods are intended to support the serialization and deserialization processes, specifically working around some of the limitations of ProtoBuf with multidimensional arrays and providing utility for function evaluation. - The file includes a cautionary note indicating that it's a tool for making and serializing definitions, suggesting it's part of a larger framework or modding toolset. ## Definitions/FXDefinitionDefinitions.cs ### `VPFDefinition` - **Purpose**: Acts as a base class for visual effects definitions. - **ProtoInclude**: Includes `VPFVisualEffectsDefinition`. ### `SimpleObjectDefinition` - **Purpose**: Base class for Line, Sphere, and Trail definitions related to visual effects. - **Fields**: - `Pos1`: Origin for the drawing relative to the missile. - `Color`: Color of the drawing (RGBA). - `Thickness`: Thickness of the drawing. - `VelocityInheritance`: Multiplier to the velocity of the drawing, inherited from the missile. - `TimeRendered`: Amount of ticks each render will be drawn. - `Material`: Texture of the drawing. - `BlendType`: Render type of the drawing. - `Fade`: Determines if the drawing should fade over time. - `TicksPerSpawn`: Ticks per spawn of the effect. ### `LineDefinition` - **Inherits**: `SimpleObjectDefinition` - **Purpose**: Defines the end point for drawing lines. - **Additional Fields**: - `Pos2`: End point for the drawing relative to the missile. ### `SphereDefinition` - **Inherits**: `SimpleObjectDefinition` - **Purpose**: Defines parameters for drawing spheres. - **Additional Fields**: - `Radius`: Radius of the sphere. - `WireDivideRatio`: Resolution of the sphere. - `Rasterizer`: Rasterizer type of the drawing. ### `TrailDefinition` - **Inherits**: `SimpleObjectDefinition` - **Purpose**: Defines trails that follow missiles. ### `VPFVisualEffectsDefinition` - **Inherits**: `VPFDefinition` - **Purpose**: Main class for defining visual effects on missiles. - **Fields**: - `SubtypeName`: Identifier for the missile subtype. - `DrawnObjects`: List of simple object definitions to be drawn. ### Notes - The file contains a stern warning not to modify it, indicating its role as a core component of a larger system. - Uses ProtoBuf for serialization, emphasizing performance and compatibility across different systems. This file is a comprehensive template for defining various visual effects, particularly for objects like missiles in a gaming context, providing a detailed and customizable set of definitions for visual appearances and behaviors. ## Definitions/TurretDefinitionDefinitions.cs ### Enums ### `FuelType` - **Purpose**: Specifies the types of fuel a turret might use. - **Values**: POWER, HYDROGEN, OXYGEN. ### `TargetFlags` - **Purpose**: Flags for targeting options in turrets, including what types of targets they can acquire and certain behavior modifiers. - **Values**: None, MeteorTargeting, MissileTargeting, SmallShipTargeting, etc. ### Structs ### `AmmoGeneration_Logic` - **Purpose**: Contains all the variables for a turret to generate its own ammo based on available resources. - **Fields**: Includes the ammo definition name, fuel type, cost, generation time, and number generated. ### `TurretAI_Logic` - **Purpose**: Contains all the variables for modifying turret AI, such as targeting flags, response times, and targeting range. - **Fields**: Includes response time, disable and enable targeting flags, maximum and minimum range, and whether the turret should shoot when a target is acquired. ### Classes ### `VPFTurretDefinition` - **Inherits**: `VPFDefinition` - **Purpose**: Main class for defining turret behavior and characteristics. - **Fields**: - `subtypeName`: Identifier for the turret subtype. - `TAI_Stats`: Turret AI stats, nullable to indicate optional use. - `AG_Stats`: Ammo generation stats, nullable to indicate optional use. ### Notes - The file is critical to the larger framework it's part of, indicated by the warning not to modify it. - Uses ProtoBuf for serialization, emphasizing the importance of performance and compatibility. - The definitions allow for a highly customizable set of behaviors and functionalities for turrets within the game or modding environment it's designed for. This file, with its comprehensive template, allows for defining a wide array of turret types and behaviors, providing extensive customization and control over their functionalities in the game. # FX/ ## FX/FXRenderer.cs ### Class: FXRenderer - **Inheritance**: Inherits from `MySessionComponentBase`. - **Purpose**: Manages the rendering of visual effects based on `VPFVisualEffectsDefinition` instances. ### Static Members - **`Definitions`**: A list of `VPFVisualEffectsDefinition` objects that define various visual effects. - **`ObjectsToRender`**: A list of `IRenderObject` interfaces representing objects that need to be rendered. ### Methods #### OnDefinitionReceived(VPFVisualEffectsDefinition def) - **Description**: Adds a visual effects definition to the `Definitions` list if it's not already included and logs the addition. - **Parameters**: `VPFVisualEffectsDefinition def` - The definition to be added. - **Behavior**: Checks if the definition is valid (non-empty subtype name), and if it's not already in the list, adds it and logs the addition. #### UpdateAfterSimulation() - **Description**: Iteratively updates each render object in `ObjectsToRender`. - **Behavior**: Goes through each `IRenderObject` in `ObjectsToRender` and calls its `Update()` method. If `Update()` returns true, the object is removed from the list. #### Update() - **Returns**: `bool` - Indicates whether the object should be removed from the rendering list (true if it should be removed). ### Notes - The `FXRenderer` is responsible for handling and updating render objects based on their definitions. It serves as a central manager for all visual effects that need to be rendered each game update cycle. ## FX/LineRenderer.cs ### Constructors ### `LineRenderer(Vector3D Origin, Vector3D End, ...)` - Initializes a line renderer with start and end points, color, thickness, and other properties. - **Parameters**: Includes visual properties like color, thickness, and dynamic properties like velocity. ### `LineRenderer(LineDefinition def, MatrixD WorldMatrix, Vector3D velocity)` - Initializes the line renderer using a `LineDefinition` object and transforms it into world space. - **Parameters**: `LineDefinition` object, world matrix, and velocity of the line. ### `LineRenderer(TrailDefinition def, MatrixD WorldMatrix, Vector3D velocity, MatrixD LastWorldMatrix)` - Similar to the above but tailored for rendering trails. - **Parameters**: `TrailDefinition` object, current and last world matrices for calculating trajectory. ### Method ### `public bool Update()` - Updates the line's position and appearance based on velocity and time. - **Returns**: `true` if the line's lifetime is over, indicating it should be removed. ## FX/SphereRenderer.cs ### Class: SphereRenderer Implements `IRenderObject` for rendering spherical visual effects. ### Constructors #### `SphereRenderer(MatrixD Center, float Radius, Vector4 Color, ...)` - Initializes a sphere renderer with its center, radius, color, thickness, and other properties. - **Parameters**: Includes the position, size, visual properties, and dynamic properties like velocity. #### `SphereRenderer(SphereDefinition def, MatrixD WorldMatrix, Vector3D velocity)` - Initializes the sphere renderer using a `SphereDefinition` object. - **Parameters**: `SphereDefinition` object, world matrix for position, and velocity for movement. ### Method #### `public bool Update()` - Updates the sphere's position, color, and thickness based on its velocity and elapsed time. - **Behavior**: Moves the sphere, fades its color and thickness over time, and draws it each frame. Returns `true` when its lifetime ends. # Missiles/ ## Missiles/Missile.cs ### Constructors #### `VPFMissile()` - A default constructor initializing a missile object. #### `VPFMissile(IMyMissile missile, VPFAmmoDefinition AmmoDefinition, VPFVisualEffectsDefinition effects)` - Initializes a missile with specific parameters including the missile itself, its ammo definition, and visual effects. ### Methods #### `public bool Update()` - Updates the missile's state each tick, handling its movement, checks for arming time, applies visual effects, and proximity detonation. It returns `true` if the missile is to be removed. #### `private void RenderMissileEffects()` - Renders custom visual effects for the missile based on its current state and provided effect definitions. #### `public void Close()` - Properly closes the missile object, removing it from tracking and clearing related resources. #### `public void APHE_DetonateMissile(MyEntity HitEntity)` - Detonates the missile with armor-piercing high explosive (APHE) effects, applying damage and effects in a specific radius. #### `public void DetonateSelf(float damage, bool doExplosionFX)` - Self-detonates the missile, creating an explosion at its current position with given parameters. #### Various Update Functions like `Update2`, `Update5`, `Update10` - Specific update functions called at different intervals to manage missile guidance, retargeting, and other periodic checks. #### `private void PD_DetectHostiles(bool detectMissiles)` - Detects nearby hostile entities for proximity detonation and determines if the missile should detonate itself. #### `private IMyEntity GL_GetTarget()` - Retrieves the current target for the missile based on its guidance logic settings. #### `private Vector3 GL_TargetPrediction()` - Predicts the future position of the target for more accurate missile guidance. #### `private void GL_UpdateDesiredDirection(Vector3 TargetPosition)` - Updates the missile's travel direction to head towards the predicted target position. ## Missiles/MissileLogic.cs ### Static Members - **`Definitions`**: List of all ammo definitions. - **`Missiles`**: Dictionary tracking all active missiles. - **`RetargetChances`**: Dictionary of retargeting chances based on missile types. ### Constructors - **`MissileLogic()`**: Initializes various lists and dictionaries for missile management. ### Methods #### Network Synchronization (`Netcode` Section) - **`SyncRequest(PacketType type)`**: Returns packets required for synchronizing the given packet type. - **`SyncData(Packet data)`**: Synchronizes missile data based on received packets. - **`DoNetcode()`**: Manages the network code, ensuring proper synchronization across multiplayer. #### Missile Management - **`OnMissileAdded(IMyMissile missile)`**: Adds a new missile to the tracking system. - **`OnProjectileAdded(ref MyProjectileInfo projectile, int index)`**: Adds or modifies projectile data. - **`OnMissileMoved(IMyMissile missile, ref Vector3 Velocity)`**: Updates missile position in the world. - **`OnMissileRemoved(IMyMissile missile)`**: Removes the missile from tracking. - **`OnMissileCollided(IMyMissile missile)`**: Handles missile collision events. #### Utility Methods - **`UpdateMissiles()`**: Updates each tracked missile per tick. - **`UpdateDisabledBlocks()`**: Checks and updates any disabled blocks. - **`ShouldSync(VPFMissile VPFmissile)`**: Determines if a missile needs to be synchronized. #### Chat Command Handlers - **`ChatCommand_ShowLoadedDefinitions(ulong SenderId, string[] SplitText)`**: Shows loaded ammo definitions through chat commands. - **`ChatCommand_KillAllMissiles(ulong SenderId, string[] SplitText)`**: Kills all missiles through a chat command. #### Load/Unload & Update - **`BeforeStart()`**: Initial setup, registering event handlers. - **`UnloadData()`**: Cleans up on unload, removing event handlers. - **`FirstFrameInit()`**: Initializes various settings on the first frame. - **`UpdateBeforeSimulation()`**: Regular update cycle for missile logic. - **`UpdateAfterSimulation()`**: Regular update cycle for network code. # Networking/ ## Networking/CommunicationTools.cs ### Class: CommunicationTools ### Static Members - **`MessageHandlerId`**: A unique identifier for message handling. - **`Players`**: A list of players for sending messages to specific clients. ### Methods #### `Load()` - Registers the message handler to start listening for incoming messages. #### `Unload()` - Unregisters the message handler and cleans up on unload. #### `SendMessageTo(Packet packet, ushort channel, ulong RecipientId, bool reliable = true)` - Sends a message to a specific recipient. - **Parameters**: The packet to send, the channel to use, recipient ID, and whether the message should be reliable. #### `SendMessageToClients(Packet packet, ushort channel, bool reliable = true, params ulong[] ignoreList)` - Sends a message to all clients, with an option to ignore certain users. - **Parameters**: The packet to send, the channel, reliability flag, and optional list of users to ignore. #### `SendMessageToServer(Packet packet, ushort channel, bool reliable = true)` - Sends a message to the server. - **Parameters**: The packet, the channel, and reliability flag. #### `MessageRecieved(ushort ChannelId, byte[] bytes, ulong SenderId, bool fromServer)` - Handles the incoming message, deserializing it and invoking the `OnMessageReceived` event. - **Parameters**: Channel ID, raw byte data, sender's ID, and whether it's from the server. #### `OnMessageReceived` Event - An event that triggers when a message is received, allowing other parts of the program to react accordingly. ## Networking/Packets.cs ### Enums ### `PacketType` - **`Definitions`**: Related to ammo or other game definitions. - **`Missiles`**: Pertaining to missile information. - **`Command`**: For command-related packets. ### Classes ### `Packet` - **Purpose**: Base abstract class for all packet types. - **Members**: `DataType` indicating the type of packet. - **Methods**: `ToString()` for easier packet identification. ### `SendDefinition` - **Inherits**: `Packet` - **Purpose**: Sends ammo or other definitions. - **Members**: `Data` holding the specific definition to be sent. ### `SyncMissileTarget` - **Inherits**: `Packet` - **Purpose**: Synchronizes missile targets. - **Members**: `missileIDs` and `targetIDs` for linking missiles to their targets. ### `Request` - **Inherits**: `Packet` - **Purpose**: Generic request packet. - **Constructor**: Sets the packet type upon creation. ### `ChatCommand` - **Inherits**: `Packet` - **Purpose**: Transmits chat commands. - **Members**: `SenderId` and `message` to contain the sender's information and the command message. # Turrets/ ## Turrets/Turret.cs ### Class: Turret Inherits from `MyGameLogicComponent` and enhances turret behavior. ### Fields - `self`: Reference to the turret entity. - `TAI_Stats`: Optional turret AI logic settings. - `AG_Stats`: Optional ammo generation logic settings. - Others: Various fields for managing fuel usage, inventory, and status flags. ### Methods #### `Init(MyObjectBuilder_EntityBase objectBuilder)` - Initializes the turret component. #### `UpdateOnceBeforeFrame()` - Sets up the turret with AI and ammo generation stats, resource components, and adds it to the turret logic system. #### `OnBeforeRemovedFromContainer()` - Cleans up when the turret is removed. #### `UpdateBeforeSimulation()` - Regular update method for the turret, handling AI logic and ammo generation. #### `DoTurretAILogic()` - Processes the AI logic for targeting and firing. #### `IsValidTargetFromRelation(MyRelationsBetweenPlayerAndBlock relations)` - Checks if a potential target is valid based on relations. #### `AttemptFindNewTarget()` - Attempts to find a new target within the turret's range. #### `ForceSetTargetOptions(TargetFlags flags, bool type)` - Adjusts turret targeting options based on given flags. #### `RemoveTarget()` - Resets the turret's targeting to default. #### `EnumToId(FuelType type)` - Converts a fuel type enum to a definition ID. #### `EnabledChanged(IMyTerminalBlock obj)` - Updates resource requirements when the turret is enabled or disabled. #### `DoAmmoGenerationLogic()` - Manages the logic for generating ammo if equipped with such capability. #### `StoreFuel()` - Stores fuel for ammo generation. #### `OnTurretFire()` - Placeholder for actions to take when the turret fires. #### `Close()` - Cleans up the turret component upon closing. ### Subclasses - `Turret_Gatling`: Specific behavior for Gatling turrets. - `Turret_Missile`: Specific behavior for Missile turrets. - `Turret_Interior`: Specific behavior for Interior turrets. ## Turrets/TurretLogic.cs ### Class: TurretLogic Extends `MySessionComponentBase` and provides global management of all turret behaviors. ### Static Members - **`Definitions`**: A list of `VPFTurretDefinition` objects defining various turret types. - **`Turrets`**: A list of `Turret` objects representing all active turrets in the game. ### Methods #### `BeforeStart()` - Registers handlers for when projectiles or missiles are added to the game. #### `UnloadData()` - Unregisters handlers and clears definitions and turrets when the game or script unloads. #### `FirstFrameInit()` - Initializes turret definitions and displays a message once when the game first starts. #### `UpdateBeforeSimulation()` - Checks if it's the first frame and if so, initializes the first frame settings. #### `OnDefinitionRecieved(VPFTurretDefinition def)` - Receives and processes new turret definitions, adding them to the global list if they're not already present. #### `OnMissileAdded(IMyMissile obj)` - Handles what happens when a missile is added to the game, specifically triggering any associated turret fire logic. #### `CallOnTurretFire(IMyEntity owner)` - Checks if the entity is a turret and triggers the `OnTurretFire()` method for that turret. #### `OnProjectileAdded(ref MyProjectileInfo projectile, int index)` - Handles what happens when a projectile is added to the game, specifically triggering any associated turret fire logic. # Utilities/ ## Utilities/ChatCommands.cs ### Class: VPFChatCommands Inherits from `MySessionComponentBase` and manages chat-based command execution. ### Static Fields - **`ChatCommands`**: A dictionary mapping command text to their corresponding action. ### Methods #### `Debug(object s)` - Displays a debug message. #### `OnChatMessageRecieved(ulong sender, string messageText, ref bool sendToOthers)` - Handles incoming chat messages and executes corresponding commands. - **Parameters**: Sender's ID, the text of the message, and a reference flag indicating whether the message should be sent to others. #### `AddChatCommand(string CommandText, Action<ulong, string[]> Command)` - Adds a new chat command to the dictionary if it doesn't already exist. - **Parameters**: The command text and the action to execute when the command is called. #### `OnNetworkMessageRecieved(ushort ChannelId, Packet Packet, ulong SenderId, bool FromServer)` - Handles network messages related to chat commands, executing the corresponding action. - **Parameters**: Channel ID, packet, sender's ID, and a flag indicating if it's from the server. #### `ChatCommand_GetAllCommands(ulong SenderId, string[] message)` - Lists all available commands to the sender. - **Parameters**: Sender's ID and the message array. #### `BeforeStart()` - Registers the message handlers for chat and network messages and initializes default commands. #### `UnloadData()` - Unregisters message handlers and clears the command dictionary. #### `ShowMessage(string message, ulong SenderId, bool Local)` - Displays a message to the chat interface. - **Parameters**: Message text, sender's ID, and a flag indicating if the message is local. ### Utility Methods - `IsOwner`, `IsAdmin`, `IsSpaceMaster`, `IsModerator`, `IsOnlyPlayer`: Check the player's privilege level. ## Utilities/DisabledBlock.cs ### Class: DisabledBlock ### Attributes - **`[ProtoContract]`**: Marks the class for serialization with ProtoBuf. ### Fields - **`TicksDisabled`**: The number of ticks for which the block is disabled. - **`previousState`**: The previous enabled/disabled state of the block. ### Constructors #### `DisabledBlock(bool state, int TicksDisabled)` - Initializes a new instance of the `DisabledBlock` with the given state and duration. - **Parameters**: The initial state of the block and the number of ticks to remain disabled. #### `DisabledBlock()` - A default constructor for serialization purposes. ### Methods #### `public bool Update(IMyFunctionalBlock block)` - Updates the block's enabled state based on the remaining ticks. - **Behavior**: Decrements `TicksDisabled` each tick and re-enables the block when it reaches zero. Returns true if the block should be removed from the disabled list. - **Parameters**: The block to update. `DisabledBlock.cs` provides a simple yet effective system for temporarily disabling and enabling blocks, keeping track of their original state and the duration of the disablement. ## Utilities/FrameworkUtilities.cs # FrameworkUtilities.cs Summary ### Class: FrameworkUtilities ### EMP, JDI, and SCI Logics - Provides methods for Electromagnetic Pulse (EMP), Jump Drive Inhibition (JDI), and Special Componentry Interaction (SCI) effects. #### `EMP(Vector3D Position, float EMP_Radius, int EMP_TimeDisabled)` - Applies EMP effects to blocks within a radius. - **Parameters**: EMP position, radius, and time disabled. #### `JDI_Hit(MyEntity hitEntity, float JDI_PowerDrainInW, bool JDI_DistributePower)` - Drains power from jump drives on a hit entity. - **Parameters**: Entity hit, power drain, and whether to distribute the power drain among all drives. #### `SCI_Hit(MyEntity hitEntity, List<SpecialComponentryInteraction_Logic> SCI_Stats, Vector3 hitpos)` - Applies special component interactions based on hit position and predefined logic. - **Parameters**: Entity hit, list of SCI logic, and hit position. #### `CastHax<T>(T typeRef, object value)` - A utility method for casting objects. #### `AppliesToBlock(SpecialComponentryInteraction_Logic logic, IMyCubeBlock block, Vector3 hitpos)` - Checks if special componentry interaction logic applies to a block based on position and type. - **Parameters**: SCI logic, block, and hit position. #### `GetTrueSubtypeID(IMySlimBlock block)` - Retrieves the true subtype ID of a block. - **Parameters**: The block in question. #### `ApplySCI_Logic(IMyCubeBlock block, List<SpecialComponentryInteraction_Logic> SCI_Stats, Vector3 hitpos)` - Applies special componentry interaction logic to a block if applicable. - **Parameters**: Block to apply to, list of SCI logic, and hit position. `FrameworkUtilities.cs` serves as a utility class for various interaction logics, providing a means to apply complex effects to blocks and entities within the game world.