示例#1
0
		/// <summary>
		/// Creates a Logger that gets the context and states from block and supplied function.
		/// </summary>
		/// <param name="calling_class">the name of the class this Logger belongs to</param>
		/// <param name="block">The block to get context and states from</param>
		/// <param name="default_secondary">the secondary state used when one is not supplied to alwaysLog() or debugLog()</param>
		public Logger(string calling_class, IMyCubeBlock block, Func<string> default_secondary = null)
		{
			this.m_classname = calling_class;

			this.f_context = () => block.CubeGrid.DisplayName + " - " + block.CubeGrid.EntityId;
			if (default_secondary == null)
			{
				this.f_state_primary = () => block.DefinitionDisplayNameText;
				this.f_state_secondary = () => block.getNameOnly() + " - " + block.EntityId;
			}
			else
			{
				this.f_state_primary = () => block.getNameOnly() + " - " + block.EntityId;
				this.f_state_secondary = default_secondary;
			}
		}
示例#2
0
		public Turret(IMyCubeBlock block)
			: base(block)
		{
			myLogger = new Logger("Turret", () => block.CubeGrid.DisplayName, () => block.DefinitionDisplayNameText, () => block.getNameOnly());
			Registrar.Add(CubeBlock, this);
			//myLogger.debugLog("definition limits = " + definition.MinElevationDegrees + ", " + definition.MaxElevationDegrees + ", " + definition.MinAzimuthDegrees + ", " + definition.MaxAzimuthDegrees, "Turret()");
			//myLogger.debugLog("radian limits = " + minElevation + ", " + maxElevation + ", " + minAzimuth + ", " + maxAzimuth, "Turret()");
		}
示例#3
0
		public InterpreterWeapon(IMyCubeBlock block)
			: base(block as IMyTerminalBlock)
		{
			this.Block = block;
			this.Grid = block.CubeGrid;

			myLogger = new Logger("InterpreterWeapon", () => Grid.DisplayName, () => Block.DefinitionDisplayNameText, () => Block.getNameOnly());
		}
示例#4
0
		public InterpreterWeapon(IMyCubeBlock block)
		{
			this.Block = block;
			this.Grid = block.CubeGrid;
			this.m_instructions = new BlockInstructions(block as IMyTerminalBlock, OnInstruction);

			myLogger = new Logger("InterpreterWeapon", () => Grid.DisplayName, () => Block.DefinitionDisplayNameText, () => Block.getNameOnly());
		}
示例#5
0
        public InterpreterWeapon(IMyCubeBlock block)
            : base(block)
        {
            this.Block = block;
            this.Grid = block.CubeGrid;

            myLogger = new Logger("InterpreterWeapon", () => Grid.DisplayName, () => Block.DefinitionDisplayNameText, () => Block.getNameOnly()) { MinimumLevel = Logger.severity.INFO };
        }
示例#6
0
        private string getBlockName(IMyCubeBlock Fatblock)
        {
            string blockName;

            if (Fatblock is Ingame.IMyRemoteControl)
            {
                blockName = Fatblock.getNameOnly();
                if (blockName == null)
                {
                    blockName = Fatblock.DisplayNameText;
                }
            }
            else
            {
                blockName = Fatblock.DisplayNameText;
            }
            return(blockName);
        }
示例#7
0
        /// <summary>
        /// Creates a Logger that gets the context and states from block and supplied function.
        /// </summary>
        /// <param name="calling_class">the name of the class this Logger belongs to</param>
        /// <param name="block">The block to get context and states from</param>
        /// <param name="default_secondary">the secondary state used when one is not supplied to alwaysLog() or debugLog()</param>
        public Logger(string calling_class, IMyCubeBlock block, Func<string> default_secondary = null)
        {
            this.m_classname = calling_class;

            if (block == null)
            {
                f_context = () => "Null block";
                return;
            }

            this.f_context = () => {
                IMyCubeGrid grid = block.CubeGrid;
                if (grid == null)
                    return "Null grid";
                return grid.DisplayName + " - " + grid.EntityId;
            };

            if (default_secondary == null)
            {
                this.f_state_primary = () => block.DefinitionDisplayNameText;
                this.f_state_secondary = () => block.getNameOnly() + " - " + block.EntityId;
            }
            else
            {
                this.f_state_primary = () => block.getNameOnly() + " - " + block.EntityId;
                this.f_state_secondary = default_secondary;
            }
        }
