private static void SetSaveFlag(ref SetFlag flags, SetFlag toSet, bool setIf)
 {
     if (setIf)
     {
         flags |= toSet;
     }
 }
Exemple #2
0
        public override Task <SetFlag> doCalibrate(CalibReq request, ServerCallContext context)
        {
            /*
             * 原来代码可以编译 Position X " + request.Position.X.ToString() + " Y " + request.Position.Y.ToString() + " Z " + request.Position.Z.ToString() +
             * 目前机器人端.pro文件如果为更新过则需要更新机器人端.pro协议,否则软件可能不能工作
             */
            Console.WriteLine("reve doCalibrate: OffsetMethod  " + request.OffsetMethod +
                              " Position X " + request.Position.X.ToString() + " Y " + request.Position.Y.ToString() + " Z " + request.Position.Theta.ToString() +
                              " Terminate " + request.Terminate.ToString());
            SetFlag resultFlag = new SetFlag();

            return(Task.FromResult(resultFlag));
        }
Exemple #3
0
        public override Task <SetFlag> triggerCamera(TriggerReq request, ServerCallContext context)
        {
            SetFlag resultFlag = new SetFlag();
            int     flag       = 0;

            if (triggerCamerHandler != null)
            {
                /*
                 * 原来代码可以编译flag = triggerCamerHandler(request.RobotPose.Position.X, request.RobotPose.Position.Y, request.RobotPose.Position.Z);
                 * 目前机器人端.pro文件如果为更新过则需要更新机器人端.pro协议,否则软件可能不能工作
                 */
                flag = triggerCamerHandler(request.RobotPose.X, request.RobotPose.Y, request.RobotPose.Theta);
            }
            resultFlag.ErrorFlag = flag;
            return(Task.FromResult(resultFlag));
        }
