public override void UpdateBeforeSimulation100() { base.UpdateBeforeSimulation100(); IMyInventory inventory = ((Sandbox.ModAPI.IMyTerminalBlock)Entity).GetInventory(0) as IMyInventory; float percent = MathHelper.Clamp((int)Math.Floor(110 - ((float)inventory.CurrentVolume / (float)inventory.MaxVolume * 100f)), 10, 100); terminalBlock.CustomData = "Efficiency: " + percent + "%"; while (new Random().Next(0, 100) < percent) { VRage.MyFixedPoint amount = (VRage.MyFixedPoint)(0.01); inventory.AddItems(amount, new MyObjectBuilder_Ingot() { SubtypeName = "UnstableMatter" }); terminalBlock.RefreshCustomInfo(); percent *= 0.3f; } if (new Random().Next(0, 30000) < 1) { inventory.AddItems((VRage.MyFixedPoint)(1), new MyObjectBuilder_Component() { SubtypeName = "SpecialTech" }); terminalBlock.RefreshCustomInfo(); } }
public override void UpdateBeforeSimulation100() { base.UpdateBeforeSimulation100(); if (m_generator.IsWorking) { IMyInventory inventory = ((Sandbox.ModAPI.IMyTerminalBlock)Entity).GetInventory(1) as IMyInventory; VRage.MyFixedPoint amount = 1; //if (!inventory.ContainItems(amount, new MyObjectBuilder_PhysicalGunObject { SubtypeName = "AutomaticRifleItem" })) //{ // inventory.AddItems(amount, new MyObjectBuilder_PhysicalGunObject { SubtypeName = "AutomaticRifleItem" }); // terminalBlock.RefreshCustomInfo(); //} //if (!inventory.ContainItems(amount, new MyObjectBuilder_AmmoMagazine { SubtypeName = "NATO_5p56x45mm" })) //{ // inventory.AddItems(10, new MyObjectBuilder_AmmoMagazine { SubtypeName = "NATO_5p56x45mm" }); // terminalBlock.RefreshCustomInfo(); //} //if (!inventory.ContainItems(10000, new MyObjectBuilder_Ore { SubtypeName = "Iron" })) //{ // inventory.AddItems(amount, new MyObjectBuilder_Ore { SubtypeName = "Iron" }); // terminalBlock.RefreshCustomInfo(); //} float cur = (float)inventory.CurrentVolume; float max = (float)inventory.MaxVolume; if (cur / max < 0.9 && inventory.ContainItems(1, new MyObjectBuilder_Ingot { SubtypeName = "Supply" })) { inventory.RemoveItemsOfType(1, new MyObjectBuilder_Ingot { SubtypeName = "Supply" }); BlackShop.AddSupply(inventory); terminalBlock.RefreshCustomInfo(); } if (cur / max < 0.9 && inventory.ContainItems(1, new MyObjectBuilder_Ingot { SubtypeName = "Supply2" })) { inventory.RemoveItemsOfType(1, new MyObjectBuilder_Ingot { SubtypeName = "Supply2" }); BlackShop.AddSupply(inventory, true); terminalBlock.RefreshCustomInfo(); } } }
public override void UpdateBeforeSimulation() { density = atmoDet.AtmosphereDetection(this.Entity); if (density > 0f) { inAtmos = true; } else { inAtmos = false; } terminalBlock.RefreshCustomInfo(); base.UpdateBeforeSimulation(); }
public override void UpdateBeforeSimulation100() { base.UpdateBeforeSimulation100(); if (m_generator.IsWorking) { Frame = frameShift++; if (Frame % 30 != 0) { return; } List <IMyPlayer> players = new List <IMyPlayer>(); MyAPIGateway.Players.GetPlayers(players, x => x.Character != null && !x.IsBot); int count = players.Count; IMyInventory inventory = ((Sandbox.ModAPI.IMyTerminalBlock)Entity).GetInventory(0) as IMyInventory; if (!inventory.ContainItems(Core.Settings.ResourceMax, new MyObjectBuilder_Ingot { SubtypeName = "Coin" })) { inventory.AddItems(Core.Settings.ResourcePerMinute + count * Core.Settings.ResourceIncreasePerPlayerMinute, new MyObjectBuilder_Ingot { SubtypeName = "Coin" }); terminalBlock.RefreshCustomInfo(); } //IMyInventory inventory1 = ((Sandbox.ModAPI.IMyTerminalBlock)Entity).GetInventory(1) as IMyInventory; //if (!inventory1.ContainItems(10, new MyObjectBuilder_AmmoMagazine { SubtypeName = "NATO_25x184mm" })) //{ // inventory1.AddItems(1, new MyObjectBuilder_AmmoMagazine { SubtypeName = "NATO_25x184mm" }); // terminalBlock.RefreshCustomInfo(); //} //List<IMyPlayer> players = new List<IMyPlayer>(); //MyAPIGateway.Players.GetPlayers(players, x => x.Controller != null && x.Controller.ControlledEntity != null); //foreach (IMyPlayer player in players) //{ // if (player.Controller.ControlledEntity is IMyCharacter) // { // MyEntity entity = player.Controller.ControlledEntity.Entity as MyEntity; // if (entity.HasInventory) // { // inventory = entity.GetInventoryBase() as MyInventory; // if (!inventory.ContainItems(10000, new MyObjectBuilder_Ingot { SubtypeName = "Coin" })) // { // inventory.AddItems(5, new MyObjectBuilder_Ingot { SubtypeName = "Coin" }); // terminalBlock.RefreshCustomInfo(); // } // } // } //} } }
public override void UpdateBeforeSimulation10() { if (m_generator.Mode == MyAssemblerMode.Disassembly) { m_generator.Mode = MyAssemblerMode.Assembly; terminalBlock.RefreshCustomInfo(); } base.UpdateBeforeSimulation10(); }
public void UpdatePrintBalanced() { if (!m_closed && Entity.InScene) { Sandbox.ModAPI.IMyTerminalBlock terminalBlock = Entity as Sandbox.ModAPI.IMyTerminalBlock; terminalBlock.RefreshCustomInfo(); printShieldStatus(); } }
public override void UpdateBeforeSimulation100() { base.UpdateBeforeSimulation100(); if (!_init) { TerminalBlock = Entity as Sandbox.ModAPI.IMyTerminalBlock; TerminalBlock.AppendingCustomInfo += AppendingCustomInfo; _init = true; } if (TerminalBlock.IsFunctional) { CompostGrid gridData = CompostDataStore.Get(TerminalBlock); float playerAmount = 0; if (gridData.LastScan == null || gridData.LastScan < DateTime.Now.AddSeconds(-5)) { gridData.Refresh(); foreach (IMyIdentity identity in gridData.PlayersOnToilet) { IMyPlayer player = Utilities.IdentityToPlayer(identity); if (player == null || player.Character == null || !player.Character.HasInventory) { continue; } IMyInventory inven = player.Character.GetInventory(); for (int i = inven.ItemCount - 1; i >= 0; i--) { VRage.Game.ModAPI.Ingame.MyInventoryItem?item = inven.GetItemAt(i); if (!item.HasValue) { continue; } if (item.Value.Type.ToString().Contains("Ore/Organic")) { playerAmount += (float)item.Value.Amount; inven.RemoveItemsAt(i); } } } } float amount = playerAmount + MyUtils.GetRandomFloat(Config.Instance.OrganicPerOxyenfarmPerSecondMin * gridData.EffectiveFarms * 1.6f, Config.Instance.OrganicPerOxyenfarmPerSecondMax * gridData.EffectiveFarms * 1.6f); TerminalBlock.GetInventory().AddItems((VRage.MyFixedPoint)amount, new MyObjectBuilder_Ore() { SubtypeName = "Organic" }); TerminalBlock.RefreshCustomInfo(); } }
void Recharge() { int chargesInInventory = (int)m_inventory.GetItemAmount(chargeDefinitionIds[damageUpgrades]); if (chargesInInventory < attractorWeaponInfo.keepAtCharge) { if (resourceSink.RequiredInputByType(electricityDefinition) != (attractorWeaponInfo.powerUsage / efficiencyUpgrades)) { resourceSink.SetRequiredInputByType(electricityDefinition, (attractorWeaponInfo.powerUsage / efficiencyUpgrades)); setPowerConsumption = (attractorWeaponInfo.powerUsage / efficiencyUpgrades); powerConsumption = (attractorWeaponInfo.powerUsage / efficiencyUpgrades); } else { if (!functionalBlock.Enabled) { powerConsumption = 0.0001f; } } if (resourceSink.CurrentInputByType(electricityDefinition) == (attractorWeaponInfo.powerUsage / efficiencyUpgrades)) { if (!overheated) { m_inventory.AddItems((MyFixedPoint)(attractorWeaponInfo.keepAtCharge - chargesInInventory), chargeObjectBuilders [damageUpgrades]); } } } else if (chargesInInventory > attractorWeaponInfo.keepAtCharge) { m_inventory.RemoveItemsOfType((MyFixedPoint)(chargesInInventory - attractorWeaponInfo.keepAtCharge), chargeObjectBuilders [damageUpgrades]); } else { if (setPowerConsumption != 0.0001f) { resourceSink.SetRequiredInputByType(electricityDefinition, 0.0001f); setPowerConsumption = 0.0001f; powerConsumption = 0.0001f; } } terminalBlock.RefreshCustomInfo(); }
public override void UpdateBeforeSimulation() { powerConsumption = resourceSink.CurrentInputByType(electricityDefinition); if (!m_inventory.IsItemAt(0)) { if (!functionalBlock.Enabled) { powerConsumption = 0.0001f; setPowerConsumption = 0.0001f; } else { if (setPowerConsumption != (pulseWeaponInfo.powerUsage / efficiencyUpgrades)) { resourceSink.SetRequiredInputByType(electricityDefinition, (pulseWeaponInfo.powerUsage / efficiencyUpgrades)); setPowerConsumption = (pulseWeaponInfo.powerUsage / efficiencyUpgrades); powerConsumption = resourceSink.CurrentInputByType(electricityDefinition); } charge += powerConsumption; if (charge > (pulseWeaponInfo.energyPerProjectile / efficiencyUpgrades)) { m_inventory.AddItems((MyFixedPoint)pulseWeaponInfo.projectilesPerCharge, chargeObjectBuilders [damageUpgrades]); charge -= (pulseWeaponInfo.energyPerProjectile / efficiencyUpgrades); } } } else { if (setPowerConsumption != 0.0001f) { resourceSink.SetRequiredInputByType(electricityDefinition, 0.0001f); setPowerConsumption = 0.0001f; powerConsumption = resourceSink.CurrentInputByType(electricityDefinition); } } terminalBlock.RefreshCustomInfo(); }
public override void UpdateBeforeSimulation100() { base.UpdateBeforeSimulation100(); //if (m_generator.IsWorking && !m_generator.CustomData.Contains("No Drill")) if (m_generator.IsWorking && m_stoneEnabled) { if (IsInVoxel(m_generator as Sandbox.ModAPI.IMyTerminalBlock)) { IMyInventory inventory = ((Sandbox.ModAPI.IMyTerminalBlock)Entity).GetInventory(1) as IMyInventory; VRage.MyFixedPoint amount = (VRage.MyFixedPoint)(500 * (1 + (0.4 * m_generator.UpgradeValues["Productivity"]))); inventory.AddItems(amount, new MyObjectBuilder_Ore() { SubtypeName = "Stone" }); terminalBlock.RefreshCustomInfo(); } } }
public override void UpdateBeforeSimulation100() { base.UpdateBeforeSimulation100(); IMyInventory inventory = ((Sandbox.ModAPI.IMyTerminalBlock)Entity).GetInventory(0) as IMyInventory; if (inventory.ItemCount < 1) { MyObjectBuilder_AmmoMagazine builder = new MyObjectBuilder_AmmoMagazine() { SubtypeName = "Missile200mm" }; inventory.AddItems((MyFixedPoint)6, builder); } TerminalalBlock.RefreshCustomInfo(); }
public override void UpdateBeforeSimulation100() { base.UpdateBeforeSimulation100(); if (m_generator.IsFunctional) { IMyInventory inventory = ((Sandbox.ModAPI.IMyTerminalBlock)Entity).GetInventory(1) as IMyInventory; VRage.MyFixedPoint amount = 1; if (!inventory.ContainItems(10000, new MyObjectBuilder_Ore { SubtypeName = "Iron" })) { inventory.AddItems(5, new MyObjectBuilder_Ore { SubtypeName = "Iron" }); terminalBlock.RefreshCustomInfo(); } } }
public override void UpdateBeforeSimulation100() { base.UpdateBeforeSimulation100(); IMyInventory inventory = ((Sandbox.ModAPI.IMyTerminalBlock)Entity).GetInventory(0) as IMyInventory; double targetAmount = 10000; if (TerminalalBlock.CustomData != null && TerminalalBlock.CustomData != "") { try { targetAmount = double.Parse(TerminalalBlock.CustomData); } catch (Exception e) { } } try { for (int i = 0; i < inventory.ItemCount; i++) { MyObjectBuilder_PhysicalObject builder = GetItemBuilder(inventory.GetItemAt(i).Value); if (builder == null) { continue; } double amount = targetAmount - (double)inventory.GetItemAmount(builder); if (amount < 0) { inventory.RemoveItemsOfType((MyFixedPoint)Math.Abs(amount), builder); } else if (amount > 0) { inventory.AddItems((MyFixedPoint)amount, builder); } } } catch (Exception e) { } TerminalalBlock.RefreshCustomInfo(); }
public override void UpdateBeforeSimulation100() { w_density = atmoDet.AtmosphereDetectionVaporator(this.Entity); IMyInventory inventory = ((Sandbox.ModAPI.IMyTerminalBlock)Entity).GetInventory(1) as IMyInventory; //check to see if the block is on if (m_vaporator.Enabled && m_vaporator.IsWorking && m_vaporator.IsFunctional) { try { var sink = Entity.Components.Get <MyResourceSinkComponent>(); poweruse = 0.4f * (1f + m_vaporator.UpgradeValues["Productivity"]) * (1f / m_vaporator.UpgradeValues["PowerEfficiency"]); if (sink != null) { sink.SetRequiredInputByType(MyResourceDistributorComponent.ElectricityId, poweruse); } } catch (Exception e) { MyAPIGateway.Utilities.ShowNotification("[ Error in " + GetType().FullName + ": " + e.Message + " ]", 10000, MyFontEnum.Red); MyLog.Default.WriteLine(e); } //m_vaporator.PowerConsumptionMultiplier = 10 * (1f + m_vaporator.UpgradeValues["Productivity"]) * (1f / m_vaporator.UpgradeValues["PowerEfficiency"]); VRage.MyFixedPoint amount = (VRage.MyFixedPoint)(0.2 * (w_density * m_vaporator.UpgradeValues["Effectiveness"]) * (1 + m_vaporator.UpgradeValues["Productivity"])); inventory.AddItems(amount, new MyObjectBuilder_Ore() { SubtypeName = "Ice" }); } terminalBlock.RefreshCustomInfo(); base.UpdateBeforeSimulation100(); }
public override void UpdateBeforeSimulation100() { base.UpdateBeforeSimulation100(); if (m_generator.IsFunctional) { IMyInventory inventory = ((Sandbox.ModAPI.IMyTerminalBlock)Entity).GetInventory(1) as IMyInventory; VRage.MyFixedPoint amount = 1; float cur = (float)inventory.CurrentVolume; float max = (float)inventory.MaxVolume; if (cur / max < 0.8 && inventory.ContainItems(1, new MyObjectBuilder_Ingot { SubtypeName = "RandomItem" })) { inventory.RemoveItemsOfType(1, new MyObjectBuilder_Ingot { SubtypeName = "RandomItem" }); RandomShop.AddRandomItem(inventory); terminalBlock.RefreshCustomInfo(); } } }
public override void UpdateBeforeSimulation() { int chargesInInventory = (int)m_inventory.GetItemAmount(chargeDefinitionIds [damageUpgrades]); IMyCubeBlock cube = Entity as IMyCubeBlock; long currentShootTime = ((MyObjectBuilder_InteriorTurret)cube.GetObjectBuilderCubeBlock()).GunBase.LastShootTime; if (currentHeat > 0f) { if ((ticks - lastShootTimeTicks) > beamWeaponInfo.heatDissipationDelay) { currentHeat -= beamWeaponInfo.heatDissipationPerTick; if (currentHeat <= 0f) { currentHeat = 0f; overheated = false; } } } //MyAPIGateway.Utilities.ShowNotification("TIME: " + currentShootTime + " :: " + lastShootTime, 17, MyFontEnum.Red); if (currentShootTime != lastShootTime) { // test hitBool = false; MyEntitySubpart subpart1 = cubeBlock.GetSubpart("InteriorTurretBase1"); MyEntitySubpart subpart2 = subpart1.GetSubpart("InteriorTurretBase2");; //MyAPIGateway.Utilities.ShowNotification("Dif: " + (currentShootTime - lastShootTime), 17, MyFontEnum.Blue); from = subpart2.WorldMatrix.Translation + subpart2.WorldMatrix.Forward * 1.25d; to = subpart2.WorldMatrix.Translation + subpart2.WorldMatrix.Forward * 3000d; LineD testRay = new LineD(from, to); List <MyLineSegmentOverlapResult <MyEntity> > result = new List <MyLineSegmentOverlapResult <MyEntity> >(); MyGamePruningStructure.GetAllEntitiesInRay(ref testRay, result); foreach (var resultItem in result) { IMyCubeGrid grid = resultItem.Element as IMyCubeGrid; IMyDestroyableObject destroyableEntity = resultItem.Element as IMyDestroyableObject; if (grid != null) { IMySlimBlock slimblock; double hitd; Vector3D?resultVec = grid.GetLineIntersectionExactAll(ref testRay, out hitd, out slimblock); if (resultVec != null) { hitBool = true; toTarget = from + subpart2.WorldMatrix.Forward * hitd; if (!MyAPIGateway.Session.CreativeMode) { slimblock.DoDamage(beamWeaponInfo.damage * (currentHeat / beamWeaponInfo.maxHeat + 0.2f), MyStringHash.GetOrCompute("Laser"), false, default(MyHitInfo), cubeBlock.EntityId); } else { slimblock.DoDamage(beamWeaponInfo.damage * 1.2f, MyStringHash.GetOrCompute("Laser"), false, default(MyHitInfo), cubeBlock.EntityId); } //MyAPIGateway.Utilities.ShowNotification("" + s.BlockDefinition.Id.SubtypeId + " ::: " + resultItem.Distance, 17); } } if (destroyableEntity != null) { IMyEntity ent = (IMyEntity)destroyableEntity; double hitd = (from - ent.WorldMatrix.Translation).Length(); toTarget = from + subpart2.WorldMatrix.Forward * hitd; hitBool = true; if (!MyAPIGateway.Session.CreativeMode) { destroyableEntity.DoDamage(beamWeaponInfo.damage * (currentHeat / beamWeaponInfo.maxHeat + 0.2f), MyStringHash.GetOrCompute("Laser"), false, default(MyHitInfo), cubeBlock.EntityId); } else { destroyableEntity.DoDamage(beamWeaponInfo.damage * 1.2f, MyStringHash.GetOrCompute("Laser"), false, default(MyHitInfo), cubeBlock.EntityId); } } } // test lastShootTime = currentShootTime; lastShootTimeTicks = ticks; currentHeat += beamWeaponInfo.heatPerTick; if (currentHeat > beamWeaponInfo.maxHeat) { currentHeat = beamWeaponInfo.maxHeat; overheated = true; } } if (ticks - lastShootTimeTicks < 3) { var beamcolor = Color.DodgerBlue; var beamcolor_aux = Color.LightSkyBlue; var maincolor = new Vector4(beamcolor.X / 30, beamcolor.Y / 30, beamcolor.Z / 30, 1f); var auxcolor = new Vector4(beamcolor_aux.X / 30, beamcolor_aux.Y / 30, beamcolor_aux.Z / 30, 1f); var material = MyStringId.GetOrCompute("WeaponLaser"); if (hitBool == false) { if (!MyAPIGateway.Utilities.IsDedicated) { if (!MyAPIGateway.Session.CreativeMode) { VRage.Game.MySimpleObjectDraw.DrawLine(from, to, material, ref auxcolor, 0.30f); VRage.Game.MySimpleObjectDraw.DrawLine(from, to, material, ref maincolor, 1.0f); } else { VRage.Game.MySimpleObjectDraw.DrawLine(from, to, material, ref auxcolor, 0.30f * 1.2f); VRage.Game.MySimpleObjectDraw.DrawLine(from, to, material, ref maincolor, 1.0f * 1.2f); } } } else { if (!MyAPIGateway.Utilities.IsDedicated) { if (!MyAPIGateway.Session.CreativeMode) { VRage.Game.MySimpleObjectDraw.DrawLine(from, toTarget, material, ref auxcolor, 0.30f); VRage.Game.MySimpleObjectDraw.DrawLine(from, toTarget, material, ref maincolor, 1.0f); } else { VRage.Game.MySimpleObjectDraw.DrawLine(from, toTarget, material, ref auxcolor, 0.30f * 1.2f); VRage.Game.MySimpleObjectDraw.DrawLine(from, toTarget, material, ref maincolor, 1.0f * 1.2f); } } } } if (chargesInInventory < beamWeaponInfo.keepAtCharge) { if (resourceSink.RequiredInputByType(electricityDefinition) != (beamWeaponInfo.powerUsage / efficiencyUpgrades)) { resourceSink.SetRequiredInputByType(electricityDefinition, (beamWeaponInfo.powerUsage / efficiencyUpgrades)); setPowerConsumption = (beamWeaponInfo.powerUsage / efficiencyUpgrades); powerConsumption = (beamWeaponInfo.powerUsage / efficiencyUpgrades); } else { if (!functionalBlock.Enabled) { powerConsumption = 0.0001f; } } if (resourceSink.CurrentInputByType(electricityDefinition) == (beamWeaponInfo.powerUsage / efficiencyUpgrades)) { if (!overheated) { m_inventory.AddItems((MyFixedPoint)(beamWeaponInfo.keepAtCharge - chargesInInventory), chargeObjectBuilders [damageUpgrades]); } } } else if (chargesInInventory > beamWeaponInfo.keepAtCharge) { m_inventory.RemoveItemsOfType((MyFixedPoint)(chargesInInventory - beamWeaponInfo.keepAtCharge), chargeObjectBuilders [damageUpgrades]); } else { if (setPowerConsumption != 0.0001f) { resourceSink.SetRequiredInputByType(electricityDefinition, 0.0001f); setPowerConsumption = 0.0001f; powerConsumption = 0.0001f; } } terminalBlock.RefreshCustomInfo(); ticks++; }