//ADD:
        public void SendAddGps(long identityId, ref MyGps gps)
        {
            var msg = new AddMsg();
            msg.IdentityId=identityId;
            msg.Name=gps.Name;
            msg.Description=gps.Description;
            msg.Coords=gps.Coords;
            msg.ShowOnHud=gps.ShowOnHud;
            msg.IsFinal=(gps.DiscardAt==null?true:false);

            MyMultiplayer.RaiseStaticEvent(s => MyGpsCollection.OnAddGps, msg);
        }
 IMyGps IMyGpsCollection.Create(string name, string description, Vector3D coords, bool showOnHud, bool temporary)
 {
     var gps = new MyGps();
     gps.Name = name;
     gps.Description = description;
     gps.Coords = coords;
     gps.ShowOnHud = showOnHud;
     if (temporary)
         gps.SetDiscardAt();
     else
         gps.DiscardAt = null;
     gps.UpdateHash();
     return gps;
 }
        public static void AddGPSToEntity(string entityName, string GPSName, string GPSDescription, long playerId = -1)
        {
            MyEntity entity;
            if (MyEntities.TryGetEntityByName(entityName, out entity))
            {
                if (playerId == -1)
                    playerId = GetLocalPlayerId();
                MyTuple<string, string> gpsIdentifier = new MyTuple<string, string>(entityName, GPSName);

                MyGps newGPS = new MyGps { ShowOnHud = true, Name = GPSName, Description = GPSDescription, AlwaysVisible = true };
                MySession.Static.Gpss.SendAddGps(playerId, ref newGPS, entity.EntityId);
            }
        }
 public static void AddGPS(string name, string description, Vector3D position, int disappearsInS = 0)
 {
     var localPlayerID = MySession.Static.LocalPlayerId;
     var newGPS = new MyGps { ShowOnHud = true, Coords = position, Name = name, Description = description, AlwaysVisible = true };
     if (disappearsInS > 0)
     {
         var timeSpan = TimeSpan.FromSeconds(MySession.Static.ElapsedPlayTime.TotalSeconds + disappearsInS);
         newGPS.DiscardAt = timeSpan;
     }
     MySession.Static.Gpss.SendAddGps(localPlayerID, ref newGPS);
 }
