Page 1 of 1

Scripting 16 - Fire

Posted: Sun Aug 11, 2019 1:14 pm
by Gurt
Scripting 16 - Fire

Scripting in SFD assumes you have a fair knowledge of C#.

The following code demonstrates how to read and remove fire. Available in v.1.3.1.

This is a limited instruction set. All you can do is to read a limited set of data from current fire nodes and remove individual fire nodes in the game. The fire system is old and this is what can easily be done in the API without refactoring a huge set of code.

Code: Select all

// Example how to create a "no-fire zone" around the middle of the map
public void OnStartup()
{
	Events.UpdateCallback.Start(OnUpdate, 0);
}
	
public void OnUpdate(float ms)
{	
	// No fire zone
	Area area = new Area(new Vector2(-32f, -32f), new Vector2(32f, 32f));
	
	Game.DrawArea(area, Color.Yellow);

	FireNode[] fireNodes = Game.GetFireNodes(area);
	foreach(FireNode fireNode in fireNodes)
	{
		if (fireNode.AttachedToObjectID != 0)
		{
			Game.EndFireNode(fireNode.InstanceID);
		}
	}
	foreach(IObject obj in Game.GetBurningObjects())
	{
		if (area.Contains(obj.GetWorldPosition()))
		{
			obj.ClearFire();
		}
	}
}
ScriptAPI Implementation
► Show Spoiler

Re: Scripting 16 - Fire

Posted: Mon Aug 12, 2019 2:38 am
by NearHuscarl
Since you add FireNode. IGame.SpawnFireNode() and IGame.SpawnFireNodes() should return FireNode and FireNode[] respectively instead of void

Re: Scripting 16 - Fire

Posted: Mon Aug 12, 2019 12:10 pm
by Gurt
NearHuscarl wrote:
Mon Aug 12, 2019 2:38 am
Since you add FireNode. IGame.SpawnFireNode() and IGame.SpawnFireNodes() should return FireNode and FireNode[] respectively instead of void
Good idea! Adding it to the next update.