예제 #1
5
 /// <summary>
 /// 更新记录状态
 /// </summary>
 /// <param name="dataRow">记录</param>
 /// <param name="updateType">操作类型</param>
 private void SetRowState(DataRow dataRow, UpdateType updateType)
 {
     if (dataRow.RowState != DataRowState.Unchanged) return;
     if (updateType == UpdateType.Add)
         dataRow.SetAdded();
     if (updateType == UpdateType.Modify)
         dataRow.SetModified();
 }
예제 #2
0
 // constructors
 /// <summary>
 /// Initializes a new instance of the <see cref="UpdateRequest" /> class.
 /// </summary>
 /// <param name="updateType">The type.</param>
 /// <param name="criteria">The criteria.</param>
 /// <param name="update">The update.</param>
 public UpdateRequest(UpdateType updateType, BsonDocument criteria, BsonDocument update)
     : base(WriteRequestType.Update)
 {
     _updateType = updateType;
     _criteria = Ensure.IsNotNull(criteria, "criteria");
     _update = Ensure.IsNotNull(update, "update");
 }
 // constructors
 /// <summary>
 /// Initializes a new instance of the <see cref="UpdateRequest" /> class.
 /// </summary>
 /// <param name="updateType">The update type.</param>
 /// <param name="filter">The filter.</param>
 /// <param name="update">The update.</param>
 public UpdateRequest(UpdateType updateType, BsonDocument filter, BsonDocument update)
     : base(WriteRequestType.Update)
 {
     _updateType = updateType;
     _filter = Ensure.IsNotNull(filter, nameof(filter));
     _update = Ensure.IsNotNull(update, nameof(update));
 }
예제 #4
0
        protected DocumentRequest(UpdateType type, string id)
        {
            if (id == null) throw new ArgumentNullException(nameof(id));

            Type = type;
            Id = id;
        }
예제 #5
0
		/// <summary>
		/// Gets the last received update blocks of the object with the given id and of the given Type
		/// </summary>
		/// <param name="type"></param>
		/// <returns></returns>
		public ICollection<UpdateBlock> GetUpdateBlocks(EntityId id, UpdateType type)
		{
			var blocks = new List<UpdateBlock>();
			foreach (var packet in UpdatePackets)
			{
				packet.GetBlocks(id, type, blocks);
			}
			return blocks;
		}
예제 #6
0
 /// <summary>
 /// 创建原始数据用于更新. 由DataTable转换为DataSet
 /// </summary>
 protected DataSet CreateDataset(DataTable data, UpdateType updateType)
 {
     DataSet ds = new DataSet();
     data.AcceptChanges(); //保存缓存数据
     foreach (DataRow row in data.Rows)
         this.SetRowState(row, updateType); //设置记录状态
     ds.Tables.Add(data.Copy()); //加到新的DataSet
     return ds;
 }
예제 #7
0
 public override void Reset()
 {
     gameObject = null;
     targetObject = null;
     maxSpeed = 10f;
     finishDistance = 1f;
     finishEvent = null;
     updateType = UpdateType.Update;
 }
예제 #8
0
		/// <summary>
		/// This method will import / update a list of videos into the Brightcove Video Library
		/// </summary>
		/// <param name="Videos">
		/// The Videos to import / update
		/// </param>
		/// <returns>
		/// returns a list of the new videos imported
		/// </returns>
		public static UpdateInsertPair<VideoItem> ImportToSitecore(this AccountItem account, List<BCVideo> Videos, UpdateType utype) {

			UpdateInsertPair<VideoItem> uip = new UpdateInsertPair<VideoItem>();

			//set all BCVideos into hashtable for quick access
			Hashtable ht = new Hashtable();
			foreach (VideoItem exVid in account.VideoLib.Videos) {
				if (!ht.ContainsKey(exVid.VideoID.ToString())) {
					//set as string, Item pair
					ht.Add(exVid.VideoID.ToString(), exVid);
				}
			}

			//Loop through the data source and add them
			foreach (BCVideo vid in Videos) {

				try {
					//remove access filter
					using (new Sitecore.SecurityModel.SecurityDisabler()) {

						VideoItem currentItem;

						//if it exists then update it
						if (ht.ContainsKey(vid.id.ToString()) && (utype.Equals(UpdateType.BOTH) || utype.Equals(UpdateType.UPDATE))) {
							currentItem = (VideoItem)ht[vid.id.ToString()];

							//add it to the new items
							uip.UpdatedItems.Add(currentItem);

							using (new EditContext(currentItem.videoItem, true, false)) {
								SetVideoFields(ref currentItem.videoItem, vid);
							}
						}
							//else just add it
						else if (!ht.ContainsKey(vid.id.ToString()) && (utype.Equals(UpdateType.BOTH) || utype.Equals(UpdateType.NEW))) {
							//Create new item
							TemplateItem templateType = account.Database.Templates["Modules/Brightcove/Brightcove Video"];

							currentItem = new VideoItem(account.VideoLib.videoLibraryItem.Add(vid.name.StripInvalidChars(), templateType));

							//add it to the new items
							uip.NewItems.Add(currentItem);

							using (new EditContext(currentItem.videoItem, true, false)) {
								SetVideoFields(ref currentItem.videoItem, vid);
							}
						}
					}
				} catch (System.Exception ex) {
					//HttpContext.Current.Response.Write(vid.name + "<br/>");
					throw new Exception("Failed on video: " + vid.name + ". " + ex.ToString());
				}
			}

			return uip;
		}
예제 #9
0
 public WorkOrderUpdate(int _workOrderId, UpdateType _updateType, int _modifiedBy, DateTime? _compStartTime, DateTime? _compEndTime, String _resultJson = "", decimal? _requestDeserialisation = null, decimal? _resultSerialisation = null)
 {
     this.WorkOrderId = _workOrderId;
     this.WorkOrderUpdateType = _updateType;
     this.ModifiedBy = _modifiedBy;
     this.ResultJson = _resultJson;
     this.ComputationStartTime = _compStartTime;
     this.ComputationEndTime = _compEndTime;
     this.RequestDeserialisationTime = _requestDeserialisation;
     this.ResultSerialisationTime = _resultSerialisation;
 }
예제 #10
0
		public static UpdateInsertPair<PlaylistItem> ImportToSitecore(this AccountItem account, List<BCPlaylist> Playlists, UpdateType utype) {

			UpdateInsertPair<PlaylistItem> uip = new UpdateInsertPair<PlaylistItem>();

			//set all BCVideos into hashtable for quick access
			Hashtable ht = new Hashtable();
			foreach (PlaylistItem exPlay in account.PlaylistLib.Playlists) {
				if (!ht.ContainsKey(exPlay.playlistItem.ToString())) {
					//set as string, Item pair
					ht.Add(exPlay.PlaylistID.ToString(), exPlay);
				}
			}

			//Loop through the data source and add them
			foreach (BCPlaylist play in Playlists) {

				try {
					//remove access filter
					using (new Sitecore.SecurityModel.SecurityDisabler()) {

						PlaylistItem currentItem;

						//if it exists then update it
						if (ht.ContainsKey(play.id.ToString()) && (utype.Equals(UpdateType.BOTH) || utype.Equals(UpdateType.UPDATE))) {
							currentItem = (PlaylistItem)ht[play.id.ToString()];

							//add it to the new items
							uip.UpdatedItems.Add(currentItem);

							using (new EditContext(currentItem.playlistItem, true, false)) {
								SetPlaylistFields(ref currentItem.playlistItem, play);
							}
						}
							//else just add it
						else if (!ht.ContainsKey(play.id.ToString()) && (utype.Equals(UpdateType.BOTH) || utype.Equals(UpdateType.NEW))) {
							//Create new item
							TemplateItem templateType = account.Database.Templates["Modules/Brightcove/Brightcove Playlist"];
							currentItem = new PlaylistItem(account.PlaylistLib.playlistLibraryItem.Add(play.name.StripInvalidChars(), templateType));

							//add it to the new items
							uip.NewItems.Add(currentItem);

							using (new EditContext(currentItem.playlistItem, true, false)) {
								SetPlaylistFields(ref currentItem.playlistItem, play);
							}
						}
					}
				} catch (System.Exception ex) {
					throw new Exception("Failed on playlist: " + play.name + ". " + ex.ToString());
				}
			}

			return uip;
		}
 // constructors
 /// <summary>
 /// Initializes a new instance of the <see cref="UpdateRequest" /> class.
 /// </summary>
 /// <param name="updateType">The update type.</param>
 /// <param name="filter">The filter.</param>
 /// <param name="update">The update.</param>
 public UpdateRequest(UpdateType updateType, BsonDocument filter, BsonDocument update)
     : base(WriteRequestType.Update)
 {
     _updateType = updateType;
     _filter = Ensure.IsNotNull(filter, nameof(filter));
     _update = Ensure.IsNotNull(update, nameof(update));
     if (updateType == UpdateType.Update && _update.ElementCount == 0)
     {
         throw new ArgumentException("Updates must have at least 1 update operator.", nameof(update));
     }
 }
예제 #12
0
        internal void RaiseStatusUpdate(UpdateType type, uint processedItems)
        {
            if (StatusUpdate == null)
                return;

            if(type == UpdateType.Output)
                StatusUpdate(UpdateType.Output, this, processedItems);

            if (type == UpdateType.Input)
                StatusUpdate(UpdateType.Input, this, processedItems);
        }
예제 #13
0
파일: Update.cs 프로젝트: meetdpanda/Gala
        public Update(string theTitle, string theAuthor, UIImage theAvatar, UpdateType theType, string theText)
        {
            title = theTitle;
            author = theAuthor;
            avatar = theAvatar;
            updateText = theText;

            string picture = string.Format ("{0}.png", theType == UpdateType.FacebookUpdate ? "fb" : "tweet");

            updateTypeImage = UIImage.FromFile (picture);
        }
