static void OnUpdateShowerTarget(ref UpdateShowerTargetMsg msg, MyNetworkClient sender)
 {
     if (msg.HasTarget)
         MyMeteorShower.CurrentTarget = new BoundingSphere(msg.Center, msg.Radius);
     else
         MyMeteorShower.CurrentTarget = null;
 }
 static void ChangeOreDetector(ref ChangeOreDetectorMsg msg, MyNetworkClient sender)
 {
     MyEntity entity;
     if (MyEntities.TryGetEntityById(msg.EntityId, out entity))
         (entity as MyOreDetector).BroadcastUsingAntennas = msg.BroadcastUsingAntennas;
 
 }
示例#3
0
 static void ProxyExplosionSuccess(ref ProxyExplosionMsg msg, MyNetworkClient sender)
 {
     //Dont create explosion particles if message is bufferred, it is useless to create hundred explosion after scene load
     if (MySession.Ready)
     {
         //  Create explosion
         MyExplosionInfo info = new MyExplosionInfo()
         {
             PlayerDamage = 0,
             //Damage = m_ammoProperties.Damage,
             Damage = 200,
             ExplosionType = msg.Type,
             ExplosionSphere = new BoundingSphere(msg.Center, msg.Radius),
             LifespanMiliseconds = MyExplosionsConstants.EXPLOSION_LIFESPAN,
             CascadeLevel = 0,
             HitEntity = null,
             ParticleScale = msg.ParticleScale,
             OwnerEntity = null,
             Direction = Vector3.Forward,
             VoxelExplosionCenter = msg.VoxelCenter,
             ExplosionFlags = MyExplosionFlags.CREATE_DEBRIS | MyExplosionFlags.CREATE_DECALS | MyExplosionFlags.CREATE_PARTICLE_EFFECT | MyExplosionFlags.CREATE_SHRAPNELS,
             VoxelCutoutScale = 1.0f,
             PlaySound = true,
             ObjectsRemoveDelayInMiliseconds = 40
         };
         MyExplosions.AddExplosion(ref info, false);
     }
 }
示例#4
0
 static void OverrideGyroControlSuccess(ref OverrideGyroControlMsg msg, MyNetworkClient sender)
 {
     MyEntity entity;
     MyEntities.TryGetEntityById(msg.EntityId, out entity);
     var block = entity as MyGyro;
     if (block != null)
         block.SetGyroOverride(msg.Override);
 }
示例#5
0
 static void ChangeGyroPowerSuccess(ref ChangeGyroPowerMsg msg, MyNetworkClient sender)
 {
     MyEntity entity;
     MyEntities.TryGetEntityById(msg.EntityId, out entity);
     var block = entity as MyGyro;
     if (block != null)
         block.GyroPower = msg.GyroPower;
 }
示例#6
0
        static void OnCurrentAmmoCountChangedMsg(ref CurrentAmmoCountChangedMsg msg, MyNetworkClient sender)
        {
            Debug.Assert(!Sync.IsServer);

            var handler = AmmoCountChanged;
            if (handler != null)
                handler(msg.WeaponId, msg.AmmoCount);
        }
示例#7
0
 static void ChangeThrustOverrideSuccess(ref ChangeThrustOverrideMsg msg, MyNetworkClient sender)
 {
     MyEntity entity;
     MyEntities.TryGetEntityById(msg.EntityId, out entity);
     var block = entity as MyThrust;
     if (block != null)
         block.SetThrustOverride(msg.ThrustOverride);
 }
 static void StopManipulationCallback(ref StopManipulationMsg msg, MyNetworkClient sender)
 {
     MyManipulationTool manipulationTool;
     if (MyEntities.TryGetEntityById(msg.EntityId, out manipulationTool))
     {
         manipulationTool.StopManipulation();
     }
 }
 static void ChangeGravityGeneratorRequest(ref ChangeGravityGeneratorMsg msg, MyNetworkClient sender)
 {
     MyEntity entity;
     MyEntities.TryGetEntityById(msg.EntityId, out entity);
     if (entity is MyGravityGeneratorSphere)
     {
         Sync.Layer.SendMessageToAllAndSelf(ref msg, MyTransportMessageEnum.Success);
     }
 }
 static void OnRemoveEnvironmentItemMessage(ref RemoveEnvironmentItemMsg msg, MyNetworkClient sender)
 {
     MyEntity entity;
     if (MyEntities.TryGetEntityById(msg.EntityId, out entity))
     {
         if (OnRemoveEnvironmentItem != null)
             OnRemoveEnvironmentItem(entity, msg.ItemInstanceId);
     }
 }
