Esempio n. 1
0
        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() }));
        }
Esempio n. 2
0
 public override void Load() // Code in that block will be called on the load of the sector
 {
     base.Load();
     MyScriptWrapper.ApplyTransition(MyMusicTransitionEnum.HeavyFight, 3);
     m_oldRelation = MyFactions.GetFactionsStatus(MyMwcObjectBuilder_FactionEnum.Rainiers, MyMwcObjectBuilder_FactionEnum.Russian);
     MyScriptWrapper.SetFactionRelation(MyMwcObjectBuilder_FactionEnum.Rainiers, MyMwcObjectBuilder_FactionEnum.Russian, MyFactions.RELATION_WORST);
 }
        private void AddStatRowToListbox(MyStatsRow statsRow)
        {
            StringBuilder pingText   = GetStringBuilderLong();
            StringBuilder killsText  = GetStringBuilderShort();
            StringBuilder deathsText = GetStringBuilderShort();

            pingText.Append(statsRow.Ping.HasValue ? statsRow.Ping.Value.ToString() + "ms" : "");
            killsText.Append(statsRow.Kills.ToString());
            deathsText.Append(statsRow.Deaths.ToString());

            Vector4?rowColor = null;

            if (statsRow.IsFaction)
            {
                if (MySession.Static.Player.Faction == statsRow.Faction)
                {
                    rowColor = new Vector4(0, 1f, 0, 0.07f);
                }
                else
                {
                    rowColor = new Vector4(1f, 0, 0, 0.07f);
                }
            }
            else if (statsRow.Id == (byte)MyClientServer.LoggedPlayer.GetUserId())
            {
                rowColor = new Vector4(1f, 1f, 1f, 0.02f);
            }

            int rowIndex = m_statsListbox.AddRow(rowColor);

            var textColor = Color.White;


            MyGuiFont textFont;

            if (MyFactions.GetFactionsRelation(MySession.Static.Player.Faction, statsRow.Faction) == MyFactionRelationEnum.Friend || statsRow.Id == m_playerId)
            {
                textFont = MyGuiManager.GetFontMinerWarsGreen();
            }
            else
            {
                textFont = MyGuiManager.GetFontMinerWarsRed();
            }

            m_statsListbox.AddItem(new MyGuiControlListboxItem(rowIndex * 4 + 0,
                                                               new MyColoredText(statsRow.Name, textColor, textFont, GetRowScale(statsRow)),
                                                               null, new MyToolTips(statsRow.Name)), rowIndex, 0);

            m_statsListbox.AddItem(new MyGuiControlListboxItem(rowIndex * 4 + 1,
                                                               new MyColoredText(killsText, textColor, textFont, GetRowScale(statsRow)),
                                                               null, new MyToolTips(killsText)), rowIndex, 1);

            m_statsListbox.AddItem(new MyGuiControlListboxItem(rowIndex * 4 + 2,
                                                               new MyColoredText(deathsText, textColor, textFont, GetRowScale(statsRow)),
                                                               null, new MyToolTips(deathsText)), rowIndex, 2);

            m_statsListbox.AddItem(new MyGuiControlListboxItem(rowIndex * 4 + 3,
                                                               new MyColoredText(pingText, textColor, textFont, GetRowScale(statsRow)),
                                                               null, new MyToolTips(pingText)), rowIndex, 3);
        }
Esempio n. 4
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));
            }
        }
 public override void Load() // Code in that block will be called on the load of the sector
 {
     base.Load();
     MyAudio.ApplyTransition(MyMusicTransitionEnum.CalmAtmosphere, 3); // Sets music group to be played in the sector - no matter if the mission is running or not
     m_oldRelation = MyFactions.GetFactionsStatus(MyMwcObjectBuilder_FactionEnum.Euroamerican, MyMwcObjectBuilder_FactionEnum.Rainiers);
     MyScriptWrapper.SetFactionRelation(MyMwcObjectBuilder_FactionEnum.Euroamerican, MyMwcObjectBuilder_FactionEnum.Rainiers, MyFactions.RELATION_WORST);
 }
