コード例 #1
0
ファイル: MyUpdateData.cs プロジェクト: fluxit/SpaceEngineers
        public MyUpdateData()
        {
            m_frameDataPool = new MyConcurrentPool<MyUpdateFrame>(5, true);
            m_updateDataQueue = new MyConcurrentQueue<MyUpdateFrame>(5);

            CurrentUpdateFrame = m_frameDataPool.Get();
        }
コード例 #2
0
        public MyUpdateData()
        {
            m_frameDataPool   = new MyConcurrentPool <MyUpdateFrame>(5, true);
            m_updateDataQueue = new MyConcurrentQueue <MyUpdateFrame>(5);

            CurrentUpdateFrame = m_frameDataPool.Get();
        }
コード例 #3
0
        public MyReceiveQueue(int channel, Mode readMode = Mode.Synchronized, int defaultMessageCount = 1, Func<TimeSpan> timestampProvider = null)
        {
#if !XB1
            Trace.Assert(readMode != Mode.Spin, "Spin mode should be used only for testing purposes, it keeps CPU under heavy load!");
#else // XB1
            System.Diagnostics.Debug.Assert(readMode != Mode.Spin, "Spin mode should be used only for testing purposes, it keeps CPU under heavy load!");
#endif // XB1

            Disposed = false;
            Channel = channel;
            ReadMode = readMode;

            m_messagePool = new MyConcurrentPool<Message>(defaultMessageCount, true);
            m_receiveQueue = new MyConcurrentQueue<Message>(defaultMessageCount);
            m_timestampProvider = timestampProvider;

            if (readMode == Mode.Spin)
            {
                m_readThread = new Thread(ReceiveThread);
                m_readThread.CurrentCulture = CultureInfo.InvariantCulture;
                m_readThread.CurrentUICulture = CultureInfo.InvariantCulture;
                m_readThread.Start();
            }
            else if (readMode == Mode.Timer)
            {
                m_timerAction = new Action(ReceiveTimer);
                m_timer = new MyTimer(1, m_timerAction);
                m_timer.Start();
            }
        }
コード例 #4
0
        public MyReceiveQueue(int channel, Action <ulong> disconnectPeerOnError, Mode readMode = Mode.Synchronized, int defaultMessageCount = 1,
                              Func <MyTimeSpan> timestampProvider = null)
        {
#if !XB1
            Trace.Assert(readMode != Mode.Spin, "Spin mode should be used only for testing purposes, it keeps CPU under heavy load!");
#else // XB1
            System.Diagnostics.Debug.Assert(readMode != Mode.Spin, "Spin mode should be used only for testing purposes, it keeps CPU under heavy load!");
#endif // XB1

            Disposed = false;
            Channel  = channel;
            ReadMode = readMode;

            m_messagePool           = new MyConcurrentPool <Message>(defaultMessageCount, true);
            m_receiveQueue          = new MyConcurrentQueue <Message>(defaultMessageCount);
            m_timestampProvider     = timestampProvider;
            m_disconnectPeerOnError = disconnectPeerOnError;

            if (readMode == Mode.Spin)
            {
                m_readThread = new Thread(ReceiveThread);
                m_readThread.CurrentCulture   = CultureInfo.InvariantCulture;
                m_readThread.CurrentUICulture = CultureInfo.InvariantCulture;
                m_readThread.Start();
            }
            else if (readMode == Mode.Timer)
            {
                m_timerAction = new Action(ReceiveTimer);
                m_timer       = new MyTimer(1, m_timerAction);
                m_timer.Start();
            }
        }
コード例 #5
0
        public static ReturnHandle <T> Get <T>(this MyConcurrentPool <T> pool, out T result) where T : class, new()
        {
            var rh = new ReturnHandle <T>(pool);

            result = rh.Handle;
            return(rh);
        }
コード例 #6
0
        public MyReceiveQueue(int channel, Mode readMode = Mode.Synchronized, int defaultMessageCount = 1, Func <TimeSpan> timestampProvider = null)
        {
            Trace.Assert(readMode != Mode.Spin, "Spin mode should be used only for testing purposes, it keeps CPU under heavy load!");

            Disposed = false;
            Channel  = channel;
            ReadMode = readMode;

            m_messagePool       = new MyConcurrentPool <Message>(defaultMessageCount, true);
            m_receiveQueue      = new MyConcurrentQueue <Message>(defaultMessageCount);
            m_timestampProvider = timestampProvider;

            if (readMode == Mode.Spin)
            {
                m_readThread = new Thread(ReceiveThread);
                m_readThread.CurrentCulture   = CultureInfo.InvariantCulture;
                m_readThread.CurrentUICulture = CultureInfo.InvariantCulture;
                m_readThread.Start();
            }
            else if (readMode == Mode.Timer)
            {
                m_timerAction = new Action(ReceiveTimer);
                m_timer       = new MyTimer(1, m_timerAction);
                m_timer.Start();
            }
        }