示例#11
0
 static void CapacitySyncSuccess(ref CapacitySyncMsg msg, MyNetworkClient sender)
 {
     MyCharacter owner;
     MyEntities.TryGetEntityById(msg.EntityId, out owner);
     if (owner != null)
     {
         MyBattery.Friend.OnSyncCapacitySuccess(owner.SuitBattery, msg.RemainingCapacity);
     }
 }
 static void EndShootSuccess(ref EndShootMessage msg, MyNetworkClient sender)
 {
     MyUserControllableGun block = null;
     MyEntities.TryGetEntityById(msg.EntityId, out block);
     if (block != null)
     {
         block.EndShoot();
     }
 }
示例#13
0
 static void ChangeUseConveyorSystemSucess(ref ChangeUseConveyorsMsg msg, MyNetworkClient sender)
 {
     MyEntity entity;
     if (MyEntities.TryGetEntityById(msg.GetEntityId(), out entity))
     {
         if (entity as IMyInventoryOwner != null)
             (entity as IMyInventoryOwner).UseConveyorSystem = msg.Value;
     }
 }
 static void StartManipulationCallback(ref StartManipulationMsg msg, MyNetworkClient sender)
 {
     MyManipulationTool manipulationTool;
     MyEntity otherEntity;
     if (MyEntities.TryGetEntityById(msg.EntityId, out manipulationTool) && MyEntities.TryGetEntityById(msg.OtherEntity, out otherEntity))
     {
         manipulationTool.StartManipulation(msg.ToolState, otherEntity, msg.HitPosition, ref msg.OwnerWorldHeadMatrix, true);
     }
 }
示例#15
0
 static void ChangeDoorSuccess(ref ChangeDoorMsg msg, MyNetworkClient sender)
 {
     MyEntity entity;
     MyEntities.TryGetEntityById(msg.EntityId, out entity);
     MyDoor block = entity as MyDoor;
     if (block != null)
     {
         block.Open = msg.Open;
     }
 }
 static void ChangeRadioBroadcasterRequest(ref ChangeRadioAntennaMsg msg, MyNetworkClient sender)
 {
     MyEntity entity;
     MyEntities.TryGetEntityById(msg.EntityId, out entity);
     var broadcasterOwner = entity as IMyComponentOwner<MyDataBroadcaster>;
     if (broadcasterOwner != null)
     {
         Sync.Layer.SendMessageToAllAndSelf(ref msg, MyTransportMessageEnum.Success);
     }
 }
        static void OnClearSlotRequest(ref PlayerToolbarClearSlotMsg msg, MyNetworkClient sender)
        {
            var playerId = new PlayerId(sender.SteamUserId, msg.PlayerSerialId);
            if (!MySession.Static.Toolbars.ContainsToolbar(playerId))
                return;

            var toolbar = MySession.Static.Toolbars.TryGetPlayerToolbar(playerId);

            toolbar.SetItemAtIndex(msg.Index, null);
        }
 static void ModMessageRecievedUnreliable(ref CustomModMsgUnreliable msg, MyNetworkClient sender)
 {
     List<Action<byte[]>> actionsList = null;
     if (m_registeredListeners.TryGetValue(msg.ModID, out actionsList) && actionsList != null)
     {
         foreach (var action in actionsList)
         {
             action(msg.Message);
         }
     }
 }
