commit 0ad135ca0fcde7a37d84262c0c5a656b1ea48743 Author: Konstantin Grachev Date: Wed May 18 19:57:23 2022 +0300 init diff --git a/Connector.cs b/Connector.cs new file mode 100644 index 0000000..d3ab778 --- /dev/null +++ b/Connector.cs @@ -0,0 +1,51 @@ +namespace Sandbox.ModAPI.Ingame +{ + public class Main + { + void Main() + { + IMyBlockGroup batteryGroup = GridTerminalSystem.GetBlockGroupWithName("Batteries"); + List batteries = new List(); + batteryGroup.GetBlocksOfType(batteries, block => block.IsSameConstructAs(Me)); + + List engines = new List(); + GridTerminalSystem.GetBlockGroupWithName("Engines").GetBlocks(engines, block => block.IsSameConstructAs(Me)); + + IMyShipConnector connector = GridTerminalSystem.GetBlockWithName("Connector") as IMyShipConnector; + + if (connector.Status == MyShipConnectorStatus.Connectable) + { + connector.GetActionWithName("SwitchLock").Apply(connector); + + if (connector.Status != MyShipConnectorStatus.Connected) + { + return; + } + + foreach (var engine in engines) + { + engine.GetActionWithName("OnOff_Off").Apply(engine); + } + + foreach (var battery in batteries) + { + battery.GetActionWithName("Recharge").Apply(battery); + } + } + else if (connector.Status == MyShipConnectorStatus.Connected) + { + foreach (var battery in batteries) + { + battery.GetActionWithName("Auto").Apply(battery); + } + + foreach (var engine in engines) + { + engine.GetActionWithName("OnOff_On").Apply(engine); + } + + connector.GetActionWithName("SwitchLock").Apply(connector); + } + } + } +} diff --git a/Ingame/IMyAdvancedDoor.cs b/Ingame/IMyAdvancedDoor.cs new file mode 100644 index 0000000..a7387c0 --- /dev/null +++ b/Ingame/IMyAdvancedDoor.cs @@ -0,0 +1,11 @@ +using System; +using System.Collections.Generic; +using System.Linq; +using System.Text; + +namespace Sandbox.ModAPI.Ingame +{ + public interface IMyAdvancedDoor : IMyDoor + { + } +} diff --git a/Ingame/IMyAirtightDoorBase.cs b/Ingame/IMyAirtightDoorBase.cs new file mode 100644 index 0000000..0537084 --- /dev/null +++ b/Ingame/IMyAirtightDoorBase.cs @@ -0,0 +1,11 @@ +using System; +using System.Collections.Generic; +using System.Linq; +using System.Text; + +namespace Sandbox.ModAPI.Ingame +{ + public interface IMyAirtightDoorBase : IMyDoor + { + } +} diff --git a/Ingame/IMyAirtightHangarDoor.cs b/Ingame/IMyAirtightHangarDoor.cs new file mode 100644 index 0000000..a85888b --- /dev/null +++ b/Ingame/IMyAirtightHangarDoor.cs @@ -0,0 +1,11 @@ +using System; +using System.Collections.Generic; +using System.Linq; +using System.Text; + +namespace Sandbox.ModAPI.Ingame +{ + public interface IMyAirtightHangarDoor : IMyAirtightDoorBase + { + } +} diff --git a/Ingame/IMyAirtightSlideDoor.cs b/Ingame/IMyAirtightSlideDoor.cs new file mode 100644 index 0000000..07eca99 --- /dev/null +++ b/Ingame/IMyAirtightSlideDoor.cs @@ -0,0 +1,11 @@ +using System; +using System.Collections.Generic; +using System.Linq; +using System.Text; + +namespace Sandbox.ModAPI.Ingame +{ + public interface IMyAirtightSlideDoor : IMyAirtightDoorBase + { + } +} diff --git a/Ingame/IMyAssembler.cs b/Ingame/IMyAssembler.cs new file mode 100644 index 0000000..87e14d5 --- /dev/null +++ b/Ingame/IMyAssembler.cs @@ -0,0 +1,12 @@ +using System; +using System.Collections.Generic; +using System.Linq; +using System.Text; + +namespace Sandbox.ModAPI.Ingame +{ + public interface IMyAssembler : IMyProductionBlock + { + bool DisassembleEnabled { get; } + } +} diff --git a/Ingame/IMyBatteryBlock.cs b/Ingame/IMyBatteryBlock.cs new file mode 100644 index 0000000..204f5c1 --- /dev/null +++ b/Ingame/IMyBatteryBlock.cs @@ -0,0 +1,23 @@ +using System; +using System.Collections.Generic; +using System.Linq; +using System.Text; + +namespace Sandbox.ModAPI.Ingame +{ + public interface IMyBatteryBlock : IMyFunctionalBlock + { + bool HasCapacityRemaining { get; } + + float CurrentStoredPower { get; } + float MaxStoredPower { get; } + + float CurrentInput { get; } + float CurrentOutput { get; } + bool IsCharging { get; } + + bool OnlyRecharge { get; set; } + bool OnlyDischarge { get; set; } + bool SemiautoEnabled { get; set; } + } +} diff --git a/Ingame/IMyBeacon.cs b/Ingame/IMyBeacon.cs new file mode 100644 index 0000000..f428063 --- /dev/null +++ b/Ingame/IMyBeacon.cs @@ -0,0 +1,12 @@ +using System; +using System.Collections.Generic; +using System.Linq; +using System.Text; + +namespace Sandbox.ModAPI.Ingame +{ + public interface IMyBeacon : IMyFunctionalBlock + { + float Radius { get; } + } +} diff --git a/Ingame/IMyBlockGroup.cs b/Ingame/IMyBlockGroup.cs new file mode 100644 index 0000000..e1d4e1e --- /dev/null +++ b/Ingame/IMyBlockGroup.cs @@ -0,0 +1,17 @@ +using System; +using System.Collections.Generic; +using System.Linq; +using System.Text; +using Sandbox.ModAPI; + +namespace Sandbox.ModAPI.Ingame +{ + public interface IMyBlockGroup + { + void GetBlocks(List blocks, Func collect = null); + void GetBlocksOfType(List blocks, Func collect = null) where T : class; + void GetBlocksOfType(List blocks, Func collect = null) where T : class; + + string Name { get;} + } +} diff --git a/Ingame/IMyCameraBlock.cs b/Ingame/IMyCameraBlock.cs new file mode 100644 index 0000000..f61dd02 --- /dev/null +++ b/Ingame/IMyCameraBlock.cs @@ -0,0 +1,72 @@ +using System; +using System.Collections.Generic; +using System.Linq; +using System.Text; +using VRageMath; + +namespace Sandbox.ModAPI.Ingame +{ + public interface IMyCameraBlock:IMyFunctionalBlock + { + /// + /// Does a raycast in the direction the camera is facing. Pitch and Yaw are in degrees. + /// Will return an empty struct if distance or angle are out of bounds. + /// + /// + /// + /// + /// + MyDetectedEntityInfo Raycast(double distance, float pitch = 0, float yaw = 0); + + /// + /// Does a raycast to the given point. + /// Will return an empty struct if distance or angle are out of bounds. + /// + /// + /// + MyDetectedEntityInfo Raycast(Vector3D targetPos); + + /// + /// Does a raycast in the given direction. + /// Will return an empty struct if distance or angle are out of bounds. + /// + /// + /// + /// + MyDetectedEntityInfo Raycast(double distance, Vector3D targetDirection); + + /// + /// The maximum distance that this camera can scan, based on the time since the last scan. + /// + double AvailableScanRange { get; } + + /// + /// When this is true, the available raycast distance will count up, and power usage is increased. + /// + bool EnableRaycast { get; set; } + + /// + /// Checks if the camera can scan the given distance. + /// + /// + /// + bool CanScan(double distance); + + /// + /// Returns the number of milliseconds until the camera can do a raycast of the given distance. + /// + /// + /// + int TimeUntilScan(double distance); + + /// + /// Returns the maximum positive angle you can apply for pitch and yaw. + /// + float RaycastConeLimit { get; } + + /// + /// Returns the maximum distance you can request a raycast. -1 means infinite. + /// + double RaycastDistanceLimit { get; } + } +} diff --git a/Ingame/IMyCargoContainer.cs b/Ingame/IMyCargoContainer.cs new file mode 100644 index 0000000..ed5dc1c --- /dev/null +++ b/Ingame/IMyCargoContainer.cs @@ -0,0 +1,11 @@ +using System; +using System.Collections.Generic; +using System.Linq; +using System.Text; + +namespace Sandbox.ModAPI.Ingame +{ + public interface IMyCargoContainer : IMyTerminalBlock + { + } +} diff --git a/Ingame/IMyCockpit.cs b/Ingame/IMyCockpit.cs new file mode 100644 index 0000000..484ab7d --- /dev/null +++ b/Ingame/IMyCockpit.cs @@ -0,0 +1,11 @@ +using System; +using System.Collections.Generic; +using System.Linq; +using System.Text; + +namespace Sandbox.ModAPI.Ingame +{ + public interface IMyCockpit : IMyShipController + { + } +} diff --git a/Ingame/IMyCollector.cs b/Ingame/IMyCollector.cs new file mode 100644 index 0000000..20b40c1 --- /dev/null +++ b/Ingame/IMyCollector.cs @@ -0,0 +1,12 @@ +using System; +using System.Collections.Generic; +using System.Linq; +using System.Text; + +namespace Sandbox.ModAPI.Ingame +{ + public interface IMyCollector : IMyFunctionalBlock + { + bool UseConveyorSystem { get; } + } +} diff --git a/Ingame/IMyConveyor.cs b/Ingame/IMyConveyor.cs new file mode 100644 index 0000000..9091c8b --- /dev/null +++ b/Ingame/IMyConveyor.cs @@ -0,0 +1,13 @@ +using System; +using System.Collections.Generic; +using System.Linq; +using System.Text; +using System.Threading.Tasks; +using VRage.Game.ModAPI.Ingame; + +namespace Sandbox.ModAPI.Ingame +{ + public interface IMyConveyor : IMyCubeBlock + { + } +} diff --git a/Ingame/IMyConveyorSorter.cs b/Ingame/IMyConveyorSorter.cs new file mode 100644 index 0000000..4122b44 --- /dev/null +++ b/Ingame/IMyConveyorSorter.cs @@ -0,0 +1,104 @@ +using System; +using System.Collections.Generic; +using System.Linq; +using System.Text; +using VRage.Game; +using VRage.Game.ObjectBuilders.Definitions; + +namespace Sandbox.ModAPI.Ingame +{ + /// + /// Determines the current mode of a conveyor sorter. + /// + public enum MyConveyorSorterMode + { + /// + /// The items in the filter list are the only items allowed through this sorter. + /// + Whitelist, + + /// + /// The items in the filter list are not allowed through this sorter. + /// + Blacklist + } + + [Serializable] + public struct MyInventoryItemFilter + { + public static implicit operator MyInventoryItemFilter(MyDefinitionId definitionId) + { + return new MyInventoryItemFilter(definitionId); + } + + /// + /// Determines whether all subtypes of the given item ID should pass this filter check. + /// + public readonly bool AllSubTypes; + + /// + /// Specifies an item to filter. Set to true to only check the main type part of this ID. + /// + public readonly MyDefinitionId ItemId; + + public MyInventoryItemFilter(string itemId, bool allSubTypes = false) : this() + { + ItemId = MyDefinitionId.Parse(itemId); + AllSubTypes = allSubTypes; + } + + public MyInventoryItemFilter(MyDefinitionId itemId, bool allSubTypes = false) : this() + { + ItemId = itemId; + AllSubTypes = allSubTypes; + } + } + + public interface IMyConveyorSorter : IMyFunctionalBlock + { + /// + /// Determines whether the sorter should drain any inventories connected to it and push them to the other side - as long + /// as the items passes the filtering as defined by the filter list () and . + /// + bool DrainAll { get; set; } + + /// + /// Determines the current mode of this sorter. Use or to change the mode. + /// + MyConveyorSorterMode Mode { get; } + + /// + /// Gets the items currently being allowed through or rejected, depending on the . + /// + /// + void GetFilterList(List items); + + /// + /// Adds a single item to the filter list. See to change the filter mode and/or fill + /// the entire list in one go. + /// + /// + void AddItem(MyInventoryItemFilter item); + + /// + /// Removes a single item from the filter list. See to change the filter mode and/or clear + /// the entire list in one go. + /// + /// + void RemoveItem(MyInventoryItemFilter item); + + /// + /// Determines whether a given item type is allowed through the sorter, depending on the filter list () and . + /// + /// + /// + bool IsAllowed(MyDefinitionId id); + + /// + /// Changes the sorter to desired mode and filters the provided items. You can pass in null to empty the list. + /// + /// + /// + void SetFilter(MyConveyorSorterMode mode, List items); + } +} diff --git a/Ingame/IMyConveyorTube.cs b/Ingame/IMyConveyorTube.cs new file mode 100644 index 0000000..382c5e1 --- /dev/null +++ b/Ingame/IMyConveyorTube.cs @@ -0,0 +1,13 @@ +using System; +using System.Collections.Generic; +using System.Linq; +using System.Text; +using System.Threading.Tasks; +using VRage.Game.ModAPI.Ingame; + +namespace Sandbox.ModAPI.Ingame +{ + public interface IMyConveyorTube : IMyCubeBlock + { + } +} diff --git a/Ingame/IMyCryoChamber.cs b/Ingame/IMyCryoChamber.cs new file mode 100644 index 0000000..2570218 --- /dev/null +++ b/Ingame/IMyCryoChamber.cs @@ -0,0 +1,12 @@ +using System; +using System.Collections.Generic; +using System.Linq; +using System.Text; +using System.Threading.Tasks; + +namespace Sandbox.ModAPI.Ingame +{ + public interface IMyCryoChamber : IMyCockpit + { + } +} diff --git a/Ingame/IMyDecoy.cs b/Ingame/IMyDecoy.cs new file mode 100644 index 0000000..1110107 --- /dev/null +++ b/Ingame/IMyDecoy.cs @@ -0,0 +1,12 @@ +using System; +using System.Collections.Generic; +using System.Linq; +using System.Text; +using System.Threading.Tasks; + +namespace Sandbox.ModAPI.Ingame +{ + public interface IMyDecoy : IMyFunctionalBlock + { + } +} diff --git a/Ingame/IMyDoor.cs b/Ingame/IMyDoor.cs new file mode 100644 index 0000000..30c4ffd --- /dev/null +++ b/Ingame/IMyDoor.cs @@ -0,0 +1,20 @@ +using System; +using System.Collections.Generic; +using System.Linq; +using System.Text; + +namespace Sandbox.ModAPI.Ingame +{ + public interface IMyDoor : IMyFunctionalBlock + { + /// + /// Indicates whether door is opened or closed. True when door is opened. + /// + bool Open { get; } + + /// + /// Door state, zero is fully closed. One is fully opened. + /// + float OpenRatio { get; } + } +} diff --git a/Ingame/IMyExtendedPistonBase.cs b/Ingame/IMyExtendedPistonBase.cs new file mode 100644 index 0000000..9814c07 --- /dev/null +++ b/Ingame/IMyExtendedPistonBase.cs @@ -0,0 +1,12 @@ +using System; +using System.Collections.Generic; +using System.Linq; +using System.Text; +using VRage.Game.ModAPI; + +namespace Sandbox.ModAPI.Ingame +{ + public interface IMyExtendedPistonBase : IMyPistonBase + { + } +} diff --git a/Ingame/IMyFunctionalBlock.cs b/Ingame/IMyFunctionalBlock.cs new file mode 100644 index 0000000..7cff19b --- /dev/null +++ b/Ingame/IMyFunctionalBlock.cs @@ -0,0 +1,13 @@ +using System; +using System.Collections.Generic; +using System.Linq; +using System.Text; + +namespace Sandbox.ModAPI.Ingame +{ + public interface IMyFunctionalBlock : IMyTerminalBlock + { + bool Enabled { get; } + void RequestEnable(bool enable); + } +} diff --git a/Ingame/IMyGridProgramRuntimeInfo.cs b/Ingame/IMyGridProgramRuntimeInfo.cs new file mode 100644 index 0000000..398ddf5 --- /dev/null +++ b/Ingame/IMyGridProgramRuntimeInfo.cs @@ -0,0 +1,47 @@ +using System; +using System.Collections.Generic; +using System.Linq; +using System.Text; + +namespace Sandbox.ModAPI.Ingame +{ + /// + /// Provides runtime info for a running grid program. + /// + public interface IMyGridProgramRuntimeInfo + { + /// + /// Gets the time elapsed since the last time the Main method of this program was run. This property returns no + /// valid data neither in the constructor nor the Save method. + /// + TimeSpan TimeSinceLastRun { get; } + + /// + /// Gets the number of milliseconds it took to execute the Main method the last time it was run. This property returns no valid + /// data neither in the constructor nor the Save method. + /// + double LastRunTimeMs { get; } + + /// + /// Gets the maximum number of significant instructions that can be executing during a single run, including + /// any other programmable blocks invoked immediately. + /// + int MaxInstructionCount { get; } + + /// + /// Gets the current number of significant instructions executed. + /// + int CurrentInstructionCount { get; } + + /// + /// Gets the maximum number of method calls that can be executed during a single run, including + /// any other programmable blocks invoked immediately. + /// + int MaxMethodCallCount { get; } + + /// + /// Gets the current number of method calls. + /// + int CurrentMethodCallCount { get; } + } +} diff --git a/Ingame/IMyGridTerminalSystem.cs b/Ingame/IMyGridTerminalSystem.cs new file mode 100644 index 0000000..66ec779 --- /dev/null +++ b/Ingame/IMyGridTerminalSystem.cs @@ -0,0 +1,20 @@ +using System; +using System.Collections.Generic; +using VRage.Collections; +using VRage.Game.ModAPI.Ingame; +using VRageMath; + +namespace Sandbox.ModAPI.Ingame +{ + public interface IMyGridTerminalSystem + { + void GetBlocks(List blocks); + void GetBlockGroups(List blockGroups, Func collect = null); + void GetBlocksOfType(List blocks, Func collect = null) where T: class; + void GetBlocksOfType(List blocks, Func collect = null) where T: class; + void SearchBlocksOfName(string name, List blocks, Func collect = null); + IMyTerminalBlock GetBlockWithName(string name); + IMyBlockGroup GetBlockGroupWithName(string name); + IMyTerminalBlock GetBlockWithId(long id); + } +} diff --git a/Ingame/IMyGyro.cs b/Ingame/IMyGyro.cs new file mode 100644 index 0000000..5f26b7b --- /dev/null +++ b/Ingame/IMyGyro.cs @@ -0,0 +1,16 @@ +using System; +using System.Collections.Generic; +using System.Linq; +using System.Text; + +namespace Sandbox.ModAPI.Ingame +{ + public interface IMyGyro : IMyFunctionalBlock + { + float GyroPower { get; } + bool GyroOverride { get; } + float Yaw { get; } + float Pitch { get; } + float Roll { get; } + } +} diff --git a/Ingame/IMyJumpDrive.cs b/Ingame/IMyJumpDrive.cs new file mode 100644 index 0000000..7f34ef3 --- /dev/null +++ b/Ingame/IMyJumpDrive.cs @@ -0,0 +1,11 @@ +using System; +using System.Collections.Generic; +using System.Linq; +using System.Text; + +namespace Sandbox.ModAPI.Ingame +{ + public interface IMyJumpDrive : IMyFunctionalBlock + { + } +} diff --git a/Ingame/IMyLCDScreen.cs b/Ingame/IMyLCDScreen.cs new file mode 100644 index 0000000..c9cc422 --- /dev/null +++ b/Ingame/IMyLCDScreen.cs @@ -0,0 +1,11 @@ +using System; +using System.Collections.Generic; +using System.Linq; +using System.Text; + +namespace Sandbox.ModAPI.Ingame +{ + public interface IMyLCDScreen + { + } +} diff --git a/Ingame/IMyLargeTurretBase.cs b/Ingame/IMyLargeTurretBase.cs new file mode 100644 index 0000000..888dfe9 --- /dev/null +++ b/Ingame/IMyLargeTurretBase.cs @@ -0,0 +1,74 @@ +using System; +using System.Collections.Generic; +using System.Linq; +using System.Text; +using VRageMath; +using Sandbox.ModAPI; +using VRage.ModAPI; + +namespace Sandbox.ModAPI.Ingame +{ + public interface IMyLargeTurretBase : IMyUserControllableGun + { + /// + /// Indicates whether a block is locally or remotely controlled. + /// + bool IsUnderControl { get; } + bool CanControl { get; } + float Range { get; } + + /// + /// Tracks entity with enabled position prediction + /// + /// + void TrackTarget(IMyEntity entity); + /// + /// Tracks given target with enabled position prediction + /// + /// + /// + void TrackTarget(Vector3D pos, Vector3 velocity); + /// + /// Tracks target without position prediction + /// + /// + void SetTarget(IMyEntity Entity); + /// + /// Targets given position + /// + /// + void SetTarget(Vector3D pos); + /// + /// Sets/gets elevation of turret, this method is not synced, you need to sync elevation manually + /// + float Elevation { get; set; } + /// + /// method used to sync elevation of turret , you need to call it to sync elevation for other clients/server + /// + void SyncElevation(); + /// + /// Sets/gets azimuth of turret, this method is not synced, you need to sync azimuth manually + /// + float Azimuth { get; set; } + /// + /// method used to sync azimuth, you need to call it to sync azimuth for other clients/server + /// + void SyncAzimuth(); + /// + /// enable/disable idle rotation for turret, this method is not synced, you need to sync manually + /// + bool EnableIdleRotation { get; set; } + /// + /// method used to sync idle rotation and elevation, you need to call it to sync rotation and elevation for other clients/server + /// + void SyncEnableIdleRotation(); + /// + /// Checks is AI is enabled for turret + /// + bool AIEnabled { get; } + /// + /// resert targeting to default values + /// + void ResetTargetingToDefault(); + } +} diff --git a/Ingame/IMyLaserAntenna.cs b/Ingame/IMyLaserAntenna.cs new file mode 100644 index 0000000..240e1ed --- /dev/null +++ b/Ingame/IMyLaserAntenna.cs @@ -0,0 +1,43 @@ +using System; +using System.Collections.Generic; +using System.Linq; +using System.Text; +using VRageMath; + +namespace Sandbox.ModAPI.Ingame +{ + /// + /// Laser antenna block interface + /// + public interface IMyLaserAntenna : IMyFunctionalBlock + { + /// + /// get target coordinates + /// + Vector3D TargetCoords + { + get; + } + + /// + /// Set coordinates of target + /// + /// GPS coordinates string + void SetTargetCoords(string coords); + + /// + /// Connect to target defined by SetTargetCoords + /// + void Connect(); + + /// + /// Connection is permanent + /// + bool IsPermanent { get; } + + /// + /// Target is outside movement limits of antenna + /// + bool IsOutsideLimits { get; } + } +} diff --git a/Ingame/IMyLightingBlock.cs b/Ingame/IMyLightingBlock.cs new file mode 100644 index 0000000..82d9f93 --- /dev/null +++ b/Ingame/IMyLightingBlock.cs @@ -0,0 +1,19 @@ +using System; +using System.Collections.Generic; +using System.Linq; +using System.Text; + +namespace Sandbox.ModAPI.Ingame +{ + public interface IMyLightingBlock : IMyFunctionalBlock + { + float Radius { get; } + float ReflectorRadius { get; } + float Intensity { get; } + float BlinkIntervalSeconds{get;} + [Obsolete("Use BlinkLength instead.")] + float BlinkLenght { get; } + float BlinkLength { get; } + float BlinkOffset{get;} + } +} diff --git a/Ingame/IMyMotorAdvancedRotor.cs b/Ingame/IMyMotorAdvancedRotor.cs new file mode 100644 index 0000000..7fec5fc --- /dev/null +++ b/Ingame/IMyMotorAdvancedRotor.cs @@ -0,0 +1,12 @@ +using System; +using System.Collections.Generic; +using System.Linq; +using System.Text; +using System.Threading.Tasks; + +namespace Sandbox.ModAPI.Ingame +{ + public interface IMyMotorAdvancedRotor : IMyMotorRotor + { + } +} diff --git a/Ingame/IMyMotorAdvancedStator.cs b/Ingame/IMyMotorAdvancedStator.cs new file mode 100644 index 0000000..de1f731 --- /dev/null +++ b/Ingame/IMyMotorAdvancedStator.cs @@ -0,0 +1,12 @@ +using System; +using System.Collections.Generic; +using System.Linq; +using System.Text; + +namespace Sandbox.ModAPI.Ingame +{ + public interface IMyMotorAdvancedStator : IMyMotorStator + { + + } +} diff --git a/Ingame/IMyMotorBase.cs b/Ingame/IMyMotorBase.cs new file mode 100644 index 0000000..5cf175f --- /dev/null +++ b/Ingame/IMyMotorBase.cs @@ -0,0 +1,30 @@ +using System; +using System.Collections.Generic; +using System.Linq; +using System.Text; + +namespace Sandbox.ModAPI.Ingame +{ + public interface IMyMotorBase : IMyFunctionalBlock + { + /// + /// Gets if the piston top is attached to something + /// + bool IsAttached { get; } + + /// + /// Gets if the motor stator is looking for a rotor + /// + bool PendingAttachment { get; } + + /// + /// Attempts to attach to a nearby rotor/wheel + /// + void Attach(); + + /// + /// Detaches the rotor/wheel from the stator/suspension + /// + void Detach(); + } +} diff --git a/Ingame/IMyMotorRotor.cs b/Ingame/IMyMotorRotor.cs new file mode 100644 index 0000000..c70ba6d --- /dev/null +++ b/Ingame/IMyMotorRotor.cs @@ -0,0 +1,16 @@ +using System; +using System.Collections.Generic; +using System.Linq; +using System.Text; +using VRage.Game.ModAPI.Ingame; + +namespace Sandbox.ModAPI.Ingame +{ + public interface IMyMotorRotor : IMyCubeBlock + { + /// + /// Gets whether the rotor is attached to a stator/suspension block + /// + bool IsAttached { get; } + } +} diff --git a/Ingame/IMyMotorStator.cs b/Ingame/IMyMotorStator.cs new file mode 100644 index 0000000..db3c67b --- /dev/null +++ b/Ingame/IMyMotorStator.cs @@ -0,0 +1,20 @@ +using System; +using System.Collections.Generic; +using System.Linq; +using System.Text; + +namespace Sandbox.ModAPI.Ingame +{ + public interface IMyMotorStator : IMyMotorBase + { + bool IsLocked { get; } + float Angle { get; } + float Torque { get; } + float BrakingTorque { get; } + float Velocity { get; } + float LowerLimit { get; } + float UpperLimit { get; } + float Displacement { get; } + } + +} diff --git a/Ingame/IMyMotorSuspension.cs b/Ingame/IMyMotorSuspension.cs new file mode 100644 index 0000000..064621c --- /dev/null +++ b/Ingame/IMyMotorSuspension.cs @@ -0,0 +1,58 @@ +using System; +using System.Collections.Generic; +using System.Linq; +using System.Text; + +namespace Sandbox.ModAPI.Ingame +{ + public interface IMyMotorSuspension : IMyMotorBase + { + bool Steering { get; } + + bool Propulsion { get; } + + bool InvertSteer { get; } + + bool InvertPropulsion { get; } + + float Damping { get; } + + float Strength { get; } + + float Friction { get; } + + float Power { get; } + + float Height { get; } + + /// + /// Wheel's current steering angle + /// + float SteerAngle { get; } + + /// + /// Max steering angle in radians. + /// + float MaxSteerAngle { get; } + + /// + /// Speed at which wheel steers. + /// + float SteerSpeed { get; } + + /// + /// Speed at which wheel returns from steering. + /// + float SteerReturnSpeed { get; } + + /// + /// Suspension travel, value from 0 to 1. + /// + float SuspensionTravel { get; } + + /// + /// Set/get brake applied to the wheel. + /// + bool Brake { get; set; } + } +} diff --git a/Ingame/IMyOreDetector.cs b/Ingame/IMyOreDetector.cs new file mode 100644 index 0000000..a5829e6 --- /dev/null +++ b/Ingame/IMyOreDetector.cs @@ -0,0 +1,13 @@ +using System; +using System.Collections.Generic; +using System.Linq; +using System.Text; + +namespace Sandbox.ModAPI.Ingame +{ + public interface IMyOreDetector : IMyFunctionalBlock + { + float Range {get;} + bool BroadcastUsingAntennas {get;} + } +} diff --git a/Ingame/IMyOxygenGenerator.cs b/Ingame/IMyOxygenGenerator.cs new file mode 100644 index 0000000..a1e3cdd --- /dev/null +++ b/Ingame/IMyOxygenGenerator.cs @@ -0,0 +1,18 @@ +using System; +using System.Collections.Generic; +using System.Linq; +using System.Text; + +namespace Sandbox.ModAPI.Ingame +{ + /// + /// Oxygen generator interface + /// + public interface IMyOxygenGenerator : IMyFunctionalBlock + { + /// + /// Autorefill enabled + /// + bool AutoRefill { get; } + } +} diff --git a/Ingame/IMyOxygenTank.cs b/Ingame/IMyOxygenTank.cs new file mode 100644 index 0000000..89b5e49 --- /dev/null +++ b/Ingame/IMyOxygenTank.cs @@ -0,0 +1,7 @@ +namespace Sandbox.ModAPI.Ingame +{ + public interface IMyOxygenTank : IMyFunctionalBlock + { + float GetOxygenLevel(); + } +} diff --git a/Ingame/IMyPassage.cs b/Ingame/IMyPassage.cs new file mode 100644 index 0000000..83b7a92 --- /dev/null +++ b/Ingame/IMyPassage.cs @@ -0,0 +1,13 @@ +using System; +using System.Collections.Generic; +using System.Linq; +using System.Text; +using System.Threading.Tasks; +using VRage.Game.ModAPI.Ingame; + +namespace Sandbox.ModAPI.Ingame +{ + public interface IMyPassage : IMyCubeBlock + { + } +} diff --git a/Ingame/IMyPistonBase.cs b/Ingame/IMyPistonBase.cs new file mode 100644 index 0000000..83a7f26 --- /dev/null +++ b/Ingame/IMyPistonBase.cs @@ -0,0 +1,52 @@ +using System; +using System.Collections.Generic; +using System.Linq; +using System.Text; + +namespace Sandbox.ModAPI.Ingame +{ + public interface IMyPistonBase : IMyFunctionalBlock + { + /// + /// Param - limit is top + /// + float Velocity { get; } + float MinLimit { get; } + float MaxLimit { get; } + + /// + /// Gets the current position of the piston head relative to the base. + /// + float CurrentPosition { get; } + + /// + /// Gets the current status. + /// + PistonStatus Status { get; } + + /// + /// Gets if the piston base is attached to the top piece + /// + bool IsAttached { get; } + + /// + /// Gets if the piston is safety locked (welded) + /// + bool IsLocked { get; } + + /// + /// Gets if the piston is looking for a top part + /// + bool PendingAttachment { get; } + + /// + /// Attaches a nearby top part to the piston block + /// + void Attach(); + + /// + /// Detaches the top from the piston + /// + void Detach(); + } +} diff --git a/Ingame/IMyPistonTop.cs b/Ingame/IMyPistonTop.cs new file mode 100644 index 0000000..ca51da5 --- /dev/null +++ b/Ingame/IMyPistonTop.cs @@ -0,0 +1,13 @@ +using System; +using System.Collections.Generic; +using System.Linq; +using System.Text; +using VRage.Game.ModAPI.Ingame; + +namespace Sandbox.ModAPI.Ingame +{ + public interface IMyPistonTop : IMyCubeBlock + { + bool IsAttached { get; } + } +} diff --git a/Ingame/IMyProductionBlock.cs b/Ingame/IMyProductionBlock.cs new file mode 100644 index 0000000..48d8e44 --- /dev/null +++ b/Ingame/IMyProductionBlock.cs @@ -0,0 +1,18 @@ +using System; +using System.Collections.Generic; +using System.Linq; +using System.Text; +using VRage; + +namespace Sandbox.ModAPI.Ingame +{ + public interface IMyProductionBlock:IMyFunctionalBlock + { + bool IsProducing { get; } + bool IsQueueEmpty { get; } + void MoveQueueItemRequest(uint queueItemId, int targetIdx); + uint NextItemId { get; } + //event Action QueueChanged; + bool UseConveyorSystem { get; } + } +} diff --git a/Ingame/IMyProgrammableBlock.cs b/Ingame/IMyProgrammableBlock.cs new file mode 100644 index 0000000..66b9f28 --- /dev/null +++ b/Ingame/IMyProgrammableBlock.cs @@ -0,0 +1,29 @@ +using System; +using System.Collections.Generic; +using System.Linq; +using System.Text; + +namespace Sandbox.ModAPI.Ingame +{ + public interface IMyProgrammableBlock : IMyFunctionalBlock + { + /// + /// This programmable block is currently running its program. + /// + bool IsRunning { get; } + + /// + /// Contains the value of the default terminal argument. + /// + string TerminalRunArgument { get; } + + /// + /// Attempts to run this programmable block using the given argument. An already running + /// programmable block cannot be run again. + /// This is equivalent to running block.ApplyAction("Run", argumentsList); + /// + /// + /// true if the action was applied, false otherwise + bool TryRun(string argument); + } +} diff --git a/Ingame/IMyProjector.cs b/Ingame/IMyProjector.cs new file mode 100644 index 0000000..6bf5844 --- /dev/null +++ b/Ingame/IMyProjector.cs @@ -0,0 +1,73 @@ +using System; +using System.Collections.Generic; +using VRage.Game; +using VRageMath; + +namespace Sandbox.ModAPI.Ingame +{ + public interface IMyProjector : IMyFunctionalBlock + { + [Obsolete( "Use ProjectionOffset vector instead." )] + int ProjectionOffsetX { get; } + + [Obsolete( "Use ProjectionOffset vector instead." )] + int ProjectionOffsetY { get; } + + [Obsolete( "Use ProjectionOffset vector instead." )] + int ProjectionOffsetZ { get; } + + [Obsolete( "Use ProjectionRotation vector instead." )] + int ProjectionRotX { get; } + + [Obsolete( "Use ProjectionRotation vector instead." )] + int ProjectionRotY { get; } + + [Obsolete( "Use ProjectionRotation vector instead." )] + int ProjectionRotZ { get; } + + /// + /// Checks if there is an active projection + /// + bool IsProjecting { get; } + + /// + /// Total number of blocks in the projection + /// + int TotalBlocks { get; } + + /// + /// Number of blocks left to be welded + /// + int RemainingBlocks { get; } + + /// + /// A comprehensive list of blocks left to be welded + /// + Dictionary RemainingBlocksPerType { get; } + + /// + /// Number of armor blocks left to be welded + /// + int RemainingArmorBlocks { get; } + + /// + /// Count of blocks which can be welded now + /// + int BuildableBlocksCount { get; } + + Vector3I ProjectionOffset { get; set; } + + /// + /// These values are not in degrees. 1 = 90 degrees, 2 = 180 degrees + /// + Vector3I ProjectionRotation { get; set; } + + /// + /// Call this after setting ProjectionOffset and ProjectionRotation to update the projection + /// + void UpdateOffsetAndRotation(); + + bool LoadRandomBlueprint( string searchPattern ); + bool LoadBlueprint( string name ); + } +} diff --git a/Ingame/IMyRadioAntenna.cs b/Ingame/IMyRadioAntenna.cs new file mode 100644 index 0000000..954fa89 --- /dev/null +++ b/Ingame/IMyRadioAntenna.cs @@ -0,0 +1,28 @@ +using System; +using System.Collections.Generic; +using System.Linq; +using System.Text; + +namespace Sandbox.ModAPI.Ingame +{ + /// + /// Antenna block interface + /// + public interface IMyRadioAntenna : IMyFunctionalBlock + { + /// + /// Broadcasting/Receiving range (read-only) + /// + float Radius {get; } + + /// + /// Show shipname on hud (read-only) + /// + bool ShowShipName { get; } + + /// + /// Returns true if antena is broadcasting (read-only) + /// + bool IsBroadcasting { get; } + } +} diff --git a/Ingame/IMyReactor.cs b/Ingame/IMyReactor.cs new file mode 100644 index 0000000..8c94b48 --- /dev/null +++ b/Ingame/IMyReactor.cs @@ -0,0 +1,22 @@ +using System; +using System.Collections.Generic; +using System.Linq; +using System.Text; + +namespace Sandbox.ModAPI.Ingame +{ + public interface IMyReactor : IMyFunctionalBlock + { + bool UseConveyorSystem { get; } + + /// + /// Current output of reactor in Megawatts + /// + float CurrentOutput { get; } + + /// + /// Maximum output of reactor in Megawatts + /// + float MaxOutput { get; } + } +} diff --git a/Ingame/IMyRefinery.cs b/Ingame/IMyRefinery.cs new file mode 100644 index 0000000..f338ccc --- /dev/null +++ b/Ingame/IMyRefinery.cs @@ -0,0 +1,11 @@ +using System; +using System.Collections.Generic; +using System.Linq; +using System.Text; + +namespace Sandbox.ModAPI.Ingame +{ + public interface IMyRefinery : IMyProductionBlock + { + } +} diff --git a/Ingame/IMyReflectorLight.cs b/Ingame/IMyReflectorLight.cs new file mode 100644 index 0000000..16cff1e --- /dev/null +++ b/Ingame/IMyReflectorLight.cs @@ -0,0 +1,11 @@ +using System; +using System.Collections.Generic; +using System.Linq; +using System.Text; + +namespace Sandbox.ModAPI.Ingame +{ + public interface IMyReflectorLight:IMyLightingBlock + { + } +} diff --git a/Ingame/IMyRemoteControl.cs b/Ingame/IMyRemoteControl.cs new file mode 100644 index 0000000..53ab1c8 --- /dev/null +++ b/Ingame/IMyRemoteControl.cs @@ -0,0 +1,65 @@ +using System; +using System.Collections.Generic; +using System.Linq; +using System.Text; +using VRageMath; + +namespace Sandbox.ModAPI.Ingame +{ + /// + /// Provides basic information about a waypoint. + /// + public struct MyWaypointInfo + { + /// + /// The waypoint name + /// + public readonly string Name; + + /// + /// The coordinates of this waypoint + /// + public readonly Vector3D Coords; + + public MyWaypointInfo(string name, Vector3D coords) + { + Name = name; + Coords = coords; + } + } + + public interface IMyRemoteControl : IMyShipController + { + // Gets the nearest player's position. Will only work if the remote control belongs to an NPC + bool GetNearestPlayer(out Vector3D playerPosition); + + /// + /// Removes all existing waypoints. + /// + void ClearWaypoints(); + + /// + /// Gets basic information about the currently configured waypoints. + /// + /// + void GetWaypointInfo(List waypoints); + + /// + /// Adds a new waypoint. + /// + /// + /// + void AddWaypoint(Vector3D coords, string name); + + /// + /// Enables or disables the autopilot. + /// + /// + void SetAutoPilotEnabled(bool enabled); + + /// + /// Determines whether the autopilot is currently enabled. + /// + bool IsAutoPilotEnabled { get; } + } +} diff --git a/Ingame/IMySensorBlock.cs b/Ingame/IMySensorBlock.cs new file mode 100644 index 0000000..fde58c0 --- /dev/null +++ b/Ingame/IMySensorBlock.cs @@ -0,0 +1,41 @@ +using System; +using System.Collections.Generic; +using System.Linq; +using System.Text; +using VRage.ModAPI; + +namespace Sandbox.ModAPI.Ingame +{ + public interface IMySensorBlock : IMyFunctionalBlock + { + /// + /// Param - active + /// + float MaxRange { get; } + float LeftExtend { get; } + float RightExtend { get; } + float TopExtend { get; } + float BottomExtend { get; } + float FrontExtend { get; } + float BackExtend { get; } + + bool PlayProximitySound { get; } + bool DetectPlayers { get; } + bool DetectFloatingObjects { get; } + bool DetectSmallShips { get; } + bool DetectLargeShips { get; } + bool DetectStations { get; } + bool DetectSubgrids { get; } + bool DetectAsteroids { get; } + + bool DetectOwner { get; } + bool DetectFriendly { get; } + bool DetectNeutral { get; } + bool DetectEnemy { get; } + + bool IsActive { get; } + + MyDetectedEntityInfo LastDetectedEntity { get; } + void DetectedEntities(List entities); + } +} diff --git a/Ingame/IMyShipConnector.cs b/Ingame/IMyShipConnector.cs new file mode 100644 index 0000000..881868c --- /dev/null +++ b/Ingame/IMyShipConnector.cs @@ -0,0 +1,16 @@ +using System; +using System.Collections.Generic; +using System.Linq; +using System.Text; + +namespace Sandbox.ModAPI.Ingame +{ + public interface IMyShipConnector:IMyFunctionalBlock + { + bool ThrowOut { get; } + bool CollectAll { get; } + bool IsLocked { get; } + bool IsConnected { get; } + IMyShipConnector OtherConnector { get; } + } +} diff --git a/Ingame/IMyShipController.cs b/Ingame/IMyShipController.cs new file mode 100644 index 0000000..8f9b254 --- /dev/null +++ b/Ingame/IMyShipController.cs @@ -0,0 +1,161 @@ +using System; +using System.Collections.Generic; +using System.Linq; +using System.Security.Cryptography.X509Certificates; +using System.Text; +using VRageMath; + +namespace Sandbox.ModAPI.Ingame +{ + public struct MyShipMass + { + /// + /// Gets the base mass of the ship. + /// + public readonly int BaseMass; + + /// + /// Gets the total mass of the ship, including cargo. + /// + public readonly int TotalMass; + + public MyShipMass(int mass, int totalMass) : this() + { + BaseMass = mass; + TotalMass = totalMass; + } + } + + /// + /// Describes what detail level to retrieve the planet elevation for. + /// + public enum MyPlanetElevation + { + /// + /// Only return the distance to the planetary sealevel. + /// + Sealevel, + + /// + /// Return the distance to the closest point of the planet. This is the same value + /// displayed in the HUD. + /// + Surface + } + + public struct MyShipVelocities + { + /// + /// Gets the ship's linear velocity (motion). + /// + public readonly Vector3D LinearVelocity; + + /// + /// Gets the ship's angular velocity (rotation). + /// + public readonly Vector3D AngularVelocity; + + public MyShipVelocities(Vector3D linearVelocity, Vector3D angularVelocity) : this() + { + LinearVelocity = linearVelocity; + AngularVelocity = angularVelocity; + } + } + + public interface IMyShipController : IMyTerminalBlock + { + /// + /// Indicates whether a block is locally or remotely controlled. + /// + bool IsUnderControl { get; } + + /// + /// Indicates whether wheels are being controlled by this controller. + /// + bool ControlWheels { get; } + + /// + /// Indicates whether thrusters are being controlled by this controller. + /// + bool ControlThrusters { get; } + + /// + /// Indicates the current state of the handbrake. + /// + bool HandBrake { get; } + + /// + /// Indicates whether dampeners are currently enabled. + /// + bool DampenersOverride { get; } + + /// + /// Gets the detected natural gravity vector and power at the current location. + /// + /// + Vector3D GetNaturalGravity(); + + /// + /// Gets the detected artificial gravity vector and power at the current location. + /// + /// + Vector3D GetArtificialGravity(); + + /// + /// Gets the total accumulated gravity vector and power at the current location, + /// taking both natural and artificial gravity into account. + /// + /// + Vector3D GetTotalGravity(); + + /// + /// Gets the basic ship speed in meters per second, for when you just need to know how fast you're going. + /// + /// + double GetShipSpeed(); + + /// + /// Determines the linear velocities in meters per second and angular velocities in radians per second. + /// Provides a more accurate representation of the directions and axis speeds. + /// + MyShipVelocities GetShipVelocities(); + + /// + /// Gets information about the current mass of the ship. + /// + /// + MyShipMass CalculateShipMass(); + + /// + /// Attempts to get the world position of the nearest planet. This method is only available when a ship is + /// within the gravity well of a planet. + /// + /// + /// + bool TryGetPlanetPosition(out Vector3D position); + + /// + /// Attempts to get the elevation of the ship in relation to the nearest planet. This method is only available + /// when a ship is within the gravity well of a planet. + /// + /// + /// + /// + bool TryGetPlanetElevation(MyPlanetElevation detail, out double elevation); + + /// + /// Directional input from user/autopilot. Values can be very large with high controller sensitivity + /// + Vector3 MoveIndicator { get; } + + /// + /// Pitch, yaw input from user/autopilot. Values can be very large with high controller sensitivity + /// + Vector2 RotationIndicator { get; } + + /// + /// Roll input from user/autopilot. Values can be very large with high controller sensitivity + /// + float RollIndicator { get; } + } +} diff --git a/Ingame/IMyShipDrill.cs b/Ingame/IMyShipDrill.cs new file mode 100644 index 0000000..f1115ba --- /dev/null +++ b/Ingame/IMyShipDrill.cs @@ -0,0 +1,12 @@ +using System; +using System.Collections.Generic; +using System.Linq; +using System.Text; + +namespace Sandbox.ModAPI.Ingame +{ + public interface IMyShipDrill : IMyFunctionalBlock + { + bool UseConveyorSystem { get; } + } +} diff --git a/Ingame/IMyShipGrinder.cs b/Ingame/IMyShipGrinder.cs new file mode 100644 index 0000000..a126ec7 --- /dev/null +++ b/Ingame/IMyShipGrinder.cs @@ -0,0 +1,11 @@ +using System; +using System.Collections.Generic; +using System.Linq; +using System.Text; + +namespace Sandbox.ModAPI.Ingame +{ + public interface IMyShipGrinder : IMyShipToolBase + { + } +} diff --git a/Ingame/IMyShipToolBase.cs b/Ingame/IMyShipToolBase.cs new file mode 100644 index 0000000..4315009 --- /dev/null +++ b/Ingame/IMyShipToolBase.cs @@ -0,0 +1,12 @@ +using System; +using System.Collections.Generic; +using System.Linq; +using System.Text; + +namespace Sandbox.ModAPI.Ingame +{ + public interface IMyShipToolBase : IMyFunctionalBlock + { + bool UseConveyorSystem { get; } + } +} diff --git a/Ingame/IMyShipWelder.cs b/Ingame/IMyShipWelder.cs new file mode 100644 index 0000000..4b9d628 --- /dev/null +++ b/Ingame/IMyShipWelder.cs @@ -0,0 +1,18 @@ +using System; +using System.Collections.Generic; +using System.Linq; +using System.Text; + +namespace Sandbox.ModAPI.Ingame +{ + /// + /// Ship welder interface + /// + public interface IMyShipWelder : IMyShipToolBase + { + /// + /// True if welder is set to helper mode + /// + bool HelpOthers { get; } + } +} diff --git a/Ingame/IMySmallGatlingGun.cs b/Ingame/IMySmallGatlingGun.cs new file mode 100644 index 0000000..0c3ad41 --- /dev/null +++ b/Ingame/IMySmallGatlingGun.cs @@ -0,0 +1,12 @@ +using System; +using System.Collections.Generic; +using System.Linq; +using System.Text; + +namespace Sandbox.ModAPI.Ingame +{ + public interface IMySmallGatlingGun : IMyUserControllableGun + { + bool UseConveyorSystem { get; } + } +} diff --git a/Ingame/IMySmallMissileLauncher.cs b/Ingame/IMySmallMissileLauncher.cs new file mode 100644 index 0000000..e9d366e --- /dev/null +++ b/Ingame/IMySmallMissileLauncher.cs @@ -0,0 +1,12 @@ +using System; +using System.Collections.Generic; +using System.Linq; +using System.Text; + +namespace Sandbox.ModAPI.Ingame +{ + public interface IMySmallMissileLauncher : IMyUserControllableGun + { + bool UseConveyorSystem { get; } + } +} diff --git a/Ingame/IMySmallMissileLauncherReload.cs b/Ingame/IMySmallMissileLauncherReload.cs new file mode 100644 index 0000000..84a9d80 --- /dev/null +++ b/Ingame/IMySmallMissileLauncherReload.cs @@ -0,0 +1,11 @@ +using System; +using System.Collections.Generic; +using System.Linq; +using System.Text; + +namespace Sandbox.ModAPI.Ingame +{ + public interface IMySmallMissileLauncherReload : IMySmallMissileLauncher + { + } +} diff --git a/Ingame/IMyTerminalBlock.cs b/Ingame/IMyTerminalBlock.cs new file mode 100644 index 0000000..5a700c7 --- /dev/null +++ b/Ingame/IMyTerminalBlock.cs @@ -0,0 +1,113 @@ +using System; +using System.Collections.Generic; +using System.Linq; +using System.Text; +using VRage.Collections; +using VRage.Game.Entity; +using VRage.Game.ModAPI.Ingame; +using IMyInventoryOwner = VRage.Game.ModAPI.Ingame.IMyInventoryOwner; +namespace Sandbox.ModAPI.Ingame +{ + public interface IMyTerminalBlock : IMyCubeBlock + { + string CustomName { get; } + string CustomNameWithFaction { get; } + string DetailedInfo { get; } + string CustomInfo { get; } + /// + /// Gets or sets the Custom Data string. + /// NOTE: Only use this for user input. For storing large mod configs, create your own MyModStorageComponent + /// + string CustomData { get; set; } + bool HasLocalPlayerAccess(); + bool HasPlayerAccess(long playerId); + void SetCustomName(string text); + void SetCustomName(StringBuilder text); + bool ShowOnHUD { get; } + void GetActions(List resultList, Func collect = null); + void SearchActionsOfName(string name,List resultList, Func collect = null); + Sandbox.ModAPI.Interfaces.ITerminalAction GetActionWithName(string name); + Sandbox.ModAPI.Interfaces.ITerminalProperty GetProperty(string id); + void GetProperties(List resultList, Func collect = null); + } + + /* + Written by Kalvin Osborne, AKA Night Lone. Please do not remove this line. + */ + public static class TerminalBlockExtentions + { + public static long GetId(this IMyTerminalBlock block) + { + return block.EntityId; + } + + public static void ApplyAction(this Sandbox.ModAPI.Ingame.IMyTerminalBlock block, string actionName) + { + block.GetActionWithName(actionName).Apply(block); + } + + public static void ApplyAction(this Sandbox.ModAPI.Ingame.IMyTerminalBlock block, string actionName, List parameters) + { + block.GetActionWithName(actionName).Apply(block, parameters); + } + + public static bool HasAction(this Sandbox.ModAPI.Ingame.IMyTerminalBlock block, string actionName) + { + return block.GetActionWithName(actionName) != null; + } + + public static bool HasInventory(this Sandbox.ModAPI.Ingame.IMyTerminalBlock block) + { + var entity = block as MyEntity; + if (entity == null) + return false; + if (!(block is IMyInventoryOwner)) + return false; + + return entity.HasInventory; + } + + public static VRage.Game.ModAPI.Ingame.IMyInventory GetInventory(this Sandbox.ModAPI.Ingame.IMyTerminalBlock block, int index) + { + var entity = block as MyEntity; + if (entity == null) + return null; + + if (!entity.HasInventory) + return null; + + return entity.GetInventoryBase(index) as IMyInventory; + } + + public static int GetInventoryCount(this Sandbox.ModAPI.Ingame.IMyTerminalBlock block) + { + var entity = block as MyEntity; + if (entity == null) + return 0; + + return entity.InventoryCount; + } + + [Obsolete("Use the blocks themselves, this method is no longer reliable")] + public static bool GetUseConveyorSystem(this Sandbox.ModAPI.Ingame.IMyTerminalBlock block) + { + if (block is IMyInventoryOwner) + { + return ((IMyInventoryOwner)block).UseConveyorSystem; + } + else + { + return false; + } + } + + [Obsolete("Use the blocks themselves, this method is no longer reliable")] + public static void SetUseConveyorSystem(this Sandbox.ModAPI.Ingame.IMyTerminalBlock block, bool use) + { + if (block is IMyInventoryOwner) + { + ((IMyInventoryOwner)block).UseConveyorSystem = use; + } + } + } +} diff --git a/Ingame/IMyTextPanel.cs b/Ingame/IMyTextPanel.cs new file mode 100644 index 0000000..6b3d477 --- /dev/null +++ b/Ingame/IMyTextPanel.cs @@ -0,0 +1,66 @@ +using System; +using System.Collections.Generic; +using System.Linq; +using System.Text; +using VRage.Game.GUI.TextPanel; + +namespace Sandbox.ModAPI.Ingame +{ + public interface IMyTextPanel : IMyFunctionalBlock + { + bool WritePublicText(string value, bool append = false); + string GetPublicText(); + + bool WritePublicTitle(string value, bool append = false); + string GetPublicTitle(); + + [Obsolete("LCD private text is deprecated")] + bool WritePrivateText(string value, bool append = false); + [Obsolete("LCD private text is deprecated")] + string GetPrivateText(); + + [Obsolete("LCD private text is deprecated")] + bool WritePrivateTitle(string value, bool append = false); + [Obsolete("LCD private text is deprecated")] + string GetPrivateTitle(); + + void AddImageToSelection(string id, bool checkExistence = false); + void AddImagesToSelection(List ids, bool checkExistence = false); + + void RemoveImageFromSelection(string id, bool removeDuplicates = false); + void RemoveImagesFromSelection(List ids, bool removeDuplicates = false); + + void ClearImagesFromSelection(); + + /// + /// Outputs the selected image ids to the specified list. + /// + /// NOTE: List is not cleared internally. + /// + /// + void GetSelectedImages(List output); + + /// + /// The image that is currently shown on the screen. + /// + /// Returns NULL if there are no images selected OR the screen is in text mode. + /// + string CurrentlyShownImage { get; } + + void ShowPublicTextOnScreen(); + [Obsolete("LCD private text is deprecated")] + void ShowPrivateTextOnScreen(); + void ShowTextureOnScreen(); + void SetShowOnScreen(ShowTextOnScreenFlag set); + + /// + /// Indicates what should be shown on the screen, none being an image. + /// + ShowTextOnScreenFlag ShowOnScreen { get; } + + /// + /// Returns true if the ShowOnScreen flag is set to either PUBLIC or PRIVATE + /// + bool ShowText { get; } + } +} diff --git a/Ingame/IMyThrust.cs b/Ingame/IMyThrust.cs new file mode 100644 index 0000000..ddfff61 --- /dev/null +++ b/Ingame/IMyThrust.cs @@ -0,0 +1,25 @@ +using System; +using System.Collections.Generic; +using System.Linq; +using System.Text; + +namespace Sandbox.ModAPI.Ingame +{ + public interface IMyThrust: IMyFunctionalBlock + { + /// + /// Gets the override thrust amount, in Newtons (N) + /// + float ThrustOverride { get; } + + /// + /// Gets the maximum thrust amount, in Newtons (N) + /// + float MaxThrust { get; } + + /// + /// Gets the current thrust amount, in Newtons (N) + /// + float CurrentThrust { get; } + } +} diff --git a/Ingame/IMyUpgradableBlock.cs b/Ingame/IMyUpgradableBlock.cs new file mode 100644 index 0000000..b4bc2e3 --- /dev/null +++ b/Ingame/IMyUpgradableBlock.cs @@ -0,0 +1,25 @@ +using System; +using System.Collections.Generic; +using System.Linq; +using System.Text; +using VRage.Game.ModAPI.Ingame; + +namespace Sandbox.ModAPI.Ingame +{ + /// + /// interface to retrieve upgrade effects on block + /// + public interface IMyUpgradableBlock : IMyCubeBlock + { + /// + /// get list of upgrades (r/o); + /// string - upgrade type, float - effect value as float (1 = 100%) + /// + void GetUpgrades(out Dictionary upgrades); + + /// + /// number of upgrades applied + /// + uint UpgradeCount { get; } + } +} diff --git a/Ingame/IMyUserControllableGun.cs b/Ingame/IMyUserControllableGun.cs new file mode 100644 index 0000000..c839e93 --- /dev/null +++ b/Ingame/IMyUserControllableGun.cs @@ -0,0 +1,12 @@ +using System; +using System.Collections.Generic; +using System.Linq; +using System.Text; + +namespace Sandbox.ModAPI.Ingame +{ + public interface IMyUserControllableGun : IMyFunctionalBlock + { + bool IsShooting { get; } + } +} diff --git a/Ingame/IMyWarhead.cs b/Ingame/IMyWarhead.cs new file mode 100644 index 0000000..47e95c9 --- /dev/null +++ b/Ingame/IMyWarhead.cs @@ -0,0 +1,13 @@ +using System; +using System.Collections.Generic; +using System.Linq; +using System.Text; + +namespace Sandbox.ModAPI.Ingame +{ + public interface IMyWarhead: IMyTerminalBlock + { + bool IsCountingDown { get; } + float DetonationTime { get; } + } +} diff --git a/Ingame/IMyWheel.cs b/Ingame/IMyWheel.cs new file mode 100644 index 0000000..83eec65 --- /dev/null +++ b/Ingame/IMyWheel.cs @@ -0,0 +1,12 @@ +using System; +using System.Collections.Generic; +using System.Linq; +using System.Text; +using System.Threading.Tasks; + +namespace Sandbox.ModAPI.Ingame +{ + public interface IMyWheel : IMyMotorRotor + { + } +} diff --git a/Ingame/MyDetectedEntityInfo.cs b/Ingame/MyDetectedEntityInfo.cs new file mode 100644 index 0000000..ee0e713 --- /dev/null +++ b/Ingame/MyDetectedEntityInfo.cs @@ -0,0 +1,101 @@ +using System; +using VRage.Game; +using VRageMath; + +namespace Sandbox.ModAPI.Ingame +{ + public enum MyDetectedEntityType + { + None = 0, + Unknown, + SmallGrid, + LargeGrid, + CharacterHuman, + CharacterOther, + FloatingObject, + Asteroid, + Planet, + Meteor, + Missile, + } + + public struct MyDetectedEntityInfo + { + public MyDetectedEntityInfo(long entityId, string name, MyDetectedEntityType type, Vector3D? hitPosition, MatrixD orientation, Vector3 velocity, MyRelationsBetweenPlayerAndBlock relationship, BoundingBoxD boundingBox, long timeStamp) + { + if (timeStamp <= 0) + throw new ArgumentException("Invalid Timestamp", "timeStamp"); + EntityId = entityId; + Name = name; + Type = type; + HitPosition = hitPosition; + Orientation = orientation; + Velocity = velocity; + Relationship = relationship; + BoundingBox = boundingBox; + TimeStamp = timeStamp; + } + + /// + /// The entity's EntityId + /// + public readonly long EntityId; + + /// + /// The entity's display name if it is friendly, or a generic descriptor if it is not + /// + public readonly string Name; + + /// + /// Enum describing the type of entity + /// + public readonly MyDetectedEntityType Type; + + /// + /// Position where the raycast hit the entity. (can be null if the sensor didn't use a raycast) + /// + public readonly Vector3D? HitPosition; + + /// + /// The entity's absolute orientation at the time it was detected + /// + public readonly MatrixD Orientation; + + /// + /// The entity's absolute velocity at the time it was detected + /// + public readonly Vector3 Velocity; + + /// + /// Relationship between the entity and the owner of the sensor + /// + public readonly MyRelationsBetweenPlayerAndBlock Relationship; + + /// + /// The entity's world-aligned bounding box + /// + public readonly BoundingBoxD BoundingBox; + + /// + /// Time when the entity was detected. This field counts milliseconds, compensated for simspeed + /// + public readonly long TimeStamp; + + /// + /// The entity's position (center of the Bounding Box) + /// + public Vector3D Position + { + get { return BoundingBox.Center; } + } + + /// + /// Determines if this structure is empty; meaning it does not contain any meaningful data + /// + /// + public bool IsEmpty() + { + return TimeStamp == 0; + } + } +} diff --git a/Ingame/MyGridProgram.cs b/Ingame/MyGridProgram.cs new file mode 100644 index 0000000..d36f9f0 --- /dev/null +++ b/Ingame/MyGridProgram.cs @@ -0,0 +1,165 @@ +#if !XB1 +using System; +using System.Reflection; + +namespace Sandbox.ModAPI.Ingame +{ + /// + /// All programmable block scripts derive from this class, meaning that all properties in this + /// class are directly available for use in your scripts. + /// If you use Visual Studio or other external editors to write your scripts, you can derive + /// directly from this class and have a compatible script template. + /// + /// + /// + /// public void Main() + /// { + /// // Print out the time elapsed since the currently running programmable block was run + /// // the last time. + /// Echo(Me.CustomName + " was last run " + Runtime.TimeSinceLastRun.TotalSeconds + " seconds ago."); + /// } + /// + /// + public abstract class MyGridProgram : IMyGridProgram + { + /* + * Note from the author (Malware): + * + * This class is intended to serve not only as the base class of the "real" ingame-scripts, but also when + * used externally, for instance when writing scripts in Visual Studio. It is also designed to be unit-testable + * which means it should never rely on anything that requires the game to run. Everything should be configurable + * via the IMyGridProgram interface, which is not available in-game. + * + * Finally, as any member of this class becomes a root member of the script, try to avoid overcrowding it. If + * possible, compartmentalize (like for instance the Runtime Info). + */ + + // WARNING: Do not autoinitialize any of these fields, or the grid program initialization process + // will fail. + private string m_storage; + private readonly Action m_main; + private readonly Action m_save; + + protected MyGridProgram() + { + // First try to get the main method with a string argument. If this fails, try to get one without. + var type = this.GetType(); + var mainMethod = type.GetMethod("Main", BindingFlags.NonPublic | BindingFlags.Public | BindingFlags.Instance, null, new[] {typeof(string)}, null); + if (mainMethod != null) + { + this.m_main = mainMethod.CreateDelegate>(this); + } + else + { + mainMethod = type.GetMethod("Main", BindingFlags.NonPublic | BindingFlags.Public | BindingFlags.Instance, null, Type.EmptyTypes, null); + if (mainMethod != null) + { + var mainWithoutArgument = mainMethod.CreateDelegate(this); + this.m_main = arg => mainWithoutArgument(); + } + } + + var saveMethod = type.GetMethod("Save", BindingFlags.NonPublic | BindingFlags.Public | BindingFlags.Instance); + if (saveMethod != null) + { + this.m_save = saveMethod.CreateDelegate(this); + } + } + + /// + /// Provides access to the grid terminal system as viewed from this programmable block. + /// + public virtual IMyGridTerminalSystem GridTerminalSystem { get; protected set; } + + /// + /// Gets a reference to the currently running programmable block. + /// + public virtual IMyProgrammableBlock Me { get; protected set; } + + /// + /// Gets the amount of in-game time elapsed from the previous run. + /// + [Obsolete("Use Runtime.TimeSinceLastRun instead")] + public virtual TimeSpan ElapsedTime { get; protected set; } + + /// + /// Gets runtime information for the running grid program. + /// + public virtual IMyGridProgramRuntimeInfo Runtime { get; protected set; } + + /// + /// Allows you to store data between game sessions. + /// + public virtual string Storage + { + get { return this.m_storage ?? ""; } + protected set { this.m_storage = value ?? ""; } + } + + /// + /// Prints out text onto the currently running programmable block's detail info area. + /// + public Action Echo { get; protected set; } + + IMyGridTerminalSystem IMyGridProgram.GridTerminalSystem + { + get { return GridTerminalSystem; } + set { GridTerminalSystem = value; } + } + + IMyProgrammableBlock IMyGridProgram.Me + { + get { return Me; } + set { Me = value; } + } + + TimeSpan IMyGridProgram.ElapsedTime + { + get { return ElapsedTime; } + set { ElapsedTime = value; } + } + + string IMyGridProgram.Storage + { + get { return Storage; } + set { Storage = value; } + } + + Action IMyGridProgram.Echo + { + get { return Echo; } + set { Echo = value; } + } + + IMyGridProgramRuntimeInfo IMyGridProgram.Runtime + { + get { return Runtime; } + set { Runtime = value; } + } + + bool IMyGridProgram.HasMainMethod + { + get { return m_main != null; } + } + + void IMyGridProgram.Main(string argument) + { + if (m_main == null) + throw new InvalidOperationException("No Main method available"); + m_main(argument ?? string.Empty); + } + + bool IMyGridProgram.HasSaveMethod + { + get { return this.m_save != null; } + } + + void IMyGridProgram.Save() + { + if (m_save == null) + return; + m_save(); + } + } +} +#endif // !XB1 diff --git a/Ingame/PistonStatus.cs b/Ingame/PistonStatus.cs new file mode 100644 index 0000000..ca2f6c6 --- /dev/null +++ b/Ingame/PistonStatus.cs @@ -0,0 +1,33 @@ +namespace Sandbox.ModAPI.Ingame +{ + /// + /// Describes the current status of the piston. + /// + public enum PistonStatus + { + /// + /// The piston velocity is 0 (stationary). + /// + Stopped, + + /// + /// The piston is being extended (moving). + /// + Extending, + + /// + /// The piston is in its extended position (stationary). + /// + Extended, + + /// + /// The piston is being retracted (moving). + /// + Retracting, + + /// + /// The piston is in its retracted position (stationary). + /// + Retracted + } +} diff --git a/Ingame/TerminalActionParameter.cs b/Ingame/TerminalActionParameter.cs new file mode 100644 index 0000000..5d07933 --- /dev/null +++ b/Ingame/TerminalActionParameter.cs @@ -0,0 +1,130 @@ +using System; +using System.Globalization; +using System.Reflection; +using VRage.Game; +using VRage.ObjectBuilders; + +namespace Sandbox.ModAPI.Ingame +{ + public struct TerminalActionParameter + { + /// + /// Gets an empty parameter. + /// + public static readonly TerminalActionParameter Empty = new TerminalActionParameter(); + + static Type ToType(TypeCode code) + { + switch (code) + { + case TypeCode.Boolean: + return typeof(bool); + + case TypeCode.Byte: + return typeof(byte); + + case TypeCode.Char: + return typeof(char); + + case TypeCode.DateTime: + return typeof(DateTime); + + case TypeCode.Decimal: + return typeof(decimal); + + case TypeCode.Double: + return typeof(double); + + case TypeCode.Int16: + return typeof(short); + + case TypeCode.Int32: + return typeof(int); + + case TypeCode.Int64: + return typeof(long); + + case TypeCode.SByte: + return typeof(sbyte); + + case TypeCode.Single: + return typeof(float); + + case TypeCode.String: + return typeof(string); + + case TypeCode.UInt16: + return typeof(ushort); + + case TypeCode.UInt32: + return typeof(uint); + + case TypeCode.UInt64: + return typeof(ulong); + } + + return null; + } + + /// + /// Creates a from a serialized value in a string and a type code. + /// + /// + /// + /// + public static TerminalActionParameter Deserialize(string serializedValue, TypeCode typeCode) + { + AssertTypeCodeValidity(typeCode); + var targetType = ToType(typeCode); + if (targetType == null) + return Empty; + var value = Convert.ChangeType(serializedValue, typeCode, CultureInfo.InvariantCulture); + return new TerminalActionParameter(typeCode, value); + } + + /// + /// Creates a from the given value. + /// + /// + /// + /// + public static TerminalActionParameter Get(object value) + { + if (value == null) + return Empty; + var typeCode = Type.GetTypeCode(value.GetType()); + AssertTypeCodeValidity(typeCode); + return new TerminalActionParameter(typeCode, value); + } + + private static void AssertTypeCodeValidity(TypeCode typeCode) + { + switch (typeCode) + { + case TypeCode.Empty: + case TypeCode.Object: + case TypeCode.DBNull: + throw new ArgumentException("Only primitive types are allowed for action parameters", "value"); + } + } + + public readonly TypeCode TypeCode; + public readonly object Value; + + private TerminalActionParameter(TypeCode typeCode, object value) + { + TypeCode = typeCode; + Value = value; + } + + public bool IsEmpty { get { return this.TypeCode == TypeCode.Empty; } } + + public MyObjectBuilder_ToolbarItemActionParameter GetObjectBuilder() + { + var itemObjectBuilder = MyObjectBuilderSerializer.CreateNewObject(); + itemObjectBuilder.TypeCode = TypeCode; + itemObjectBuilder.Value = (this.Value == null) ? null : Convert.ToString(this.Value, CultureInfo.InvariantCulture); + return itemObjectBuilder; + } + } +} \ No newline at end of file diff --git a/Mayak.test.cs b/Mayak.test.cs new file mode 100644 index 0000000..b89be6e --- /dev/null +++ b/Mayak.test.cs @@ -0,0 +1,45 @@ +namespace Sandbox.ModAPI.Ingame +{ + public class Main + { + void Main() + { + IMyTerminalBlock mayak = GridTerminalSystem.GetBlockWithName("Маяк") as IMyTerminalBlock; + + if (mayak.) + if (connector.Status == MyShipConnectorStatus.Connectable) + { + connector.GetActionWithName("SwitchLock").Apply(connector); + + if (connector.Status != MyShipConnectorStatus.Connected) + { + return; + } + + foreach (var engine in engines) + { + engine.GetActionWithName("OnOff_Off").Apply(engine); + } + + foreach (var battery in batteries) + { + battery.GetActionWithName("Recharge").Apply(battery); + } + } + else if (connector.Status == MyShipConnectorStatus.Connected) + { + foreach (var battery in batteries) + { + battery.GetActionWithName("Auto").Apply(battery); + } + + foreach (var engine in engines) + { + engine.GetActionWithName("OnOff_On").Apply(engine); + } + + connector.GetActionWithName("SwitchLock").Apply(connector); + } + } + } +} diff --git a/Svarshiki.cs b/Svarshiki.cs new file mode 100644 index 0000000..5882248 --- /dev/null +++ b/Svarshiki.cs @@ -0,0 +1,9 @@ +namespace Sandbox.ModAPI.Ingame +{ + public class Main + { +public void Main(string argument, UpdateType updateSource) +{ +} +} +} diff --git a/vendor b/vendor new file mode 160000 index 0000000..a109106 --- /dev/null +++ b/vendor @@ -0,0 +1 @@ +Subproject commit a109106fc0ded66bdd5da70e099646203c56550f