Esempio n. 1
0
        //  Add new ship to the list
        public static MySmallShip Add(string displayName, MyMwcObjectBuilder_Ship objectBuilder)
        {
            MySmallShip newShip = m_hologramShips.Allocate();

            if (newShip != null)
            {
                newShip.Init(displayName, objectBuilder);

                if (newShip.Physics.Enabled)
                {
                    newShip.Physics.Enabled = false;
                }

                /*
                 * newShip.Physics.Type = MyConstants.RIGIDBODY_TYPE_DEFAULT;
                 * newShip.Physics.CollisionLayer = MyConstants.COLLISION_LAYER_UNCOLLIDABLE;
                 */
                newShip.IsHologram = true;

                // we dont want the hologram to have a light
                newShip.RemoveLight();
                newShip.RemoveSubObjectLights();

                newShip.Config.Engine.Level         = 1;
                newShip.Config.ReflectorLight.Level = 1;
                newShip.GetReflectorProperties().CurrentBillboardLength    = 40;
                newShip.GetReflectorProperties().CurrentBillboardThickness = 6;

                newShip.CastShadows = false;
            }
            return(newShip);
        }
Esempio n. 2
0
        void DamageShip(MySmallShip detectedEntity, float influenceStrength)
        {
            Debug.Assert(m_effectHelper.DamageStrength != null);
            var damageAmount = m_effectHelper.DamageStrength.Value * influenceStrength;

            detectedEntity.DoDamage(0, damageAmount * MyConstants.PHYSICS_STEP_SIZE_IN_SECONDS, 0, MyDamageType.Unknown, MyAmmoType.None, this);
        }
Esempio n. 3
0
        public static bool CanUse(MyEntity entity, params object[] args)
        {
            IMyUseableEntity useableEntity = entity as IMyUseableEntity;

            MySmallShip smallShip = GetSmallShipFromArguments(args);

            if (useableEntity == null)
            {
                return(false);
            }
            if ((useableEntity.UseProperties.UseType & MyUseType.Solo) == 0)
            {
                return(false);
            }
            if (entity is MyDrone ? !IsCustomLookAtTarget(smallShip, entity, entity.WorldVolume.Radius) : !IsLookAtTarget(smallShip, entity))
            {
                return(false);
            }
            if (smallShip != MyGuiScreenGamePlay.Static.ControlledEntity)
            {
                return(false);
            }

            return(useableEntity.CanBeUsed(smallShip));
        }
Esempio n. 4
0
 public void Remove(MySmallShip friend)
 {
     m_playerFriends.Remove(friend);
     UpdateHUD(friend, false);
     friend.Physics.GroupMask &= ~FriendMask;
     friend.OnClosing         -= m_friendClosing;
 }
 public void UseFromHackingTool(MySmallShip useBy, int hackingLevelDifference)
 {
     if (ConnectedEntities.Count > 0)
     {
         Use(useBy);
     }
 }
Esempio n. 6
0
        private static bool IsTargetVisible(MySmallShip smallShip, MyEntity otherEntity)
        {
            MyLine line = new MyLine(smallShip.WorldVolume.Center, otherEntity.GetPosition(), true);
            MyIntersectionResultLineTriangleEx?result = MyEntities.GetIntersectionWithLine(ref line, smallShip, null, ignoreChilds: true);

            return(result != null && result.Value.Entity.GetBaseEntity() == otherEntity);
        }
Esempio n. 7
0
        public override void RecreateControls(bool contructor)
        {
            Controls.Clear();

            AddCaption(new StringBuilder("Player Head Shake"), Color.Yellow.ToVector4());

            MyGuiControlLabel label = new MyGuiControlLabel(this, new Vector2(0.01f, -m_size.Value.Y / 2.0f + 0.07f), null, new System.Text.StringBuilder("(press ALT to share focus)"), Color.Yellow.ToVector4(), MyGuiConstants.LABEL_TEXT_SCALE * 0.7f,
                                                            MyGuiDrawAlignEnum.HORISONTAL_CENTER_AND_VERTICAL_TOP);

            Controls.Add(label);

            m_currentPosition = -m_size.Value / 2.0f + new Vector2(0.02f, 0.10f);

            m_currentPosition.Y += 0.01f;

            MySmallShip ship = MySession.PlayerShip;

            if (ship != null)
            {
                AddSlider(new StringBuilder("MaxVelocity"), 0, 1, ship.GetCameraSpring(), MemberHelper.GetMember(() => ship.GetCameraSpring().m_MaxVelocity));
                AddSlider(new StringBuilder("MaxAccel"), 0, 80, ship.GetCameraSpring(), MemberHelper.GetMember(() => ship.GetCameraSpring().m_MaxAccel));
                AddSlider(new StringBuilder("MaxDistanceSpeed"), 0, 500, ship.GetCameraSpring(), MemberHelper.GetMember(() => ship.GetCameraSpring().m_MaxDistanceSpeed));
                AddSlider(new StringBuilder("linearVelocityDumping"), 0, 1, ship.GetCameraSpring(), MemberHelper.GetMember(() => ship.GetCameraSpring().m_linearVelocityDumping));
                AddSlider(new StringBuilder("localTranslationDumping"), 0, 1, ship.GetCameraSpring(), MemberHelper.GetMember(() => ship.GetCameraSpring().m_localTranslationDumping));
            }

            m_currentPosition.Y += 0.01f;
        }