示例#19
0
 static void ChangeParamsSuccess(ref ChangeParamsMsg msg, MyNetworkClient sender)
 {
     MyEntity entity;
     MyEntities.TryGetEntityById(msg.EntityId, out entity);
     var block = entity as MySpaceBall;
     if (block != null)
     {
         block.VirtualMass = msg.VirtualMass;
         block.Friction = msg.Friction;
     }
 }
示例#20
0
 private static void UseRequest(ref UseMsg msg, MyNetworkClient sender)
 {
     MyCharacter user;
     MyMedicalRoom medicalRoom;
     MyEntities.TryGetEntityById(msg.EntityId, out medicalRoom);
     MyEntities.TryGetEntityById(msg.UsedByEntityId, out user);
     if (user != null && medicalRoom != null)
     {
         Sync.Layer.SendMessageToAllAndSelf(ref msg, MyTransportMessageEnum.Success);
     }
 }
 static void ChangeGravityGeneratorSuccess(ref ChangeGravityGeneratorMsg msg, MyNetworkClient sender)
 {
     MyEntity entity;
     MyEntities.TryGetEntityById(msg.EntityId, out entity);
     var block = entity as MyGravityGeneratorSphere;
     if (block != null)
     {
         block.Radius = msg.Radius;
         block.GravityAcceleration = msg.GravityAcceleration;
     }
 }
示例#22
0
 static void DoDamage(ref DoDamageMsg msg, MyNetworkClient sender)
 {
     MyEntity ent;
     if(!MyEntities.TryGetEntityById(msg.DestroyableEntityId, out ent))
         return;
     if (!(ent is IMyDestroyableObject))
     {
         Debug.Fail("Damage can be done to destroyable only");
         return;
     }
     (ent as IMyDestroyableObject).DoDamage(msg.Damage, msg.Type, false);
 }
 static void StartManipulationCallback(ref StartManipulationMsg msg, MyNetworkClient sender)
 {
     MyManipulationTool manipulationTool;
     MyEntity otherEntity;
     if (MyEntities.TryGetEntityById(msg.EntityId, out manipulationTool) && MyEntities.TryGetEntityById(msg.OtherEntity, out otherEntity))
     {
         manipulationTool.StartManipulation(msg.ToolState, otherEntity, msg.HitPosition, ref msg.OwnerWorldHeadMatrix, true);
         if (Sync.IsServer)
         {
             Sync.Layer.SendMessageToAllButOne(ref msg, sender.SteamUserId);
         }
     }
 }
示例#24
0
 static void ChangeOreDetector(ref ChangeOreDetectorMsg msg, MyNetworkClient sender)
 {
     MyEntity entity;
     if (MyEntities.TryGetEntityById(msg.EntityId, out entity))
     {
         (entity as MyOreDetector).BroadcastUsingAntennas = msg.BroadcastUsingAntennas;
         if (Sync.IsServer)
         {
             Sync.Layer.SendMessageToAllButOne(ref msg, sender.SteamUserId);
         }
     }
 
 }
 static void EndShootSuccess(ref EndShootMessage msg, MyNetworkClient sender)
 {
     MyUserControllableGun block = null;
     MyEntities.TryGetEntityById(msg.EntityId, out block);
     if (block != null)
     {
         block.EndShoot();
         if (Sync.IsServer)
         {
             Sync.Layer.SendMessageToAllButOne(ref msg, sender.SteamUserId, MyTransportMessageEnum.Success);
         }
     }
 }
示例#26
0
 protected override void ReadInternal(BitStream stream, MyNetworkClient sender, MyEntity controlledEntity)
 {
     Context = (MyContextKind)stream.ReadInt32(2);
     if (Context != MyContextKind.None)
     {
         long entityId = stream.ReadInt64();
         ContextEntity = MyEntities.GetEntityByIdOrDefault(entityId);
     }
     else
     {
         ContextEntity = null;
     }
 }
