Not a member of Pastebin yet?
Sign Up,
it unlocks many cool features!
- --- EvilSensor_pre_update.cs 2014-11-10 04:53:08.000000000 -0500
- +++ EvilSensor.cs 2014-11-10 23:23:41.480550400 -0500
- @@ -1,12 +1,7 @@
- -using Sandbox.Common;
- -using Sandbox.Common.Components;
- +using Sandbox.Common.Components;
- using Sandbox.Common.ObjectBuilders;
- using Sandbox.Definitions;
- -using Sandbox.Engine;
- -using Sandbox.Game;
- -using Sandbox.ModAPI;
- using Sandbox.ModAPI.Ingame;
- -using Sandbox.ModAPI.Interfaces;
- namespace EvilSensor
- {
- @@ -44,11 +39,21 @@
- string ore = null;
- + var oreAmount = 100;
- +
- foreach(var o in OreNames)
- {
- if (Sensor.CustomName.StartsWith(o, System.StringComparison.InvariantCultureIgnoreCase))
- {
- ore = o;
- + try
- + {
- + oreAmount = System.Convert.ToInt32(Sensor.CustomName.Substring(Sensor.CustomName.LastIndexOf(" ") + 1));
- + }
- + catch (System.FormatException)
- + {
- + oreAmount = 100;
- + }
- break;
- }
- }
- @@ -58,7 +63,7 @@
- // We want to spawn ore and throw it at entity which entered sensor
- MyObjectBuilder_FloatingObject floatingBuilder = new MyObjectBuilder_FloatingObject();
- - floatingBuilder.Item = new MyObjectBuilder_InventoryItem() { Amount = 100, Content = new MyObjectBuilder_Ore() { SubtypeName = ore } };
- + floatingBuilder.Item = new MyObjectBuilder_InventoryItem() { Amount = oreAmount, Content = new MyObjectBuilder_Ore() { SubtypeName = ore } };
- floatingBuilder.PersistentFlags = MyPersistentEntityFlags2.InScene; // Very important
- floatingBuilder.PositionAndOrientation = new MyPositionAndOrientation(Sensor.WorldMatrix.Translation + Sensor.WorldMatrix.Forward * 1.5f, Sensor.WorldMatrix.Forward, Sensor.WorldMatrix.Up);
- if (Sandbox.ModAPI.MyAPIGateway.Multiplayer.IsServer)
Advertisement
Add Comment
Please, Sign In to add comment