Esempio n. 8
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. 9
0
 public override void Init(StringBuilder hudLabelText, MySmallShip parentObject,
     Vector3 position, Vector3 forwardVector, Vector3 upVector,
     MyMwcObjectBuilder_SmallShip_Weapon objectBuilder)
 {
     base.Init(hudLabelText, MyModelsEnum.Shotgun, MyMaterialType.METAL, parentObject, position,
         forwardVector, upVector, objectBuilder);
 }
Esempio n. 10
0
        public static bool CanHack(MyEntity entity, params object[] args)
        {
            IMyUseableEntity useableEntity = entity as IMyUseableEntity;

            MySmallShip smallShip = GetSmallShipFromArguments(args);

            if (useableEntity == null)
            {
                return(false);
            }
            if (useableEntity.UseProperties.IsHacked)
            {
                return(false);
            }
            if ((useableEntity.UseProperties.HackType & MyUseType.Solo) == 0)
            {
                return(false);
            }
            if (!IsLookAtTarget(smallShip, entity))
            {
                return(false);
            }
            if (smallShip != MyGuiScreenGamePlay.Static.ControlledEntity)
            {
                return(false);
            }

            return(useableEntity.CanBeHacked(smallShip));
        }
Esempio n. 11
0
        public override void RecreateControls(bool contructor)
        {
            Controls.Clear();

            AddCaption(new StringBuilder("Player Head Shake"), Color.Yellow.ToVector4());

            MyGuiControlLabel label = new MyGuiControlLabel(this, new Vector2(0.01f, -m_size.Value.Y / 2.0f + 0.07f), null, new System.Text.StringBuilder("(press ALT to share focus)"), Color.Yellow.ToVector4(), MyGuiConstants.LABEL_TEXT_SCALE * 0.7f,
                                                            MyGuiDrawAlignEnum.HORISONTAL_CENTER_AND_VERTICAL_TOP);

            Controls.Add(label);

            m_currentPosition = -m_size.Value / 2.0f + new Vector2(0.02f, 0.10f);

            m_currentPosition.Y += 0.01f;

            MySmallShip ship = MySession.PlayerShip;

            if (ship != null)
            {
                AddSlider(new StringBuilder("MaxShake"), 0, 30, ship.GetShake(), MemberHelper.GetMember(() => ship.GetShake().m_MaxShake));
                AddSlider(new StringBuilder("MaxShakePos"), 0, 1, ship.GetShake(), MemberHelper.GetMember(() => ship.GetShake().m_MaxShakePos));
                AddSlider(new StringBuilder("MaxShakeDir"), 0, 1, ship.GetShake(), MemberHelper.GetMember(() => ship.GetShake().m_MaxShakeDir));
                AddSlider(new StringBuilder("Reduction"), 0, 1, ship.GetShake(), MemberHelper.GetMember(() => ship.GetShake().m_Reduction));
                AddSlider(new StringBuilder("Damping"), 0, 1, ship.GetShake(), MemberHelper.GetMember(() => ship.GetShake().m_Damping));
                AddSlider(new StringBuilder("OffConstant"), 0, 1, ship.GetShake(), MemberHelper.GetMember(() => ship.GetShake().m_OffConstant));
                AddSlider(new StringBuilder("DirReduction"), 0, 30, ship.GetShake(), MemberHelper.GetMember(() => ship.GetShake().m_DirReduction));
            }

            m_currentPosition.Y += 0.01f;
        }
Esempio n. 12
0
        private static MySmallShip GetSmallShipFromArguments(object[] args)
        {
            MySmallShip smallShip = args[0] as MySmallShip;

            Debug.Assert(smallShip != null);
            return(smallShip);
        }
Esempio n. 13
0
 private MyToolKit(MySmallShip smallShipOwner, MyPlayer playerOwner, MyInventoryItem toolInventoryItem, MyToolKitDelegates[] delegates)
 {
     m_smallShipOwner    = smallShipOwner;
     m_playerOwner       = playerOwner;
     m_toolInventoryItem = toolInventoryItem;
     m_delegates         = delegates;
 }
Esempio n. 14
0
 private MyToolKit(MySmallShip smallShipOwner, MyPlayer playerOwner, MyInventoryItem toolInventoryItem, MyToolKitDelegates[] delegates) 
 {
     m_smallShipOwner = smallShipOwner;
     m_playerOwner = playerOwner;
     m_toolInventoryItem = toolInventoryItem;
     m_delegates = delegates;
 }