예제 #14
0
파일: Corps.cs 프로젝트: karliky/wowwow
        public override void PrepareUpdateData( byte []data, ref int offset, UpdateType type, bool forOther )
        {
            int o = offset;
            /*			int offset = 4;
            Converter.ToBytes( 1, tempBuff, ref offset );
            Converter.ToBytes( (byte)0, tempBuff, ref offset );	*/
            tempBuff[ offset++ ] = 2;
            Converter.ToBytes( Guid, tempBuff, ref offset );
            ResetBitmap();
            Converter.ToBytes( (byte)7, tempBuff, ref offset );
            Converter.ToBytes( (int)0, tempBuff, ref offset );
            Converter.ToBytes( (int)0, tempBuff, ref offset );//	Movement flags
            Converter.ToBytes( X, tempBuff, ref offset );
            Converter.ToBytes( Y, tempBuff, ref offset );
            Converter.ToBytes( Z, tempBuff, ref offset );
            Converter.ToBytes( Orientation, tempBuff, ref offset );
            Converter.ToBytes( 0, tempBuff, ref offset );
            Converter.ToBytes( 2.5f, tempBuff, ref offset );
            Converter.ToBytes( 7f, tempBuff, ref offset );
            Converter.ToBytes( 2.5f, tempBuff, ref offset );
            Converter.ToBytes( (float)4.5f, tempBuff, ref offset );//	vitesse encore ?
            Converter.ToBytes( (float)4.7222f, tempBuff, ref offset );//	vitesse encore ?
            Converter.ToBytes( (float)Math.PI, tempBuff, ref offset );//	turn rate
            Converter.ToBytes( (uint)0, tempBuff, ref offset );
            Converter.ToBytes( (uint)1, tempBuff, ref offset );

            Converter.ToBytes( (uint)0, tempBuff, ref offset );
            Converter.ToBytes( (uint)0, tempBuff, ref offset );
            Converter.ToBytes( (uint)0, tempBuff, ref offset );

            setUpdateValue( Const.OBJECT_FIELD_GUID, Guid );
            setUpdateValue( Const.OBJECT_FIELD_TYPE, 0x81 );
            setUpdateValue( Const.OBJECT_FIELD_SCALE_X, (float)1.0f );
            setUpdateValue( 6, owner );
            setUpdateValue( 8, Orientation );
            setUpdateValue( 9, X );
            setUpdateValue( 10, Y );
            setUpdateValue( 11, Z );
            int last = 0;
            setUpdateValue( last = (int)UpdateFields.CORPSE_FIELD_DISPLAY_ID, Model );
            setUpdateValue( (int)UpdateFields.CORPSE_FIELD_BYTES_1, bytes2 );
            setUpdateValue( (int)UpdateFields.CORPSE_FIELD_BYTES_2, bytes3 );
            setUpdateValue( last = (int)UpdateFields.CORPSE_FIELD_FLAGS, 4 );

            FlushUpdateData( tempBuff, ref offset, 2 + ( last / 32 ) );
            /*Console.WriteLine("teleport");
            string s = "";
            for(int t = o;t < offset;t++ )
                s += tempBuff[ t ].ToString( "X2" ) + " ";
            Debug.WriteLine(s);
            */
            //World.ToNearestPlayer( this, tempBuff, offset );
        }
 public static IElementNameValidator ForUpdateType(UpdateType updateType)
 {
     switch (updateType)
     {
         case UpdateType.Replacement:
             return CollectionElementNameValidator.Instance;
         case UpdateType.Update:
             return UpdateElementNameValidator.Instance;
         default:
             return new UpdateOrReplacementElementNameValidator();
     }
 }
예제 #16
0
        public UpdateBlock(ParsedUpdatePacket parser, int index)
        {
            this.index = index;
            packet = parser;
            //Offset = parser.index;

            Type = (UpdateType)ReadByte();

            if (!Enum.IsDefined(typeof(UpdateType), (byte)Type))
            {
                throw new Exception("Invalid UpdateType '" + Type + "' in Block " + this);
            }

            // Console.WriteLine("Reading {0}-Block...", Type);

            if (Type == UpdateType.OutOfRange ||
                Type == UpdateType.Near)
            {
                var count = ReadUInt();
                EntityIds = new EntityId[count];
                for (var i = 0; i < count; i++)
                {
                    EntityIds[i] = ReadPackedEntityId();
                }
            }
            else
            {
                EntityId = ReadPackedEntityId();

                if (Type == UpdateType.Create ||
                    Type == UpdateType.CreateSelf)
                {
                    ObjectType = (ObjectTypeId)ReadByte();
                }

                if (Type == UpdateType.Create ||
                    Type == UpdateType.CreateSelf ||
                    Type == UpdateType.Movement)
                {
                    m_movement = ReadMovementBlock();
                }

                if (Type != UpdateType.Movement)
                {
                    Values = ReadValues();
                }
            }

            if (Type != UpdateType.Create && Type != UpdateType.CreateSelf)
            {
                ObjectType = EntityId.ObjectType;
            }
        }
        public UpdateTypeFilter(FilterBehaviour behaviour, IMicroblog blog, UpdateType updateType)
        {
            IsIncluded = behaviour;
            Microblog = blog;
            UpdateType = updateType;

            MicroblogAccountName = blog.Credentials.AccountName;
            MicroblogName = blog.Protocol;
            UpdateTypeName = UpdateType.GetType().AssemblyQualifiedName;

            if (UpdateType.SaveType)
                UpdateTypeParameter = UpdateType.Type;
        }
예제 #18
0
 public ReturnValue Update(UpdateType What)
 {
     ReturnValue returnValue = ReturnValue.Success;
     if (What == UpdateType.All || What == UpdateType.FileSystem)
     {
         //update file system
         returnValue = updateFileSystem(DeployFolder, Path.GetFullPath("\\" + IpAddress), Credential);
     }
     if (What == UpdateType.All || What == UpdateType.Registry)
     {
         //todo: update registry
     }
     return(returnValue);
 }
예제 #19
0
 public LevenbergMarquardt(Function func, JFunc Jfunc, NVector p_min, NVector p_max, NVector dp, double[] eps, UpdateType updateType)
 {
     this.func = func;
     this.Jfunc = Jfunc;
     n = p_min.N;
     this.p_min = p_min;
     if (p_max.N != n) throw new Exception("LevenbergMarquardt: size mismatch p_max");
     this.p_max = p_max;
     if (Jfunc == null)
     {
         if (dp.N != n) throw new Exception("LevenbergMarquardt: size mismatch dp");
         this.dp = dp;
     }
     MaxIter = 50 * n;
     this.eps = eps;
     this.updateType = updateType;
 }
예제 #20
0
        public async Task<UpdateType> CheckUpdate(UpdateType locked = UpdateType.None)
        {
            var releases = await _releaseClient.GetAll(RepositoryOwner, RepostoryName);

            SemVersion lockedVersion;
            switch (locked)
            {
                case UpdateType.Major:
                    lockedVersion = new SemVersion(CurrentVersion.Major + 1);
                    LatestRelease = releases.FirstOrDefault(
                        release => !release.Prerelease &&
                        Helper.StripInitialV(release.TagName) > CurrentVersion &&
                        Helper.StripInitialV(release.TagName) < lockedVersion
                    );
                    break;
                case UpdateType.Minor:
                    lockedVersion = new SemVersion(CurrentVersion.Major, CurrentVersion.Minor + 1);
                    LatestRelease = releases.FirstOrDefault(
                        release => !release.Prerelease &&
                        Helper.StripInitialV(release.TagName) > CurrentVersion &&
                        Helper.StripInitialV(release.TagName) < lockedVersion
                    );
                    break;
                default:
                    LatestRelease = releases.FirstOrDefault(
                        release => !release.Prerelease &&
                        Helper.StripInitialV(release.TagName) > CurrentVersion
                    );
                    break;
            }

            if (LatestRelease == null) return UpdateType.None;

            var tagName = LatestRelease.TagName;
            var latestVersion = Helper.StripInitialV(tagName);

            if (latestVersion.Major != CurrentVersion.Major)
                return UpdateType.Major;
            if (latestVersion.Minor != CurrentVersion.Minor)
                return UpdateType.Minor;
            if (latestVersion.Patch != CurrentVersion.Patch)
                return UpdateType.Patch;

            return UpdateType.None;
        }
예제 #21
0
파일: GameEngine.cs 프로젝트: coreafive/XLE
        public void Update(FrameTime ft, UpdateType updateType)
        {
                // There are 3 update types defined by Sony.
                //  Here they are:
            // Editing: in this mode physics and AI 
            // should not be updated.
            // While particle system and other editing related effects
            // should be updated
    
            // GamePlay: update all the subsystems.
            // Some editing related effects shoult not updated.

            // Paused: none of the time based effects are simulated.
            // Delta time should be zero.

            if (updateType != UpdateType.Paused)
                s_underlyingScene.IncrementTime(ft.ElapsedTime);
        }
예제 #22
0
        /// <summary>
        /// 更新数据
        /// </summary>
        /// <param name="updateType">操作类型</param>
        /// <returns></returns>
        public bool Update(DataTable sSavatb, UpdateType updateType)
        {
            sSavatb.AcceptChanges();
            for (int i = 0; i < sSavatb.Rows.Count; i++)
                if (updateType == UpdateType.Modify)
                    sSavatb.Rows[i].SetModified();

            DataSet ds = new DataSet();
            ds.Tables.Add(sSavatb.Copy());
            bool ret = _DataDictBridge.Update(ds); //调用DAL层更新数据
            //bool ret = base.Update(updateType);
            if (ret)
            {
                //_SummaryTable.AcceptChanges();
                _IsAdd = false;
            }

            return ret;
        }
예제 #23
0
        /// <summary>Clears and resets this TweenParams instance using default values,
        /// so it can be reused without instantiating another one</summary>
        public TweenParams Clear()
        {
            id = target = null;
            updateType = DOTween.defaultUpdateType;
            isIndependentUpdate = DOTween.defaultTimeScaleIndependent;
            onStart = onPlay = onRewind = onUpdate = onStepComplete = onComplete = onKill = null;
            onWaypointChange = null;
            isRecyclable = DOTween.defaultRecyclable;
            isSpeedBased = false;
            autoKill = DOTween.defaultAutoKill;
            loops = 1;
            loopType = DOTween.defaultLoopType;
            delay = 0;
            isRelative = false;
            easeType = Ease.Unset;
            customEase = null;
            easeOvershootOrAmplitude = DOTween.defaultEaseOvershootOrAmplitude;
            easePeriod = DOTween.defaultEasePeriod;

            return this;
        }
예제 #24
0
 public SimpleUpdateForm(UpdateType type, UpdateCheckerSettings settings)
 {
     InitializeComponent();
     Icon = Gui.Icon;
     m_Type = type;
     m_Settings = settings;
     extensionVersionLinkLabel.LinkClicked +=ExtensionVersionLinkLabelOnLinkClicked;
     playerVersionLinkLabel.LinkClicked +=PlayerVersionLinkLabelOnLinkClicked;
     switch (m_Type)
     {
         case UpdateType.Both:
             EnableExtensionInfo();
             EnablePlayerInfo();
             break;
         case UpdateType.Extensions:
             EnableExtensionInfo();
             break;
         case UpdateType.Player:
             EnablePlayerInfo();
             break;
     }
 }
예제 #25
0
        /// <summary>
        /// 更新数据
        /// </summary>
        /// <param name="updateType">操作类型</param>
        /// <returns></returns>
        public bool Update(DataTable sSavatb, UpdateType updateType)
        {
            sSavatb.Rows[0][tb_sys_DbLink.FCreateDate] = DateTime.Now;

              sSavatb.AcceptChanges();

              if (updateType == UpdateType.Add)
                  sSavatb.Rows[0].SetAdded();
              else
                  sSavatb.Rows[0].SetModified();

              DataSet ds = new DataSet();
              ds.Tables.Add(sSavatb.Copy());
              bool ret = _DataDictBridge.Update(ds); //调用DAL层更新数据
              //bool ret = base.Update(updateType);
              if (ret)
              {
                  //_SummaryTable.AcceptChanges();
                  _IsAdd = false;
              }

              return ret;
        }
예제 #26
0
		public virtual void Add( UpdateType type, Mobile user )
		{
			switch( type )
			{
				case UpdateType.Buddy:
					{
						Remove( UpdateType.Ignore, user );

						if( !_buddyList.Contains( user ) )
							_buddyList.Add( user );

						break;
					}
				case UpdateType.Ignore:
					{
						Remove( UpdateType.Buddy, user );

						if( !_ignoreList.Contains( user ) )
							_ignoreList.Add( user );

						break;
					}
			}
		}
