public MyNotification(MyTextsWrapperEnum notificationText, int disapearTimeMs, MyEntity owner = null, object[] textFormatArguments = null) : this(notificationText, GetCurrentScreen(), 1.0f, MyGuiConstants.DEFAULT_CONTROL_FONT, MyGuiDrawAlignEnum.HORISONTAL_CENTER_AND_VERTICAL_CENTER, disapearTimeMs, owner, false, textFormatArguments) { }
private MyNotification(int notificationTextId, string notificationString, MyGuiScreenGamePlayType LifeArea, float scale, MyGuiFont font, MyGuiDrawAlignEnum textAlign, int disapearTimeMs, MyEntity owner, bool showConfirmMessage = false, object[] textFormatArguments = null) { Owner = owner; m_originalText = notificationString; m_notificationText = notificationString; m_notificationTextID = (int)notificationTextId; m_isTextDirty = false; // always false: m_isDisappeared = false; m_actualScale = scale; m_actualFont = font; m_actualTextAlign = textAlign; m_textFormatArguments = textFormatArguments; // timing: m_disappearTimeMs = disapearTimeMs; m_aliveTime = 0; // life space; m_lifeSpace = LifeArea; // show standart message? m_showConfirmMessage = showConfirmMessage; }
public MyNotification(String notificationText, MyGuiScreenGamePlayType LifeArea, float scale, MyGuiFont font, MyGuiDrawAlignEnum textAlign, int disapearTimeMs, MyEntity owner = null, bool showConfirmMessage = false, object[] textFormatArguments = null) : this(0, notificationText, LifeArea, scale, font, textAlign, disapearTimeMs, owner, showConfirmMessage, textFormatArguments) { }
/// <summary> /// Inits the specified hud label text. /// </summary> /// <param name="hudLabelText">The hud label text.</param> /// <param name="modelLod0Enum">The model lod0 enum.</param> /// <param name="modelLod1Enum">The model lod1 enum.</param> /// <param name="parentObject">The parent object.</param> /// <param name="scale">The scale.</param> /// <param name="objectBuilder">The object builder.</param> public override void Init(StringBuilder hudLabelText, MyModelsEnum? modelLod0Enum, MyModelsEnum? modelLod1Enum, MyEntity parentObject, float? scale, MyMwcObjectBuilder_Base objectBuilder, MyModelsEnum? modelCollision = null, Models.MyModelsEnum? modelLod2 = null) { Flags |= EntityFlags.EditableInEditor; NeedsUpdate = true; base.Init(hudLabelText, modelLod0Enum, modelLod1Enum, null, scale, objectBuilder, modelCollision, modelLod2); }
/// <summary> /// Adds entity to action entities list /// </summary> public void AddEntity(MyEntity entity) { if (entity != null) { ActionEntities.Add(entity); } }
public MyEditorActionBase(MyEntity entity) { MinerWars.AppCode.Game.Render.MyRender.GetRenderProfiler().StartProfilingBlock("MyEditorActionBase::ctor"); Init(1); AddEntity(entity); MinerWars.AppCode.Game.Render.MyRender.GetRenderProfiler().EndProfilingBlock(); }
public void UpdateEntity(MyEntity entity) { Vector3 position; Quaternion rotation; GetValues(m_time, out position, out rotation); entity.MoveAndRotate(position, Matrix.CreateFromQuaternion(rotation)); }
static MyParticleEffect GetEffectForWeapon(MyEntity weapon, int effectID) { Dictionary<int, MyParticleEffect> effects; m_hitParticles.TryGetValue(weapon, out effects); if (effects == null) { effects = new Dictionary<int, MyParticleEffect>(); m_hitParticles.Add(weapon, effects); } MyParticleEffect effect; effects.TryGetValue(effectID, out effect); if (effect == null) { effect = MyParticlesManager.CreateParticleEffect(effectID); effects.Add(effectID, effect); effect.Tag = weapon; effect.OnDelete += new EventHandler(effect_OnDelete); } else { effect.Restart(); } return effect; }
/// <summary> /// GetSelectableEntity - return top most parent which can be selectable (in case of weapons slection return ship!) /// </summary> /// <param name="entity"></param> /// <returns></returns> public static MyEntity GetSelectableEntity(MyEntity entity) { if (entity == null) return null; if (entity.Parent == null) { if (entity.IsSelectable()) return entity; else return null; } MyEntity currEntity = entity; MyEntity topMostSelectable = (currEntity.IsSelectable()) ? currEntity : null; //store while (currEntity.Parent != null) { if (currEntity.IsSelectableAsChild() && currEntity.IsSelectable()) return currEntity; currEntity = currEntity.Parent; if (currEntity.IsSelectable()) topMostSelectable = currEntity; } return topMostSelectable; }
private void mineDetector_OnEntityPositionChange(MyEntityDetector sender, MyEntity entity, Vector3 newposition) { if (sender.Closed) return; if (entity == MySession.PlayerShip) { if (m_beepCue == null || !m_beepCue.Value.IsPlaying) { m_beepCue = MyAudio.AddCue2D(MySoundCuesEnum.SfxHudAlarmDamageA); } float distance = (entity.GetPosition() - sender.GetPosition()).Length(); if (distance < m_mineStartRadius) { uint mineId = 0; for (int i = 0; i < m_mines.GetLength(0); i++) { if (m_mines[i, 1] == sender.Parent.EntityId.Value.NumericValue) { mineId = m_mines[i, 0]; } } ExplodeMine(mineId); sender.Off(); sender.Parent.MarkForClose(); } } }
void MyScriptWrapper_AlarmLaunched(MyEntity prefabContainer, MyEntity enemy) { if (prefabContainer.EntityId != null && prefabContainer.EntityId.Value.NumericValue == 155) { MyScriptWrapper.ActivateSpawnPoint(153); } }
void EntityInventoryItemAmountChanged(MyEntity entity, MyInventory inventory, MyInventoryItem item, float number) { if (MyScriptWrapper.IsPlayerShip(entity)) { CheckOre(); } }
public MyMwcVector3Int? RenderCellCoord; //Render cell coordinate if voxel public MyRenderObject(MyEntity entity, MyMwcVector3Int? renderCellCoord) { Entity = entity; Flags = MyElementFlag.EF_AABB_DIRTY; m_renderFlags = RenderFlags.SkipIfTooSmall | RenderFlags.NeedsResolveCastShadow; RenderCellCoord = renderCellCoord; }
public void Clear() { m_glare = null; m_ignoreEntity1 = null; m_ignoreEntity2 = null; IsDone = false; }
private void ScannerOnOnEntityScanned(MyPrefabScanner sender, MyEntity scannedEntity) { if (scannedEntity == MySession.PlayerShip && m_scanners.Contains(sender)) { scannedEntity.DoDamage(0, 1000000, 0, MyDamageType.Unknown, MyAmmoType.Unknown, null); ((MyPrefabContainer) sender.Parent).AlarmOn = true; } }
public override void Init(StringBuilder displayName, Models.MyModelsEnum? modelLod0Enum, Models.MyModelsEnum? modelLod1Enum, MyEntity parentObject, float? scale, CommonLIB.AppCode.ObjectBuilders.MyMwcObjectBuilder_Base objectBuilder, Models.MyModelsEnum? modelCollision = null, Models.MyModelsEnum? modelLod2Enum = null) { base.Init(displayName, modelLod0Enum, modelLod1Enum, parentObject, scale, objectBuilder, modelCollision, modelLod2Enum); this.CastShadows = false; this.NeedsUpdate = true; this.Save = false; }
public MyEditorActionWithObjectBuildersBase(MyEntity actionEntity, bool getExactCopy = false) : base(actionEntity) { MinerWars.AppCode.Game.Render.MyRender.GetRenderProfiler().StartProfilingBlock("MyEditorActionWithObjectBuildersBase::ctor"); this.Init(1); ActionObjectBuilders.Add(new ObjectBuilderCreate(actionEntity, getExactCopy)); MinerWars.AppCode.Game.Render.MyRender.GetRenderProfiler().EndProfilingBlock(); }
public override void Load() { base.Load(); m_madelynDummy = MyScriptWrapper.GetEntity((uint) EntityID.MadelynDummy); m_madelyn = MyScriptWrapper.GetEntity("Madelyn"); m_shootWarningSent = false; MyScriptWrapper.EntityDeath += OnEntityDeath; }
public MyIntersectionResultLineTriangleEx? GetIntersectionWithLine(MyEntity physObject, ref MyLine line, ref Matrix customInvMatrix, IntersectionFlags flags) { MyLine lineInModelSpace = new MyLine(MyUtils.GetTransform(line.From, ref customInvMatrix), MyUtils.GetTransform(line.To, ref customInvMatrix), true); MyIntersectionResultLineTriangleEx? ret = m_rootNode.GetIntersectionWithLine(physObject, m_model, ref lineInModelSpace, null, flags); return ret; }
// Return true if object intersects specified sphere. // This method doesn't return exact point of intersection or any additional data. // We don't look for closest intersection - so we stop on first intersection found. public bool GetIntersectionWithSphere(MyEntity physObject, ref BoundingSphere sphere) { // Transform sphere from world space to object space Matrix worldInv = physObject.GetWorldMatrixInverted(); Vector3 positionInObjectSpace = MyUtils.GetTransform(sphere.Center, ref worldInv); BoundingSphere sphereInObjectSpace = new BoundingSphere(positionInObjectSpace, sphere.Radius); return m_rootNode.GetIntersectionWithSphere(m_model, ref sphereInObjectSpace); }
protected MyGuiControlEntityUse(IMyGuiControlsParent parent, Vector2 size, MyEntity entity, MyTexture2D texture) : base(parent, Vector2.Zero, size, Vector4.One, new StringBuilder(entity.DisplayName), MyGuiManager.GetHubItemBackground()) { m_entity = entity; m_topLeftPosition = -m_size.Value / 2f + new Vector2(0.025f, 0.025f); Controls.Add(new MyGuiControlLabel(this, m_topLeftPosition + new Vector2(0.063f, 0.0f), null, GetEntityName(entity), MyGuiConstants.LABEL_TEXT_COLOR, MyGuiConstants.LABEL_TEXT_SCALE, MyGuiDrawAlignEnum.HORISONTAL_LEFT_AND_VERTICAL_CENTER, MyGuiManager.GetFontMinerWarsBlue())); LoadControls(); m_texture = texture; }
public static void UpdateGunShot(MyEntity physObject, MyTrailerGunsShotTypeEnum gunShot) { // This method will be called even on not-tracker objects, so here we check if we need to store data about this one MyPhysObjectTrackedTickData tickData = InsertActiveTick(physObject); if (tickData != null) { tickData.GunShot = gunShot; } }
public MyEditorActionEntityCopy(MyEntity actionEntity) : base(actionEntity, true) { ActionEntities.Clear(); SourceEntities = new List<MyEntity>(); SourceEntities.Add(actionEntity); AddChildren(); RemapEntityIdsOnInit(); }
public void Start(Vector3 startPos, Vector3 goalPos, MyEntity goalEntity) { m_startPos = startPos; m_goalPos = goalPos; m_goalEntity = goalEntity; Path = new List<Vector3>(); Message = MyTextsWrapper.Get(MyTextsWrapperEnum.GPSNoPath); goalEntity.OnClose += goalEntity_OnClose; }
public void Start(MyLightGlare glare, Vector3 cameraPosition, MyEntity ignoreEntity1 = null, MyEntity ignoreEntity2 = null) { m_glare = glare; m_cameraPosition = cameraPosition; m_ignoreEntity1 = ignoreEntity1; m_ignoreEntity2 = ignoreEntity2; IsDone = false; }
public static MyGuiScreenInventory OpenInventory(MyGuiScreenInventoryType inventoryScreenType, MyEntity otherSide = null, MySmallShipInteractionActionEnum? action = null) { MyMwcLog.WriteLine("OpenInventory()"); // return harvester when opening inventory, harvester can update inventory, which would not propagete to inventory screen and closing inventory would override those changes var harvester = MySession.PlayerShip.Weapons.GetMountedHarvestingDevice(); if (harvester != null && harvester.CurrentState != MyHarvestingDeviceEnum.InsideShip) harvester.Shot(null); StringBuilder otherSideInventoryName = null; MyInventory otherSideInventory = null; List<MySmallShipBuilderWithName> shipsObjectBuilders = null; bool closeOtherSideInventory = false; m_inventoryScreenType = inventoryScreenType; m_shipsInventoryOwner = MySession.Static; m_player = MySession.Static.Player; m_detectedEntity = otherSide; m_detectedAction = action; shipsObjectBuilders = new List<MySmallShipBuilderWithName>(); shipsObjectBuilders.Add(new MySmallShipBuilderWithName(MySession.PlayerShip.GetObjectBuilder(true) as MyMwcObjectBuilder_SmallShip_Player)); switch(m_inventoryScreenType) { case MyGuiScreenInventoryType.GodEditor: LoadGodEditorInventory(ref otherSideInventory, ref otherSideInventoryName, ref shipsObjectBuilders); closeOtherSideInventory = true; break; case MyGuiScreenInventoryType.InGameEditor: LoadIngameEditorInventory(ref otherSideInventory, ref otherSideInventoryName); break; case MyGuiScreenInventoryType.Game: LoadGameInventory(ref otherSideInventory, ref otherSideInventoryName, ref shipsObjectBuilders); break; } var currentShipBuilder = shipsObjectBuilders[0]; shipsObjectBuilders.Sort((x, y) => ((int)x.Builder.ShipType).CompareTo((int)y.Builder.ShipType)); m_curentIndex = shipsObjectBuilders.IndexOf(currentShipBuilder); MyMwcObjectBuilder_Inventory otherSideInventoryBuilder = otherSideInventory != null ? otherSideInventory.GetObjectBuilder(true) : null; if (closeOtherSideInventory) { Debug.Assert(otherSideInventory != null); otherSideInventory.Close(); } m_currentInventoryScreen = new MyGuiScreenInventory(shipsObjectBuilders, m_curentIndex, m_player.Money, m_tradeForMoney, otherSideInventoryBuilder, otherSideInventoryName, m_inventoryScreenType); m_currentInventoryScreen.OnSave += Save; m_currentInventoryScreen.Closed += OnInventoryScreenClosed; MyGuiScreenGamePlay.Static.HideSelectAmmo(); return m_currentInventoryScreen; }
public void NotifyEntityScanned(MyEntity scannedEntity) { if (!m_scannedEntities.Contains(scannedEntity)) { m_scannedEntities.Add(scannedEntity); if (OnEntityScanned != null) { OnEntityScanned(this, scannedEntity); } } }
public MyGuiScreenEditorObject3DBase(MyEntity physObject, Vector2 position, Vector4 backgroundColor, Vector2? size, MyTextsWrapperEnum caption, Vector2? screenPosition = null) : base(position, backgroundColor, size) { m_caption = caption; m_newObjectPosition = MySpectator.Target + 2000 * MySpectator.Orientation; m_entity = physObject; m_backgroundFadeColor = MyGuiConstants.SCREEN_BACKGROUND_FADE_BLANK_DARK; m_backgroundFadeColor.W = 0.75f; m_screenPosition = screenPosition; this.OnEnterCallback = OnEnterClick; }
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 MyIntersectionResultLineTriangleEx? GetIntersectionWithLine(MyEntity physObject, ref MyLine line, IntersectionFlags flags) { BoundingSphere vol = physObject.WorldVolume; // Check if line intersects phys object's current bounding sphere, and if not, return 'no intersection' if (MyUtils.IsLineIntersectingBoundingSphere(ref line, ref vol) == false) return null; // Transform line into 'model instance' local/object space. Bounding box of a line is needed!! Matrix worldInv = physObject.GetWorldMatrixInverted(); return GetIntersectionWithLine(physObject, ref line, ref worldInv, flags); }