示例#1
0
        public override void Init(MyObjectBuilder_EntityBase objectBuilder)
        {
            Pair = new BlockLimitPair();
            base.Init(objectBuilder);
            this.NeedsUpdate = MyEntityUpdateEnum.EACH_100TH_FRAME;
            IMyFunctionalBlock FBlock = Entity as IMyFunctionalBlock;

            Pair.Block = Entity as IMyFunctionalBlock;
            FBlock.OwnershipChanged += Lock;
            FBlock.IsWorkingChanged += Lock;
            //FBlock.PropertiesChanged += PropertiesChanged;
            FBlock.AppendingCustomInfo += AppInfo;
        }
示例#2
0
 private void UpdatePair(BlockLimitPair Pair, Dictionary <long, List <long> > BlockDict, int Limit)
 {
     if (Pair.Block.IsWorking)
     {
         if (BlockDict.ContainsKey(Pair.Block.OwnerId))
         {
             List <long> Blocks = BlockDict.GetValueOrDefault(Pair.Block.OwnerId);
             if (Blocks != null && !Blocks.Contains(Pair.Block.EntityId))
             {
                 if (Blocks.Count < Limit)
                 {
                     Blocks.Add(Pair.Block.EntityId);
                     Pair.LimitReached = false;
                 }
                 else
                 {
                     Pair.Block.Enabled = false;
                     Pair.LimitReached  = true;
                 }
             }
         }
         else
         {
             List <long> Blocks = new List <long>();
             Blocks.Add(Pair.Block.EntityId);
             BlockDict.Add(Pair.Block.OwnerId, Blocks);
             Pair.LimitReached = false;
         }
     }
     else if (BlockDict.ContainsKey(Pair.Block.OwnerId))
     {
         List <long> Blocks = BlockDict.GetValueOrDefault(Pair.Block.OwnerId);
         Blocks.RemoveAll(x => x == Pair.Block.EntityId);
     }
     Pair.Block.RefreshCustomInfo();
 }