예제 #27
0
        /// <summary>
        /// 更新数据
        /// </summary>
        /// <param name="updateType">操作类型</param>
        /// <returns></returns>
        public override bool Update(UpdateType updateType)
        {
            _SummaryTable.Rows[0][tb_sys_CompanyInfo.FCreationDate] = DateTime.Now;
            _SummaryTable.Rows[0][tb_sys_CompanyInfo.FLastUpdatedBy] = Loginer.CurrentUser.Account;

            _SummaryTable.AcceptChanges();

            if (_IsAdd)
                _SummaryTable.Rows[0].SetAdded();
            else
                _SummaryTable.Rows[0].SetModified();

            DataSet ds = new DataSet();
            ds.Tables.Add(_SummaryTable.Copy());
            bool ret = _DataDictBridge.Update(ds); //调用DAL层更新数据
            //bool ret = base.Update(updateType);
            if (ret)
            {
                _SummaryTable.AcceptChanges();
                _IsAdd = false;
            }

            return ret;
        }
예제 #28
0
 public NotificationSummary(User user, NotificationSystem notificationSystem, ITotals publisher, UpdateType updateType)
 {
     User = user;
     NotificationSystem = notificationSystem;
     Publisher          = publisher;
     UpdateType         = updateType;
 }
예제 #29
0
        public void Main(string argument, UpdateType updateSource)
        {
            Echo($"Last run: {DateTime.Now}");

            /*
             * private IMyTextPanel CockpitDriveChargeStatusTextPanel = null;
             * private IMyTextPanel textPanelJumpDriveDetailedInfo = null;
             * private IMyTextPanel textPanelIngotDisplay = null;
             * private IMyTextPanel textPanelOreDisplay = null;
             */
            if (CockpitDriveChargeStatusTextPanel != null)
            {
                Echo(CockpitDriveChargeStatusTextPanel.CustomName);
            }
            if (textPanelJumpDriveDetailedInfo != null)
            {
                Echo(textPanelJumpDriveDetailedInfo.CustomName);
            }
            if (textPanelIngotDisplay != null)
            {
                Echo(textPanelIngotDisplay.CustomName);
            }
            if (textPanelOreDisplay != null)
            {
                Echo(textPanelOreDisplay.CustomName);
            }
            if (textPanelHydrogenDisplay != null)
            {
                Echo(textPanelHydrogenDisplay.CustomName);
            }

            if (CockpitDriveChargeStatusTextPanel != null)
            {
                List <IMyJumpDrive> jumpDrives = new List <IMyJumpDrive>();
                GridTerminalSystem.GetBlocksOfType(jumpDrives, x => x.IsSameConstructAs(Me));

                float[] driveCharge = new float[2];

                foreach (IMyJumpDrive drive in jumpDrives)
                {
                    driveCharge[0] += drive.MaxStoredPower;
                    driveCharge[1] += drive.CurrentStoredPower;
                }

                int barLength = 91;

                string outText = $"Drive Charge: {((driveCharge[1] / driveCharge[0]) * 100):000.00}%\n" +
                                 $"[";

                float onePercent = driveCharge[0] / barLength;

                for (float i = 0; i < barLength; i++)
                {
                    if (onePercent * i < driveCharge[1])
                    {
                        outText += "|";
                    }
                    else
                    {
                        outText += "'";
                    }
                }

                outText += "]";

                CockpitDriveChargeStatusTextPanel.FontColor =
                    driveCharge[0] == driveCharge[1] ? Color.Green : Color.Orange;
                CockpitDriveChargeStatusTextPanel.ContentType = ContentType.TEXT_AND_IMAGE;
                CockpitDriveChargeStatusTextPanel.WriteText(outText);

                if (textPanelJumpDriveDetailedInfo != null)
                {
                    textPanelJumpDriveDetailedInfo.WriteText(jumpDrives[0].DetailedInfo);
                }
                else
                {
                    Echo("!textPanelJumpDriveDetailedInfo");
                }
            }

            if (textPanelIngotDisplay != null)
            {
                List <IMyCargoContainer> cargoContainers = new List <IMyCargoContainer>();
                GridTerminalSystem.GetBlocksOfType(cargoContainers, x => x.IsSameConstructAs(Me));

                List <ItemInfo> itemInfos = new List <ItemInfo>();
                foreach (IMyCargoContainer container in cargoContainers)
                {
                    IMyInventory           inventory = container.GetInventory();
                    List <MyInventoryItem> items     = new List <MyInventoryItem>();
                    inventory.GetItems(items, x => x.Type.TypeId == "MyObjectBuilder_Ingot");

                    foreach (MyInventoryItem item in items)
                    {
                        if (itemInfos.FindAll(x => x.SubtypeId == item.Type.SubtypeId).Count == 0)
                        {
                            itemInfos.Add(new ItemInfo(item));
                        }
                        else
                        {
                            foreach (ItemInfo info in itemInfos)
                            {
                                if (info.SubtypeId == item.Type.SubtypeId)
                                {
                                    info.Amount += info.Amount;
                                }
                            }
                        }
                    }
                }

                string output = "   Ingots\n";
                foreach (ItemInfo info in itemInfos)
                {
                    output += $"{info.SubtypeId} : {info.Amount.ToIntSafe()}\n";
                    switch (info.SubtypeId)
                    {
                    case "Platinum":
                        output += $"{WriteProgressBar('=', ' ', info.Amount, 24, Ingot.MaxPlatinum)}\n";
                        break;

                    case "Nickel":
                        output += $"{WriteProgressBar('=', ' ', info.Amount, 24, Ingot.MaxNickel)}\n";
                        break;

                    case "Silicon":
                        output += $"{WriteProgressBar('=', ' ', info.Amount, 24, Ingot.MaxSilicon)}\n";
                        break;

                    case "Cobalt":
                        output += $"{WriteProgressBar('=', ' ', info.Amount, 24, Ingot.MaxCobalt)}\n";
                        break;

                    case "Iron":
                        output += $"{WriteProgressBar('=', ' ', info.Amount, 24, Ingot.MaxIron)}\n";
                        break;

                    case "Stone":
                        output += $"{WriteProgressBar('=', ' ', info.Amount, 24, Ingot.MaxStone)}\n";
                        break;

                    case "Silver":
                        output += $"{WriteProgressBar('=', ' ', info.Amount, 24, Ingot.MaxSilver)}\n";
                        break;

                    case "Gold":
                        output += $"{WriteProgressBar('=', ' ', info.Amount, 24, Ingot.MaxGold)}\n";
                        break;

                    default:
                        output += $"{WriteProgressBar('=', ' ', info.Amount, 24, 1000)}\n";
                        break;
                    }
                }

                textPanelIngotDisplay.WriteText(output);
            }

            if (textPanelOreDisplay != null)
            {
                Echo("Ores");

                List <IMyCargoContainer> cargoContainers = new List <IMyCargoContainer>();
                GridTerminalSystem.GetBlocksOfType(cargoContainers, x => x.IsSameConstructAs(Me));

                List <ItemInfo> itemInfos = new List <ItemInfo>();
                foreach (IMyCargoContainer container in cargoContainers)
                {
                    IMyInventory           inventory = container.GetInventory();
                    List <MyInventoryItem> items     = new List <MyInventoryItem>();
                    inventory.GetItems(items, x => x.Type.TypeId == "MyObjectBuilder_Ore");

                    foreach (MyInventoryItem item in items)
                    {
                        if (itemInfos.FindAll(x => x.SubtypeId == item.Type.SubtypeId).Count == 0)
                        {
                            itemInfos.Add(new ItemInfo(item));
                        }
                        else
                        {
                            foreach (ItemInfo info in itemInfos)
                            {
                                if (info.SubtypeId == item.Type.SubtypeId)
                                {
                                    info.Amount += info.Amount;
                                }
                            }
                        }
                    }
                }

                string output = "   Ores\n";
                foreach (ItemInfo info in itemInfos)
                {
                    output += $"{info.SubtypeId} : {info.Amount.ToIntSafe()}\n";
                    switch (info.SubtypeId)
                    {
                    case "Platinum":
                        output += $"{WriteProgressBar('=', ' ', info.Amount, 24, Ore.MaxPlatinum)}\n";
                        break;

                    case "Nickel":
                        output += $"{WriteProgressBar('=', ' ', info.Amount, 24, Ore.MaxNickel)}\n";
                        break;

                    case "Silicon":
                        output += $"{WriteProgressBar('=', ' ', info.Amount, 24, Ore.MaxSilicon)}\n";
                        break;

                    case "Cobalt":
                        output += $"{WriteProgressBar('=', ' ', info.Amount, 24, Ore.MaxCobalt)}\n";
                        break;

                    case "Iron":
                        output += $"{WriteProgressBar('=', ' ', info.Amount, 24, Ore.MaxIron)}\n";
                        break;

                    case "Stone":
                        output += $"{WriteProgressBar('=', ' ', info.Amount, 24, Ore.MaxStone)}\n";
                        break;

                    case "Silver":
                        output += $"{WriteProgressBar('=', ' ', info.Amount, 24, Ore.MaxSilver)}\n";
                        break;

                    case "Gold":
                        output += $"{WriteProgressBar('=', ' ', info.Amount, 24, Ore.MaxGold)}\n";
                        break;

                    default:
                        output += $"{WriteProgressBar('=', ' ', info.Amount, 24, 1000)}\n";
                        break;
                    }
                }

                textPanelOreDisplay.WriteText(output);
            }

            if (textPanelHydrogenDisplay != null)
            {
                List <IMyGasTank> gasTanks = new List <IMyGasTank>();
                GridTerminalSystem.GetBlocksOfType(gasTanks, x => x.CustomName.Contains("Hydrogen Tank"));

                double filledRatio = 0;

                foreach (IMyGasTank tank in gasTanks)
                {
                    filledRatio += tank.FilledRatio;
                }

                textPanelHydrogenDisplay.WriteText(
                    $"Hydrogen:\n{WriteProgressBar('|', '\'', (int)(filledRatio * 100), 92, 100 * gasTanks.Count)}");
            }

            //IMyTextPanel powerUse = (IMyTextPanel) GridTerminalSystem.GetBlockWithName("Screen_Diagnostic_444_hv");

            //if (powerUse != null)
            //{
            //    List<IMyTerminalBlock> blocks = new List<IMyTerminalBlock>();
            //    GridTerminalSystem.GetBlocksOfType(blocks);

            //    string output = "";

            //    foreach (IMyTerminalBlock block in blocks)
            //    {
            //        if (block.IsFunctional)
            //        {
            //            block.
            //        }
            //    }
            //}
        }
예제 #30
0
 public void ModulePreMain(string argument, UpdateType updateSource)
 {
     Echo("Test Rig for Shared modes");
     Echo("UpdateSource=" + updateSource.ToString());
 }
예제 #31
0
 bool Check(UpdateType t)
 {
     return((UpdateType & t) == t);
 }