Esempio n. 15
0
        private void MyScriptWrapper_FadedOut()
        {
            MyScriptWrapper.FadedOut -= MyScriptWrapper_FadedOut;
            var ship = MyScriptWrapper.GetEntity((uint)EntityID.Bot_Disabled_03) as MySmallShipBot;

            MyScriptWrapper.ChangeShip(ship);

            MySmallShip vitolino = (MySmallShip)MyScriptWrapper.GetEntity("RavenGuy");

            vitolino.SetName("Disabled_vitolino");
            MyScriptWrapper.DisableShip(vitolino);

            MySmallShip tanja = (MySmallShip)MyScriptWrapper.GetEntity("RavenGirl");

            tanja.SetName("Disabled_tanja");
            MyScriptWrapper.DisableShip(tanja);

            MySmallShip vitolinoNewShip = (MySmallShip)MyScriptWrapper.TryGetEntity((uint)EntityID.Bot_Disabled_04);

            if (vitolinoNewShip != null)
            {
                vitolinoNewShip.MarkForClose();
            }
            MyScriptWrapper.InsertFriend(MyActorEnum.VALENTIN, vitolinoNewShip != null ? vitolinoNewShip.ShipType : MyMwcObjectBuilder_SmallShip_TypesEnum.HEWER);

            MySmallShip tanjaNewShip = (MySmallShip)MyScriptWrapper.TryGetEntity((uint)EntityID.Bot_Disabled_05);

            if (tanjaNewShip != null)
            {
                tanjaNewShip.MarkForClose();
            }
            MyScriptWrapper.InsertFriend(MyActorEnum.TARJA, tanjaNewShip != null ? tanjaNewShip.ShipType : MyMwcObjectBuilder_SmallShip_TypesEnum.KAMMLER);

            MyScriptWrapper.FadeIn();
        }
Esempio n. 16
0
 public override void Init(StringBuilder hudLabelText, MySmallShip parentObject,
                           Vector3 position, Vector3 forwardVector, Vector3 upVector,
                           MyMwcObjectBuilder_SmallShip_Weapon objectBuilder)
 {
     base.Init(hudLabelText, MyModelsEnum.Shotgun, MyMaterialType.METAL, parentObject, position,
               forwardVector, upVector, objectBuilder);
 }
Esempio n. 17
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));
            }
        }
Esempio n. 18
0
        public static void Update()
        {
            if ((MyMinerGame.TotalTimeInMilliseconds - m_lastActualizeTime) > ACTUALIZE_TIME)
            {
                m_lastActualizeTime = MyMinerGame.TotalTimeInMilliseconds;

                if (MyHud.GetHudEnemiesOnScreen().Count > 0 && CurrentTarget == null)
                {
                    SwitchNextTarget(true);
                    return;
                }

                if (CurrentTarget != null && !MyHud.GetHudEnemiesOnScreen().Contains(CurrentTarget))
                {
                    SwitchNextTarget(true);
                    return;
                }

                MySmallShip smallShipTarget = CurrentTarget as MySmallShip;
                if (smallShipTarget != null)
                {
                    if (smallShipTarget.IsEngineTurnedOff())
                    {
                        SwitchNextTarget(true);
                        return;
                    }
                }
            }
        }
Esempio n. 19
0
        //private void OnTargetDetected(MyEntityDetector sender, MyEntity entity, int criterias)
        //{
        //    m_foundSmallShips.Add(entity as MySmallShip);
        //    m_foundSmallShipsPositionChange = true;
        //}

        //private void OnTargetLost(MyEntityDetector sender, MyEntity entity)
        //{
        //    m_foundSmallShips.Remove(entity as MySmallShip);
        //}

        //private void OnTargetPositionChanged(MyEntityDetector sender, MyEntity entity, Vector3 position)
        //{
        //    m_foundSmallShipsPositionChange = true;
        //}

        private void OnNearestTargetChange(MyEntityDetector sender, MyEntity oldNearestEntity, MyEntity newNearestEntity)
        {
            m_target = newNearestEntity as MySmallShip;
            if (m_target != null)
            {
            }
        }
Esempio n. 20
0
 public virtual void Init(StringBuilder hudLabelText, MySmallShip parentObject,
     Vector3 position, Vector3 forwardVector, Vector3 upVector,
     MyMwcObjectBuilder_SmallShip_Weapon objectBuilder)
 {
     WeaponType = objectBuilder.WeaponType;
     //  Don't need to check frustum, because it's checked by this gun's parent
     m_frustumCheckBeforeDrawEnabled = false;
 }
Esempio n. 21
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 Init(StringBuilder hudLabelText, MySmallShip parentObject, Vector3 position,
                           Vector3 forwardVector, Vector3 upVector,
                           MyMwcObjectBuilder_SmallShip_Weapon objectBuilder)
 {
     base.Init(hudLabelText, MyModelsEnum.UniversalLauncher, MyMaterialType.METAL, parentObject, position,
               forwardVector, upVector, objectBuilder);
     m_lastTimeShoot = MyConstants.FAREST_TIME_IN_PAST;
 }
Esempio n. 23
0
 public virtual void Init(StringBuilder hudLabelText, MySmallShip parentObject,
                          Vector3 position, Vector3 forwardVector, Vector3 upVector,
                          MyMwcObjectBuilder_SmallShip_Weapon objectBuilder)
 {
     WeaponType = objectBuilder.WeaponType;
     //  Don't need to check frustum, because it's checked by this gun's parent
     m_frustumCheckBeforeDrawEnabled = false;
 }