Esempio n. 6
0
        /// <summary>
        /// Kill all cheat implementation
        /// </summary>
        static void KillAllEnabled(MyGameplayCheat cheat)
        {
            // We need player ship to recognize friends
            if (MySession.PlayerShip == null)
            {
                return;
            }

            foreach (var entity in MyEntities.GetEntities().ToArray())
            {
                MySmallShip smallShip = entity as MySmallShip;
                if (smallShip != null &&
                    smallShip.Visible &&
                    smallShip != MySession.PlayerShip &&
                    MyFactions.GetFactionsRelation(MySession.PlayerShip, smallShip) == MyFactionRelationEnum.Enemy)
                {
                    entity.DoDamage(0, 1000000, 0, MyDamageType.Unknown, MyAmmoType.Unknown, null);
                }

                MyPrefabContainer container = entity as MyPrefabContainer;
                if (container != null &&
                    MyFactions.GetFactionsRelation(MySession.PlayerShip, container) == MyFactionRelationEnum.Enemy)
                {
                    foreach (var prefab in container.GetPrefabs().ToArray())
                    {
                        MyPrefabLargeWeapon largeWeapon = prefab as MyPrefabLargeWeapon;
                        if (largeWeapon != null)
                        {
                            prefab.DoDamage(0, 1000000, 0, MyDamageType.Unknown, MyAmmoType.Unknown, null);
                        }
                    }
                }
            }
        }
Esempio n. 7
0
        private static void GetDetectedObjects()
        {
            using (MyEntities.EntityCloseLock.AcquireSharedUsing())
            {
                using (m_detectedObjectsLock.AcquireSharedUsing())
                {
                    Debug.Assert(m_detectedObjectsHelperCollection.Count == 0);
                    foreach (IMyObjectToDetect obj in m_objectsToDetect)
                    {
                        // if we are in radar jammer's range or in sun wind jam range, then we detect only friends
                        if (IsNearRadarJammerOrSunWind() && obj is MyEntity && (MyFactions.GetFactionsRelation(GetOwner().Faction, ((MyEntity)obj).Faction) == MyFactionRelationEnum.Enemy))
                        {
                            continue;
                        }

                        //activeDetector.IsDetected(GetRadarPosition(), objectToDetect)
                        if (!CanBeDetected(obj))
                        {
                            continue;
                        }

                        BoundingSphere detectingSphere = new BoundingSphere(GetOwner().GetPosition(), DefaultRadarRange);
                        if (!detectingSphere.Intersects(obj.WorldAABB))
                        {
                            continue;
                        }

                        m_detectedObjectsHelperCollection.Add(obj);
                    }
                    m_objectsToDetect.Clear();
                }
            }
        }
Esempio n. 8
0
        public static bool CanBuild(MyPrefabContainer prefabContainer, params object[] args)
        {
            MySmallShip smallShip = GetSmallShipFromArguments(args);

            return((MyFactions.GetFactionsRelation(smallShip, prefabContainer) == MyFactionRelationEnum.Friend) &&
                   prefabContainer.ContainsPrefab(PrefabTypesFlagEnum.FoundationFactory) &&
                   ControlIsInPlayerShip());
        }
        public override void Load() // Code in that block will be called on the load of the sector
        {
            base.Load();
            MyScriptWrapper.ApplyTransition(MyMusicTransitionEnum.HeavyFight, 3); // Sets music group to be played in the sector - no matter if the mission is running or not

            m_oldRelation = MyFactions.GetFactionsStatus(MyMwcObjectBuilder_FactionEnum.Russian, MyMwcObjectBuilder_FactionEnum.Russian_KGB);
            MyScriptWrapper.SetFactionRelation(MyMwcObjectBuilder_FactionEnum.Russian, MyMwcObjectBuilder_FactionEnum.Russian_KGB, MyFactions.RELATION_WORST);
        }
Esempio n. 10
0
        public static bool IsNearMothership(MyPrefabHangar prefabHangar, params object[] args)
        {
            MySmallShip smallShip = GetSmallShipFromArguments(args);

            return((prefabHangar.PrefabHangarType == MyMwcObjectBuilder_PrefabHangar_TypesEnum.HANGAR &&
                    MyFactions.GetFactionsRelation(smallShip, prefabHangar) == MyFactionRelationEnum.Friend) &&
                   IsTargetVisible(smallShip, prefabHangar) &&
                   ControlIsInPlayerShip());
        }