예제 #32
0
 /// <summary>
 /// 当改变按钮状态时调用此方法
 /// </summary>
 /// <param name="currentState">当前的状态</param>
 protected override void ButtonStateChanged(UpdateType currentState)
 {
     base.ButtonStateChanged(currentState);
 }
예제 #33
0
 //终止上传
 private void toolStripButton4_Click(object sender, EventArgs e)
 {
     controller.StopUpdate();
     this.UT = UpdateType.待上传;
     this.timer1.Stop();
 }
예제 #34
0
        public void Main(string argument, UpdateType updateSource)
        {
            float generating = 0.0f;

            _solarPanels.ForEach((IMySolarPanel solarPanel) => { generating += solarPanel.MaxOutput; });
            generating *= 1000.0f;
            generating /= _solarPanels.Count;


            if (wait_for_rotorX)
            {
                float deg_5_in_rad = (float)(5.0 * (Math.PI / 180.0));
                if (_rotorX.Angle >= -deg_5_in_rad || _rotorX.Angle <= deg_5_in_rad)
                {
                    wait_for_rotorX           = false;
                    _rotorX.TargetVelocityRPM = VELOCITY;
                }
            }
            else
            {
                var rotor = _dirX ? _rotorX : _rotorY;
                ++_rotator.counter;

                if (generating <= _lastOutput)
                {
                    if (_rotator.prev_greater)
                    {
                        _rotator.counter = 0;
                    }
                    _rotator.prev_greater = false;
                }
                else
                {
                    //if (!_rotator.prev_greater)
                    //{
                    _rotator.counter = 0;
                    //}
                    _rotator.prev_greater = true;
                }


                if (rotor.Angle >= rotor.UpperLimitRad)
                {
                    rotor.TargetVelocityRPM = -2 * VELOCITY;
                    wait_for_rotorX         = true;
                }
                else if (rotor.Angle <= rotor.LowerLimitRad)
                {
                    rotor.TargetVelocityRPM = 2 * VELOCITY;
                    wait_for_rotorX         = true;
                }
                else if (_rotator.counter == 10)
                {
                    _rotator.counter = 0;
                    _dirX            = !_dirX;

                    rotor.TargetVelocityRPM = -rotor.TargetVelocityRPM;
                }
            }

            /*if (generating < _lastOutput)
             * {
             ++_Xcounter;
             *  _Ycounter = 0;
             *  rotor.TargetVelocityRPM = -rotor.TargetVelocityRPM;
             * }
             * else
             * {
             *  _Xcounter = 0;
             ++_Ycounter;
             * }
             *
             * if (_Xcounter == 10 || _Ycounter == 10)
             * {
             *  _Xcounter = 0;
             *  _Ycounter = 0;
             *  _dirX = !_dirX;
             *  if (_dirX)
             *  {
             *      _rotorX.RotorLock = false;
             *      _rotorY.RotorLock = true;
             *  }
             *  else
             *  {
             *      _rotorX.RotorLock = true;
             *      _rotorY.RotorLock = false;
             *  }
             * }*/

            _prev[_prevIndex] = generating;
            _prevIndex        = (_prevIndex + 1) % _prev.Length;

            _PanelTextSurface.WriteText(String.Format(
                                            "Average: {0}\nLast: {1}\nOutput: {2}\nRotorX: {3}\nRotorY: {4}\nWaitForRotorX: {5}\nRotorX Max: {6}\nCounter: {7}",
                                            _prev.Sum() / _prev.Length,
                                            _lastOutput,
                                            generating,
                                            _rotorX.Angle,
                                            _rotorY.Angle,
                                            wait_for_rotorX,
                                            _rotorX.UpperLimitRad,
                                            _rotator.counter
                                            ));

            _lastOutput = generating;
        }
예제 #35
0
        public void Main(string argument, UpdateType updateSource)
        {
            if (!string.IsNullOrWhiteSpace(argument))
            {
                if ("start".Equals(argument, StringComparison.InvariantCultureIgnoreCase))
                {
                    Runtime.UpdateFrequency = UpdateFrequency.Update10;
                }
                else
                {
                    Runtime.UpdateFrequency = UpdateFrequency.None;
                    foreach (var ejector in minerEjectors)
                    {
                        ejector.ThrowOut = false;
                    }
                    return;
                }
            }

            Echo("Running.");

            var ejectors = minerEjectors.GetEnumerator();

            if (!ejectors.MoveNext())
            {
                return;
            }
            ejectors.Current.ThrowOut = false;
            var currentEjector = ejectors.Current.GetInventory();

            foreach (var inventory in minerInventories)
            {
                items.Clear();
                inventory.GetItems(items, i => i.Type.TypeId == OreType && EjectingOres.ContainsKey(i.Type.SubtypeId));
                foreach (var item in items)
                {
                    var limit         = (float)EjectingOres[item.Type.SubtypeId];
                    var amountToEject = ((float)item.Amount - limit);
                    while (amountToEject > 0)
                    {
                        while (currentEjector.IsFull)
                        {
                            ejectors.Current.ThrowOut = true;
                            if (!ejectors.MoveNext())
                            {
                                return;
                            }
                            currentEjector = ejectors.Current.GetInventory();
                        }

                        var massBeforeTransfer = currentEjector.CurrentMass;
                        if (currentEjector.TransferItemFrom(inventory, item, (MyFixedPoint)amountToEject))
                        {
                            amountToEject -= (float)(currentEjector.CurrentMass - massBeforeTransfer);
                        }

                        ejectors.Current.ThrowOut = true;
                        if (!ejectors.MoveNext())
                        {
                            return;
                        }
                        currentEjector = ejectors.Current.GetInventory();
                    }
                }
            }

            while (ejectors.MoveNext())
            {
                ejectors.Current.ThrowOut = false;
            }
        }
예제 #36
0
        public void Main(string argument, UpdateType updateSource)
        {
            var quantities = new Dictionary <MyItemType, MyFixedPoint>();

            // Init quantities from the content of the coffer
            IMyInventory inventory = cargo.GetInventory();

            foreach (Target target in targets)
            {
                quantities.Add(target.target, inventory.GetItemAmount(target.target));
            }

            var usage = new Dictionary <IMyProductionBlock, long>();

            foreach (IMyProductionBlock factory in factories)
            {
                List <MyProductionItem> queue = new List <MyProductionItem>();
                factory.GetQueue(queue);
                usage.Add(factory, queue.Count());
                foreach (MyProductionItem prod in queue)
                {
                    foreach (Target target in targets)
                    {
                        if (target.recipe != prod.BlueprintId)
                        {
                            continue;
                        }
                        quantities[target.target] += prod.Amount;
                    }
                }
            }

            int actualFactory = 0;

            while (usage[factories[actualFactory]] > 3)
            {
                actualFactory++;
                // No free factory
                if (actualFactory >= factories.Count())
                {
                    goto Displays;
                }
            }
            while (targets[actualTarget].amount - quantities[targets[actualTarget].target] <= targets[actualTarget].batch())
            {
                actualTarget++;
                // Nothing to produce
                if (actualTarget >= targets.Count())
                {
                    actualTarget = 0;
                    goto Displays;
                }
            }
            // Iterate over targets to produce, one queue item by one queue item,
            // and assign them to factories
            while (true)
            {
                factories[actualFactory].AddQueueItem(targets[actualTarget].recipe, targets[actualTarget].batch());
                usage[factories[actualFactory]]++;
                quantities[targets[actualTarget].target] += targets[actualTarget].batch();

                // Find next target
                int nextTarget = (actualTarget + 1) % targets.Count();
                while (targets[nextTarget].amount - quantities[targets[nextTarget].target] <= targets[nextTarget].batch())
                {
                    nextTarget++;
                    nextTarget %= targets.Count();
                    // No target left
                    if (nextTarget == actualTarget)
                    {
                        goto Displays;
                    }
                }
                actualTarget = nextTarget;

                // Find next factory
                int nextFactory = (actualFactory + 1) % factories.Count();
                while (usage[factories[nextFactory]] > 3)
                {
                    nextFactory++;
                    nextFactory %= factories.Count();
                    // No free factory left
                    if (nextFactory == actualFactory)
                    {
                        goto Displays;
                    }
                }
                actualFactory = nextFactory;
            }

            // Update displays
Displays:
            StringBuilder sb_good = new StringBuilder("", 100);
            StringBuilder sb_ok  = new StringBuilder("", 100);
            StringBuilder sb_bad = new StringBuilder("", 100);

            foreach (Target target in targets)
            {
                long bs       = toLong(inventory.GetItemAmount(target.target));
                long staged   = toLong(quantities[target.target]) - bs;
                long expected = toLong(target.amount);
                long batch    = toLong(target.batch());

                if (expected == 0 && bs == 0)
                {
                    continue;
                }

                if (bs + staged + batch > expected && staged == 0)
                {
                    sb_good.AppendFormat("{0} {1}/{2}/{3}\n", target.target.SubtypeId, bs, staged, expected);
                }
                else if (bs + staged >= expected / 3)
                {
                    sb_ok.AppendFormat("{0} {1}/{2}/{3}\n", target.target.SubtypeId, bs, staged, expected);
                }
                else
                {
                    sb_bad.AppendFormat("{0} {1}/{2}/{3}\n", target.target.SubtypeId, bs, staged, expected);
                }
            }

            panel_good.WriteText(sb_good, false);
            panel_ok.WriteText(sb_ok, false);
            panel_bad.WriteText(sb_bad, false);
        }
예제 #37
0
 public void Main(string argument, UpdateType updateSource)
 {
 }
예제 #38
0
        public void Main(string argument, UpdateType updateSource)
        {
            var block = GridTerminalSystem.GetBlockWithName(argument);

            Echo(block.ToString());
        }
예제 #39
0
        public override void Reset()
        {
            base.Reset();

            gameObject = null;

            punch = new FsmVector2 {
                UseVariable = false
            };
            duration = new FsmFloat {
                UseVariable = false
            };
            setSpeedBased = new FsmBool {
                UseVariable = false, Value = false
            };
            vibrato = new FsmInt {
                UseVariable = false, Value = 10
            };
            elasticity = new FsmFloat {
                UseVariable = false, Value = 1
            };
            snapping = new FsmBool {
                UseVariable = false, Value = false
            };

            startEvent        = null;
            finishEvent       = null;
            finishImmediately = new FsmBool {
                UseVariable = false, Value = false
            };

            stringAsId = new FsmString {
                UseVariable = false
            };
            tagAsId = new FsmString {
                UseVariable = false
            };

            startDelay = new FsmFloat {
                Value = 0
            };

            selectedEase = DOTweenActionsEnums.SelectedEase.EaseType;
            easeType     = Ease.Linear;

            loops = new FsmInt {
                Value = 0
            };
            loopType = LoopType.Restart;

            autoKillOnCompletion = new FsmBool {
                Value = true
            };
            recyclable = new FsmBool {
                Value = false
            };

            updateType          = UpdateType.Normal;
            isIndependentUpdate = new FsmBool {
                Value = false
            };

            debugThis = new FsmBool {
                Value = false
            };
        }
 /// <summary>
 /// Implementation of UpdateOp.Update
 /// </summary>
 /// <param name="type">Update type</param>
 /// <param name="oclass">Object class</param>
 /// <param name="attributes">Object attributes</param>
 /// <param name="options">Operation options</param>
 /// <returns><see cref="Uid"/> of the updated object</returns>
 public override Uid Update(
     UpdateType type,
     ObjectClass oclass,
     ICollection<ConnectorAttribute> attributes,
     OperationOptions options)
 {
     // TODO: Implement Update
     return base.Update(type, oclass, attributes, options);
 }