Esempio n. 24
0
 public static void Add(Vector3 position, Vector3 initialVelocity, Vector3 direction, MyMwcObjectBuilder_SmallShip_Ammo usedAmmo, MySmallShip ignoreMinerShip)
 {
     MyCannonShot newMissile = m_missiles.Allocate();
     if (newMissile != null)
     {
         newMissile.Start(position, initialVelocity, direction, usedAmmo, ignoreMinerShip);
     }
 }
Esempio n. 25
0
        public override void Init(StringBuilder hudLabelText, MySmallShip parentObject,
            Vector3 position, Vector3 forwardVector, Vector3 upVector,
            MyMwcObjectBuilder_SmallShip_Weapon objectBuilder)
        {
            base.Init(hudLabelText, MyModelsEnum.MissileLauncher, MyMaterialType.METAL, parentObject,
                position, forwardVector, upVector, objectBuilder);

            m_lastTimeShoot = MyConstants.FAREST_TIME_IN_PAST;
        }
Esempio n. 26
0
        public void UseFromHackingTool(MySmallShip useBy, int hackingLevelDifference)
        {
            float cashMoveToPlayer = Cash * (0.5f + hackingLevelDifference * 0.1f);

            MySession.Static.Player.Money += cashMoveToPlayer;
            Cash -= cashMoveToPlayer;
            MyHudNotification.AddNotification(
                new MyHudNotification.MyNotification(MyTextsWrapperEnum.YouObtainNotification, MyGuiManager.GetFontMinerWarsGreen(), 5000, null, new object[] { MyMwcUtils.GetFormatedPriceForGame((decimal)cashMoveToPlayer) }));
        }
Esempio n. 27
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. 28
0
 public void Close()
 {
     StopHacking(MyHackingResultEnum.Canceled);
     m_owner.OnDie   -= m_ownerDie;
     m_owner.OnClose -= m_ownerClose;
     m_owner          = null;
     m_hackingProgressScreenSuccess  = null;
     m_hackingProgressScreenCanceled = null;
 }
Esempio n. 29
0
        /// <summary>
        /// Called after remoting.Deserialize
        /// Remove old init version after objectBuilder is removed
        /// </summary>
        public void Init(StringBuilder hudLabelText, MySmallShip parentObject,
                         Vector3 position, Vector3 forwardVector, Vector3 upVector)
        {
            Debug.Assert((int)WeaponType != 0);
            //  Don't need to check frustum, because it's checked by this gun's parent
            m_frustumCheckBeforeDrawEnabled = false;

            Init(hudLabelText, parentObject, position, forwardVector, upVector, new MyMwcObjectBuilder_SmallShip_Weapon(WeaponType));
        }
        public void Use(MySmallShip useBy)
        {
            //if (ConnectedEntityIds.Any())
            //{
            //    MyGuiManager.AddScreen(new MyGuiScreenSecurityControlHUB(useBy, this));
            //}
            var screenSecurityControlHUB = new MyGuiScreenSecurityControlHUB(useBy, this);

            MyGuiScreenGamePlay.Static.DisplaySecurityHubScreen(screenSecurityControlHUB);
        }
Esempio n. 31
0
        public static MyToolKit CreateInstance(MySmallShip smallShipOwner, MyPlayer playerOwner, MyInventoryItem toolInventoryItem)
        {
            Debug.Assert(smallShipOwner != null);
            Debug.Assert(playerOwner != null);
            Debug.Assert(IsSupportedToolKitItem(toolInventoryItem));

            MyToolKitDelegates[] delegates = m_delegatesPerToolKitType[toolInventoryItem.ObjectBuilderId.Value];
            Debug.Assert(delegates.Length > 0);
            return(new MyToolKit(smallShipOwner, playerOwner, toolInventoryItem, delegates));
        }
Esempio n. 32
0
 public MyHackingTool(MySmallShip owner, int hackingLevel)
 {
     m_owner          = owner;
     HackingLevel     = hackingLevel;
     m_ownerDie       = new DieHandler(OnOwnerDie);
     m_ownerClose     = OnOwnerClose;
     m_owner.OnClose += m_ownerClose;
     m_hackingProgressScreenSuccess  = new EventHandler(m_hackingProgressScreen_OnSuccess);
     m_hackingProgressScreenCanceled = new EventHandler(m_hackingProgressScreen_OnCanceled);
 }
Esempio n. 33
0
 public MyToolKits(MySmallShip smallShipOwner, MyPlayer playerOwner) 
 {
     OnInventoryContentChangedHandler = new OnInventoryContentChange(SmallShipInventory_OnInventoryContentChange);
     m_smallShipOwner = smallShipOwner;
     m_playerOwner = playerOwner;
     m_inventoryItemsHelper = new List<MyInventoryItem>();
     m_toolKits = new List<MyToolKit>();
     m_smallShipOwner.Inventory.OnInventoryContentChange += OnInventoryContentChangedHandler;
     RefreshToolKits();
 }        