Example #5
0
        static void OnAddGps(AddMsg msg)
        {
            MyGps gps = new MyGps();
            gps.Name = msg.Name;
            gps.Description = msg.Description;
            gps.Coords = msg.Coords;
            gps.ShowOnHud = msg.ShowOnHud;
            gps.AlwaysVisible = msg.AlwaysVisible;
            gps.DiscardAt = null;
            if (!msg.IsFinal)
                gps.SetDiscardAt();
            gps.UpdateHash();
            if(msg.EntityId > 0)
                gps.SetEntity(MyEntities.GetEntityById(msg.EntityId));
            if (MySession.Static.Gpss.AddPlayerGps(msg.IdentityId, ref gps))
            {//new entry succesfully added
                if (gps.ShowOnHud && msg.IdentityId == MySession.Static.LocalPlayerId)
                    MyHud.GpsMarkers.RegisterMarker(gps);
            }

            var handler = MySession.Static.Gpss.ListChanged;
            if (handler != null)
            {
                handler(msg.IdentityId);
            }
        }
        public MyActionDescription GetActionInfo(UseActionEnum actionEnum)
        {
            m_buttonPanel.Toolbar.UpdateItem(m_index);
            var slot = m_buttonPanel.Toolbar.GetItemAtIndex(m_index);
            switch (actionEnum)
            {
                case UseActionEnum.Manipulate:

                    if (m_buttonDesc == null)
                    {
                        m_buttonDesc = new MyGps();
                        
                        m_buttonDesc.Description = "";
                        m_buttonDesc.Coords = ActivationMatrix.Translation;
                        m_buttonDesc.ShowOnHud = true;
                        m_buttonDesc.DiscardAt = null;
                    }

                    MyHud.ButtonPanelMarkers.RegisterMarker(m_buttonDesc);

                    SetButtonName(m_buttonPanel.GetCustomButtonName(m_index));

                    if (slot != null)
                    {
                        return new MyActionDescription()
                        {
                            Text = MySpaceTexts.NotificationHintPressToUse,
                            FormatParams = new object[] { MyInput.Static.GetGameControl(MyControlsSpace.USE), slot.DisplayName },
                            IsTextControlHint = true,
                            JoystickFormatParams = new object[] { MyControllerHelper.GetCodeForControl(MySpaceBindingCreator.CX_CHARACTER, MyControlsSpace.USE), slot.DisplayName },
                        };
                    }
                    else
                    {
                        return new MyActionDescription() { Text = MySpaceTexts.Blank };
                    }

                case UseActionEnum.OpenTerminal:
                    return new MyActionDescription()
                    {
                        Text = MySpaceTexts.NotificationHintPressToOpenButtonPanel,
                        FormatParams = new object[] { MyInput.Static.GetGameControl(MyControlsSpace.TERMINAL) },
                        IsTextControlHint = true,
                        JoystickText = MySpaceTexts.NotificationHintJoystickPressToOpenButtonPanel,
                    };

                default:
                    Debug.Fail("Invalid branch reached.");
                    return new MyActionDescription()
                    {
                        Text = MySpaceTexts.NotificationHintPressToOpenButtonPanel,
                        FormatParams = new object[] { MyInput.Static.GetGameControl(MyControlsSpace.TERMINAL) },
                        IsTextControlHint = true
                    };
            }
        }
        private void FillRight(MyGps ins)
        {
            UnhookSyncEvents();
            m_checkInsShowOnHud.IsCheckedChanged -= OnShowOnHudChecked;   
            m_panelInsName.SetText(new StringBuilder(ins.Name));
            m_panelInsDesc.SetText(new StringBuilder(ins.Description));
            //m_textInsDesc
            m_xCoord.SetText(new StringBuilder(ins.Coords.X.ToString("F2",System.Globalization.CultureInfo.InvariantCulture)));
            m_yCoord.SetText(new StringBuilder(ins.Coords.Y.ToString("F2",System.Globalization.CultureInfo.InvariantCulture)));
            m_zCoord.SetText(new StringBuilder(ins.Coords.Z.ToString("F2",System.Globalization.CultureInfo.InvariantCulture)));
            m_checkInsShowOnHud.IsChecked = ins.ShowOnHud;
            m_checkInsShowOnHud.IsCheckedChanged += OnShowOnHudChecked;
            m_previousHash = ins.Hash;
            HookSyncEvents();
            m_needsSyncName = false;
            m_needsSyncDesc = false;
            m_needsSyncX = false;
            m_needsSyncY = false;
            m_needsSyncZ = false;

            m_panelInsName.ColorMask = Vector4.One;
            m_xCoord.ColorMask = Vector4.One;
            m_yCoord.ColorMask = Vector4.One;
            m_zCoord.ColorMask = Vector4.One;
            m_nameOk = m_xOk = m_yOk = m_zOk = true;
            updateWarningLabel();
        }
 private void OnButtonPressedNew(MyGuiControlButton sender)
 {
     trySync();
     MyGps ins = new MyGps();
     ins.Name = MyTexts.Get(MySpaceTexts.TerminalTab_GPS_NewCoord_Name).ToString();
     ins.Description = MyTexts.Get(MySpaceTexts.TerminalTab_GPS_NewCoord_Desc).ToString();
     ins.Coords = new Vector3D(0, 0, 0);
     ins.ShowOnHud = true;
     ins.DiscardAt = null;//finalize
     MySession.Static.Gpss.SendAddGps(MySession.LocalPlayerId, ref ins);
     m_searchIns.Text = "";
     enableEditBoxes(false);
 }
        public bool AddPlayerGps(long identityId, ref MyGps gps)
        {

            if (gps == null)
                return false;
            Dictionary<int,MyGps> result;
            var success = m_playerGpss.TryGetValue(identityId, out result);
            if (!success)
            {
                result = new Dictionary<int,MyGps>();
                m_playerGpss.Add(identityId, result);
            }
            if (result.ContainsKey(gps.Hash))
            {
                //Request to add existing. We update timestamp:
                MyGps mGps;
                result.TryGetValue(gps.Hash,out mGps);
                if (mGps.DiscardAt != null)//not final
                    mGps.SetDiscardAt();
                return false;
            }
            result.Add(gps.Hash,gps);
            
            return true;
        }
        //MODIFY:
        public void SendModifyGps(long identityId, MyGps gps)
        {//beware: gps must still contain original hash. Recompute during/after success.
            var msg = new ModifyMsg();
            msg.IdentityId = identityId;
            msg.Name = gps.Name;
            msg.Description = gps.Description;
            msg.Coords = gps.Coords;
            msg.Hash = gps.Hash;

            Sync.Layer.SendMessageToServer(ref msg, MyTransportMessageEnum.Request);
        }
        static void AddSuccess(ref AddMsg msg, MyNetworkClient sender)
        {
            MyGps gps=new MyGps();
            gps.Name=msg.Name;
            gps.Description=msg.Description;
            gps.Coords=msg.Coords;
            gps.ShowOnHud=msg.ShowOnHud;
            gps.DiscardAt=null;
            if (!msg.IsFinal)
               gps.SetDiscardAt();
            gps.UpdateHash();
            if (MySession.Static.Gpss.AddPlayerGps(msg.IdentityId, ref gps))
            {//new entry succesfully added
                if (gps.ShowOnHud && msg.IdentityId == MySession.LocalPlayerId)
                    MyHud.GpsMarkers.RegisterMarker(gps);
            }

            var handler = MySession.Static.Gpss.ListChanged;
            if (handler != null)
            {
                handler(msg.IdentityId);
            }
        }
        //ADD:
        public void SendAddGps(long identityId, ref MyGps gps)
        {
            var msg = new AddMsg();
            msg.IdentityId=identityId;
            msg.Name=gps.Name;
            msg.Description=gps.Description;
            msg.Coords=gps.Coords;
            msg.ShowOnHud=gps.ShowOnHud;
            msg.IsFinal=(gps.DiscardAt==null?true:false);

            Sync.Layer.SendMessageToServer(ref msg, MyTransportMessageEnum.Request);
        }
        //MODIFY:
        public void SendModifyGps(long identityId, MyGps gps)
        {//beware: gps must still contain original hash. Recompute during/after success.
            var msg = new ModifyMsg();
            msg.IdentityId = identityId;
            msg.Name = gps.Name;
            msg.Description = gps.Description;
            msg.Coords = gps.Coords;
            msg.Hash = gps.Hash;

            MyMultiplayer.RaiseStaticEvent(s => MyGpsCollection.ModifyRequest, msg);
        }
 private MyGuiControlTable.Row AddToList(MyGps ins)
 {
     var row = new MyGuiControlTable.Row(ins);
     var name = new StringBuilder(ins.Name);
     row.AddCell(new MyGuiControlTable.Cell(text: name, userData: ins, textColor: (ins.DiscardAt != null ? Color.Gray : (ins.ShowOnHud ? ITEM_SHOWN_COLOR : Color.White))));
     m_tableIns.Add(row);
     return row;
 }
 public void LoadGpss(MyObjectBuilder_Checkpoint checkpoint)
 {
     if (MyFakes.ENABLE_GPS && checkpoint.Gps!=null)
         foreach(var entry in checkpoint.Gps.Dictionary)//identity
         {
             foreach (var gpsEntry in entry.Value.Entries)
             {
                 MyGps gps = new MyGps(gpsEntry);
                 Dictionary<int, MyGps> playersGpss;
                 if (!m_playerGpss.TryGetValue(entry.Key, out playersGpss))
                 {
                     playersGpss = new Dictionary<int, MyGps>();
                     m_playerGpss.Add(entry.Key, playersGpss);
                 }
                 playersGpss.Add(gps.GetHashCode(), gps);
                 if (gps.ShowOnHud && entry.Key == MySession.LocalPlayerId && MySession.LocalPlayerId!=0)// LocalPlayerId=0 => loading MP game and not yet initialized. Or server, which does not matter
                     MyHud.GpsMarkers.RegisterMarker(gps);
             }
         }
 }
 private bool trySync()
 {//takes current right side values of name, description and coordinates, compares them against record with previous hash and synces if necessary
     if (m_previousHash != null && (m_needsSyncName || m_needsSyncDesc || m_needsSyncX || m_needsSyncY || m_needsSyncZ))
     {
         if (MySession.Static.Gpss.ExistsForPlayer(MySession.LocalPlayerId))
         {
             if (IsNameOk(m_panelInsName.Text) && IsCoordOk(m_xCoord.Text) && IsCoordOk(m_yCoord.Text) && IsCoordOk(m_zCoord.Text))
             {
                 Dictionary<int, MyGps> insList;
                 insList = MySession.Static.Gpss[MySession.LocalPlayerId];
                 MyGps ins;
                 if (insList.TryGetValue((int)m_previousHash, out ins))
                 {
                     if (m_needsSyncName)
                         ins.Name = m_panelInsName.Text;
                     if (m_needsSyncDesc)
                         ins.Description = m_panelInsDesc.Text;
                     StringBuilder str = new StringBuilder();
                     if (m_needsSyncX)
                     {
                         m_xCoord.GetText(str);
                         ins.Coords.X = Math.Round(double.Parse(str.ToString(), System.Globalization.CultureInfo.InvariantCulture),2);
                     }
                     str.Clear();
                     if (m_needsSyncY)
                     {
                         m_yCoord.GetText(str);
                         ins.Coords.Y = Math.Round(double.Parse(str.ToString(), System.Globalization.CultureInfo.InvariantCulture),2);
                     }
                     str.Clear();
                     if (m_needsSyncZ)
                     {
                         m_zCoord.GetText(str);
                         ins.Coords.Z = Math.Round(double.Parse(str.ToString(), System.Globalization.CultureInfo.InvariantCulture), 2);
                     }
                     m_syncedGps = ins;
                     MySession.Static.Gpss.SendModifyGps(MySession.LocalPlayerId, ins);
                     return true;
                 }
             }
         }
     }
     return false;
 }
        public MyObjectBuilder_Gps.Entry GetObjectBuilderEntry(MyGps gps)
        {
                return new MyObjectBuilder_Gps.Entry()
                {
                    name = gps.Name,
                    description = gps.Description,
                    coords = gps.Coords,
                    isFinal = (gps.DiscardAt == null ? true : false),
                    showOnHud = gps.ShowOnHud
                };

        }
 private void OnButtonPressedNewFromCurrent(MyGuiControlButton sender)
 {
     trySync();
     MyGps ins = new MyGps();
     MySession.Static.Gpss.GetNameForNewCurrent(m_NameBuilder);
     ins.Name = m_NameBuilder.ToString();
     ins.Description = MyTexts.Get(MySpaceTexts.TerminalTab_GPS_NewFromCurrent_Desc).ToString();
     ins.Coords = new Vector3D(MySession.LocalHumanPlayer.GetPosition());
     ins.Coords.X = Math.Round(ins.Coords.X, 2);
     ins.Coords.Y = Math.Round(ins.Coords.Y, 2);
     ins.Coords.Z = Math.Round(ins.Coords.Z, 2);
     ins.ShowOnHud = true;
     ins.DiscardAt = null;//final
     MySession.Static.Gpss.SendAddGps(MySession.LocalPlayerId, ref ins);
     m_searchIns.Text = "";
     enableEditBoxes(false);
 }
        public int ScanText(string input, string desc = null)
        {//scans given text and adds all as uncorfirmed
            int count = 0;
            // GPS:name without doublecolons:123.4:234.5:3421.6:
            foreach (Match match in Regex.Matches(input, m_ScanPattern))
            {
                String name = match.Groups[1].Value;
                double x, y, z;
                try
                {
                    x = double.Parse(match.Groups[2].Value, System.Globalization.CultureInfo.InvariantCulture);
                    x = Math.Round(x, 2);
                    y = double.Parse(match.Groups[3].Value, System.Globalization.CultureInfo.InvariantCulture);
                    y = Math.Round(y, 2);
                    z = double.Parse(match.Groups[4].Value, System.Globalization.CultureInfo.InvariantCulture);
                    z = Math.Round(z, 2);
                }
                catch (SystemException)
                {
                    continue;//search for next GPS in the input
                }

                MyGps newGps = new MyGps()
                {
                    Name = name,
                    Description = desc,
                    Coords = new Vector3D(x, y, z),
                    ShowOnHud = false
                };
                newGps.UpdateHash();
                MySession.Static.Gpss.SendAddGps(MySession.LocalPlayerId, ref newGps);
                ++count;
                if (count == PARSE_MAX_COUNT)
                    break;
            }

            return count;
        }
        public void Close()
        {
            trySync();
            if (m_tableIns != null)
            {
                ClearList();
                m_tableIns.ItemSelected -= OnTableItemSelected;
                m_tableIns.ItemDoubleClicked -= OnTableDoubleclick;
            }
            m_syncedGps = null;
            MySession.Static.Gpss.GpsChanged -= OnInsChanged;
            MySession.Static.Gpss.ListChanged -= OnListChanged;

            UnhookSyncEvents();

            m_checkInsShowOnHud.IsCheckedChanged -= OnShowOnHudChecked;

            m_buttonAdd.ButtonClicked -= OnButtonPressedNew;
            m_buttonAddFromClipboard.ButtonClicked -= OnButtonPressedNewFromClipboard;
            m_buttonAddCurrent.ButtonClicked -= OnButtonPressedNewFromCurrent;
            m_buttonDelete.ButtonClicked -= OnButtonPressedDelete;

            m_buttonCopy.ButtonClicked -= OnButtonPressedCopy;
        }
        public static void SetGPSHighlight(string entityName, string GPSName, string GPSDescription, bool enabled = true, int thickness = 1, int pulseTimeInFrames = 120, Color color = default(Color), long playerId = -1)
        {
            MyEntity entity;
            if (MyEntities.TryGetEntityByName(entityName, out entity))
            {
                if (playerId == -1)
                    playerId = GetLocalPlayerId();
                MyTuple<string, string> gpsIdentifier = new MyTuple<string, string>(entityName, GPSName);

                if (enabled)
                {
                    MyGps newGPS = new MyGps { ShowOnHud = true, Name = GPSName, Description = GPSDescription, AlwaysVisible = true };
                    MySession.Static.Gpss.SendAddGps(playerId, ref newGPS, entity.EntityId);
                }
                else
                {
                    var gps = MySession.Static.Gpss.GetGpsByName(playerId, GPSName);
                    if (gps != null)
                        MySession.Static.Gpss.SendDelete(playerId, gps.Hash);
                }
                SetHighlight(entityName, enabled: enabled, thickness: thickness, pulseTimeInFrames: pulseTimeInFrames, color: color, playerId: playerId);
            }
        }
        void DieInternal()
        {
            if (!CharacterCanDie && !MyPerGameSettings.CharacterSuicideEnabled)
                return;

            if (MySession.Static.LocalCharacter == this)
                m_localCharacterWasInThirdPerson = !IsInFirstPersonView;

            MyHud.CharacterInfo.HealthRatio = 0f;
            SoundComp.PlayDeathSound(StatComp != null ? StatComp.LastDamage.Type : MyStringHash.NullOrEmpty);
            if (UseNewAnimationSystem)
                AnimationController.Variables.SetValue(MyAnimationVariableStorageHints.StrIdDead, 1.0f);

            if (m_InventoryScreen != null)
            {
                m_InventoryScreen.CloseScreen();
            }

            if (StatComp != null && StatComp.Health != null)
                StatComp.Health.OnStatChanged -= StatComp.OnHealthChanged;

            if (m_breath != null)
                m_breath.CurrentState = MyCharacterBreath.State.NoBreath;

            if (CurrentRemoteControl != null)
            {
                //This will happen when character is killed without being destroyed
                var remoteControl = CurrentRemoteControl as MyRemoteControl;
                if (remoteControl != null)
                {
                    remoteControl.ForceReleaseControl();
                }
                else
                {
                    var turretControl = CurrentRemoteControl as MyLargeTurretBase;
                    if (turretControl != null)
                    {
                        turretControl.ForceReleaseControl();
                    }
                }
            }

            if (ControllerInfo != null && ControllerInfo.IsLocallyHumanControlled())
            {
                if (MyGuiScreenTerminal.IsOpen)
                {
                    MyGuiScreenTerminal.Hide();
                }

                if (MyGuiScreenGamePlay.ActiveGameplayScreen != null)
                {
                    MyGuiScreenGamePlay.ActiveGameplayScreen.CloseScreen();
                    MyGuiScreenGamePlay.ActiveGameplayScreen = null;
                }

                if (MyGuiScreenGamePlay.TmpGameplayScreenHolder != null)
                {
                    MyGuiScreenGamePlay.TmpGameplayScreenHolder.CloseScreen();
                    MyGuiScreenGamePlay.TmpGameplayScreenHolder = null;
                }
            }

            if (Parent is MyCockpit)
            {
                var cockpit = Parent as MyCockpit;
                if (cockpit.Pilot == this)
                    cockpit.RemovePilot(); //needed to be done localy otherwise client wont see respawn message
            }

            if (MySession.Static.ControlledEntity is MyRemoteControl)
            {
                //This will happen when character is killed without being destroyed
                var remoteControl = MySession.Static.ControlledEntity as MyRemoteControl;
                if (remoteControl.PreviousControlledEntity == this)
                {
                    remoteControl.ForceReleaseControl();
                }
            }

            //TODO(AF) Create a shared RemoteControl component
            if (MySession.Static.ControlledEntity is MyLargeTurretBase)
            {
                //This will happen when character is killed without being destroyed
                var turret = MySession.Static.ControlledEntity as MyLargeTurretBase;
                    turret.ForceReleaseControl();
                }

            if (m_currentMovementState == MyCharacterMovementEnum.Died)
            {
                StartRespawn(0.1f);
                return;
            }


            ulong playerId = 0;
            if (ControllerInfo.Controller != null && ControllerInfo.Controller.Player != null)
            {
                playerId = ControllerInfo.Controller.Player.Id.SteamId;
                if (!MySession.Static.Cameras.TryGetCameraSettings(ControllerInfo.Controller.Player.Id, EntityId, out m_cameraSettingsWhenAlive))
                {
                    if (ControllerInfo.IsLocallyHumanControlled())
                    {
                        m_cameraSettingsWhenAlive = new MyEntityCameraSettings()
                        {
                            Distance = MyThirdPersonSpectator.Static.GetViewerDistance(),
                            IsFirstPerson = IsInFirstPersonView,
                            HeadAngle = new Vector2(HeadLocalXAngle, HeadLocalYAngle)
                        };
                    }
                }
            }

            MyAnalyticsHelper.ReportPlayerDeath(ControllerInfo.IsLocallyHumanControlled(), playerId);

            MySandboxGame.Log.WriteLine("Player character died. Id : " + playerId);

            EndShootAll();

            // If it is the local player who died, give this player a death location coordinate
            if (GetPlayerIdentityId() == MySession.Static.LocalPlayerId)
            {
                m_isDeathPlayer = true;
                string bodyLocationName = MyTexts.Get(MySpaceTexts.GPS_Body_Location_Name).ToString();
                MyGps deathLocation = MySession.Static.Gpss.GetGpsByName(MySession.Static.LocalPlayerId, bodyLocationName) as MyGps;

                if (deathLocation != null)
                {
                    deathLocation.Coords = new Vector3D(MySession.Static.LocalHumanPlayer.GetPosition());
                    deathLocation.Coords.X = Math.Round(deathLocation.Coords.X, 2);
                    deathLocation.Coords.Y = Math.Round(deathLocation.Coords.Y, 2);
                    deathLocation.Coords.Z = Math.Round(deathLocation.Coords.Z, 2);
                    MySession.Static.Gpss.SendModifyGps(MySession.Static.LocalPlayerId, deathLocation);
                }
                else
                {
                    deathLocation = new MyGps();
                    deathLocation.Name = bodyLocationName;
                    deathLocation.Description = MyTexts.Get(MySpaceTexts.GPS_Body_Location_Desc).ToString();
                    deathLocation.Coords = new Vector3D(MySession.Static.LocalHumanPlayer.GetPosition());
                    deathLocation.Coords.X = Math.Round(deathLocation.Coords.X, 2);
                    deathLocation.Coords.Y = Math.Round(deathLocation.Coords.Y, 2);
                    deathLocation.Coords.Z = Math.Round(deathLocation.Coords.Z, 2);
                    deathLocation.ShowOnHud = true;
                    deathLocation.DiscardAt = null;
                    MySession.Static.Gpss.SendAddGps(MySession.Static.LocalPlayerId, ref deathLocation);
                }
            }

            if (Sync.IsServer && m_currentWeapon != null && m_currentWeapon.PhysicalObject != null)
            {
                var inventoryItem = new MyPhysicalInventoryItem()
                {
                    Amount = 1,
                    Scale = 1f,
                    Content = m_currentWeapon.PhysicalObject,
                };
                // Guns 
                if (inventoryItem.Content is MyObjectBuilder_PhysicalGunObject)
                {
                    (inventoryItem.Content as MyObjectBuilder_PhysicalGunObject).GunEntity.EntityId = 0;
                }
                MyFloatingObjects.Spawn(inventoryItem, ((MyEntity)m_currentWeapon).PositionComp.GetPosition(), WorldMatrix.Forward, WorldMatrix.Up, Physics);
                this.GetInventory().RemoveItemsOfType(1, m_currentWeapon.PhysicalObject);
            }

            IsUsing = null;
            m_isFalling = false;
            SetCurrentMovementState(MyCharacterMovementEnum.Died);
            UnequipWeapon();
            //Inventory.Clear(false);
            StopUpperAnimation(0.5f);
            //SoundComp.StartSecondarySound(Definition.DeathSoundName, sync: false);

            m_animationCommandsEnabled = true;
            if (m_isInFirstPerson)
                PlayCharacterAnimation("DiedFps", MyBlendOption.Immediate, MyFrameOption.PlayOnce, 0.5f);
            else
                PlayCharacterAnimation("Died", MyBlendOption.Immediate, MyFrameOption.PlayOnce, 0.5f);

            //InitBoxPhysics(MyMaterialType.METAL, ModelLod0, 900, 0, MyPhysics.DefaultCollisionFilter, RigidBodyFlag.RBF_DEFAULT);
            //InitSpherePhysics(MyMaterialType.METAL, ModelLod0, 900, 0, 0, 0, RigidBodyFlag.RBF_DEFAULT);

            InitDeadBodyPhysics();

            StartRespawn(RESPAWN_TIME);

            m_currentLootingCounter = m_characterDefinition.LootingTime;

            if (CharacterDied != null)
                CharacterDied(this);

            foreach (var component in Components)
            {
                var characterComponent = component as MyCharacterComponent;
                if (characterComponent != null)
                {
                    characterComponent.OnCharacterDead();
                }
            }
            SoundComp.CharacterDied();
            JetpackComp = null; // m_jetpackEnabled = false;

            // Syncing dead bodies only when the ragdoll is disabled
            if (!Components.Has<MyCharacterRagdollComponent>())
            {
                SyncFlag = true;
            }
        }
Example #23
0
        public override void UpdateOnceBeforeFrame()
        {
            base.UpdateOnceBeforeFrame();

            UpdateFloraAndPhysics(true);

            if (m_planetInitValues.AddGps)
            {
                MyGps newGps = new MyGps()
                {
                    Name = StorageName,
                    Coords = PositionComp.GetPosition(),
                    ShowOnHud = true
                };
                newGps.UpdateHash();
                MySession.Static.Gpss.SendAddGps(MySession.Static.LocalPlayerId, ref newGps);
            }
        }