public override void Init(StringBuilder hudLabelText, MySmallShip parentObject, Vector3 position, Vector3 forwardVector, Vector3 upVector, MyMwcObjectBuilder_SmallShip_Weapon objectBuilder) { m_model = MyModelsEnum.ThermalDrill; m_movingCueEnum = MySoundCuesEnum.VehToolThermalDrillLoop3d; m_movingCueReleaseEnum = MySoundCuesEnum.VehToolThermalDrillRelease3d; m_drillCueEnum = MySoundCuesEnum.VehToolThermalDrillColliding3d; m_drillOtherCueEnum = MySoundCuesEnum.VehToolThermalDrillCollidingOther3d; m_drillOtherCueReleaseEnum = MySoundCuesEnum.VehToolThermalDrillCollidingOtherRelease3d; m_drillCueReleaseEnum = MySoundCuesEnum.VehToolThermalDrillCollidingRelease3d; m_idleCueEnum = MySoundCuesEnum.VehToolThermalDrillIdle3d; base.Init(hudLabelText, parentObject, position, forwardVector, upVector, objectBuilder); m_minDrillingDuration = MyThermalDrillDeviceConstants.MIN_DRILLING_DURATION; m_range = MyThermalDrillDeviceConstants.RANGE; m_radius = MyThermalDrillDeviceConstants.RADIUS; m_damage = MyThermalDrillDeviceConstants.DAMAGE_PER_SECOND; m_maxRotatingSpeedDrilling = MyThermalDrillDeviceConstants.MAX_ROTATING_SPEED_DRILLING; m_maxRotatingSpeedIdle = MyThermalDrillDeviceConstants.MAX_ROTATING_SPEED_IDLE; // drill head: Matrix matrix = Matrix.Identity; MyModelDummy dummy; if (ModelLod0.Dummies.TryGetValue("head", out dummy)) matrix = dummy.Matrix; else Debug.Assert(false, "Dummy 'head' in thermal drill model is missing."); m_drillHead = new MyDrillHead(); m_drillHead.Init(matrix.Translation, this, MyModelsEnum.ThermalDrillHead); }
public void Remove(MySmallShip friend) { m_playerFriends.Remove(friend); UpdateHUD(friend, false); friend.Physics.GroupMask &= ~FriendMask; friend.OnClosing -= m_friendClosing; }
public MyCameraSpring(MySmallShip ship) { m_LimitedVelocity = Vector3.Zero; m_Ship = ship; m_GameRigidBody0 = ship.Physics; m_LinearVelocity = Vector3.Zero; m_LocalTranslation = Vector3.Zero; }
private static bool IsLookAtTarget(MySmallShip smallShip, MyEntity otherEntity) { if (!MUST_LOOK_AT_TARGET || MySession.Is25DSector) { return true; } float length = Vector3.Distance(smallShip.WorldVolume.Center, otherEntity.WorldVolume.Center); MyLine line = new MyLine(smallShip.WorldVolume.Center, smallShip.WorldVolume.Center + smallShip.WorldMatrix.Forward * length * 1.5f, true); MyIntersectionResultLineTriangleEx? result = MyEntities.GetIntersectionWithLine(ref line, smallShip, null, ignoreChilds: true); return result != null && result.Value.Entity.GetBaseEntity() == otherEntity; }
public void Add(MySmallShip friend) { Debug.Assert(!friend.Closed); if (!Contains(friend)) { friend.OnClosing += m_friendClosing; friend.Physics.GroupMask |= FriendMask; m_playerFriends.Add(friend); UpdateHUD(friend, true); } }
public override void Init(StringBuilder hudLabelText, MySmallShip parentObject, Vector3 position, Vector3 forwardVector, Vector3 upVector, MyMwcObjectBuilder_SmallShip_Weapon objectBuilder) { base.Init(hudLabelText, parentObject, position, forwardVector, upVector, objectBuilder); m_rotatingSpeed = 0; m_ejectedDistance = 0; }
public override void Init(StringBuilder hudLabelText, MySmallShip parentObject, Vector3 position, Vector3 forwardVector, Vector3 upVector, MyMwcObjectBuilder_SmallShip_Weapon objectBuilder) { m_model = MyModelsEnum.Drill_Base; m_movingCueEnum = MySoundCuesEnum.VehToolCrusherDrillLoop3d; m_movingCueReleaseEnum = MySoundCuesEnum.VehToolCrusherDrillRelease3d; m_drillCueEnum = MySoundCuesEnum.VehToolCrusherDrillColliding3d; m_drillOtherCueEnum = MySoundCuesEnum.VehToolCrusherDrillCollidingOther3d; m_drillOtherCueReleaseEnum = MySoundCuesEnum.VehToolCrusherDrillCollidingOtherRelease3d; m_drillCueReleaseEnum = MySoundCuesEnum.VehToolCrusherDrillCollidingRelease3d; m_idleCueEnum = MySoundCuesEnum.VehToolCrusherDrillIdle3d; base.Init(hudLabelText, parentObject, position, forwardVector, upVector, objectBuilder); m_minDrillingDuration = MyCrusherDrillDeviceConstants.MIN_DRILLING_DURATION; m_range = MyCrusherDrillDeviceConstants.RANGE; m_radius = MyCrusherDrillDeviceConstants.RADIUS; m_damage = MyCrusherDrillDeviceConstants.DAMAGE_PER_SECOND; m_maxRotatingSpeedDrilling = MyCrusherDrillDeviceConstants.MAX_ROTATING_SPEED_DRILLING; m_maxRotatingSpeedIdle = MyCrusherDrillDeviceConstants.MAX_ROTATING_SPEED_IDLE; //Create Drill Bits m_drillBits = new MyDrillBit[DRILL_BIT_COUNT]; for (int i = 0; i < DRILL_BIT_COUNT; i++) { m_drillBits[i] = new MyDrillBit(); } //Init Drill Bits Vector3 gear1Offset = new Vector3(0, 0, 0.05f); Vector3 gear2Offset = new Vector3(0, 0, 0.15f); Vector3 gear3Offset = new Vector3(0, 0, 0.30f); const float FIRST_ROTATE_SPEED = 0.2f * MathHelper.TwoPi * MyConstants.PHYSICS_STEP_SIZE_IN_SECONDS; const float SECOND_ROTATE_SPEED = 0.5f * -FIRST_ROTATE_SPEED; const float THIRD_ROTATE_SPEED = 1.25f * FIRST_ROTATE_SPEED; Matrix bit01 = MyMath.NormalizeMatrix(ModelLod0.Dummies["BIT01"].Matrix); Matrix bit02 = MyMath.NormalizeMatrix(ModelLod0.Dummies["BIT02"].Matrix); Matrix bit03 = MyMath.NormalizeMatrix(ModelLod0.Dummies["BIT03"].Matrix); m_drillBits[0].Init(null, bit01, gear1Offset, FIRST_ROTATE_SPEED, this, MyModelsEnum.Drill_Gear1); m_drillBits[1].Init(null, bit01, gear2Offset, SECOND_ROTATE_SPEED, this, MyModelsEnum.Drill_Gear2); m_drillBits[2].Init(null, bit01, gear3Offset, THIRD_ROTATE_SPEED, this, MyModelsEnum.Drill_Gear3); m_drillBits[3].Init(null, bit02, gear1Offset, FIRST_ROTATE_SPEED, this, MyModelsEnum.Drill_Gear1); m_drillBits[4].Init(null, bit02, gear2Offset, SECOND_ROTATE_SPEED, this, MyModelsEnum.Drill_Gear2); m_drillBits[5].Init(null, bit02, gear3Offset, THIRD_ROTATE_SPEED, this, MyModelsEnum.Drill_Gear3); m_drillBits[6].Init(null, bit03, gear1Offset, FIRST_ROTATE_SPEED, this, MyModelsEnum.Drill_Gear1); m_drillBits[7].Init(null, bit03, gear2Offset, SECOND_ROTATE_SPEED, this, MyModelsEnum.Drill_Gear2); m_drillBits[8].Init(null, bit03, gear3Offset, THIRD_ROTATE_SPEED, this, MyModelsEnum.Drill_Gear3); }
public MyGuiScreenEditorSmallShip(MySmallShip smallShip) : base(smallShip, new Vector2(0.5f, 0.5f), MyGuiConstants.SCREEN_BACKGROUND_COLOR, null, MyTextsWrapperEnum.EditSmallShip) { m_bot = smallShip as MySmallShipBot; Init(); m_selectShipFactionCombobox.SelectItemByKey((int)m_bot.Faction); m_selectAITemplateCombobox.SelectItemByKey((int)m_bot.AITemplate.TemplateId); m_aggresivitySlider.SetValue(m_bot.Aggressivity); m_seeDistanceSlider.SetValue(m_bot.SeeDistance); m_selectSmallShipCombobox.SelectItemByKey((int)m_bot.ShipType); }
public override void Init(StringBuilder hudLabelText, MySmallShip parentObject, Vector3 position, Vector3 forwardVector, Vector3 upVector, MyMwcObjectBuilder_SmallShip_Weapon objectBuilder) { m_model = MyModelsEnum.PressureDrill; m_movingCueEnum = null; m_movingCueReleaseEnum = null; m_drillCueEnum = null; m_drillOtherCueEnum = null; m_drillCueReleaseEnum = null; m_drillOtherCueReleaseEnum = null; m_radius = MyPressureDrillDeviceConstants.RADIUS; m_damage = MyPressureDrillDeviceConstants.DAMAGE; base.Init(hudLabelText, parentObject, position, forwardVector, upVector, objectBuilder); }
private static bool IsCustomLookAtTarget(MySmallShip smallShip, MyEntity otherEntity, float radius) { if (!MUST_LOOK_AT_TARGET) { return true; } BoundingSphere sphere = new BoundingSphere(otherEntity.WorldVolume.Center, radius); Ray ray = new Ray(smallShip.GetPosition(), smallShip.WorldMatrix.Forward); float? rayIntersection = ray.Intersects(sphere); if (rayIntersection.HasValue) { MyLine line = new MyLine(smallShip.WorldVolume.Center, otherEntity.WorldVolume.Center, true); MyIntersectionResultLineTriangleEx? result = MyEntities.GetIntersectionWithLine(ref line, smallShip, null, ignoreChilds: true); return !result.HasValue || !result.HasValue || result.Value.Entity == otherEntity; } return false; }
public override void Init(StringBuilder hudLabelText, MySmallShip parentObject, Vector3 position, Vector3 forwardVector, Vector3 upVector, MyMwcObjectBuilder_SmallShip_Weapon objectBuilder) { m_model = MyModelsEnum.SawDrill; m_movingCueEnum = MySoundCuesEnum.VehToolSawLoop3d; m_movingCueReleaseEnum = MySoundCuesEnum.VehToolSawRelease3d; m_drillCueEnum = MySoundCuesEnum.VehToolSawCut3d; m_drillOtherCueEnum = MySoundCuesEnum.VehToolSawCutOther3d; m_drillOtherCueReleaseEnum = MySoundCuesEnum.VehToolSawCutOtherRelease3d; m_drillCueReleaseEnum = MySoundCuesEnum.VehToolSawCutRelease3d; m_idleCueEnum = MySoundCuesEnum.VehToolSawIdle3d; base.Init(hudLabelText, parentObject, position, forwardVector, upVector, objectBuilder); m_minDrillingDuration = MySawDrillDeviceConstants.MIN_DRILLING_DURATION; m_range = MySawDrillDeviceConstants.RANGE; m_radius = MySawDrillDeviceConstants.RADIUS; m_damage = MySawDrillDeviceConstants.DAMAGE_PER_SECOND; m_directionalEffectID = MyParticleEffectsIDEnum.Drill_Saw; }
public MyGuiScreenSecurityControlHUB(MySmallShip useBy, MyPrefabSecurityControlHUB prefabSecurityControlHUB) : base(new Vector2(0.505f, 0.5f), MyGuiConstants.SCREEN_BACKGROUND_COLOR, new Vector2(0.57f, 0.96f), true, MyGuiManager.GetHubBackground()) { AddCaption(MyTextsWrapperEnum.SecurityControlHUB, new Vector2(0, 0.005f)); m_prefabSecurityControlHUB = prefabSecurityControlHUB; m_useBy = useBy; m_entitiesGui = new List<MyGuiControlEntityUse>(); RecreateControls(true); /* Controls.Add(new MyGuiControlButton(this, new Vector2(0f, 0.45f), MyGuiConstants.MESSAGE_BOX_BUTTON_SIZE, MyGuiConstants.BUTTON_BACKGROUND_COLOR, MyTextsWrapperEnum.Exit, MyGuiConstants.BUTTON_TEXT_COLOR, MyGuiConstants.BUTTON_TEXT_SCALE, OnExitClick, MyGuiControlButtonTextAlignment.CENTERED, true, MyGuiDrawAlignEnum.HORISONTAL_CENTER_AND_VERTICAL_CENTER, true)); * */ MyGuiScreenGamePlay.Static.ReleasedControlOfEntity += OnGameReleasedControlOfEntity; MyGuiScreenGamePlay.Static.RollLeftPressed += OnSwitchPrevious; MyGuiScreenGamePlay.Static.RollRightPressed += OnSwitchNext; MySession.PlayerShip.OnDie += OnPlayerShipDie; MySession.Static.Player.AliveChanged += Player_AliveChanged; m_prefabSecurityControlHUB.OnEntityDisconnected += m_prefabSecurityControlHUB_OnEntityDisconnected; }
public void UseFromHackingTool(MySmallShip useBy, int hackingLevelDifference) { Use(useBy); }
public static bool CanLootShip(MySmallShip shipToLoot, params object[] args) { if (!ControlIsInPlayerShip() || IsBlocked(shipToLoot, args)) { return false; } MySmallShip smallShip = GetSmallShipFromArguments(args); //bool hasRightFactionRelation = MyFactions.GetFactionsRelation(smallShip, shipToLoot) == MyFactionRelationEnum.Enemy; //return hasRightFactionRelation && IsLookAtTarget(smallShip, shipToLoot); return IsShipLootable(shipToLoot) && IsLookAtTarget(smallShip, shipToLoot); }
private static bool IsShipLootable(MySmallShip smallShip) { bool isParked = (smallShip is MySmallShipBot && ((MySmallShipBot)smallShip).IsParked()); return smallShip.IsPilotDead() || isParked && smallShip.Enabled; }
public void UseFromHackingTool(MySmallShip useBy, int hackingLevelDifference) { throw new NotSupportedException(); }
public void Use(MySmallShip useBy) { MyGuiScreenGamePlay.Static.TakeControlOfCamera(this); }
public void GetClosestSmallShipInSearchDistance(out MySmallShip closestShip) { closestShip = m_target; }
public void GetClosestPotentialSmallShipInSearchDistance(out MySmallShip closestShip) { closestShip = m_potentialTarget; }
public void SpoilHologram(MySmallShip smallShip) { Debug.Assert(smallShip.IsHologram); lock (m_hologramLock) { m_spoiledHolograms.Add(smallShip); } }
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; }
public void Use(MySmallShip useBy) { MyGuiManager.AddScreen(new MyGuiScreenEntityUseSolo(this)); }
public bool TryFindRoute(MySmallShip target) { if (m_findingRoute) return false; m_findingRoute = true; MyRoutefindingHelper.FindRouteInBackground(this, target.RouteMemory, RouteFoundCallback, null); return true; }
public bool CanBeUsed(MySmallShip usedBy) { return IsWorking() && (MyFactions.GetFactionsRelation(usedBy, this) == MyFactionRelationEnum.Friend || UseProperties.IsHacked); }
public void LaunchAlarm(MySmallShip source) { foreach (var entity in MyEntities.GetEntities()) { var container = entity as MyPrefabContainer; if (container != null) { container.LaunchAlarm(this, source); } } }
public bool CanBeHacked(MySmallShip hackedBy) { return IsWorking() && (MyFactions.GetFactionsRelation(hackedBy, this) == MyFactionRelationEnum.Neutral || MyFactions.GetFactionsRelation(hackedBy, this) == MyFactionRelationEnum.Enemy); }
/// <summary> /// For debugging, add text to the debug screen which details the state of this bot. /// TODO: Move this to MyGuiScreenDebugBot. That class is specific to bot so this stuff could/should go there. /// </summary> /// <param name="bot">Computer-controlled ship.</param> /// <param name="player">The bot's target.</param> public static void AddToFrameDebugText(MySmallShipBot bot, MySmallShip player) { // Get a reference to the debug screen. MyGuiScreenDebugBot debugScreen = MyGuiManager.GetScreenDebugBot(); if (debugScreen != null) { // Here's the bot info we're adding to the debug screen text. debugScreen.AddToFrameDebugText("MyPhysObjectBot"); // Hello. debugScreen.AddToFrameDebugText(" Message: Hello!"); // Position. debugScreen.AddToFrameDebugText(" Player.Position: " + MyUtils.GetFormatedVector3(player.GetPosition(), 0)); // Offest between bot and player. Vector3 playerPos = player.GetPosition(); Vector3 botPos = bot.GetPosition(); Vector3 botToPlayer = botPos - playerPos; debugScreen.AddToFrameDebugText(" BotToPlayer: " + botToPlayer.ToString()); // Offest between player and bot. Vector3 playerToBot = playerPos - botPos; debugScreen.AddToFrameDebugText(" PlayerToBot: " + playerToBot.ToString()); // Bot forward Vector3 forward = bot.WorldMatrix.Forward; debugScreen.AddToFrameDebugText(" Bot.WorldMatrix.Forward: " + MyUtils.GetFormatedVector3(forward, 0)); // m_playersRelativePosition //debugScreen.AddToFrameDebugText(" Bot.m_playersRelativePosition: " + MyUtils.GetFormatedVector3(bot.Behavior.TargetsRelativePosition, 0)); // Aimed at player? //debugScreen.AddToFrameDebugText(" Bot.IsAimedAtPlayer: " + bot.IsBotPrettyMuchAimedAtPlayer()); // Distance to player. //debugScreen.AddToFrameDebugText(" Bot.DistanceToPlayer: " + ((int)(bot.DistanceTo(bot.Decision.Target))).ToString()); // Rotation indicator. //debugScreen.AddToFrameDebugText(" Bot.RotationIndicator: " + MyUtils.GetFormatedVector2(bot.RotationIndicator, 1)); // Blank line. debugScreen.AddToFrameDebugText(" "); } }
public bool CanBeHacked(MySmallShip hackedBy) { return false; }
void CreateCargoBoxWithDroppedItems(IEnumerable<int> droppedItemIDs, MySmallShip dropper) { var worldMatrix = Matrix.CreateWorld( dropper.WorldVolume.Center, dropper.GetForward(), dropper.GetUp()); var items = new List<MyMwcObjectBuilder_InventoryItem>(); foreach (var droppedItemID in droppedItemIDs) { var inventoryItem = m_itemsRepository.GetItem(droppedItemID); items.Add(new MyMwcObjectBuilder_InventoryItem(inventoryItem.GetInventoryItemObjectBuilder(false), inventoryItem.Amount)); } var inventory = new MyMwcObjectBuilder_Inventory(items, MyInventory.DEFAULT_MAX_ITEMS); var cargoBoxBuilder = new MyMwcObjectBuilder_CargoBox(inventory) { CargoBoxType = MyMwcObjectBuilder_CargoBox_TypesEnum.DroppedItems }; cargoBoxBuilder.PersistentFlags |= MyPersistentEntityFlags.ActivatedOnAllDifficulties; var cargoBox = MyEntities.CreateFromObjectBuilderAndAdd(null, cargoBoxBuilder, worldMatrix); var matrix = cargoBox.WorldMatrix; matrix.Translation += 0.8f * dropper.WorldVolume.Radius * dropper.GetForward(); matrix.Translation -= 0.5f * dropper.WorldVolume.Radius * dropper.GetUp(); cargoBox.WorldMatrix = matrix; cargoBoxBuilder.EntityId = cargoBox.EntityId.ToNullableUInt(); if (MyMultiplayerGameplay.IsRunning) { MyMultiplayerGameplay.Static.NewEntity(cargoBoxBuilder, cargoBox.WorldMatrix); MyMultiplayerGameplay.Static.HookEntity(cargoBox); } }
public bool CanBeUsed(MySmallShip usedBy) { return IsWorking(); }