public static MyGuiScreenInventory OpenInventory(MyGuiScreenInventoryType inventoryScreenType, MyEntity otherSide = null, MySmallShipInteractionActionEnum? action = null)
        {
            MyMwcLog.WriteLine("OpenInventory()");


            // return harvester when opening inventory, harvester can update inventory, which would not propagete to inventory screen and closing inventory would override those changes
            var harvester = MySession.PlayerShip.Weapons.GetMountedHarvestingDevice();
            if (harvester != null && harvester.CurrentState != MyHarvestingDeviceEnum.InsideShip)
                harvester.Shot(null);

            StringBuilder otherSideInventoryName = null;
            MyInventory otherSideInventory = null;
            List<MySmallShipBuilderWithName> shipsObjectBuilders = null;
            bool closeOtherSideInventory = false;
            
            m_inventoryScreenType = inventoryScreenType;
            m_shipsInventoryOwner = MySession.Static;
            m_player = MySession.Static.Player;
            m_detectedEntity = otherSide;
            m_detectedAction = action;
            shipsObjectBuilders = new List<MySmallShipBuilderWithName>();
            shipsObjectBuilders.Add(new MySmallShipBuilderWithName(MySession.PlayerShip.GetObjectBuilder(true) as MyMwcObjectBuilder_SmallShip_Player));

            switch(m_inventoryScreenType)
            {            
                case MyGuiScreenInventoryType.GodEditor:
                    LoadGodEditorInventory(ref otherSideInventory, ref otherSideInventoryName, ref shipsObjectBuilders);
                    closeOtherSideInventory = true;
                    break;
                case MyGuiScreenInventoryType.InGameEditor:
                    LoadIngameEditorInventory(ref otherSideInventory, ref otherSideInventoryName);
                    break;
                case MyGuiScreenInventoryType.Game:
                    LoadGameInventory(ref otherSideInventory, ref otherSideInventoryName, ref shipsObjectBuilders);
                    break;
            }
            
            var currentShipBuilder = shipsObjectBuilders[0];            
            shipsObjectBuilders.Sort((x, y) => ((int)x.Builder.ShipType).CompareTo((int)y.Builder.ShipType));
            m_curentIndex = shipsObjectBuilders.IndexOf(currentShipBuilder);
            MyMwcObjectBuilder_Inventory otherSideInventoryBuilder = otherSideInventory != null ? otherSideInventory.GetObjectBuilder(true) : null;
            if (closeOtherSideInventory) 
            {
                Debug.Assert(otherSideInventory != null);
                otherSideInventory.Close();
            }
            m_currentInventoryScreen = new MyGuiScreenInventory(shipsObjectBuilders, m_curentIndex,
                                                                      m_player.Money, m_tradeForMoney,
                                                                      otherSideInventoryBuilder, otherSideInventoryName,
                                                                      m_inventoryScreenType);
            m_currentInventoryScreen.OnSave += Save;
            m_currentInventoryScreen.Closed += OnInventoryScreenClosed;
            MyGuiScreenGamePlay.Static.HideSelectAmmo();
            return m_currentInventoryScreen;
        }
 private void MyGuiScreenInventoryManagerForGameOnOpeningInventoryScreen(MyEntity entity, MySmallShipInteractionActionEnum interactionAction)
 {
     if (MissionEntityIDs.Contains(entity.EntityId.Value.NumericValue))
     {
         MissionEntityIDs.Remove(entity.EntityId.Value.NumericValue);
         if (0 == MissionEntityIDs.Count)
         {
             m_isSuccess = true;
         }
     }
 }
Example #3
0
 public override bool IsMissionEntityNotification(MyEntity entity, MySmallShipInteractionActionEnum action)
 {
     foreach (var objective in ActiveObjectives)
     {
         if (objective.IsMissionEntityNotification(entity, action))
         {
             return(true);
         }
     }
     return(false);
 }