コード例 #7
0
ファイル: Log.cs プロジェクト: keleios/WeaponCore
        public static void Close()
        {
            try
            {
                _threadedLineQueue.Clear();
                foreach (var pair in _instances)
                {
                    pair.Value.TextWriter.Flush();
                    pair.Value.TextWriter.Close();
                    pair.Value.TextWriter.Dispose();
                    pair.Value.Clean();

                    _logPool.Return(pair.Value);
                }
                _instances.Clear();
                _logPool.Clean();
                _logPool           = null;
                _instances         = null;
                _threadedLineQueue = null;
                _defaultInstance   = null;
            }
            catch (Exception e)
            {
            }
        }
コード例 #8
0
        internal void Init(Projectile p, MyConcurrentPool <Fragment> fragPool)
        {
            for (int i = 0; i < p.Info.AmmoDef.Shrapnel.Fragments; i++)
            {
                var frag = fragPool.Get();
                frag.System             = p.Info.System;
                frag.Ai                 = p.Info.Ai;
                frag.AmmoDef            = p.Info.System.AmmoTypes[p.Info.AmmoDef.Const.ShrapnelId].AmmoDef;
                frag.Target             = p.Info.Target.Entity;
                frag.Overrides          = p.Info.Overrides;
                frag.WeaponId           = p.Info.WeaponId;
                frag.MuzzleId           = p.Info.MuzzleId;
                frag.FiringCube         = p.Info.Target.FiringCube;
                frag.Guidance           = p.Info.EnableGuidance;
                frag.Origin             = !Vector3D.IsZero(p.Info.Hit.LastHit) ? p.Info.Hit.LastHit : p.Position;
                frag.OriginUp           = p.Info.OriginUp;
                frag.WeaponRng          = p.Info.WeaponRng;
                frag.IsFiringPlayer     = p.Info.IsFiringPlayer;
                frag.ClientSent         = p.Info.ClientSent;
                frag.PredictedTargetPos = p.PredictedTargetPos;
                frag.Velocity           = p.Velocity;
                frag.DeadSphere         = p.DeadSphere;
                frag.LockOnFireState    = p.Info.LockOnFireState;
                frag.IgnoreShield       = p.Info.ShieldBypassed && p.Info.AmmoDef.Const.ShieldDamageBypassMod > 0;
                var dirMatrix = Matrix.CreateFromDir(p.Info.Direction);
                var posValue  = MathHelper.ToRadians(MathHelper.Clamp(p.Info.AmmoDef.Shrapnel.Degrees, 0, 360));
                posValue *= 0.5f;
                var randomFloat1 = (float)(frag.WeaponRng.TurretRandom.NextDouble() * posValue);
                var randomFloat2 = (float)(frag.WeaponRng.TurretRandom.NextDouble() * MathHelper.TwoPi);
                frag.WeaponRng.TurretCurrentCounter += 2;
                var mutli = p.Info.AmmoDef.Shrapnel.Reverse ? -1 : 1;

                var shrapnelDir = Vector3.TransformNormal(mutli * -new Vector3(
                                                              MyMath.FastSin(randomFloat1) * MyMath.FastCos(randomFloat2),
                                                              MyMath.FastSin(randomFloat1) * MyMath.FastSin(randomFloat2),
                                                              MyMath.FastCos(randomFloat1)), dirMatrix);

                frag.Direction     = shrapnelDir;
                frag.PrimeEntity   = null;
                frag.TriggerEntity = null;
                if (frag.AmmoDef.Const.PrimeModel && frag.AmmoDef.Const.PrimeEntityPool.Count > 0)
                {
                    frag.PrimeEntity = frag.AmmoDef.Const.PrimeEntityPool.Get();
                }

                if (frag.AmmoDef.Const.TriggerModel && p.Info.System.Session.TriggerEntityPool.Count > 0)
                {
                    frag.TriggerEntity = p.Info.System.Session.TriggerEntityPool.Get();
                }

                if (frag.AmmoDef.Const.PrimeModel && frag.PrimeEntity == null || frag.AmmoDef.Const.TriggerModel && frag.TriggerEntity == null)
                {
                    p.Info.System.Session.FragmentsNeedingEntities.Add(frag);
                }

                Sharpnel.Add(frag);
            }
        }