예제 #41
0
        public void SendUpdateMessage(string compType, Guid customId, GhLivePoint position, UpdateType type)
        {
            GhLiveMessage messageObj = new GhLiveMessage();

            messageObj.Type       = compType;
            messageObj.CustomId   = customId;
            messageObj.Point      = position;
            messageObj.UpdateType = type;
            messageObj.Sender     = _id;

            string stuff = Newtonsoft.Json.JsonConvert.SerializeObject(messageObj);

            socket.Emit("update", stuff);
        }
예제 #42
0
 public static extern Result DeleteFile(
     string relativePath,
     UpdateType updateType,
     ref UpdateFailureCause failureCause);
예제 #43
0
 public void Main(string argument, UpdateType updateSource)
 {
     FindTargetsList();
 }
예제 #44
0
    private static SetActionUIMessage _Send(GameObject recipient,
                                            IActionGUI action,
                                            UpdateType ProposedAction,
                                            bool show      = false,
                                            float cooldown = 0,
                                            int location   = 0)
    {
        //SO action singleton ID
        if (action is UIActionScriptableObject actionFromSO)
        {
            SetActionUIMessage msg = new SetActionUIMessage
            {
                actionListID   = UIActionSOSingleton.ActionsTOID[actionFromSO],
                showAlert      = show,
                cooldown       = cooldown,
                SpriteLocation = location,
                ProposedAction = ProposedAction,
                ComponentType  = actionFromSO.GetType()
            };
            msg.SendTo(recipient);
            return(msg);
        }
        //SpellList singleton index
        else if (action is Spell spellAction)
        {
            SetActionUIMessage msg = new SetActionUIMessage
            {
                spellListIndex = spellAction.SpellData.Index,
                showAlert      = show,
                cooldown       = cooldown,
                SpriteLocation = location,
                ProposedAction = ProposedAction,
                ComponentType  = spellAction.GetType()
            };
            msg.SendTo(recipient);
            return(msg);
        }
        else
        {
            //Action pre-placed on a networked object
            var  netObject         = (action as Component).GetComponent <NetworkIdentity>();
            var  type              = action.GetType();
            var  foundActions      = netObject.GetComponentsInChildren(type);
            var  componentLocation = 0;
            bool isFound           = false;
            foreach (var foundAction in foundActions)
            {
                if ((foundAction as IActionGUI) == action)
                {
                    isFound = true;
                    break;
                }

                componentLocation++;
            }

            if (isFound)
            {
                SetActionUIMessage msg = new SetActionUIMessage
                {
                    NetObject         = netObject.netId,
                    ComponentLocation = componentLocation,
                    ComponentType     = type,
                    cooldown          = cooldown,
                    showAlert         = show,
                    SpriteLocation    = location,
                    ProposedAction    = ProposedAction
                };
                msg.SendTo(recipient);
                return(msg);
            }
            else
            {
                Logger.LogError("Failed to find IActionGUI on NetworkIdentity");
            }
        }

        return(null);
    }
예제 #45
0
파일: ServiceHost.cs 프로젝트: nie93/LVC118
 /// <summary>
 /// Sends a message to all connected clients.
 /// </summary>
 /// <param name="message">The message to be sent.</param>
 /// <param name="type">Update message type.</param>
 /// <param name="publishToLog">Flag that determines if message should go to log.</param>
 internal void BroadcastMessage(string message, UpdateType type = UpdateType.Information, bool publishToLog = true)
 {
     m_serviceHelper.UpdateStatus(type, publishToLog, "{0}{1}", message, Environment.NewLine);
 }
예제 #46
0
 public ComponentMessage(TComponent content, UpdateType action, bool isSynchronous = false)
     : base(isSynchronous)
 {
     Action  = action;
     Content = content;
 }
        public void Main(string argument, UpdateType updateSource)
        {
            if (Ship_Controller == null && !GetControllingBlock())
            {
                Echo("The Ship Controller does not exist.");
                return;
            }
            if ((updateSource & (UpdateType.Update1 | UpdateType.Update10 | UpdateType.Update100)) > 0)
            {
                Detect();
                Output(PrintOut() + "\n" + Register.PrintOut());
                Echo("RADAR " + currExt + " " + currRPM + ":\n" +
                     "DetectPlayers:" + DetectPlayers + "\n" +
                     "DetectFloatingObjects:" + DetectFloatingObjects + "\n" +
                     "DetectSmallShips:" + DetectSmallShips + "\n" +
                     "DetectLargeShips:" + DetectLargeShips + "\n" +
                     "DetectStations:" + DetectStations + "\n" +
                     "DetectSubgrids:" + DetectSubgrids + "\n" +
                     "DetectAsteroids:" + DetectAsteroids + "\n" +

                     "DetectOwner:" + DetectOwner + "\n" +
                     "DetectFriendly:" + DetectFriendly + "\n" +
                     "DetectNeutral:" + DetectNeutral + "\n" +
                     "DetectEnemy:" + DetectEnemy);
                DoYourJob();
                IncrementAll();
            }
            else
            if ((updateSource & UpdateType.IGC) > 0)
            {
                if (misCMDListener != null && misCMDListener.HasPendingMessage)
                {
                    MyIGCMessage message = misCMDListener.AcceptMessage();
                    if (message.Tag.Equals(misCMDTag))
                    {
                        string   data = (string)message.Data;
                        string[] bits = data.Split(';');

                        double X, Y, Z;
                        int    i = 0;

                        if (bits.Length <= 0)
                        {
                            return;
                        }
                        switch (bits[0].ToUpper())
                        {
                        case "SALVO":
                            if (bits.Length > 3)
                            {
                                if (
                                    double.TryParse(bits[i++], out X) &&
                                    double.TryParse(bits[i++], out Y) &&
                                    double.TryParse(bits[i++], out Z)
                                    )
                                {
                                    //curTarget = new Entry(float.Parse(bits[1]), float.Parse(bits[2]), float.Parse(bits[3]));
                                    PrepareGPSStrike(X, Y, Z, "SALVO");
                                }
                            }
                            break;

                        case "BOOM":
                            if (bits.Length > 1)
                            {
                                Register.RemoveMissionCode(bits[1]);
                            }
                            break;
                        }
                    }
                }
                return;
            }
            else
            {
                if (argument.Length > 0)
                {
                    string[] args = argument.ToLower().Split(' ');
                    float    detExt = 8000, tarRPM = 3;
                    double   X, Y, Z;
                    int      index, i = 0;
                    Entry    target;
                    switch (args[0])
                    {
                    case "ext":
                    case "range":
                        if (args.Length > 1 && float.TryParse(args[1], out detExt))
                        {
                            Echo("set: " + detExt + " " + tarRPM);
                            SetRadExt(detExt);
                        }
                        break;

                    case "rpm":
                        if (args.Length > 1 && float.TryParse(args[1], out tarRPM))
                        {
                            Echo("set: " + detExt + " " + tarRPM);
                            SetRadRPM(tarRPM);
                        }
                        break;

                    case "rad":
                    case "set":
                        i = 1;
                        if (args.Length > 2 && float.TryParse(args[i++], out detExt) && float.TryParse(args[i++], out tarRPM))
                        {
                            Echo("set: " + detExt + " " + tarRPM);
                            SetRadars(detExt, tarRPM);
                        }
                        break;

                    case "gpsstrike":
                    case "gpstrike":
                    case "gps":
                        if (
                            double.TryParse(args[i++], out X) &&
                            double.TryParse(args[i++], out Y) &&
                            double.TryParse(args[i++], out Z))
                        {
                            PrepareGPSStrike(X, Y, Z);
                        }
                        break;

                    case "get":
                        if (args.Length < 2)
                        {
                            index = 0;
                        }
                        else
                        {
                            try { index = int.Parse(args[1]) - 1; } catch (Exception e) { e.ToString(); return; }
                        }
                        target = Register.GetByIndex(index); if (target == null)
                        {
                            return;
                        }

                        ErrorOutput("Position of [" + (index + 1) + "]: " + Format(target.Location));

                        break;


                    case "attack":
                    case "fire":
                        if (args.Length > 1)
                        {
                            int magnitude = 0;
                            try { index = int.Parse(args[1]) - 1; } catch (Exception e) { e.ToString(); return; }
                            target = Register.GetByIndex(index); if (target == null)
                            {
                                return;
                            }

                            if (args.Length > 2)
                            {
                                try { magnitude = int.Parse(args[2]); } catch (Exception e) { e.ToString(); magnitude = 0; }
                            }
                            PrepareForLaunch(target.Id.ToString(), magnitude);
                        }

                        break;

                    case "abort":
                        Abort(true);
                        break;

                    case "aegis":
                        if (args.Length < 2)
                        {
                            AEGIS = !AEGIS;
                        }
                        else
                        {
                            switch (args[1])
                            {
                            case "on":
                            case "up":
                            case "true":
                                AEGIS = true;
                                break;

                            case "off":
                            case "down":
                            case "false":
                            case "terminate":
                                AEGIS = false;
                                break;
                            }
                        }
                        break;

                    case "detect":
                        if (args.Length > 1)
                        {
                            switch (args[1])
                            {
                            case "players":
                            case "characters":
                                DetectPlayers = true;
                                break;

                            case "objects":
                            case "garbage":
                                DetectFloatingObjects = true;
                                break;

                            case "smallships":
                            case "small":
                                DetectSmallShips = true;
                                break;

                            case "largeships":
                            case "large":
                                DetectLargeShips = true;
                                break;

                            case "stations":
                            case "static":
                                DetectStations = true;
                                break;

                            case "sub":
                            case "subgrids":
                                DetectSubgrids = true;
                                break;

                            case "asteroids":
                            case "comets":
                                // OJ NIE NIE BYCZQ -1
                                //DetectAsteroids = true;
                                break;

                            case "own":
                            case "owner":
                            case "my":
                            case "mine":
                                DetectOwner = true;
                                break;

                            case "friendly":
                            case "fac":
                            case "green":
                            case "allies":
                            case "ally":
                                DetectFriendly = true;
                                break;

                            case "noo":
                            case "neutral":
                                DetectNeutral = true;
                                break;

                            case "enemy":
                            case "ene":
                            case "red":
                                DetectEnemy = true;
                                break;

                            case "default":
                                DetectPlayers         = false;
                                DetectFloatingObjects = false;
                                DetectSmallShips      = true;
                                DetectLargeShips      = true;
                                DetectStations        = true;
                                DetectSubgrids        = false;
                                DetectAsteroids       = false;

                                DetectOwner    = false;
                                DetectFriendly = false;
                                DetectNeutral  = true;
                                DetectEnemy    = true;
                                break;

                            default:
                                Echo("Term unknown: '" + args[1] + "'");
                                break;
                            }
                            SetRadars();
                        }
                        break;

                    case "ignore":
                        if (args.Length > 1)
                        {
                            switch (args[1])
                            {
                            case "players":
                            case "characters":
                                DetectPlayers = false;
                                break;

                            case "objects":
                            case "garbage":
                                DetectFloatingObjects = false;
                                break;

                            case "smallships":
                            case "small":
                                DetectSmallShips = false;
                                break;

                            case "largeships":
                            case "large":
                                DetectLargeShips = false;
                                break;

                            case "stations":
                            case "static":
                                DetectStations = false;
                                break;

                            case "sub":
                            case "subgrids":
                                DetectSubgrids = false;
                                break;

                            case "asteroids":
                            case "comets":
                                DetectAsteroids = false;
                                break;

                            case "own":
                            case "owner":
                            case "my":
                            case "mine":
                                DetectOwner = false;
                                break;

                            case "friendly":
                            case "friend":
                            case "fac":
                            case "green":
                            case "allies":
                            case "ally":
                                DetectFriendly = false;
                                break;

                            case "noo":
                            case "neutral":
                                DetectNeutral = false;
                                break;

                            case "enemy":
                            case "ene":
                            case "red":
                                DetectEnemy = false;
                                break;

                            case "default":
                                DetectPlayers         = false;
                                DetectFloatingObjects = false;
                                DetectSmallShips      = true;
                                DetectLargeShips      = true;
                                DetectStations        = true;
                                DetectSubgrids        = false;
                                DetectAsteroids       = false;

                                DetectOwner    = false;
                                DetectFriendly = false;
                                DetectNeutral  = true;
                                DetectEnemy    = true;
                                break;

                            default:
                                Echo("Term unknown: '" + args[1] + "'");
                                break;
                            }
                            SetRadars();
                        }
                        break;

                    default:
                        Echo("Term unknown: '" + args[0] + "'");
                        break;
                    }
                }
            }
        }
