private List<TimerBase> runningTimers; // immutable #endregion Fields #region Constructors public TimerManager(PluginTrace pluginTrace) { this.PluginTrace = pluginTrace; this.runningTimers = new List<TimerBase>(10); this.alterTimersLock = new object(); }
public TimerManager(PluginTrace pluginTrace) { this.PluginTrace = pluginTrace; this.runningTimers = new List <TimerBase>(10); this.alterTimersLock = new object(); }
public CircuitProcessor(PluginTrace pluginTrace, CircuitHandler circuitHandler, ObjectMeasureData senderMeasureData) { Contract.Requires<ArgumentNullException>(pluginTrace != null); Contract.Requires<ArgumentNullException>(circuitHandler != null); this.PluginTrace = pluginTrace; this.CircuitHandler = circuitHandler; this.SenderMeasureData = senderMeasureData; // Is sender directly wired? bool isSenderWired; if (this.SenderMeasureData.BlockType == BlockType.DoorOpened) { isSenderWired = false; for (int y = this.SenderMeasureData.OriginTileLocation.Y; y < this.SenderMeasureData.OriginTileLocation.Y + this.SenderMeasureData.Size.Y; y++) { if (TerrariaUtils.Tiles[this.SenderMeasureData.OriginTileLocation.X, y].HasWire()) { isSenderWired = true; break; } } } else { isSenderWired = TerrariaUtils.Tiles.IsObjectWired(this.SenderMeasureData); } this.result = new CircuitProcessingResult { IsAdvancedCircuit = !isSenderWired, SenderLocation = this.SenderMeasureData.OriginTileLocation }; }
public HousingManager(PluginTrace trace, Configuration config) { Contract.Requires<ArgumentNullException>(trace != null); Contract.Requires<ArgumentNullException>(config != null); this.Trace = trace; this.config = config; }
protected WorldMetadataHandlerBase(PluginTrace pluginTrace, string metadataDirectoryPath) : base(pluginTrace, Path.Combine( metadataDirectoryPath, string.Format(WorldMetadataHandlerBase.WorldMetadataFileNameFormat, Main.worldID) )) { if (!Directory.Exists(metadataDirectoryPath)) Directory.CreateDirectory(metadataDirectoryPath); this.MetadataDirectoryPath = metadataDirectoryPath; }
public ProtectionManager( PluginTrace pluginTrace, Configuration config, ChestManager chestManager, ServerMetadataHandler serverMetadataHandler, WorldMetadata worldMetadata ) { this.PluginTrace = pluginTrace; this.config = config; this.ChestManager = chestManager; this.ServerMetadataHandler = serverMetadataHandler; this.WorldMetadata = worldMetadata; }
public PluginCooperationHandler(PluginTrace pluginTrace) { Contract.Requires<ArgumentNullException>(pluginTrace != null); const string ProtectorSomeTypeQualifiedName = "Terraria.Plugins.CoderCow.Protector.ProtectorPlugin, Protector"; const string SignCommandsSomeTypeQualifiedName = "SignCommands.scSign, SignCommands"; this.PluginTrace = pluginTrace; this.IsProtectorAvailable = (Type.GetType(ProtectorSomeTypeQualifiedName, false) != null); this.IsSignCommandsAvailable = (Type.GetType(SignCommandsSomeTypeQualifiedName, false) != null); }
public ProtectionManager( PluginTrace pluginTrace, Configuration config, ServerMetadataHandler serverMetadataHandler, WorldMetadata worldMetadata ) { this.PluginTrace = pluginTrace; this.config = config; this.ServerMetadataHandler = serverMetadataHandler; this.WorldMetadata = worldMetadata; this.RefillTimers = new TimerManager(pluginTrace); this.RefillTimerCallbackHandler = this.RefillChestTimer_Callback; }
protected WorldMetadataHandlerBase(PluginTrace pluginTrace, string metadataDirectoryPath) : base( pluginTrace, Path.Combine( metadataDirectoryPath, string.Format(WorldMetadataHandlerBase.WorldMetadataFileNameFormat, Main.worldID) ) ) { if (!Directory.Exists(metadataDirectoryPath)) { Directory.CreateDirectory(metadataDirectoryPath); } this.MetadataDirectoryPath = metadataDirectoryPath; }
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 ProtectorPlugin(Main game) : base(game) { this.pluginInfo = new PluginInfo( "Protector", Assembly.GetAssembly(typeof(ProtectorPlugin)).GetName().Version, "Beta", "CoderCow", "Protects blocks and objects from being changed." ); this.Order = 1; #if DEBUG if (Debug.Listeners.Count == 0) Debug.Listeners.Add(new ConsoleTraceListener()); #endif this.trace = new PluginTrace(ProtectorPlugin.TracePrefix); ProtectorPlugin.latestInstance = this; }
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 trace, PluginInfo pluginInfo, Configuration config, HousingManager housingManager, Func<Configuration> reloadConfigurationCallback ) : base(trace) { Contract.Requires<ArgumentNullException>(trace != null); Contract.Requires<ArgumentException>(!pluginInfo.Equals(PluginInfo.Empty)); Contract.Requires<ArgumentNullException>(config != null); Contract.Requires<ArgumentNullException>(housingManager != null); Contract.Requires<ArgumentNullException>(reloadConfigurationCallback != null); this.PluginInfo = pluginInfo; this.Config = config; this.HousingManager = housingManager; this.ReloadConfigurationCallback = reloadConfigurationCallback; #region Command Setup base.RegisterCommand( new[] { "house", "housing" }, this.RootCommand_Exec, this.RootCommand_HelpCallback ); #endregion }
protected MetadataHandlerBase(PluginTrace pluginTrace, string metadataFilePath) { this.PluginTrace = pluginTrace; this.MetadataFilePath = metadataFilePath; }
public CircuitProcessor(PluginTrace pluginTrace, CircuitHandler circuitHandler, DPoint senderLocation) : this(pluginTrace, circuitHandler, CircuitProcessor.CircuitProcessorCtor_MeasureSender(senderLocation)) { Contract.Requires<ArgumentNullException>(pluginTrace != null); Contract.Requires<ArgumentNullException>(circuitHandler != null); }
protected UserInteractionHandlerBase(PluginTrace pluginTrace) { this.PluginTrace = pluginTrace; this.RegisteredCommands = new Collection<Command>(); this.activeCommandInteractions = new Dictionary<TSPlayer,CommandInteraction>(); }
public PluginCooperationHandler(PluginTrace pluginTrace) { this.PluginTrace = pluginTrace; }
protected UserInteractionHandlerBase(PluginTrace pluginTrace) { this.PluginTrace = pluginTrace; this.RegisteredCommands = new Collection <Command>(); this.activeCommandInteractions = new Dictionary <TSPlayer, CommandInteraction>(); }
public UserInteractionHandler( PluginTrace trace, PluginInfo pluginInfo, Configuration config, ServerMetadataHandler serverMetadataHandler, WorldMetadata worldMetadata, ProtectionManager protectionManager, ChestManager chestManager, PluginCooperationHandler pluginCooperationHandler, Func<Configuration> reloadConfigurationCallback ) : base(trace) { Contract.Requires<ArgumentNullException>(trace != null); Contract.Requires<ArgumentException>(!pluginInfo.Equals(PluginInfo.Empty)); Contract.Requires<ArgumentNullException>(config != null); Contract.Requires<ArgumentNullException>(serverMetadataHandler != null); Contract.Requires<ArgumentNullException>(worldMetadata != null); Contract.Requires<ArgumentNullException>(protectionManager != null); Contract.Requires<ArgumentNullException>(pluginCooperationHandler != null); Contract.Requires<ArgumentNullException>(reloadConfigurationCallback != null); this.PluginInfo = pluginInfo; this.Config = config; this.ServerMetadataHandler = serverMetadataHandler; this.WorldMetadata = worldMetadata; this.ChestManager = chestManager; this.ProtectionManager = protectionManager; this.PluginCooperationHandler = pluginCooperationHandler; this.ReloadConfigurationCallback = reloadConfigurationCallback; this.PlayerIndexChestDictionary = new Dictionary<int,DPoint>(20); this.ChestPlayerIndexDictionary = new Dictionary<DPoint,int>(20); #region Command Setup base.RegisterCommand( new[] { "protector" }, this.RootCommand_Exec, this.RootCommand_HelpCallback ); base.RegisterCommand( new[] { "protect", "pt" }, this.ProtectCommand_Exec, this.ProtectCommand_HelpCallback, ProtectorPlugin.ManualProtect_Permission, allowServer: false ); base.RegisterCommand( new[] { "deprotect", "dp" }, this.DeprotectCommand_Exec, this.DeprotectCommand_HelpCallback, ProtectorPlugin.ManualDeprotect_Permission, allowServer: false ); base.RegisterCommand( new[] { "protectioninfo", "ptinfo", "pi" }, this.ProtectionInfoCommand_Exec, this.ProtectionInfoCommand_HelpCallback, allowServer: false ); base.RegisterCommand( new[] { "share" }, this.ShareCommand_Exec, this.ShareCommandHelpCallback, allowServer: false ); base.RegisterCommand( new[] { "unshare" }, this.UnshareCommand_Exec, this.UnshareCommand_HelpCallback, allowServer: false ); base.RegisterCommand( new[] { "sharepublic" }, this.SharePublicCommand_Exec, this.SharePublicCommandHelpCallback, allowServer: false ); base.RegisterCommand( new[] { "unsharepublic" }, this.UnsharePublicCommand_Exec, this.UnsharePublicCommand_HelpCallback, allowServer: false ); base.RegisterCommand( new[] { "sharegroup" }, this.ShareGroupCommand_Exec, this.ShareGroupCommand_HelpCallback, ProtectorPlugin.ShareWithGroups_Permission, allowServer: false ); base.RegisterCommand( new[] { "unsharegroup" }, this.UnshareGroupCommand_Exec, this.UnshareGroup_HelpCallback, ProtectorPlugin.ShareWithGroups_Permission, allowServer: false ); base.RegisterCommand( new[] { "lockchest", "lchest" }, this.LockChestCommand_Exec, this.LockChestCommand_HelpCallback, ProtectorPlugin.Utility_Permission, allowServer: false ); base.RegisterCommand( new[] { "swapchest", "schest" }, this.SwapChestCommand_Exec, this.SwapChestCommand_HelpCallback, ProtectorPlugin.Utility_Permission, allowServer: false ); base.RegisterCommand( new[] { "refillchest", "rchest" }, this.RefillChestCommand_Exec, this.RefillChestCommand_HelpCallback, ProtectorPlugin.SetRefillChests_Permission, allowServer: false ); base.RegisterCommand( new[] { "refillchestmany", "rchestmany" }, this.RefillChestManyCommand_Exec, this.RefillChestManyCommand_HelpCallback, ProtectorPlugin.Utility_Permission ); base.RegisterCommand( new[] { "bankchest", "bchest" }, this.BankChestCommand_Exec, this.BankChestCommand_HelpCallback, ProtectorPlugin.SetBankChests_Permission, allowServer: false ); base.RegisterCommand( new[] { "dumpbankchest", "dbchest" }, this.DumpBankChestCommand_Exec, this.DumpBankChestCommand_HelpCallback, ProtectorPlugin.DumpBankChests_Permission, allowServer: false ); base.RegisterCommand( new[] { "tradechest", "tchest" }, this.TradeChestCommand_Exec, this.TradeChestCommand_HelpCallback, ProtectorPlugin.SetTradeChests_Permission, allowServer: false ); #endregion #if DEBUG base.RegisterCommand(new[] { "fc" }, args => { for (int i= 0; i < Main.chest.Length; i++) { if (i != ChestManager.DummyChestIndex) Main.chest[i] = Main.chest[i] ?? new Chest(); } }, requiredPermission: Permissions.maintenance); base.RegisterCommand(new[] { "fcnames" }, args => { for (int i= 0; i < Main.chest.Length; i++) { if (i != ChestManager.DummyChestIndex) { Main.chest[i] = Main.chest[i] ?? new Chest(); Main.chest[i].name = "Chest!"; } } }, requiredPermission: Permissions.maintenance); #endif }
public UserInteractionHandler( PluginTrace trace, PluginInfo pluginInfo, Configuration config, ServerMetadataHandler serverMetadataHandler, WorldMetadata worldMetadata, ProtectionManager protectionManager, PluginCooperationHandler pluginCooperationHandler, Func<Configuration> reloadConfigurationCallback ) : base(trace) { Contract.Requires<ArgumentNullException>(trace != null); Contract.Requires<ArgumentException>(!pluginInfo.Equals(PluginInfo.Empty)); Contract.Requires<ArgumentNullException>(config != null); Contract.Requires<ArgumentNullException>(serverMetadataHandler != null); Contract.Requires<ArgumentNullException>(worldMetadata != null); Contract.Requires<ArgumentNullException>(protectionManager != null); Contract.Requires<ArgumentNullException>(pluginCooperationHandler != null); Contract.Requires<ArgumentNullException>(reloadConfigurationCallback != null); this.PluginInfo = pluginInfo; this.Config = config; this.ServerMetadataHandler = serverMetadataHandler; this.WorldMetadata = worldMetadata; this.ProtectionManager = protectionManager; this.PluginCooperationHandler = pluginCooperationHandler; this.ReloadConfigurationCallback = reloadConfigurationCallback; #region Command Setup base.RegisterCommand( new[] { "protector" }, this.RootCommand_Exec, this.RootCommand_HelpCallback ); base.RegisterCommand( new[] { "protect", "pt" }, this.ProtectCommand_Exec, this.ProtectCommand_HelpCallback, ProtectorPlugin.ManualProtect_Permission, allowServer: false ); base.RegisterCommand( new[] { "deprotect", "dp" }, this.DeprotectCommand_Exec, this.DeprotectCommand_HelpCallback, ProtectorPlugin.ManualDeprotect_Permission, allowServer: false ); base.RegisterCommand( new[] { "protectioninfo", "ptinfo", "pi" }, this.ProtectionInfoCommand_Exec, this.ProtectionInfoCommand_HelpCallback, allowServer: false ); base.RegisterCommand( new[] { "share" }, this.ShareCommand_Exec, this.ShareCommandHelpCallback, allowServer: false ); base.RegisterCommand( new[] { "unshare" }, this.UnshareCommand_Exec, this.UnshareCommand_HelpCallback, allowServer: false ); base.RegisterCommand( new[] { "sharepublic" }, this.SharePublicCommand_Exec, this.SharePublicCommandHelpCallback, allowServer: false ); base.RegisterCommand( new[] { "unsharepublic" }, this.UnsharePublicCommand_Exec, this.UnsharePublicCommand_HelpCallback, allowServer: false ); base.RegisterCommand( new[] { "sharegroup" }, this.ShareGroupCommand_Exec, this.ShareGroupCommand_HelpCallback, ProtectorPlugin.ShareWithGroups_Permission, allowServer: false ); base.RegisterCommand( new[] { "unsharegroup" }, this.UnshareGroupCommand_Exec, this.UnshareGroup_HelpCallback, ProtectorPlugin.ShareWithGroups_Permission, allowServer: false ); base.RegisterCommand( new[] { "lockchest", "lchest" }, this.LockChestCommand_Exec, this.LockChestCommand_HelpCallback, ProtectorPlugin.Utility_Permission, allowServer: false ); base.RegisterCommand( new[] { "refillchest", "rchest" }, this.RefillChestCommand_Exec, this.RefillChestCommand_HelpCallback, ProtectorPlugin.SetRefillChests_Permission, allowServer: false ); base.RegisterCommand( new[] { "refillchestmany", "rchestmany" }, this.RefillChestManyCommand_Exec, this.RefillChestManyCommand_HelpCallback, ProtectorPlugin.Utility_Permission ); base.RegisterCommand( new[] { "bankchest", "bchest" }, this.BankChestCommand_Exec, this.BankChestCommand_HelpCallback, ProtectorPlugin.SetBankChests_Permission, allowServer: false ); base.RegisterCommand( new[] { "dumpbankchest", "dbchest" }, this.DumpBankChestCommand_Exec, this.DumpBankChestCommand_HelpCallback, ProtectorPlugin.DumpBankChests_Permission, allowServer: false ); #endregion }
public TestRunner( PluginTrace pluginTrace, WorldMetadataHandler metadataHandler, PluginCooperationHandler cooperationHandler ): base(pluginTrace) { Contract.Requires<ArgumentNullException>(pluginTrace != null); Contract.Requires<ArgumentNullException>(metadataHandler != null); Contract.Requires<ArgumentNullException>(cooperationHandler != null); this.PluginTrace = pluginTrace; this.MetadataHandler = metadataHandler; this.CooperationHandler = cooperationHandler; this.RegisterTest(@"BP\Multi Branches", this.BP_MultiBranches); this.RegisterTest(@"BP\Snake Branches", this.BP_SnakeBranches); this.RegisterTest(@"BP\Wire Bunch", this.BP_WireBunch); this.RegisterTest(@"BP\Multi Branches2", this.BP_MultiBranches2); this.RegisterTest(@"BP\Double Signal", this.BP_DoubleSignal); this.RegisterTest(@"BP\Double Signal2", this.BP_DoubleSignal2); this.RegisterTest(@"BP\Loop", this.BP_Loop); this.RegisterTest(@"BP\Processing Time", this.BP_ProcessingTime); this.RegisterTest(@"Vanilla\All Sprites State Toggle Test", this.Vanilla_AllSpritesToggleState); this.RegisterTest(@"Vanilla\Basic Door Toggling Test", this.Vanilla_BasicDoorToggling); this.RegisterTest(@"Vanilla\Blocked Door Toggling 1", this.Vanilla_BlockedDoorToggling1); this.RegisterTest(@"Vanilla\Blocked Door Toggling 2", this.Vanilla_BlockedDoorToggling2); this.RegisterTest(@"Vanilla\Pumps", this.Vanilla_Pumps); this.RegisterTest(@"Vanilla\Statues", this.Vanilla_Statues); this.RegisterTest(@"Vanilla\ComponentActivation", this.Vanilla_ComponentActivation); this.RegisterTest(@"Vanilla\Timers", this.Vanilla_Timers); this.RegisterTest(@"AC\All Sprites State Toggle Test", this.AC_AllSpritesToggleState); this.RegisterTest(@"AC\Basic Door Toggling Test", this.AC_BasicDoorToggling); this.RegisterTest(@"AC\Blocked Door Toggling 1", this.AC_BlockedDoorToggling1); this.RegisterTest(@"AC\Blocked Door Toggling 2", this.AC_BlockedDoorToggling2); this.RegisterTest(@"AC\Pumps", this.AC_Pumps); this.RegisterTest(@"AC\Statues", this.AC_Statues); this.RegisterTest(@"AC\ComponentActivation", this.AC_ComponentActivation); this.RegisterTest(@"AC\Single Tile Trigger Ports", this.AC_SingleTileTriggerPorts); this.RegisterTest(@"AC\Single Tile Trigger Input Ports", this.AC_SingleTileTriggerInputPorts); this.RegisterTest(@"AC\Single Tile Trigger Port Input", this.AC_SingleTileTriggerPortInput); this.RegisterTest(@"AC\Self Switching", this.AC_SelfSwitching); this.RegisterTest(@"AC\Multi Port Sending", this.AC_MultiPortSending); this.RegisterTest(@"AC\Green Pressure Plate", this.AC_GreenPressurePlate); this.RegisterTest(@"AC\Red Pressure Plate", this.AC_RedPressurePlate); this.RegisterTest(@"AC\Multi Receiving", this.AC_MultiReceiving); this.RegisterTest(@"AC\Not Gate", this.AC_NotGate); this.RegisterTest(@"AC\Swapper", this.AC_Swapper); this.RegisterTest(@"AC\And Gate", this.AC_AndGate); this.RegisterTest(@"AC\Or Gate", this.AC_OrGate); this.RegisterTest(@"AC\Xor Gate", this.AC_XorGate); this.RegisterTest(@"AC\Input Port Inbetween", this.AC_InputPortInbetween); this.RegisterTest(@"AC\Single Wired Ports", this.AC_SingleWiredPorts); this.RegisterTest(@"AC\Self Deactivating Timers", this.AC_SelfDeactivatingTimers); this.RegisterTest(@"AC\Port Loop Through", this.AC_PortLoopThrough); this.RegisterTest(@"AC\Sender Forwarding", this.AC_SenderForwarding); this.RegisterTest(@"AC\Crossover Bridge", this.AC_CrossoverBridge); this.RegisterTest(@"AC\Multi Tile Trigger Ports 1", this.AC_MultiTileTriggerPorts1); this.RegisterTest(@"AC\Multi Tile Trigger Ports 2", this.AC_MultiTileTriggerPorts2); this.RegisterTest(@"AC\Multi Tile Trigger Input Ports 1", this.AC_MultiTileTriggerInputPorts1); this.RegisterTest(@"AC\Multi Tile Trigger Input Ports 2", this.AC_MultiTileTriggerInputPorts2); this.RegisterTest(@"AC\Multi Tile Trigger Ports 3", this.AC_MultiTileTriggerPorts3); this.RegisterTest(@"AC\Timers", this.AC_Timers); this.RegisterTest(@"AC\NOT Ports 1", this.AC_NOTPorts1); this.RegisterTest(@"AC\NOT Ports 2", this.AC_NOTPorts2); this.RegisterTest(@"AC\NOT Ports 3", this.AC_NOTPorts3); this.RegisterTest(@"AC\Switch Forwarding", this.AC_SwitchForwarding); this.RegisterTest(@"AC\Grandfather Clock", this.AC_GrandfatherClock); this.RegisterTest(@"AC\Block Activator", this.AC_BlockActivator); this.RegisterTest(@"AC\Boulder", this.AC_Boulder); this.RegisterTest(@"AC\Wireless Transmitter", this.AC_WirelessTransmitter); this.RegisterTest(@"AC\Wireless Transmitter 2", this.AC_WirelessTransmitter2); }
public PluginCooperationHandler(PluginTrace pluginTrace) { this.PluginTrace = pluginTrace; this.IsSeconomyAvailable = (Type.GetType(SeconomySomeTypeQualifiedName, false) != null); }
public TimerManager(PluginTrace pluginTrace) { this.PluginTrace = pluginTrace; this.RunningTimers = new List <TimerBase>(); }
public WorldMetadataHandler(PluginTrace pluginTrace, string metadataDirectoryPath): base(pluginTrace, metadataDirectoryPath) {}