Guest User

EvilSensor Patch #4

a guest
Nov 10th, 2014
19
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
Diff 2.03 KB | None | 0 0
  1. --- EvilSensor_pre_update.cs    2014-11-10 04:53:08.000000000 -0500
  2. +++ EvilSensor.cs   2014-11-10 23:23:41.480550400 -0500
  3. @@ -1,12 +1,7 @@
  4. -using Sandbox.Common;
  5. -using Sandbox.Common.Components;
  6. +using Sandbox.Common.Components;
  7.  using Sandbox.Common.ObjectBuilders;
  8.  using Sandbox.Definitions;
  9. -using Sandbox.Engine;
  10. -using Sandbox.Game;
  11. -using Sandbox.ModAPI;
  12.  using Sandbox.ModAPI.Ingame;
  13. -using Sandbox.ModAPI.Interfaces;
  14.  
  15.  namespace EvilSensor
  16.  {
  17. @@ -44,11 +39,21 @@
  18.  
  19.              string ore = null;
  20.  
  21. +            var oreAmount = 100;
  22. +
  23.              foreach(var o in OreNames)
  24.              {
  25.                  if (Sensor.CustomName.StartsWith(o, System.StringComparison.InvariantCultureIgnoreCase))
  26.                  {
  27.                      ore = o;
  28. +                    try
  29. +                    {
  30. +                        oreAmount = System.Convert.ToInt32(Sensor.CustomName.Substring(Sensor.CustomName.LastIndexOf(" ") + 1));
  31. +                    }
  32. +                    catch (System.FormatException)
  33. +                    {
  34. +                        oreAmount = 100;
  35. +                    }
  36.                      break;
  37.                  }
  38.              }
  39. @@ -58,7 +63,7 @@
  40.  
  41.              // We want to spawn ore and throw it at entity which entered sensor
  42.              MyObjectBuilder_FloatingObject floatingBuilder = new MyObjectBuilder_FloatingObject();
  43. -            floatingBuilder.Item = new MyObjectBuilder_InventoryItem() { Amount = 100, Content = new MyObjectBuilder_Ore() { SubtypeName = ore } };
  44. +            floatingBuilder.Item = new MyObjectBuilder_InventoryItem() { Amount = oreAmount, Content = new MyObjectBuilder_Ore() { SubtypeName = ore } };
  45.              floatingBuilder.PersistentFlags = MyPersistentEntityFlags2.InScene; // Very important
  46.              floatingBuilder.PositionAndOrientation = new MyPositionAndOrientation(Sensor.WorldMatrix.Translation + Sensor.WorldMatrix.Forward * 1.5f, Sensor.WorldMatrix.Forward, Sensor.WorldMatrix.Up);
  47.              if (Sandbox.ModAPI.MyAPIGateway.Multiplayer.IsServer)
Advertisement
Add Comment
Please, Sign In to add comment