Ejemplo n.º 1
0
        public BatteryBlockNetworkManager(BatteryBlockEntity parent, Object backingObject)
        {
            m_parent        = parent;
            m_backingObject = backingObject;

            MySandboxGame.Static.Invoke(RegisterPacketHandlers);
        }
Ejemplo n.º 2
0
        public BatteryBlockNetworkManager(BatteryBlockEntity parent, Object backingObject)
        {
            m_parent        = parent;
            m_backingObject = backingObject;

            Action action = RegisterPacketHandlers;

            SandboxGameAssemblyWrapper.Instance.EnqueueMainGameAction(action);
        }
Ejemplo n.º 3
0
        protected static void ReceiveCurrentPowerPacket <T>(ref T packet, Object netManager) where T : struct
        {
            try
            {
                //object result = BaseObject.InvokeEntityMethod( packet, BatteryBlockNetManagerCurrentStoredPowerPacketGetIdMethod );
                //object result = BaseObject.GetEntityFieldValue(packet, BatteryBlockNetManagerCurrentStoredPowerPacketGetIdField);
                object result = null;
                if (result == null)
                {
                    return;
                }
                long       entityId      = (long)result;
                BaseObject matchedEntity = GameEntityManager.GetEntity(entityId);
                if (matchedEntity == null)
                {
                    return;
                }
                if (!(matchedEntity is BatteryBlockEntity))
                {
                    return;
                }
                BatteryBlockEntity battery = (BatteryBlockEntity)matchedEntity;

                result = BaseObject.GetEntityFieldValue(packet, BatteryBlockNetManagerCurrentStoredPowerPacketValueField);
                if (result == null)
                {
                    return;
                }
                float packetPowerLevel = (float)result;
                if (packetPowerLevel == 1.0f)
                {
                    return;
                }

                BaseObject.SetEntityFieldValue(packet, BatteryBlockNetManagerCurrentStoredPowerPacketValueField, battery.CurrentStoredPower);

                Type       refPacketType           = packet.GetType( ).MakeByRefType( );
                MethodInfo basePacketHandlerMethod = BaseObject.GetStaticMethod(InternalType, BatteryBlockNetManagerCurrentPowerPacketReceiver, new Type[] { refPacketType, netManager.GetType( ) });
                basePacketHandlerMethod.Invoke(null, new object[] { packet, netManager });
            }
            catch (Exception ex)
            {
                ApplicationLog.BaseLog.Error(ex);
            }
        }