Esempio n. 11
0
        public float GetDeviatedAngleFromDamageRatio()
        {
            MyEntity topMostParent = GetTopMostParent();

            if (MySession.PlayerShip != null &&
                MyFactions.GetFactionsRelation(topMostParent, MySession.PlayerShip) == MyFactionRelationEnum.Enemy)
            {
                float degrees = (float)Math.Pow(120, topMostParent.GetDamageRatio() * 1.5 - 1.2) * 4f;
                return(MathHelper.ToRadians(degrees));
            }
            return(0f);
        }
        protected float GetDeviatedAngleByDamageRatio()
        {
            MyPrefabLargeWeapon prefabLargeWeapon = GetWeaponBase().PrefabParent;

            if (MySession.PlayerShip != null &&
                MyFactions.GetFactionsRelation(prefabLargeWeapon, MySession.PlayerShip) == MyFactionRelationEnum.Enemy)
            {
                float degrees = (float)Math.Pow(120, prefabLargeWeapon.GetDamageRatio() * 1.5 - 1.2) * 4f;
                return(MathHelper.ToRadians(degrees));
            }
            return(0f);
        }
Esempio n. 13
0
        private bool IsPotentialTarget(MySmallShip smallShip, params object[] args)
        {
            if (MyFactions.GetFactionsRelation(GetOwner(), smallShip) != MyFactionRelationEnum.Enemy)
            {
                return(false);
            }

            if (smallShip == MySession.PlayerShip && (Vector3.DistanceSquared(smallShip.GetPosition(), this.GetPosition()) > MyGameplayConstants.GameplayDifficultyProfile.LargeWeaponMaxAttackingDistanceForPlayer * MyGameplayConstants.GameplayDifficultyProfile.LargeWeaponMaxAttackingDistanceForPlayer))
            {
                return(false);
            }

            return(true);
        }
Esempio n. 14
0
        public void Notify(BoundingBox bbox, MyEntity source)
        {
            System.Diagnostics.Debug.Assert(source == null || !source.Closed);

            results.Clear();
            m_dangerZoneStructure.OverlapAllBoundingBox <MyDangerZoneElement>(ref bbox, results);

            foreach (var dangerZone in results)
            {
                if (source == null || (dangerZone.Bot != source && MyFactions.GetFactionsRelation(dangerZone.Bot, source) == MyFactionRelationEnum.Enemy))
                {
                    dangerZone.Bot.AddCuriousLocation(source != null ? source.GetPosition() : bbox.GetCenter(), source);
                }
            }
        }
Esempio n. 15
0
        public void Notify(MyLine line, MyEntity source)
        {
            System.Diagnostics.Debug.Assert(source == null || !source.Closed);

            lineResults.Clear();
            m_dangerZoneStructure.OverlapAllLineSegment <MyDangerZoneElement>(ref line, lineResults);

            foreach (var resultItem in lineResults)
            {
                if (source == null || (resultItem.Element.Bot != source && MyFactions.GetFactionsRelation(resultItem.Element.Bot, source) == MyFactionRelationEnum.Enemy))
                {
                    resultItem.Element.Bot.AddCuriousLocation(source != null ? source.GetPosition() : line.From, source);
                }
            }
        }
        private Vector3 GetTargetPositionByDamageRatio(MySmallShipBot bot)
        {
            Vector3 targetPos = m_target.GetPosition();

            if (MySession.PlayerShip != null && MyFactions.GetFactionsRelation(bot, MySession.PlayerShip) == MyFactionRelationEnum.Enemy)
            {
                Vector3 botPos         = bot.GetPosition();
                Vector3 botToTarget    = targetPos - botPos;
                Vector3 dir            = Vector3.Normalize(botToTarget);
                float   degrees        = (float)Math.Pow(120, bot.GetDamageRatio() * 1.5 - 1.2) * 4f;
                float   deviatingAngle = MathHelper.ToRadians(degrees);
                dir       = MyUtilRandomVector3ByDeviatingVector.GetRandom(dir, deviatingAngle);
                targetPos = botPos + botToTarget.Length() * dir * 3;
            }
            return(targetPos);
        }