Esempio n. 34
0
 public MyToolKits(MySmallShip smallShipOwner, MyPlayer playerOwner)
 {
     OnInventoryContentChangedHandler = new OnInventoryContentChange(SmallShipInventory_OnInventoryContentChange);
     m_smallShipOwner       = smallShipOwner;
     m_playerOwner          = playerOwner;
     m_inventoryItemsHelper = new List <MyInventoryItem>();
     m_toolKits             = new List <MyToolKit>();
     m_smallShipOwner.Inventory.OnInventoryContentChange += OnInventoryContentChangedHandler;
     RefreshToolKits();
 }
Esempio n. 35
0
        public float ZOffset;       // z-offset from ship's dummy

        public void Init(StringBuilder hudLabelText, MyModelsEnum? modelEnum, MyMaterialType materialType,
            MySmallShip parent, Vector3 position, Vector3 forwardVector, Vector3 upVector,
            MyMwcObjectBuilder_Base objectBuilder)
        {
            base.Init(hudLabelText, modelEnum, materialType, parent, position, forwardVector, upVector, objectBuilder);

            Debug.Assert(objectBuilder is MyMwcObjectBuilder_SmallShip_Weapon);
            WeaponType = ((MyMwcObjectBuilder_SmallShip_Weapon)objectBuilder).WeaponType;
            //  Don't need to check frustum, because it's checked by this gun's parent
            m_frustumCheckBeforeDrawEnabled = false;
        }
Esempio n. 36
0
        public static bool CanExamineEmptyCargoBox(MyCargoBox cargoBox, params object[] args)
        {
            if (IsBlocked(cargoBox, args))
            {
                return(false);
            }

            MySmallShip smallShip = GetSmallShipFromArguments(args);

            return(cargoBox.Inventory.GetInventoryItems().Count == 0 && IsLookAtTarget(smallShip, cargoBox) && ControlIsInPlayerShip());
        }
Esempio n. 37
0
 public void Close() 
 {
     m_smallShipOwner.Inventory.OnInventoryContentChange -= OnInventoryContentChangedHandler;
     OnInventoryContentChangedHandler = null;
     m_toolKits.Clear();
     m_toolKits = null;
     m_inventoryItemsHelper.Clear();
     m_inventoryItemsHelper = null;
     m_smallShipOwner = null;
     m_playerOwner = null;
 }
Esempio n. 38
0
        static void PlayCurrentSentence()
        {
            MinerWars.AppCode.Game.Render.MyRender.GetRenderProfiler().StartProfilingBlock("PlayCurrentSentence");

            StopSound();
            CurrentSentenceStarted_ms = MyMinerGame.TotalGamePlayTimeInMilliseconds;
            if (CurrentSentence == null || CurrentSentence.Cue == null)
            {
                m_currentCue = null;
                MinerWars.AppCode.Game.Render.MyRender.GetRenderProfiler().EndProfilingBlock();
                return;
            }

            MinerWars.AppCode.Game.Render.MyRender.GetRenderProfiler().EndProfilingBlock();
            MinerWars.AppCode.Game.Render.MyRender.GetRenderProfiler().StartProfilingBlock("LoadSentence");

            if (CurrentSentence.Listener != null)
            {
                var         speaker  = MyScriptWrapper.TryGetEntity(MyActorConstants.GetActorName(CurrentSentence.Actor)) as MySmallShipBot;
                MySmallShip listener = null;
                if (CurrentSentence.Listener.Value == MyActorEnum.APOLLO)
                {
                    listener = MySession.Static.Player.Ship;
                }
                else
                {
                    listener = MyScriptWrapper.TryGetEntity(MyActorConstants.GetActorName(CurrentSentence.Listener.Value)) as MySmallShip;
                }
                if (speaker != null && listener != null)
                {
                    speaker.LookTarget = listener;
                }
            }
            if (CurrentSentence.Cue != null)
            {
                m_currentCue = MyAudio.AddCue2D(CurrentSentence.Cue.Value, m_volume);

                if (OnSentenceStarted != null)
                {
                    OnSentenceStarted(m_currentDialogueId, CurrentSentence.Text);
                }

                if (m_currentCue != null && CurrentSentence.PauseBefore_ms != 0)
                {
                    m_currentCue.Value.Pause();
                }
            }
            else
            {
                m_currentCue = null;
            }

            MinerWars.AppCode.Game.Render.MyRender.GetRenderProfiler().EndProfilingBlock();
        }
Esempio n. 39
0
        public virtual void Start(MySmallShip ship, MyDetectorConfiguration configuration) 
        {
            m_ship = ship;
            m_detectInterval = configuration.DetectInterval;
            m_timeFromLastDetect = 0;
            m_isActive = false;
            m_detectorType = configuration.DetectorType;

            Range = configuration.Range;
            CanBeDisabledByRadarJammer = configuration.CanBeDisabledByRadarJammer;
        }
Esempio n. 40
0
        public override void Start(Vector3 position, Vector3 initialVelocity, Vector3 direction, float impulseMultiplier, MyEntity owner)
        {
            base.Start(position, initialVelocity, direction, impulseMultiplier, owner, MyTextsWrapper.Get(MyTextsWrapperEnum.MineSmartHud));

            EntityId = MyEntityIdentifier.AllocateId();
            MyEntityIdentifier.AddEntityWithId(this);

            m_currentTarget = null;
            m_movingCue = null;
            m_lastTimeSearchedForTarget = MyConstants.FAREST_TIME_IN_PAST;
            Faction = owner.Faction;
            GuidedInMultiplayer = true;
        }
