public MyMwcObjectBuilder_Player(float health, float money, float withoutOxygen, MyMwcObjectBuilder_PlayerStatistics playerStatisticsObjectBuilder, MyMwcObjectBuilder_SmallShip shipObjectBuilder, MyMwcObjectBuilder_ShipConfig shipConfigObjectBuilder) { Health = health; Money = money; WithoutOxygen = withoutOxygen; PlayerStatisticsObjectBuilder = playerStatisticsObjectBuilder; ShipObjectBuilder = shipObjectBuilder; ShipConfigObjectBuilder = shipConfigObjectBuilder; }
public void Init(MyMwcObjectBuilder_ShipConfig objectBuilder) { Engine.SetValue(objectBuilder.Engine); RadarType.SetValue((MyHudRadarTypesEnum)objectBuilder.RadarType); AutoLeveling.SetValue(objectBuilder.AutoLeveling); MovementSlowdown.SetValue(objectBuilder.MovementSlowdown); BackCamera.SetValue(objectBuilder.BackCamera); ViewMode.SetValue((MyViewModeTypesEnum)objectBuilder.ViewMode); }
void OnMeDied(byte? killerId) { if (IsStory()) { // Player has same ship and inventory, with minimum of 20% armor, health, oxygen... StoredShip = MySession.PlayerShip.GetObjectBuilder(false) as MyMwcObjectBuilder_SmallShip; StoredShip.ClearEntityId(); } m_lastConfig = MySession.PlayerShip.Config.GetObjectBuilder(); m_lastAmmoAssignment = MySession.PlayerShip.Weapons.AmmoAssignments.GetObjectBuilder(); m_lastCamera = MyGuiScreenGamePlay.Static.CameraAttachedTo; if (m_lastCamera != MyCameraAttachedToEnum.PlayerMinerShip && m_lastCamera != MyCameraAttachedToEnum.PlayerMinerShip_ThirdPersonDynamic && m_lastCamera != MyCameraAttachedToEnum.PlayerMinerShip_ThirdPersonFollowing && m_lastCamera != MyCameraAttachedToEnum.PlayerMinerShip_ThirdPersonStatic) { m_lastCamera = MyCameraAttachedToEnum.PlayerMinerShip; } PlayerStatistics.Deaths++; UpdateStats(); DisplayDeathNotification(killerId); // This is really SICK! MyGuiManager.CloseIngameScreens(); m_respawnTime = MyMinerGame.TotalGamePlayTimeInMilliseconds + (int)m_multiplayerConfig.RespawnTime.TotalMilliseconds; Log("DIE, respawn in: " + m_multiplayerConfig.RespawnTime.TotalMilliseconds + " ms"); }
public void Respawn(MyMwcObjectBuilder_SmallShip shipBuilder, Matrix respawnPosition) { Log("Respawn faction: " + MyFactionConstants.GetFactionProperties(MySession.PlayerShip.Faction).Name); int oldPriority = 0; if (m_lastConfig == null && MySession.PlayerShip != null) { m_lastConfig = MySession.PlayerShip.Config.GetObjectBuilder(); } if (MySession.PlayerShip != null) { oldPriority = MySession.PlayerShip.AIPriority; if (MySession.PlayerShip.IsDummy || MySession.PlayerShip.IsExploded()) { MySession.PlayerShip.Activate(false, false); MySession.PlayerShip.MarkForClose(); MySession.PlayerShip = null; } } MySession.Static.Player.RestoreHealth(); // To proper respawn shipBuilder.ShipHealthRatio = MathHelper.Clamp(shipBuilder.ShipHealthRatio, 0.2f, 1.0f); shipBuilder.Oxygen = MathHelper.Clamp(shipBuilder.Oxygen, 100.0f, float.MaxValue); //Debug.Assert(!shipBuilder.EntityId.HasValue); var playership = (MySmallShip)MyEntities.CreateFromObjectBuilderAndAdd(MyClientServer.LoggedPlayer.GetDisplayName().ToString(), shipBuilder, respawnPosition); playership.AIPriority = oldPriority; // Restore bot priority if (IsSandBox()) { if (m_lastConfig != null) { playership.Config.Init(m_lastConfig); } } else { if (MyGuiScreenGamePlay.Static.Checkpoint.PlayerObjectBuilder.ShipConfigObjectBuilder != null) { playership.Config.Init(MyGuiScreenGamePlay.Static.Checkpoint.PlayerObjectBuilder.ShipConfigObjectBuilder); } } playership.ConfigChanged += m_onConfigChanged; playership.OnDie += m_onEntityDie; playership.Activate(true); MyCockpitGlassDecals.Clear(); var respawnMsg = new MyEventRespawn(); respawnMsg.EntityId = playership.EntityId.Value.NumericValue; respawnMsg.Position = new MyMwcPositionAndOrientation(playership.WorldMatrix); respawnMsg.Inventory = GetInventory(playership, true); respawnMsg.ShipType = playership.ShipType; respawnMsg.Faction = playership.Faction; float ratio = (IsStory() && StoredShip != null) ? 0.2f : 1.0f; playership.ArmorHealth = MathHelper.Clamp(playership.ArmorHealth, playership.MaxArmorHealth * ratio, playership.MaxArmorHealth); playership.Fuel = MathHelper.Clamp(playership.Fuel, playership.MaxFuel * ratio, playership.MaxFuel); playership.HealthRatio = MathHelper.Clamp(playership.HealthRatio, ratio, 1.0f); playership.Oxygen = MathHelper.Clamp(playership.Oxygen, playership.MaxOxygen * ratio, playership.MaxOxygen); MySession.Static.Player.RestoreHealth(); playership.PilotHealth = MySession.Static.Player.MaxHealth; if (MyMultiplayerGameplay.IsSandBox()) { MakeInventoryItemsNontradeable(playership); } if (m_lastAmmoAssignment != null) { playership.Weapons.AmmoAssignments.Init(m_lastAmmoAssignment); } // As last to prevent many changes when doing something playership.InventoryChanged += m_onInventoryChanged; LogDevelop("RESPAWN end"); Peers.SendToAll(ref respawnMsg, NetDeliveryMethod.ReliableOrdered); }