예제 #48
0
 /// <summary>
 /// 创建用于保存的临时数据
 /// </summary>
 /// <param name="sourceData">原始数据</param>
 /// <param name="currentType">当前操作状态</param>
 /// <returns></returns>
 public abstract DataSet CreateSaveData(DataSet sourceData, UpdateType currentType);
예제 #49
0
        private void EnabledRow(Host host, UpdateType type, int index)
        {
            var row = (PatchingHostsDataGridViewRow)dataGridViewHosts.Rows[index];

            var poolOfOne = Helpers.GetPoolOfOne(host.Connection);

            if (WizardMode == WizardMode.AutomatedUpdates)
            {
                // This check is first because it generally can't be fixed, it's a property of the host
                if (poolOfOne != null && poolOfOne.IsAutoUpdateRestartsForbidden()) // Forbids update auto restarts
                {
                    row.Enabled = false;
                    row.Cells[3].ToolTipText = Messages.POOL_FORBIDS_AUTOMATED_UPDATES;
                    return;
                }

                var pool = Helpers.GetPool(host.Connection);
                if (pool != null && !pool.IsPoolFullyUpgraded()) //partially upgraded pool is not supported
                {
                    row.Enabled = false;
                    row.Cells[3].ToolTipText = Messages.PATCHINGWIZARD_SELECTSERVERPAGE_AUTOMATED_UPDATES_NOT_SUPPORTED_PARTIALLY_UPGRADED;

                    return;
                }

                //check updgrade sequences
                Updates.UpgradeSequence us = Updates.GetUpgradeSequence(host.Connection);

                if (us == null) //version not supported
                {
                    row.Enabled = false;
                    row.Cells[3].ToolTipText = Messages.PATCHINGWIZARD_SELECTSERVERPAGE_AUTOMATED_UPDATES_NOT_SUPPORTED_HOST_VERSION;

                    return;
                }

                //unlicensed servers are not enabled
                if (Host.RestrictBatchHotfixApply(host))
                {
                    row.Enabled = false;
                    row.Cells[3].ToolTipText = Messages.PATCHINGWIZARD_SELECTSERVERPAGE_HOST_UNLICENSED_FOR_AUTOMATED_UPDATES;

                    return;
                }

                //if there is a host missing from the upgrade sequence
                if (host.Connection.Cache.Hosts.Any(h => !us.Keys.Contains(h)))
                {
                    row.Enabled = false;
                    row.Cells[3].ToolTipText = Messages.PATCHINGWIZARD_SELECTSERVERPAGE_SERVER_NOT_AUTO_UPGRADABLE;

                    return;
                }

                //if all hosts are up-to-date
                if (us.AllHostsUpToDate)
                {
                    row.Enabled = false;
                    row.Cells[3].ToolTipText = Messages.PATCHINGWIZARD_SELECTSERVERPAGE_SERVER_UP_TO_DATE;

                    return;
                }

                //if host is unreachable
                if (!host.IsLive())
                {
                    row.Enabled = false;
                    row.Cells[3].ToolTipText = Messages.PATCHINGWIZARD_SELECTSERVERPAGE_HOST_UNREACHABLE;
                    return;
                }

                return;
            }

            List <Host> applicableHosts = null;

            if (SelectedUpdateAlert != null)
            {
                applicableHosts = SelectedUpdateAlert.DistinctHosts;
            }
            else if (FileFromDiskAlert != null)
            {
                applicableHosts = FileFromDiskAlert.DistinctHosts;
            }

            if (!host.CanApplyHotfixes() && (Helpers.ElyOrGreater(host) || type != UpdateType.ISO))
            {
                row.Enabled = false;
                row.Cells[3].ToolTipText = Messages.PATCHINGWIZARD_SELECTSERVERPAGE_HOST_UNLICENSED;
                return;
            }

            if (!host.IsLive())
            {
                row.Enabled = false;
                row.Cells[3].ToolTipText = Messages.PATCHINGWIZARD_SELECTSERVERPAGE_HOST_UNREACHABLE;
                return;
            }

            switch (type)
            {
            case UpdateType.NewRetail:
            case UpdateType.Existing:
                if (Helpers.ElyOrGreater(host))
                {
                    row.Enabled = false;
                    row.Cells[3].ToolTipText = Messages.PATCHINGWIZARD_SELECTSERVERPAGE_PATCH_NOT_APPLICABLE;
                }
                disableNotApplicableHosts(row, applicableHosts, host);
                break;

            case UpdateType.ISO:
                if (!Helpers.CreamOrGreater(host.Connection) && !Helpers.ElyOrGreater(host))     //from Ely, iso does not mean supplemental pack
                {
                    row.Enabled = false;
                    row.Cells[3].ToolTipText = Messages.PATCHINGWIZARD_SELECTSERVERPAGE_CANNOT_INSTALL_SUPP_PACKS;
                }
                else
                {
                    if (applicableHosts != null)
                    {
                        disableNotApplicableHosts(row, applicableHosts, host);
                    }
                    else
                    {
                        var firstCheckedHost = GetFirstCheckedHost();
                        if (firstCheckedHost != null && (Helpers.ElyOrGreater(firstCheckedHost) != Helpers.ElyOrGreater(host)))
                        {
                            row.Enabled = false;
                            row.Cells[3].ToolTipText = string.Format(Messages.PATCHINGWIZARD_SELECTSERVERPAGE_MIXED_VERSIONS, firstCheckedHost.ProductVersionTextShort(), host.ProductVersionTextShort());
                        }
                        else if (!row.Enabled)
                        {
                            row.Enabled = true;
                            row.Cells[3].ToolTipText = null;
                        }
                    }
                }
                break;
            }
        }
