mirror of
https://github.com/Facepunch/sbox-public.git
synced 2026-04-19 05:48:07 -04:00
This commit imports the C# engine code and game files, excluding C++ source code. [Source-Commit: ceb3d758046e50faa6258bc3b658a30c97743268]
81 lines
1.1 KiB
C#
81 lines
1.1 KiB
C#
namespace Editor;
|
|
|
|
class SceneSelectionMode
|
|
{
|
|
public Scene Scene { get; }
|
|
public SelectionSystem Selection { get; }
|
|
|
|
public Ray FirstRay { get; private set; }
|
|
public Ray Ray { get; private set; }
|
|
|
|
int calls = 0;
|
|
|
|
Ray previousRay;
|
|
|
|
public SceneSelectionMode( Scene scene, SelectionSystem selection )
|
|
{
|
|
Scene = scene;
|
|
Selection = selection;
|
|
}
|
|
|
|
internal void Finish( Ray currentRay )
|
|
{
|
|
Ray = currentRay;
|
|
OnDisabled();
|
|
}
|
|
|
|
internal void Think( Ray currentRay )
|
|
{
|
|
Ray = currentRay;
|
|
|
|
calls++;
|
|
|
|
if ( calls == 1 )
|
|
{
|
|
FirstRay = Ray;
|
|
OnEnabled();
|
|
}
|
|
|
|
if ( previousRay != currentRay )
|
|
{
|
|
OnMouseMoved();
|
|
}
|
|
|
|
OnUpdate();
|
|
|
|
previousRay = Ray;
|
|
}
|
|
|
|
/// <summary>
|
|
/// Called at start
|
|
/// </summary>
|
|
public virtual void OnEnabled()
|
|
{
|
|
|
|
}
|
|
|
|
/// <summary>
|
|
/// The mouse has moved, update the selection
|
|
/// </summary>
|
|
public virtual void OnMouseMoved()
|
|
{
|
|
|
|
}
|
|
|
|
/// <summary>
|
|
/// Called every frame
|
|
/// </summary>
|
|
public virtual void OnUpdate()
|
|
{
|
|
|
|
}
|
|
|
|
/// <summary>
|
|
/// Called when disabled
|
|
/// </summary>
|
|
public virtual void OnDisabled()
|
|
{
|
|
|
|
}
|
|
}
|