private void OnGameTick(float dt) { if (burning) { if (fuelLevel > 0) { fuelLevel = Math.Max(0, fuelLevel - 0.0001f); } if (fuelLevel <= 0) { burning = false; } if (contents != null) { float temp = contents.Collectible.GetTemperature(api.World, contents); if (temp < 1100) { contents.Collectible.SetTemperature(api.World, contents, temp + 2); } } } if (renderer != null) { renderer.SetContents(contents, fuelLevel, burning, false); } }
internal void TryIgnite() { if (burning) { return; } burning = true; renderer?.SetContents(contents, fuelLevel, burning, false); MarkDirty(); }
internal void TryIgnite() { if (burning) { return; } burning = true; renderer?.SetContents(contents, fuelLevel, burning, false); lastTickTotalHours = Api.World.Calendar.TotalHours; MarkDirty(); }
private void OnClientTick(float dt) { if (Api?.Side == EnumAppSide.Client && clientSidePrevBurning != burning) { ToggleAmbientSounds(IsBurning); clientSidePrevBurning = IsBurning; } if (burning && Api.World.Rand.NextDouble() < 0.13) { smokeParticles.MinPos.Set(Pos.X + 4 / 16f, Pos.Y + 14 / 16f, Pos.Z + 4 / 16f); int g = 50 + Api.World.Rand.Next(50); smokeParticles.Color = ColorUtil.ToRgba(150, g, g, g); Api.World.SpawnParticles(smokeParticles); } if (renderer != null) { renderer.SetContents(contents, fuelLevel, burning, false); } }
private void OnGameTick(float dt) { if (burning) { if (api.Side == EnumAppSide.Client && api.World.Rand.NextDouble() < 0.1) { smokeParticles.minPos.Set(pos.X + 4 / 16f, pos.Y + 14 / 16f, pos.Z + 4 / 16f); int g = 50 + api.World.Rand.Next(50); smokeParticles.color = ColorUtil.ToRgba(150, g, g, g); api.World.SpawnParticles(smokeParticles); } if (fuelLevel > 0) { fuelLevel = Math.Max(0, fuelLevel - 0.0001f); } if (fuelLevel <= 0) { burning = false; } if (contents != null) { float temp = contents.Collectible.GetTemperature(api.World, contents); if (temp < 1100) { float tempGain = (float)(api.World.Calendar.TotalHours - lastHeatTotalHours) * 1500; contents.Collectible.SetTemperature(api.World, contents, temp + tempGain); } } } if (renderer != null) { renderer.SetContents(contents, fuelLevel, burning, false); } lastHeatTotalHours = api.World.Calendar.TotalHours; }
public override void Initialize(ICoreAPI api) { base.Initialize(api); if (contents != null) { contents.ResolveBlockOrItem(api.World); } if (api is ICoreClientAPI) { ICoreClientAPI capi = (ICoreClientAPI)api; capi.Event.RegisterRenderer(renderer = new ForgeContentsRenderer(pos, capi), EnumRenderStage.Opaque); renderer.SetContents(contents, fuelLevel, burning, true); } api.Event.RegisterGameTickListener(OnGameTick, 50); }
public override void Initialize(ICoreAPI api) { base.Initialize(api); if (contents != null) { contents.ResolveBlockOrItem(api.World); } if (api is ICoreClientAPI) { ICoreClientAPI capi = (ICoreClientAPI)api; capi.Event.RegisterRenderer(renderer = new ForgeContentsRenderer(Pos, capi), EnumRenderStage.Opaque, "forge"); renderer.SetContents(contents, fuelLevel, burning, true); RegisterGameTickListener(OnClientTick, 50); } wsys = api.ModLoader.GetModSystem <WeatherSystemBase>(); RegisterGameTickListener(OnCommonTick, 200); }