public virtual void Init(MyModelsEnum modelEnum, MyMwcObjectBuilder_SmallShip_Ammo_TypesEnum ammoEnum, bool spherePhysics = true) { base.Init(null, modelEnum, null, null, null, null); AmmoType = ammoEnum; m_gameplayProperties = MyGameplayConstants.GetGameplayProperties(MyMwcObjectBuilderTypeEnum.SmallShip_Ammo, (int)ammoEnum, Faction); m_ammoProperties = MyAmmoConstants.GetAmmoProperties(ammoEnum); // Collision skin if (spherePhysics) { InitSpherePhysics(MyMaterialType.AMMO, ModelLod0, m_gameplayProperties.WeightPerUnit, MyPhysicsConfig.DefaultAngularDamping, MyConstants.COLLISION_LAYER_DEFAULT, RigidBodyFlag.RBF_DEFAULT); } else { InitBoxPhysics(MyMaterialType.AMMO, ModelLod0, m_gameplayProperties.WeightPerUnit, MyPhysicsConfig.DefaultAngularDamping, MyConstants.COLLISION_LAYER_DEFAULT, RigidBodyFlag.RBF_DEFAULT); } Physics.GetRBElementList()[0].Flags |= MyElementFlag.EF_MODEL_PREFER_LOD0; NeedsUpdate = true; RenderObjects[0].SkipIfTooSmall = false; CastShadows = false; Closed = true; //Because ammobase instance is going to pool. It is started by Start() IsDestructible = true; PreloadTextures(); }
/// <summary> /// Returns new instance of object to build with max amount from gameplay properties /// </summary> /// <param name="objectBuilder">Object builder</param> /// <returns>New instance of object to build</returns> public static MyObjectToBuild CreateFromObjectBuilder(MyMwcObjectBuilder_Base objectBuilder) { //warning: use default faction for get gameplay properties for creating object to build float amount = MyGameplayConstants.GetGameplayProperties(objectBuilder, MyMwcObjectBuilder_FactionEnum.Euroamerican).MaxAmount; return(MyObjectToBuild.CreateFromObjectBuilder(objectBuilder, amount)); }
private void AddTreeViewItem(MyTreeViewItem parentItem, StringBuilder text, MyTexture2D icon, Vector2 iconSize, MyTexture2D expandIcon, MyTexture2D collapseIcon, Vector2 expandIconSize, MyMwcObjectBuilder_Base objectBuilder, MyBuildingSpecification buildingSpecification) { var item = parentItem.AddItem(new StringBuilder(), icon, iconSize, expandIcon, collapseIcon, expandIconSize); item.Tag = new MyObjectToBuild(objectBuilder, buildingSpecification, MyGameplayConstants.GetGameplayProperties(objectBuilder, MyEditor.Static.FoundationFactory.PrefabContainer.Faction).MaxAmount); item.ToolTip = new MyToolTips(); item.ToolTip.AddToolTip(text, Color.White, 0.7f); item.ToolTip.AddToolTip(MyTextsWrapper.Get(MyTextsWrapperEnum.BuildingRequirements)); item.ToolTip.AddToolTip(new StringBuilder(), Color.Green); item.ToolTip.AddToolTip(new StringBuilder(), Color.Red); item.IconTexts = new MyIconTexts(); item.IconTexts[MyGuiDrawAlignEnum.HORISONTAL_LEFT_AND_VERTICAL_BOTTOM] = new MyColoredText(new StringBuilder(), MyGuiConstants.COLORED_TEXT_DEFAULT_COLOR, 0.8f); item.IconTexts[MyGuiDrawAlignEnum.HORISONTAL_CENTER_AND_VERTICAL_BOTTOM] = new MyColoredText(new StringBuilder()); item.IconTexts[MyGuiDrawAlignEnum.HORISONTAL_CENTER_AND_VERTICAL_CENTER] = new MyColoredText(new StringBuilder()); item.Action = OnItemAction; item.RightClick = OnItemRighClick; UpdateTreeViewItemState(item, MyTreeViewItemUpdateStateFlag.All); }
/// <summary> /// CreatePrefabObjectBuilder /// </summary> /// <param name="prefabCategory"></param> /// <returns></returns> public MyMwcObjectBuilder_PrefabBase CreatePrefabObjectBuilder(MyMwcObjectBuilderTypeEnum prefabType, int prefabId, MyMwcObjectBuilder_Prefab_AppearanceEnum textureEnum) { MyGameplayProperties gameplayProperties = MyGameplayConstants.GetGameplayProperties(prefabType, prefabId, MyMwcObjectBuilder_FactionEnum.Euroamerican); MyPrefabConfiguration prefabConfig = MyPrefabConstants.GetPrefabConfiguration(prefabType, prefabId); MyMwcVector3Short pos = new MyMwcVector3Short(0, 0, 0); MyMwcObjectBuilder_PrefabBase objBuilder = MyMwcObjectBuilder_Base.CreateNewObject(prefabType, prefabId) as MyMwcObjectBuilder_PrefabBase; objBuilder.PositionInContainer = pos; objBuilder.AnglesInContainer = Vector3.Zero; objBuilder.PrefabHealthRatio = MyGameplayConstants.HEALTH_RATIO_MAX; objBuilder.PrefabMaxHealth = null; objBuilder.FactionAppearance = textureEnum; objBuilder.IsDestructible = gameplayProperties.IsDestructible; if (prefabConfig.DisplayHud) { objBuilder.PersistentFlags |= MyPersistentEntityFlags.DisplayOnHud; } return(objBuilder); }
public void Init() { Init(MyModelsEnum.RemoteCamera, MyMwcObjectBuilder_SmallShip_Ammo_TypesEnum.Universal_Launcher_Remote_Camera, MyUniversalLauncherConstants.USE_SPHERE_PHYSICS); // initialize gameplay properties here: m_gameplayProperties = MyGameplayConstants.GetGameplayProperties(MyMwcObjectBuilderTypeEnum.SmallShip_Tool, (int)MyMwcObjectBuilder_SmallShip_Tool_TypesEnum.REMOTE_CAMERA, MyMwcObjectBuilder_FactionEnum.None); Debug.Assert(m_gameplayProperties != null); if (m_gameplayProperties != null) { MaxHealth = m_gameplayProperties.MaxHealth; Health = m_gameplayProperties.MaxHealth; } //Physics.RigidBody.RaiseFlag(RigidBodyFlag.RBF_COLDET_THROUGH_VOXEL_TRIANGLES); m_canByAffectedByExplosionForce = true; UseProperties = new MyUseProperties(MyUseType.Solo, MyUseType.None, MyTextsWrapperEnum.NotificationYouCanTake); UseProperties.Init(MyUseType.Solo, MyUseType.None, 0, 1, false); }
public static MyInventoryItem CreateInventoryItemFromObjectBuilder(MyMwcObjectBuilder_Base objectBuilder, float amount) { float maxAmount = MyGameplayConstants.GetGameplayProperties(objectBuilder, MyMwcObjectBuilder_FactionEnum.Euroamerican).MaxAmount; float amountToAdd = Math.Min(maxAmount, amount); int objectBuilderId = objectBuilder.GetObjectBuilderId().HasValue ? objectBuilder.GetObjectBuilderId().Value : 0; MyGuiHelperBase guiHelper = MyGuiObjectBuilderHelpers.GetGuiHelper(objectBuilder.GetObjectBuilderType(), objectBuilderId); MyCommonDebugUtils.AssertDebug(guiHelper != null); //warning: use default faction for get gameplay properties for inventory item MyGameplayProperties inventoryItemProperties = MyGameplayConstants.GetGameplayProperties(objectBuilder.GetObjectBuilderType(), objectBuilderId, MyMwcObjectBuilder_FactionEnum.Euroamerican); MyCommonDebugUtils.AssertDebug(inventoryItemProperties != null); MyInventoryItem item = MyInventory.InventoryItemsPool.Allocate(); item.Start(guiHelper, inventoryItemProperties, objectBuilder, amountToAdd); return(item); }
// 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; }
/// <summary> /// All weapons cheat implementation /// </summary> static void AllWeaponsEnabled(MyGameplayCheat cheat) { if (MySession.PlayerShip == null) { return; } List <MyMwcObjectBuilder_SmallShip_Weapon> weapons = new List <MyMwcObjectBuilder_SmallShip_Weapon>(); List <MyMwcObjectBuilder_AssignmentOfAmmo> ammoAssignment = new List <MyMwcObjectBuilder_AssignmentOfAmmo>(); List <MyMwcObjectBuilder_InventoryItem> inventoryItems = new List <MyMwcObjectBuilder_InventoryItem>(); // weapons foreach (MyMwcObjectBuilder_SmallShip_Weapon_TypesEnum weapon in Enum.GetValues(typeof(MyMwcObjectBuilder_SmallShip_Weapon_TypesEnum))) { weapons.Add(new MyMwcObjectBuilder_SmallShip_Weapon(weapon)); // we want have 2x autocanon if (weapon == MyMwcObjectBuilder_SmallShip_Weapon_TypesEnum.Autocanon) { weapons.Add(new MyMwcObjectBuilder_SmallShip_Weapon(weapon)); } } // ammo assignment ammoAssignment.Add(new MyMwcObjectBuilder_AssignmentOfAmmo(MyMwcObjectBuilder_FireKeyEnum.Primary, MyMwcObjectBuilder_AmmoGroupEnum.Bullet, MyMwcObjectBuilder_SmallShip_Ammo_TypesEnum.Autocannon_Basic)); ammoAssignment.Add(new MyMwcObjectBuilder_AssignmentOfAmmo(MyMwcObjectBuilder_FireKeyEnum.Secondary, MyMwcObjectBuilder_AmmoGroupEnum.Missile, MyMwcObjectBuilder_SmallShip_Ammo_TypesEnum.Missile_Basic)); ammoAssignment.Add(new MyMwcObjectBuilder_AssignmentOfAmmo(MyMwcObjectBuilder_FireKeyEnum.Third, MyMwcObjectBuilder_AmmoGroupEnum.UniversalLauncherFront, MyMwcObjectBuilder_SmallShip_Ammo_TypesEnum.Universal_Launcher_Mine_Basic)); ammoAssignment.Add(new MyMwcObjectBuilder_AssignmentOfAmmo(MyMwcObjectBuilder_FireKeyEnum.Fourth, MyMwcObjectBuilder_AmmoGroupEnum.UniversalLauncherBack, MyMwcObjectBuilder_SmallShip_Ammo_TypesEnum.Universal_Launcher_Mine_Smart)); ammoAssignment.Add(new MyMwcObjectBuilder_AssignmentOfAmmo(MyMwcObjectBuilder_FireKeyEnum.Fifth, MyMwcObjectBuilder_AmmoGroupEnum.Bullet, MyMwcObjectBuilder_SmallShip_Ammo_TypesEnum.Autocannon_Basic)); MySession.PlayerShip.Weapons.Init(weapons, ammoAssignment); foreach (MyMwcObjectBuilder_SmallShip_Ammo_TypesEnum ammo in Enum.GetValues(typeof(MyMwcObjectBuilder_SmallShip_Ammo_TypesEnum))) { MyMwcObjectBuilder_InventoryItem item = new MyMwcObjectBuilder_InventoryItem(new MyMwcObjectBuilder_SmallShip_Ammo(ammo), MyGameplayConstants.GetGameplayProperties(MyMwcObjectBuilderTypeEnum.SmallShip_Ammo, (int)ammo, MySession.PlayerShip.Faction).MaxAmount); if (!MySession.PlayerShip.Inventory.IsFull) { MySession.PlayerShip.Inventory.AddInventoryItem(MyInventory.CreateInventoryItemFromInventoryItemObjectBuilder(item)); } } }