public override void LoadData() { try { if (MyAPIGateway.Utilities.IsDedicated) // DS side doesn't need lights { return; } Instance = this; UpdateOnce = new List <BlockLogic>(); monitorTypes = new Dictionary <MyObjectBuilderType, BlockHandling>(); blockLogics = new Dictionary <long, BlockLogic>(); ViewDistanceChecks = new Dictionary <long, Action <Vector3D> >(); TempDummies = new Dictionary <string, IMyModelDummy>(); MyAPIGateway.Entities.OnEntityAdd += EntitySpawned; SetUpdateOrder(MyUpdateOrder.AfterSimulation); Setup(); } catch (Exception e) { SimpleLog.Error(this, e); UnloadData(); throw; } }
public BlockLogic(AttachedLightsSession session, IMyCubeBlock block, LightConfigurator configurator) { Session = session; Block = block; this.configurator = configurator; Block.IsWorkingChanged += WorkingChanged; WorkingChanged(Block); if (maxViewRangeSq > 0) { session.ViewDistanceChecks.Add(Block.EntityId, RangeCheck); } }
protected override void UnloadData() { Instance = null; if (MyAPIGateway.Utilities.IsDedicated) { return; } MyAPIGateway.Entities.OnEntityAdd -= EntitySpawned; monitorTypes?.Clear(); monitorTypes = null; blockLogics?.Clear(); blockLogics = null; ViewDistanceChecks?.Clear(); ViewDistanceChecks = null; TempDummies?.Clear(); TempDummies = null; }