void IMyEntityController.TakeControl(IMyControllableEntity entity) { if (entity is Sandbox.Game.Entities.IMyControllableEntity) { TakeControl(entity as Sandbox.Game.Entities.IMyControllableEntity); } }
public static void GetLinearVelocity(this IMyControllableEntity controlledEntity, ref Vector3 velocityVector, bool useRemoteControlVelocity = true) { if (controlledEntity.Entity.Physics != null) { velocityVector = (controlledEntity.Entity.Physics != null) ? controlledEntity.Entity.Physics.LinearVelocity : Vector3.Zero; } else { MyCockpit cockpit = controlledEntity as MyCockpit; if (cockpit != null) { velocityVector = (cockpit.CubeGrid.Physics != null) ? cockpit.CubeGrid.Physics.LinearVelocity : Vector3.Zero; } else { MyRemoteControl control = controlledEntity as MyRemoteControl; if ((control != null) & useRemoteControlVelocity) { velocityVector = (control.CubeGrid.Physics != null) ? control.CubeGrid.Physics.LinearVelocity : Vector3.Zero; } else { MyLargeTurretBase base2 = controlledEntity as MyLargeTurretBase; if (base2 != null) { velocityVector = (base2.CubeGrid.Physics != null) ? base2.CubeGrid.Physics.LinearVelocity : Vector3.Zero; } } } } }
public static void SwitchControl(this IMyControllableEntity entity, IMyControllableEntity newControlledEntity) { if (entity.ControllerInfo.Controller != null) { entity.ControllerInfo.Controller.TakeControl(newControlledEntity); } }
protected virtual void Controller_ControlledEntityChanged(IMyControllableEntity oldEntity, IMyControllableEntity newEntity) { if (oldEntity == null && newEntity is MyCharacter) { EraseRespawn(); } m_navigation.ChangeEntity(newEntity); m_navigation.AimWithMovement(); var newCharacter = newEntity as MyCharacter; if (newCharacter != null) { var character = m_player.Controller.ControlledEntity as MyCharacter; var jetpack = newCharacter.JetpackComp; if (jetpack != null) { jetpack.TurnOnJetpack(false); } } if (HasLogic) { m_botLogic.OnControlledEntityChanged(newEntity); } }
private void WatchEntity(IMyControllableEntity entity) { var container = (entity as IMyEntity)?.Components; if (container == null) { return; } var ent = entity.Entity; if (ent == null) { return; } _log.Debug($"Beginning to watch entity {ent.DisplayName}"); ent.PositionComp.OnPositionChanged += OnPositionChanged; OnPositionChanged(ent.PositionComp); var p = ent; while (p != null) { p.NeedsWorldMatrix = true; p = p.Parent; } }
private void Controller_ControlledEntityChanged(IMyControllableEntity oldEnt, IMyControllableEntity newEnt) { if (newEnt == null) { return; } var grid = newEnt.Entity.Parent as MyCubeGrid; if (grid == null) { return; } colorList.Clear(); // Scan grid for colors foreach (var block in grid.GetBlocks()) { // Filter blocks builded by player if (block.BuiltBy != MySession.Static.LocalHumanPlayer.Identity.IdentityId) { continue; } // unique list of colors in grid colorList.Add(block.ColorMaskHSV); if (colorList.Count >= NUMBER_OF_COLORS_TO_ACHIEV) { //Final condition NotifyAchieved(); MySession.Static.LocalHumanPlayer.Controller.ControlledEntityChanged -= Controller_ControlledEntityChanged; return; } } }
public DroneNavigation(IMyCubeGrid ship, IMyControllableEntity shipControls, List <IMyEntity> nearbyFloatingObjects, double maxEngagementRange) { //stuff passed from sip _shipControls = shipControls; Ship = ship; GridTerminalSystem = MyAPIGateway.TerminalActionsHelper.GetTerminalSystemForGrid(ship); _nearbyFloatingObjects = nearbyFloatingObjects; var value = (ship.LocalAABB.Max - ship.LocalAABB.Center).Length(); if (ship.Physics.Mass > 100000) { FollowRange = 600 + value; } else { FollowRange = 400 + value; } ShipOrientation(); FindGyros(); _initialized = true; }
public virtual UseActionResult CanUse(UseActionEnum actionEnum, IMyControllableEntity user) { if (m_pilot != null) { return(UseActionResult.UsedBySomeoneElse); } if (!IsFunctional) { return(UseActionResult.CockpitDamaged); } long identityId = user.ControllerInfo.ControllingIdentityId; if (identityId != 0) { bool accessAllowed = HasPlayerAccess(identityId); if (!accessAllowed) { return(UseActionResult.AccessDenied); } return(UseActionResult.OK); } return(UseActionResult.AccessDenied); }
public static IMyEntity FindLookAtEntity(IMyControllableEntity controlledEntity, bool findShips, bool findCubes, bool findPlayers, bool findAsteroids, bool findPlanets, bool findReplicable) { IMyEntity entity; double distance; Vector3D hitPoint; FindLookAtEntity(controlledEntity, true, false, out entity, out distance, out hitPoint, findShips, findCubes, findPlayers, findAsteroids, findPlanets, findReplicable); return entity; }
private void RaiseControlledEntityChanged(IMyControllableEntity old, IMyControllableEntity entity) { var handler = ControlledEntityChanged; if (handler != null) { handler(old, entity); } }
void RaiseUseSuccess(UseActionEnum actionEnum, IMyControllableEntity usedBy) { var handler = UseSuccess; if (handler != null) { handler(actionEnum, usedBy); } }
protected override void sync_UseSuccess(UseActionEnum actionEnum, IMyControllableEntity user) { /*if (user.Entity == MySession.Static.LocalCharacter) * { * MySession.Static.CameraAttachedToChanged += CameraAttachedToChanged; * }*/ base.sync_UseSuccess(actionEnum, user); }
void RaiseUseFailure(UseActionEnum actionEnum, UseActionResult actionResult, IMyControllableEntity usedBy) { var handler = UseFailed; if (handler != null) { handler(actionEnum, actionResult, usedBy); } }
public void TakeControl(IMyControllableEntity entity) { if (ControlledEntity == entity) { return; } if (entity != null && entity.ControllerInfo.Controller != null) { Debug.Fail("Entity controlled by another controller, release it first"); return; } var old = ControlledEntity; if (old != null) { var entityCameraSettings = old.GetCameraEntitySettings(); float headLocalXAngle = old.HeadLocalXAngle; float headLocalYAngle = old.HeadLocalYAngle; old.Entity.OnClosing -= m_controlledEntityClosing; ControlledEntity = null; old.ControllerInfo.Controller = null; // This will call OnControlReleased bool firstPerson = entityCameraSettings != null? entityCameraSettings.IsFirstPerson : (MySession.GetCameraControllerEnum() != MyCameraControllerEnum.ThirdPersonSpectator); if (!MySandboxGame.IsDedicated) { MySession.Static.Cameras.SaveEntityCameraSettings( Player.Id, old.Entity.EntityId, firstPerson, MyThirdPersonSpectator.Static.GetDistance(), headLocalXAngle, headLocalYAngle); } } if (entity != null) { ControlledEntity = entity; ControlledEntity.Entity.OnClosing += m_controlledEntityClosing; ControlledEntity.ControllerInfo.Controller = this; // This will call OnControlAcquired if (!MySandboxGame.IsDedicated && ControlledEntity.Entity is Sandbox.ModAPI.Interfaces.IMyCameraController) { MySession.SetEntityCameraPosition(Player.Id, ControlledEntity.Entity); } } if (old != entity) { RaiseControlledEntityChanged(old, entity); } }
public static void SwitchControl(this IMyControllableEntity entity, IMyControllableEntity newControlledEntity) { Debug.Assert(entity != null, "Entity is null"); Debug.Assert(entity.ControllerInfo.Controller != null, "Entity is not controlled"); if (entity.ControllerInfo.Controller != null) { entity.ControllerInfo.Controller.TakeControl(newControlledEntity); } }
private void ReturnControl(IMyControllableEntity nextControllableEntity) { //Check if it was already switched by server if (ControllerInfo.Controller != null) { this.SwitchControl(nextControllableEntity); } PreviousControlledEntity = null; }
protected override void sync_UseSuccess(UseActionEnum actionEnum, IMyControllableEntity user) { base.sync_UseSuccess(actionEnum, user); AcquireControl(user); if (user.ControllerInfo != null && user.ControllerInfo.Controller != null) { user.SwitchControl(this); } }
private void OnControlledEntityChanged(IMyControllableEntity old, IMyControllableEntity @new) { if (old != null) { UnwatchEntity(old); } if (@new != null) { WatchEntity(@new); } }
public void ChangeEntity(IMyControllableEntity newEntity) { m_entity = newEntity == null ? null : newEntity.Entity; if (m_entity != null) { m_forwardVector = PositionAndOrientation.Forward; m_upVector = PositionAndOrientation.Up; m_speed = 0.0f; m_rotationSpeedModifier = 1; } }
public void ChangeEntity(IMyControllableEntity newEntity) { this.m_entity = newEntity?.Entity; if (this.m_entity != null) { this.m_forwardVector = (Vector3)this.PositionAndOrientation.Forward; this.m_upVector = (Vector3)this.PositionAndOrientation.Up; this.m_speed = 0f; this.m_rotationSpeedModifier = 1f; } }
static void UseFailureCallback(MySyncControllableEntity sync, ref UseObject_UseMsg msg, MyNetworkClient sender) { MyEntity controlledEntity; bool userFound = MyEntities.TryGetEntityById <MyEntity>(msg.UsedByEntityId, out controlledEntity); Debug.Assert(userFound); IMyControllableEntity controllableEntity = controlledEntity as IMyControllableEntity; Debug.Assert(controllableEntity != null, "Controllable entity needs to get control from another controllable entity"); sync.RaiseUseFailure(msg.UseAction, msg.UseResult, controllableEntity); }
public override UseActionResult CanUse(UseActionEnum actionEnum, IMyControllableEntity user) { if (IsWorking) { return(base.CanUse(actionEnum, user)); } else { return(UseActionResult.Unpowered); } }
public void TakeControl(IMyControllableEntity entity) { if (ControlledEntity == entity) return; if (entity != null && entity.ControllerInfo.Controller != null) { Debug.Fail("Entity controlled by another controller, release it first"); return; } var old = ControlledEntity; if (old != null) { var entityCameraSettings = old.GetCameraEntitySettings(); float headLocalXAngle = old.HeadLocalXAngle; float headLocalYAngle = old.HeadLocalYAngle; old.Entity.OnClosing -= m_controlledEntityClosing; old.ControllerInfo.Controller = null; // This will call OnControlReleased ControlledEntity = null; bool firstPerson = entityCameraSettings != null? entityCameraSettings.IsFirstPerson : (MySession.Static.GetCameraControllerEnum() != MyCameraControllerEnum.ThirdPersonSpectator); if (!MySandboxGame.IsDedicated) { MySession.Static.Cameras.SaveEntityCameraSettings( Player.Id, old.Entity.EntityId, firstPerson, MyThirdPersonSpectator.Static.GetDistance(), headLocalXAngle, headLocalYAngle); } } if (entity != null) { ControlledEntity = entity; ControlledEntity.Entity.OnClosing += m_controlledEntityClosing; ControlledEntity.ControllerInfo.Controller = this; // This will call OnControlAcquired if (!MySandboxGame.IsDedicated && ControlledEntity.Entity is Sandbox.ModAPI.Interfaces.IMyCameraController) { MySession.Static.SetEntityCameraPosition(Player.Id, ControlledEntity.Entity); } } if (old != entity) RaiseControlledEntityChanged(old, entity); }
public virtual void RequestUse(UseActionEnum actionEnum, IMyControllableEntity usedBy) { Debug.Assert(Entity is IMyUsableEntity, "Entity must implement IMyUsableEntity to use it"); UseObject_UseMsg msg = new UseObject_UseMsg(); msg.EntityId = SyncedEntityId; msg.UseAction = actionEnum; msg.UsedByEntityId = usedBy.Entity.EntityId; MySession.Static.SyncLayer.SendMessageToServer(ref msg); }
private static bool IsReportedPlayer(MyEntity entity) { if (entity != null) { IMyControllableEntity entity2 = entity as IMyControllableEntity; if ((entity2 == null) || !entity2.ControllerInfo.IsLocallyControlled()) { return((entity.Parent != null) && IsReportedPlayer(entity.Parent)); } } return(true); }
public override void UpdateBeforeSimulation100() { base.UpdateBeforeSimulation100(); bool flag = base.HasLocalPlayerAccess(); if (base.IsWorking) { bool flag2 = false; if (flag && (MySession.Static.LocalCharacter != null)) { if (this.m_oreDetectorComponent.BroadcastUsingAntennas) { MyCharacter localCharacter = MySession.Static.LocalCharacter; MyCubeGrid topMostParent = base.GetTopMostParent(null) as MyCubeGrid; if (topMostParent != null) { MyGroups <MyCubeGrid, MyGridLogicalGroupData> .Group group = MyCubeGridGroups.Static.Logical.GetGroup(topMostParent); if ((group != null) && localCharacter.HasAccessToLogicalGroup(group.GroupData)) { flag2 = true; } } } else { IMyControllableEntity controlledEntity = MySession.Static.ControlledEntity; if ((controlledEntity != null) && (controlledEntity.Entity != null)) { MyCubeGrid topMostParent = controlledEntity.Entity.GetTopMostParent(null) as MyCubeGrid; if (topMostParent != null) { MyGroups <MyCubeGrid, MyGridLogicalGroupData> .Group group = MyCubeGridGroups.Static.Logical.GetGroup(topMostParent); MyGroups <MyCubeGrid, MyGridLogicalGroupData> .Group group3 = MyCubeGridGroups.Static.Logical.GetGroup(base.CubeGrid); if (ReferenceEquals(topMostParent, base.CubeGrid) || (((group != null) && (group3 != null)) && (group.GroupData == group3.GroupData))) { flag2 = true; } } } } } if (flag2) { this.m_oreDetectorComponent.Update(base.PositionComp.GetPosition(), base.EntityId, false); this.m_oreDetectorComponent.SetRelayedRequest = true; } else { this.m_oreDetectorComponent.Clear(); } } }
protected override void Controller_ControlledEntityChanged(IMyControllableEntity oldEntity, IMyControllableEntity newEntity) { base.Controller_ControlledEntityChanged(oldEntity, newEntity); if (newEntity is MyCharacter) { var character = m_player.Controller.ControlledEntity as MyCharacter; character.EnableJetpack(false); if (StartingWeaponId.SubtypeId != MyStringHash.NullOrEmpty) { AddItems(newEntity as MyCharacter); } } }
private void ControlledEntityChanged(IMyControllableEntity old, IMyControllableEntity result) { var oldEnt = old as IMyEntity; var resultEnt = result as IMyEntity; if (oldEnt != null) { RemoveEntity(oldEnt); } if (resultEnt != null) { TrackEntity(resultEnt, MyAPIGateway.Session.SessionSettings.ViewDistance); } }
protected virtual void Controller_ControlledEntityChanged(IMyControllableEntity oldEntity, IMyControllableEntity newEntity) { if (oldEntity == null && newEntity is MyCharacter) { m_deathTimestamp = 0; m_respawnRequestSent = false; } m_navigation.ChangeEntity(newEntity); m_navigation.ResetAiming(true); if (HasLogic) { m_botLogic.OnControlledEntityChanged(newEntity); } }
private void GetUpdatePositions() { this.m_tmpUpdatePositions.Clear(); using (IEnumerator <MyPlayer> enumerator = Sync.Players.GetOnlinePlayers().GetEnumerator()) { while (enumerator.MoveNext()) { IMyControllableEntity controlledEntity = enumerator.Current.Controller.ControlledEntity; if (controlledEntity != null) { this.m_tmpUpdatePositions.Add(controlledEntity.Entity.PositionComp.GetPosition()); } } } }
public static void handle_60Hz() { /* * is_spectator_mode_on = false; * if (MyAPIGateway.Session.SessionSettings.EnableSpectator) * { * var spectator_controller = MyAPIGateway.Session.CameraController as MySpectatorCameraController; * if (spectator_controller != null) * is_spectator_mode_on = spectator_controller.SpectatorCameraMovement == MySpectatorCameraMovementEnum.UserControlled; * } */ local_player = MyAPIGateway.Session.LocalHumanPlayer; local_controller = local_player?.Controller.ControlledEntity; }
private void OnBotControlledEntityChanged(IMyControllableEntity oldControllable, IMyControllableEntity newControllable) { var oldCharacter = oldControllable as MyCharacter; var newCharacter = newControllable as MyCharacter; if (oldCharacter != null) { oldCharacter.CharacterDied -= BotCharacterDied; } if (newCharacter != null) { newCharacter.CharacterDied += BotCharacterDied; } }
public void OpenControlMenu(IMyControllableEntity controlledEntity) { m_controlMenu = null; if (controlledEntity is MyCharacter) { SetupCharacterScreen(controlledEntity as MyCharacter); } else if (controlledEntity is MyShipController) { SetupSpaceshipScreen(controlledEntity as MyShipController); } if (IsControlMenuInitialized) { m_controlMenu.RecreateControls(false); MyGuiSandbox.AddScreen(MyGuiScreenGamePlay.ActiveGameplayScreen = m_controlMenu); } }
public DroneNavigation(IMyCubeGrid ship, IMyControllableEntity shipControls, List<IMyEntity> nearbyFloatingObjects, double maxEngagementRange) { //stuff passed from sip _shipControls = shipControls; Ship = ship; GridTerminalSystem = MyAPIGateway.TerminalActionsHelper.GetTerminalSystemForGrid(ship); _nearbyFloatingObjects = nearbyFloatingObjects; var value = (ship.LocalAABB.Max - ship.LocalAABB.Center).Length(); if (ship.Physics.Mass > 100000) FollowRange = 600 + value; else FollowRange = 400 + value; ShipOrientation(); FindGyros(); _initialized = true; }
private bool CheckPreviousEntity(IMyControllableEntity entity) { if (entity is MyCharacter) { return true; } if (entity is MyCryoChamber) { return false; } if (entity is MyCockpit) { return true; } return false; }
private void AcquireControl(IMyControllableEntity previousControlledEntity) { if (!CheckPreviousEntity(previousControlledEntity)) { return; } if (m_autoPilotEnabled) { SetAutoPilotEnabled(false); } PreviousControlledEntity = previousControlledEntity; var shipController = (PreviousControlledEntity as MyShipController); if (shipController != null) { m_enableFirstPerson = shipController.EnableFirstPerson; cockpitPilot = shipController.Pilot; if (cockpitPilot != null) { cockpitPilot.CurrentRemoteControl = this; } } else { m_enableFirstPerson = true; var character = PreviousControlledEntity as MyCharacter; if (character != null) { character.CurrentRemoteControl = this; } } //MySession.Static.SetCameraController(MyCameraControllerEnum.Entity, this); if (MyCubeBuilder.Static.IsActivated) { //MyCubeBuilder.Static.Deactivate(); MySession.Static.GameFocusManager.Clear(); } UpdateEmissivity(); }
private bool TryFindSavedEntity() { MyEntity oldControllerEntity; if (m_savedPreviousControlledEntityId.HasValue && MyEntities.TryGetEntityById(m_savedPreviousControlledEntityId.Value, out oldControllerEntity)) { m_previousControlledEntity = (IMyControllableEntity)oldControllerEntity; if (m_previousControlledEntity != null) { AddPreviousControllerEvents(); if (m_previousControlledEntity is MyCockpit) { cockpitPilot = (m_previousControlledEntity as MyCockpit).Pilot; } return true; } } return false; }
public bool HasExtendedControl(IMyControllableEntity baseEntity, MyEntity secondEntity) { return baseEntity.ControllerInfo.Controller == GetEntityController(secondEntity); }
protected virtual void Controller_ControlledEntityChanged(IMyControllableEntity oldEntity, IMyControllableEntity newEntity) { if (oldEntity == null && newEntity is MyCharacter) EraseRespawn(); m_navigation.ChangeEntity(newEntity); m_navigation.AimWithMovement(); var newCharacter = newEntity as MyCharacter; if (newCharacter != null) { var character = m_player.Controller.ControlledEntity as MyCharacter; var jetpack = newCharacter.JetpackComp; if(jetpack != null) jetpack.TurnOnJetpack(false); } if (HasLogic) m_botLogic.OnControlledEntityChanged(newEntity); }
protected virtual void sync_UseSuccess(UseActionEnum actionEnum, IMyControllableEntity user) { }
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); }
protected virtual void Controller_ControlledEntityChanged(IMyControllableEntity oldEntity, IMyControllableEntity newEntity) { if (oldEntity == null && newEntity is MyCharacter) { m_deathTimestamp = 0; m_respawnRequestSent = false; } m_navigation.ChangeEntity(newEntity); m_navigation.ResetAiming(true); if (HasLogic) m_botLogic.OnControlledEntityChanged(newEntity); }
public void ReduceControl(IMyControllableEntity baseEntity, MyEntity entityWhichLoosesControl) { if (!TryReduceControl(baseEntity, entityWhichLoosesControl)) { Debug.Fail("Both entities must be controlled by same player"); } }
UseActionResult IMyUsableEntity.CanUse(UseActionEnum actionEnum, IMyControllableEntity user) { return MarkedForClose ? UseActionResult.Closed : UseActionResult.OK; // When object is not collected, it's usable }
private void controller_ControlledEntityChanged(IMyControllableEntity oldEntity, IMyControllableEntity newEntity) { Debug.Assert(oldEntity != null || newEntity != null, "Both old and new entity cannot be null!"); Debug.Assert(oldEntity == null || oldEntity.ControllerInfo.Controller == null, "Inconsistency! Controller of old entity is not empty!"); Debug.Assert(oldEntity == null || m_controlledEntities.ContainsKey((oldEntity as MyEntity).EntityId), "Old entity control not in controller collection!"); Debug.Assert(newEntity == null || !m_controlledEntities.ContainsKey((newEntity as MyEntity).EntityId), "New entity control is already in the controller collection!"); var controller = (newEntity == null ? oldEntity.ControllerInfo.Controller : newEntity.ControllerInfo.Controller); if (oldEntity != null) m_controlledEntities.Remove((oldEntity as MyEntity).EntityId, immediate: true); if (newEntity != null) m_controlledEntities.Add((newEntity as MyEntity).EntityId, controller.Player.Id, immediate: true); }
protected override void sync_UseSuccess(UseActionEnum actionEnum, IMyControllableEntity user) { base.sync_UseSuccess(actionEnum, user); AcquireControl(user); if (user.ControllerInfo != null && user.ControllerInfo.Controller != null) { user.SwitchControl(this); RefreshTerminal(); } //switch to binded camera if (m_bindedCamera != 0) { MyEntity entity; if (MyEntities.TryGetEntityById(m_bindedCamera, out entity)) { MyCameraBlock camera = entity as MyCameraBlock; if (camera != null) { camera.RequestSetView(); } else { m_bindedCamera.Value = 0; } } else { m_bindedCamera.Value = 0; } } }
private static bool GetConnectorStatus(IMyControllableEntity shipController) { return (shipController as MyShipController).CubeGrid.GridSystems.ConveyorSystem.Connected; }
public UseActionResult CanUse(UseActionEnum actionEnum, IMyControllableEntity user) { if (m_previousControlledEntity != null && user != m_previousControlledEntity) { return UseActionResult.UsedBySomeoneElse; } return UseActionResult.OK; }
public bool TryReduceControl(IMyControllableEntity baseEntity, MyEntity entityWhichLoosesControl) { MyPlayer.PlayerId playerB; var controller = baseEntity.ControllerInfo.Controller; if (controller != null && m_controlledEntities.TryGetValue(entityWhichLoosesControl.EntityId, out playerB) && controller.Player.Id == playerB) { RemoveControlledEntity(entityWhichLoosesControl); return true; } return false; }
void sync_UseFailed(UseActionEnum actionEnum, UseActionResult actionResult, IMyControllableEntity user) { if (user != null && user.ControllerInfo.IsLocallyHumanControlled()) { if (actionResult == UseActionResult.UsedBySomeoneElse) MyHud.Notifications.Add(new MyHudNotification(MySpaceTexts.AlreadyUsedBySomebodyElse, 2500, MyFontEnum.Red)); else if (actionResult == UseActionResult.AccessDenied) MyHud.Notifications.Add(MyNotificationSingletons.AccessDenied); else if (actionResult == UseActionResult.Unpowered) MyHud.Notifications.Add(new MyHudNotification(MySpaceTexts.BlockIsNotPowered, 2500, MyFontEnum.Red)); else if (actionResult == UseActionResult.CockpitDamaged) MyHud.Notifications.Add(new MyHudNotification(MySpaceTexts.Notification_CockpitIsDamaged, 2500, MyFontEnum.Red)); } }
public new void SetEntity(IMyControllableEntity entity) { m_entity = entity as MyShipController; }
protected override void sync_UseSuccess(UseActionEnum actionEnum, IMyControllableEntity user) { base.sync_UseSuccess(actionEnum, user); AcquireControl(user); if (user.ControllerInfo != null && user.ControllerInfo.Controller != null) { user.SwitchControl(this); RefreshTerminal(); } }
public void ReduceAllControl(IMyControllableEntity baseEntity) { MyPlayer.PlayerId playerId; bool success = m_controlledEntities.TryGetValue(baseEntity.Entity.EntityId, out playerId); Debug.Assert(success, "Could not get the controller of the base entity!"); if (!success) return; foreach (var entry in m_controlledEntities) { if (entry.Value != playerId) continue; // Only take entities controlled by the same controller as baseEntity if (entry.Key == baseEntity.Entity.EntityId) continue; // But don't reduce control from the base entity itself MyEntity entity = null; MyEntities.TryGetEntity(entry.Key, out entity); Debug.Assert(entity != null, "Could not find controlled entity!"); if (entity == null) continue; RemoveControlledEntityProxy(entity, immediateOnServer: false); } m_controlledEntities.ApplyRemovals(); WriteDebugInfo(); }
public virtual UseActionResult CanUse(UseActionEnum actionEnum, IMyControllableEntity user) { if (m_pilot != null) return UseActionResult.UsedBySomeoneElse; if (!IsFunctional) return UseActionResult.CockpitDamaged; long identityId = user.ControllerInfo.ControllingIdentityId; if (identityId != 0) { bool accessAllowed = HasPlayerAccess(identityId); if (!accessAllowed) return UseActionResult.AccessDenied; return UseActionResult.OK; } return UseActionResult.AccessDenied; }
public void SetEntity(IMyControllableEntity entity) { m_entity = entity; }
public void ExtendControl(IMyControllableEntity baseEntity, MyEntity entityGettingControl) { var controller = baseEntity.ControllerInfo.Controller; if (controller != null) { // This can fail when something else is controlling entityGettingControl // This is case when player entered second cockpit (and first cockpit is controlled by someone) TrySetControlledEntity(controller.Player.Id, entityGettingControl); } else { Debug.Fail("'entityWithControl' is not controlled"); } }