public IMyBot CreateBot(MyPlayer player, MyObjectBuilder_Bot botBuilder, MyBotDefinition botDefinition) { var output = new MySandboxBot(player, botDefinition); if (botBuilder != null) output.Init(botBuilder); return output; }
public bool Update(MyPlayer player, MyEntity entity) //returns if lost { //MySessionComponentMission.Static.TryCreateFromDefault(Id); //if (IsLocal(player.Id)) // UpdateLocal(player.Id); if (!Sync.IsServer) return false; MyMissionTriggers mtrig; if (!MissionTriggers.TryGetValue(player.Id, out mtrig)) { //Debug.Assert(false,"Bad ID for update in missionTriggers"); mtrig = TryCreateFromDefault(player.Id, false); } mtrig.UpdateWin(player, entity); if (!mtrig.Won) mtrig.UpdateLose(player, entity); else { m_someoneWon = true; MyAnalyticsHelper.ReportTutorialEnd(); } return mtrig.Lost; }
public static void PlayerLost(MyPlayer.PlayerId id, int triggerIndex) { MySessionComponentMissionTriggers.Static.SetLost(id, triggerIndex); if (!Sync.MultiplayerActive || !MySession.Static.IsScenario) return; LostMsg msg = new LostMsg(); msg.index = triggerIndex; msg.playerId = id; Sync.Layer.SendMessageToAll(ref msg, MyTransportMessageEnum.Success); }
public void SendControlPilotMsg(MyPlayer player) { var msg = new ControlPilotMsg(); msg.EntityId = Entity.Entity.EntityId; msg.SteamId = player.Id.SteamId; msg.SerialId = player.Id.SerialId; MySession.Static.SyncLayer.SendMessageToAllAndSelf(ref msg); }
/*public bool Update(MyFaction faction, MyCharacter me) { bool res = false; if (faction != null) res = Update(faction.FactionId, me); else res = Update(me.EntityId, me); return res; }*/ /*public bool Update() { return false; }*/ public bool Update(MyPlayer.PlayerId Id, MyCharacter me) { MyMissionTriggers mtrig; if (!MissionTriggers.TryGetValue(Id, out mtrig)) { //Debug.Assert(false,"Bad ID for update in missionTriggers"); return false; } mtrig.UpdateWin(me); mtrig.UpdateLose(me);//!! return false; }
public MySandboxBot(MyPlayer botPlayer, MyBotDefinition botDefinition) { m_definition = botDefinition as MyAgentDefinition; m_player = botPlayer; m_navigation = new MyBotNavigation(); m_respawnRequestSent = false; m_actionCollection = null; m_botMemory = new MyBotMemory(this); m_player.Controller.ControlledEntityChanged += Controller_ControlledEntityChanged; m_navigation.ChangeEntity(m_player.Controller.ControlledEntity); }
public MyHumanoidBot(MyPlayer player, MyBotDefinition botDefinition) : base(player, botDefinition) { Debug.Assert(botDefinition is MyHumanoidBotDefinition, "Provided bot definition is not of humanoid type"); if (m_player.Controller.ControlledEntity is MyCharacter) // when loaded player already controls entity { var character = m_player.Controller.ControlledEntity as MyCharacter; if (character.CurrentWeapon == null && StartingWeaponId.SubtypeId != MyStringHash.NullOrEmpty) { AddItems(character); } } Sandbox.Game.Gui.MyCestmirDebugInputComponent.PlacedAction += DebugGoto; }
public void TryCreateFromDefault(MyPlayer.PlayerId newId, bool overwrite) { if (overwrite) MissionTriggers.Remove(newId); else if (MissionTriggers.ContainsKey(newId)) return;//already exists, thats ok for us MyMissionTriggers mtrig = new MyMissionTriggers(); MissionTriggers.Add(newId, mtrig); MyMissionTriggers source; MissionTriggers.TryGetValue(new MyPlayer.PlayerId(0,0), out source); if (source == null) //older save which does not have defaults set return; mtrig.CopyTriggersFrom(source); }
public bool Update(MyPlayer.PlayerId Id, MyEntity entity) //returns if lost { //MySessionComponentMission.Static.TryCreateFromDefault(Id); if (IsLocal(Id)) UpdateLocal(Id); if (!Sync.IsServer) return false; MyMissionTriggers mtrig; if (!MissionTriggers.TryGetValue(Id, out mtrig)) { //Debug.Assert(false,"Bad ID for update in missionTriggers"); mtrig=TryCreateFromDefault(Id, false); } mtrig.UpdateWin(Id, entity); if (!mtrig.Won) mtrig.UpdateLose(Id, entity); else m_someoneWon = true; return mtrig.Lost; }
public void ResetPlayerIdentity(MyPlayer player) { if (player.Identity != null) { if (MySession.Static.Settings.PermanentDeath.Value) { if (!player.Identity.IsDead) Sync.Players.KillPlayer(player); var faction = MySession.Static.Factions.TryGetPlayerFaction(player.Identity.IdentityId); if (faction != null) MyFactionCollection.KickMember(faction.FactionId, player.Identity.IdentityId); //Clear chat history if (MySession.Static.ChatSystem != null) { MySession.Static.ChatSystem.ClearChatHistoryForPlayer(player.Identity); } var identity = Sync.Players.CreateNewIdentity(player.DisplayName); player.Identity = identity; } } }
private bool CheckRangeAndAccess(IMyControllableEntity controlledEntity, MyPlayer player) { var terminal = controlledEntity as MyTerminalBlock; if (terminal == null) { var character = controlledEntity as MyCharacter; if (character != null) { return MyAntennaSystem.Static.CheckConnection(character, CubeGrid, player); } else { return true; } } MyCubeGrid playerGrid = terminal.SlimBlock.CubeGrid; return MyAntennaSystem.Static.CheckConnection(playerGrid, CubeGrid, player); }
public void TryTakeSpawneeOwnership(MyPlayer player) { if (MySession.Static.IsScenario && m_takeSpawneeOwnership && Sync.IsServer && OwnerId == 0) ChangeBlockOwnerRequest(player.Identity.IdentityId, MyOwnershipShareModeEnum.None); }
public void TrySetFaction(MyPlayer player) { if (MySession.Static.IsScenario && m_setFactionToSpawnee && Sync.IsServer && OwnerId != 0) { //if (null != MySession.Static.Factions.TryGetPlayerFaction(player.Identity.IdentityId)) // return; IMyFaction faction = MySession.Static.Factions.TryGetPlayerFaction(this.OwnerId); if (faction == null) return; MyFactionCollection.SendJoinRequest(faction.FactionId, player.Identity.IdentityId); if (!faction.AutoAcceptMember) MyFactionCollection.AcceptJoin(faction.FactionId, player.Identity.IdentityId); } }
public abstract void SetupCharacterDefault(MyPlayer player, MyWorldGenerator.Args args);
public abstract MyIdentity CreateNewIdentity(string identityName, MyPlayer.PlayerId playerId, string modelName);
public void SendNewGlobalMessage(MyPlayer.PlayerId senderId, string text) { MyMultiplayer.RaiseEvent(this, x => x.OnGlobalMessageRequest, senderId.SteamId, text); }
public void SetPlayer(MyPlayer player, bool update = true) { m_controlInfo.Value = player.Id; if (Sync.IsServer && update) { MyPlayerCollection.ChangePlayerCharacter(player, this, this); } }
public IMyBot CreateBot(MyPlayer player, MyObjectBuilder_Bot botBuilder, MyBotDefinition botDefinition) { Debug.Assert(m_botDataByBehaviorType.ContainsKey(botDefinition.BehaviorType), "Undefined behavior type. Bot is not going to be created"); if (!m_botDataByBehaviorType.ContainsKey(botDefinition.BehaviorType)) return null; Debug.Assert(m_botTypeByDefinitionType.ContainsKey(botDefinition.TypeDefinitionId.TypeId), "Type not found. Bot is not going to be created!"); if (!m_botTypeByDefinitionType.ContainsKey(botDefinition.TypeDefinitionId.TypeId)) return null; var botData = m_botDataByBehaviorType[botDefinition.BehaviorType]; var behaviorTypeData = m_botTypeByDefinitionType[botDefinition.TypeDefinitionId.TypeId]; IMyBot output = CreateBot(behaviorTypeData.BotType, player, botDefinition); CreateActions(output, botData.BotActionsType); CreateLogic(output, botData.LogicType, botDefinition.BehaviorSubtype); if (botBuilder != null) output.Init(botBuilder); return output; }
public MyEntityController(MyPlayer parent) { Player = parent; m_controlledEntityClosing = ControlledEntity_OnClosing; }
private IMyBot CreateBot(Type botType, MyPlayer player, MyBotDefinition botDefinition) { return Activator.CreateInstance(botType, player, botDefinition) as IMyBot; // MW:TODO so far agent and humanoid have players so let's keep it like this }
private void AddPlayer(PlayerId playerId, MyPlayer newPlayer) { m_players.Add(playerId, newPlayer); OnPlayersChanged(true, playerId.SteamId); }
public void SendNewPlayerMessage(MyPlayer.PlayerId senderId, MyPlayer.PlayerId receiverId, string text, TimeSpan timestamp) { MyMultiplayer.RaiseEvent(this, x => x.OnPlayerMessageRequest, text, senderId.SteamId, receiverId.SteamId, timestamp.Ticks); }
public override void BeforeStart() { base.BeforeStart(); m_botPlayer = Sync.Players.GetPlayerById(new MyPlayer.PlayerId(Sync.MyId, 1)); }
public abstract bool HandleRespawnRequest(bool joinGame, bool newIdentity, long medicalRoom, string respawnShipId, MyPlayer.PlayerId playerId, Vector3D? spawnPosition);
void Players_NewPlayerRequestSucceeded(int playerSerialId) { m_botPlayer = Sync.Players.GetPlayerById(new MyPlayer.PlayerId(Sync.MyId, 1)); }
public abstract void AfterRemovePlayer(MyPlayer player);
private bool TryFindSavingPlayerId(SerializableDictionaryCompat<long, MyObjectBuilder_Checkpoint.PlayerId, ulong> controlledEntities, long controlledObject, out MyPlayer.PlayerId playerId) { playerId = new MyPlayer.PlayerId(); if (MyFakes.REUSE_OLD_PLAYER_IDENTITY == false) return false; if (!Sync.IsServer || Sync.Clients.Count != 1) return false; //Never reuse identity in dedicated server! if (Engine.Platform.Game.IsDedicated) return false; if (controlledEntities == null) return false; bool foundLocalPlayer = false; foreach (var controlledEntityIt in controlledEntities.Dictionary) { // This can used if we load an existing game and want to impersonate the saving player if (controlledEntityIt.Key == controlledObject) { playerId = new MyPlayer.PlayerId(controlledEntityIt.Value.ClientId, controlledEntityIt.Value.SerialId); } if (controlledEntityIt.Value.ClientId == Sync.MyId && controlledEntityIt.Value.SerialId == 0) { foundLocalPlayer = true; } } // We can impersonate the other player only if we don't have an identity set on the server already return foundLocalPlayer == false; }
public abstract int CountAvailableSpawns(MyPlayer player);
public void SetEntityCameraPosition(MyPlayer.PlayerId pid, IMyEntity cameraEntity) { if (LocalHumanPlayer == null || LocalHumanPlayer.Id != pid) return; MyEntityCameraSettings cameraSettings; bool found = Cameras.TryGetCameraSettings(pid, cameraEntity.EntityId, out cameraSettings); if (found) { if (!cameraSettings.IsFirstPerson) { SetCameraController(MyCameraControllerEnum.ThirdPersonSpectator, cameraEntity); MyThirdPersonSpectator.Static.ResetViewerAngle(cameraSettings.HeadAngle); MyThirdPersonSpectator.Static.ResetViewerDistance(cameraSettings.Distance); } } else { if (GetCameraControllerEnum() == MyCameraControllerEnum.ThirdPersonSpectator) MyThirdPersonSpectator.Static.RecalibrateCameraPosition(cameraEntity is MyCharacter); } }
public void Init(IMyGuiControlsParent controlsParent, MyPlayer controller, MyCubeGrid grid, MyTerminalBlock currentBlock, MyGridColorHelper colorHelper) { m_controlsParent = controlsParent; m_controller = controller; m_colorHelper = colorHelper; if (grid == null) { foreach (var control in controlsParent.Controls) control.Visible = false; var label = MyGuiScreenTerminal.CreateErrorLabel(MySpaceTexts.ScreenTerminalError_ShipNotConnected, "ErrorMessage"); controlsParent.Controls.Add(label); return; } m_terminalSystem = grid.GridSystems.TerminalSystem; m_tmpGroup = new MyBlockGroup(grid); m_blockSearch = (MyGuiControlTextbox)m_controlsParent.Controls.GetControlByName("FunctionalBlockSearch"); m_blockSearch.TextChanged += blockSearch_TextChanged; m_blockSearchClear = (MyGuiControlButton)m_controlsParent.Controls.GetControlByName("FunctionalBlockSearchClear"); m_blockSearchClear.ButtonClicked += blockSearchClear_ButtonClicked; m_blockListbox = (MyGuiControlListbox)m_controlsParent.Controls.GetControlByName("FunctionalBlockListbox"); m_blockNameLabel = (MyGuiControlLabel)m_controlsParent.Controls.GetControlByName("BlockNameLabel"); m_blockNameLabel.Text = ""; m_groupName = (MyGuiControlTextbox)m_controlsParent.Controls.GetControlByName("GroupName"); m_groupName.TextChanged += m_groupName_TextChanged; m_showAll = (MyGuiControlButton)m_controlsParent.Controls.GetControlByName("ShowAll"); m_showAll.Selected = m_showAllTerminalBlocks; m_showAll.ButtonClicked += showAll_Clicked; m_showAll.SetToolTip(MySpaceTexts.Terminal_ShowAllInTerminal); m_showAll.IconRotation = 0f; m_showAll.Icon = new MyGuiHighlightTexture { Normal = @"Textures\GUI\Controls\button_hide.dds", Highlight = @"Textures\GUI\Controls\button_unhide.dds", SizePx = new Vector2(40f, 40f), }; m_showAll.Size = new Vector2(0, 0); m_showAll.HighlightType = MyGuiControlHighlightType.FORCED; m_showAll.IconOriginAlign = MyGuiDrawAlignEnum.HORISONTAL_LEFT_AND_VERTICAL_TOP; m_groupSave = (MyGuiControlButton)m_controlsParent.Controls.GetControlByName("GroupSave"); m_groupSave.TextEnum = MySpaceTexts.TerminalButton_GroupSave; m_groupSave.TextAlignment = MyGuiDrawAlignEnum.HORISONTAL_CENTER_AND_VERTICAL_CENTER; m_groupSave.ButtonClicked += groupSave_ButtonClicked; m_groupDelete = (MyGuiControlButton)m_controlsParent.Controls.GetControlByName("GroupDelete"); m_groupDelete.ButtonClicked += groupDelete_ButtonClicked; m_groupDelete.Enabled = false; m_blockListbox.ItemsSelected += blockListbox_ItemSelected; RefreshBlockList(); m_terminalSystem.BlockAdded += TerminalSystem_BlockAdded; m_terminalSystem.BlockRemoved += TerminalSystem_BlockRemoved; m_terminalSystem.GroupAdded += TerminalSystem_GroupAdded; m_terminalSystem.GroupRemoved += TerminalSystem_GroupRemoved; if (currentBlock != null) SelectBlocks(new MyTerminalBlock[] { currentBlock }); }
void Players_PlayersChanged(bool added, MyPlayer.PlayerId playerId) { if (!m_closed) { UpdatePlayerList(); } }