示例#27
0
 static void ChangeGyroPowerSuccess(ref ChangeGyroPowerMsg msg, MyNetworkClient sender)
 {
     MyEntity entity;
     MyEntities.TryGetEntityById(msg.EntityId, out entity);
     var block = entity as MyGyro;
     if (block != null)
     {
         block.GyroPower = msg.GyroPower;
         if (Sync.IsServer)
         {
             Sync.Layer.SendMessageToAllButOne(ref msg, sender.SteamUserId, MyTransportMessageEnum.Success);
         }
     }
 }
示例#28
0
        private static void MissileCreatedSuccess(ref MissileShootMsg msg, MyNetworkClient sender)
        {
            MyEntity shootingEntity;
            MyEntities.TryGetEntityById(msg.LauncherEntityId, out shootingEntity);
            Debug.Assert(shootingEntity != null, "Could not find missile shooting entity");
            if (shootingEntity == null)
                return;

            var shootingLauncher = shootingEntity as IMyMissileGunObject;
            Debug.Assert(shootingLauncher != null, "Shooting entity was not an IMyMissileGunObject");
            if (shootingLauncher == null)
                return;

            shootingLauncher.ShootMissile(msg.InitialVelocity);
        }
示例#29
0
 static void ChangeParamsSuccess(ref ChangeParamsMsg msg, MyNetworkClient sender)
 {
     MyEntity entity;
     MyEntities.TryGetEntityById(msg.EntityId, out entity);
     var block = entity as MySpaceBall;
     if (block != null)
     {
         block.VirtualMass = msg.VirtualMass;
         block.Friction = msg.Friction;
         if (Sync.IsServer)
         {
             Sync.Layer.SendMessageToAllButOne(ref msg, sender.SteamUserId, MyTransportMessageEnum.Success);
         }
     }
 }
示例#30
0
 static void ChangeUseConveyorSystemSucess(ref ChangeUseConveyorsMsg msg, MyNetworkClient sender)
 {
     MyEntity entity;
     if (MyEntities.TryGetEntityById(msg.GetEntityId(), out entity))
     {
         if (entity as IMyInventoryOwner != null)
         {
             (entity as IMyInventoryOwner).UseConveyorSystem = msg.Value;
             if (Sync.IsServer)
             {
                 Sync.Layer.SendMessageToAllButOne(ref msg, sender.SteamUserId, MyTransportMessageEnum.Success);
             }
         }
     }
 }
示例#31
0
        static void SyncCooldownResponse(ref SyncCooldownResponseMessage msg, MyNetworkClient sender)
        {
            int currentTime = MySandboxGame.TotalGamePlayTimeInMilliseconds;

            // msg.respawnTimes can be null, if the server sent empty list
            if (msg.RespawnTimes != null)
            {
                foreach (var respawnTime in msg.RespawnTimes)
                {
                    var controllerId = new MyPlayer.PlayerId()
                    {
                        SteamId = MySteam.UserId, SerialId = respawnTime.ControllerId
                    };
                    var key = new RespawnKey()
                    {
                        ControllerId = controllerId, RespawnShipId = respawnTime.ShipId
                    };

                    m_globalRespawnTimesMs.Add(key, currentTime + respawnTime.RelativeRespawnTime, immediate: true);
                }
            }

            m_synced = true;
        }
示例#32
0
 public MyPlayer(MyNetworkClient client, PlayerId id)
 {
     m_client   = client;
     Id         = id;
     Controller = new MyEntityController(this);
 }
示例#33
0
 static void SyncCooldownRequest(ref SyncCooldownRequestMessage msg, MyNetworkClient sender)
 {
     SyncCooldownToPlayer(sender.SteamUserId);
 }