コード例 #9
0
 static MyNetworkWriter()
 {
     m_descriptorPool  = new MyConcurrentPool <MyPacketDescriptor>(0, x => x.Reset(), 0x2710, null);
     m_bitStreamPool   = new MyConcurrentPool <MyPacketDataBitStream>(0, null, 0x2710, null);
     m_arrayPacketPool = new MyConcurrentPool <MyPacketDataArray>(0, null, 0x2710, null);
     m_crc32           = new Crc32();
     m_packetsTmp      = new List <IPacketData>();
     m_streamTmp       = new ByteStream(0xf4640, true);
 }
コード例 #10
0
        public override void LoadData()
        {
            try
            {
                foreach (var mod in Session.Mods)
                {
                    if (mod.PublishedFileId == 1365616918 || mod.PublishedFileId == 2189703321)
                    {
                        ShieldMod = true;
                    }
                    else if (mod.GetPath().Contains("AppData\\Roaming\\SpaceEngineers\\Mods\\DefenseShields"))
                    {
                        ShieldMod = true;
                    }
                    else if (mod.PublishedFileId == 1931509062 || mod.PublishedFileId == 1995197719 || mod.PublishedFileId == 2006751214 || mod.PublishedFileId == 2015560129)
                    {
                        ReplaceVanilla = true;
                    }
                    else if (mod.GetPath().Contains("AppData\\Roaming\\SpaceEngineers\\Mods\\VanillaReplacement"))
                    {
                        ReplaceVanilla = true;
                    }
                    else if (mod.PublishedFileId == 2123506303 || mod.PublishedFileId == 2496225055)
                    {
                        if (mod.Name != ModContext.ModId)
                        {
                            SuppressWc = true;
                        }
                    }
                    else if (mod.PublishedFileId == 2200451495)
                    {
                        WaterMod = true;
                    }
                }

                if (SuppressWc)
                {
                    return;
                }

                AllDefinitions                      = Static.GetAllDefinitions();
                SoundDefinitions                    = Static.GetSoundDefinitions();
                MyEntities.OnEntityCreate          += OnEntityCreate;
                MyAPIGateway.Gui.GuiControlCreated += MenuOpened;
                MyAPIGateway.Gui.GuiControlRemoved += MenuClosed;

                MyAPIGateway.Utilities.RegisterMessageHandler(7773, ArmorHandler);
                MyAPIGateway.Utilities.RegisterMessageHandler(7771, Handler);
                MyAPIGateway.Utilities.SendModMessage(7772, null);

                TriggerEntityModel = ModContext.ModPath + "\\Models\\Environment\\JumpNullField.mwm";
                TriggerEntityPool  = new MyConcurrentPool <MyEntity>(0, TriggerEntityClear, 10000, TriggerEntityActivator);

                ReallyStupidKeenShit();
            }
            catch (Exception ex) { Log.Line($"Exception in LoadData: {ex}"); }
        }