Esempio n. 41
0
        public override void Init(StringBuilder hudLabelText, MySmallShip parentObject,
            Vector3 position, Vector3 forwardVector, Vector3 upVector,
            MyMwcObjectBuilder_SmallShip_Weapon objectBuilder)
        {
            base.Init(hudLabelText, MyModelsEnum.Autocannon_Base, MyMaterialType.METAL, parentObject, 
                position, forwardVector, upVector, objectBuilder);

            m_rotationAngle = MyMwcUtils.GetRandomRadian();
            m_lastTimeShoot = MyConstants.FAREST_TIME_IN_PAST;
            m_smokeLastTime = MyConstants.FAREST_TIME_IN_PAST;
            m_smokesToGenerate = 0;
            m_cannonMotorEndPlayed = true;
            m_rotationTimeout = (float)MyAutocanonConstants.ROTATION_TIMEOUT + MyMwcUtils.GetRandomFloat(-500, +500);

            m_barrelMatrix = ModelLod0.Dummies["BARREL_POSITION"].Matrix;
            m_barrel = new MyAutocannonBarrel();
            m_barrel.Init(null, m_barrelMatrix, this);
        }
Esempio n. 42
0
 public bool CanBeHacked(MySmallShip hackedBy)
 {
     return false;
 }
Esempio n. 43
0
        //  This method realy initiates/starts the missile
        //  IMPORTANT: Direction vector must be normalized!
        public void Start(Vector3 position, Vector3 initialVelocity, Vector3 directionNormalized, MyMwcObjectBuilder_SmallShip_Ammo usedAmmo, MySmallShip minerShip)
        {
            m_usedAmmo = usedAmmo;
            m_ammoProperties = MyAmmoConstants.GetAmmoProperties(usedAmmo.AmmoType);
            m_gameplayProperties = MyGameplayConstants.GetGameplayProperties(m_usedAmmo, Faction);
            m_penetratedVoxelMap = null;
            m_wasPenetration = false;
            m_hasExplosion = false;
            m_isExploded = false;
            m_collidedEntity = null;
            m_collisionPoint = null;
                
            Matrix orientation = GetWorldRotation();
            Vector3 pos = position;

            //  Play missile thrust cue (looping)
            m_thrusterCue = MyAudio.AddCue3D(MySoundCuesEnum.WepMissileFly, pos, orientation.Forward, orientation.Up, this.Physics.LinearVelocity);

            m_light = MyLights.AddLight();
            if (m_light != null)
            {
                m_light.Start(MyLight.LightTypeEnum.PointLight, GetPosition(), MyMissileHelperUtil.GetCannonShotLightColor(), 1, MyMissileConstants.MISSILE_LIGHT_RANGE);
            }

            m_diffuseColor = m_ammoProperties.TrailColor;

            switch (usedAmmo.AmmoType)
            {
                case MyMwcObjectBuilder_SmallShip_Ammo_TypesEnum.Cannon_Basic:
                case MyMwcObjectBuilder_SmallShip_Ammo_TypesEnum.Cannon_High_Speed:
                case MyMwcObjectBuilder_SmallShip_Ammo_TypesEnum.Cannon_Armor_Piercing_Incendiary:
                case MyMwcObjectBuilder_SmallShip_Ammo_TypesEnum.Cannon_SAPHEI:
                case MyMwcObjectBuilder_SmallShip_Ammo_TypesEnum.Cannon_Proximity_Explosive:
                    m_explosionType = MyExplosionTypeEnum.MISSILE_EXPLOSION;
                    break;
                case MyMwcObjectBuilder_SmallShip_Ammo_TypesEnum.Cannon_BioChem:
                    m_explosionType = MyExplosionTypeEnum.BIOCHEM_EXPLOSION;
                    break;
                case MyMwcObjectBuilder_SmallShip_Ammo_TypesEnum.Cannon_EMP:
                    m_explosionType = MyExplosionTypeEnum.EMP_EXPLOSION;
                    break;
                case MyMwcObjectBuilder_SmallShip_Ammo_TypesEnum.Cannon_Tunnel_Buster:
                    m_explosionType = MyExplosionTypeEnum.BLASTER_EXPLOSION;
                    break;
                default:
                    throw new MyMwcExceptionApplicationShouldNotGetHere();
                    break;
            }

            this.Physics.Mass = m_gameplayProperties.WeightPerUnit;

            Vector3? correctedDirection = null;
            if (MyGameplayConstants.GameplayDifficultyProfile.EnableAimCorrection)
            {
                if (minerShip == MinerWars.AppCode.Game.Managers.Session.MySession.PlayerShip)
                {
                    correctedDirection = MyEntities.GetDirectionFromStartPointToHitPointOfNearestObject(minerShip, position, m_ammoProperties.MaxTrajectory);
                }
            }

            if (correctedDirection != null)
                directionNormalized = correctedDirection.Value;

            base.Start(position, initialVelocity, directionNormalized, m_ammoProperties.DesiredSpeed, minerShip);

            if (correctedDirection != null) //override the base class behaviour, update the missile direction
            {
                Matrix ammoWorld = minerShip.WorldMatrix;
                ammoWorld.Translation = position;
                ammoWorld.Forward = correctedDirection.Value;

                SetWorldMatrix(ammoWorld);
            }

            m_smokeEffect = MyParticlesManager.CreateParticleEffect((int)MyParticleEffectsIDEnum.Smoke_CannonShot);
            m_smokeEffect.AutoDelete = false;
            m_smokeEffect.WorldMatrix = WorldMatrix;
        }