예제 #50
0
    public void Main(string argument, UpdateType updateSource)
    {
        //Normal update
        if (updateSource == UpdateType.Update100)
        {
            //Update on screen if main assembler is in production
            ClearScreen();
            //Move all item out of main assembler
            var output = new List <MyInventoryItem>();
            MainAssembler.OutputInventory.GetItems(output);
            foreach (var item in output)
            {
                if (AnyCargo != null)
                {
                    MainAssembler.OutputInventory.TransferItemTo(AnyCargo.GetInventory(), item);
                }
            }
            //Max characters: 53
            Dictionary <string, int> itemsAndAmount = new Dictionary <string, int>();
            Dictionary <string, int> itemsAndQueue  = new Dictionary <string, int>();
            if (RequestedAndAmountCustom == null)
            {
                RequestedAndAmountCustom = new Dictionary <string, int>();
            }
            //Check sorter for requests
            var requests = new List <MyInventoryItemFilter>();
            SorterOfRequested.GetFilterList(requests);
            Report($"Request: {requests.Count} | {(allDone ? "(All done)" : "(Working)")}");
            foreach (var item in requests)
            {
                itemsAndAmount.Add(item.ItemType.SubtypeId, 0);
                itemsAndQueue.Add(item.ItemType.SubtypeId, 0);
            }
            //Check main assembly for queues
            var queue = new List <MyProductionItem>();
            MainAssembler.GetQueue(queue);
            Report($"Queue: {queue.Count} | {(MainAssembler.IsProducing ? "ACTIVE" : "INACTIVE")}");
            //Check if assembler is in disassembling moded
            if (MainAssembler.Mode == MyAssemblerMode.Disassembly)
            {
                MainAssembler.Mode = MyAssemblerMode.Assembly;
            }
            foreach (var item in queue)
            {
                if (!itemsAndQueue.ContainsKey(item.BlueprintId.SubtypeName))
                {
                    itemsAndQueue.Add(item.BlueprintId.SubtypeName, item.Amount.ToIntSafe());
                }
                else
                {
                    itemsAndQueue[item.BlueprintId.SubtypeName] += item.Amount.ToIntSafe();
                }
            }
            //Checking items
            List <IMyTerminalBlock> allBlocks = new List <IMyTerminalBlock>();
            GridTerminalSystem.GetBlocks(allBlocks);
            foreach (var block in allBlocks)
            {
                if (block == SorterOfRequested)
                {
                    continue;
                }
                else if (block == Me)
                {
                    continue;
                }
                if (AnyCargo == null)
                {
                    if (block is IMyCargoContainer && !block.GetInventory().IsFull)
                    {
                        AnyCargo = block as IMyCargoContainer;
                    }
                }
                else
                {
                    if (AnyCargo.GetInventory().IsFull)
                    {
                        AnyCargo = null;
                    }
                }

                if (block.InventoryCount > 0)
                {
                    for (int i = 0; i < block.InventoryCount; i++)
                    {
                        var allItems = block.GetInventory(i);
                        if (allItems != null && allItems.ItemCount > 0)
                        {
                            var actualAllItems = new List <MyInventoryItem>();
                            allItems.GetItems(actualAllItems);
                            foreach (var item2 in actualAllItems)
                            {
                                if (itemsAndAmount.ContainsKey(item2.Type.SubtypeId))
                                {
                                    itemsAndAmount[item2.Type.SubtypeId] += item2.Amount.ToIntSafe();
                                }
                                else
                                {
                                    itemsAndAmount.Add(item2.Type.SubtypeId, item2.Amount.ToIntSafe());
                                }
                            }
                        }
                    }
                }
            }
            Report($"AM=Amount | AS=Assembling | REQ=Required");
            Report($"{"Name",-22} | {"AM",-6} | {"AS",-6} | {"REQ",-6} |\r\n" +
                   $"-----------------------------------------------------");
            foreach (var pair in itemsAndAmount)
            {
                if (!itemsAndQueue.ContainsKey(pair.Key))
                {
                    continue;
                }
                if (RequestedAndAmountCustom.ContainsKey(pair.Key))
                {
                    Report($"{pair.Key,-22} | {pair.Value,-6} | {itemsAndQueue[pair.Key],-6} | {RequestedAndAmountCustom[pair.Key],-6} |\r\n");
                }
                else
                {
                    Report($"{pair.Key,-22} | {pair.Value,-6} | {itemsAndQueue[pair.Key],-6} | {MinimumAmount,-6} |\r\n");
                }
                if ((RequestedAndAmountCustom.ContainsKey(pair.Key) && pair.Value < RequestedAndAmountCustom[pair.Key]) ||
                    (!RequestedAndAmountCustom.ContainsKey(pair.Key) && pair.Value < MinimumAmount))
                {
                    allDone = false;
                }
            }
            if (!MainAssembler.IsProducing && MainAssembler.IsQueueEmpty && !allDone)
            {
                Runtime.UpdateFrequency = UpdateFrequency.None;
                Main("CheckAndRequest", UpdateType.Script);
            }
            ReportAllItemsInfo();
        }
        else if (argument == "CheckAndRequest" && updateSource == UpdateType.Script)
        {
            ClearScreen();
            Report("Begin checking items");
            //Get sorter
            //Find item list on Conveyer sorter filter list
            RequestedItems = new List <MyInventoryItemFilter>();
            SorterOfRequested.GetFilterList(RequestedItems);
            Report("Gathered list of items from sorter of request");
            Report($"Found {RequestedItems.Count} items");
            RequestedAndAmount       = new Dictionary <string, int>();
            RequestedAndAmountCustom = new Dictionary <string, int>();
            //Read all custom amounts
            if (!string.IsNullOrEmpty(Me.CustomData))
            {
                var linesOfCustom = Me.CustomData.Split("\r\n".ToCharArray(), StringSplitOptions.RemoveEmptyEntries);
                foreach (var line in linesOfCustom)
                {
                    var info = line.Split('=');
                    RequestedAndAmountCustom.Add(info[0], int.Parse(info[1]));
                }
            }
            //Load requested amount from custom data or write into it if empty
            string input = "";
            foreach (var item in RequestedItems)
            {
                RequestedAndAmount.Add(item.ItemType.SubtypeId, 0);
                Report($"Add {item.ItemType.SubtypeId} into requested list");
                if (RequestedAndAmountCustom.ContainsKey(item.ItemType.SubtypeId))
                {
                    input += $"{item.ItemType.SubtypeId}={RequestedAndAmountCustom[item.ItemType.SubtypeId]}\r\n";
                }
                else
                {
                    input += $"{item.ItemType.SubtypeId}={MinimumAmount}\r\n";
                    RequestedAndAmountCustom.Add(item.ItemType.SubtypeId, MinimumAmount);
                }
            }
            Me.CustomData = input;
            //Check all inventories
            Report("Began checking inventories");
            List <IMyTerminalBlock> allBlocks = new List <IMyTerminalBlock>();
            GridTerminalSystem.GetBlocks(allBlocks);
            Report($"Began checking {allBlocks.Count} blocks");
            foreach (var item in allBlocks)
            {
                Report($"Checking {item.CustomName}");
                if (item == SorterOfRequested)
                {
                    continue;
                }
                else if (item == Me)
                {
                    continue;
                }

                if (item.InventoryCount > 0)
                {
                    for (int i = 0; i < item.InventoryCount; i++)
                    {
                        Report($"Found inventory on {item.CustomName} {i + 1}/{item.InventoryCount}");
                        var allItems = item.GetInventory(i);
                        Report($"{item.CustomName}'s inventory {(allItems == null ? "is null" : "has an item")} {allItems.ItemCount}");
                        if (allItems != null && allItems.ItemCount > 0)
                        {
                            var actualAllItems = new List <MyInventoryItem>();
                            allItems.GetItems(actualAllItems);
                            Report($"Found {actualAllItems.Count} item on inventory");
                            foreach (var req in RequestedItems)
                            {
                                foreach (var actual in actualAllItems)
                                {
                                    Report($"{req.ItemType.SubtypeId} vs {actual.Type.SubtypeId}");
                                    if (req.ItemType.SubtypeId == actual.Type.SubtypeId)
                                    {
                                        Report($"Add {req.ItemType.SubtypeId} into list");
                                        Report($"Add {actual.Amount.ToIntSafe()} into dictionary");
                                        if (!RequestedAndAmount.ContainsKey(req.ItemType.SubtypeId))
                                        {
                                            RequestedAndAmount.Add(req.ItemType.SubtypeId, 0);
                                        }
                                        RequestedAndAmount[req.ItemType.SubtypeId] += actual.Amount.ToIntSafe();
                                    }
                                }
                            }
                        }
                    }
                }
            }
            ClearScreen();
            Report("Began requesting assembler");
            var queue = new List <MyProductionItem>();
            MainAssembler.GetQueue(queue);
            //If it has less than MinimumAmount then send request to assembly
            //TODO: Take all slaves assembly into account
            bool unfinished = false;
            foreach (var pair in RequestedAndAmount)
            {
                //Check if it's already in queue or not
                foreach (var item in queue)
                {
                    if (item.BlueprintId.SubtypeName == pair.Key)
                    {
                        continue;
                    }
                }
                if (RequestedAndAmountCustom.ContainsKey(pair.Key))
                {
                    Report($"{pair.Key}: R={RequestedAndAmountCustom[pair.Key]} Now={pair.Value}");
                    if (pair.Value <= RequestedAndAmountCustom[pair.Key])
                    {
                        Report($"Parsing item id: {pair.Key}");
                        MyDefinitionId itemID = MyDefinitionId.Parse($"MyObjectBuilder_BlueprintDefinition/{pair.Key}");
                        Report($"Item ID parsing: {(itemID == null ? "ItemID parse failed" : "ItemID parse complete")}");
                        Report($"Requested item \"{itemID.SubtypeName}\" still missing about {RequestedAndAmountCustom[pair.Key] - pair.Value}");
                        try
                        {
                            MainAssembler.AddQueueItem(itemID, Convert.ToDecimal(RequestedAndAmountCustom[itemID.SubtypeName] - pair.Value));
                        }
                        catch (Exception e)
                        {
                            Report($"ERROR: {e.Message}");
                        }
                        unfinished = true;
                    }
                }
                else
                {
                    Report($"{pair.Key}: R={MinimumAmount} Now={pair.Value}");
                    if (pair.Value <= MinimumAmount)
                    {
                        Report($"Parsing item id: {pair.Key}");
                        MyDefinitionId itemID = MyDefinitionId.Parse($"MyObjectBuilder_BlueprintDefinition/{pair.Key}");
                        Report($"Item ID parsing: {(itemID == null ? "ItemID parse failed" : "ItemID parse complete")}");
                        Report($"Requested item \"{itemID.SubtypeName}\" still missing about {(MinimumAmount - pair.Value)}");
                        MainAssembler.AddQueueItem(itemID, Convert.ToDecimal(MinimumAmount - pair.Value));
                        unfinished = true;
                    }
                }
            }
            if (unfinished)
            {
                //Set back updater
                Runtime.UpdateFrequency = UpdateFrequency.Update100;
            }
            else
            {
                allDone = true;
                Runtime.UpdateFrequency = UpdateFrequency.Update100;
            }
        }
    }
예제 #51
0
 /// <summary>
 /// Logs a status message to connected clients.
 /// </summary>
 /// <param name="message">Message to log.</param>
 /// <param name="type">Type of message to log.</param>
 public void LogStatusMessage(string message, UpdateType type = UpdateType.Information)
 {
     DisplayStatusMessage(message, type);
 }
예제 #52
0
 /// <summary>
 /// Handler for processing any of the 'trigger' upatetypes
 /// </summary>
 /// <param name="argument"></param>
 /// <param name="updateSource"></param>
 public void ProcessTrigger(string sArgument, MyCommandLine myCommandLine, UpdateType updateSource)
 {
     if (myCommandLine != null && myCommandLine.ArgumentCount > 1)
     {
         if (myCommandLine.Argument(0) == "setmode")
         {
             int  toMode = 0;
             bool bOK    = int.TryParse(myCommandLine.Argument(1), out toMode);
             if (bOK)
             {
                 SetMode(toMode);
                 WantOnce();
             }
         }
     }
 }
        public override void Reset()
        {
            base.Reset();

            gameObject = null;

            position = new FsmVector3 {
                UseVariable = false
            };
            duration = new FsmFloat {
                UseVariable = false
            };
            setSpeedBased = new FsmBool {
                UseVariable = false, Value = false
            };
            axisConstraint = AxisConstraint.None;
            up             = new FsmVector3 {
                UseVariable = false, Value = Vector3.up
            };

            setRelative = new FsmBool {
                UseVariable = false, Value = false
            };

            playInReverse = new FsmBool {
                UseVariable = false, Value = false
            };
            setReverseRelative = new FsmBool {
                UseVariable = false, Value = false
            };

            startEvent        = null;
            finishEvent       = null;
            finishImmediately = new FsmBool {
                UseVariable = false, Value = false
            };

            stringAsId = new FsmString {
                UseVariable = false
            };
            tagAsId = new FsmString {
                UseVariable = false
            };

            startDelay = new FsmFloat {
                Value = 0
            };

            selectedEase = DOTweenActionsEnums.SelectedEase.EaseType;
            easeType     = Ease.Linear;

            loops = new FsmInt {
                Value = 0
            };
            loopType = LoopType.Restart;

            autoKillOnCompletion = new FsmBool {
                Value = true
            };
            recyclable = new FsmBool {
                Value = false
            };

            updateType          = UpdateType.Normal;
            isIndependentUpdate = new FsmBool {
                Value = false
            };

            debugThis = new FsmBool {
                Value = false
            };
        }
예제 #54
0
 public void Main(string argument, UpdateType updateSource)
 {
     _impl.Main(argument, updateSource);
 }