Esempio n. 17
0
        protected override void DoDamageInternal(float playerDamage, float damage, float empDamage, MyDamageType damageType, MyAmmoType ammoType, MyEntity damageSource, bool justDeactivate)
        {
            if (damageSource != null && damageSource == MySession.PlayerShip)
            {
                var factionRelation = MyFactions.GetFactionsRelation(damageSource.Faction, Faction);
                if ((factionRelation == MyFactionRelationEnum.Friend || factionRelation == MyFactionRelationEnum.Neutral) &&
                    !MyGuiScreenGamePlay.Static.IsCheatEnabled(MyGameplayCheatsEnum.FRIEND_NEUTRAL_CANT_DIE) &&
                    !MyFakes.INDESTRUCTIBLE_PREFABS)
                {
                    MySession.PlayerShip.AddFriendlyFireDamage(this, damage);
                    return;
                }
            }

            base.DoDamageInternal(playerDamage, damage, empDamage, damageType, ammoType, damageSource, justDeactivate);
        }
Esempio n. 18
0
        /// <summary>
        /// Prepares the hologram ship for display.
        /// </summary>
        private void ActivateHologram()
        {
            //this.Physics.Enabled = false;
            //this.Physics.LinearVelocity = Vector3.Zero;

            MyEntity owner = OwnerEntity;

            if (owner != null)
            {
                var ownerShipBuilder = (owner.GetObjectBuilder(false) as MyMwcObjectBuilder_SmallShip);
                Debug.Assert(ownerShipBuilder != null, "ownerShipBuilder != null");

                m_hologramBuilder.ShipType                = ownerShipBuilder.ShipType;
                m_hologramBuilder.ShipMaxHealth           = ownerShipBuilder.ShipMaxHealth;
                m_hologramBuilder.ShipHealthRatio         = ownerShipBuilder.ShipHealthRatio;
                m_hologramBuilder.ArmorHealth             = ownerShipBuilder.ArmorHealth;
                m_hologramBuilder.Oxygen                  = ownerShipBuilder.Oxygen;
                m_hologramBuilder.Fuel                    = ownerShipBuilder.Fuel;
                m_hologramBuilder.ReflectorLight          = ownerShipBuilder.ReflectorLight;
                m_hologramBuilder.ReflectorLongRange      = ownerShipBuilder.ReflectorLongRange;
                m_hologramBuilder.ReflectorShadowDistance = ownerShipBuilder.ReflectorShadowDistance;
                m_hologramBuilder.PositionAndOrientation  = ownerShipBuilder.PositionAndOrientation;
                m_hologramBuilder.Faction                 = ownerShipBuilder.Faction;

                string displayName = ownerShipBuilder.DisplayName;
                if (MyFactions.GetFactionsRelation(m_hologramBuilder.Faction, MySession.Static.Player.Faction) == MyFactionRelationEnum.Friend || MySession.PlayerShip == owner)
                {
                    displayName = "Hologram";
                }

                m_hologramShip            = MyHologramShips.Add(displayName, m_hologramBuilder);
                m_hologramShip.AIPriority = 1;
                m_hologramShip.IsHologram = true;
                if (m_hologramShip != null)
                {
                    m_hologramBaseMatrix = this.WorldMatrix;

                    m_scale         = new Vector3(0, 1, 1);
                    m_hologramState = HologramState.Activating;

                    foreach (var bot in m_awareBots)
                    {
                        bot.SpoilHologram(m_hologramShip);
                    }
                }
            }
        }
