public static ChunkSpawner MakeChunkSpawner(ChunkConfiguration chunkType, CompoundCloudSystem cloudSystem) { foreach (var mesh in chunkType.Meshes) { if (mesh.LoadedScene == null) { throw new ArgumentException("configured chunk spawner has a mesh that has no scene loaded"); } } return(new ChunkSpawner(chunkType, cloudSystem)); }
private KeyValuePair <ChunkConfiguration, Task <Stream> > CreateKeyValuePair(ChunkConfiguration chunkConfiguration, Task <Stream> chunkDataStream) { if (chunkConfiguration == null) { throw new ArgumentNullException("chunkConfiguration"); } if (chunkDataStream == null) { throw new ArgumentNullException("chunkDataStream"); } return(new KeyValuePair <ChunkConfiguration, Task <Stream> >(chunkConfiguration, chunkDataStream)); }
/// <summary> /// Grabs data from the type to initialize this /// </summary> /// <remarks> /// <para> /// Doesn't initialize the graphics scene which needs to be set separately /// </para> /// </remarks> public void Init(ChunkConfiguration chunkType, CompoundCloudSystem compoundClouds, string modelPath) { this.compoundClouds = compoundClouds; // Grab data VentPerSecond = chunkType.VentAmount; Dissolves = chunkType.Dissolves; Size = chunkType.Size; Damages = chunkType.Damages; DeleteOnTouch = chunkType.DeleteOnTouch; Mass = chunkType.Mass; // These are stored for saves to work Radius = chunkType.Radius; ChunkScale = chunkType.ChunkScale; ModelNodePath = modelPath; // Apply physics shape var shape = GetNode <CollisionShape>("CollisionShape"); // This only works as long as the sphere shape type is not changed in the editor ((SphereShape)shape.Shape).Radius = chunkType.Radius; // Copy compounds to vent if (chunkType.Compounds != null && chunkType.Compounds.Count > 0) { // Capacity is set to 0 so that no compounds can be added // the normal way to the chunk ContainedCompounds = new CompoundBag(0); foreach (var entry in chunkType.Compounds) { ContainedCompounds.Compounds.Add(entry.Key, entry.Value.Amount); } } // Needs physics callback when this is engulfable or damaging if (Damages > 0 || DeleteOnTouch || Size > 0) { ContactsReported = Constants.DEFAULT_STORE_CONTACTS_COUNT; Connect("body_shape_entered", this, "OnContactBegin"); Connect("body_shape_exited", this, "OnContactEnd"); } }
public void CanWriteData() { GameObject obj = new GameObject(); obj.AddComponent <MeshRenderer>(); obj.AddComponent <MeshCollider>(); obj.AddComponent <MeshFilter>(); Chunk chunk = obj.AddComponent <Chunk>(); ChunkConfiguration config = ScriptableObject .CreateInstance("ChunkConfiguration") as ChunkConfiguration; chunk.configuration = config; chunk.Initialize(); chunk.Write(Vector3Int.zero, 10); Assert.AreEqual(10, chunk.Read(Vector3Int.zero)); chunk.Dispose(); }
public BulkTask CreateTask(string taskName) { Check.NotEmpty(taskName, nameof(taskName)); var connectionString = _taskConfigurationObject.GetConfigurationValue <string>("connectionString"); var query = _taskConfigurationObject.GetConfigurationValue <string>("query"); var host = _taskConfigurationObject.GetConfigurationValue <string>("host"); var port = _taskConfigurationObject.GetConfigurationValue <int>("port"); var source = new SqlServerQuery(connectionString, query); var bulkTaskConfiguration = new BulkTaskConfiguration(taskName, host, port) { IndexName = IndexTemplate, TypeName = Type }; var chunkConfiguration = new ChunkConfiguration() { ChunkSize = ChunkSize }; return(new BulkTask(bulkTaskConfiguration, chunkConfiguration, source, _logger)); }
public static FloatingChunk SpawnChunk(ChunkConfiguration chunkType, Vector3 location, Node worldNode, PackedScene chunkScene, CompoundCloudSystem cloudSystem, Random random) { var chunk = (FloatingChunk)chunkScene.Instance(); // Settings need to be applied before adding it to the scene var selectedMesh = chunkType.Meshes.Random(random); chunk.GraphicsScene = selectedMesh.LoadedScene ?? throw new Exception("Chunk scene has not been loaded even though it should be loaded here"); chunk.ConvexPhysicsMesh = selectedMesh.LoadedConvexShape; if (chunk.GraphicsScene == null) { throw new ArgumentException("couldn't find a graphics scene for a chunk"); } // Pass on the chunk data chunk.Init(chunkType, cloudSystem, selectedMesh.SceneModelPath); chunk.UsesDespawnTimer = !chunkType.Dissolves; worldNode.AddChild(chunk); // Chunk is spawned with random rotation chunk.Transform = new Transform(new Quat( new Vector3(0, 1, 1).Normalized(), 2 * Mathf.Pi * (float)random.NextDouble()), location); chunk.GetNode <Spatial>("NodeToScale").Scale = new Vector3(chunkType.ChunkScale, chunkType.ChunkScale, chunkType.ChunkScale); chunk.AddToGroup(Constants.FLUID_EFFECT_GROUP); chunk.AddToGroup(Constants.AI_TAG_CHUNK); return(chunk); }
public ChunkSpawner(ChunkConfiguration chunkType, CompoundCloudSystem cloudSystem) { this.chunkType = chunkType; this.cloudSystem = cloudSystem; chunkScene = SpawnHelpers.LoadChunkScene(); }
public ISpawned Spawn(Vector3 location, ChunkConfiguration chunkType, Node worldNode) { return(Spawn(chunkType, location, worldNode, chunkScene, cloudSystem, random)); }
public ChunkItem(ChunkConfiguration chunkType, ChunkSpawner chunkSpawner) { this.chunkType = chunkType; ChunkSpawner = chunkSpawner; }
private KeyValuePair <ChunkConfiguration, Task <Stream> > CreateKeyValuePair(ChunkConfiguration chunkConfiguration, Stream chunkDataStream) { return(CreateKeyValuePair(chunkConfiguration, Task.FromResult(chunkDataStream))); }
public void Append(ChunkConfiguration chunkConfiguration, Stream chunkDataStream) { _chunks.Add(CreateKeyValuePair(chunkConfiguration, chunkDataStream)); }
public void InsertAt(int index, ChunkConfiguration chunkConfiguration, Task <Stream> chunkDataStream) { _chunks.Insert(index, CreateKeyValuePair(chunkConfiguration, chunkDataStream)); }
public void Prepend(ChunkConfiguration chunkConfiguration, Task <Stream> chunkDataStream) { InsertAt(0, chunkConfiguration, chunkDataStream); }