Esempio n. 44
0
        /// <summary>
        /// Inits weapon and mount to this slot
        /// </summary>
        /// <param name="weapon">Weapon</param>
        /// <param name="objectBuilder">Weapon's objectbuilder</param>
        /// <param name="parentShip">Parent ship</param>
        public void InitAndMount(MySmallShipGunBase weapon, MyMwcObjectBuilder_SmallShip_Weapon objectBuilder, MySmallShip parentShip)
        {
            Debug.Assert(WeaponSubObject != null);
            weapon.Init(null, parentShip, GetPosition(), GetForwardVector(), GetUpVector(), objectBuilder);
            float? yOffset = GetOffsetFromWeaponSubObject(SUB_OBJECT_Y_OFFSET_KEY);
            if (yOffset != null)
            {
                weapon.YOffset = yOffset.Value;
            }

            float? zOffset = GetOffsetFromWeaponSubObject(SUB_OBJECT_Z_OFFSET_KEY);
            if (zOffset != null)
            {
                weapon.ZOffset = zOffset.Value;
            }
            Mount(weapon);
        }
Esempio n. 45
0
        //const float HARVESTER_ROCK_THROWN_STRENGTH = 7;

        public override void Init(StringBuilder hudLabelText, MySmallShip parentObject,
            Vector3 position, Vector3 forwardVector, Vector3 upVector,
            MyMwcObjectBuilder_SmallShip_Weapon objectBuilder)
        {
            base.Init(hudLabelText, MyModelsEnum.HarvestingTube, MyMaterialType.METAL, parentObject,
                position, forwardVector, upVector, objectBuilder);

            m_harvestingOreHead = new MyHarvestingHead();
            m_harvestingOreHead.Init(this);

            m_parentMinerShip = (MySmallShip)Parent;

            StartInsideShip();
        }
Esempio n. 46
0
 public bool CanBeUsed(MySmallShip usedBy)
 {
     return IsAbleToWork() && (MyFactions.GetFactionsRelation(usedBy, this) == MyFactionRelationEnum.Friend || UseProperties.IsHacked);
 }
Esempio n. 47
0
 public bool CanBeHacked(MySmallShip hackedBy)
 {
     return IsWorking() && (MyFactions.GetFactionsRelation(hackedBy, this) == MyFactionRelationEnum.Neutral ||
         MyFactions.GetFactionsRelation(hackedBy, this) == MyFactionRelationEnum.Enemy);
 }
Esempio n. 48
0
 public static void ChangeShip(MySmallShip oldShip, MySmallShip newShip)
 {
     Debug.Assert(oldShip != null && newShip != null);
     foreach (var bot in m_bots)
     {
         if (bot.Leader == oldShip)
         {
             bot.StopFollow();
             bot.Follow(newShip);
         }
     }
 }
Esempio n. 49
0
 public override void Start(MySmallShip ship, MyDetectorConfiguration configuration) 
 {
     base.Start(ship, configuration);
     m_oreMaterial = (MyMwcVoxelMaterialsEnum)configuration.Parameters[0];
 }        
Esempio n. 50
0
 public void Use(MySmallShip useBy)
 {
     MyGuiManager.AddScreen(new MyGuiScreenEntityUseSolo(this));
 }
Esempio n. 51
0
 public bool CanBeUsed(MySmallShip usedBy)
 {
     return usedBy == OwnerEntity;
 }
Esempio n. 52
0
 public bool CanBeHacked(MySmallShip hackedBy)
 {
     return IsWorking() && 
            PrefabHangarType == MyMwcObjectBuilder_PrefabHangar_TypesEnum.VENDOR &&
            MyFactions.GetFactionsRelation(hackedBy, this) == MyFactionRelationEnum.Enemy;
 }
Esempio n. 53
0
 private bool IsVisualyDetected(MySmallShip smallShip)
 {
     return MyFakes.ENABLE_BOTS_FOV_WHEN_RADAR_JAMMER && smallShip != null && smallShip.HasRadarJammerActive();
 }
Esempio n. 54
0
 public bool CanBeUsed(MySmallShip usedBy)
 {
     return false;
 }
Esempio n. 55
0
        public static MyToolKit CreateInstance(MySmallShip smallShipOwner, MyPlayer playerOwner, MyInventoryItem toolInventoryItem) 
        {
            Debug.Assert(smallShipOwner != null);
            Debug.Assert(playerOwner != null);
            Debug.Assert(IsSupportedToolKitItem(toolInventoryItem));

            MyToolKitDelegates[] delegates = m_delegatesPerToolKitType[toolInventoryItem.ObjectBuilderId.Value];
            Debug.Assert(delegates.Length > 0);
            return new MyToolKit(smallShipOwner, playerOwner, toolInventoryItem, delegates);
        }
