Esempio n. 1
0
        public void LogComponentMessage(int uid, ComponentFamily senderfamily, string sendertype,
                                        ComponentMessageType type)
        {
            if (!_logging)
                return;

            try
            {
                _loggerServiceClient.LogServerComponentMessage(uid, (int) senderfamily, sendertype, (int) type);
            }
            catch (CommunicationException e)
            {
            }
        }
Esempio n. 2
0
        public void LogOutgoingComponentNetMessage(int uid, ComponentFamily family, object[] parameters)
        {
            if (!_logging)
                return;

            for (int i = 0; i < parameters.Length; i++)
            {
                if (parameters[i] is Enum)
                    parameters[i] = (int) parameters[i];
            }
            try
            {
                _loggerServiceClient.LogClientOutgoingNetMessage(uid, (int) family, parameters);
            }
            catch (CommunicationException e)
            {
            }
        }
        /// <summary>
        /// Allows a component owned by this entity to send a message to a counterpart component on the
        /// counterpart entities on all clients.
        /// </summary>
        /// <param name="sendingEntity">Entity sending the message (also entity to send to)</param>   
        /// <param name="family">Family of the component sending the message</param>
        /// <param name="method">Net delivery method -- if null, defaults to NetDeliveryMethod.ReliableUnordered</param>
        /// <param name="messageParams">Parameters of the message</param>
        public void SendComponentNetworkMessage(Entity sendingEntity, ComponentFamily family,
                                                NetDeliveryMethod method = NetDeliveryMethod.ReliableUnordered,
                                                params object[] messageParams)
        {
            NetOutgoingMessage message = CreateEntityMessage();
            message.Write((byte)EntityMessage.ComponentMessage);
            message.Write(sendingEntity.Uid); //Write this entity's UID
            message.Write((byte) family);
            PackParams(message, messageParams);

            if (_messageProfiling)
            {
//Log the message
                var logger = IoCManager.Resolve<IMessageLogger>();
                logger.LogOutgoingComponentNetMessage(sendingEntity.Uid, family, messageParams);
            }

            //Send the message
            _networkManager.SendMessage(message, method);
        }
Esempio n. 4
0
        public void LogIncomingComponentNetMessage(long clientUID, int uid, EntityMessage entityMessage,
                                                   ComponentFamily componentFamily, object[] parameters)
        {
            if (!_logging)
                return;

            for (int i = 0; i < parameters.Length; i++)
            {
                if (parameters[i] is Enum)
                    parameters[i] = (int) parameters[i];
            }
            try
            {
                _loggerServiceClient.LogServerIncomingNetMessage(clientUID, uid, (int) entityMessage,
                                                                 (int) componentFamily, parameters);
            }
            catch (CommunicationException e)
            {
            }
        }
 public void SendComponentNetworkMessage(Entity sendingEntity, ComponentFamily family,
                                         [Optional] [DefaultParameterValue(NetDeliveryMethod.ReliableUnordered)] NetDeliveryMethod method, params object[] messageParams)
 {
     throw new NotImplementedException();
 }
 public MarshalComponentParameter(ComponentFamily family, ComponentParameter parameter)
 {
     Family = family;
     Parameter = parameter;
 }
Esempio n. 7
0
 public IncomingEntityComponentMessage(ComponentFamily componentFamily, List <object> messageParameters)
 {
     ComponentFamily   = componentFamily;
     MessageParameters = messageParameters;
 }