Esempio n. 19
0
        public void NotifyExplosion(Vector3 position, float radius, MyEntity source)
        {
            System.Diagnostics.Debug.Assert(source == null || !source.Closed);

            BoundingBox bbox = new BoundingBox(position - new Vector3(radius + EXTRA_EXPLOSION_RADIUS), position + new Vector3(radius + EXTRA_EXPLOSION_RADIUS));

            results.Clear();
            m_dangerZoneStructure.OverlapAllBoundingBox <MyDangerZoneElement>(ref bbox, results);

            foreach (var dangerZone in results)
            {
                if (source == null || (dangerZone.Bot != source && MyFactions.GetFactionsRelation(dangerZone.Bot, source) == MyFactionRelationEnum.Enemy))
                {
                    dangerZone.Bot.AddCuriousLocation(position, null);
                }
            }
        }
        void detector_OnEntityLeave(MyEntityDetector sender, MyEntity entity)
        {
            //MySpawnPoint spawnPoint = (MySpawnPoint)MyScriptWrapper.GetEntity((uint)EntityID.PatrolSpawnPoint);

            MyDummyPoint dummy = (MyDummyPoint)sender.Parent;


            if (MyFactions.GetFactionsRelation(dummy, entity) == MyFactionRelationEnum.Friend)
            {
            }


            uint            scannerId = (uint)dummy.Tag;
            MyPrefabScanner scanner   = (MyPrefabScanner)MyScriptWrapper.GetEntity(scannerId);

            scanner.Enabled = true;
        }
Esempio n. 21
0
        public static void MakeEnemy(MyMwcObjectBuilder_FactionEnum shipFaction)
        {
            // Order bots to kill player
            foreach (var bot in MyBotCoordinator.GetBots())
            {
                var relation = MyFactions.GetFactionsRelation(shipFaction, bot.Faction);
                if (relation == MyFactionRelationEnum.Friend || relation == MyFactionRelationEnum.Neutral)
                {
                    bot.Attack(MySession.PlayerShip);
                }
            }

            MyScriptWrapper.SetPlayerFaction(MyMwcObjectBuilder_FactionEnum.Freelancers);


            MyMissions.DisableSaveObjectives();
        }
Esempio n. 22
0
        protected override void SetHudMarker()
        {
            MyHudIndicatorFlagsEnum hudFlags      = MyHudIndicatorFlagsEnum.SHOW_TEXT | MyHudIndicatorFlagsEnum.SHOW_BORDER_INDICATORS | MyHudIndicatorFlagsEnum.SHOW_HEALTH_BARS | MyHudIndicatorFlagsEnum.SHOW_DISTANCE | MyHudIndicatorFlagsEnum.SHOW_MISSION_MARKER;
            MyGuitargetMode?        guiTargetMode = MyGuitargetMode.Neutral;

            if (PrefabHangarType == MyMwcObjectBuilder_PrefabHangar_TypesEnum.HANGAR &&
                MyFactions.GetFactionsRelation(this.m_owner, MySession.PlayerShip) == MyFactionRelationEnum.Friend)
            {
                guiTargetMode = MyGuitargetMode.Friend;
            }
            else
            {
                hudFlags |= MyHudIndicatorFlagsEnum.SHOW_ONLY_IF_DETECTED_BY_RADAR | MyHudIndicatorFlagsEnum.ALPHA_CORRECTION_BY_DISTANCE;
            }


            MyHud.ChangeText(this, new StringBuilder(GetCorrectDisplayName()), guiTargetMode, 0, hudFlags);
        }
Esempio n. 23
0
        protected override bool IsObjectMeetDetectCriterium(IMyObjectToDetect objectToDetect)
        {
            MyEntity entity = objectToDetect as MyEntity;

            // TODO: temporary disable displaying mission entities on radar

            /*// we detect all mission entities
             * if(MyMissions.IsMissionEntity(entity))
             * {
             *  return true;
             * }
             * // we detect all friendly ship, foundation factories and hangars
             * else */if (entity is MyShip || entity is MyPrefabFoundationFactory || entity is MyPrefabHangar)
            {
                return(MyFactions.GetFactionsRelation(m_ship, entity) == MyFactionRelationEnum.Friend);
            }
            return(false);
        }
Esempio n. 24
0
        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);
        }