コード例 #11
0
        internal void Init(Projectile p, MyConcurrentPool <Fragment> fragPool)
        {
            for (int i = 0; i < p.Info.AmmoDef.Shrapnel.Fragments; i++)
            {
                var frag = fragPool.Get();

                frag.System             = p.Info.System;
                frag.Ai                 = p.Info.Ai;
                frag.AmmoDef            = p.Info.System.WeaponAmmoTypes[p.Info.AmmoDef.Const.ShrapnelId].AmmoDef;
                frag.Target             = p.Info.Target.Entity;
                frag.Overrides          = p.Info.Overrides;
                frag.WeaponId           = p.Info.WeaponId;
                frag.MuzzleId           = p.Info.MuzzleId;
                frag.FiringCube         = p.Info.Target.FiringCube;
                frag.Guidance           = p.Info.EnableGuidance;
                frag.Origin             = !Vector3D.IsZero(p.Hit.HitPos) ? p.Hit.HitPos : p.Position;
                frag.OriginUp           = p.Info.OriginUp;
                frag.Seed               = p.Info.Seed;
                frag.PredictedTargetPos = p.PredictedTargetPos;
                frag.Velocity           = p.Velocity;
                var dirMatrix = Matrix.CreateFromDir(p.Info.Direction);
                var posValue  = MathHelper.ToRadians(MathHelper.Clamp(p.Info.AmmoDef.Shrapnel.Degrees, 0, 360));
                posValue *= 0.5f;
                var randomFloat1 = MyUtils.GetRandomFloat(0.0f, posValue);
                var randomFloat2 = MyUtils.GetRandomFloat(0.0f, MathHelper.TwoPi);

                var mutli = p.Info.AmmoDef.Shrapnel.Reverse ? -1 : 1;

                var shrapnelDir = Vector3.TransformNormal(mutli * -new Vector3(
                                                              MyMath.FastSin(randomFloat1) * MyMath.FastCos(randomFloat2),
                                                              MyMath.FastSin(randomFloat1) * MyMath.FastSin(randomFloat2),
                                                              MyMath.FastCos(randomFloat1)), dirMatrix);

                frag.Direction = shrapnelDir;

                frag.PrimeEntity   = null;
                frag.TriggerEntity = null;
                if (frag.AmmoDef.Const.PrimeModel && frag.AmmoDef.Const.PrimeEntityPool.Count > 0)
                {
                    frag.PrimeEntity = frag.AmmoDef.Const.PrimeEntityPool.Get();
                }

                if (frag.AmmoDef.Const.TriggerModel && p.Info.Ai.Session.TriggerEntityPool.Count > 0)
                {
                    frag.TriggerEntity = p.Info.Ai.Session.TriggerEntityPool.Get();
                }

                if (frag.AmmoDef.Const.PrimeModel && frag.PrimeEntity == null || frag.AmmoDef.Const.TriggerModel && frag.TriggerEntity == null)
                {
                    p.Info.Ai.Session.FragmentsNeedingEntities.Add(frag);
                }

                Sharpnel.Add(frag);
            }
        }
コード例 #12
0
        public Caches(PaintGunMod main) : base(main)
        {
            Players = new MyConcurrentPool <List <IMyPlayer> >(
                clear: (l) => l.Clear(),
                activator: () => new List <IMyPlayer>(MyAPIGateway.Session.SessionSettings.MaxPlayers),
                expectedAllocations: 5,
                defaultCapacity: 1);

            AlreadyMirrored = new List <Vector3I>(8);
            PackedColors    = new List <uint>(Constants.COLOR_PALETTE_SIZE);
        }
コード例 #13
0
ファイル: ModCommunication.cs プロジェクト: thakyZ/Torch
        public static void Register()
        {
            MyLog.Default.WriteLineAndConsole("TORCH MOD: Registering mod communication.");
            _processing  = new BlockingCollection <MessageBase>(new ConcurrentQueue <MessageBase>());
            _playerCache = new List <IMyPlayer>();
            _messagePool = new MyConcurrentPool <IncomingMessage>(8);

            MyAPIGateway.Multiplayer.RegisterMessageHandler(NET_ID, MessageHandler);
            //background thread to handle de/compression and processing
            _closing = false;
            MyAPIGateway.Parallel.StartBackground(DoProcessing);
            MyLog.Default.WriteLineAndConsole("TORCH MOD: Mod communication registered successfully.");
        }
コード例 #14
0
        public void OnDeviceInit()
        {
            m_pool = new MyConcurrentPool<MyRenderContext>(m_poolSize, true);
            
            // Initialize all RCs
            m_tmpList.Clear();
            int poolSize = m_pool.Count;
            for (int i = 0; i < poolSize; i++)
            {
                MyRenderContext rc = m_pool.Get();
                m_tmpList.Add(rc);
                rc.Initialize();
            }
            foreach (var rc in m_tmpList)
                m_pool.Return(rc);
            m_tmpList.Clear();

            m_isDeviceInit = true;
        }
コード例 #15
0
        public void OnDeviceInit()
        {
            m_pool = new MyConcurrentPool <MyRenderContext>(MaxDeferredRCsCount, true);

            // Initialize all RCs
            m_tmpList.Clear();
            int poolSize = m_pool.Count;

            for (int i = 0; i < poolSize; i++)
            {
                MyRenderContext rc = m_pool.Get();
                m_tmpList.Add(rc);
                rc.Initialize();
            }
            foreach (var rc in m_tmpList)
            {
                m_pool.Return(rc);
            }
            m_tmpList.Clear();

            m_isDeviceInit = true;
        }
