Skip to content

Commit

Permalink
Update newfile.txt
Browse files Browse the repository at this point in the history
  • Loading branch information
InvalidArgument3 committed Jun 11, 2024
1 parent 6c9e934 commit e0b3ebc
Showing 1 changed file with 58 additions and 2 deletions.
60 changes: 58 additions & 2 deletions Dynamic Asteroids/Data/newfile.txt
Original file line number Diff line number Diff line change
Expand Up @@ -76,13 +76,25 @@ namespace DynamicAsteroids
public static float BaseIntegrity = 1f;
public static float MinAsteroidSize = 50f;
public static float MaxAsteroidSize = 250f;
public static float MinSubChunkSize = 2f;
public static float MinSubChunkSize = 5f;

public static double SubChunkVelocityMin = 1.0;
public static double SubChunkVelocityMax = 5.0;
public static double SubChunkAngularVelocityMin = 0.01;
public static double SubChunkAngularVelocityMax = 0.1;

public static int[] IceDropRange = { 1000, 10000 };
public static int[] StoneDropRange = { 1000, 10000 };
public static int[] IronDropRange = { 500, 2500 };
public static int[] NickelDropRange = { 500, 2500 };
public static int[] CobaltDropRange = { 500, 2500 };
public static int[] MagnesiumDropRange = { 500, 2500 };
public static int[] SiliconDropRange = { 500, 2500 };
public static int[] SilverDropRange = { 500, 2500 };
public static int[] GoldDropRange = { 500, 2500 };
public static int[] PlatinumDropRange = { 500, 2500 };
public static int[] UraniniteDropRange = { 500, 2500 };

public static SpawnableArea[] ValidSpawnLocations =
{
new SpawnableArea
Expand Down Expand Up @@ -447,6 +459,7 @@ namespace DynamicAsteroids
using System.IO;
using Sandbox.Definitions;
using Sandbox.Engine.Physics;
using Sandbox.Game;
using Sandbox.Game.Entities;
using Sandbox.ModAPI;
using SC.SUGMA;
Expand Down Expand Up @@ -518,6 +531,14 @@ namespace DynamicAsteroids.AsteroidEntities
private static readonly string[] PlatinumAsteroidModels = { @"Models\OreAsteroid_Platinum.mwm" };
private static readonly string[] UraniniteAsteroidModels = { @"Models\OreAsteroid_Uraninite.mwm" };


private void CreateEffects(Vector3D position)
{
MyVisualScriptLogicProvider.CreateParticleEffectAtPosition("roidbreakparticle1", position);
MyVisualScriptLogicProvider.PlaySingleSoundAtPosition("roidbreak", position);
}


public static AsteroidEntity CreateAsteroid(Vector3D position, float size, Vector3D initialVelocity, AsteroidType type)
{
var ent = new AsteroidEntity();
Expand All @@ -539,13 +560,16 @@ namespace DynamicAsteroids.AsteroidEntities

float newSize = Size / splits;

CreateEffects(PositionComp.GetPosition());

if (newSize <= AsteroidSettings.MinSubChunkSize)
{
MyPhysicalItemDefinition item = MyDefinitionManager.Static.GetPhysicalItemDefinition(new MyDefinitionId(typeof(MyObjectBuilder_Ore), Type.ToString()));
var newObject = MyObjectBuilderSerializer.CreateNewObject(item.Id.TypeId, item.Id.SubtypeId.ToString()) as MyObjectBuilder_PhysicalObject;
for (int i = 0; i < splits; i++)
{
MyFloatingObjects.Spawn(new MyPhysicalInventoryItem(1000, newObject), PositionComp.GetPosition() + RandVector() * Size, Vector3D.Forward, Vector3D.Up, Physics);
int dropAmount = GetRandomDropAmount(Type);
MyFloatingObjects.Spawn(new MyPhysicalInventoryItem(dropAmount, newObject), PositionComp.GetPosition() + RandVector() * Size, Vector3D.Forward, Vector3D.Up, Physics);
}

// Send a removal message before closing
Expand Down Expand Up @@ -589,6 +613,38 @@ namespace DynamicAsteroids.AsteroidEntities
Close();
}


private int GetRandomDropAmount(AsteroidType type)
{
switch (type)
{
case AsteroidType.Ice:
return MainSession.I.Rand.Next(AsteroidSettings.IceDropRange[0], AsteroidSettings.IceDropRange[1]);
case AsteroidType.Stone:
return MainSession.I.Rand.Next(AsteroidSettings.StoneDropRange[0], AsteroidSettings.StoneDropRange[1]);
case AsteroidType.Iron:
return MainSession.I.Rand.Next(AsteroidSettings.IronDropRange[0], AsteroidSettings.IronDropRange[1]);
case AsteroidType.Nickel:
return MainSession.I.Rand.Next(AsteroidSettings.NickelDropRange[0], AsteroidSettings.NickelDropRange[1]);
case AsteroidType.Cobalt:
return MainSession.I.Rand.Next(AsteroidSettings.CobaltDropRange[0], AsteroidSettings.CobaltDropRange[1]);
case AsteroidType.Magnesium:
return MainSession.I.Rand.Next(AsteroidSettings.MagnesiumDropRange[0], AsteroidSettings.MagnesiumDropRange[1]);
case AsteroidType.Silicon:
return MainSession.I.Rand.Next(AsteroidSettings.SiliconDropRange[0], AsteroidSettings.SiliconDropRange[1]);
case AsteroidType.Silver:
return MainSession.I.Rand.Next(AsteroidSettings.SilverDropRange[0], AsteroidSettings.SilverDropRange[1]);
case AsteroidType.Gold:
return MainSession.I.Rand.Next(AsteroidSettings.GoldDropRange[0], AsteroidSettings.GoldDropRange[1]);
case AsteroidType.Platinum:
return MainSession.I.Rand.Next(AsteroidSettings.PlatinumDropRange[0], AsteroidSettings.PlatinumDropRange[1]);
case AsteroidType.Uraninite:
return MainSession.I.Rand.Next(AsteroidSettings.UraniniteDropRange[0], AsteroidSettings.UraniniteDropRange[1]);
default:
return 0;
}
}

public void OnDestroy()
{
SplitAsteroid();
Expand Down

0 comments on commit e0b3ebc

Please sign in to comment.