Esempio n. 1
0
        protected ObjectBase()
		{
            int updateFieldInfoLen = _UpdateFieldInfos.Fields.Length;

			m_privateUpdateMask = new UpdateMask(updateFieldInfoLen);

			// we only need a distinction between private and public if we have any non-public update fields
			if (HasPrivateUpdateFields)
			{
				m_publicUpdateMask = new UpdateMask(updateFieldInfoLen);
			}
			else
			{
				m_publicUpdateMask = m_privateUpdateMask;
			}

			m_updateValues = new CompoundType[updateFieldInfoLen];

            Type = ObjectTypes.Object;
            SetFloat(ObjectFields.SCALE_X, 1.0f);
		}
Esempio n. 2
0
		protected void WriteSpontaneousUpdate(UpdateMask mask, UpdatePacket packet, Character receiver, UpdateFieldId[] indices, bool visible)
		{
			// create mask
            for (var i = 0; i < indices.Length; i++)
            {
            	var index = indices[i].RawId;
            	var field = UpdateFieldMgr.Get(ObjectTypeId).Fields[index];
				for (var j = 0; j < field.Size; j++)
				{
					mask.SetBit(index + j);
				}
            }

			// write mask
			mask.WriteTo(packet);

			// write values
			for (var i = mask.m_lowestIndex; i <= mask.m_highestIndex; i++)
			{
				if (mask.GetBit(i))
				{
					if (visible)
					{
						WriteUpdateValue(packet, receiver, i);
					}
					else
					{
						packet.Write(0);
					}
				}
			}
		}
Esempio n. 3
0
		public void SendSpontaneousUpdate(Character receiver, bool visible, params UpdateFieldId[] indices)
		{
			var highestIndex = 0;
			foreach (var index in indices)
			{
				if (index.RawId > highestIndex)
				{
					highestIndex = index.RawId;
				}
			}

			var mask = new UpdateMask(highestIndex);
			using (var packet = new UpdatePacket(1024))
			{
				packet.Position = 4;						// jump over header
				packet.Write(1);							// Update Count
				packet.Write((byte)UpdateType.Values);
				EntityId.WritePacked(packet);
				WriteSpontaneousUpdate(mask, packet, receiver, indices, visible);

				receiver.Send(packet);
			}
		}
Esempio n. 4
0
		protected void WriteUpdateValues(bool forCreation, Character receiver, UpdateFieldFlags relation)
		{
			UpdateMask mask;
			if (forCreation)
			{
				// completely new
				var pos = receiver.m_updatePacket.Position;
				mask = new UpdateMask(m_highestUsedUpdateIndex);
				receiver.m_updatePacket.Position = pos + 1 + (4 * mask.MaxBlockCount);	// skip over the index block
				for (var i = 0; i <= m_highestUsedUpdateIndex; i++)
				{
					var flags = _UpdateFieldInfos.FieldFlags[i];
					if (flags.HasAnyFlag(relation) && m_updateValues[i].UInt32 != 0)
					{
						mask.SetBit(i);
						WriteUpdateValue(receiver.m_updatePacket, receiver, i);
					}
				}
				var newPos = receiver.m_updatePacket.Position;
				receiver.m_updatePacket.Position = pos;
				mask.WriteFull(receiver.m_updatePacket);								// write the full index block
				receiver.m_updatePacket.Position = newPos;
				return;
				//WriteUpdateValues(receiver, relation, 0, _UpdateFieldInfos.Fields.Length, true);
			}

			if (relation.HasAnyFlag(UpdateFieldFlags.Private))
		    {
		        // Private
		        mask = m_privateUpdateMask;
		    }
		    else if (relation.HasAnyFlag(UpdateFieldFlags.OwnerOnly | UpdateFieldFlags.GroupOnly))
		    {
		        // Group or Owner
		        var pos = receiver.m_updatePacket.Position;
		        mask = new UpdateMask(m_privateUpdateMask.m_highestIndex);
		        receiver.m_updatePacket.Position = pos + 1 + (4 * mask.MaxBlockCount);	// skip over the index block
		        for (var i = m_privateUpdateMask.m_lowestIndex; i <= m_privateUpdateMask.m_highestIndex; i++)
		        {
		            var flags = _UpdateFieldInfos.FieldFlags[i];
					if (flags.HasAnyFlag(relation) &&
						(!flags.HasAnyFlag(UpdateFieldFlags.Public) || m_publicUpdateMask.GetBit(i)))
                    {
                        mask.SetBit(i);
                        WriteUpdateValue(receiver.m_updatePacket, receiver, i);
                    }
		        }
		        var newPos = receiver.m_updatePacket.Position;
		        receiver.m_updatePacket.Position = pos;
		        mask.WriteFull(receiver.m_updatePacket);								// write the full index block
		        receiver.m_updatePacket.Position = newPos;
		        //WriteUpdateValues(receiver, relation, m_privateUpdateMask.m_lowestIndex, m_privateUpdateMask.m_highestIndex, false);
		        return;
		    }
		    else
		    {
		        // Public
		        mask = m_publicUpdateMask;
		    }

		    mask.WriteTo(receiver.m_updatePacket);

		    for (var i = mask.m_lowestIndex; i <= mask.m_highestIndex; i++)
		    {
		        if (mask.GetBit(i))
		        {
		            WriteUpdateValue(receiver.m_updatePacket, receiver, i);
		        }
		    }
		}