コード例 #16
0
 internal static void OnDeviceReset()
 {
     Immediate.Context = MyRender11.ImmediateContext;
     m_pool            = new MyConcurrentPool <MyRenderContext>(PoolSize, true);
 }
コード例 #17
0
 static MyQueryFactory()
 {
     m_disjointQueries  = new MyConcurrentPool <MyQuery>(MAX_FRAMES_LAG, true);
     m_timestampQueries = new MyConcurrentPool <MyQuery>(MAX_TIMESTAMP_QUERIES, true);
 }
コード例 #18
0
 public static ReturnHandle <T> GetHandle <T>(this MyConcurrentPool <T> pool) where T : class, new()
 {
     return(new ReturnHandle <T>(pool));
 }
コード例 #19
0
 public void Dispose()
 {
     _pool.Return(Handle);
     _pool  = null;
     Handle = null;
 }
コード例 #20
0
 public ReturnHandle(MyConcurrentPool <T> pool)
 {
     _pool  = pool;
     Handle = pool.Get();
 }
コード例 #21
0
ファイル: MyQuery.cs プロジェクト: fluxit/SpaceEngineers
 static MyQueryFactory()
 {
     m_disjointQueries = new MyConcurrentPool<MyQuery>(MaxFramesLag, true);
     m_timestampQueries = new MyConcurrentPool<MyQuery>(MaxTimestampQueries, true);
 }