Esempio n. 56
0
 public void Use(MySmallShip useBy)
 {
     throw new NotSupportedException();
 }
Esempio n. 57
0
 public void UseFromHackingTool(MySmallShip useBy, int hackingLevelDifference)
 {
     return;
 }
Esempio n. 58
0
 public void Use(MySmallShip useBy)
 {
     // return the camera to owner's inventory
     bool addedSuccess = useBy.Inventory.AddInventoryItem(MyMwcObjectBuilderTypeEnum.SmallShip_Ammo, (int?) MyMwcObjectBuilder_SmallShip_Ammo_TypesEnum.Universal_Launcher_Remote_Camera, 1, false) == 0f;
     if (!addedSuccess) 
     {
         MyAudio.AddCue2D(MySoundCuesEnum.HudInventoryFullWarning);
     }
     this.MarkForClose();
 }
Esempio n. 59
0
        /// <summary>
        /// Advanced prediction based on current target and missile velocity
        /// </summary>
        /// <param name="targetShip"></param>
        /// <returns></returns>
        protected Vector3 GetPredictedVelocityToTargetShipPrecise(MySmallShip targetShip)
        { //create new dir navigated to target ship.
            if (targetShip != null)
            {
                //calculate position to navigate missile to
                Vector3 idealDir = targetShip.WorldMatrix.Translation - WorldMatrix.Translation; //simple solution

                float distance = (this.WorldMatrix.Translation - targetShip.WorldMatrix.Translation).Length();
                float time = distance / m_actualSpeed;

                if (time > MyGuidedMissileConstants.MISSILE_PREDICATION_TIME_TRESHOLD)
                {
                    m_predicatedPosition = time * m_targetVelocity + targetShip.WorldMatrix.Translation;
                    idealDir = m_predicatedPosition - WorldMatrix.Translation; //simple solution
                }

                idealDir = MyMwcUtils.Normalize(idealDir);


                Vector3 targetVelocity = targetShip.Physics.LinearVelocity;
                Vector3 targetPosition = targetShip.WorldMatrix.Translation;
                Vector3 position = this.WorldMatrix.Translation;
                float speed = this.Physics.LinearVelocity.Length();

                //These variables are named by linear equation constants. Solution
                //of the equation is the time when missile and target collide
                float a = targetVelocity.LengthSquared() - speed * speed;
                float b = 2 * (Vector3.Dot(targetVelocity, targetPosition) - Vector3.Dot(targetVelocity, position));
                float c = (position.LengthSquared() + targetPosition.LengthSquared() - 2 * (Vector3.Dot(targetPosition, position)));
                float d = (b * b) - (4 * a * c);
                if (d >= 0)
                    d = (float)Math.Sqrt(d);
                else
                {
                    return idealDir;
                }

                //We test both solutions and find better one
                float t = (-b + d) / (2 * a);
                Vector3 v1 = (targetVelocity * t + targetPosition - position) / (speed * t);
                Vector3 pr1 = this.Physics.LinearVelocity * t;
                v1 = MyMwcUtils.Normalize(v1);
                t = (-b - d) / (2 * a);
                Vector3 v2 = (targetVelocity * t + targetPosition - position) / (speed * t);
                Vector3 pr2 = this.Physics.LinearVelocity * t;
                v2 = MyMwcUtils.Normalize(v2);

                float dot1 = Vector3.Dot(this.WorldMatrix.Forward, v1);
                float dot2 = Vector3.Dot(this.WorldMatrix.Forward, v2);

                //Which solution is closer to current missile dir?
                if ((dot1 - 1) * (dot1 - 1) < (dot2 - 1) * (dot2 - 1))
                {
                    idealDir = v1;
                    m_predicatedPosition = pr1 + this.GetPosition();
                }
                else
                {
                    idealDir = v2;
                    m_predicatedPosition = pr2 + this.GetPosition();
                }

                //create new navigation direction
                Vector3 actualDir = WorldMatrix.Forward;

                Vector3 rotationAxis = Vector3.Cross(actualDir, idealDir);
                Matrix rotationMatrix = Matrix.CreateFromAxisAngle(rotationAxis, m_turnSpeed * MyConstants.PHYSICS_STEP_SIZE_IN_SECONDS);
                rotationMatrix.Right = MyMwcUtils.Normalize(rotationMatrix.Right);
                rotationMatrix.Up = MyMwcUtils.Normalize(rotationMatrix.Up);
                rotationMatrix.Forward = MyMwcUtils.Normalize(rotationMatrix.Forward);

                Matrix newBodyMatrix = WorldMatrix * rotationMatrix;

                newBodyMatrix.Translation = WorldMatrix.Translation;

                SetWorldMatrix(newBodyMatrix);

                return newBodyMatrix.Forward;
            }

            //no target ship, fly straight ahead
            return WorldMatrix.Forward;
        }
Esempio n. 60
0
 public MyReflectorConfig(MySmallShip ship)
 {
     m_ship = ship;
 }