Skip to content
Merged

Lua #158

Show file tree
Hide file tree
Changes from all commits
Commits
Show all changes
25 commits
Select commit Hold shift + click to select a range
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
16 changes: 8 additions & 8 deletions .vscode/launch.json
Original file line number Diff line number Diff line change
Expand Up @@ -6,17 +6,17 @@
"type": "coreclr",
"request": "launch",
"preLaunchTask": "build Source.Launcher",
"program": "${workspaceFolder}/Build/Source.Launcher.dll",
"cwd": "${workspaceFolder}/Build",
"program": "${workspaceFolder}/Build/Debug/Source.Launcher.dll",
"cwd": "${workspaceFolder}/Build/Debug",
"stopAtEntry": false
},
{
"name": "Source.Launcher (External Terminal)",
"type": "coreclr",
"request": "launch",
"preLaunchTask": "build Source.Launcher",
"program": "${workspaceFolder}/Build/Source.Launcher.dll",
"cwd": "${workspaceFolder}/Build",
"program": "${workspaceFolder}/Build/Debug/Source.Launcher.dll",
"cwd": "${workspaceFolder}/Build/Debug",
"stopAtEntry": false,
"console": "externalTerminal"
},
Expand All @@ -25,8 +25,8 @@
"type": "coreclr",
"request": "launch",
"preLaunchTask": "build Source.Dedicated",
"program": "${workspaceFolder}/Build/Source.Dedicated.dll",
"cwd": "${workspaceFolder}/Build",
"program": "${workspaceFolder}/Build/Debug (Dedicated)/Source.Dedicated.dll",
"cwd": "${workspaceFolder}/Build/Debug (Dedicated)",
"args": ["-maxplayers", "2", "+map", "gm_flatgrass"],
"stopAtEntry": false
},
Expand All @@ -35,8 +35,8 @@
"type": "coreclr",
"request": "launch",
"preLaunchTask": "build Source.Dedicated",
"program": "${workspaceFolder}/Build/Source.Dedicated.dll",
"cwd": "${workspaceFolder}/Build",
"program": "${workspaceFolder}/Build/Debug (Dedicated)/Source.Dedicated.dll",
"cwd": "${workspaceFolder}/Build/Debug (Dedicated)",
"args": ["-maxplayers", "2", "+map", "gm_flatgrass"],
"stopAtEntry": false,
"console": "externalTerminal"
Expand Down
2 changes: 2 additions & 0 deletions .vscode/tasks.json
Original file line number Diff line number Diff line change
Expand Up @@ -7,6 +7,7 @@
"type": "process",
"args": [
"build",
"--no-restore",
"${workspaceFolder}/Source.Launcher/Source.Launcher.csproj",
"-p:WarningLevel=0"
],
Expand All @@ -18,6 +19,7 @@
"type": "process",
"args": [
"build",
"--no-restore",
"${workspaceFolder}/Source.Dedicated/Source.Dedicated.csproj",
"-p:WarningLevel=0",
"-c",
Expand Down
2 changes: 1 addition & 1 deletion Dependencies/Steamworks.NET
13 changes: 12 additions & 1 deletion Game.Client/C_BaseEntity.cs
Original file line number Diff line number Diff line change
Expand Up @@ -1074,7 +1074,7 @@ public virtual bool GetSoundSpatialization(ref SpatializationInfo info) {
public virtual void ValidateModelIndex() {
SetModelByIndex(ModelIndex);
}
void SetModelPointer(Model? model) {
public void SetModelPointer(Model? model) {
if (model != Model) {
DestroyModelInstance();
Model = model;
Expand Down Expand Up @@ -2114,6 +2114,17 @@ public ref Matrix3x4 EntityToWorldTransform() {
return ref CoordinateFrame;
}

public virtual void GetVectors(out Vector3 forward, out Vector3 right, out Vector3 up) {
ref readonly Matrix3x4 entityToWorld = ref EntityToWorldTransform();

MathLib.MatrixGetColumn(entityToWorld, 0, out forward);

MathLib.MatrixGetColumn(entityToWorld, 1, out right);
right *= -1.0f;

MathLib.MatrixGetColumn(entityToWorld, 2, out up);
}

public ref Vector3 GetNetworkOrigin() => ref NetworkOrigin;
public ref readonly Vector3 GetOldOrigin() => ref OldOrigin;
public ref QAngle GetNetworkAngles() => ref NetworkAngles;
Expand Down
2 changes: 2 additions & 0 deletions Game.Client/C_PropJeep.cs
Original file line number Diff line number Diff line change
Expand Up @@ -18,6 +18,8 @@ public class C_PropJeep : C_PropVehicleDriveable

[NetworkName("m_bHeadlightIsOn")]
public bool HeadlightIsOn;

public override bool IsJeep() => true;
}

[NetworkName("CPropJeepEpisodic")]
Expand Down
2 changes: 2 additions & 0 deletions Game.Client/C_RagdollProp.cs
Original file line number Diff line number Diff line change
Expand Up @@ -28,4 +28,6 @@ .. Enumerable.Range(0, RAGDOLL_MAX_ELEMENTS).Select(i => RecvPropQAngles(FIELD.O
public float BlendWeight;
[NetworkName("m_nOverlaySequence")]
public int OverlaySequence;

public override bool IsRagdollProp() => true;
}
3 changes: 2 additions & 1 deletion Game.Client/ClientEntityList.cs
Original file line number Diff line number Diff line change
Expand Up @@ -33,7 +33,8 @@ public class ClientEntityList : BaseEntityList, IClientEntityList
public IClientUnknown? GetListedEntity(int entNum) => (IClientUnknown?)LookupEntityByNetworkIndex(entNum);

public IClientEntity? GetClientEntityFromHandle(in BaseHandle ent) {
throw new NotImplementedException();
IClientUnknown? pEnt = GetClientUnknownFromHandle(ent);
return pEnt == null ? null : pEnt.GetIClientEntity();
}

public IClientNetworkable? GetClientNetworkable(int entnNum) {
Expand Down
9 changes: 8 additions & 1 deletion Game.Client/ClientModeShared.cs
Original file line number Diff line number Diff line change
Expand Up @@ -37,7 +37,14 @@ public ClientModeShared() {
strcpy(HostName, "Unset");
}

static void SetupVGuiMatrices(bool push, IMatRenderContext renderContext) {
public void SetupGModSurface(bool push) {
if (push)
surface.PushMakeCurrent(GarrysMod.GModBase.GetGModBasePanel(true)!, false);
else
surface.PopMakeCurrent(GarrysMod.GModBase.GetGModBasePanel(true)!);
}

public static void SetupVGuiMatrices(bool push, IMatRenderContext renderContext) {
if (!push) {
renderContext.MatrixMode(MaterialMatrixMode.Projection);
renderContext.PopMatrix();
Expand Down
63 changes: 63 additions & 0 deletions Game.Client/ClientRenderTargets.cs
Original file line number Diff line number Diff line change
@@ -0,0 +1,63 @@
using Source.Common.Bitmap;
using Source.Common.Client;
using Source.Common.MaterialSystem;

using TextureFlags = Source.Common.TextureFlags;

namespace Game.Client;

public class BaseClientRenderTargets : IClientRenderTargets
{
protected readonly TextureReference WaterReflectionTexture = new();
protected readonly TextureReference WaterRefractionTexture = new();
protected readonly TextureReference CameraTexture = new();

protected static ITexture? CreateWaterReflectionTexture(IMaterialSystem materialSystem, int size) {
return materialSystem.CreateNamedRenderTargetTextureEx2("_rt_WaterReflection", size, size, RenderTargetSizeMode.Picmip, materialSystem.GetBackBufferFormat(), MaterialRenderTargetDepth.Shared, TextureFlags.ClampS | TextureFlags.ClampT, CreateRenderTargetFlags.HDR);
}

protected static ITexture? CreateWaterRefractionTexture(IMaterialSystem materialSystem, int size) {
return materialSystem.CreateNamedRenderTargetTextureEx2("_rt_WaterRefraction", size, size, RenderTargetSizeMode.Picmip, ImageFormat.RGBA8888, MaterialRenderTargetDepth.Shared, TextureFlags.ClampS | TextureFlags.ClampT, CreateRenderTargetFlags.HDR);
}

protected static ITexture? CreateCameraTexture(IMaterialSystem materialSystem, int size) {
return materialSystem.CreateNamedRenderTargetTextureEx2("_rt_Camera", size, size, RenderTargetSizeMode.Default, materialSystem.GetBackBufferFormat(), MaterialRenderTargetDepth.Shared, 0, CreateRenderTargetFlags.HDR);
}

public virtual void InitClientRenderTargets(IMaterialSystem materialSystem, IMaterialSystemHardwareConfig hardwareConfig) => InitClientRenderTargets(materialSystem, hardwareConfig, 1024, 256);

public void InitClientRenderTargets(IMaterialSystem materialSystem, IMaterialSystemHardwareConfig hardwareConfig, int waterTextureSize, int cameraTextureSize) {
// Water effects
WaterReflectionTexture.Init(CreateWaterReflectionTexture(materialSystem, waterTextureSize));
WaterRefractionTexture.Init(CreateWaterRefractionTexture(materialSystem, waterTextureSize));

// Monitors
CameraTexture.Init(CreateCameraTexture(materialSystem, cameraTextureSize));
}

public virtual void ShutdownClientRenderTargets() {
// Water effects
WaterReflectionTexture.Shutdown();
WaterRefractionTexture.Shutdown();

// Monitors
CameraTexture.Shutdown();
}
}

public class ClientRenderTargets : BaseClientRenderTargets
{
public override void InitClientRenderTargets(IMaterialSystem materialSystem, IMaterialSystemHardwareConfig hardwareConfig) {
InitClientRenderTargets(materialSystem, hardwareConfig, 1024, 512);
materialSystem.CreateNamedRenderTargetTexture("_rt_spawnicon", 512, 512, RenderTargetSizeMode.Default, ImageFormat.ARGB8888, MaterialRenderTargetDepth.Separate, true, false);

RenderTexture.GetMoBlurTex0();
RenderTexture.GetMoBlurTex1();
RenderTexture.GetBloomTex0();
RenderTexture.GetBloomTex1();
RenderTexture.GetMorphTex0();
RenderTexture.GetMorphTex1();
RenderTexture.GetSuperFPTex2(hardwareConfig);
RenderTexture.GetSuperFPTex(hardwareConfig);
}
}
2 changes: 0 additions & 2 deletions Game.Client/GarrysMod/IntroScreen.cs
Original file line number Diff line number Diff line change
Expand Up @@ -74,9 +74,7 @@ public void Update(ReadOnlySpan<char> status, bool step) {
renderContext.PushMatrix();
renderContext.LoadIdentity();

surface.SetInDrawing(true);
DoDraw(ref renderContext, status, width, height, progress);
surface.SetInDrawing(false);

renderContext.MatrixMode(MaterialMatrixMode.Projection);
renderContext.PopMatrix();
Expand Down
Loading
Loading