コード例 #22
0
        public AmmoConstants(WeaponAmmoTypes ammo, WeaponDefinition wDef, Session session, WeaponSystem system)
        {
            MyInventory.GetItemVolumeAndMass(ammo.AmmoDefinitionId, out MagMass, out MagVolume);

            MagazineDef    = MyDefinitionManager.Static.GetAmmoMagazineDefinition(ammo.AmmoDefinitionId);
            TracerMaterial = MyStringId.GetOrCompute(ammo.AmmoDef.AmmoGraphics.Lines.TracerMaterial);
            TrailMaterial  = MyStringId.GetOrCompute(ammo.AmmoDef.AmmoGraphics.Lines.Trail.Material);

            if (ammo.AmmoDefinitionId.SubtypeId.String != "Energy" || ammo.AmmoDefinitionId.SubtypeId.String == string.Empty)
            {
                AmmoItem = new MyPhysicalInventoryItem()
                {
                    Amount = 1, Content = MyObjectBuilderSerializer.CreateNewObject <MyObjectBuilder_AmmoMagazine>(ammo.AmmoDefinitionId.SubtypeName)
                }
            }
            ;

            for (int i = 0; i < wDef.Ammos.Length; i++)
            {
                var ammoType = wDef.Ammos[i];
                if (ammoType.AmmoRound.Equals(ammo.AmmoDef.Shrapnel.AmmoRound))
                {
                    ShrapnelId = i;
                }
            }

            IsMine             = ammo.AmmoDef.Trajectory.Guidance == DetectFixed || ammo.AmmoDef.Trajectory.Guidance == DetectSmart || ammo.AmmoDef.Trajectory.Guidance == DetectTravelTo;
            IsField            = ammo.AmmoDef.Trajectory.FieldTime > 0;
            IsHybrid           = ammo.AmmoDef.HybridRound;
            IsTurretSelectable = !ammo.IsShrapnel || ammo.AmmoDef.HardPointUsable;


            AmmoParticle        = ammo.AmmoDef.AmmoGraphics.Particles.Ammo.Name != string.Empty;
            AmmoParticleShrinks = ammo.AmmoDef.AmmoGraphics.Particles.Ammo.ShrinkByDistance;
            HitParticleShrinks  = ammo.AmmoDef.AmmoGraphics.Particles.Hit.ShrinkByDistance;

            HitParticle = ammo.AmmoDef.AmmoGraphics.Particles.Hit.Name != string.Empty;

            DrawLine          = ammo.AmmoDef.AmmoGraphics.Lines.Tracer.Enable;
            LineColorVariance = ammo.AmmoDef.AmmoGraphics.Lines.ColorVariance.Start > 0 && ammo.AmmoDef.AmmoGraphics.Lines.ColorVariance.End > 0;
            LineWidthVariance = ammo.AmmoDef.AmmoGraphics.Lines.WidthVariance.Start > 0 || ammo.AmmoDef.AmmoGraphics.Lines.WidthVariance.End > 0;
            SpeedVariance     = ammo.AmmoDef.Trajectory.SpeedVariance.Start > 0 || ammo.AmmoDef.Trajectory.SpeedVariance.End > 0;
            RangeVariance     = ammo.AmmoDef.Trajectory.RangeVariance.Start > 0 || ammo.AmmoDef.Trajectory.RangeVariance.End > 0;
            TrailWidth        = ammo.AmmoDef.AmmoGraphics.Lines.Trail.CustomWidth > 0 ? ammo.AmmoDef.AmmoGraphics.Lines.Trail.CustomWidth : ammo.AmmoDef.AmmoGraphics.Lines.Tracer.Width;
            TargetOffSet      = ammo.AmmoDef.Trajectory.Smarts.Inaccuracy > 0;

            TargetLossTime   = ammo.AmmoDef.Trajectory.TargetLossTime > 0 ? ammo.AmmoDef.Trajectory.TargetLossTime : int.MaxValue;
            CanZombie        = TargetLossTime > 0 && TargetLossTime != int.MaxValue && !IsMine;
            MaxLifeTime      = ammo.AmmoDef.Trajectory.MaxLifeTime > 0 ? ammo.AmmoDef.Trajectory.MaxLifeTime : int.MaxValue;
            MaxChaseTime     = ammo.AmmoDef.Trajectory.Smarts.MaxChaseTime > 0 ? ammo.AmmoDef.Trajectory.Smarts.MaxChaseTime : int.MaxValue;
            MaxObjectsHit    = ammo.AmmoDef.ObjectsHit.MaxObjectsHit > 0 ? ammo.AmmoDef.ObjectsHit.MaxObjectsHit : int.MaxValue;
            BaseDamage       = ammo.AmmoDef.BaseDamage;
            MaxTargets       = ammo.AmmoDef.Trajectory.Smarts.MaxTargets;
            TargetLossDegree = ammo.AmmoDef.Trajectory.TargetLossDegree > 0 ? (float)Math.Cos(MathHelper.ToRadians(ammo.AmmoDef.Trajectory.TargetLossDegree)) : 0;

            ShieldModifier  = ammo.AmmoDef.DamageScales.Shields.Modifier > 0 ? ammo.AmmoDef.DamageScales.Shields.Modifier : 1;
            ShieldBypassMod = ammo.AmmoDef.DamageScales.Shields.BypassModifier > 0 && ammo.AmmoDef.DamageScales.Shields.BypassModifier < 1 ? ammo.AmmoDef.DamageScales.Shields.BypassModifier : 1;
            AmmoSkipAccel   = ammo.AmmoDef.Trajectory.AccelPerSec <= 0;
            FeelsGravity    = ammo.AmmoDef.Trajectory.GravityMultiplier > 0;

            MaxTrajectory    = ammo.AmmoDef.Trajectory.MaxTrajectory;
            MaxTrajectorySqr = MaxTrajectory * MaxTrajectory;
            HasBackKickForce = ammo.AmmoDef.BackKickForce > 0;

            MaxLateralThrust = MathHelperD.Clamp(ammo.AmmoDef.Trajectory.Smarts.MaxLateralThrust, 0.000001, 1);

            Fields(ammo.AmmoDef, out PulseInterval, out PulseChance, out Pulse);
            AreaEffects(ammo.AmmoDef, out AreaEffect, out AreaEffectDamage, out AreaEffectSize, out DetonationDamage, out AmmoAreaEffect, out AreaRadiusSmall, out AreaRadiusLarge, out DetonateRadiusSmall, out DetonateRadiusLarge, out Ewar, out EwarEffect, out EwarTriggerRange);

            DamageScales(ammo.AmmoDef, out DamageScaling, out FallOffScaling, out ArmorScaling, out CustomDamageScales, out CustomBlockDefinitionBasesToScales, out SelfDamage, out VoxelDamage);
            Beams(ammo.AmmoDef, out IsBeamWeapon, out VirtualBeams, out RotateRealBeam, out ConvergeBeams, out OneHitParticle, out OffsetEffect);
            CollisionShape(ammo.AmmoDef, out CollisionIsLine, out CollisionSize, out TracerLength);
            SmartsDelayDistSqr = (CollisionSize * ammo.AmmoDef.Trajectory.Smarts.TrackingDelay) * (CollisionSize * ammo.AmmoDef.Trajectory.Smarts.TrackingDelay);
            PrimeEntityPool    = Models(ammo.AmmoDef, wDef, out PrimeModel, out TriggerModel, out ModelPath);
            Energy(ammo, system, wDef, out EnergyAmmo, out MustCharge, out Reloadable, out EnergyMagSize, out BurstMode, out HasShotReloadDelay);
            Sound(ammo.AmmoDef, session, out HitSound, out AmmoTravelSound, out HitSoundDistSqr, out AmmoTravelSoundDistSqr, out AmmoSoundMaxDistSqr);
            MagazineSize = EnergyAmmo ? EnergyMagSize : MagazineDef.Capacity;
            GetPeakDps(ammo, system, wDef, out PeakDps, out ShotsPerSec, out BaseDps, out AreaDps, out DetDps);

            DesiredProjectileSpeed = (float)(!IsBeamWeapon ? ammo.AmmoDef.Trajectory.DesiredSpeed : MaxTrajectory * MyEngineConstants.UPDATE_STEPS_PER_SECOND);
            Trail = ammo.AmmoDef.AmmoGraphics.Lines.Trail.Enable;
        }