Esempio n. 8
0
        /// <summary>
        /// Allows a component owned by this entity to send a message to a counterpart component on the
        /// counterpart entities on all clients.
        /// </summary>
        /// <param name="sendingEntity">Entity sending the message (also entity to send to)</param>
        /// <param name="family">Family of the component sending the message</param>
        /// <param name="method">Net delivery method -- if null, defaults to NetDeliveryMethod.ReliableUnordered</param>
        /// <param name="recipient">Client connection to send to. If null, send to all.</param>
        /// <param name="messageParams">Parameters of the message</param>
        public void SendDirectedComponentNetworkMessage(IEntity sendingEntity, ComponentFamily family,
                                                        NetDeliveryMethod method,
                                                        NetConnection recipient, params object[] messageParams)
        {
            NetOutgoingMessage message = CreateEntityMessage();

            message.Write((byte)EntityMessage.ComponentMessage);
            message.Write(sendingEntity.Uid); //Write this entity's UID
            message.Write((byte)family);
            //Loop through the params and write them as is proper
            foreach (object messageParam in messageParams)
            {
                if (messageParam.GetType().IsSubclassOf(typeof(Enum)))
                {
                    message.Write((byte)NetworkDataType.d_enum);
                    message.Write((int)messageParam);
                }
                else if (messageParam is bool)
                {
                    message.Write((byte)NetworkDataType.d_bool);
                    message.Write((bool)messageParam);
                }
                else if (messageParam is byte)
                {
                    message.Write((byte)NetworkDataType.d_byte);
                    message.Write((byte)messageParam);
                }
                else if (messageParam is sbyte)
                {
                    message.Write((byte)NetworkDataType.d_sbyte);
                    message.Write((sbyte)messageParam);
                }
                else if (messageParam is ushort)
                {
                    message.Write((byte)NetworkDataType.d_ushort);
                    message.Write((ushort)messageParam);
                }
                else if (messageParam is short)
                {
                    message.Write((byte)NetworkDataType.d_short);
                    message.Write((short)messageParam);
                }
                else if (messageParam is int)
                {
                    message.Write((byte)NetworkDataType.d_int);
                    message.Write((int)messageParam);
                }
                else if (messageParam is uint)
                {
                    message.Write((byte)NetworkDataType.d_uint);
                    message.Write((uint)messageParam);
                }
                else if (messageParam is ulong)
                {
                    message.Write((byte)NetworkDataType.d_ulong);
                    message.Write((ulong)messageParam);
                }
                else if (messageParam is long)
                {
                    message.Write((byte)NetworkDataType.d_long);
                    message.Write((long)messageParam);
                }
                else if (messageParam is float)
                {
                    message.Write((byte)NetworkDataType.d_float);
                    message.Write((float)messageParam);
                }
                else if (messageParam is double)
                {
                    message.Write((byte)NetworkDataType.d_double);
                    message.Write((double)messageParam);
                }
                else if (messageParam is string)
                {
                    message.Write((byte)NetworkDataType.d_string);
                    message.Write((string)messageParam);
                }
                else if (messageParam is byte[])
                {
                    message.Write((byte)NetworkDataType.d_byteArray);
                    message.Write(((byte[])messageParam).Length);
                    message.Write((byte[])messageParam);
                }
                else
                {
                    throw new NotImplementedException("Cannot write specified type.");
                }
            }

            //Send the message
            if (recipient == null)
            {
                m_netServer.SendToAll(message, method);
            }
            else
            {
                m_netServer.SendMessage(message, recipient, method);
            }

            if (_messageProfiling)
            {
                var logger = IoCManager.Resolve <IMessageLogger>();
                logger.LogOutgoingComponentNetMessage(
                    (recipient == null) ? 0 : recipient.RemoteUniqueIdentifier,
                    sendingEntity.Uid,
                    family,
                    PackParamsForLog(messageParams));
            }
        }
Esempio n. 9
0
 public IEnumerable <IComponent> GetComponents(ComponentFamily family)
 {
     return(components[family]);
 }
Esempio n. 10
0
 public void SendDirectedComponentNetworkMessage(IEntity sendingEntity, ComponentFamily family,
                                                 NetDeliveryMethod method, NetConnection recipient,
                                                 params object[] messageParams)
 {
     throw new NotImplementedException();
 }
 public IncomingEntityComponentMessage(ComponentFamily componentFamily, List<object> messageParameters)
 {
     ComponentFamily = componentFamily;
     MessageParameters = messageParameters;
 }
 public void SendComponentNetworkMessage(Entity sendingEntity, ComponentFamily family,
                                         [Optional][DefaultParameterValue(NetDeliveryMethod.ReliableUnordered)] NetDeliveryMethod method, params object[] messageParams)
 {
     throw new NotImplementedException();
 }
Esempio n. 13
0
 /// <summary>
 /// Gets the component of the specified family, if it exists
 /// </summary>
 /// <param name="family">componentfamily to get</param>
 /// <returns></returns>
 public IComponent GetComponent(ComponentFamily family)
 {
     return(_components.ContainsKey(family) ? _components[family] : null);
 }