Exemple #4
0
        private void Click(object sender, MouseButtonEventArgs e)
        {
            switch (Type)
            {
            case CellType.Unknow:
                (IsFlag == (e.ChangedButton == MouseButton.Left) ? SetFlag : Open)?.Invoke(this, e);
                break;

            case CellType.Flag:
                SetFlag?.Invoke(this, e);
                break;

            case CellType.Open:
                Open?.Invoke(this, e);
                break;
            }
        }
		private static bool GetSaveFlag( SetFlag flags, SetFlag toGet )
		{
			return ( (flags & toGet) != 0 );
		}
		// Genova: suporte ao UO:ML.
		#region Mondain's Legacy		
		private static void SetSaveFlag( ref SetFlag flags, SetFlag toSet, bool setIf )
		{
			if ( setIf )
				flags |= toSet;
		}
        public override void Deserialize(GenericReader reader)
        {
            base.Deserialize(reader);

            int version = reader.ReadInt();

            switch (version)
            {
            case 6:
            {
                #region Set Items
                SetFlag sflags = (SetFlag)reader.ReadEncodedInt();

                if (GetSaveFlag(sflags, SetFlag.Attributes))
                {
                    m_SetAttributes = new AosAttributes(this, reader);
                }
                else
                {
                    m_SetAttributes = new AosAttributes(this);
                }

                if (GetSaveFlag(sflags, SetFlag.SkillBonuses))
                {
                    m_SetSkillBonuses = new AosSkillBonuses(this, reader);
                }
                else
                {
                    m_SetSkillBonuses = new AosSkillBonuses(this);
                }

                if (GetSaveFlag(sflags, SetFlag.SetHue))
                {
                    m_SetHue = reader.ReadEncodedInt();
                }

                if (GetSaveFlag(sflags, SetFlag.LastEquipped))
                {
                    m_LastEquipped = reader.ReadBool();
                }

                if (GetSaveFlag(sflags, SetFlag.SetEquipped))
                {
                    m_SetEquipped = reader.ReadBool();
                }
                #endregion
                goto case 5;
            }

            case 5:
            {
                SaveFlag flags = (SaveFlag)reader.ReadEncodedInt();

                if (GetSaveFlag(flags, SaveFlag.Resource))
                {
                    m_Resource = (CraftResource)reader.ReadEncodedInt();
                }
                else
                {
                    m_Resource = DefaultResource;
                }

                if (GetSaveFlag(flags, SaveFlag.Attributes))
                {
                    m_AosAttributes = new AosAttributes(this, reader);
                }
                else
                {
                    m_AosAttributes = new AosAttributes(this);
                }

                if (GetSaveFlag(flags, SaveFlag.ClothingAttributes))
                {
                    m_AosClothingAttributes = new AosArmorAttributes(this, reader);
                }
                else
                {
                    m_AosClothingAttributes = new AosArmorAttributes(this);
                }

                if (GetSaveFlag(flags, SaveFlag.SkillBonuses))
                {
                    m_AosSkillBonuses = new AosSkillBonuses(this, reader);
                }
                else
                {
                    m_AosSkillBonuses = new AosSkillBonuses(this);
                }

                if (GetSaveFlag(flags, SaveFlag.Resistances))
                {
                    m_AosResistances = new AosElementAttributes(this, reader);
                }
                else
                {
                    m_AosResistances = new AosElementAttributes(this);
                }

                if (GetSaveFlag(flags, SaveFlag.MaxHitPoints))
                {
                    m_MaxHitPoints = reader.ReadEncodedInt();
                }

                if (GetSaveFlag(flags, SaveFlag.HitPoints))
                {
                    m_HitPoints = reader.ReadEncodedInt();
                }

                if (GetSaveFlag(flags, SaveFlag.Crafter))
                {
                    m_Crafter = reader.ReadMobile();
                }

                if (GetSaveFlag(flags, SaveFlag.Quality))
                {
                    m_Quality = (ClothingQuality)reader.ReadEncodedInt();
                }
                else
                {
                    m_Quality = ClothingQuality.Regular;
                }

                if (GetSaveFlag(flags, SaveFlag.StrReq))
                {
                    m_StrReq = reader.ReadEncodedInt();
                }
                else
                {
                    m_StrReq = -1;
                }

                if (GetSaveFlag(flags, SaveFlag.PlayerConstructed))
                {
                    m_PlayerConstructed = true;
                }

                break;
            }

            case 4:
            {
                m_Resource = (CraftResource)reader.ReadInt();

                goto case 3;
            }

            case 3:
            {
                m_AosAttributes         = new AosAttributes(this, reader);
                m_AosClothingAttributes = new AosArmorAttributes(this, reader);
                m_AosSkillBonuses       = new AosSkillBonuses(this, reader);
                m_AosResistances        = new AosElementAttributes(this, reader);

                goto case 2;
            }

            case 2:
            {
                m_PlayerConstructed = reader.ReadBool();
                goto case 1;
            }

            case 1:
            {
                m_Crafter = reader.ReadMobile();
                m_Quality = (ClothingQuality)reader.ReadInt();
                break;
            }

            case 0:
            {
                m_Crafter = null;
                m_Quality = ClothingQuality.Regular;
                break;
            }
            }

            #region Sets Items
            if (m_SetAttributes == null)
            {
                m_SetAttributes = new AosAttributes(this);
            }

            if (m_SetSkillBonuses == null)
            {
                m_SetSkillBonuses = new AosSkillBonuses(this);
            }
            #endregion

            if (version < 2)
            {
                m_PlayerConstructed = true;                 // we don't know, so, assume it's crafted
            }
            if (version < 3)
            {
                m_AosAttributes         = new AosAttributes(this);
                m_AosClothingAttributes = new AosArmorAttributes(this);
                m_AosSkillBonuses       = new AosSkillBonuses(this);
                m_AosResistances        = new AosElementAttributes(this);
            }

            if (version < 4)
            {
                m_Resource = DefaultResource;
            }

            if (m_MaxHitPoints == 0 && m_HitPoints == 0)
            {
                m_HitPoints = m_MaxHitPoints = Utility.RandomMinMax(InitMinHits, InitMaxHits);
            }

            Mobile parent = Parent as Mobile;

            if (parent != null)
            {
                if (Core.AOS)
                {
                    m_AosSkillBonuses.AddTo(parent);
                }

                AddStatBonuses(parent);
                parent.CheckStatTimers();
            }
        }
        public override void Serialize(GenericWriter writer)
        {
            base.Serialize(writer);

            writer.Write((int)6);                // version

            #region Set Items

            SetFlag sflags = SetFlag.None;

            SetSaveFlag(ref sflags, SetFlag.Attributes, !m_SetAttributes.IsEmpty);
            SetSaveFlag(ref sflags, SetFlag.SkillBonuses, !m_SetSkillBonuses.IsEmpty);
            SetSaveFlag(ref sflags, SetFlag.SetHue, m_SetHue != 0);
            SetSaveFlag(ref sflags, SetFlag.LastEquipped, m_LastEquipped);
            SetSaveFlag(ref sflags, SetFlag.SetEquipped, m_SetEquipped);

            writer.WriteEncodedInt((int)sflags);

            if (GetSaveFlag(sflags, SetFlag.Attributes))
            {
                m_SetAttributes.Serialize(writer);
            }

            if (GetSaveFlag(sflags, SetFlag.SkillBonuses))
            {
                m_SetSkillBonuses.Serialize(writer);
            }

            if (GetSaveFlag(sflags, SetFlag.SetHue))
            {
                writer.WriteEncodedInt((int)m_SetHue);
            }

            if (GetSaveFlag(sflags, SetFlag.LastEquipped))
            {
                writer.Write((bool)m_LastEquipped);
            }

            if (GetSaveFlag(sflags, SetFlag.SetEquipped))
            {
                writer.Write((bool)m_SetEquipped);
            }


            #endregion

            SaveFlag flags = SaveFlag.None;

            SetSaveFlag(ref flags, SaveFlag.Resource, m_Resource != DefaultResource);
            SetSaveFlag(ref flags, SaveFlag.Attributes, !m_AosAttributes.IsEmpty);
            SetSaveFlag(ref flags, SaveFlag.ClothingAttributes, !m_AosClothingAttributes.IsEmpty);
            SetSaveFlag(ref flags, SaveFlag.SkillBonuses, !m_AosSkillBonuses.IsEmpty);
            SetSaveFlag(ref flags, SaveFlag.Resistances, !m_AosResistances.IsEmpty);
            SetSaveFlag(ref flags, SaveFlag.MaxHitPoints, m_MaxHitPoints != 0);
            SetSaveFlag(ref flags, SaveFlag.HitPoints, m_HitPoints != 0);
            SetSaveFlag(ref flags, SaveFlag.PlayerConstructed, m_PlayerConstructed != false);
            SetSaveFlag(ref flags, SaveFlag.Crafter, m_Crafter != null);
            SetSaveFlag(ref flags, SaveFlag.Quality, m_Quality != ClothingQuality.Regular);
            SetSaveFlag(ref flags, SaveFlag.StrReq, m_StrReq != -1);


            writer.WriteEncodedInt((int)flags);

            if (GetSaveFlag(flags, SaveFlag.Resource))
            {
                writer.WriteEncodedInt((int)m_Resource);
            }

            if (GetSaveFlag(flags, SaveFlag.Attributes))
            {
                m_AosAttributes.Serialize(writer);
            }

            if (GetSaveFlag(flags, SaveFlag.ClothingAttributes))
            {
                m_AosClothingAttributes.Serialize(writer);
            }

            if (GetSaveFlag(flags, SaveFlag.SkillBonuses))
            {
                m_AosSkillBonuses.Serialize(writer);
            }

            if (GetSaveFlag(flags, SaveFlag.Resistances))
            {
                m_AosResistances.Serialize(writer);
            }

            if (GetSaveFlag(flags, SaveFlag.MaxHitPoints))
            {
                writer.WriteEncodedInt((int)m_MaxHitPoints);
            }

            if (GetSaveFlag(flags, SaveFlag.HitPoints))
            {
                writer.WriteEncodedInt((int)m_HitPoints);
            }

            if (GetSaveFlag(flags, SaveFlag.Crafter))
            {
                writer.Write((Mobile)m_Crafter);
            }

            if (GetSaveFlag(flags, SaveFlag.Quality))
            {
                writer.WriteEncodedInt((int)m_Quality);
            }

            if (GetSaveFlag(flags, SaveFlag.StrReq))
            {
                writer.WriteEncodedInt((int)m_StrReq);
            }
        }
 private static bool GetSaveFlag(SetFlag flags, SetFlag toGet)
 {
     return((flags & toGet) != 0);
 }