コード例 #23
0
ファイル: ModCommunication.cs プロジェクト: thakyZ/Torch
        public static void DoProcessing()
        {
            while (!_closing)
            {
                try
                {
                    MessageBase m;
                    try
                    {
                        m = _processing.Take();
                    }
                    catch
                    {
                        continue;
                    }

                    MyLog.Default.WriteLineAndConsole($"Processing message: {m.GetType().Name}");

                    if (m is IncomingMessage) //process incoming messages
                    {
                        MessageBase i;
                        try
                        {
                            var o = MyCompression.Decompress(m.CompressedData);
                            m.CompressedData = null;
                            _messagePool.Return((IncomingMessage)m);
                            i = MyAPIGateway.Utilities.SerializeFromBinary <MessageBase>(o);
                        }
                        catch (Exception ex)
                        {
                            MyLog.Default.WriteLineAndConsole($"TORCH MOD: Failed to deserialize message! {ex}");
                            continue;
                        }

                        if (TorchModCore.Debug)
                        {
                            MyAPIGateway.Utilities.ShowMessage("Torch", $"Received message of type {i.GetType().Name}");
                        }

                        if (MyAPIGateway.Multiplayer.IsServer)
                        {
                            i.ProcessServer();
                        }
                        else
                        {
                            i.ProcessClient();
                        }
                    }
                    else //process outgoing messages
                    {
                        if (TorchModCore.Debug)
                        {
                            MyAPIGateway.Utilities.ShowMessage("Torch", $"Sending message of type {m.GetType().Name}");
                        }

                        var b = MyAPIGateway.Utilities.SerializeToBinary(m);
                        m.CompressedData = MyCompression.Compress(b);

                        switch (m.TargetType)
                        {
                        case MessageTarget.Single:
                            MyAPIGateway.Multiplayer.SendMessageTo(NET_ID, m.CompressedData, m.Target);
                            break;

                        case MessageTarget.Server:
                            MyAPIGateway.Multiplayer.SendMessageToServer(NET_ID, m.CompressedData);
                            break;

                        case MessageTarget.AllClients:
                            MyAPIGateway.Players.GetPlayers(_playerCache);
                            foreach (var p in _playerCache)
                            {
                                if (p.SteamUserId == MyAPIGateway.Multiplayer.MyId)
                                {
                                    continue;
                                }
                                MyAPIGateway.Multiplayer.SendMessageTo(NET_ID, m.CompressedData, p.SteamUserId);
                            }

                            break;

                        case MessageTarget.AllExcept:
                            MyAPIGateway.Players.GetPlayers(_playerCache);
                            foreach (var p in _playerCache)
                            {
                                if (p.SteamUserId == MyAPIGateway.Multiplayer.MyId || m.Ignore.Contains(p.SteamUserId))
                                {
                                    continue;
                                }
                                MyAPIGateway.Multiplayer.SendMessageTo(NET_ID, m.CompressedData, p.SteamUserId);
                            }

                            break;

                        default:
                            throw new Exception();
                        }

                        _playerCache.Clear();
                    }
                }
                catch (Exception ex)
                {
                    MyLog.Default.WriteLineAndConsole($"TORCH MOD: Exception occurred in communication thread! {ex}");
                }
            }

            MyLog.Default.WriteLineAndConsole("TORCH MOD: INFO: Communication thread shut down successfully! THIS IS NOT AN ERROR");
            //exit signal received. Clean everything and GTFO
            _processing?.Dispose();
            _processing = null;
            _messagePool?.Clean();
            _messagePool = null;
            _playerCache = null;
        }
