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)); } }
static void MyFactions_OnFactionStatusChanged(MyMwcObjectBuilder_FactionEnum faction1, MyMwcObjectBuilder_FactionEnum faction2, MyFactionRelationEnum previousRelation, bool display, bool save) { if (!display) { return; } MyTextsWrapperEnum relationChangeEnum = MyTextsWrapperEnum.General; MyFactionRelationEnum newRelation = MyFactions.GetFactionsRelation(faction1, faction2); switch (newRelation) { case MyFactionRelationEnum.Friend: relationChangeEnum = MyTextsWrapperEnum.GlobalEventFactionRelationChange_NeutralToFriends; break; case MyFactionRelationEnum.Neutral: if (previousRelation == MyFactionRelationEnum.Friend) { relationChangeEnum = MyTextsWrapperEnum.GlobalEventFactionRelationChange_FriendsToNeutral; } else { relationChangeEnum = MyTextsWrapperEnum.GlobalEventFactionRelationChange_EnemyToNeutral; } break; case MyFactionRelationEnum.Enemy: relationChangeEnum = MyTextsWrapperEnum.GlobalEventFactionRelationChange_NeutralToEnemy; break; } MyHudNotification.AddNotification(new MyHudNotification.MyNotification(relationChangeEnum, 5000, null, new object[] { MyFactionConstants.GetFactionProperties(faction1).Name.ToString(), MyFactionConstants.GetFactionProperties(faction2).Name.ToString() })); }
void MyFactions_OnFactionStatusChanged(MyMwcObjectBuilder_FactionEnum faction1, MyMwcObjectBuilder_FactionEnum faction2, MyFactionRelationEnum previousRelation, bool display, bool save) { if (!save) { return; } float relation = MyFactions.GetFactionsStatus(faction1, faction2); AddFactionRelationChange(faction1, faction2, relation); }
private static bool CanShout(IMyObjectToDetect detectedObject) { MyEntity detectedEntity = detectedObject as MyEntity; if (detectedEntity != null) { MyFactionRelationEnum factionRelation = MyFactions.GetFactionsRelation(MySession.PlayerShip, detectedEntity); if (detectedEntity is MySmallShipBot && factionRelation != MyFactionRelationEnum.Friend) { MySmallShipBot bot = detectedEntity as MySmallShipBot; return(!bot.IsParked() && !bot.IsPilotDead()); } if (detectedEntity is MyPrefabLargeWeapon && factionRelation == MyFactionRelationEnum.Enemy) { MyPrefabLargeWeapon largeWeapon = detectedEntity as MyPrefabLargeWeapon; return(largeWeapon.IsWorking()); } } return(false); }
private void SetTransparentParameters(out Vector4 color, out MyTransparentMaterialEnum?faceMaterial, out MyTransparentMaterialEnum?lineMaterial) { if (Game.Editor.MyEditor.Static.IsActive()) { faceMaterial = MyTransparentMaterialEnum.ObjectiveDummyFace; lineMaterial = MyTransparentMaterialEnum.ObjectiveDummyLine; } else { faceMaterial = null; lineMaterial = null; } if (MyMissions.IsMissionEntity(this)) { color = MyHudConstants.MISSION_CUBE_COLOR; } else { MyFactionRelationEnum status = MyFactions.GetFactionsRelation(this, MySession.PlayerShip); switch (status) { case MyFactionRelationEnum.Friend: color = MyHudConstants.FRIEND_CUBE_COLOR; break; case MyFactionRelationEnum.Enemy: color = MyHudConstants.ENEMY_CUBE_COLOR; break; case MyFactionRelationEnum.Neutral: color = MyHudConstants.NEUTRAL_CUBE_COLOR; break; default: throw new MyMwcExceptionApplicationShouldNotGetHere(); } } }
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)); } }
internal MyGuiFont GetSenderFont(MyFactionRelationEnum senderRelation) { switch (senderRelation) { case MyFactionRelationEnum.Enemy: return MyGuiManager.GetFontMinerWarsRed(); case MyFactionRelationEnum.Friend: return MyGuiManager.GetFontMinerWarsGreen(); case MyFactionRelationEnum.Neutral: return MyGuiManager.GetFontMinerWarsWhite(); default: return MyGuiManager.GetFontMinerWarsBlue(); } }
private MyGuiFont GetSenderFont(MyFactionRelationEnum senderRelation) { return(MyGuiScreenGamePlay.Static.GetSenderFont(senderRelation)); }
static void MyFactions_OnFactionStatusChanged(MyMwcObjectBuilder_FactionEnum faction1, MyMwcObjectBuilder_FactionEnum faction2, MyFactionRelationEnum previousRelation, bool display, bool save) { if (!display) { return; } MyTextsWrapperEnum relationChangeEnum = MyTextsWrapperEnum.General; MyFactionRelationEnum newRelation = MyFactions.GetFactionsRelation(faction1, faction2); switch (newRelation) { case MyFactionRelationEnum.Friend: relationChangeEnum = MyTextsWrapperEnum.GlobalEventFactionRelationChange_NeutralToFriends; break; case MyFactionRelationEnum.Neutral: if (previousRelation == MyFactionRelationEnum.Friend) relationChangeEnum = MyTextsWrapperEnum.GlobalEventFactionRelationChange_FriendsToNeutral; else relationChangeEnum = MyTextsWrapperEnum.GlobalEventFactionRelationChange_EnemyToNeutral; break; case MyFactionRelationEnum.Enemy: relationChangeEnum = MyTextsWrapperEnum.GlobalEventFactionRelationChange_NeutralToEnemy; break; } MyHudNotification.AddNotification(new MyHudNotification.MyNotification(relationChangeEnum, 5000, null, new object[] { MyFactionConstants.GetFactionProperties(faction1).Name.ToString(), MyFactionConstants.GetFactionProperties(faction2).Name.ToString() })); }
private MyGuiFont GetSenderFont(MyFactionRelationEnum senderRelation) { return MyGuiScreenGamePlay.Static.GetSenderFont(senderRelation); }
public bool CanBeDisplayed(MyFactionRelationEnum factionRelation) { switch(factionRelation) { case MyFactionRelationEnum.Friend: return Friend; case MyFactionRelationEnum.Neutral: return Neutral; case MyFactionRelationEnum.Enemy: return Enemy; } throw new MyMwcExceptionApplicationShouldNotGetHere(); }