public static void GetLinearVelocity(this IMyControllableEntity controlledEntity, ref Vector3 velocityVector, bool useRemoteControlVelocity = true) { if (controlledEntity.Entity.Physics != null) { velocityVector = (controlledEntity.Entity.Physics != null) ? controlledEntity.Entity.Physics.LinearVelocity : Vector3.Zero; } else { MyCockpit cockpit = controlledEntity as MyCockpit; if (cockpit != null) { velocityVector = (cockpit.CubeGrid.Physics != null) ? cockpit.CubeGrid.Physics.LinearVelocity : Vector3.Zero; } else { MyRemoteControl control = controlledEntity as MyRemoteControl; if ((control != null) & useRemoteControlVelocity) { velocityVector = (control.CubeGrid.Physics != null) ? control.CubeGrid.Physics.LinearVelocity : Vector3.Zero; } else { MyLargeTurretBase base2 = controlledEntity as MyLargeTurretBase; if (base2 != null) { velocityVector = (base2.CubeGrid.Physics != null) ? base2.CubeGrid.Physics.LinearVelocity : Vector3.Zero; } } } } }
// REMOVE-ME: This seems to be dead code public void Init(Matrix localMatrix, MyLargeTurretBase parentObject) { m_shotsLeftInBurst = ShotsInBurst; // This prevents missile launches from shooting missiles into their own base BarrelElevationMin = -0.6f; }
public override void Init(MyEntity entity, MyLargeTurretBase turretBase) { base.Init(entity, turretBase); // backward compatibility with old models/mods if (!m_gunBase.HasDummies) { Vector3 pos = 2 * entity.PositionComp.WorldMatrix.Forward; m_gunBase.AddMuzzleMatrix(MyAmmoType.HighSpeed, Matrix.CreateTranslation(pos)); } }
public static void IdleMover(MyLargeTurretBase __instance) { if (!(__instance is IMyLargeTurretBase turret)) { return; } if (turret.EnableIdleRotation) { turret.EnableIdleRotation = false; turret.SyncEnableIdleRotation(); } return; }
public override void Init(MyEntity entity, MyLargeTurretBase turretBase) { base.Init(entity, turretBase); // backward compatibility with old models/mods if (!m_gunBase.HasDummies) { Matrix muzzle = Matrix.Identity; muzzle.Translation += entity.PositionComp.WorldMatrix.Forward * 3; m_gunBase.AddMuzzleMatrix(MyAmmoType.Missile, muzzle); } m_shotsLeftInBurst = ShotsInBurst; if (m_soundEmitter != null) m_soundEmitter.Entity = (MyEntity)turretBase; }
public virtual void Init(MyEntity entity, MyLargeTurretBase turretBase) { m_entity = entity; m_turretBase = turretBase; m_gunBase = turretBase.GunBase as MyGunBase; // Check for the dummy cubes for the muzzle flash positions: if (m_entity.Model != null) { if (m_entity.Model.Dummies.ContainsKey("camera")) { CameraDummy = m_entity.Model.Dummies["camera"]; } m_gunBase.LoadDummies(m_entity.Model.Dummies); } m_entity.OnClose += m_entity_OnClose; }
public virtual void Init(MyEntity entity, MyLargeTurretBase turretBase) { m_entity = entity; m_turretBase = turretBase; m_gunBase = turretBase.GunBase as MyGunBase; // Check for the dummy cubes for the muzzle flash positions: if (m_entity.Model != null) { if (m_entity.Model.Dummies.ContainsKey("camera")) { CameraDummy = m_entity.Model.Dummies["camera"]; } m_gunBase.LoadDummies(m_entity.Model.Dummies); } m_entity.OnClose += m_entity_OnClose; }
/// <summary> /// Fill CanTarget from turret /// </summary> protected override void Update100_Options_TargetingThread(TargetingOptions Options) { MyLargeTurretBase turret = (MyLargeTurretBase)CubeBlock; SetFlag(turret.TargetMissiles, TargetType.Missile); SetFlag(turret.TargetMeteors, TargetType.Meteor); SetFlag(turret.TargetCharacters, TargetType.Character); SetFlag(turret.TargetLargeGrids, TargetType.LargeGrid); SetFlag(turret.TargetSmallGrids, TargetType.SmallGrid); SetFlag(turret.TargetStations, TargetType.Station); if (turret.TargetNeutrals) { Options.Flags &= ~TargetingFlags.IgnoreOwnerless; } else { Options.Flags |= TargetingFlags.IgnoreOwnerless; } Options.TargetingRange = myTurret.Range; //Log.DebugLog("CanTarget = " + Options.CanTarget, "TargetOptionsFromTurret()"); }
public static bool Throttler(MyLargeTurretBase __instance, VRage.ModAPI.MyEntityUpdateEnum update, int tick) { // Not enabled or wrongly configured if (!TweakerPlugin.Instance.Config.LargeTurretBaseTweakEnabled || TweakerPlugin.Instance.Config.LargeTurretBaseTweakFactor == 0f) { return(true); } // Block is not working if (!__instance.IsWorking) { return(true); } // Is doing some shooting if (__instance.Target != null || __instance.IsPlayerControlled) { _largeTurretBaseKeepalive.AddOrUpdate(__instance.EntityId, 30, (key, oldValue) => 30); #if DEBUG if (update == VRage.ModAPI.MyEntityUpdateEnum.EACH_10TH_FRAME) { Log.Debug($"MyLargeTurretBase reset keepalive update={update.ToString()} value=30 entity={__instance.EntityId}({__instance.DisplayNameText})"); } #endif return(true); } // Was doing some shooting and needs to be active until hot else if (_largeTurretBaseKeepalive.TryGetValue(__instance.EntityId, out var keepalive) && keepalive > 0) { if (update == VRage.ModAPI.MyEntityUpdateEnum.EACH_10TH_FRAME) { _largeTurretBaseKeepalive.TryUpdate(__instance.EntityId, keepalive - 1, keepalive); #if DEBUG Log.Debug($"MyLargeTurretBase decreasing keepalive update={update.ToString()} value={keepalive} entity={__instance.EntityId}({__instance.DisplayNameText})"); #endif } return(true); } int value = 0; if (update == VRage.ModAPI.MyEntityUpdateEnum.EACH_FRAME) { value = _largeTurretBaseSlowdown1.AddOrUpdate(__instance.EntityId, _rnd.Next(1, 90), (key, oldValue) => ++ oldValue); } else if (update == VRage.ModAPI.MyEntityUpdateEnum.EACH_10TH_FRAME) { value = _largeTurretBaseSlowdown10.AddOrUpdate(__instance.EntityId, _rnd.Next(1, 9), (key, oldValue) => ++ oldValue); } switch (TweakerPlugin.Instance.Config.LargeTurretBaseTweakFactorType) { case 0: if (value < (int)((Sync.ServerSimulationRatio < TweakerPlugin.Instance.Config.LargeTurretBaseTweakFactor) ? (Sync.ServerSimulationRatio / TweakerPlugin.Instance.Config.LargeTurretBaseTweakFactor) : 1) * tick) { return(false); } break; case 1: if (value < ((Sync.ServerCPULoad > TweakerPlugin.Instance.Config.LargeTurretBaseTweakFactor) ? (TweakerPlugin.Instance.Config.LargeTurretBaseTweakFactor / Sync.ServerCPULoad) : 1) * tick) { return(false); } break; case 2: if (value * (update == VRage.ModAPI.MyEntityUpdateEnum.EACH_10TH_FRAME ? 10 : 1) < TweakerPlugin.Instance.Config.LargeTurretBaseTweakFactor) { return(false); } break; case 3: return(false); } #if DEBUG Log.Debug($"MyLargeTurretBase pass update={update.ToString()} value={value} entity={__instance.EntityId}({__instance.DisplayNameText})"); #endif if (update == VRage.ModAPI.MyEntityUpdateEnum.EACH_FRAME) { _largeTurretBaseSlowdown1[__instance.EntityId] = 0; } else if (update == VRage.ModAPI.MyEntityUpdateEnum.EACH_10TH_FRAME) { _largeTurretBaseSlowdown10[__instance.EntityId] = 0; } return(true); }
public static bool Throttler10(MyLargeTurretBase __instance) { return(Throttler(__instance, VRage.ModAPI.MyEntityUpdateEnum.EACH_10TH_FRAME, 10)); }
public override void OnAddedToContainer(MyComponentContainer container) { base.OnAddedToContainer(container); m_turretBase = Entity as MyLargeTurretBase; }
public TurretWrapper(MySlimBlock block) : base(block) { Block = (MyLargeTurretBase)block.FatBlock; }
// ReSharper disable once InconsistentNaming private static void InitPatch(MyLargeTurretBase __instance) { _shootingRange.GetSync <float>(__instance).ValueChangedInRange(0, __instance.BlockDefinition.MaxRangeMeters); }
public MySyncLargeTurret(MyLargeTurretBase turret) : base(turret) { m_turret = turret; }
public MyDebugRenderComponentLargeTurret(MyLargeTurretBase turretBase) : base(turretBase) { m_turretBase = turretBase; }
public override void OnAddedToContainer() { base.OnAddedToContainer(); m_turretBase = Container.Entity as MyLargeTurretBase; }
public static bool TestPatchMethod(MyLargeTurretBase __instance) { __instance.Enabled = !__instance.Enabled; return(false); }