Esempio n. 25
0
        protected override void OnContactStart(MyContactEventInfo contactInfo)
        {
            base.OnContactStart(contactInfo);

            if (m_state == MyCurrentState.ACTIVATED)
            {
                m_collidedEntity = contactInfo.GetOtherEntity(this);

                if (m_collidedEntity is MySmallShip && MyFactions.GetFactionsRelation(this, m_collidedEntity) == MyFactionRelationEnum.Enemy)
                {
                    if (this.OwnerEntity is MySmallShip && (MySmallShip)this.OwnerEntity == MySession.PlayerShip && m_collidedEntity is MyStaticAsteroid && !m_collidedEntity.IsDestructible)
                    {
                        HUD.MyHud.ShowIndestructableAsteroidNotification();
                    }

                    //  Create explosion and close;
                    Explode();
                }
            }
        }
        public override void Load(MyMissionBase sender)
        {
            base.Load(sender);
            m_spawnPoints.Clear();

            if (m_spawnPointIDs == null)
            {   //Add all spawnpoints in mission
                List <uint> list = new List <uint>();
                foreach (MyEntity entity in MyEntities.GetEntities())
                {
                    MySpawnPoint spawnPoint = entity as MySpawnPoint;
                    if (spawnPoint != null && MyFactions.GetFactionsRelation(MySession.PlayerShip.Faction, spawnPoint.Faction) == MyFactionRelationEnum.Enemy && !m_excludedSpawnPointIDs.Contains(spawnPoint.EntityId.Value.NumericValue))
                    {
                        list.Add(spawnPoint.EntityId.Value.NumericValue);
                        spawnPoint.OnActivatedChanged += new Action <MySpawnPoint>(spawnPoint_OnActivatedChanged);
                    }
                }
                m_spawnPointIDs = list.ToArray();
            }

            foreach (uint spawnPointID in m_spawnPointIDs)
            {
                m_spawnPoints.Add(MyEntities.GetEntityById(new MyEntityIdentifier(spawnPointID)) as MySpawnPoint);
            }

            MyScriptWrapper.OnSpawnpointBotSpawned += OnSpawnpointBotSpawned;

            m_currentBotsCount = 0;

            foreach (MySpawnPoint spawnPoint in m_spawnPoints)
            {
                spawnPoint.LeftToSpawn     = 0;
                spawnPoint.FirstSpawnTimer = 0;
                spawnPoint.RespawnTimer    = 0;

                m_currentBotsCount += spawnPoint.GetShipCount();
                spawnPoint.Deactivate();
            }

            UpdateCurrentBotCount();
        }
Esempio n. 27
0
        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();
                }
            }
        }
Esempio n. 28
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));
            }
        }
    internal static void HandleInput(MySolarMapRenderer renderer, MyGuiInput input, bool receivedFocusInThisUpdate)
    {
        if (input.IsNewKeyPress(Keys.NumPad7))
        {
            center = renderer.GetTargetSector();
        }

        if (input.IsNewKeyPress(Keys.NumPad9))
        {
            point = renderer.GetTargetSector();
        }

        if (input.IsNewKeyPress(Keys.NumPad8))
        {
            System.Diagnostics.Debug.WriteLine(string.Format("MyFactions.AddFactionArea(MyMwcObjectBuilder_FactionEnum.China, new MyMwcVector3Int({0}), new MyMwcVector3Int({1}));", center, point));
            MyFactions.AddFactionArea(MyMwcObjectBuilder_FactionEnum.China, center, point);
        }

        if (input.IsNewKeyPress(Keys.NumPad4))
        {
            Debug.WriteLine(MyFactions.GetFactionBySector(renderer.GetTargetSector()));
        }
    }
Esempio n. 30
0
 public void SendToTeam <T>(ref T multiplayerEvent, MyMwcObjectBuilder_FactionEnum senderFaction, NetDeliveryMethod delivery = NetDeliveryMethod.Unreliable, int sequenceChannel = 0, int maxSize = 512)
     where T : struct, IMyEvent
 {
     m_playerConnections.Clear();
     foreach (var p in Players)
     {
         var connection = p.Connection;
         if (connection != null && MyFactions.GetFactionsRelation(p.Faction, senderFaction) == MyFactionRelationEnum.Friend)
         {
             if (connection is MyRelayedConnection)
             {
                 m_peer.Send(ref multiplayerEvent, connection, delivery, sequenceChannel, maxSize);
             }
             else
             {
                 m_playerConnections.Add(connection);
             }
         }
     }
     if (m_playerConnections.Count > 0)
     {
         m_peer.SendToAll(ref multiplayerEvent, m_playerConnections, delivery, sequenceChannel);
     }
 }