示例#1
0
        public static bool CanTrade(MyEntity entityToTrade, params object[] args)
        {
            if (!ControlIsInPlayerShip() || IsBlocked(entityToTrade, args))
            {
                return(false);
            }

            bool hasRightType = /*(entityToTrade is MySmallShip) || */ (entityToTrade is MyPrefabHangar);

            if (!hasRightType)
            {
                return(false);
            }

            MySmallShip           smallShip       = GetSmallShipFromArguments(args);
            MyFactionRelationEnum factionRelation = MyFactions.GetFactionsRelation(entityToTrade, smallShip);

            if (entityToTrade is MyPrefabHangar)
            {
                MyPrefabHangar prefabHangar = entityToTrade as MyPrefabHangar;
                return((factionRelation == MyFactionRelationEnum.Neutral || factionRelation == MyFactionRelationEnum.Friend || prefabHangar.UseProperties.IsHacked) &&
                       prefabHangar.IsWorking() && prefabHangar.PrefabHangarType == MyMwcObjectBuilder_PrefabHangar_TypesEnum.VENDOR && IsTargetVisible(smallShip, prefabHangar));
            }
            else
            {
                Debug.Fail("This shouldn't happen! You can't trade with bot");
                return(factionRelation == MyFactionRelationEnum.Neutral &&
                       !IsShipLootable(entityToTrade as MySmallShip) &&
                       IsLookAtTarget(smallShip, entityToTrade));
            }
        }
示例#2
0
        public static bool CanTradeForFree(MyEntity entityToTrade, params object[] args)
        {
            if (!ControlIsInPlayerShip() || IsBlocked(entityToTrade, args))
            {
                return(false);
            }

            // temporary disabled trading for free with smallships
            bool hasRightType = /*(entityToTrade is MySmallShip) || */ (entityToTrade is MyPrefabHangar || entityToTrade is MyDrone);

            if (!hasRightType)
            {
                return(false);
            }

            MySmallShip           smallShip       = GetSmallShipFromArguments(args);
            MyFactionRelationEnum factionRelation = MyFactions.GetFactionsRelation(entityToTrade, smallShip);

            if (entityToTrade is MyPrefabHangar)
            {
                MyPrefabHangar prefabHangar = entityToTrade as MyPrefabHangar;
                return(prefabHangar.PrefabHangarType == MyMwcObjectBuilder_PrefabHangar_TypesEnum.HANGAR &&
                       factionRelation == MyFactionRelationEnum.Friend &&
                       prefabHangar.IsWorking() && IsTargetVisible(smallShip, prefabHangar));
            }
            else if (entityToTrade is MyDrone)
            {
                return(factionRelation == MyFactionRelationEnum.Friend &&
                       !IsShipLootable(entityToTrade as MySmallShip) &&
                       IsCustomLookAtTarget(smallShip, entityToTrade, entityToTrade.WorldVolume.Radius * 1.0f));
            }
            else
            {
                return(factionRelation == MyFactionRelationEnum.Friend &&
                       !IsShipLootable(entityToTrade as MySmallShip) &&
                       IsLookAtTarget(smallShip, entityToTrade));
            }
        }