public void FactionChange(MyFactionStateChange type, long fromFaction, long toFaction, long playerId, long senderId) { if (type == MyFactionStateChange.SendPeaceRequest) { IMyFaction faction = MyAPIGateway.Session.Factions.TryGetFactionById(toFaction); if (faction == null || !faction.IsEveryoneNpc() || faction.Tag.Length <= 3) { return; } foreach (var npcId in NpcFactionPairs.Values) { if (MyAPIGateway.Session.Factions.GetRelationBetweenFactions(fromFaction, toFaction) != VRage.Game.MyRelationsBetweenFactions.Enemies) { return; } } foreach (var npcId in NpcFactionPairs.Values) { if (npcId == toFaction) { if (MyAPIGateway.Session.Factions.GetReputationBetweenPlayerAndFaction(senderId, npcId) >= AllowPeaceAmt) { MyAPIGateway.Session.Factions.AcceptPeace(fromFaction, toFaction); break; } } } } }
public override void UpdateBeforeSimulation() { if (!Block.IsFunctional) { return; } var thrust = Block as Sandbox.ModAPI.Ingame.IMyThrust; if (!thrust.Enabled) { return; } var waters = SharedDataSingleton.Instance.WaterMap; if (waters == null) { return; } // NPCs can use every thruster under water IMyFaction faction = MyAPIGateway.Session.Factions.TryGetPlayerFaction(Block.OwnerId); if (faction != null) { // this does work for a player not being in any faction and SPRT Pirates at least if (faction.IsEveryoneNpc()) { return; } ; } var isUnderwater = false; foreach (var item in waters) { if (!item.Value.IsUnderwater(Block.PositionComp.GetPosition())) { continue; } isUnderwater = true; } string ThrusterName = thrust.DefinitionDisplayNameText; if (ThrusterName.Contains("Water")) { if (isUnderwater == false) { thrust.Enabled = false; } } else { if (isUnderwater == true) { thrust.Enabled = false; } } }