Exemplo n.º 1
0
 private static bool HasPlayerShipFalseFriendStatus(MySmallShip playerShip, IMyHasFaction anotherFaction) 
 {
     return (playerShip.FalseFactions & anotherFaction.Faction) != 0;
     //foreach (MyMwcObjectBuilder_FactionEnum falseFaction in playerShip.FalseFactions) 
     //{
     //    if (GetFactionsRelation(falseFaction, anotherFaction.Faction) == MyFactionRelationEnum.Friend) 
     //    {
     //        return true;
     //    }
     //}
     //return false;
 }
Exemplo n.º 2
0
        /// <summary>
        /// Use this method to get relationship between two entities
        /// </summary>
        /// <param name="hasFaction1">Entity 1</param>
        /// <param name="hasFaction2">Entity 2</param>
        /// <returns></returns>
        public static MyFactionRelationEnum GetFactionsRelation(IMyHasFaction hasFaction1, IMyHasFaction hasFaction2) 
        {
            Debug.Assert(hasFaction1 != hasFaction2);
            MyFactionRelationEnum result;

            if (MySession.Static != null && MySession.Static.Player != null && MySession.Static.Player.Ship != null)
            {
                if (hasFaction1.Faction == MySession.Static.Player.Faction && HasPlayerShipFalseFriendStatus(MySession.Static.Player.Ship as MySmallShip, hasFaction2))
                {
                    result = MyFactionRelationEnum.Friend;
                }
                else if (hasFaction2.Faction == MySession.Static.Player.Faction && HasPlayerShipFalseFriendStatus(MySession.Static.Player.Ship as MySmallShip, hasFaction1))
                {
                    result = MyFactionRelationEnum.Friend;
                }
                else
                {
                    result = GetFactionsRelation(hasFaction1.Faction, hasFaction2.Faction);
                }
            }
            else 
            {
                result = GetFactionsRelation(hasFaction1.Faction, hasFaction2.Faction);
            }

            return result;
        }