Advertisement
Not a member of Pastebin yet?
Sign Up,
it unlocks many cool features!
- /*
- * Same idea and thrust logic code from Whip's Speed Matcher Script https://steamcommunity.com/sharedfiles/filedetails/?id=1109204252
- * Adapted for straightforward use with WeaponCore rather than camera raycasts.
- *
- * This program does thrust overrides. It does not turn thrusters on/off.
- * Player WASD/whatever control is *not* blocked, Whip's logic accounts for it, so you can adjust your position freely with your controls while otherwise dampening to match your target.
- *
- * COMMAND ARGUMENTS ARE AS FOLLOWS:
- matchclosest
- Will speed dampen relative to the closest entity detected by weaponcore weapon(s). This will generally need to be an enemy, or at least owned by somebody else.
- matchfocus
- Will speed dampen relative to the entity being explicitly targeted by your ship, as in has a big reticle and you're getting stats on it on top of the screen.
- STATE LIGHTING
- Light blocks in the block group named "indicators" will turn blue when there is an active speed match, and green when normal behavior is in effect.
- CUSTOMDATA OPTION:
- automatchfocus
- If automatchfocus is in the CustomData of the program block, then any time you focus a ship in WeaponCore, it will automatically trigger the same logic as matchfocus.
- This may be undesirable if you use thruster overrides as part of your general or combat routine. OTOH, if you don't and are lazy, there ya go, it 'just works' without using a toolbar slot.
- */
- public Program()
- {
- chkInitializations();
- toggleMatchSpeed();
- toggleMatchSpeed();
- }
- public WcPbApi modAPIWeaponCore = null;
- public bool modAPIWeaponCoreReady = false;
- public List<IMyShipController> controllers = new List<IMyShipController>();
- public List<IMyThrust> thrusters = new List<IMyThrust>();
- public List<IMyLightingBlock> indicators = new List<IMyLightingBlock>();
- public void setlight(Color c)
- {
- foreach(IMyLightingBlock b in indicators)
- {
- b.Color = c;
- }
- }
- public bool autoMatchFocus = false;
- public void loadBlocks()
- {
- if (!modAPIWeaponCoreReady) return;
- controllers.Clear();
- GridTerminalSystem.GetBlocksOfType<IMyShipController>(controllers, b => b.CubeGrid == Me.CubeGrid);
- thrusters.Clear();
- GridTerminalSystem.GetBlocksOfType<IMyThrust>(thrusters, b => b.CubeGrid == Me.CubeGrid);
- IMyBlockGroup ind = GridTerminalSystem.GetBlockGroupWithName("indicators");
- if(ind != null)
- {
- ind.GetBlocksOfType<IMyLightingBlock>(indicators);
- }
- if (Me.CustomData.Contains("automatchfocus")) autoMatchFocus = true;
- else autoMatchFocus = false;
- }
- DateTime apiCheckCode = DateTime.MinValue;
- DateTime blockCheck = DateTime.MinValue;
- public bool matchingSpeed = false;
- class TargetData
- {
- public long EntityId;
- public string Name;
- public Vector3D Position;
- public Vector3D Velocity;
- public TargetData() { }
- public TargetData(MyDetectedEntityInfo i)
- {
- setFromDetected(i);
- }
- public void setFromDetected(MyDetectedEntityInfo i)
- {
- EntityId = i.EntityId;
- Name = i.Name;
- Position = i.Position;
- Velocity = i.Velocity;
- }
- }
- TargetData matchTarget = null;
- public IMyShipController getShipController()
- {
- foreach (IMyShipController c in controllers)
- {
- if (c.IsMainCockpit && c.CanControlShip) return c;
- }
- foreach (IMyShipController c in controllers)
- {
- if (c.IsMainCockpit) return c;
- }
- foreach (IMyShipController c in controllers)
- {
- if (c.CanControlShip) return c;
- }
- return controllers.Count > 0 ? controllers[0] : null;
- }
- void toggleMatchSpeed()
- {
- matchingSpeed = !matchingSpeed;
- if (matchingSpeed)
- {
- Runtime.UpdateFrequency = UpdateFrequency.Update1;
- setlight(Color.Blue);
- }
- else
- {
- Runtime.UpdateFrequency = UpdateFrequency.Update10;
- matchTarget = null;
- setlight(Color.Green);
- foreach (var thisThrust in thrusters)
- {
- thisThrust.ThrustOverridePercentage = 0;
- }
- }
- }
- public static bool hasTimeElapsedSet(ref DateTime last, int seconds)
- {
- var now = DateTime.Now;
- if ((now - last).TotalSeconds > seconds)
- {
- last = now;
- return true;
- }
- return false;
- }
- public void chkInitializations()
- {
- if (hasTimeElapsedSet(ref blockCheck, 25))
- {
- loadBlocks();
- }
- if (hasTimeElapsedSet(ref apiCheckCode, 5))
- {
- if (modAPIWeaponCore == null) try { modAPIWeaponCore = new WcPbApi(); } catch (Exception) { }
- if (modAPIWeaponCore != null && !modAPIWeaponCoreReady)
- {
- try
- {
- if (modAPIWeaponCore.Activate(Me))
- {
- modAPIWeaponCoreReady = true;
- blockCheck = new DateTime();
- loadBlocks();
- }
- }
- catch (Exception) { }
- }
- }
- if (!modAPIWeaponCoreReady) return;
- }
- public void Main(string argument, UpdateType updateSource)
- {
- chkInitializations();
- if (argument.StartsWith("match"))
- {
- toggleMatchSpeed();
- if (matchingSpeed)
- {
- if (argument == "matchclosest")
- {
- Dictionary<MyDetectedEntityInfo, float> threatList = new Dictionary<MyDetectedEntityInfo, float>();
- modAPIWeaponCore.GetSortedThreats(Me, threatList);
- List<KeyValuePair<MyDetectedEntityInfo, float>> tmpa = new List<KeyValuePair<MyDetectedEntityInfo, float>>();
- foreach (KeyValuePair<MyDetectedEntityInfo, float> kvp in threatList) tmpa.Add(kvp);
- if (tmpa.Count > 0)
- {
- matchTarget = new TargetData(tmpa[0].Key);
- }
- else toggleMatchSpeed();
- }
- if (argument == "matchfocus")
- {
- MyDetectedEntityInfo? focus = modAPIWeaponCore.GetAiFocus(Me.CubeGrid.EntityId);
- if (focus.HasValue && !focus.Value.IsEmpty())
- {
- matchTarget = new TargetData(focus.Value);
- }
- else toggleMatchSpeed();
- }
- }
- else matchTarget = null;
- }
- if (updateSource == UpdateType.Update1 || updateSource == UpdateType.Update10)
- {
- if (!matchingSpeed && autoMatchFocus)
- {
- MyDetectedEntityInfo? focus = modAPIWeaponCore.GetAiFocus(Me.CubeGrid.EntityId);
- if (focus.HasValue && !focus.Value.IsEmpty())
- {
- toggleMatchSpeed();
- matchTarget = new TargetData(focus.Value);
- }
- }
- if (matchingSpeed)
- {
- Dictionary<MyDetectedEntityInfo, float> threatList = new Dictionary<MyDetectedEntityInfo, float>();
- modAPIWeaponCore.GetSortedThreats(Me, threatList);
- List<KeyValuePair<MyDetectedEntityInfo, float>> tmpa = new List<KeyValuePair<MyDetectedEntityInfo, float>>();
- bool canTrack = false;
- MyDetectedEntityInfo? focus = modAPIWeaponCore.GetAiFocus(Me.CubeGrid.EntityId);
- if (focus.HasValue && focus.Value.EntityId == matchTarget.EntityId)
- {
- matchTarget.setFromDetected(focus.Value);
- //matchTarget = focus.Value;
- canTrack = true;
- }
- if (!canTrack)
- {
- foreach (KeyValuePair<MyDetectedEntityInfo, float> kvp in threatList)
- {
- if (kvp.Key.EntityId == matchTarget.EntityId)
- {
- matchTarget.setFromDetected(kvp.Key);
- canTrack = true;
- break;
- }
- }
- }
- if (!canTrack || matchTarget == null)
- {
- toggleMatchSpeed();
- }else
- {
- targetVelocityVec = matchTarget.Velocity;
- }
- }
- }
- if (matchingSpeed)
- {
- Echo("m: " + matchTarget.Name);
- //Vector3D targetVelocityVec
- var myVelocityVec = getShipController().GetShipVelocities().LinearVelocity;
- Echo("mv: " + myVelocityVec.X.ToString("0.0") + "," + myVelocityVec.Y.ToString("0.0")+","+ myVelocityVec.Z.ToString("0.0"));
- Echo("tv: " + targetVelocityVec.X.ToString("0.0") + "," + targetVelocityVec.Y.ToString("0.0") + "," + targetVelocityVec.Z.ToString("0.0"));
- SpeedMatcher();
- }
- else Echo("not match");
- Echo("\nautoMatchFocus=" + autoMatchFocus);
- }
- //taken mostly wholesale from https://github.com/Whiplash141/SpaceEngineersScripts/blob/master/Released/speed_matcher.cs
- Vector3D targetVelocityVec = new Vector3D(0, 0, 0);
- void SpeedMatcher()
- {
- /*if (!shouldMatch)
- {
- foreach (var thisThrust in allThrust)
- {
- SetThrusterOverride(thisThrust, 0f);
- }
- return;
- }*/
- var thisController = getShipController();// GetControlledShipController(allShipControllers);
- var myVelocityVec = thisController.GetShipVelocities().LinearVelocity;
- var inputVec = thisController.MoveIndicator;
- var desiredDirectionVec = Vector3D.TransformNormal(inputVec, thisController.WorldMatrix); //world relative input vector
- var relativeVelocity = myVelocityVec - targetVelocityVec;
- //if (!shouldScan) //if the scan is finished
- //thisController.DampenersOverride = false;
- ApplyThrust(thrusters, relativeVelocity, desiredDirectionVec, thisController);
- }
- void ApplyThrust(List<IMyThrust> thrusters, Vector3D travelVec, Vector3D desiredDirectionVec, IMyShipController thisController)
- {
- var mass = thisController.CalculateShipMass().PhysicalMass;
- var gravity = thisController.GetNaturalGravity();
- var desiredThrust = mass * (2 * travelVec + gravity);
- var thrustToApply = desiredThrust;
- if (!Vector3D.IsZero(desiredDirectionVec))
- {
- thrustToApply = VectorRejection(desiredThrust, desiredDirectionVec);
- }
- //convert desired thrust vector to local
- //thrustToApply = Vector3D.TransformNormal(thrustToApply, MatrixD.Transpose(thisController.WorldMatrix));
- foreach (IMyThrust thisThrust in thrusters)
- {
- if (Vector3D.Dot(thisThrust.WorldMatrix.Backward, desiredDirectionVec) > .7071) //thrusting in desired direction
- {
- thisThrust.ThrustOverridePercentage = 1f;
- }
- else if (Vector3D.Dot(thisThrust.WorldMatrix.Forward, thrustToApply) > 0 && thisController.DampenersOverride)
- {
- var neededThrust = Vector3D.Dot(thrustToApply, thisThrust.WorldMatrix.Forward);
- var outputProportion = MathHelper.Clamp(neededThrust / thisThrust.MaxEffectiveThrust, 0, 1);
- thisThrust.ThrustOverridePercentage = (float)outputProportion;
- thrustToApply -= thisThrust.WorldMatrix.Forward * outputProportion * thisThrust.MaxEffectiveThrust;
- }
- else
- {
- thisThrust.ThrustOverridePercentage = 0.000001f;
- }
- }
- }
- public Vector3D VectorRejection(Vector3D a, Vector3D b) //reject a on b
- {
- if (Vector3D.IsZero(b))
- return Vector3D.Zero;
- return a - a.Dot(b) / b.LengthSquared() * b;
- }
- }
- public class Utility
- {
- /// <summary>
- /// if seconds since last, replace last with now and return true
- /// </summary>
- }
- public class MD5
- {
- /*
- * Round shift values
- */
- static int[] s = new int[64] {
- 7, 12, 17, 22, 7, 12, 17, 22, 7, 12, 17, 22, 7, 12, 17, 22,
- 5, 9, 14, 20, 5, 9, 14, 20, 5, 9, 14, 20, 5, 9, 14, 20,
- 4, 11, 16, 23, 4, 11, 16, 23, 4, 11, 16, 23, 4, 11, 16, 23,
- 6, 10, 15, 21, 6, 10, 15, 21, 6, 10, 15, 21, 6, 10, 15, 21
- };
- /*
- * Constant K Values
- */
- static uint[] K = new uint[64] {
- 0xd76aa478, 0xe8c7b756, 0x242070db, 0xc1bdceee,
- 0xf57c0faf, 0x4787c62a, 0xa8304613, 0xfd469501,
- 0x698098d8, 0x8b44f7af, 0xffff5bb1, 0x895cd7be,
- 0x6b901122, 0xfd987193, 0xa679438e, 0x49b40821,
- 0xf61e2562, 0xc040b340, 0x265e5a51, 0xe9b6c7aa,
- 0xd62f105d, 0x02441453, 0xd8a1e681, 0xe7d3fbc8,
- 0x21e1cde6, 0xc33707d6, 0xf4d50d87, 0x455a14ed,
- 0xa9e3e905, 0xfcefa3f8, 0x676f02d9, 0x8d2a4c8a,
- 0xfffa3942, 0x8771f681, 0x6d9d6122, 0xfde5380c,
- 0xa4beea44, 0x4bdecfa9, 0xf6bb4b60, 0xbebfbc70,
- 0x289b7ec6, 0xeaa127fa, 0xd4ef3085, 0x04881d05,
- 0xd9d4d039, 0xe6db99e5, 0x1fa27cf8, 0xc4ac5665,
- 0xf4292244, 0x432aff97, 0xab9423a7, 0xfc93a039,
- 0x655b59c3, 0x8f0ccc92, 0xffeff47d, 0x85845dd1,
- 0x6fa87e4f, 0xfe2ce6e0, 0xa3014314, 0x4e0811a1,
- 0xf7537e82, 0xbd3af235, 0x2ad7d2bb, 0xeb86d391
- };
- public static uint leftRotate(uint x, int c)
- {
- return (x << c) | (x >> (32 - c));
- }
- // assumes whole bytes as input
- public static string Calculate(byte[] input)
- {
- uint a0 = 0x67452301; // A
- uint b0 = 0xefcdab89; // B
- uint c0 = 0x98badcfe; // C
- uint d0 = 0x10325476; // D
- var addLength = (56 - ((input.Length + 1) % 64)) % 64; // calculate the new length with padding
- var processedInput = new byte[input.Length + 1 + addLength + 8];
- Array.Copy(input, processedInput, input.Length);
- processedInput[input.Length] = 0x80; // add 1
- byte[] length = BitConverter.GetBytes(input.Length * 8); // bit converter returns little-endian
- Array.Copy(length, 0, processedInput, processedInput.Length - 8, 4); // add length in bits
- for (int i = 0; i < processedInput.Length / 64; ++i)
- {
- // copy the input to M
- uint[] M = new uint[16];
- for (int j = 0; j < 16; ++j)
- M[j] = BitConverter.ToUInt32(processedInput, (i * 64) + (j * 4));
- // initialize round variables
- uint A = a0, B = b0, C = c0, D = d0, F = 0, g = 0;
- // primary loop
- for (uint k = 0; k < 64; ++k)
- {
- if (k <= 15)
- {
- F = (B & C) | (~B & D);
- g = k;
- }
- else if (k >= 16 && k <= 31)
- {
- F = (D & B) | (~D & C);
- g = ((5 * k) + 1) % 16;
- }
- else if (k >= 32 && k <= 47)
- {
- F = B ^ C ^ D;
- g = ((3 * k) + 5) % 16;
- }
- else if (k >= 48)
- {
- F = C ^ (B | ~D);
- g = (7 * k) % 16;
- }
- var dtemp = D;
- D = C;
- C = B;
- B = B + leftRotate((A + F + K[k] + M[g]), s[k]);
- A = dtemp;
- }
- a0 += A;
- b0 += B;
- c0 += C;
- d0 += D;
- }
- return GetByteString(a0) + GetByteString(b0) + GetByteString(c0) + GetByteString(d0);
- }
- private static string GetByteString(uint x)
- {
- return String.Join("", BitConverter.GetBytes(x).Select(y => y.ToString("x2")));
- }
- }
- class UtilitySpatial
- {
- }
- public class WcPbApi
- {
- private Action<IMyTerminalBlock, IDictionary<MyDetectedEntityInfo, float>> _getSortedThreats;
- private Func<long, bool> _hasGridAi;
- //private Func<Sandbox.ModAPI.Ingame.IMyTerminalBlock, long, int, Vector3D?> _getPredictedTargetPos;
- //private Func<Sandbox.ModAPI.Ingame.IMyTerminalBlock, int, Sandbox.ModAPI.Ingame.MyDetectedEntityInfo> _getWeaponTarget;
- //private Action<ICollection<MyDefinitionId>> _getCoreTurrets;
- private Func<long, int, Sandbox.ModAPI.Ingame.MyDetectedEntityInfo> _getAiFocus;
- private Func<Sandbox.ModAPI.Ingame.IMyTerminalBlock, long, int, bool> _setAiFocus;
- private Action<Sandbox.ModAPI.Ingame.IMyTerminalBlock, bool, bool, int> _toggleWeaponFire;
- private Func<Sandbox.ModAPI.Ingame.IMyTerminalBlock, bool> _hasCoreWeapon;
- //private Action<Sandbox.ModAPI.Ingame.IMyTerminalBlock, ICollection<Sandbox.ModAPI.Ingame.MyDetectedEntityInfo>> _getObstructions;
- private Func<Sandbox.ModAPI.Ingame.IMyTerminalBlock, ICollection<string>, int, bool> _getTurretTargetTypes;
- private Action<Sandbox.ModAPI.Ingame.IMyTerminalBlock, ICollection<string>, int> _setTurretTargetTypes;
- private Func<Sandbox.ModAPI.Ingame.IMyTerminalBlock, long, int, Vector3D?> _getPredictedTargetPos;
- private Func<Sandbox.ModAPI.Ingame.IMyTerminalBlock, int, Matrix> _getWeaponAzimuthMatrix;
- private Func<Sandbox.ModAPI.Ingame.IMyTerminalBlock, int, Matrix> _getWeaponElevationMatrix;
- private Func<Sandbox.ModAPI.Ingame.IMyTerminalBlock, long, int, MyTuple<bool, Vector3D?>> _isTargetAlignedExtended;
- private Func<Sandbox.ModAPI.Ingame.IMyTerminalBlock, int, string> _getActiveAmmo;
- private Action<Sandbox.ModAPI.Ingame.IMyTerminalBlock, int, string> _setActiveAmmo;
- private Func<long, float> _getConstructEffectiveDps;
- private Func<Sandbox.ModAPI.Ingame.IMyTerminalBlock, int, Sandbox.ModAPI.Ingame.MyDetectedEntityInfo> _getWeaponTarget;
- private Action<Sandbox.ModAPI.Ingame.IMyTerminalBlock, long, int> _setWeaponTarget;
- private Action<Sandbox.ModAPI.Ingame.IMyTerminalBlock, int, Action<long, int, ulong, long, Vector3D, bool>> _monitorProjectile;
- private Action<Sandbox.ModAPI.Ingame.IMyTerminalBlock, int, Action<long, int, ulong, long, Vector3D, bool>> _unMonitorProjectile;
- private Func<ulong, MyTuple<Vector3D, Vector3D, float, float, long, string>> _getProjectileState;
- public bool Activate(IMyTerminalBlock pbBlock)
- {
- var dict = pbBlock.GetProperty("WcPbAPI")?.As<IReadOnlyDictionary<string, Delegate>>().GetValue(pbBlock);
- if (dict == null) throw new Exception("WcPbAPI failed to activate");
- return ApiAssign(dict);
- }
- public bool ApiAssign(IReadOnlyDictionary<string, Delegate> delegates)
- {
- if (delegates == null)
- return false;
- AssignMethod(delegates, "GetSortedThreats", ref _getSortedThreats);
- AssignMethod(delegates, "HasGridAi", ref _hasGridAi);
- AssignMethod(delegates, "GetAiFocus", ref _getAiFocus);
- AssignMethod(delegates, "SetAiFocus", ref _setAiFocus);
- AssignMethod(delegates, "ToggleWeaponFire", ref _toggleWeaponFire);
- AssignMethod(delegates, "HasCoreWeapon", ref _hasCoreWeapon);
- AssignMethod(delegates, "GetPredictedTargetPosition", ref _getPredictedTargetPos);
- AssignMethod(delegates, "GetTurretTargetTypes", ref _getTurretTargetTypes);
- AssignMethod(delegates, "SetTurretTargetTypes", ref _setTurretTargetTypes);
- AssignMethod(delegates, "GetWeaponAzimuthMatrix", ref _getWeaponAzimuthMatrix);
- AssignMethod(delegates, "GetWeaponElevationMatrix", ref _getWeaponElevationMatrix);
- AssignMethod(delegates, "IsTargetAlignedExtended", ref _isTargetAlignedExtended);
- AssignMethod(delegates, "GetActiveAmmo", ref _getActiveAmmo);
- AssignMethod(delegates, "SetActiveAmmo", ref _setActiveAmmo);
- AssignMethod(delegates, "GetConstructEffectiveDps", ref _getConstructEffectiveDps);
- AssignMethod(delegates, "GetWeaponTarget", ref _getWeaponTarget);
- AssignMethod(delegates, "SetWeaponTarget", ref _setWeaponTarget);
- AssignMethod(delegates, "MonitorProjectile", ref _monitorProjectile);
- AssignMethod(delegates, "UnMonitorProjectile", ref _unMonitorProjectile);
- AssignMethod(delegates, "GetProjectileState", ref _getProjectileState);
- return true;
- }
- private void AssignMethod<T>(IReadOnlyDictionary<string, Delegate> delegates, string name, ref T field) where T : class
- {
- if (delegates == null)
- {
- field = null;
- return;
- }
- Delegate del;
- if (!delegates.TryGetValue(name, out del))
- throw new Exception($"{GetType().Name} :: Couldn't find {name} delegate of type {typeof(T)}");
- field = del as T;
- if (field == null)
- throw new Exception(
- $"{GetType().Name} :: Delegate {name} is not type {typeof(T)}, instead it's: {del.GetType()}");
- }
- public void GetSortedThreats(IMyTerminalBlock pbBlock, IDictionary<MyDetectedEntityInfo, float> collection) =>
- _getSortedThreats?.Invoke(pbBlock, collection);
- public bool HasGridAi(long entity) => _hasGridAi?.Invoke(entity) ?? false;
- //public Vector3D? GetPredictedTargetPosition(Sandbox.ModAPI.Ingame.IMyTerminalBlock weapon, long targetEnt, int weaponId) =>_getPredictedTargetPos?.Invoke(weapon, targetEnt, weaponId) ?? null;
- // public MyDetectedEntityInfo? GetWeaponTarget(Sandbox.ModAPI.Ingame.IMyTerminalBlock weapon, int weaponId = 0) => _getWeaponTarget?.Invoke(weapon, weaponId);
- //public void GetAllCoreTurrets(ICollection<MyDefinitionId> collection) => _getCoreTurrets?.Invoke(collection);
- public MyDetectedEntityInfo? GetAiFocus(long shooter, int priority = 0) => _getAiFocus?.Invoke(shooter, priority);
- public bool SetAiFocus(Sandbox.ModAPI.Ingame.IMyTerminalBlock pBlock, long target, int priority = 0) =>
- _setAiFocus?.Invoke(pBlock, target, priority) ?? false;
- public void ToggleWeaponFire(Sandbox.ModAPI.Ingame.IMyTerminalBlock weapon, bool on, bool allWeapons, int weaponId = 0) =>
- _toggleWeaponFire?.Invoke(weapon, on, allWeapons, weaponId);
- public bool HasCoreWeapon(Sandbox.ModAPI.Ingame.IMyTerminalBlock weapon) => _hasCoreWeapon?.Invoke(weapon) ?? false;
- //public void GetObstructions(Sandbox.ModAPI.Ingame.IMyTerminalBlock pBlock, ICollection<Sandbox.ModAPI.Ingame.MyDetectedEntityInfo> collection) =>
- // _getObstructions?.Invoke(pBlock, collection);
- public Vector3D? GetPredictedTargetPosition(Sandbox.ModAPI.Ingame.IMyTerminalBlock weapon, long targetEnt, int weaponId) =>
- _getPredictedTargetPos?.Invoke(weapon, targetEnt, weaponId) ?? null;
- public Matrix GetWeaponAzimuthMatrix(Sandbox.ModAPI.Ingame.IMyTerminalBlock weapon, int weaponId) =>
- _getWeaponAzimuthMatrix?.Invoke(weapon, weaponId) ?? Matrix.Zero;
- public Matrix GetWeaponElevationMatrix(Sandbox.ModAPI.Ingame.IMyTerminalBlock weapon, int weaponId) =>
- _getWeaponElevationMatrix?.Invoke(weapon, weaponId) ?? Matrix.Zero;
- public MyTuple<bool, Vector3D?> IsTargetAlignedExtended(Sandbox.ModAPI.Ingame.IMyTerminalBlock weapon, long targetEnt, int weaponId) =>
- _isTargetAlignedExtended?.Invoke(weapon, targetEnt, weaponId) ?? new MyTuple<bool, Vector3D?>();
- public string GetActiveAmmo(Sandbox.ModAPI.Ingame.IMyTerminalBlock weapon, int weaponId) =>
- _getActiveAmmo?.Invoke(weapon, weaponId) ?? null;
- public void SetActiveAmmo(Sandbox.ModAPI.Ingame.IMyTerminalBlock weapon, int weaponId, string ammoType) =>
- _setActiveAmmo?.Invoke(weapon, weaponId, ammoType);
- public float GetConstructEffectiveDps(long entity) => _getConstructEffectiveDps?.Invoke(entity) ?? 0f;
- public MyDetectedEntityInfo? GetWeaponTarget(Sandbox.ModAPI.Ingame.IMyTerminalBlock weapon, int weaponId = 0) =>
- _getWeaponTarget?.Invoke(weapon, weaponId);
- public void SetWeaponTarget(Sandbox.ModAPI.Ingame.IMyTerminalBlock weapon, long target, int weaponId = 0) =>
- _setWeaponTarget?.Invoke(weapon, target, weaponId);
- public void MonitorProjectileCallback(Sandbox.ModAPI.Ingame.IMyTerminalBlock weapon, int weaponId, Action<long, int, ulong, long, Vector3D, bool> action) =>
- _monitorProjectile?.Invoke(weapon, weaponId, action);
- public void UnMonitorProjectileCallback(Sandbox.ModAPI.Ingame.IMyTerminalBlock weapon, int weaponId, Action<long, int, ulong, long, Vector3D, bool> action) =>
- _unMonitorProjectile?.Invoke(weapon, weaponId, action);
- //// POs, Dir, baseDamageLeft, HealthLeft, TargetEntityId, AmmoName
- public MyTuple<Vector3D, Vector3D, float, float, long, string> GetProjectileState(ulong projectileId) =>
- _getProjectileState?.Invoke(projectileId) ?? new MyTuple<Vector3D, Vector3D, float, float, long, string>();
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement