private static void HandleEmitters(byte[] data) { byte lengh = data[1]; var emitters = new List <Emitter>(); for (var i = 2; i < data.Length; i += lengh) { var em = new byte[lengh]; Array.Copy(data, i, em, 0, lengh); var emitter = MyAPIGateway.Utilities.SerializeFromBinary <Emitter>(em); emitters.Add(emitter); } var emitterDic = new Dictionary <IMySlimBlock, int>(); foreach (Emitter emitter in emitters) { IMyEntity entity; MyAPIGateway.Entities.TryGetEntityById(emitter.GridId, out entity); if (entity == null) { MyAPIGateway.Utilities.ShowMessage(emitter.GridId.ToString(), "NULL GRID"); } var pos = new Vector3I(emitter.PosX, emitter.PosY, emitter.PosZ); IMySlimBlock block = (entity as IMyCubeGrid)?.GetCubeBlock(pos); if (block == null) { MyAPIGateway.Utilities.ShowMessage(pos.ToString(), "NULL BLOCK"); continue; } emitterDic.Add(block, emitter.EffectId); } DamageCore.CheckAndRemoveEmitters(emitterDic); DamageCore.AddNewEmitters(emitterDic); }
public override void LoadData() { base.LoadData(); Instance = this; }