Esempio n. 14
0
 /// <summary>
 /// Checks to see if a component of a certain family exists
 /// </summary>
 /// <param name="family">componentfamily to check</param>
 /// <returns>true if component exists, false otherwise</returns>
 public bool HasComponent(ComponentFamily family)
 {
     return(_components.ContainsKey(family));
 }
        /// <summary>
        /// Allows a component owned by this entity to send a message to a counterpart component on the
        /// counterpart entities on all clients.
        /// </summary>
        /// <param name="sendingEntity">Entity sending the message (also entity to send to)</param>   
        /// <param name="family">Family of the component sending the message</param>
        /// <param name="method">Net delivery method -- if null, defaults to NetDeliveryMethod.ReliableUnordered</param>
        /// <param name="recipient">Client connection to send to. If null, send to all.</param>
        /// <param name="messageParams">Parameters of the message</param>
        public void SendDirectedComponentNetworkMessage(Entity sendingEntity, ComponentFamily family,
                                                        NetDeliveryMethod method,
                                                        NetConnection recipient, params object[] messageParams)
        {
            NetOutgoingMessage message = CreateEntityMessage();
            message.Write((byte) EntityMessage.ComponentMessage);
            message.Write(sendingEntity.Uid); //Write this entity's UID
            message.Write((byte) family);
            //Loop through the params and write them as is proper
            foreach (object messageParam in messageParams)
            {
                if (messageParam.GetType().IsSubclassOf(typeof (Enum)))
                {
                    message.Write((byte) NetworkDataType.d_enum);
                    message.Write((int) messageParam);
                }
                else if (messageParam is bool)
                {
                    message.Write((byte) NetworkDataType.d_bool);
                    message.Write((bool) messageParam);
                }
                else if (messageParam is byte)
                {
                    message.Write((byte) NetworkDataType.d_byte);
                    message.Write((byte) messageParam);
                }
                else if (messageParam is sbyte)
                {
                    message.Write((byte) NetworkDataType.d_sbyte);
                    message.Write((sbyte) messageParam);
                }
                else if (messageParam is ushort)
                {
                    message.Write((byte) NetworkDataType.d_ushort);
                    message.Write((ushort) messageParam);
                }
                else if (messageParam is short)
                {
                    message.Write((byte) NetworkDataType.d_short);
                    message.Write((short) messageParam);
                }
                else if (messageParam is int)
                {
                    message.Write((byte) NetworkDataType.d_int);
                    message.Write((int) messageParam);
                }
                else if (messageParam is uint)
                {
                    message.Write((byte) NetworkDataType.d_uint);
                    message.Write((uint) messageParam);
                }
                else if (messageParam is ulong)
                {
                    message.Write((byte) NetworkDataType.d_ulong);
                    message.Write((ulong) messageParam);
                }
                else if (messageParam is long)
                {
                    message.Write((byte) NetworkDataType.d_long);
                    message.Write((long) messageParam);
                }
                else if (messageParam is float)
                {
                    message.Write((byte) NetworkDataType.d_float);
                    message.Write((float) messageParam);
                }
                else if (messageParam is double)
                {
                    message.Write((byte) NetworkDataType.d_double);
                    message.Write((double) messageParam);
                }
                else if (messageParam is string)
                {
                    message.Write((byte) NetworkDataType.d_string);
                    message.Write((string) messageParam);
                }
                else if (messageParam is byte[])
                {
                    message.Write((byte) NetworkDataType.d_byteArray);
                    message.Write(((byte[]) messageParam).Length);
                    message.Write((byte[]) messageParam);
                }
                else
                {
                    throw new NotImplementedException("Cannot write specified type.");
                }
            }

            //Send the message
            if (recipient == null)
                m_netServer.SendToAll(message, method);
            else
                m_netServer.SendMessage(message, recipient, method);

            if (_messageProfiling)
            {
                var logger = IoCManager.Resolve<IMessageLogger>();
                logger.LogOutgoingComponentNetMessage(
                    (recipient == null) ? 0 : recipient.RemoteUniqueIdentifier,
                    sendingEntity.Uid,
                    family,
                    PackParamsForLog(messageParams));
            }
        }
Esempio n. 16
0
 private void SelectCFamily_SelectionChanged(object sender, SelectionChangedEventArgs e)
 {
     _componentFamilyFilter = (ComponentFamily)SelectCFamily.SelectedItem;
     UpdateItemsView();
 }
Esempio n. 17
0
 public List<Component> GetComponents(ComponentFamily family)
 {
     return components[family].Cast<Component>().ToList();
 }
Esempio n. 18
0
 public void SendComponentNetworkMessage(IEntity sendingEntity, ComponentFamily family,
                                         NetDeliveryMethod method = NetDeliveryMethod.ReliableUnordered, params object[] messageParams)
 {
     throw new NotImplementedException();
 }
Esempio n. 19
0
 public ComponentState(ComponentFamily family)
 {
     Family = family;
 }
 private void SelectCFamily_SelectionChanged(object sender, SelectionChangedEventArgs e)
 {
     _componentFamilyFilter = (ComponentFamily)SelectCFamily.SelectedItem;
     UpdateItemsView();
 }
Esempio n. 21
0
        public void LogIncomingComponentNetMessage(int uid, EntityMessage entityMessage, ComponentFamily componentFamily,
                                                   object[] parameters)
        {
            if (!_logging)
            {
                return;
            }

            for (int i = 0; i < parameters.Length; i++)
            {
                if (parameters[i] is Enum)
                {
                    parameters[i] = (int)parameters[i];
                }
            }
            try
            {
                _loggerServiceClient.LogClientIncomingNetMessage(uid, (int)entityMessage, (int)componentFamily,
                                                                 parameters);
            }
            catch (CommunicationException e)
            {
            }
        }
Esempio n. 22
0
 public ComponentState(ComponentFamily family)
 {
     Family = family;
 }
Esempio n. 23
0
 public MarshalComponentParameter(ComponentFamily family, ComponentParameter parameter)
 {
     Family    = family;
     Parameter = parameter;
 }
 public void SendDirectedComponentNetworkMessage(Entity sendingEntity, ComponentFamily family,
                                                 NetDeliveryMethod method, NetConnection recipient,
                                                 params object[] messageParams)
 {
     throw new NotImplementedException();
 }
Esempio n. 25
0
 public List <Component> GetComponents(ComponentFamily family)
 {
     return(components[family].Cast <Component>().ToList());
 }