Line endings: LF everywhere
.gitattributes forces LF (CRLF only for .bat/.cmd), core.autocrlf is off; files that differed only by CRLF are normalized.
This commit is contained in:
1 parent
bd7b472dff
commit
8d3f7445f3
6 files changed
+884
-854
No files matched your search
@@ -0,0 +1,30 @@
|
|||||||
|
# Line endings: LF everywhere, on every OS, whatever core.autocrlf says.
|
||||||
|
* text=auto eol=lf
|
||||||
|
|
||||||
|
# cmd.exe misreads labels and goto in LF batch files, so they stay CRLF.
|
||||||
|
*.bat text eol=crlf
|
||||||
|
*.cmd text eol=crlf
|
||||||
|
|
||||||
|
# Binaries: never converted, never diffed as text.
|
||||||
|
*.png binary
|
||||||
|
*.jpg binary
|
||||||
|
*.jpeg binary
|
||||||
|
*.webp binary
|
||||||
|
*.svg text
|
||||||
|
*.ogg binary
|
||||||
|
*.wav binary
|
||||||
|
*.mp3 binary
|
||||||
|
*.ttf binary
|
||||||
|
*.otf binary
|
||||||
|
*.woff binary
|
||||||
|
*.woff2 binary
|
||||||
|
*.dll binary
|
||||||
|
*.so binary
|
||||||
|
*.dylib binary
|
||||||
|
*.pdb binary
|
||||||
|
*.exe binary
|
||||||
|
*.zip binary
|
||||||
|
*.pck binary
|
||||||
|
*.moc3 binary
|
||||||
|
*.res binary
|
||||||
|
*.scn binary
|
||||||
+37
-37
@@ -1,37 +1,37 @@
|
|||||||
# Godot 4.x
|
# Godot 4.x
|
||||||
.godot/
|
.godot/
|
||||||
.idea/
|
.idea/
|
||||||
sdk/
|
sdk/
|
||||||
bin/
|
bin/
|
||||||
obj/
|
obj/
|
||||||
|
|
||||||
#ai
|
#ai
|
||||||
.omo/
|
.omo/
|
||||||
.opencode/
|
.opencode/
|
||||||
|
|
||||||
gen/
|
gen/
|
||||||
obj/
|
obj/
|
||||||
bin/
|
bin/
|
||||||
|
|
||||||
*.tres~
|
*.tres~
|
||||||
*.tscn~
|
*.tscn~
|
||||||
|
|
||||||
# GDScript LSP
|
# GDScript LSP
|
||||||
.godot/
|
.godot/
|
||||||
|
|
||||||
# Export
|
# Export
|
||||||
*.exe
|
*.exe
|
||||||
*.dmg
|
*.dmg
|
||||||
*.apk
|
*.apk
|
||||||
*.aab
|
*.aab
|
||||||
*.pck
|
*.pck
|
||||||
*.zip
|
*.zip
|
||||||
*.log
|
*.log
|
||||||
|
|
||||||
# OS
|
# OS
|
||||||
.DS_Store
|
.DS_Store
|
||||||
Thumbs.db
|
Thumbs.db
|
||||||
|
|
||||||
# Editor
|
# Editor
|
||||||
*.import
|
*.import
|
||||||
*.godot.uid
|
*.godot.uid
|
||||||
+146
-146
@@ -1,147 +1,147 @@
|
|||||||
using Cthangover.Core.Scenes;
|
using Cthangover.Core.Scenes;
|
||||||
using Cthangover.Core.Settings;
|
using Cthangover.Core.Settings;
|
||||||
using Cthangover.Core.UI.Tool;
|
using Cthangover.Core.UI.Tool;
|
||||||
using Cthangover.Core.Utils;
|
using Cthangover.Core.Utils;
|
||||||
using Godot;
|
using Godot;
|
||||||
|
|
||||||
using Cthangover.Mods.Interface.Tool;
|
using Cthangover.Mods.Interface.Tool;
|
||||||
namespace Cthangover.Mods.Time
|
namespace Cthangover.Mods.Time
|
||||||
{
|
{
|
||||||
/// <summary>
|
/// <summary>
|
||||||
/// Draggable lamp UI element for the player's portable light source.
|
/// Draggable lamp UI element for the player's portable light source.
|
||||||
/// Input handling exists in both _GuiInput (bubbled) and _Input (global)
|
/// Input handling exists in both _GuiInput (bubbled) and _Input (global)
|
||||||
/// to catch drags that start on the lamp but continue outside its rect.
|
/// to catch drags that start on the lamp but continue outside its rect.
|
||||||
/// When the lamp is hidden, it resets position to offscreen (-1000,-1000)
|
/// When the lamp is hidden, it resets position to offscreen (-1000,-1000)
|
||||||
/// to disable the light in the shader. GetLightParams() is a static helper
|
/// to disable the light in the shader. GetLightParams() is a static helper
|
||||||
/// so the light controller can query lamp parameters without coupling to
|
/// so the light controller can query lamp parameters without coupling to
|
||||||
/// the behaviour instance. Inherits from TextureRectModIconLoader for
|
/// the behaviour instance. Inherits from TextureRectModIconLoader for
|
||||||
/// mod-provided lamp icon textures.
|
/// mod-provided lamp icon textures.
|
||||||
/// </summary>
|
/// </summary>
|
||||||
public partial class LampBehaviour : TextureRectModIconLoader
|
public partial class LampBehaviour : TextureRectModIconLoader
|
||||||
{
|
{
|
||||||
private UiLightController controller;
|
private UiLightController controller;
|
||||||
private Vector2 dragPosition;
|
private Vector2 dragPosition;
|
||||||
private bool isPlaced;
|
private bool isPlaced;
|
||||||
|
|
||||||
private bool pressingOnLamp;
|
private bool pressingOnLamp;
|
||||||
|
|
||||||
/// <summary>
|
/// <summary>
|
||||||
/// Queries lamp parameters (color, radius, influence) from
|
/// Queries lamp parameters (color, radius, influence) from
|
||||||
/// <see cref="GameData.Instance.Runtime.LampData"/>. Static so the
|
/// <see cref="GameData.Instance.Runtime.LampData"/>. Static so the
|
||||||
/// <see cref="UiLightController"/> can query without a direct reference.
|
/// <see cref="UiLightController"/> can query without a direct reference.
|
||||||
/// </summary>
|
/// </summary>
|
||||||
public static (Color, float, float) GetLightParams()
|
public static (Color, float, float) GetLightParams()
|
||||||
{
|
{
|
||||||
var lampData = GameData.Instance.Runtime.LampData;
|
var lampData = GameData.Instance.Runtime.LampData;
|
||||||
var radius = lampData.Radius;
|
var radius = lampData.Radius;
|
||||||
var influence = lampData.Influence;
|
var influence = lampData.Influence;
|
||||||
return (Colors.Yellow, radius, influence);
|
return (Colors.Yellow, radius, influence);
|
||||||
}
|
}
|
||||||
|
|
||||||
/// <summary>
|
/// <summary>
|
||||||
/// Visibility toggle for the lamp. Setting to <c>false</c> resets the
|
/// Visibility toggle for the lamp. Setting to <c>false</c> resets the
|
||||||
/// placed state and sends the light position offscreen to disable
|
/// placed state and sends the light position offscreen to disable
|
||||||
/// the lamp light in the shader. Uses <c>new</c> to log transitions.
|
/// the lamp light in the shader. Uses <c>new</c> to log transitions.
|
||||||
/// </summary>
|
/// </summary>
|
||||||
public new bool Visible
|
public new bool Visible
|
||||||
{
|
{
|
||||||
get => base.Visible;
|
get => base.Visible;
|
||||||
set
|
set
|
||||||
{
|
{
|
||||||
if (base.Visible != value)
|
if (base.Visible != value)
|
||||||
GameLogger.Log("LIGHT", $"Lamp.Visible: {base.Visible} -> {value}, isPlaced={isPlaced}", LogLevel.Debug);
|
GameLogger.Log("LIGHT", $"Lamp.Visible: {base.Visible} -> {value}, isPlaced={isPlaced}", LogLevel.Debug);
|
||||||
base.Visible = value;
|
base.Visible = value;
|
||||||
if (!value)
|
if (!value)
|
||||||
{
|
{
|
||||||
pressingOnLamp = false;
|
pressingOnLamp = false;
|
||||||
if (isPlaced)
|
if (isPlaced)
|
||||||
{
|
{
|
||||||
isPlaced = false;
|
isPlaced = false;
|
||||||
controller?.UpdateLightPos(new Vector2(-1000f, -1000f));
|
controller?.UpdateLightPos(new Vector2(-1000f, -1000f));
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
/// <summary>Finds the shared <see cref="UiLightController"/> this lamp pushes positions to.</summary>
|
/// <summary>Finds the shared <see cref="UiLightController"/> this lamp pushes positions to.</summary>
|
||||||
public override void _Ready()
|
public override void _Ready()
|
||||||
{
|
{
|
||||||
base._Ready();
|
base._Ready();
|
||||||
MouseFilter = MouseFilterEnum.Stop;
|
MouseFilter = MouseFilterEnum.Stop;
|
||||||
controller = SceneContextNode.FindNode<UiLightController>("Lights");
|
controller = SceneContextNode.FindNode<UiLightController>("Lights");
|
||||||
GameLogger.Log("LIGHT", $"Lamp._Ready: controller={(controller != null ? "OK" : "NULL")}", LogLevel.Debug);
|
GameLogger.Log("LIGHT", $"Lamp._Ready: controller={(controller != null ? "OK" : "NULL")}", LogLevel.Debug);
|
||||||
}
|
}
|
||||||
|
|
||||||
/// <summary>Click to place the light at the cursor, drag to move it, and click a placed lamp to pick it back up.</summary>
|
/// <summary>Click to place the light at the cursor, drag to move it, and click a placed lamp to pick it back up.</summary>
|
||||||
public override void _GuiInput(InputEvent @event)
|
public override void _GuiInput(InputEvent @event)
|
||||||
{
|
{
|
||||||
if (@event is InputEventMouseButton mouseButton)
|
if (@event is InputEventMouseButton mouseButton)
|
||||||
{
|
{
|
||||||
if (mouseButton.ButtonIndex == MouseButton.Left)
|
if (mouseButton.ButtonIndex == MouseButton.Left)
|
||||||
{
|
{
|
||||||
if (mouseButton.Pressed)
|
if (mouseButton.Pressed)
|
||||||
{
|
{
|
||||||
pressingOnLamp = true;
|
pressingOnLamp = true;
|
||||||
dragPosition = GetGlobalMousePosition();
|
dragPosition = GetGlobalMousePosition();
|
||||||
|
|
||||||
if (isPlaced)
|
if (isPlaced)
|
||||||
{
|
{
|
||||||
dragPosition = new Vector2(-1000f, -1000f);
|
dragPosition = new Vector2(-1000f, -1000f);
|
||||||
controller?.UpdateLightPos(dragPosition);
|
controller?.UpdateLightPos(dragPosition);
|
||||||
isPlaced = false;
|
isPlaced = false;
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
else
|
else
|
||||||
{
|
{
|
||||||
if (pressingOnLamp && !isPlaced)
|
if (pressingOnLamp && !isPlaced)
|
||||||
{
|
{
|
||||||
isPlaced = true;
|
isPlaced = true;
|
||||||
controller?.UpdateLightPos(dragPosition);
|
controller?.UpdateLightPos(dragPosition);
|
||||||
}
|
}
|
||||||
pressingOnLamp = false;
|
pressingOnLamp = false;
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
AcceptEvent();
|
AcceptEvent();
|
||||||
}
|
}
|
||||||
else if (@event is InputEventMouseMotion mouseMotion)
|
else if (@event is InputEventMouseMotion mouseMotion)
|
||||||
{
|
{
|
||||||
if (Input.IsMouseButtonPressed(MouseButton.Left))
|
if (Input.IsMouseButtonPressed(MouseButton.Left))
|
||||||
{
|
{
|
||||||
dragPosition = GetGlobalMousePosition();
|
dragPosition = GetGlobalMousePosition();
|
||||||
controller?.UpdateLightPos(dragPosition);
|
controller?.UpdateLightPos(dragPosition);
|
||||||
isPlaced = false;
|
isPlaced = false;
|
||||||
AcceptEvent();
|
AcceptEvent();
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
/// <summary>Keeps dragging the placed light while the pointer moves outside the lamp's own control rect.</summary>
|
/// <summary>Keeps dragging the placed light while the pointer moves outside the lamp's own control rect.</summary>
|
||||||
public override void _Input(InputEvent @event)
|
public override void _Input(InputEvent @event)
|
||||||
{
|
{
|
||||||
if (!Visible)
|
if (!Visible)
|
||||||
return;
|
return;
|
||||||
|
|
||||||
if (@event is InputEventMouseMotion mouseMotion
|
if (@event is InputEventMouseMotion mouseMotion
|
||||||
&& Input.IsMouseButtonPressed(MouseButton.Left)
|
&& Input.IsMouseButtonPressed(MouseButton.Left)
|
||||||
&& pressingOnLamp)
|
&& pressingOnLamp)
|
||||||
{
|
{
|
||||||
dragPosition = GetGlobalMousePosition();
|
dragPosition = GetGlobalMousePosition();
|
||||||
controller?.UpdateLightPos(dragPosition);
|
controller?.UpdateLightPos(dragPosition);
|
||||||
isPlaced = false;
|
isPlaced = false;
|
||||||
}
|
}
|
||||||
|
|
||||||
if (@event is InputEventMouseButton mouseButton
|
if (@event is InputEventMouseButton mouseButton
|
||||||
&& mouseButton.ButtonIndex == MouseButton.Left
|
&& mouseButton.ButtonIndex == MouseButton.Left
|
||||||
&& !mouseButton.Pressed
|
&& !mouseButton.Pressed
|
||||||
&& pressingOnLamp)
|
&& pressingOnLamp)
|
||||||
{
|
{
|
||||||
if (!isPlaced)
|
if (!isPlaced)
|
||||||
{
|
{
|
||||||
isPlaced = true;
|
isPlaced = true;
|
||||||
controller?.UpdateLightPos(dragPosition);
|
controller?.UpdateLightPos(dragPosition);
|
||||||
}
|
}
|
||||||
pressingOnLamp = false;
|
pressingOnLamp = false;
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
+79
-79
@@ -1,79 +1,79 @@
|
|||||||
using System.Text.Json.Serialization;
|
using System.Text.Json.Serialization;
|
||||||
using Godot;
|
using Godot;
|
||||||
|
|
||||||
namespace Cthangover.Mods.Time
|
namespace Cthangover.Mods.Time
|
||||||
{
|
{
|
||||||
/// <summary>
|
/// <summary>
|
||||||
/// Serializable light definition for JSON scene lighting. Coordinates are
|
/// Serializable light definition for JSON scene lighting. Coordinates are
|
||||||
/// viewport-relative (0.0–1.0) so scenes adapt to different resolutions.
|
/// viewport-relative (0.0–1.0) so scenes adapt to different resolutions.
|
||||||
/// ToPixelPos/FromPixelPos convert between normalized space and pixel space
|
/// ToPixelPos/FromPixelPos convert between normalized space and pixel space
|
||||||
/// using a reference viewport size. Color is stored as a hex string for
|
/// using a reference viewport size. Color is stored as a hex string for
|
||||||
/// human-readable JSON editing.
|
/// human-readable JSON editing.
|
||||||
/// </summary>
|
/// </summary>
|
||||||
public class LightDef
|
public class LightDef
|
||||||
{
|
{
|
||||||
/// <summary>
|
/// <summary>
|
||||||
/// Normalized horizontal position (0.0–1.0) relative to viewport width.
|
/// Normalized horizontal position (0.0–1.0) relative to viewport width.
|
||||||
/// </summary>
|
/// </summary>
|
||||||
[JsonPropertyName("x")]
|
[JsonPropertyName("x")]
|
||||||
public float X { get; set; }
|
public float X { get; set; }
|
||||||
|
|
||||||
/// <summary>
|
/// <summary>
|
||||||
/// Normalized vertical position (0.0–1.0) relative to viewport height.
|
/// Normalized vertical position (0.0–1.0) relative to viewport height.
|
||||||
/// </summary>
|
/// </summary>
|
||||||
[JsonPropertyName("y")]
|
[JsonPropertyName("y")]
|
||||||
public float Y { get; set; }
|
public float Y { get; set; }
|
||||||
|
|
||||||
/// <summary>
|
/// <summary>
|
||||||
/// Light radius in pixel units. Determines the falloff distance in the
|
/// Light radius in pixel units. Determines the falloff distance in the
|
||||||
/// lighting shader.
|
/// lighting shader.
|
||||||
/// </summary>
|
/// </summary>
|
||||||
[JsonPropertyName("radius")]
|
[JsonPropertyName("radius")]
|
||||||
public float Radius { get; set; }
|
public float Radius { get; set; }
|
||||||
|
|
||||||
/// <summary>
|
/// <summary>
|
||||||
/// Light intensity (0.0–1.0). At <c>1.0</c>, the light fully brightens
|
/// Light intensity (0.0–1.0). At <c>1.0</c>, the light fully brightens
|
||||||
/// pixels within its radius. Lower values create subtler effects.
|
/// pixels within its radius. Lower values create subtler effects.
|
||||||
/// </summary>
|
/// </summary>
|
||||||
[JsonPropertyName("influence")]
|
[JsonPropertyName("influence")]
|
||||||
public float Influence { get; set; } = 1f;
|
public float Influence { get; set; } = 1f;
|
||||||
|
|
||||||
/// <summary>
|
/// <summary>
|
||||||
/// Light color as a hex string (e.g. "#ff8800"). Parsed by
|
/// Light color as a hex string (e.g. "#ff8800"). Parsed by
|
||||||
/// <see cref="ToColor"/> for shader upload.
|
/// <see cref="ToColor"/> for shader upload.
|
||||||
/// </summary>
|
/// </summary>
|
||||||
[JsonPropertyName("color")]
|
[JsonPropertyName("color")]
|
||||||
public string ColorHex { get; set; } = "#ffff00";
|
public string ColorHex { get; set; } = "#ffff00";
|
||||||
|
|
||||||
/// <summary>
|
/// <summary>
|
||||||
/// Converts <see cref="ColorHex"/> to a Godot <c>Color</c> struct.
|
/// Converts <see cref="ColorHex"/> to a Godot <c>Color</c> struct.
|
||||||
/// </summary>
|
/// </summary>
|
||||||
public Color ToColor()
|
public Color ToColor()
|
||||||
{
|
{
|
||||||
return new Color(ColorHex);
|
return new Color(ColorHex);
|
||||||
}
|
}
|
||||||
|
|
||||||
/// <summary>
|
/// <summary>
|
||||||
/// Converts normalized coordinates (<see cref="X"/>, <see cref="Y"/>) to
|
/// Converts normalized coordinates (<see cref="X"/>, <see cref="Y"/>) to
|
||||||
/// pixel coordinates based on <paramref name="viewportSize"/>.
|
/// pixel coordinates based on <paramref name="viewportSize"/>.
|
||||||
/// </summary>
|
/// </summary>
|
||||||
/// <param name="viewportSize">Current viewport dimensions in pixels.</param>
|
/// <param name="viewportSize">Current viewport dimensions in pixels.</param>
|
||||||
public Vector2 ToPixelPos(Vector2 viewportSize)
|
public Vector2 ToPixelPos(Vector2 viewportSize)
|
||||||
{
|
{
|
||||||
return new Vector2(X * viewportSize.X, Y * viewportSize.Y);
|
return new Vector2(X * viewportSize.X, Y * viewportSize.Y);
|
||||||
}
|
}
|
||||||
|
|
||||||
/// <summary>
|
/// <summary>
|
||||||
/// Computes normalized coordinates from pixel coordinates by dividing by
|
/// Computes normalized coordinates from pixel coordinates by dividing by
|
||||||
/// <paramref name="referenceSize"/>. Enables saving light positions
|
/// <paramref name="referenceSize"/>. Enables saving light positions
|
||||||
/// across different resolutions.
|
/// across different resolutions.
|
||||||
/// </summary>
|
/// </summary>
|
||||||
/// <param name="pixelPos">Light position in pixel space.</param>
|
/// <param name="pixelPos">Light position in pixel space.</param>
|
||||||
/// <param name="referenceSize">Viewport dimensions used as reference.</param>
|
/// <param name="referenceSize">Viewport dimensions used as reference.</param>
|
||||||
public void FromPixelPos(Vector2 pixelPos, Vector2 referenceSize)
|
public void FromPixelPos(Vector2 pixelPos, Vector2 referenceSize)
|
||||||
{
|
{
|
||||||
X = pixelPos.X / referenceSize.X;
|
X = pixelPos.X / referenceSize.X;
|
||||||
Y = pixelPos.Y / referenceSize.Y;
|
Y = pixelPos.Y / referenceSize.Y;
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
+519
-519
File diff suppressed because it is too large.
Load diff
+73
-73
@@ -1,73 +1,73 @@
|
|||||||
using Cthangover.Core.Bootstrap;
|
using Cthangover.Core.Bootstrap;
|
||||||
using Cthangover.Core.Settings;
|
using Cthangover.Core.Settings;
|
||||||
using Cthangover.Core.Events;
|
using Cthangover.Core.Events;
|
||||||
using Cthangover.Core.Mods;
|
using Cthangover.Core.Mods;
|
||||||
using Cthangover.Core.UI.Event;
|
using Cthangover.Core.UI.Event;
|
||||||
using Godot;
|
using Godot;
|
||||||
|
|
||||||
namespace Cthangover.Mods.Time
|
namespace Cthangover.Mods.Time
|
||||||
{
|
{
|
||||||
/// <summary>
|
/// <summary>
|
||||||
/// Bridges the scene-event timer system to the in-game clock.
|
/// Bridges the scene-event timer system to the in-game clock.
|
||||||
/// Implements <see cref="Cthangover.Core.UI.Event.IOnTimeEvent"/>
|
/// Implements <see cref="Cthangover.Core.UI.Event.IOnTimeEvent"/>
|
||||||
/// with priority 0 so that the tick is processed before most
|
/// with priority 0 so that the tick is processed before most
|
||||||
/// other listeners. The controller must be explicitly registered
|
/// other listeners. The controller must be explicitly registered
|
||||||
/// via <see cref="EnsureRegistered"/>, which finds the
|
/// via <see cref="EnsureRegistered"/>, which finds the
|
||||||
/// <see cref="Cthangover.Core.UI.Event.SceneEventController"/> in
|
/// <see cref="Cthangover.Core.UI.Event.SceneEventController"/> in
|
||||||
/// the scene tree and subscribes <see cref="OnTimerTick"/> to it.
|
/// the scene tree and subscribes <see cref="OnTimerTick"/> to it.
|
||||||
/// Registration is idempotent — subsequent calls are no-ops.
|
/// Registration is idempotent — subsequent calls are no-ops.
|
||||||
/// </summary>
|
/// </summary>
|
||||||
public class TimeTickController : IOnTimeEvent
|
public class TimeTickController : IOnTimeEvent
|
||||||
{
|
{
|
||||||
/// <summary>Executes before default-priority listeners so time
|
/// <summary>Executes before default-priority listeners so time
|
||||||
/// updates are visible to all other tick handlers.</summary>
|
/// updates are visible to all other tick handlers.</summary>
|
||||||
public int Priority => 0;
|
public int Priority => 0;
|
||||||
|
|
||||||
private bool _registered;
|
private bool _registered;
|
||||||
|
|
||||||
/// <summary>
|
/// <summary>
|
||||||
/// Locates the <see cref="Cthangover.Core.UI.Event.SceneEventController"/>
|
/// Locates the <see cref="Cthangover.Core.UI.Event.SceneEventController"/>
|
||||||
/// in the scene tree and registers this controller as a timer-tick
|
/// in the scene tree and registers this controller as a timer-tick
|
||||||
/// listener. Safe to call multiple times — only the first call
|
/// listener. Safe to call multiple times — only the first call
|
||||||
/// does work.
|
/// does work.
|
||||||
/// </summary>
|
/// </summary>
|
||||||
public void EnsureRegistered(Node node)
|
public void EnsureRegistered(Node node)
|
||||||
{
|
{
|
||||||
if (_registered)
|
if (_registered)
|
||||||
return;
|
return;
|
||||||
var eventController = node.GetTree()?.Root?.FindChild("EventController", true, false) as SceneEventController;
|
var eventController = node.GetTree()?.Root?.FindChild("EventController", true, false) as SceneEventController;
|
||||||
if (eventController == null)
|
if (eventController == null)
|
||||||
return;
|
return;
|
||||||
eventController.AddTimerTickEventListener(this);
|
eventController.AddTimerTickEventListener(this);
|
||||||
_registered = true;
|
_registered = true;
|
||||||
}
|
}
|
||||||
|
|
||||||
/// <summary>
|
/// <summary>
|
||||||
/// Called by the event system on each timer pulse. Advances
|
/// Called by the event system on each timer pulse. Advances
|
||||||
/// the in-game clock by one minute via
|
/// the in-game clock by one minute via
|
||||||
/// <see cref="TimeData.AddTick"/>.
|
/// <see cref="TimeData.AddTick"/>.
|
||||||
/// </summary>
|
/// </summary>
|
||||||
public void OnTimerTick()
|
public void OnTimerTick()
|
||||||
{
|
{
|
||||||
// The SceneEventController keeps ticking (1s interval, ProcessMode
|
// The SceneEventController keeps ticking (1s interval, ProcessMode
|
||||||
// Always) while the launcher boot compiles mods in the background —
|
// Always) while the launcher boot compiles mods in the background —
|
||||||
// registration in GameData._Ready succeeds because the engine puts
|
// registration in GameData._Ready succeeds because the engine puts
|
||||||
// every autoload into the tree before any _Ready fires. Touching
|
// every autoload into the tree before any _Ready fires. Touching
|
||||||
// Runtime here would create it before the starter inventory can be
|
// Runtime here would create it before the starter inventory can be
|
||||||
// seeded through loaded mod factories: the seed then runs against an
|
// seeded through loaded mod factories: the seed then runs against an
|
||||||
// empty registry, logs "Initialize refused" spam and permanently
|
// empty registry, logs "Initialize refused" spam and permanently
|
||||||
// skips the starter items. Skip boot-window ticks instead — the same
|
// skips the starter items. Skip boot-window ticks instead — the same
|
||||||
// readiness contract GameData.Runtime enforces.
|
// readiness contract GameData.Runtime enforces.
|
||||||
if (!Boot.ModsReady)
|
if (!Boot.ModsReady)
|
||||||
return;
|
return;
|
||||||
|
|
||||||
GameData.Instance.Runtime.Time.AddTick();
|
GameData.Instance.Runtime.Time.AddTick();
|
||||||
ModEventBus.Publish(new TimeTickEvent
|
ModEventBus.Publish(new TimeTickEvent
|
||||||
{
|
{
|
||||||
TimeTick = GameData.Instance.Runtime.Time.Tick,
|
TimeTick = GameData.Instance.Runtime.Time.Tick,
|
||||||
NormalizedTime = GameData.Instance.Runtime.Time.Normalized,
|
NormalizedTime = GameData.Instance.Runtime.Time.Normalized,
|
||||||
});
|
});
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
}
|
}
|
||||||
Reference in new issue
Block a user