Scripting 16 - Fire
Posted: Sun Aug 11, 2019 1:14 pm
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.
ScriptAPI Implementation
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();
}
}
}
► Show Spoiler