예제 #55
0
        private void EnabledRow(Host host, UpdateType type, int index)
        {
            var row = (PatchingHostsDataGridViewRow)dataGridViewHosts.Rows[index];

            if (IsInAutomaticMode)
            {
                var pool = Helpers.GetPool(host.Connection);
                if (pool != null && !pool.IsPoolFullyUpgraded) //partially upgraded pool is not supported
                {
                    row.Enabled = false;
                    row.Cells[3].ToolTipText = Messages.PATCHINGWIZARD_SELECTSERVERPAGE_AUTO_UPDATE_NOT_SUPPORTED_PARTIALLY_UPGRADED;

                    return;
                }

                //check updgrade sequences
                Updates.UpgradeSequence us = Updates.GetUpgradeSequence(host.Connection, AutoDownloadedXenServerVersions);

                if (us == null) //version not supported
                {
                    row.Enabled = false;
                    row.Cells[3].ToolTipText = Messages.PATCHINGWIZARD_SELECTSERVERPAGE_AUTO_UPDATE_NOT_SUPPORTED_HOST_VERSION;

                    return;
                }

                //unlicensed servers are not enabled
                if (Host.RestrictBatchHotfixApply(host))
                {
                    row.Enabled = false;
                    row.Cells[3].ToolTipText = Messages.PATCHINGWIZARD_SELECTSERVERPAGE_HOST_UNLICENSED_FOR_BATCH_UPDATING;

                    return;
                }

                //if there is a host missing from the upgrade sequence
                if (host.Connection.Cache.Hosts.Any(h => !us.Keys.Contains(h)))
                {
                    row.Enabled = false;
                    row.Cells[3].ToolTipText = Messages.PATCHINGWIZARD_SELECTSERVERPAGE_SERVER_NOT_AUTO_UPGRADABLE;

                    return;
                }

                //if all hosts are up-to-date
                if (us.AllHostsUpToDate)
                {
                    row.Enabled = false;
                    row.Cells[3].ToolTipText = Messages.PATCHINGWIZARD_SELECTSERVERPAGE_SERVER_UP_TO_DATE;

                    return;
                }

                return;
            }

            List <Host> selectedHosts = null;

            if (SelectedUpdateAlert != null)
            {
                selectedHosts = SelectedUpdateAlert.DistinctHosts;
            }
            else if (FileFromDiskAlert != null)
            {
                selectedHosts = FileFromDiskAlert.DistinctHosts;
            }

            Pool poolOfOne = Helpers.GetPoolOfOne(host.Connection);

            if (poolOfOne != null && poolOfOne.IsPatchingForbidden)
            {
                row.Enabled = false;
                row.Cells[3].ToolTipText = Messages.PATCHINGWIZARD_SELECTSERVERPAGE_PATCHING_FORBIDDEN;
                return;
            }

            if (type != UpdateType.NewSuppPack && !host.CanApplyHotfixes)
            {
                row.Enabled = false;
                row.Cells[3].ToolTipText = Messages.PATCHINGWIZARD_SELECTSERVERPAGE_HOST_UNLICENSED;
                return;
            }

            switch (type)
            {
            case UpdateType.NewRetail:
            case UpdateType.Existing:
                disableNotApplicableHosts(row, selectedHosts, host);
                break;

            case UpdateType.NewSuppPack:
                if (!host.CanInstallSuppPack)
                {
                    row.Enabled = false;
                    row.Cells[3].ToolTipText = Messages.PATCHINGWIZARD_SELECTSERVERPAGE_CANNOT_INSTALL_SUPP_PACKS;
                }
                break;
            }
        }
예제 #56
0
        public static async Task <IReadOnlyCollection <IContainerGroup> > StartFleet(ILogger log, Cfg cfg, UpdateType optionUpdateType)
        {
            var sheets        = (await ChannelSheets.MainChannels(cfg.App.Sheets, log)).ToList();
            var evenBatchSize = (int)Math.Ceiling(sheets.Count / Math.Ceiling(sheets.Count / (double)cfg.App.ChannelsPerContainer));

            var batches = sheets.Randomize().Batch(evenBatchSize).Select((b, i) => (batch: b.ToList(), name: $"{cfg.App.Container.Name}-fleet-{i}", i)).ToList();

            var azure = GetAzure(cfg);

            // before starting feel. Ensure they are all not already running
            await batches.BlockAction(async b => await EnsureNotRunning(b.name, azure, cfg.App.ResourceGroup), cfg.App.DefaultParallel);

            var fleet = await batches.BlockTransform(async b => {
                var(batch, fleetName, i) = b;
                var region = Regions[i % Regions.Length];
                var args   = new[] {
                    "update",
                    "-t", optionUpdateType.ToString(),
                    "-c", batch.Join("|", c => c.Id)
                };
                var group = await ContainerGroup(cfg, azure, fleetName, region, args.ToArray());
                return(await group.CreateAsync());
            }, cfg.App.DefaultParallel);

            log.Information("Started fleet containers: {Containers}", fleet.Join(", ", f => f.Name));
            return(fleet);
        }
예제 #57
0
파일: Go.cs 프로젝트: squirr3l/GoKit
    /// <summary>
    /// loops through all the Tweens and updates any that are of updateType. If any Tweens are complete
    /// (the update call will return true) they are removed.
    /// </summary>
    private void handleUpdateOfType( UpdateType updateType, float deltaTime )
    {
        // loop backwards so we can remove completed tweens
        for( var i = _tweens.Count - 1; i >= 0; --i )
        {
            var t = _tweens[i];

            // only process tweens with our update type that are running
            if( t.updateType == updateType && t.state == TweenState.Running && t.update( deltaTime * t.timeScale ) )
            {
                // tween is complete if we get here. if destroyed or set to auto remove kill it
                if( t.state == TweenState.Destroyed || t.autoRemoveOnComplete )
                {
                    removeTween( t );
                    t.destroy();
                }
            }
        }
    }
예제 #58
0
 /// <summary> When the Rider is Aiming is necesary to change the Update Mode to Late Update</summary>
 public virtual void ForceUpdateMode(bool val)
 {
     updateType = val ? UpdateType.LateUpdate : defaultUpdate;
 }
예제 #59
0
        void outp_StatusUpdate(UpdateType type, IUpdateSource source, uint processedItems)
        {
            // if the update is too frequent, slow it down
            if (lastStatusUpdate == 0)
            {
                lastStatusUpdate = sw.ElapsedMilliseconds;
            }
            else if (sw.ElapsedMilliseconds - lastStatusUpdate < 800)
            {
                source.ReportEveryNth *= 2;
            }
            else if (sw.ElapsedMilliseconds - lastStatusUpdate > 1200)
            {
                source.ReportEveryNth = (uint)(source.ReportEveryNth / 1.5f);
            }

            lastStatusUpdate = sw.ElapsedMilliseconds;

            uint itemsPerSec = (uint)(processedItems / (sw.ElapsedMilliseconds / 1000f - outPutstartTime / 1000f));

            string currentAction = "Processing";

            switch (type)
            {
                case UpdateType.Map:
                    break;
                case UpdateType.Reduce:
                    break;
                case UpdateType.Input:
                    return; // currently not interesed in Load events
                    //currentAction = "Loading";
                    //break;
                case UpdateType.Output:
                    currentAction = "Saving";
                    break;
                default:
                    break;
            }


            Console.WriteLine(string.Format("[{1,2}.{2:000}] {4} item #{0:0,0} (avg: {3:0,0}/sec)", 
                processedItems,
                (int)sw.Elapsed.TotalSeconds, 
                sw.Elapsed.Milliseconds, 
                itemsPerSec,
                currentAction
                )
                );

            if (Progress != null)
                Progress(type, processedItems, sw.Elapsed.TotalSeconds, itemsPerSec);
        }
예제 #60
0
        private async Task PerformUpdate(UpdateType updateType)
        {
            try
            {
                if (!modelHelpers.Gallifrey.IsInitialised && updateType != UpdateType.StartUp)
                {
                    return;
                }

                //Do Update
                UpdateResult updateResult;
                if (updateType == UpdateType.Manual || updateType == UpdateType.StartUp)
                {
                    var controller = await modelHelpers.ShowIndeterminateProgressAsync("Please Wait", "Checking For Updates");

                    controller.SetIndeterminate();
                    updateResult = await modelHelpers.Gallifrey.VersionControl.CheckForUpdates(true);

                    await controller.CloseAsync();
                }
                else
                {
                    updateResult = await modelHelpers.Gallifrey.VersionControl.CheckForUpdates(false);
                }

                //Handle Update Result
                if (updateResult == UpdateResult.Updated && (updateType == UpdateType.Manual || updateType == UpdateType.StartUp))
                {
                    var messageResult = await modelHelpers.ShowMessageAsync("Update Found", "Restart Now To Install Update?", MessageDialogStyle.AffirmativeAndNegative, new MetroDialogSettings { AffirmativeButtonText = "Yes", NegativeButtonText = "No", DefaultButtonFocus = MessageDialogResult.Affirmative });

                    if (messageResult == MessageDialogResult.Affirmative)
                    {
                        modelHelpers.Gallifrey.TrackEvent(TrackingType.ManualUpdateRestart);
                        modelHelpers.CloseApp(true);
                    }
                }
                else if (updateResult == UpdateResult.Updated && modelHelpers.Gallifrey.Settings.AppSettings.AutoUpdate && !machineLocked && !modelHelpers.FlyoutOpenOrDialogShowing)
                {
                    modelHelpers.Gallifrey.TrackEvent(TrackingType.AutoUpdateInstalled);
                    modelHelpers.CloseApp(true);
                }
                else if (updateResult == UpdateResult.Updated)
                {
                    modelHelpers.ShowNotification("Update Found, Restart Now To Install!");
                }
                else if (updateResult == UpdateResult.NoInternet && updateType == UpdateType.Manual)
                {
                    await modelHelpers.ShowMessageAsync("Unable To Update", "Unable To Access https://gallifrey-releases.blyth.me.uk To Check For Updates");
                }
                else if (updateResult == UpdateResult.NotDeployable && updateType == UpdateType.Manual)
                {
                    await modelHelpers.ShowMessageAsync("Unable To Update", "You Cannot Auto Update This Version Of Gallifrey");
                }
                else if ((updateResult == UpdateResult.NoUpdate || updateResult == UpdateResult.TooSoon) && updateType == UpdateType.Manual)
                {
                    await modelHelpers.ShowMessageAsync("No Update Found", "There Are No Updates At This Time, Check Back Soon!");
                }
                else if (updateResult == UpdateResult.ReinstallNeeded && (updateType == UpdateType.Manual || updateType == UpdateType.StartUp))
                {
                    var messageResult = await modelHelpers.ShowMessageAsync("Update Error", "To Update An Uninstall/Reinstall Is Required.\nThis Can Happen Automatically & No Timers Will Be Lost\nAll You Need To Do Is Press The \"Install\" Button When Prompted\n\nDo You Want To Update Now?", MessageDialogStyle.AffirmativeAndNegative, new MetroDialogSettings { AffirmativeButtonText = "Yes", NegativeButtonText = "No", DefaultButtonFocus = MessageDialogResult.Affirmative });

                    if (messageResult == MessageDialogResult.Affirmative)
                    {
                        try
                        {
                            modelHelpers.Gallifrey.VersionControl.ManualReinstall();
                            await Task.Delay(TimeSpan.FromSeconds(2));
                        }
                        catch (Exception)
                        {
                            await modelHelpers.ShowMessageAsync("Update Error", "There Was An Error Trying To Update Gallifrey, You May Need To Re-Download The App");
                        }
                        finally
                        {
                            modelHelpers.CloseApp();
                        }
                    }
                }
            }
            catch (Exception ex)
            {
                if (updateType == UpdateType.Manual || updateType == UpdateType.StartUp)
                {
                    await modelHelpers.ShowMessageAsync("Update Error", "There Was An Error Trying To Update Gallifrey, If This Problem Persists Please Contact Support");

                    modelHelpers.CloseApp(true);
                }
                else
                {
                    ExceptionlessClient.Default.CreateEvent().SetException(ex).AddTags("Hidden").Submit();
                }
            }
        }