コード例 #24
0
 internal static void OnDeviceReset()
 {
     m_pool = new MyConcurrentPool <MyRenderContext>(PoolSize, true);
 }
コード例 #25
0
ファイル: ModCommunication.cs プロジェクト: kingpeti/Torch
        public static void DoProcessing()
        {
            while (!_closing)
            {
                try
                {
                    var m = _processing.Take();
                    MyLog.Default.WriteLineAndConsole($"Processing message: {m.GetType().Name}");

                    if (m is IncomingMessage)
                    {
                        MessageBase i;
                        try
                        {
                            var o = MyCompression.Decompress(m.CompressedData);
                            m.CompressedData = null;
                            _messagePool.Return((IncomingMessage)m);
                            i = MyAPIGateway.Utilities.SerializeFromBinary <MessageBase>(o);
                        }
                        catch (Exception ex)
                        {
                            MyLog.Default.WriteLineAndConsole($"TORCH MOD: Failed to deserialize message! {ex}");
                            continue;
                        }

                        if (MyAPIGateway.Multiplayer.IsServer)
                        {
                            i.ProcessServer();
                        }
                        else
                        {
                            i.ProcessClient();
                        }
                    }
                    else
                    {
                        var b = MyAPIGateway.Utilities.SerializeToBinary(m);
                        m.CompressedData = MyCompression.Compress(b);

                        MyAPIGateway.Utilities.InvokeOnGameThread(() =>
                        {
                            switch (m.TargetType)
                            {
                            case MessageTarget.Single:
                                MyAPIGateway.Multiplayer.SendMessageTo(NET_ID, m.CompressedData, m.Target);
                                break;

                            case MessageTarget.Server:
                                MyAPIGateway.Multiplayer.SendMessageToServer(NET_ID, m.CompressedData);
                                break;

                            case MessageTarget.AllClients:
                                MyAPIGateway.Players.GetPlayers(_playerCache);
                                foreach (var p in _playerCache)
                                {
                                    if (p.SteamUserId == MyAPIGateway.Multiplayer.MyId)
                                    {
                                        continue;
                                    }
                                    MyAPIGateway.Multiplayer.SendMessageTo(NET_ID, m.CompressedData, p.SteamUserId);
                                }
                                break;

                            case MessageTarget.AllExcept:
                                MyAPIGateway.Players.GetPlayers(_playerCache);
                                foreach (var p in _playerCache)
                                {
                                    if (p.SteamUserId == MyAPIGateway.Multiplayer.MyId || m.Ignore.Contains(p.SteamUserId))
                                    {
                                        continue;
                                    }
                                    MyAPIGateway.Multiplayer.SendMessageTo(NET_ID, m.CompressedData, p.SteamUserId);
                                }
                                break;

                            default:
                                throw new Exception();
                            }
                            _playerCache.Clear();
                        });
                    }
                }
                catch (Exception ex)
                {
                    MyLog.Default.WriteLineAndConsole($"TORCH MOD: Exception occurred in communication thread! {ex}");
                }
            }

            MyLog.Default.WriteLineAndConsole("TORCH MOD: COMMUNICATION THREAD: EXIT SIGNAL RECEIVED!");
            //exit signal received. Clean everything and GTFO
            _processing?.Dispose();
            _processing = null;
            _messagePool?.Clean();
            _messagePool = null;
            _playerCache = null;
        }
コード例 #26
0
 internal static void OnDeviceReset()
 {
     Immediate.Context = MyRender11.ImmediateContext;
     m_pool = new MyConcurrentPool<MyRenderContext>(PoolSize, true);
 }
コード例 #27
0
 static MyQueryFactory()
 {
     m_disjointQueries  = new MyConcurrentPool <MyQuery>(MaxFramesLag, true);
     m_timestampQueries = new MyConcurrentPool <MyQuery>(MaxTimestampQueries, true);
 }