Example #4
0
 public override bool IsMissionEntityNotification(MyEntity entity, MySmallShipInteractionActionEnum action)
 {
     foreach (var objective in ActiveObjectives)
     {
         if (objective.IsMissionEntityNotification(entity, action))
         {
             return true;
         }
     }
     return false;
 }
 private void MyGuiScreenInventoryManagerForGameOnOpeningInventoryScreen(MyEntity entity, MySmallShipInteractionActionEnum interactionAction)
 {
     if (MissionEntityIDs.Contains(entity.EntityId.Value.NumericValue))
     {
         MissionEntityIDs.Remove(entity.EntityId.Value.NumericValue);
         if (0 == MissionEntityIDs.Count)
         {
             m_isSuccess = true;
         }
     }
 }
Example #6
0
 public virtual bool IsMissionEntityNotification(MyEntity entity, MySmallShipInteractionActionEnum action)
 {
     return(false);
 }
Example #7
0
 void OpeningInventoryScreen(MyEntity entity, MySmallShipInteractionActionEnum interactionAction)
 {
     if (entity == this && interactionAction == MySmallShipInteractionActionEnum.Loot)
     {
         m_isLooted = true;
     }
 }
Example #8
0
        /// <summary>
        /// Displays notification
        /// </summary>
        /// <param name="entity">Entity</param>        
        /// <param name="action">Action</param>
        private MyHudNotification.MyNotification DisplayDetectedEntityActionNotification(MyEntity entity, MySmallShipInteractionActionEnum action)
        {
            string entityName = entity.DisplayName;
            //// if we trade throught hangar, we want display prefab container's name, not hangar's name
            //if (entity is MyPrefabHangar)
            //{
            //    entityName = (entity as MyPrefabHangar).GetOwner().DisplayName;
            //}

            //else
            //{
            //    entityName = entity.DisplayName;
            //}


            //get localized entity name
            entityName = entity.GetCorrectDisplayName();

            if (String.IsNullOrWhiteSpace(entityName))
            {
                entityName = MyTextsWrapper.Get(MyTextsWrapperEnum.ThisObject).ToString();
            }

            bool isMissionNotification = MyMissions.IsMissionEntityNotification(entity, action);
            object[] args = new object[3];
            MyTextsWrapperEnum notificationText;
            MyGuiFont notificationFont;
            switch (action)
            {
                case MySmallShipInteractionActionEnum.TradeForFree:
                    notificationFont = MyHudConstants.FRIEND_FONT;
                    notificationText = MyTextsWrapperEnum.NotificationYouCanTradeWith;
                    args[0] = MyGuiManager.GetInput().GetGameControlTextEnum(MyGameControlEnums.INVENTORY);
                    args[1] = entityName;
                    break;
                case MySmallShipInteractionActionEnum.TradeForMoney:
                    notificationFont = MyHudConstants.NEUTRAL_FONT;
                    notificationText = MyTextsWrapperEnum.NotificationYouCanTradeWith;
                    args[0] = MyGuiManager.GetInput().GetGameControlTextEnum(MyGameControlEnums.INVENTORY);
                    args[1] = entityName;
                    break;
                case MySmallShipInteractionActionEnum.Loot:
                    notificationFont = MyHudConstants.ENEMY_FONT;
                    notificationText = MyTextsWrapperEnum.NotificationYouCanLoot;
                    args[0] = MyGuiManager.GetInput().GetGameControlTextEnum(MyGameControlEnums.INVENTORY);
                    args[1] = entityName;
                    break;
                case MySmallShipInteractionActionEnum.Examine:
                    notificationFont = MyHudConstants.NEUTRAL_FONT;
                    notificationText = MyTextsWrapperEnum.NotificationYouCanExamine;
                    args[0] = MyGuiManager.GetInput().GetGameControlTextEnum(MyGameControlEnums.INVENTORY);
                    args[1] = MyGuiManager.GetInput().GetGameControlTextEnum(MyGameControlEnums.USE);
                    args[2] = entityName;
                    break;
                case MySmallShipInteractionActionEnum.ExamineEmpty:
                    notificationFont = MyHudConstants.NEUTRAL_FONT;
                    notificationText = MyTextsWrapperEnum.NotificationYouCanExamineEmpty;
                    args[0] = MyGuiManager.GetInput().GetGameControlTextEnum(MyGameControlEnums.INVENTORY);
                    args[1] = entityName;
                    break;
                case MySmallShipInteractionActionEnum.Blocked:
                    notificationFont = MyHudConstants.ENEMY_FONT;
                    notificationText = MyTextsWrapperEnum.NotificationYouCantExamine;
                    args[0] = entityName;
                    break;
                case MySmallShipInteractionActionEnum.Build:
                    notificationFont = MyHudConstants.NEUTRAL_FONT;
                    notificationText = MyTextsWrapperEnum.NotificationYouCanBuild;
                    break;
                case MySmallShipInteractionActionEnum.Travel:
                    notificationFont = MyHudConstants.FRIEND_FONT;
                    notificationText = MyTextsWrapperEnum.NotificationYouCanTravel;
                    args[0] = MyGuiManager.GetInput().GetGameControlTextEnum(MyGameControlEnums.TRAVEL);
                    args[1] = entityName;
                    break;
                case MySmallShipInteractionActionEnum.Use:
                    IMyUseableEntity useableEntity = entity as IMyUseableEntity;
                    Debug.Assert(useableEntity != null);
                    notificationFont = MyHudConstants.FRIEND_FONT;
                    if (useableEntity.UseProperties.UseText != null)
                    {
                        notificationText = useableEntity.UseProperties.UseText.Value;
                    }
                    else
                    {
                        notificationText = MyTextsWrapperEnum.NotificationYouCanUse;
                    }
                    args[0] = MyGuiManager.GetInput().GetGameControlTextEnum(MyGameControlEnums.USE);
                    args[1] = entityName;
                    break;
                case MySmallShipInteractionActionEnum.Hack:
                    notificationFont = MyHudConstants.NEUTRAL_FONT;
                    notificationText = MyTextsWrapperEnum.NotificationYouCanHack;
                    args[0] = MyGuiManager.GetInput().GetGameControlTextEnum(MyGameControlEnums.USE);
                    args[1] = entityName;
                    break;
                default:
                    throw new Exception();
            }

            MyHudNotification.MyNotification notification = new MyHudNotification.MyNotification(
                notificationText,
                MyHudNotification.GetCurrentScreen(),
                1f,
                isMissionNotification ? MyHudConstants.MISSION_FONT : notificationFont,
                MyGuiDrawAlignEnum.HORISONTAL_CENTER_AND_VERTICAL_CENTER,
                MyHudNotification.DONT_DISAPEAR,
                null,
                false,
                args);
            MyHudNotification.AddNotification(notification);

            return notification;
        }
Example #9
0
 public virtual bool IsMissionEntityNotification(MyEntity entity, MySmallShipInteractionActionEnum action)
 {
     return false;
 }
Example #10
0
 public static bool IsMissionEntityNotification(MyEntity entity, MySmallShipInteractionActionEnum action)
 {
     
     return ActiveMission != null && ActiveMission.IsMissionEntityNotification(entity, action)
         || ActiveMission == null && action == MySmallShipInteractionActionEnum.Travel && MyMissions.IsMissionEntity(entity);
 }
Example #11
0
 public override bool IsMissionEntityNotification(MyEntity entity, MySmallShipInteractionActionEnum action)
 {
     //return base.IsMissionEntityNotification(entity, action);
     return base.IsMissionEntity(entity);
  
 }
Example #12
0
 public override bool IsMissionEntityNotification(MyEntity entity, MySmallShipInteractionActionEnum action)
 {
     //return base.IsMissionEntityNotification(entity, action);
     return(base.IsMissionEntity(entity));
 }