/// <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); } } } } }
protected override MyMwcObjectBuilder_Base GetObjectBuilderInternal(bool getExactCopy) { MyMwcObjectBuilder_PrefabLargeWeapon objectBuilderWeapon = (MyMwcObjectBuilder_PrefabLargeWeapon)base.GetObjectBuilderInternal(getExactCopy); //This is duplicate from MyPrefab objectBuilderWeapon.PositionInContainer = MyPrefabContainer.GetRelativePositionInContainerCoords(this.LocalMatrix.Translation); float yaw, pitch, roll; Matrix rot = this.LocalMatrix; rot.Translation = Vector3.Zero; MyUtils.RotationMatrixToYawPitchRoll(ref rot, out yaw, out pitch, out roll); objectBuilderWeapon.AnglesInContainer = new Vector3(yaw, pitch, roll); //end of duplicate from MyPrefab objectBuilderWeapon.PrefabLargeWeaponType = weaponType; //objectBuilderWeapon.PrefabHealthRatio = Health; objectBuilderWeapon.UseProperties = UseProperties.GetObjectBuilder(); objectBuilderWeapon.SearchingDistance = SearchingDistance; objectBuilderWeapon.AimingDistance = 0; return(objectBuilderWeapon); }
private static void UnpackMothership() { MyTrace.Send(TraceWindow.Saving, "Player unpacking mothership"); MyInventoryItem item = MySession.Static.Inventory.GetInventoryItem(MyMwcObjectBuilderTypeEnum.PrefabContainer, null); if (item != null) { //place largeship //MyMwcObjectBuilder_LargeShip largeShipObjectBuilder = (MyMwcObjectBuilder_LargeShip)inventoryItems[0].GetObjectBuilder(true); MyMwcObjectBuilder_PrefabContainer containerObjectBuilder = (MyMwcObjectBuilder_PrefabContainer)item.GetInventoryItemObjectBuilder(true); // We need to remove id's because mothership container could have same entity id in different sector containerObjectBuilder.RemapEntityIds(new MyEntityIdRemapContext()); MyPrefabContainer container = new MyPrefabContainer(); container.Init(null, containerObjectBuilder, FindMothershipPosition()); MyEntities.Add(container); //CreateFromObjectBuilderAndAdd(null, largeShipObjectBuilder, Matrix.CreateTranslation(MySession.PlayerShip.GetPosition() + new Vector3(100,100,0))); MySession.Static.Inventory.RemoveInventoryItem(item); container.Link(); MyTrace.Send(TraceWindow.Saving, "Player mothership found and unpacked"); } }
/// <summary> /// DrawSelectedBounding /// </summary> private void DrawSelectedBounding() { if (MyConfig.EditorDisplayUnselectedBounding) { Vector4 color = new Vector4(0.6f, 0.6f, 0.6f, 0.2f); foreach (MyEntity entity in MyEntities.GetEntities()) { entity.DebugDrawBox(color, false); } foreach (MyVoxelMap voxelMap in MyVoxelMaps.GetVoxelMaps()) { MyDebugDraw.DrawHiresBoxWireframe(Matrix.CreateScale(voxelMap.GetSize()) * voxelMap.WorldMatrix, new Vector3(0, 0.4f, 0), 0.3f); } } if (IsEditingPrefabContainer()) { m_activePrefabContainer.DebugDrawBox(new Vector4(1, 1, 0, 0.4f)); } foreach (MyEntity entity in MyEditorGizmo.SelectedEntities) { if (entity is MyPrefabContainer) { MyPrefabContainer container = (MyPrefabContainer)entity; container.DebugDrawBox(new Vector4(0, 1, 0, 0.4f)); } } }
public MyPrefabKinematic(MyPrefabContainer owner) : base(owner) { m_onGameLoaded = new EventHandler(MyGuiScreenGamePlay_OnGameLoaded); MyGuiScreenGamePlay.OnGameLoaded += m_onGameLoaded; m_parts = new MyPrefabKinematicPart[MyMwcObjectBuilder_PrefabKinematic.MAX_KINEMATIC_PARTS]; m_edges = new List <Tuple <MyWayPoint, MyWayPoint> >(); }
private void Init(int entitiesCount) { m_activeContainer = MyEditor.Static.GetEditedPrefabContainer(); if (ActionEntities == null) { ActionEntities = new List <MyEntity>(entitiesCount); } }
private static void SetContainerVisibleStatus(MyPrefabContainer container, bool visible) { if (visible) { MyScriptWrapper.UnhideEntity(container); } else { MyScriptWrapper.HideEntity(container); } }
/// <summary> /// Creates new instance of foundation factory prefab /// </summary> /// <param name="owner">Owner</param> public MyPrefabFoundationFactory(MyPrefabContainer owner) : base(owner) { Player = MySession.Static.Player; BuildObjects = new List <MyObjectToBuild>(); BuildingQueue = new List <MyObjectToBuild>(); BuildingObject = null; m_buildingTimeFromStart = 0; IsBuilding = false; }
public MyGuiScreenEntityWithInventory(MyEntity entityWithInventory) : base(entityWithInventory, new Vector2(0.5f, 0.5f), MyGuiConstants.SCREEN_BACKGROUND_COLOR, null, MyTextsWrapperEnum.EditInventory) { Debug.Assert(entityWithInventory is IMyInventory); EntityWithInventory = entityWithInventory as IMyInventory; if (entityWithInventory is MyPrefabHangar) { PrefabContainer = ((MyPrefabHangar)entityWithInventory).GetOwner(); } else { PrefabContainer = entityWithInventory as MyPrefabContainer; } m_itemsAdded = new List <MyInventoryItem>(); m_itemsRemoved = new List <MyInventoryItem>(); Init(); }
private int GetPanelsLeft(uint containerEntityId) { int panelsLeft = -2; // apparently there are 13*9 panels and two non-panels :) MyPrefabContainer container = MyScriptWrapper.GetEntity(containerEntityId) as MyPrefabContainer; Debug.Assert(container != null); if (container != null) { foreach (var prefab in container.GetPrefabs()) { if (prefab is MyPrefabLight == false) { ++panelsLeft; } } } return(panelsLeft); }
/// <summary> /// Creates new foundation factory from player's inventory. When player has no foundation factory in inventory, then returns result false. /// </summary> /// <param name="result">Result of foundation factory creation</param> /// <returns>Instance of new foundation factory</returns> public static MyPrefabFoundationFactory TryCreateFoundationFactory(MyPlayer player, out bool result) { MyPrefabFoundationFactory foundationFactory = null; MyInventoryItem foundationFactoryItem = player.Ship.Inventory.GetInventoryItem(MyMwcObjectBuilderTypeEnum.PrefabFoundationFactory, (int)MyMwcObjectBuilder_PrefabFoundationFactory_TypesEnum.DEFAULT); if (foundationFactoryItem == null) { foundationFactoryItem = player.Ship.Inventory.GetInventoryItem(MyMwcObjectBuilderTypeEnum.FoundationFactory, null); } if (foundationFactoryItem == null) { result = false; } else { MyMwcObjectBuilder_PrefabFoundationFactory foundationFactoryBuilder = MyMwcObjectBuilder_Base.CreateNewObject(MyMwcObjectBuilderTypeEnum.PrefabFoundationFactory, (int)MyMwcObjectBuilder_PrefabFoundationFactory_TypesEnum.DEFAULT) as MyMwcObjectBuilder_PrefabFoundationFactory; MyMwcObjectBuilder_PrefabContainer prefabContainerBuilder = new MyMwcObjectBuilder_PrefabContainer( null, MyMwcObjectBuilder_PrefabContainer_TypesEnum.INSTANCE, new List <MyMwcObjectBuilder_PrefabBase>(), MyClientServer.LoggedPlayer.GetUserId(), player.Faction, new MyMwcObjectBuilder_Inventory(new List <MyMwcObjectBuilder_InventoryItem>(), 1000)); Matrix ffWorld = Matrix.Identity; ffWorld.Translation = player.Ship.WorldMatrix.Translation + player.Ship.WorldMatrix.Forward * 20; MyPrefabContainer prefabContainer = new MyPrefabContainer(); prefabContainer.Init(null, prefabContainerBuilder, ffWorld); MyEntities.Add(prefabContainer); MyPrefabConfiguration ffConfiguration = MyPrefabConstants.GetPrefabConfiguration(MyMwcObjectBuilderTypeEnum.PrefabFoundationFactory, (int)MyMwcObjectBuilder_PrefabFoundationFactory_TypesEnum.DEFAULT); foundationFactory = new MyPrefabFoundationFactory(prefabContainer); foundationFactory.Init(null, new Vector3(0f, 0f, 0f), Matrix.Identity, foundationFactoryBuilder, ffConfiguration); prefabContainer.AddPrefab(foundationFactory); player.Ship.Inventory.RemoveInventoryItemAmount(ref foundationFactoryItem, 1f); result = true; } return(foundationFactory); }
static public void DumpAllEntities() { m_typesStats.Clear(); MyMwcLog.WriteLine("Dump of all loaded prefabs"); MyMwcLog.WriteLine(""); foreach (MyEntity entity in MyEntities.GetEntities()) { MyPrefabContainer container = entity as MyPrefabContainer; if (container != null) { foreach (var prefab in container.GetPrefabs()) { string ts = prefab.ModelLod0.AssetName.ToString(); if (!m_typesStats.ContainsKey(ts)) { m_typesStats.Add(ts, new MyTypeStats()); } m_typesStats[ts].Count++; m_typesStats[ts].Tris += prefab.ModelLod0.Triangles.Length; m_typesStats[ts].UserData = prefab; m_typesStats[ts].UserString += prefab.EntityId.Value.NumericValue + " "; } } } foreach (var po in SortByCount(m_typesStats)) { var prefab = ((MinerWars.AppCode.Game.Prefabs.MyPrefabBase)po.Value.UserData); int verticesSize = prefab.ModelLod0.GetVBSize + prefab.ModelLod0.GetIBSize; MyMwcLog.WriteLine(po.Key + "," + po.Value.Count + "," + po.Value.Tris + "," + verticesSize + "," + prefab.ModelLod0.GetBVHSize() + "," + po.Value.UserString); } }
public MyPrefabBankNode(MyPrefabContainer owner) : base(owner) { }
public void HandleInput(MyGuiInput input) { if (!m_bHandleInput) { return; } Vector2 currPos = MyGuiManager.MouseCursorPosition;// new MyPoint(input.GetMouseX(), input.GetMouseY()); if (currPos == m_lastPos && MyConfig.EditorUseCameraCrosshair == false) { return; } m_lastPos = currPos; MyEntity entity = GetIntersectedEntity(); if (entity == null && m_mouseOverEntity != null) { //@ TurnOff highlightning HighlightEntity(m_mouseOverEntity, false); return; } entity = MySelectionTool.GetSelectableEntity(entity); //this needs to be tweaked //@ entity is selected do not highlight! foreach (MyEntity sel in MyEditorGizmo.SelectedEntities) { if (sel == entity) { return; } } //@ filter - if editor is in mode EditPrefabContainer (so it's not allowed to select other entity outside container) //@ i do not allow highlight entity outside of prefab container //@ - when editor ingamemode - dont allow to select/mouseover anything except my own container or entities in it MyPrefabContainer container = MyEditor.Static.GetEditedPrefabContainer(); if (container != null && entity != null) { if (container.IsEntityFromContainer(entity) == false) { BoundingSphere sphere = entity.WorldVolume; if (container.GetIntersectionWithMaximumBoundingBox(ref sphere) == false) { return; } } } if (entity == null) { //@ TurnOff highlightning HighlightEntity(m_mouseOverEntity, false); return; } if (entity != m_mouseOverEntity) { if (m_mouseOverEntity != null) { HighlightEntity(m_mouseOverEntity, false); } HighlightEntity(entity, true); } }
public MyPrefabCamera(MyPrefabContainer owner) : base(owner) { }
/// <summary> /// RemoveContainer /// </summary> /// <param name="container"></param> public void RemoveContainer(MyPrefabContainer container) { m_containerList.Remove(container); }
/// <summary> /// AddContainer /// </summary> /// <param name="container"></param> public void AddContainer(MyPrefabContainer container) { m_containerList.Add(container); }
public MyPrefabLargeWeapon(MyPrefabContainer owner) : base(owner) { CheckExplosionObstacles = false; }
public MyPrefabKinematicRotating(MyPrefabContainer owner) : base(owner) { m_parts = new List<MyPrefabKinematicRotatingPart>(); }
//private BoundingBox m_localBoundingBox; public MyPrefabHangar(MyPrefabContainer owner) : base(owner) { }
public MyPrefabLargeShip(MyPrefabContainer owner) : base(owner) { }
protected static void ShowContainer(MyPrefabContainer container) { SetContainerVisibleStatus(container, true); }
public MyPrefabGenerator(MyPrefabContainer owner) : base(owner) { }
protected static void HideContainer(MyPrefabContainer container) { SetContainerVisibleStatus(container, false); }
public MyPrefabLight(MyPrefabContainer owner): base(owner) { }
/// <summary> /// CreatePrefab /// </summary> /// <param name="hudLabelText"></param> /// <param name="objBuilder"></param> /// <returns></returns> public MyPrefabBase CreatePrefab(string hudLabelText, MyPrefabContainer prefabContainer, MyMwcObjectBuilder_PrefabBase prefabBuilder) { Render.MyRender.GetRenderProfiler().StartProfilingBlock("MyPrefabFactory.CreatePrefab"); MyPrefabConfiguration config = MyPrefabConstants.GetPrefabConfiguration(prefabBuilder.GetObjectBuilderType(), prefabBuilder.GetObjectBuilderId().Value); Vector3 relativePosition = MyPrefabContainer.GetRelativePositionInAbsoluteCoords(prefabBuilder.PositionInContainer); Matrix prefabLocalOrientation = Matrix.CreateFromYawPitchRoll(prefabBuilder.AnglesInContainer.X, prefabBuilder.AnglesInContainer.Y, prefabBuilder.AnglesInContainer.Z); MyPrefabBase prefab = null; if (config is MyPrefabConfigurationKinematic) { prefab = new MyPrefabKinematic(prefabContainer); } else if (config is MyPrefabConfigurationLight) { prefab = new MyPrefabLight(prefabContainer); } else if (config is MyPrefabConfigurationLargeWeapon) { prefab = new MyPrefabLargeWeapon(prefabContainer); } else if (config is MyPrefabConfigurationSound) { prefab = new MyPrefabSound(prefabContainer); } else if (config is MyPrefabConfigurationParticles) { prefab = new MyPrefabParticles(prefabContainer); } else if (config is MyPrefabConfigurationLargeShip) { prefab = new MyPrefabLargeShip(prefabContainer); } else if (config is MyPrefabConfigurationHangar) { prefab = new MyPrefabHangar(prefabContainer); } else if(config is MyPrefabConfigurationFoundationFactory) { prefab = new MyPrefabFoundationFactory(prefabContainer); } else if (config is MyPrefabConfigurationSecurityControlHUB) { prefab = new MyPrefabSecurityControlHUB(prefabContainer); } else if (config is MyPrefabConfigurationBankNode) { prefab = new MyPrefabBankNode(prefabContainer); } else if (config is MyPrefabConfigurationGenerator) { prefab = new MyPrefabGenerator(prefabContainer); } else if (config is MyPrefabConfigurationScanner) { prefab = new MyPrefabScanner(prefabContainer); } else if (config is MyPrefabConfigurationCamera) { prefab = new MyPrefabCamera(prefabContainer); } else if (config is MyPrefabConfigurationAlarm) { prefab = new MyPrefabAlarm(prefabContainer); } else { prefab = new MyPrefab(prefabContainer); //prefab.Init(hudLabelText, relativePosition, prefabLocalOrientation, prefabBuilder, config); } prefab.Init(hudLabelText, relativePosition, prefabLocalOrientation, prefabBuilder, config); Render.MyRender.GetRenderProfiler().EndProfilingBlock(); return prefab; }
public MyPrefabLight(MyPrefabContainer owner) : base(owner) { }
public MyGuiControlPrefabContainerUse(IMyGuiControlsParent parent, MyPrefabContainer prefabContainer, MyTexture2D texture) : base(parent, new Vector2(0.452f, 0.127f), prefabContainer, texture) { }
public MyPrefabParticles(MyPrefabContainer owner) : base(owner) { ; }
public MyPrefabKinematic(MyPrefabContainer owner) : base(owner) { m_onGameLoaded = new EventHandler(MyGuiScreenGamePlay_OnGameLoaded); MyGuiScreenGamePlay.OnGameLoaded += m_onGameLoaded; m_parts = new MyPrefabKinematicPart[MyMwcObjectBuilder_PrefabKinematic.MAX_KINEMATIC_PARTS]; m_edges = new List<Tuple<MyWayPoint, MyWayPoint>>(); }
public MyPrefabAlarm(MyPrefabContainer owner) : base(owner) { }
/// <summary> /// asteroid has to be either MyVoxelMap or MyStaticAsteroid. /// </summary> /// <param name="asteroid">Has to be either MyVoxelMap or MyStaticAsteroid!</param> public MyGuiScreenEditorPrefabContainer(MyPrefabContainer prefabContainer) : base(prefabContainer, new Vector2(0.5f, 0.5f), MyGuiConstants.SCREEN_BACKGROUND_COLOR, null, MyTextsWrapperEnum.EditPrefabContainer) { Init(); }
public MyPrefabSound(MyPrefabContainer owner) : base(owner) { }
public MyPrefabScanner(MyPrefabContainer owner) : base(owner) { m_scannedEntities = new List <MyEntity>(); OnEntityScanned += m_owner.LaunchAlarm; }
public MyPrefabKinematicPartBase(MyPrefabContainer owner) : base(owner) { Flags |= EntityFlags.NeedsId; }
public MyPrefabKinematicPart(MyPrefabContainer owner) : base(owner) { }