示例#8
0
 public TextPanel(IMyCubeBlock block)
 {
     myCubeBlock = block;
     myTextPanel = block as Ingame.IMyTextPanel;
     myTermBlock = block as IMyTerminalBlock;
     myLogger    = new Logger("TextPanel", () => myCubeBlock.CubeGrid.DisplayName, () => myCubeBlock.getNameOnly());
     myLogger.debugLog("init: " + myCubeBlock.DisplayNameText, "DelayedInit()");
     myTermBlock.CustomNameChanged += TextPanel_CustomNameChanged;
     myTermBlock.OnClosing         += Close;
 }
示例#9
0
		public Turret(IMyCubeBlock block)
			: base(block)
		{
			myLogger = new Logger("Turret", () => block.CubeGrid.DisplayName, () => block.DefinitionDisplayNameText, () => block.getNameOnly());
			Registrar.Add(CubeBlock, this);
		}
示例#10
0
        private void runActionOnBlock(string blockName, string actionString)
        {
            //log("entered runActionOnBlock("+blockName+", "+actionString+")", "runActionOnBlock()", Logger.severity.TRACE);
            blockName    = blockName.ToLower().Replace(" ", "");
            actionString = actionString.Trim();

            List <IMySlimBlock> blocksWithName = new List <IMySlimBlock>();

            owner.myGrid.GetBlocks(blocksWithName);
            foreach (IMySlimBlock block in blocksWithName)
            {
                IMyCubeBlock fatblock = block.FatBlock;
                if (fatblock == null)
                {
                    continue;
                }

                Sandbox.Common.MyRelationsBetweenPlayerAndBlock relationship = fatblock.GetUserRelationToOwner(owner.currentRCblock.OwnerId);
                if (relationship != Sandbox.Common.MyRelationsBetweenPlayerAndBlock.Owner && relationship != Sandbox.Common.MyRelationsBetweenPlayerAndBlock.FactionShare)
                {
                    //log("failed relationship test for " + fatblock.DisplayNameText + ", result was " + relationship.ToString(), "runActionOnBlock()", Logger.severity.TRACE);
                    continue;
                }
                //log("passed relationship test for " + fatblock.DisplayNameText + ", result was " + relationship.ToString(), "runActionOnBlock()", Logger.severity.TRACE);

                //log("testing: " + fatblock.DisplayNameText, "runActionOnBlock()", Logger.severity.TRACE);
                // name test
                if (fatblock is Ingame.IMyRemoteControl)
                {
                    string nameOnly = fatblock.getNameOnly();
                    if (nameOnly == null || !nameOnly.Contains(blockName))
                    {
                        continue;
                    }
                }
                else
                {
                    if (!fatblock.DisplayNameText.looseContains(blockName))
                    {
                        //log("testing failed " + fatblock.DisplayNameText + " does not contain " + blockName, "runActionOnBlock()", Logger.severity.TRACE);
                        continue;
                    }
                    //log("testing successfull " + fatblock.DisplayNameText + " contains " + blockName, "runActionOnBlock()", Logger.severity.TRACE);
                }

                if (!(fatblock is IMyTerminalBlock))
                {
                    //log("not a terminal block: " + fatblock.DisplayNameText, "runActionOnBlock()", Logger.severity.TRACE);
                    continue;
                }
                IMyTerminalBlock terminalBlock = fatblock as IMyTerminalBlock;
                ITerminalAction  actionToRun   = terminalBlock.GetActionWithName(actionString);              // get actionToRun on every iteration so invalid blocks can be ignored
                if (actionToRun != null)
                {
                    log("running action: " + actionString + " on block: " + fatblock.DisplayNameText, "runActionOnBlock()", Logger.severity.DEBUG);
                    actionToRun.Apply(fatblock);
                }
                else
                {
                    log("could not get action: " + actionString + " for: " + fatblock.DisplayNameText, "runActionOnBlock()", Logger.severity.TRACE);
                }
            }
        }