public UserInteractionHandler(
            PluginTrace pluginTrace, PluginInfo pluginInfo, Configuration config,
            WorldMetadata worldMetadata, PluginCooperationHandler pluginCooperationHandler, Action reloadConfigurationCallback
            ) : base(pluginTrace)
        {
            if (pluginTrace == null)
            {
                throw new ArgumentNullException();
            }
            if (config == null)
            {
                throw new ArgumentNullException();
            }
            if (worldMetadata == null)
            {
                throw new ArgumentNullException();
            }
            if (pluginCooperationHandler == null)
            {
                throw new ArgumentNullException();
            }
            if (reloadConfigurationCallback == null)
            {
                throw new ArgumentNullException();
            }

            this.PluginInfo                  = pluginInfo;
            this.Config                      = config;
            this.WorldMetadata               = worldMetadata;
            this.PluginCooperationHandler    = pluginCooperationHandler;
            this.ReloadConfigurationCallback = reloadConfigurationCallback;

            this.RegisterCommand(new[] { "advancedcircuits", "ac" }, this.RootCommand_Exec);
        }
Пример #2
0
        public CircuitHandler(PluginTrace pluginTrace, Configuration config, WorldMetadata worldMetadata, PluginCooperationHandler pluginCooperationHandler)
        {
            Contract.Requires <ArgumentNullException>(pluginTrace != null);
            Contract.Requires <ArgumentNullException>(config != null);
            Contract.Requires <ArgumentNullException>(worldMetadata != null);
            Contract.Requires <ArgumentNullException>(pluginCooperationHandler != null);

            this.PluginTrace              = pluginTrace;
            this.Config                   = config;
            this.WorldMetadata            = worldMetadata;
            this.PluginCooperationHandler = pluginCooperationHandler;
            this.isDayTime                = Main.dayTime;
            this.isDaylight               = (Main.dayTime && Main.time >= 7200 && Main.time <= 46800);

            // Timers are always inactive when a map is loaded, so switch them into their active state.
            foreach (DPoint activeTimerLocation in this.WorldMetadata.ActiveTimers.Keys)
            {
                ObjectMeasureData timerMeasureData = TerrariaUtils.Tiles.MeasureObject(activeTimerLocation);

                if (!TerrariaUtils.Tiles.ObjectHasActiveState(timerMeasureData))
                {
                    TerrariaUtils.Tiles.SetObjectState(timerMeasureData, true);
                }
            }
        }
    public UserInteractionHandler(
      PluginTrace pluginTrace, PluginInfo pluginInfo, Configuration config, 
      WorldMetadata worldMetadata, PluginCooperationHandler pluginCooperationHandler, Action reloadConfigurationCallback
    ): base(pluginTrace) {
      Contract.Requires<ArgumentNullException>(pluginTrace != null);
      Contract.Requires<ArgumentNullException>(config != null);
      Contract.Requires<ArgumentNullException>(worldMetadata != null);
      Contract.Requires<ArgumentNullException>(pluginCooperationHandler != null);
      Contract.Requires<ArgumentNullException>(reloadConfigurationCallback != null);

      this.PluginInfo = pluginInfo;
      this.Config = config;
      this.WorldMetadata = worldMetadata;
      this.PluginCooperationHandler = pluginCooperationHandler;
      this.ReloadConfigurationCallback = reloadConfigurationCallback;

      this.RegisterCommand(new[] { "advancedcircuits", "ac" }, this.RootCommand_Exec);
    }
        public UserInteractionHandler(
            PluginTrace pluginTrace, PluginInfo pluginInfo, Configuration config,
            WorldMetadata worldMetadata, PluginCooperationHandler pluginCooperationHandler, Action reloadConfigurationCallback
            ) : base(pluginTrace)
        {
            Contract.Requires <ArgumentNullException>(pluginTrace != null);
            Contract.Requires <ArgumentNullException>(config != null);
            Contract.Requires <ArgumentNullException>(worldMetadata != null);
            Contract.Requires <ArgumentNullException>(pluginCooperationHandler != null);
            Contract.Requires <ArgumentNullException>(reloadConfigurationCallback != null);

            this.PluginInfo                  = pluginInfo;
            this.Config                      = config;
            this.WorldMetadata               = worldMetadata;
            this.PluginCooperationHandler    = pluginCooperationHandler;
            this.ReloadConfigurationCallback = reloadConfigurationCallback;

            this.RegisterCommand(new[] { "advancedcircuits", "ac" }, this.RootCommand_Exec);
        }
    public CircuitHandler(PluginTrace pluginTrace,Configuration config, WorldMetadata worldMetadata, PluginCooperationHandler pluginCooperationHandler) {
      Contract.Requires<ArgumentNullException>(pluginTrace != null);
      Contract.Requires<ArgumentNullException>(config != null);
      Contract.Requires<ArgumentNullException>(worldMetadata != null);
      Contract.Requires<ArgumentNullException>(pluginCooperationHandler != null);

      this.PluginTrace = pluginTrace;
      this.Config = config;
      this.WorldMetadata = worldMetadata;
      this.PluginCooperationHandler = pluginCooperationHandler;
      this.isDayTime = Main.dayTime;
      this.isDaylight = (Main.dayTime && Main.time >= 7200 && Main.time <= 46800);

      // Timers are always inactive when a map is loaded, so switch them into their active state.
      foreach (DPoint activeTimerLocation in this.WorldMetadata.ActiveTimers.Keys) {
        ObjectMeasureData timerMeasureData = TerrariaUtils.Tiles.MeasureObject(activeTimerLocation);
        
        if(!TerrariaUtils.Tiles.ObjectHasActiveState(timerMeasureData))
          TerrariaUtils.Tiles.SetObjectState(timerMeasureData, true);
      }
    }
        private void Game_PostInitialize(EventArgs e)
        {
            ServerApi.Hooks.GamePostInitialize.Deregister(this, this.Game_PostInitialize);

            if (!Directory.Exists(AdvancedCircuitsPlugin.AdvancedCircuitsDataDirectory))
            {
                Directory.CreateDirectory(AdvancedCircuitsPlugin.AdvancedCircuitsDataDirectory);
            }

            if (!this.InitConfig())
            {
                return;
            }
            if (!this.InitWorldMetdataHandler())
            {
                return;
            }

            this.PluginCooperationHandler = new PluginCooperationHandler(this.Trace);
      #if !Testrun
            this.CircuitHandler = new CircuitHandler(
                this.Trace, this.Config, this.WorldMetadataHandler.Metadata, this.PluginCooperationHandler
                );
      #endif

            this.InitUserInteractionHandler();

            this.hooksEnabled = true;

      #if Testrun
            this.testRunner = new TestRunner(this.Trace, this.WorldMetadataHandler, this.PluginCooperationHandler);
            this.testRunner.RunAllTests();
            this.testRunner.TestRunCompleted += (sender, e) => {
                this.circuitHandler = new CircuitHandler(
                    this.Trace, this.Config, this.WorldMetadataHandler.Metadata, this.PluginCooperationHandler
                    );
                this.config.MaxCircuitLength = 5000;
            };
      #endif
        }
    private void Game_PostInitialize(EventArgs e) {
      ServerApi.Hooks.GamePostInitialize.Deregister(this, this.Game_PostInitialize);

      if (!Directory.Exists(AdvancedCircuitsPlugin.AdvancedCircuitsDataDirectory))
        Directory.CreateDirectory(AdvancedCircuitsPlugin.AdvancedCircuitsDataDirectory);
      
      if (!this.InitConfig())
        return;
      if (!this.InitWorldMetdataHandler())
        return;

      this.PluginCooperationHandler = new PluginCooperationHandler(this.Trace);
      #if !Testrun
      this.CircuitHandler = new CircuitHandler(
        this.Trace, this.Config, this.WorldMetadataHandler.Metadata, this.PluginCooperationHandler
      );
      #endif

      this.InitUserInteractionHandler();

      this.hooksEnabled = true;

      #if Testrun
      this.testRunner = new TestRunner(this.Trace, this.WorldMetadataHandler, this.PluginCooperationHandler);
      this.testRunner.RunAllTests();
      this.testRunner.TestRunCompleted += (sender, e) => {
        this.circuitHandler = new CircuitHandler(
          this.Trace, this.Config, this.WorldMetadataHandler.Metadata, this.PluginCooperationHandler
        );
        this.config.MaxCircuitLength = 5000;
      };
      #endif
    }