Rust update

This commit is contained in:
Flero 2025-08-09 20:48:06 +09:30
parent d62ccfaa04
commit 3352bcc902
Signed by: flerouwu
SSH key fingerprint: SHA256:FB8cuclKIbQLfo1o/JNTq7r9e3vocaOu/vkEg+gViVU
1215 changed files with 118140 additions and 42980 deletions

View file

@ -0,0 +1,8 @@
<?xml version="1.0" encoding="UTF-8"?>
<project version="4">
<component name="UserContentModel">
<attachedFolders />
<explicitIncludes />
<explicitExcludes />
</component>
</project>

View file

@ -0,0 +1,8 @@
<?xml version="1.0" encoding="UTF-8"?>
<project version="4">
<component name="RiderProjectSettingsUpdater">
<option name="singleClickDiffPreview" value="1" />
<option name="unhandledExceptionsIgnoreList" value="1" />
<option name="vcsConfiguration" value="3" />
</component>
</project>

View file

@ -0,0 +1,6 @@
<?xml version="1.0" encoding="UTF-8"?>
<project version="4">
<component name="VcsDirectoryMappings">
<mapping directory="$PROJECT_DIR$" vcs="Git" />
</component>
</project>

View file

@ -0,0 +1,117 @@
<?xml version="1.0" encoding="UTF-8"?>
<project version="4">
<component name="AutoImportSettings">
<option name="autoReloadType" value="SELECTIVE" />
</component>
<component name="ChangeListManager">
<list default="true" id="cab4d00f-f27d-4bfb-879d-b88dbdbd387a" name="Changes" comment="" />
<option name="SHOW_DIALOG" value="false" />
<option name="HIGHLIGHT_CONFLICTS" value="true" />
<option name="HIGHLIGHT_NON_ACTIVE_CHANGELIST" value="false" />
<option name="LAST_RESOLUTION" value="IGNORE" />
</component>
<component name="Git.Settings">
<option name="RECENT_GIT_ROOT_PATH" value="$PROJECT_DIR$" />
</component>
<component name="HighlightingSettingsPerFile">
<setting file="file://$APPLICATION_CONFIG_DIR$/resharper-host/DecompilerCache/decompiler/05bc115bb13446a4a5a9726e7cadc8a11cc00/c7/a1802ed9/SingletonComponent`1.cs" root0="FORCE_HIGHLIGHTING" />
<setting file="file://$APPLICATION_CONFIG_DIR$/resharper-host/DecompilerCache/decompiler/6e967e31775a4fc393ed08e0806a560111200/19/2697cdd4/Connection.cs" root0="FORCE_HIGHLIGHTING" />
<setting file="file://$APPLICATION_CONFIG_DIR$/resharper-host/DecompilerCache/decompiler/6e967e31775a4fc393ed08e0806a560111200/56/b72a8061/Message.cs" root0="FORCE_HIGHLIGHTING" />
<setting file="file://$APPLICATION_CONFIG_DIR$/resharper-host/DecompilerCache/decompiler/6e967e31775a4fc393ed08e0806a560111200/d0/588c04bd/NetWrite.cs" root0="FORCE_HIGHLIGHTING" />
<setting file="file://$APPLICATION_CONFIG_DIR$/resharper-host/DecompilerCache/decompiler/6e967e31775a4fc393ed08e0806a560111200/f7/e8bb595c/NetRead.cs" root0="FORCE_HIGHLIGHTING" />
<setting file="file://$APPLICATION_CONFIG_DIR$/resharper-host/DecompilerCache/decompiler/7719071d86fe4bd88432192c9add9bd412400/b6/77f632b7/Manifest.cs" root0="FORCE_HIGHLIGHTING" />
<setting file="file://$APPLICATION_CONFIG_DIR$/resharper-host/DecompilerCache/decompiler/7719071d86fe4bd88432192c9add9bd412400/dd/c67e27ae/BuildInfo.cs" root0="FORCE_HIGHLIGHTING" />
<setting file="file://$APPLICATION_CONFIG_DIR$/resharper-host/DecompilerCache/decompiler/936831a09d2245b5af6ce4177639876b154000/13/9d08ec6a/BasePlayer.cs" root0="FORCE_HIGHLIGHTING" />
<setting file="file://$APPLICATION_CONFIG_DIR$/resharper-host/DecompilerCache/decompiler/936831a09d2245b5af6ce4177639876b154000/1f/1c00eed3/PlayerInventory.cs" root0="FORCE_HIGHLIGHTING" />
<setting file="file://$APPLICATION_CONFIG_DIR$/resharper-host/DecompilerCache/decompiler/936831a09d2245b5af6ce4177639876b154000/47/77d3983e/ItemContainer.cs" root0="FORCE_HIGHLIGHTING" />
<setting file="file://$APPLICATION_CONFIG_DIR$/resharper-host/DecompilerCache/decompiler/a3e2fae2358a415fbd36c6e4bf7898c9ec00/09/5dbcb1c4/AudioSource.cs" root0="FORCE_HIGHLIGHTING" />
<setting file="file://$APPLICATION_CONFIG_DIR$/resharper-host/DecompilerCache/decompiler/fcb9dac8ae3a488693b0f4cd5b0db0be287150/49/292e70af/List`1.cs" root0="FORCE_HIGHLIGHTING" />
<setting file="file://$PROJECT_DIR$/Assembly-CSharp/AntiHackType.cs" root0="FORCE_HIGHLIGHTING" />
<setting file="file://$PROJECT_DIR$/Assembly-CSharp/BasePlayer.cs" root0="SKIP_HIGHLIGHTING" />
<setting file="file://$PROJECT_DIR$/Assembly-CSharp/BowWeapon.cs" root0="SKIP_HIGHLIGHTING" />
</component>
<component name="ProjectColorInfo">{
&quot;customColor&quot;: &quot;&quot;,
&quot;associatedIndex&quot;: 4
}</component>
<component name="ProjectId" id="2zWH1Jo1tZN8klWsnMMNqkTjE02" />
<component name="ProjectViewState">
<option name="showLibraryContents" value="true" />
</component>
<component name="PropertiesComponent">{
&quot;keyToString&quot;: {
&quot;ModuleVcsDetector.initialDetectionPerformed&quot;: &quot;true&quot;,
&quot;RunOnceActivity.ShowReadmeOnStart&quot;: &quot;true&quot;,
&quot;RunOnceActivity.git.unshallow&quot;: &quot;true&quot;,
&quot;git-widget-placeholder&quot;: &quot;main&quot;,
&quot;node.js.detected.package.eslint&quot;: &quot;true&quot;,
&quot;node.js.detected.package.tslint&quot;: &quot;true&quot;,
&quot;node.js.selected.package.eslint&quot;: &quot;(autodetect)&quot;,
&quot;node.js.selected.package.tslint&quot;: &quot;(autodetect)&quot;,
&quot;nodejs_package_manager_path&quot;: &quot;npm&quot;,
&quot;settings.editor.selected.configurable&quot;: &quot;settings.sync&quot;,
&quot;vue.rearranger.settings.migration&quot;: &quot;true&quot;
}
}</component>
<component name="RunManager">
<configuration name="Attach to Unity Editor" type="UNITY_DEBUG_RUN_CONFIGURATION" factoryName="Unity Debug" show_console_on_std_err="false" show_console_on_std_out="false" port="50000" address="localhost">
<option name="allowRunningInParallel" value="false" />
<option name="listenPortForConnections" value="false" />
<option name="pid" />
<option name="projectPathOnTarget" />
<option name="runtimes">
<list />
</option>
<option name="selectedOptions">
<list />
</option>
<option name="useMixedMode" value="false" />
<method v="2" />
</configuration>
</component>
<component name="TaskManager">
<task active="true" id="Default" summary="Default task">
<changelist id="cab4d00f-f27d-4bfb-879d-b88dbdbd387a" name="Changes" comment="" />
<created>1751839692746</created>
<option name="number" value="Default" />
<option name="presentableId" value="Default" />
<updated>1751839692746</updated>
<workItem from="1751839693846" duration="8394000" />
<workItem from="1751962144419" duration="17000" />
<workItem from="1752154689532" duration="2534000" />
<workItem from="1752194095166" duration="2142000" />
<workItem from="1752219714755" duration="10000" />
<workItem from="1752274528875" duration="1271000" />
<workItem from="1753567185116" duration="887000" />
</task>
<servers />
</component>
<component name="TypeScriptGeneratedFilesManager">
<option name="version" value="3" />
</component>
<component name="UnityProjectConfiguration" hasMinimizedUI="false" />
<component name="UnityProjectDiscoverer">
<option name="hasUnityReference" value="true" />
</component>
<component name="VcsManagerConfiguration">
<option name="CLEAR_INITIAL_COMMIT_MESSAGE" value="true" />
</component>
<component name="XDebuggerManager">
<breakpoint-manager>
<breakpoints>
<breakpoint enabled="true" type="DotNet_Exception_Breakpoints">
<properties exception="System.OperationCanceledException" breakIfHandledByOtherCode="false" displayValue="System.OperationCanceledException" />
<option name="timeStamp" value="1" />
</breakpoint>
<breakpoint enabled="true" type="DotNet_Exception_Breakpoints">
<properties exception="System.Threading.Tasks.TaskCanceledException" breakIfHandledByOtherCode="false" displayValue="System.Threading.Tasks.TaskCanceledException" />
<option name="timeStamp" value="2" />
</breakpoint>
<breakpoint enabled="true" type="DotNet_Exception_Breakpoints">
<properties exception="System.Threading.ThreadAbortException" breakIfHandledByOtherCode="false" displayValue="System.Threading.ThreadAbortException" />
<option name="timeStamp" value="3" />
</breakpoint>
</breakpoints>
</breakpoint-manager>
</component>
</project>

View file

@ -22,7 +22,7 @@
</ItemGroup>
<ItemGroup>
<Reference Include="System.Core">
<HintPath>../../ProtobitRust/.references/RustDedicated_Data/Managed/System.Core.dll</HintPath>
<HintPath>../../../ProtobitRust/.references/RustDedicated_Data/Managed/System.Core.dll</HintPath>
</Reference>
</ItemGroup>
</Project>

View file

@ -13,49 +13,49 @@
<ItemGroup />
<ItemGroup>
<Reference Include="Facepunch.UnityEngine">
<HintPath>../../ProtobitRust/.references/RustDedicated_Data/Managed/Facepunch.UnityEngine.dll</HintPath>
<HintPath>../../../ProtobitRust/.references/RustDedicated_Data/Managed/Facepunch.UnityEngine.dll</HintPath>
</Reference>
<Reference Include="UnityEngine.UI">
<HintPath>../../ProtobitRust/.references/RustDedicated_Data/Managed/UnityEngine.UI.dll</HintPath>
<HintPath>../../../ProtobitRust/.references/RustDedicated_Data/Managed/UnityEngine.UI.dll</HintPath>
</Reference>
<Reference Include="Rust.UI">
<HintPath>../../ProtobitRust/.references/RustDedicated_Data/Managed/Rust.UI.dll</HintPath>
<HintPath>../../../ProtobitRust/.references/RustDedicated_Data/Managed/Rust.UI.dll</HintPath>
</Reference>
<Reference Include="Unity.TextMeshPro">
<HintPath>../../ProtobitRust/.references/RustDedicated_Data/Managed/Unity.TextMeshPro.dll</HintPath>
<HintPath>../../../ProtobitRust/.references/RustDedicated_Data/Managed/Unity.TextMeshPro.dll</HintPath>
</Reference>
<Reference Include="UnityEngine.CoreModule">
<HintPath>../../ProtobitRust/.references/RustDedicated_Data/Managed/UnityEngine.CoreModule.dll</HintPath>
<HintPath>../../../ProtobitRust/.references/RustDedicated_Data/Managed/UnityEngine.CoreModule.dll</HintPath>
</Reference>
<Reference Include="UnityEngine.InputLegacyModule">
<HintPath>../../ProtobitRust/.references/RustDedicated_Data/Managed/UnityEngine.InputLegacyModule.dll</HintPath>
<HintPath>../../../ProtobitRust/.references/RustDedicated_Data/Managed/UnityEngine.InputLegacyModule.dll</HintPath>
</Reference>
<Reference Include="Facepunch.System">
<HintPath>../../ProtobitRust/.references/RustDedicated_Data/Managed/Facepunch.System.dll</HintPath>
<HintPath>../../../ProtobitRust/.references/RustDedicated_Data/Managed/Facepunch.System.dll</HintPath>
</Reference>
<Reference Include="System.Xml">
<HintPath>../../ProtobitRust/.references/RustDedicated_Data/Managed/System.Xml.dll</HintPath>
<HintPath>../../../ProtobitRust/.references/RustDedicated_Data/Managed/System.Xml.dll</HintPath>
</Reference>
<Reference Include="UnityEngine.AudioModule">
<HintPath>../../ProtobitRust/.references/RustDedicated_Data/Managed/UnityEngine.AudioModule.dll</HintPath>
<HintPath>../../../ProtobitRust/.references/RustDedicated_Data/Managed/UnityEngine.AudioModule.dll</HintPath>
</Reference>
<Reference Include="UnityEngine.ParticleSystemModule">
<HintPath>../../ProtobitRust/.references/RustDedicated_Data/Managed/UnityEngine.ParticleSystemModule.dll</HintPath>
<HintPath>../../../ProtobitRust/.references/RustDedicated_Data/Managed/UnityEngine.ParticleSystemModule.dll</HintPath>
</Reference>
<Reference Include="Facepunch.Network">
<HintPath>../../ProtobitRust/.references/RustDedicated_Data/Managed/Facepunch.Network.dll</HintPath>
<HintPath>../../../ProtobitRust/.references/RustDedicated_Data/Managed/Facepunch.Network.dll</HintPath>
</Reference>
<Reference Include="Facepunch.Unity">
<HintPath>../../ProtobitRust/.references/RustDedicated_Data/Managed/Facepunch.Unity.dll</HintPath>
<HintPath>../../../ProtobitRust/.references/RustDedicated_Data/Managed/Facepunch.Unity.dll</HintPath>
</Reference>
<Reference Include="Facepunch.Input">
<HintPath>../../ProtobitRust/.references/RustDedicated_Data/Managed/Facepunch.Input.dll</HintPath>
<HintPath>../../../ProtobitRust/.references/RustDedicated_Data/Managed/Facepunch.Input.dll</HintPath>
</Reference>
<Reference Include="System.Core">
<HintPath>../../ProtobitRust/.references/RustDedicated_Data/Managed/System.Core.dll</HintPath>
<HintPath>../../../ProtobitRust/.references/RustDedicated_Data/Managed/System.Core.dll</HintPath>
</Reference>
<Reference Include="UnityEngine.JSONSerializeModule">
<HintPath>../../ProtobitRust/.references/RustDedicated_Data/Managed/UnityEngine.JSONSerializeModule.dll</HintPath>
<HintPath>../../../ProtobitRust/.references/RustDedicated_Data/Managed/UnityEngine.JSONSerializeModule.dll</HintPath>
</Reference>
</ItemGroup>
</Project>

View file

@ -20,6 +20,14 @@ public class TOD_AtmosphereParameters
[TOD_Min(0f)]
public float Contrast = 1.5f;
[Tooltip("Overall brightness of the nighttime atmosphere.")]
[TOD_Min(0f)]
public float NightBrightness = 1f;
[Tooltip("Overall contrast of the nighttime atmosphere.")]
[TOD_Min(0f)]
public float NightContrast = 1f;
[Tooltip("Directionality factor that determines the size of the glow around the sun.")]
[TOD_Range(0f, 1f)]
public float Directionality = 0.7f;

View file

@ -17,6 +17,10 @@ public class TOD_Components : MonoBehaviour
public GameObject Clouds;
public GameObject VClouds;
public GameObject ForegroundFog;
public GameObject Billboards;
public GameObject Light;
@ -55,6 +59,10 @@ public class TOD_Components : MonoBehaviour
public Renderer CloudRenderer { get; set; }
public Renderer VCloudsRenderer { get; set; }
public Renderer ForegroundFogRenderer { get; set; }
public Renderer[] BillboardRenderers { get; set; }
public MeshFilter SpaceMeshFilter { get; set; }
@ -71,6 +79,8 @@ public class TOD_Components : MonoBehaviour
public MeshFilter CloudMeshFilter { get; set; }
public MeshFilter VCloudsMeshFilter { get; set; }
public MeshFilter[] BillboardMeshFilters { get; set; }
public Material SpaceMaterial { get; set; }
@ -87,6 +97,8 @@ public class TOD_Components : MonoBehaviour
public Material CloudMaterial { get; set; }
public Material VCloudsMaterial { get; set; }
public Material[] BillboardMaterials { get; set; }
public Light LightSource { get; set; }
@ -160,6 +172,16 @@ public class TOD_Components : MonoBehaviour
CloudMeshFilter = Clouds.GetComponent<MeshFilter>();
CloudMaterial = CloudRenderer.sharedMaterial;
}
if ((bool)VClouds)
{
VCloudsMeshFilter = VClouds.GetComponent<MeshFilter>();
VCloudsRenderer = VClouds.GetComponent<MeshRenderer>();
VCloudsMaterial = VCloudsRenderer.sharedMaterial;
}
if ((bool)ForegroundFog)
{
ForegroundFogRenderer = ForegroundFog.GetComponent<MeshRenderer>();
}
if ((bool)Billboards)
{
BillboardTransform = Billboards.GetComponent<Transform>();

View file

@ -40,4 +40,8 @@ public class TOD_DayParameters
[Tooltip("Brightness multiplier of the reflection probe.")]
[Range(0f, 1f)]
public float ReflectionMultiplier = 1f;
[Tooltip("Max reflection multiplier")]
[Range(0f, 1f)]
public float ReflectionMaxClamp = 1f;
}

View file

@ -202,30 +202,39 @@ public abstract class TOD_ImageEffect : MonoBehaviour
return identity;
}
protected RenderTexture GetSkyMask(RenderTexture source, Material skyMaskMaterial, Material screenClearMaterial, ResolutionType resolution, Vector3 lightPos, int blurIterations, float blurRadius, float maxRadius)
protected Vector3i GetSkyMaskSize(RenderTexture source, ResolutionType resolution)
{
int width;
int height;
int depthBuffer;
int x;
int y;
int z;
switch (resolution)
{
case ResolutionType.High:
width = source.width;
height = source.height;
depthBuffer = 0;
x = source.width;
y = source.height;
z = 0;
break;
case ResolutionType.Normal:
width = source.width / 2;
height = source.height / 2;
depthBuffer = 0;
x = source.width / 2;
y = source.height / 2;
z = 0;
break;
default:
width = source.width / 4;
height = source.height / 4;
depthBuffer = 0;
x = source.width / 4;
y = source.height / 4;
z = 0;
break;
}
RenderTexture temporary = RenderTexture.GetTemporary(width, height, depthBuffer);
return new Vector3i(x, y, z);
}
protected RenderTexture GetSkyMask(RenderTexture source, Material skyMaskMaterial, Material screenClearMaterial, ResolutionType resolution, Vector3 lightPos, int blurIterations, float blurRadius, float maxRadius)
{
Vector3i skyMaskSize = GetSkyMaskSize(source, resolution);
int x = skyMaskSize.x;
int y = skyMaskSize.y;
int z = skyMaskSize.z;
RenderTexture temporary = RenderTexture.GetTemporary(x, y, z);
RenderTexture renderTexture = null;
skyMaskMaterial.SetVector("_BlurRadius4", new Vector4(1f, 1f, 0f, 0f) * blurRadius);
skyMaskMaterial.SetVector("_LightPosition", new Vector4(lightPos.x, lightPos.y, lightPos.z, maxRadius));
@ -246,12 +255,12 @@ public abstract class TOD_ImageEffect : MonoBehaviour
skyMaskMaterial.SetVector("_LightPosition", new Vector4(lightPos.x, lightPos.y, lightPos.z, maxRadius));
for (int i = 0; i < blurIterations; i++)
{
renderTexture = RenderTexture.GetTemporary(width, height, depthBuffer);
renderTexture = RenderTexture.GetTemporary(x, y, z);
Graphics.Blit(temporary, renderTexture, skyMaskMaterial, 0);
RenderTexture.ReleaseTemporary(temporary);
num = blurRadius * (((float)i * 2f + 1f) * 6f) / 768f;
skyMaskMaterial.SetVector("_BlurRadius4", new Vector4(num, num, 0f, 0f));
temporary = RenderTexture.GetTemporary(width, height, depthBuffer);
temporary = RenderTexture.GetTemporary(x, y, z);
Graphics.Blit(renderTexture, temporary, skyMaskMaterial, 0);
RenderTexture.ReleaseTemporary(renderTexture);
num = blurRadius * (((float)i * 2f + 2f) * 6f) / 768f;

View file

@ -16,6 +16,10 @@ public class TOD_MoonParameters
[TOD_Min(0f)]
public float MeshBrightness = 2f;
[Tooltip("Default brightness of moon.")]
[TOD_Min(0f)]
public float MeshBrightnessDefault = 2f;
[Tooltip("Contrast of the moon.")]
[TOD_Min(0f)]
public float MeshContrast = 1f;

View file

@ -43,4 +43,8 @@ public class TOD_NightParameters
[Tooltip("Brightness multiplier of the reflection probe.")]
[Range(0f, 1f)]
public float ReflectionMultiplier = 1f;
[Tooltip("Max reflection multiplier")]
[Range(0f, 1f)]
public float ReflectionMaxClamp = 1f;
}

View file

@ -70,6 +70,10 @@ public class TOD_Resources : MonoBehaviour
public int ID_Directionality { get; private set; }
public int ID_NightBrightness { get; private set; }
public int ID_NightContrast { get; private set; }
public int ID_MoonHaloPower { get; private set; }
public int ID_MoonHaloColor { get; private set; }
@ -106,6 +110,8 @@ public class TOD_Resources : MonoBehaviour
public int ID_StarVisibility { get; private set; }
public int ID_StarColorScale { get; private set; }
public int ID_SunMeshContrast { get; private set; }
public int ID_SunMeshBrightness { get; private set; }
@ -151,6 +157,8 @@ public class TOD_Resources : MonoBehaviour
ID_Brightness = Shader.PropertyToID("TOD_Brightness");
ID_Fogginess = Shader.PropertyToID("TOD_Fogginess");
ID_Directionality = Shader.PropertyToID("TOD_Directionality");
ID_NightContrast = Shader.PropertyToID("TOD_NightContrast");
ID_NightBrightness = Shader.PropertyToID("TOD_NightBrightness");
ID_MoonHaloPower = Shader.PropertyToID("TOD_MoonHaloPower");
ID_MoonHaloColor = Shader.PropertyToID("TOD_MoonHaloColor");
ID_CloudSize = Shader.PropertyToID("TOD_CloudSize");
@ -168,6 +176,7 @@ public class TOD_Resources : MonoBehaviour
ID_StarSize = Shader.PropertyToID("TOD_StarSize");
ID_StarBrightness = Shader.PropertyToID("TOD_StarBrightness");
ID_StarVisibility = Shader.PropertyToID("TOD_StarVisibility");
ID_StarColorScale = Shader.PropertyToID("TOD_StarColorScale");
ID_SunMeshContrast = Shader.PropertyToID("TOD_SunMeshContrast");
ID_SunMeshBrightness = Shader.PropertyToID("TOD_SunMeshBrightness");
ID_MoonMeshContrast = Shader.PropertyToID("TOD_MoonMeshContrast");

View file

@ -54,6 +54,8 @@ public class TOD_Scattering : TOD_ImageEffect
private Material skyMaskMaterial;
private RenderTexture skyMaskTexture;
protected void OnEnable()
{
if (!ScatteringShader)
@ -87,6 +89,11 @@ public class TOD_Scattering : TOD_ImageEffect
{
Object.DestroyImmediate(skyMaskMaterial);
}
if (skyMaskTexture != null)
{
skyMaskTexture.Release();
skyMaskTexture = null;
}
}
protected void OnPreCull()
@ -105,6 +112,36 @@ public class TOD_Scattering : TOD_ImageEffect
}
}
private void MakeSkyMaskTexture(RenderTexture source)
{
Vector3i skyMaskSize = GetSkyMaskSize(source, Resolution);
int x = skyMaskSize.x;
int y = skyMaskSize.y;
int z = skyMaskSize.z;
skyMaskTexture = new RenderTexture(x, y, z);
skyMaskTexture.wrapMode = TextureWrapMode.Clamp;
skyMaskTexture.filterMode = FilterMode.Bilinear;
skyMaskTexture.Create();
Shader.SetGlobalTexture("_TOD_SkyMask", skyMaskTexture);
}
private void ResizeSkyMask(RenderTexture source)
{
if (skyMaskTexture == null)
{
MakeSkyMaskTexture(source);
return;
}
Vector3i skyMaskSize = GetSkyMaskSize(source, Resolution);
if (skyMaskSize.x != skyMaskTexture.width || skyMaskSize.y != skyMaskTexture.height)
{
skyMaskTexture.Release();
skyMaskTexture.width = skyMaskSize.x;
skyMaskTexture.height = skyMaskSize.y;
skyMaskTexture.Create();
}
}
[ImageEffectOpaque]
protected void OnRenderImage(RenderTexture source, RenderTexture destination)
{
@ -113,6 +150,7 @@ public class TOD_Scattering : TOD_ImageEffect
Graphics.Blit(source, destination);
return;
}
ResizeSkyMask(source);
sky.Components.Scattering = this;
Vector3 lightPos = cam.WorldToViewportPoint(sky.Components.SunTransform.position);
RenderTexture skyMask = GetSkyMask(source, skyMaskMaterial, screenClearMaterial, Resolution, lightPos, BlurIterations, BlurRadius, MaxRadius);
@ -128,6 +166,7 @@ public class TOD_Scattering : TOD_ImageEffect
}
Shader.SetGlobalTexture("TOD_BayerTexture", DitheringTexture);
Shader.SetGlobalVector("TOD_ScatterDensity", new Vector4(HeightFalloff, ZeroLevel, GlobalDensity, StartDistance));
Graphics.Blit(skyMask, skyMaskTexture);
Graphics.Blit(source, destination, scatteringMaterial);
RenderTexture.ReleaseTemporary(skyMask);
}

View file

@ -138,6 +138,8 @@ public class TOD_Sky : MonoBehaviour
private float timeSinceReflectionUpdate = float.MaxValue;
private bool drawVClouds;
private const int TOD_SAMPLES = 2;
private Vector3 kBetaMie;
@ -565,6 +567,17 @@ public class TOD_Sky : MonoBehaviour
Components.Billboards.SetActive(state);
}
public void SetVClouds(bool state)
{
drawVClouds = state;
Components.VCloudsRenderer.enabled = state;
bool flag = !state;
for (int i = 0; i < Components.BillboardRenderers.Length; i++)
{
Components.BillboardRenderers[i].enabled = flag;
}
}
private void UpdateQualitySettings()
{
if (!Headless)
@ -773,6 +786,8 @@ public class TOD_Sky : MonoBehaviour
Shader.SetGlobalFloat(Resources.ID_Brightness, Atmosphere.Brightness);
Shader.SetGlobalFloat(Resources.ID_Fogginess, Atmosphere.Fogginess);
Shader.SetGlobalFloat(Resources.ID_Directionality, Atmosphere.Directionality);
Shader.SetGlobalFloat(Resources.ID_NightBrightness, Atmosphere.NightBrightness);
Shader.SetGlobalFloat(Resources.ID_NightContrast, Atmosphere.NightContrast);
Shader.SetGlobalFloat(Resources.ID_MoonHaloPower, 1f / Moon.HaloSize);
Shader.SetGlobalColor(Resources.ID_MoonHaloColor, MoonHaloColor);
float value = Mathf.Lerp(0.8f, 0f, Clouds.Coverage);
@ -794,6 +809,7 @@ public class TOD_Sky : MonoBehaviour
Shader.SetGlobalFloat(Resources.ID_StarSize, Stars.Size);
Shader.SetGlobalFloat(Resources.ID_StarBrightness, Stars.Brightness);
Shader.SetGlobalFloat(Resources.ID_StarVisibility, (1f - Atmosphere.Fogginess) * (1f - LerpValue));
Shader.SetGlobalColor(Resources.ID_StarColorScale, Stars.ColorScale.linear);
Shader.SetGlobalFloat(Resources.ID_SunMeshContrast, 1f / Mathf.Max(0.001f, Sun.MeshContrast));
Shader.SetGlobalFloat(Resources.ID_SunMeshBrightness, Sun.MeshBrightness * (1f - Atmosphere.Fogginess));
Shader.SetGlobalFloat(Resources.ID_MoonMeshContrast, 1f / Mathf.Max(0.001f, Moon.MeshContrast));
@ -987,6 +1003,16 @@ public class TOD_Sky : MonoBehaviour
Cycle.DateTime = Cycle.DateTime;
}
public float GetDayTime()
{
return Mathf.Clamp01(SunZenith / 90f);
}
public float GetNightTime()
{
return Mathf.Clamp01((SunZenith - 90f) / 90f);
}
private void UpdateScattering()
{
float num = 0f - Atmosphere.Directionality;
@ -1217,33 +1243,34 @@ public class TOD_Sky : MonoBehaviour
Components.AtmosphereRenderer.enabled = flag4;
bool flag5 = false;
Components.ClearRenderer.enabled = flag5;
bool flag6 = Clouds.Coverage > 0f && Clouds.Opacity > 0f;
bool flag6 = Clouds.Coverage > 0f && Clouds.Opacity > 0f && !drawVClouds;
Components.CloudRenderer.enabled = flag6;
Components.VCloudsRenderer.enabled = drawVClouds;
LerpValue = Mathf.InverseLerp(105f, 90f, SunZenith);
float time = Mathf.Clamp01(SunZenith / 90f);
float time2 = Mathf.Clamp01((SunZenith - 90f) / 90f);
float dayTime = GetDayTime();
float nightTime = GetNightTime();
float num116 = Mathf.Clamp01((LerpValue - 0.1f) / 0.9f);
float num117 = Mathf.Clamp01((0.1f - LerpValue) / 0.1f);
float num118 = Mathf.Clamp01((90f - num111 * 57.29578f) / 5f);
SunVisibility = (1f - Atmosphere.Fogginess) * num116;
MoonVisibility = (1f - Atmosphere.Fogginess) * num117 * num118;
SunLightColor = TOD_Util.ApplyAlpha(Day.LightColor.Evaluate(time));
MoonLightColor = TOD_Util.ApplyAlpha(Night.LightColor.Evaluate(time2));
SunRayColor = TOD_Util.ApplyAlpha(Day.RayColor.Evaluate(time));
MoonRayColor = TOD_Util.ApplyAlpha(Night.RayColor.Evaluate(time2));
SunSkyColor = TOD_Util.ApplyAlpha(Day.SkyColor.Evaluate(time));
MoonSkyColor = TOD_Util.ApplyAlpha(Night.SkyColor.Evaluate(time2));
SunMeshColor = TOD_Util.ApplyAlpha(Day.SunColor.Evaluate(time));
Color a = Night.MoonColor.Evaluate(time2);
Color b = Night.MoonColorRed.Evaluate(time2);
SunLightColor = TOD_Util.ApplyAlpha(Day.LightColor.Evaluate(dayTime));
MoonLightColor = TOD_Util.ApplyAlpha(Night.LightColor.Evaluate(nightTime));
SunRayColor = TOD_Util.ApplyAlpha(Day.RayColor.Evaluate(dayTime));
MoonRayColor = TOD_Util.ApplyAlpha(Night.RayColor.Evaluate(nightTime));
SunSkyColor = TOD_Util.ApplyAlpha(Day.SkyColor.Evaluate(dayTime));
MoonSkyColor = TOD_Util.ApplyAlpha(Night.SkyColor.Evaluate(nightTime));
SunMeshColor = TOD_Util.ApplyAlpha(Day.SunColor.Evaluate(dayTime));
Color a = Night.MoonColor.Evaluate(nightTime);
Color b = Night.MoonColorRed.Evaluate(nightTime);
MoonMeshColor = TOD_Util.ApplyAlpha(Color.Lerp(a, b, Cycle.RedMoonLerp));
SunCloudColor = TOD_Util.ApplyAlpha(Day.CloudColor.Evaluate(time));
MoonCloudColor = TOD_Util.ApplyAlpha(Night.CloudColor.Evaluate(time2));
Color b2 = TOD_Util.ApplyAlpha(Day.FogColor.Evaluate(time));
Color a2 = TOD_Util.ApplyAlpha(Night.FogColor.Evaluate(time2));
SunCloudColor = TOD_Util.ApplyAlpha(Day.CloudColor.Evaluate(dayTime));
MoonCloudColor = TOD_Util.ApplyAlpha(Night.CloudColor.Evaluate(nightTime));
Color b2 = TOD_Util.ApplyAlpha(Day.FogColor.Evaluate(dayTime));
Color a2 = TOD_Util.ApplyAlpha(Night.FogColor.Evaluate(nightTime));
FogColor = Color.Lerp(a2, b2, LerpValue);
Color color = TOD_Util.ApplyAlpha(Day.AmbientColor.Evaluate(time));
Color color2 = TOD_Util.ApplyAlpha(Night.AmbientColor.Evaluate(time2));
Color color = TOD_Util.ApplyAlpha(Day.AmbientColor.Evaluate(dayTime));
Color color2 = TOD_Util.ApplyAlpha(Night.AmbientColor.Evaluate(nightTime));
AmbientColor = Color.Lerp(color2, color, LerpValue);
Color b3 = color;
Color a3 = color2;

View file

@ -14,4 +14,7 @@ public class TOD_StarParameters
[Tooltip("Type of the stars position calculation.")]
public TOD_StarsPositionType Position = TOD_StarsPositionType.Rotating;
[Tooltip("Tint of the stars.")]
public Color ColorScale = Color.white;
}

View file

@ -12,6 +12,10 @@ public class TOD_SunParameters
[TOD_Min(0f)]
public float MeshBrightness = 2f;
[Tooltip("Default brightness of sun.")]
[TOD_Min(0f)]
public float MeshBrightnessDefault = 2f;
[Tooltip("Contrast of the sun.")]
[TOD_Min(0f)]
public float MeshContrast = 1f;

View file

@ -146,7 +146,7 @@ public class AdventCalendar : BaseCombatEntity
}
foreach (ItemAmount itemAmount in rewards)
{
if (itemAmount.itemDef.IsAllowedInEra(EraRestriction.Loot))
if (itemAmount.itemDef.IsAllowed(EraRestriction.Loot))
{
player.GiveItem(ItemManager.CreateByItemID(itemAmount.itemid, Mathf.CeilToInt(itemAmount.amount), 0uL).SetItemOwnership(player, ItemOwnershipPhrases.AdventCalendar), GiveItemReason.PickedUp);
}

View file

@ -1,3 +1,4 @@
using UnityEngine;
using UnityEngine.UI;
public class ArmorInformationPanel : ItemInformationPanel
@ -14,6 +15,8 @@ public class ArmorInformationPanel : ItemInformationPanel
public ItemTextValue biteDisplay;
public ItemTextValue speedDisplay;
public ItemTextValue spacer;
public Text areaProtectionText;
@ -32,5 +35,19 @@ public class ArmorInformationPanel : ItemInformationPanel
public ItemIcon[] insertIcons;
public GridLayoutGroup informationGridLayout;
public RectOffset paddingOnResize;
public Vector2 cellSizeOnResize;
public Vector2 spacingOnResize;
private RectOffset originalPadding;
private Vector2 originalCellSize;
private Vector2 originalSpacing;
private ProtectionProperties protection;
}

View file

@ -1,4 +1,5 @@
using System;
using System.Collections.Generic;
using UnityEngine;
public static class ArrayEx
@ -73,4 +74,33 @@ public static class ArrayEx
}
}
}
public static int BinarySearch<TElement, TNeedle>(this TElement[] array, Func<TElement, TNeedle> selector, TNeedle needle, IComparer<TNeedle> comparer = null)
{
if (comparer == null)
{
comparer = Comparer<TNeedle>.Default;
}
int num = 0;
int num2 = array.Length - 1;
while (num <= num2)
{
int num3 = num + (num2 - num) / 2;
TNeedle x = selector(array[num3]);
int num4 = comparer.Compare(x, needle);
if (num4 == 0)
{
return num3;
}
if (num4 < 0)
{
num = num3 + 1;
}
else
{
num2 = num3 - 1;
}
}
return ~num;
}
}

View file

@ -13,238 +13,250 @@
<ItemGroup />
<ItemGroup>
<Reference Include="UnityEngine.CoreModule">
<HintPath>../../ProtobitRust/.references/RustDedicated_Data/Managed/UnityEngine.CoreModule.dll</HintPath>
<HintPath>../../../ProtobitRust/.references/RustDedicated_Data/Managed/UnityEngine.CoreModule.dll</HintPath>
</Reference>
<Reference Include="Rust.World">
<HintPath>../../ProtobitRust/.references/RustDedicated_Data/Managed/Rust.World.dll</HintPath>
</Reference>
<Reference Include="Facepunch.Network">
<HintPath>../../ProtobitRust/.references/RustDedicated_Data/Managed/Facepunch.Network.dll</HintPath>
</Reference>
<Reference Include="Facepunch.UnityEngine">
<HintPath>../../ProtobitRust/.references/RustDedicated_Data/Managed/Facepunch.UnityEngine.dll</HintPath>
</Reference>
<Reference Include="UnityEngine.PhysicsModule">
<HintPath>../../ProtobitRust/.references/RustDedicated_Data/Managed/UnityEngine.PhysicsModule.dll</HintPath>
</Reference>
<Reference Include="Rust.Localization">
<HintPath>../../ProtobitRust/.references/RustDedicated_Data/Managed/Rust.Localization.dll</HintPath>
</Reference>
<Reference Include="Rust.UI">
<HintPath>../../ProtobitRust/.references/RustDedicated_Data/Managed/Rust.UI.dll</HintPath>
</Reference>
<Reference Include="Rust.Data">
<HintPath>../../ProtobitRust/.references/RustDedicated_Data/Managed/Rust.Data.dll</HintPath>
</Reference>
<Reference Include="System.Core">
<HintPath>../../ProtobitRust/.references/RustDedicated_Data/Managed/System.Core.dll</HintPath>
</Reference>
<Reference Include="Facepunch.Nexus">
<HintPath>../../ProtobitRust/.references/RustDedicated_Data/Managed/Facepunch.Nexus.dll</HintPath>
</Reference>
<Reference Include="Facepunch.System">
<HintPath>../../ProtobitRust/.references/RustDedicated_Data/Managed/Facepunch.System.dll</HintPath>
</Reference>
<Reference Include="Facepunch.Unity">
<HintPath>../../ProtobitRust/.references/RustDedicated_Data/Managed/Facepunch.Unity.dll</HintPath>
</Reference>
<Reference Include="Rust.Global">
<HintPath>../../ProtobitRust/.references/RustDedicated_Data/Managed/Rust.Global.dll</HintPath>
<HintPath>../../../ProtobitRust/.references/RustDedicated_Data/Managed/Rust.World.dll</HintPath>
</Reference>
<Reference Include="UnityEngine.AnimationModule">
<HintPath>../../ProtobitRust/.references/RustDedicated_Data/Managed/UnityEngine.AnimationModule.dll</HintPath>
<HintPath>../../../ProtobitRust/.references/RustDedicated_Data/Managed/UnityEngine.AnimationModule.dll</HintPath>
</Reference>
<Reference Include="Facepunch.Console">
<HintPath>../../ProtobitRust/.references/RustDedicated_Data/Managed/Facepunch.Console.dll</HintPath>
<Reference Include="Facepunch.UnityEngine">
<HintPath>../../../ProtobitRust/.references/RustDedicated_Data/Managed/Facepunch.UnityEngine.dll</HintPath>
</Reference>
<Reference Include="UnityEngine.ParticleSystemModule">
<HintPath>../../ProtobitRust/.references/RustDedicated_Data/Managed/UnityEngine.ParticleSystemModule.dll</HintPath>
</Reference>
<Reference Include="UnityEngine.VehiclesModule">
<HintPath>../../ProtobitRust/.references/RustDedicated_Data/Managed/UnityEngine.VehiclesModule.dll</HintPath>
</Reference>
<Reference Include="UnityEngine.UI">
<HintPath>../../ProtobitRust/.references/RustDedicated_Data/Managed/UnityEngine.UI.dll</HintPath>
</Reference>
<Reference Include="Assembly-CSharp-firstpass">
<HintPath>../../ProtobitRust/.references/RustDedicated_Data/Managed/Assembly-CSharp-firstpass.dll</HintPath>
</Reference>
<Reference Include="UnityEngine.AIModule">
<HintPath>../../ProtobitRust/.references/RustDedicated_Data/Managed/UnityEngine.AIModule.dll</HintPath>
</Reference>
<Reference Include="Rust.Clans">
<HintPath>../../ProtobitRust/.references/RustDedicated_Data/Managed/Rust.Clans.dll</HintPath>
</Reference>
<Reference Include="Unity.Collections">
<HintPath>../../ProtobitRust/.references/RustDedicated_Data/Managed/Unity.Collections.dll</HintPath>
</Reference>
<Reference Include="Unity.Mathematics">
<HintPath>../../ProtobitRust/.references/RustDedicated_Data/Managed/Unity.Mathematics.dll</HintPath>
</Reference>
<Reference Include="UnityEngine.AudioModule">
<HintPath>../../ProtobitRust/.references/RustDedicated_Data/Managed/UnityEngine.AudioModule.dll</HintPath>
</Reference>
<Reference Include="Unity.TextMeshPro">
<HintPath>../../ProtobitRust/.references/RustDedicated_Data/Managed/Unity.TextMeshPro.dll</HintPath>
</Reference>
<Reference Include="UnityEngine.UIModule">
<HintPath>../../ProtobitRust/.references/RustDedicated_Data/Managed/UnityEngine.UIModule.dll</HintPath>
</Reference>
<Reference Include="Unity.AI.Navigation">
<HintPath>../../ProtobitRust/.references/RustDedicated_Data/Managed/Unity.AI.Navigation.dll</HintPath>
</Reference>
<Reference Include="Newtonsoft.Json">
<HintPath>../../ProtobitRust/.references/RustDedicated_Data/Managed/Newtonsoft.Json.dll</HintPath>
</Reference>
<Reference Include="UnityEngine.InputLegacyModule">
<HintPath>../../ProtobitRust/.references/RustDedicated_Data/Managed/UnityEngine.InputLegacyModule.dll</HintPath>
</Reference>
<Reference Include="Rust.Platform.Common">
<HintPath>../../ProtobitRust/.references/RustDedicated_Data/Managed/Rust.Platform.Common.dll</HintPath>
</Reference>
<Reference Include="Facepunch.Skeleton">
<HintPath>../../ProtobitRust/.references/RustDedicated_Data/Managed/Facepunch.Skeleton.dll</HintPath>
</Reference>
<Reference Include="Facepunch.BurstCloth">
<HintPath>../../ProtobitRust/.references/RustDedicated_Data/Managed/Facepunch.BurstCloth.dll</HintPath>
</Reference>
<Reference Include="EZhex1991.EZSoftBone">
<HintPath>../../ProtobitRust/.references/RustDedicated_Data/Managed/EZhex1991.EZSoftBone.dll</HintPath>
</Reference>
<Reference Include="Facepunch.Flexbox">
<HintPath>../../ProtobitRust/.references/RustDedicated_Data/Managed/Facepunch.Flexbox.dll</HintPath>
</Reference>
<Reference Include="CurvedTextMeshPro">
<HintPath>../../ProtobitRust/.references/RustDedicated_Data/Managed/CurvedTextMeshPro.dll</HintPath>
</Reference>
<Reference Include="UnityEngine.VideoModule">
<HintPath>../../ProtobitRust/.references/RustDedicated_Data/Managed/UnityEngine.VideoModule.dll</HintPath>
<Reference Include="Rust.UI">
<HintPath>../../../ProtobitRust/.references/RustDedicated_Data/Managed/Rust.UI.dll</HintPath>
</Reference>
<Reference Include="Rust.Workshop">
<HintPath>../../ProtobitRust/.references/RustDedicated_Data/Managed/Rust.Workshop.dll</HintPath>
<HintPath>../../../ProtobitRust/.references/RustDedicated_Data/Managed/Rust.Workshop.dll</HintPath>
</Reference>
<Reference Include="Rust.Platform.Common">
<HintPath>../../../ProtobitRust/.references/RustDedicated_Data/Managed/Rust.Platform.Common.dll</HintPath>
</Reference>
<Reference Include="Facepunch.Console">
<HintPath>../../../ProtobitRust/.references/RustDedicated_Data/Managed/Facepunch.Console.dll</HintPath>
</Reference>
<Reference Include="Rust.Global">
<HintPath>../../../ProtobitRust/.references/RustDedicated_Data/Managed/Rust.Global.dll</HintPath>
</Reference>
<Reference Include="UnityEngine.UIModule">
<HintPath>../../../ProtobitRust/.references/RustDedicated_Data/Managed/UnityEngine.UIModule.dll</HintPath>
</Reference>
<Reference Include="UnityEngine.UI">
<HintPath>../../../ProtobitRust/.references/RustDedicated_Data/Managed/UnityEngine.UI.dll</HintPath>
</Reference>
<Reference Include="Facepunch.Flexbox">
<HintPath>../../../ProtobitRust/.references/RustDedicated_Data/Managed/Facepunch.Flexbox.dll</HintPath>
</Reference>
<Reference Include="Unity.TextMeshPro">
<HintPath>../../../ProtobitRust/.references/RustDedicated_Data/Managed/Unity.TextMeshPro.dll</HintPath>
</Reference>
<Reference Include="Facepunch.Network">
<HintPath>../../../ProtobitRust/.references/RustDedicated_Data/Managed/Facepunch.Network.dll</HintPath>
</Reference>
<Reference Include="UnityEngine.PhysicsModule">
<HintPath>../../../ProtobitRust/.references/RustDedicated_Data/Managed/UnityEngine.PhysicsModule.dll</HintPath>
</Reference>
<Reference Include="Rust.Localization">
<HintPath>../../../ProtobitRust/.references/RustDedicated_Data/Managed/Rust.Localization.dll</HintPath>
</Reference>
<Reference Include="Rust.Data">
<HintPath>../../../ProtobitRust/.references/RustDedicated_Data/Managed/Rust.Data.dll</HintPath>
</Reference>
<Reference Include="System.Core">
<HintPath>../../../ProtobitRust/.references/RustDedicated_Data/Managed/System.Core.dll</HintPath>
</Reference>
<Reference Include="Facepunch.Nexus">
<HintPath>../../../ProtobitRust/.references/RustDedicated_Data/Managed/Facepunch.Nexus.dll</HintPath>
</Reference>
<Reference Include="Facepunch.System">
<HintPath>../../../ProtobitRust/.references/RustDedicated_Data/Managed/Facepunch.System.dll</HintPath>
</Reference>
<Reference Include="Facepunch.Unity">
<HintPath>../../../ProtobitRust/.references/RustDedicated_Data/Managed/Facepunch.Unity.dll</HintPath>
</Reference>
<Reference Include="UnityEngine.ParticleSystemModule">
<HintPath>../../../ProtobitRust/.references/RustDedicated_Data/Managed/UnityEngine.ParticleSystemModule.dll</HintPath>
</Reference>
<Reference Include="UnityEngine.VehiclesModule">
<HintPath>../../../ProtobitRust/.references/RustDedicated_Data/Managed/UnityEngine.VehiclesModule.dll</HintPath>
</Reference>
<Reference Include="Assembly-CSharp-firstpass">
<HintPath>../../../ProtobitRust/.references/RustDedicated_Data/Managed/Assembly-CSharp-firstpass.dll</HintPath>
</Reference>
<Reference Include="UnityEngine.AIModule">
<HintPath>../../../ProtobitRust/.references/RustDedicated_Data/Managed/UnityEngine.AIModule.dll</HintPath>
</Reference>
<Reference Include="Rust.Clans">
<HintPath>../../../ProtobitRust/.references/RustDedicated_Data/Managed/Rust.Clans.dll</HintPath>
</Reference>
<Reference Include="Unity.Collections">
<HintPath>../../../ProtobitRust/.references/RustDedicated_Data/Managed/Unity.Collections.dll</HintPath>
</Reference>
<Reference Include="Unity.Mathematics">
<HintPath>../../../ProtobitRust/.references/RustDedicated_Data/Managed/Unity.Mathematics.dll</HintPath>
</Reference>
<Reference Include="UnityEngine.AudioModule">
<HintPath>../../../ProtobitRust/.references/RustDedicated_Data/Managed/UnityEngine.AudioModule.dll</HintPath>
</Reference>
<Reference Include="Unity.AI.Navigation">
<HintPath>../../../ProtobitRust/.references/RustDedicated_Data/Managed/Unity.AI.Navigation.dll</HintPath>
</Reference>
<Reference Include="Newtonsoft.Json">
<HintPath>../../../ProtobitRust/.references/RustDedicated_Data/Managed/Newtonsoft.Json.dll</HintPath>
</Reference>
<Reference Include="UnityEngine.InputLegacyModule">
<HintPath>../../../ProtobitRust/.references/RustDedicated_Data/Managed/UnityEngine.InputLegacyModule.dll</HintPath>
</Reference>
<Reference Include="Facepunch.Skeleton">
<HintPath>../../../ProtobitRust/.references/RustDedicated_Data/Managed/Facepunch.Skeleton.dll</HintPath>
</Reference>
<Reference Include="Facepunch.BurstCloth">
<HintPath>../../../ProtobitRust/.references/RustDedicated_Data/Managed/Facepunch.BurstCloth.dll</HintPath>
</Reference>
<Reference Include="EZhex1991.EZSoftBone">
<HintPath>../../../ProtobitRust/.references/RustDedicated_Data/Managed/EZhex1991.EZSoftBone.dll</HintPath>
</Reference>
<Reference Include="CurvedTextMeshPro">
<HintPath>../../../ProtobitRust/.references/RustDedicated_Data/Managed/CurvedTextMeshPro.dll</HintPath>
</Reference>
<Reference Include="UnityEngine.VideoModule">
<HintPath>../../../ProtobitRust/.references/RustDedicated_Data/Managed/UnityEngine.VideoModule.dll</HintPath>
</Reference>
<Reference Include="Facepunch.Raknet">
<HintPath>../../ProtobitRust/.references/RustDedicated_Data/Managed/Facepunch.Raknet.dll</HintPath>
<HintPath>../../../ProtobitRust/.references/RustDedicated_Data/Managed/Facepunch.Raknet.dll</HintPath>
</Reference>
<Reference Include="UnityEngine.TerrainModule">
<HintPath>../../ProtobitRust/.references/RustDedicated_Data/Managed/UnityEngine.TerrainModule.dll</HintPath>
<HintPath>../../../ProtobitRust/.references/RustDedicated_Data/Managed/UnityEngine.TerrainModule.dll</HintPath>
</Reference>
<Reference Include="Facepunch.Input">
<HintPath>../../ProtobitRust/.references/RustDedicated_Data/Managed/Facepunch.Input.dll</HintPath>
<HintPath>../../../ProtobitRust/.references/RustDedicated_Data/Managed/Facepunch.Input.dll</HintPath>
</Reference>
<Reference Include="Facepunch.UnwrapBaker.Settings">
<HintPath>../../ProtobitRust/.references/RustDedicated_Data/Managed/Facepunch.UnwrapBaker.Settings.dll</HintPath>
<HintPath>../../../ProtobitRust/.references/RustDedicated_Data/Managed/Facepunch.UnwrapBaker.Settings.dll</HintPath>
</Reference>
<Reference Include="UnityEngine.IMGUIModule">
<HintPath>../../ProtobitRust/.references/RustDedicated_Data/Managed/UnityEngine.IMGUIModule.dll</HintPath>
<HintPath>../../../ProtobitRust/.references/RustDedicated_Data/Managed/UnityEngine.IMGUIModule.dll</HintPath>
</Reference>
<Reference Include="Rust.FileSystem">
<HintPath>../../ProtobitRust/.references/RustDedicated_Data/Managed/Rust.FileSystem.dll</HintPath>
<HintPath>../../../ProtobitRust/.references/RustDedicated_Data/Managed/Rust.FileSystem.dll</HintPath>
</Reference>
<Reference Include="Ionic.Zip.Reduced">
<HintPath>../../ProtobitRust/.references/RustDedicated_Data/Managed/Ionic.Zip.Reduced.dll</HintPath>
<HintPath>../../../ProtobitRust/.references/RustDedicated_Data/Managed/Ionic.Zip.Reduced.dll</HintPath>
</Reference>
<Reference Include="Cronos">
<HintPath>../../ProtobitRust/.references/RustDedicated_Data/Managed/Cronos.dll</HintPath>
<HintPath>../../../ProtobitRust/.references/RustDedicated_Data/Managed/Cronos.dll</HintPath>
</Reference>
<Reference Include="Unity.Burst">
<HintPath>../../ProtobitRust/.references/RustDedicated_Data/Managed/Unity.Burst.dll</HintPath>
<HintPath>../../../ProtobitRust/.references/RustDedicated_Data/Managed/Unity.Burst.dll</HintPath>
</Reference>
<Reference Include="UnityEngine.ClothModule">
<HintPath>../../ProtobitRust/.references/RustDedicated_Data/Managed/UnityEngine.ClothModule.dll</HintPath>
<HintPath>../../../ProtobitRust/.references/RustDedicated_Data/Managed/UnityEngine.ClothModule.dll</HintPath>
</Reference>
<Reference Include="UnityEngine.TerrainPhysicsModule">
<HintPath>../../ProtobitRust/.references/RustDedicated_Data/Managed/UnityEngine.TerrainPhysicsModule.dll</HintPath>
<HintPath>../../../ProtobitRust/.references/RustDedicated_Data/Managed/UnityEngine.TerrainPhysicsModule.dll</HintPath>
</Reference>
<Reference Include="UnityEngine.UnityWebRequestModule">
<HintPath>../../ProtobitRust/.references/RustDedicated_Data/Managed/UnityEngine.UnityWebRequestModule.dll</HintPath>
<HintPath>../../../ProtobitRust/.references/RustDedicated_Data/Managed/UnityEngine.UnityWebRequestModule.dll</HintPath>
</Reference>
<Reference Include="UnityEngine.WindModule">
<HintPath>../../ProtobitRust/.references/RustDedicated_Data/Managed/UnityEngine.WindModule.dll</HintPath>
<HintPath>../../../ProtobitRust/.references/RustDedicated_Data/Managed/UnityEngine.WindModule.dll</HintPath>
</Reference>
<Reference Include="System.Net.Http">
<HintPath>../../ProtobitRust/.references/RustDedicated_Data/Managed/System.Net.Http.dll</HintPath>
<HintPath>../../../ProtobitRust/.references/RustDedicated_Data/Managed/System.Net.Http.dll</HintPath>
</Reference>
<Reference Include="Facepunch.Sqlite">
<HintPath>../../ProtobitRust/.references/RustDedicated_Data/Managed/Facepunch.Sqlite.dll</HintPath>
<HintPath>../../../ProtobitRust/.references/RustDedicated_Data/Managed/Facepunch.Sqlite.dll</HintPath>
</Reference>
<Reference Include="UnityEngine.DirectorModule">
<HintPath>../../ProtobitRust/.references/RustDedicated_Data/Managed/UnityEngine.DirectorModule.dll</HintPath>
<HintPath>../../../ProtobitRust/.references/RustDedicated_Data/Managed/UnityEngine.DirectorModule.dll</HintPath>
</Reference>
<Reference Include="Unity.Timeline">
<HintPath>../../ProtobitRust/.references/RustDedicated_Data/Managed/Unity.Timeline.dll</HintPath>
<HintPath>../../../ProtobitRust/.references/RustDedicated_Data/Managed/Unity.Timeline.dll</HintPath>
</Reference>
<Reference Include="BoomlagoonJSON">
<HintPath>../../../ProtobitRust/.references/RustDedicated_Data/Managed/BoomlagoonJSON.dll</HintPath>
</Reference>
<Reference Include="UnityEngine.UnityWebRequestWWWModule">
<HintPath>../../ProtobitRust/.references/RustDedicated_Data/Managed/UnityEngine.UnityWebRequestWWWModule.dll</HintPath>
<HintPath>../../../ProtobitRust/.references/RustDedicated_Data/Managed/UnityEngine.UnityWebRequestWWWModule.dll</HintPath>
</Reference>
<Reference Include="Facepunch.Steamworks.Posix">
<HintPath>../../ProtobitRust/.references/RustDedicated_Data/Managed/Facepunch.Steamworks.Posix.dll</HintPath>
<HintPath>../../../ProtobitRust/.references/RustDedicated_Data/Managed/Facepunch.Steamworks.Posix.dll</HintPath>
</Reference>
<Reference Include="UnityEngine.TextRenderingModule">
<HintPath>../../ProtobitRust/.references/RustDedicated_Data/Managed/UnityEngine.TextRenderingModule.dll</HintPath>
<HintPath>../../../ProtobitRust/.references/RustDedicated_Data/Managed/UnityEngine.TextRenderingModule.dll</HintPath>
</Reference>
<Reference Include="RTLTMPro">
<HintPath>../../ProtobitRust/.references/RustDedicated_Data/Managed/RTLTMPro.dll</HintPath>
<HintPath>../../../ProtobitRust/.references/RustDedicated_Data/Managed/RTLTMPro.dll</HintPath>
</Reference>
<Reference Include="EasyRoads3Dv3">
<HintPath>../../ProtobitRust/.references/RustDedicated_Data/Managed/EasyRoads3Dv3.dll</HintPath>
<HintPath>../../../ProtobitRust/.references/RustDedicated_Data/Managed/EasyRoads3Dv3.dll</HintPath>
</Reference>
<Reference Include="UnityEngine.Physics2DModule">
<HintPath>../../ProtobitRust/.references/RustDedicated_Data/Managed/UnityEngine.Physics2DModule.dll</HintPath>
<HintPath>../../../ProtobitRust/.references/RustDedicated_Data/Managed/UnityEngine.Physics2DModule.dll</HintPath>
</Reference>
<Reference Include="Fleck">
<HintPath>../../ProtobitRust/.references/RustDedicated_Data/Managed/Fleck.dll</HintPath>
<HintPath>../../../ProtobitRust/.references/RustDedicated_Data/Managed/Fleck.dll</HintPath>
</Reference>
<Reference Include="Facepunch.Rcon">
<HintPath>../../ProtobitRust/.references/RustDedicated_Data/Managed/Facepunch.Rcon.dll</HintPath>
<HintPath>../../../ProtobitRust/.references/RustDedicated_Data/Managed/Facepunch.Rcon.dll</HintPath>
</Reference>
<Reference Include="ZString">
<HintPath>../../ProtobitRust/.references/RustDedicated_Data/Managed/ZString.dll</HintPath>
<HintPath>../../../ProtobitRust/.references/RustDedicated_Data/Managed/ZString.dll</HintPath>
</Reference>
<Reference Include="Azure.Identity">
<HintPath>../../ProtobitRust/.references/RustDedicated_Data/Managed/Azure.Identity.dll</HintPath>
<HintPath>../../../ProtobitRust/.references/RustDedicated_Data/Managed/Azure.Identity.dll</HintPath>
</Reference>
<Reference Include="Azure.Storage.Blobs">
<HintPath>../../ProtobitRust/.references/RustDedicated_Data/Managed/Azure.Storage.Blobs.dll</HintPath>
<HintPath>../../../ProtobitRust/.references/RustDedicated_Data/Managed/Azure.Storage.Blobs.dll</HintPath>
</Reference>
<Reference Include="Azure.Core">
<HintPath>../../ProtobitRust/.references/RustDedicated_Data/Managed/Azure.Core.dll</HintPath>
<HintPath>../../../ProtobitRust/.references/RustDedicated_Data/Managed/Azure.Core.dll</HintPath>
</Reference>
<Reference Include="Facepunch.Ping">
<HintPath>../../ProtobitRust/.references/RustDedicated_Data/Managed/Facepunch.Ping.dll</HintPath>
<HintPath>../../../ProtobitRust/.references/RustDedicated_Data/Managed/Facepunch.Ping.dll</HintPath>
</Reference>
<Reference Include="Rust.Harmony">
<HintPath>../../ProtobitRust/.references/RustDedicated_Data/Managed/Rust.Harmony.dll</HintPath>
<HintPath>../../../ProtobitRust/.references/RustDedicated_Data/Managed/Rust.Harmony.dll</HintPath>
</Reference>
<Reference Include="UnityEngine.UIElementsModule">
<HintPath>../../../ProtobitRust/.references/RustDedicated_Data/Managed/UnityEngine.UIElementsModule.dll</HintPath>
</Reference>
<Reference Include="UIEffect">
<HintPath>../../../ProtobitRust/.references/RustDedicated_Data/Managed/UIEffect.dll</HintPath>
</Reference>
<Reference Include="LeTai.TrueShadow">
<HintPath>../../../ProtobitRust/.references/RustDedicated_Data/Managed/LeTai.TrueShadow.dll</HintPath>
</Reference>
<Reference Include="LZ4">
<HintPath>../../ProtobitRust/.references/RustDedicated_Data/Managed/LZ4.dll</HintPath>
<HintPath>../../../ProtobitRust/.references/RustDedicated_Data/Managed/LZ4.dll</HintPath>
</Reference>
<Reference Include="Rust.Clans.Local">
<HintPath>../../ProtobitRust/.references/RustDedicated_Data/Managed/Rust.Clans.Local.dll</HintPath>
<HintPath>../../../ProtobitRust/.references/RustDedicated_Data/Managed/Rust.Clans.Local.dll</HintPath>
</Reference>
<Reference Include="Rust.Platform">
<HintPath>../../ProtobitRust/.references/RustDedicated_Data/Managed/Rust.Platform.dll</HintPath>
<HintPath>../../../ProtobitRust/.references/RustDedicated_Data/Managed/Rust.Platform.dll</HintPath>
</Reference>
<Reference Include="Rust.Demo">
<HintPath>../../ProtobitRust/.references/RustDedicated_Data/Managed/Rust.Demo.dll</HintPath>
<HintPath>../../../ProtobitRust/.references/RustDedicated_Data/Managed/Rust.Demo.dll</HintPath>
</Reference>
<Reference Include="UnityEngine.ImageConversionModule">
<HintPath>../../ProtobitRust/.references/RustDedicated_Data/Managed/UnityEngine.ImageConversionModule.dll</HintPath>
<HintPath>../../../ProtobitRust/.references/RustDedicated_Data/Managed/UnityEngine.ImageConversionModule.dll</HintPath>
</Reference>
<Reference Include="System.Runtime.CompilerServices.Unsafe">
<HintPath>../../ProtobitRust/.references/RustDedicated_Data/Managed/System.Runtime.CompilerServices.Unsafe.dll</HintPath>
<HintPath>../../../ProtobitRust/.references/RustDedicated_Data/Managed/System.Runtime.CompilerServices.Unsafe.dll</HintPath>
</Reference>
<Reference Include="TimeZoneConverter">
<HintPath>../../ProtobitRust/.references/RustDedicated_Data/Managed/TimeZoneConverter.dll</HintPath>
<HintPath>../../../ProtobitRust/.references/RustDedicated_Data/Managed/TimeZoneConverter.dll</HintPath>
</Reference>
<Reference Include="Facepunch.SteamNetworking">
<HintPath>../../ProtobitRust/.references/RustDedicated_Data/Managed/Facepunch.SteamNetworking.dll</HintPath>
<HintPath>../../../ProtobitRust/.references/RustDedicated_Data/Managed/Facepunch.SteamNetworking.dll</HintPath>
</Reference>
<Reference Include="UnityEngine.JSONSerializeModule">
<HintPath>../../ProtobitRust/.references/RustDedicated_Data/Managed/UnityEngine.JSONSerializeModule.dll</HintPath>
<HintPath>../../../ProtobitRust/.references/RustDedicated_Data/Managed/UnityEngine.JSONSerializeModule.dll</HintPath>
</Reference>
<Reference Include="UnityEngine.TilemapModule">
<HintPath>../../ProtobitRust/.references/RustDedicated_Data/Managed/UnityEngine.TilemapModule.dll</HintPath>
<HintPath>../../../ProtobitRust/.references/RustDedicated_Data/Managed/UnityEngine.TilemapModule.dll</HintPath>
</Reference>
</ItemGroup>
</Project>

View file

@ -52,19 +52,6 @@ public class AttackEntity : HeldEntity
private EncryptedValue<float> nextAttackTime = float.NegativeInfinity;
protected bool UsingInfiniteAmmoCheat
{
get
{
BasePlayer ownerPlayer = GetOwnerPlayer();
if (ownerPlayer == null || (!ownerPlayer.IsAdmin && !ownerPlayer.IsDeveloper))
{
return false;
}
return ownerPlayer.GetInfoBool("player.infiniteammo", defaultVal: false);
}
}
public float NextAttackTime => nextAttackTime;
public virtual Vector3 GetInheritedVelocity(BasePlayer player, Vector3 direction)

View file

@ -384,12 +384,23 @@ public class AttackHelicopter : PlayerHelicopter
public override void OnFlagsChanged(Flags old, Flags next)
{
base.OnFlagsChanged(old, next);
if (base.isServer)
if (!base.isServer)
{
VehicleEngineController<PlayerHelicopter>.EngineState engineState = engineController.EngineStateFrom(old);
if (engineController.CurEngineState != engineState)
return;
}
VehicleEngineController<PlayerHelicopter>.EngineState engineState = engineController.EngineStateFrom(old);
if (engineController.CurEngineState == engineState)
{
return;
}
SetFlag(Flags.Reserved5, engineController.IsStartingOrOn);
AttackHelicopterTurret turret = GetTurret();
if ((bool)turret && !engineController.IsStartingOrOn)
{
HeldEntity attachedHeldEntity = turret.GetAttachedHeldEntity();
if ((bool)attachedHeldEntity && attachedHeldEntity is ITurretNotify turretNotify)
{
SetFlag(Flags.Reserved5, engineController.IsStartingOrOn);
turretNotify.OnAddedRemovedToTurret(added: false);
}
}
}
@ -499,6 +510,22 @@ public class AttackHelicopter : PlayerHelicopter
WeaponFireFailed(rockets.GetRocketAmount(), player);
}
}
else
{
if (!IsOn() || GunnerIsInGunnerView)
{
return;
}
AttackHelicopterTurret turret2 = GetTurret();
if ((bool)turret2)
{
HeldEntity attachedHeldEntity = turret2.GetAttachedHeldEntity();
if ((bool)attachedHeldEntity && attachedHeldEntity is ITurretNotify turretNotify)
{
turretNotify.WarmupTick(wantsShoot: false);
}
}
}
}
private void WeaponFireFailed(int ammo, BasePlayer player)
@ -551,6 +578,22 @@ public class AttackHelicopter : PlayerHelicopter
{
SetFlag(Flags.Reserved9, b: false);
}
else
{
if (!IsPassenger(player))
{
return;
}
AttackHelicopterTurret turret = GetTurret();
if ((bool)turret)
{
HeldEntity attachedHeldEntity = turret.GetAttachedHeldEntity();
if ((bool)attachedHeldEntity && attachedHeldEntity is ITurretNotify turretNotify)
{
turretNotify.OnAddedRemovedToTurret(added: false);
}
}
}
}
internal override void DoServerDestroy()

View file

@ -214,6 +214,10 @@ public class AttackHelicopterTurret : StorageContainer
{
result = TryFireWeapon();
}
else if (GetAttachedHeldEntity() is ITurretNotify turretNotify)
{
turretNotify.WarmupTick(wantsShoot: false);
}
input.eyeRay.direction = ClampEyeAngle(owner.transform, input.eyeRay.direction, owner.turretPitchClamp, owner.turretYawClamp);
Vector3 bulletHitPoint = Ballistics.GetBulletHitPoint(input.eyeRay);
bulletHitPoint.y -= muzzleYOffset;
@ -275,6 +279,10 @@ public class AttackHelicopterTurret : StorageContainer
{
heldEntity2.SetGenericVisible(wantsVis: false);
heldEntity2.SetLightsOn(isOn: false);
if (heldEntity2 is ITurretNotify turretNotify)
{
turretNotify.WarmupTick(wantsShoot: false);
}
}
attachedHeldEntity.Set(null);
muzzleYOffset = 0f;
@ -314,6 +322,14 @@ public class AttackHelicopterTurret : StorageContainer
{
return false;
}
if (baseProjectile is ITurretNotify turretNotify)
{
turretNotify.WarmupTick(wantsShoot: true);
if (!turretNotify.CanShoot())
{
return false;
}
}
}
heldEntity.ServerUse();
GetAmmoAmounts(out var clip, out var available);

View file

@ -4,6 +4,7 @@ using ConVar;
using Facepunch.Extend;
using Facepunch.Math;
using Network;
using ProtoBuf;
using UnityEngine;
using UnityEngine.Networking;
@ -17,6 +18,8 @@ public static class Auth_CentralizedBans
public string reason;
public long expiryDate;
public bool isMute;
}
private static readonly BanPayload payloadData = new BanPayload();
@ -94,6 +97,7 @@ public static class Auth_CentralizedBans
payloadData.steamId = 0uL;
payloadData.reason = null;
payloadData.expiryDate = 0L;
payloadData.isMute = false;
JsonUtility.FromJsonOverwrite(request.downloadHandler.text, payloadData);
if (payloadData.expiryDate > 0 && Epoch.Current >= payloadData.expiryDate)
{
@ -111,7 +115,23 @@ public static class Auth_CentralizedBans
}
string text = payloadData.reason ?? "no reason given";
string text2 = ((payloadData.expiryDate > 0) ? (" for " + (payloadData.expiryDate - Epoch.Current).FormatSecondsLong()) : "");
Reject("You are banned from this server" + text2 + " (" + text + ")");
if (payloadData.isMute)
{
PlayerState playerState = SingletonComponent<ServerMgr>.Instance.playerStateManager.Get(steamId);
playerState.chatMuted = true;
if (payloadData.expiryDate > 0)
{
playerState.chatMuteExpiryTimestamp = payloadData.expiryDate;
}
else
{
playerState.chatMuteExpiryTimestamp = 0.0;
}
}
else
{
Reject("You are banned from this server" + text2 + " (" + text + ")");
}
return true;
}
catch (Exception exception)

View file

@ -34,6 +34,12 @@ public class AutoTurret : ContainerIOEntity, IRemoteControllable, IHostileWarnin
}
}
private enum YawPitchMode
{
Separate,
Merged
}
public GameObjectRef gun_fire_effect;
public GameObjectRef bulletEffect;
@ -157,15 +163,25 @@ public class AutoTurret : ContainerIOEntity, IRemoteControllable, IHostileWarnin
private const float SlowProjectileSpeedThreshold = 100f;
private Matrix4x4 gunRoot;
protected Transform cachedTransf;
private Matrix4x4 gunAimInitialLS;
private YawPitchMode rotateMode;
private Quaternion gunAimInitialRot;
private Matrix4x4 toYawFromRoot;
private Quaternion gunAimRotLS;
private Matrix4x4 toPitchFromRootOrYaw;
private Transform cachedTransf;
private Matrix4x4 toRCEyesFromPitch;
private Quaternion gunAimInitialYawRot;
private Quaternion gunAimInitialPitchOrTotalRot;
private Quaternion gunAimYawRotLS;
private Quaternion gunAimPitchOrTotalRotLS;
private Quaternion gunAimTotalRotWS;
private double nextForcedAimTime;
@ -591,7 +607,12 @@ public class AutoTurret : ContainerIOEntity, IRemoteControllable, IHostileWarnin
{
if (base.isServer)
{
return cachedTransf.localToWorldMatrix * gunAimInitialLS * Matrix4x4.Rotate(gunAimRotLS);
Matrix4x4 localToWorldMatrix = cachedTransf.localToWorldMatrix;
if (rotateMode == YawPitchMode.Separate)
{
return localToWorldMatrix * toYawFromRoot * Matrix4x4.Rotate(gunAimYawRotLS) * toPitchFromRootOrYaw * Matrix4x4.Rotate(gunAimPitchOrTotalRotLS);
}
return localToWorldMatrix * toPitchFromRootOrYaw * Matrix4x4.Rotate(gunAimPitchOrTotalRotLS);
}
return gun_pitch.localToWorldMatrix;
}
@ -724,14 +745,26 @@ public class AutoTurret : ContainerIOEntity, IRemoteControllable, IHostileWarnin
speed = ((!HasTarget()) ? 15f : 35f);
}
Quaternion quaternion = Quaternion.LookRotation(aimDir);
if (base.isServer)
if (!base.isServer)
{
Quaternion quaternion2 = Quaternion.Inverse(cachedTransf.rotation * gunAimInitialRot) * quaternion;
if (gunAimRotLS != quaternion2)
return;
}
Quaternion rotation = cachedTransf.rotation;
if (rotateMode == YawPitchMode.Merged)
{
Quaternion quaternion2 = Quaternion.Inverse(rotation * gunAimInitialPitchOrTotalRot) * quaternion;
if (gunAimPitchOrTotalRotLS != quaternion2)
{
gunAimRotLS = Mathx.Lerp(gunAimRotLS, quaternion2, speed, dt);
gunAimPitchOrTotalRotLS = Mathx.Lerp(gunAimPitchOrTotalRotLS, quaternion2, speed, dt);
}
}
else if (gunAimTotalRotWS != quaternion)
{
gunAimTotalRotWS = Mathx.Lerp(gunAimTotalRotWS, quaternion, speed, dt);
Vector3 eulerAngles = (Quaternion.Inverse(rotation * gunAimInitialYawRot) * gunAimTotalRotWS).eulerAngles;
gunAimYawRotLS = Quaternion.Euler(0f, eulerAngles.y, 0f);
gunAimPitchOrTotalRotLS = Quaternion.Euler(eulerAngles.x, 0f, 0f);
}
}
public bool IsAuthed(ulong id)
@ -866,44 +899,55 @@ public class AutoTurret : ContainerIOEntity, IRemoteControllable, IHostileWarnin
}
else
{
if (EnsureReloaded() || !inputState.IsDown(BUTTON.FIRE_PRIMARY))
if (EnsureReloaded())
{
return;
}
BaseProjectile attachedWeapon = GetAttachedWeapon();
if ((bool)attachedWeapon)
if (inputState.IsDown(BUTTON.FIRE_PRIMARY))
{
float damageModifier = 1f;
float speedModifier = 1f;
ItemDefinition ammoType = attachedWeapon.primaryMagazine.ammoType;
if ((bool)ammoType)
if ((bool)attachedWeapon)
{
ItemModProjectile component = ammoType.GetComponent<ItemModProjectile>();
if ((bool)component && component.projectileVelocity < 100f)
if (attachedWeapon is ITurretNotify turretNotify)
{
speedModifier = 2f;
turretNotify.WarmupTick(wantsShoot: true);
}
float damageModifier = 1f;
float speedModifier = 1f;
ItemDefinition ammoType = attachedWeapon.primaryMagazine.ammoType;
if ((bool)ammoType)
{
ItemModProjectile component = ammoType.GetComponent<ItemModProjectile>();
if ((bool)component && component.projectileVelocity < 100f)
{
speedModifier = 2f;
}
}
if (attachedWeapon.primaryMagazine.contents > 0)
{
FireAttachedGun(Vector3.zero, aimCone, null, damageModifier, speedModifier);
float delay = (attachedWeapon.isSemiAuto ? (attachedWeapon.repeatDelay * 1.5f) : attachedWeapon.repeatDelay);
delay = attachedWeapon.ScaleRepeatDelay(delay);
nextShotTime = timeAsDouble + (double)delay;
}
else
{
nextShotTime = timeAsDouble + 5.0;
}
}
if (attachedWeapon.primaryMagazine.contents > 0)
else if (HasGenericFireable())
{
FireAttachedGun(Vector3.zero, aimCone, null, damageModifier, speedModifier);
float delay = (attachedWeapon.isSemiAuto ? (attachedWeapon.repeatDelay * 1.5f) : attachedWeapon.repeatDelay);
delay = attachedWeapon.ScaleRepeatDelay(delay);
nextShotTime = timeAsDouble + (double)delay;
AttachedWeapon.ServerUse();
nextShotTime = timeAsDouble + 0.11500000208616257;
}
else
{
nextShotTime = timeAsDouble + 5.0;
nextShotTime = timeAsDouble + 1.0;
}
}
else if (HasGenericFireable())
else if ((bool)attachedWeapon && attachedWeapon is ITurretNotify turretNotify2)
{
AttachedWeapon.ServerUse();
nextShotTime = timeAsDouble + 0.11500000208616257;
}
else
{
nextShotTime = timeAsDouble + 1.0;
turretNotify2.WarmupTick(wantsShoot: false);
}
}
}
@ -1023,6 +1067,11 @@ public class AutoTurret : ContainerIOEntity, IRemoteControllable, IHostileWarnin
public void SetIsOnline(bool online)
{
BaseProjectile attachedWeapon = GetAttachedWeapon();
if ((bool)attachedWeapon && attachedWeapon is ITurretNotify turretNotify)
{
turretNotify.OnAddedRemovedToTurret(online);
}
if (online != IsOn())
{
SetFlag(Flags.On, online);
@ -1348,12 +1397,24 @@ public class AutoTurret : ContainerIOEntity, IRemoteControllable, IHostileWarnin
targetTrigger.GetComponent<SphereCollider>().radius = sightRange;
UpdateNearbyTurrets(created: true);
cachedTransf = base.transform;
gunRoot = cachedTransf.localToWorldMatrix;
Matrix4x4 matrix4x = gun_yaw.localToWorldMatrix * gunRoot.inverse;
Matrix4x4 matrix4x2 = Matrix4x4.TRS(gun_pitch.localPosition, gun_pitch.localRotation, gun_pitch.localScale);
gunAimInitialLS = matrix4x2 * matrix4x;
gunAimRotLS = gunAimInitialLS.rotation;
gunAimInitialRot = gunAimRotLS;
rotateMode = ((gun_pitch.localPosition.x == 0f && gun_pitch.localPosition.z == 0f) ? YawPitchMode.Merged : YawPitchMode.Separate);
if (rotateMode == YawPitchMode.Merged)
{
toPitchFromRootOrYaw = cachedTransf.worldToLocalMatrix * gun_pitch.localToWorldMatrix;
gunAimInitialPitchOrTotalRot = toPitchFromRootOrYaw.rotation;
}
else
{
toYawFromRoot = base.transform.root.worldToLocalMatrix * gun_yaw.localToWorldMatrix;
gunAimInitialYawRot = toYawFromRoot.rotation;
toPitchFromRootOrYaw = gun_yaw.worldToLocalMatrix * gun_pitch.localToWorldMatrix;
gunAimInitialPitchOrTotalRot = toPitchFromRootOrYaw.rotation;
gunAimTotalRotWS = gun_pitch.rotation;
}
if ((bool)RCEyes)
{
toRCEyesFromPitch = gun_pitch.worldToLocalMatrix * RCEyes.localToWorldMatrix;
}
}
internal override void DoServerDestroy()
@ -1456,10 +1517,14 @@ public class AutoTurret : ContainerIOEntity, IRemoteControllable, IHostileWarnin
public virtual void FireAttachedGun(Vector3 targetPos, float aimCone, BaseCombatEntity target = null, float damageModifier = 1f, float speedModifier = 1f)
{
BaseProjectile attachedWeapon = GetAttachedWeapon();
if (!(attachedWeapon == null) && !IsOffline())
if (!(attachedWeapon == null) && !IsOffline() && (!(attachedWeapon is ITurretNotify turretNotify) || turretNotify.CanShoot()))
{
Matrix4x4 value = (IsBeingControlled ? RCEyes.localToWorldMatrix : GetCenterMuzzle());
attachedWeapon.ServerUse(damageModifier, speedModifier, value, useBulletThickness: false);
Matrix4x4 centerMuzzle = GetCenterMuzzle();
if (IsBeingControlled)
{
centerMuzzle *= toRCEyesFromPitch;
}
attachedWeapon.ServerUse(damageModifier, speedModifier, centerMuzzle, useBulletThickness: false);
}
}
@ -1550,6 +1615,11 @@ public class AutoTurret : ContainerIOEntity, IRemoteControllable, IHostileWarnin
public void IdleTick(float dt)
{
BaseProjectile attachedWeapon = GetAttachedWeapon();
if ((bool)attachedWeapon && attachedWeapon is ITurretNotify turretNotify)
{
turretNotify.WarmupTick(wantsShoot: false);
}
double realtimeSinceStartupAsDouble = UnityEngine.Time.realtimeSinceStartupAsDouble;
if (realtimeSinceStartupAsDouble > nextIdleAimTime)
{
@ -1801,6 +1871,10 @@ public class AutoTurret : ContainerIOEntity, IRemoteControllable, IHostileWarnin
{
attachedWeapon.SetGenericVisible(wantsVis: false);
attachedWeapon.SetLightsOn(isOn: false);
if (attachedWeapon is ITurretNotify turretNotify)
{
turretNotify.OnAddedRemovedToTurret(added: false);
}
}
AttachedWeapon = null;
}
@ -1850,6 +1924,10 @@ public class AutoTurret : ContainerIOEntity, IRemoteControllable, IHostileWarnin
transform.localPosition += Vector3.forward * num * zOffsetScale;
heldEntity.SetGenericVisible(wantsVis: true);
heldEntity.SetLightsOn(isOn: true);
if (heldEntity is ITurretNotify turretNotify)
{
turretNotify.OnAddedRemovedToTurret(added: true);
}
return heldEntity;
}
@ -1860,6 +1938,10 @@ public class AutoTurret : ContainerIOEntity, IRemoteControllable, IHostileWarnin
{
attachedWeapon.SetGenericVisible(wantsVis: false);
attachedWeapon.SetLightsOn(isOn: false);
if (attachedWeapon is ITurretNotify turretNotify)
{
turretNotify.OnAddedRemovedToTurret(added: false);
}
}
AttachedWeapon = null;
base.OnDied(info);
@ -1909,6 +1991,10 @@ public class AutoTurret : ContainerIOEntity, IRemoteControllable, IHostileWarnin
}
if ((bool)attachedWeapon)
{
if (attachedWeapon is ITurretNotify turretNotify)
{
turretNotify.WarmupTick(wantsShoot: true);
}
float damageModifier = 1f;
float speedModifier = 1f;
ItemDefinition ammoType = attachedWeapon.primaryMagazine.ammoType;

View file

@ -324,6 +324,13 @@ public class BallistaGun : BaseVehicleSeat
}
using (TimeWarning.New("SERVER_SwitchAmmoTo"))
{
using (TimeWarning.New("Conditions"))
{
if (!RPC_Server.CallsPerSecond.Test(4118009042u, "SERVER_SwitchAmmoTo", this, player, 5uL))
{
return true;
}
}
try
{
using (TimeWarning.New("Call"))
@ -765,6 +772,7 @@ public class BallistaGun : BaseVehicleSeat
}
[RPC_Server]
[RPC_Server.CallsPerSecond(5uL)]
private void SERVER_SwitchAmmoTo(RPCMessage msg)
{
BasePlayer player = msg.player;

View file

@ -35,7 +35,7 @@ public class BaseCombatEntity : BaseEntity
{
public bool enabled;
[ItemSelector(ItemCategory.All)]
[ItemSelector]
public ItemDefinition itemTarget;
public int itemCount;
@ -64,10 +64,10 @@ public class BaseCombatEntity : BaseEntity
{
public bool enabled;
[ItemSelector(ItemCategory.All)]
[ItemSelector]
public ItemDefinition itemTarget;
[ItemSelector(ItemCategory.All)]
[ItemSelector]
public ItemDefinition ignoreForRepair;
public GameObjectRef repairEffect;
@ -405,6 +405,7 @@ public class BaseCombatEntity : BaseEntity
info.msg.baseCombat = Facepunch.Pool.Get<BaseCombat>();
info.msg.baseCombat.state = (int)lifestate;
info.msg.baseCombat.health = Health();
info.msg.baseCombat.maxHealth = MaxHealth();
if (ItemOwnership.IsValid())
{
info.msg.ownership = Facepunch.Pool.Get<ItemOwnershipAmount>();
@ -442,6 +443,10 @@ public class BaseCombatEntity : BaseEntity
{
lifestate = (LifeState)info.msg.baseCombat.state;
_health = info.msg.baseCombat.health;
if (info.msg.baseCombat.maxHealth != 0f)
{
_maxHealth = info.msg.baseCombat.maxHealth;
}
}
base.Load(info);
if (info.msg.ownership != null)
@ -479,6 +484,7 @@ public class BaseCombatEntity : BaseEntity
{
_maxHealth = newMax;
_health = Mathf.Min(_health, newMax);
SendNetworkUpdate();
}
public void DoHitNotify(HitInfo info)

View file

@ -85,12 +85,21 @@ public class BaseDiggableEntity : BaseCombatEntity
{
return null;
}
Item item2 = ItemManager.Create(item.Value.Item, Random.Range(item.Value.Min, item.Value.Max + 1), 0uL);
item2.SetItemOwnership(player, ItemOwnershipPhrases.MetalDetector);
Item item2 = ItemManager.Create(item.Value.Item, Random.Range(item.Value.Min, item.Value.Max + 1), item.Value.Skin);
if (item.Value.Owner.HasValue)
{
ItemOwnershipShare value = item.Value.Owner.Value;
item2.AddItemOwnership(value.username, value.reason, value.amount);
}
item2.AddItemOwnership(player, ItemOwnershipPhrases.MetalDetector);
if (item.Value.Condition.HasValue)
{
item2.condition = item.Value.Condition.Value;
}
DroppedItem droppedItem = null;
if (item2 != null)
{
if (item2.hasCondition)
if (item2.hasCondition && !item.Value.Condition.HasValue)
{
item2.condition = Random.Range(item2.info.condition.foundCondition.fractionMin, item2.info.condition.foundCondition.fractionMax) * item2.info.condition.max;
}
@ -100,6 +109,10 @@ public class BaseDiggableEntity : BaseCombatEntity
droppedItem.NeverCombine = true;
droppedItem.SetAngularVelocity(new Vector3(Random.Range(-1f, 1f), Random.Range(-1f, 1f), Random.Range(-1f, 1f)) * 720f);
}
if (item.Value.UID.HasValue)
{
BuriedItems.Instance.UnregisterItem(item.Value.UID.Value);
}
}
return droppedItem;
}
@ -119,6 +132,10 @@ public class BaseDiggableEntity : BaseCombatEntity
obj.AddRange(lootList.GetItems());
}
}
if ((bool)BuriedItems.Instance)
{
BuriedItems.Instance.AddItems(obj, digWorldPos);
}
DiggableEntityLoot.ItemEntry? result = null;
if (obj.Count != 0)
{

View file

@ -8,6 +8,7 @@ using System.Runtime.CompilerServices;
using ConVar;
using Facepunch;
using Facepunch.Extend;
using Facepunch.Rust;
using Network;
using ProtoBuf;
using Rust;
@ -1066,6 +1067,8 @@ public class BaseEntity : BaseNetworkable, IOnParentSpawning, IPrefabPreProcess
}
}
bool IPrefabPreProcess.CanRunDuringBundling => false;
public virtual TraitFlag Traits => TraitFlag.None;
public float Weight { get; protected set; }
@ -2685,25 +2688,42 @@ public class BaseEntity : BaseNetworkable, IOnParentSpawning, IPrefabPreProcess
{
Debug.Log("SV_RPCMessage: From invalid player " + basePlayer);
}
return;
}
else if (ConVar.AntiHack.rpcstallmode > 0 && basePlayer.isStalled)
if (ConVar.AntiHack.rpcstallmode > 0 && basePlayer.isStalled)
{
if (ConVar.Global.developer > 0)
{
Debug.Log("SV_RPCMessage: player is stalled " + basePlayer);
}
return;
}
else if (ConVar.AntiHack.rpcstallmode > 1 && basePlayer.wasStalled)
if (ConVar.AntiHack.rpcstallmode > 1 && basePlayer.wasStalled)
{
if (ConVar.Global.developer > 0)
{
Debug.Log("SV_RPCMessage: player was stalled " + basePlayer);
}
return;
}
else if (!OnRpcMessage(basePlayer, nameID, message))
(byte[], int) buffer = message.read.GetBuffer();
if (OnRpcMessage(basePlayer, nameID, message))
{
for (int i = 0; i < Components.Count && !Components[i].OnRpcMessage(basePlayer, nameID, message); i++)
if (!basePlayer.IsRealNull())
{
Analytics.Azure.OnServerRPC(basePlayer, nameID, buffer.Item1, buffer.Item2);
}
return;
}
for (int i = 0; i < Components.Count; i++)
{
if (Components[i].OnRpcMessage(basePlayer, nameID, message))
{
if (!basePlayer.IsRealNull())
{
Analytics.Azure.OnServerRPC(basePlayer, nameID, buffer.Item1, buffer.Item2);
}
break;
}
}
}
@ -3186,6 +3206,13 @@ public class BaseEntity : BaseNetworkable, IOnParentSpawning, IPrefabPreProcess
entitySlots[6].uid = info.msg.entitySlots.lowerCenterDecoration;
entitySlots[7].uid = info.msg.entitySlots.storageMonitor;
}
else
{
for (int i = 0; i < entitySlots.Length; i++)
{
entitySlots[i] = default(EntityRef);
}
}
if (info.msg.parent != null)
{
if (base.isServer)
@ -3233,11 +3260,11 @@ public class BaseEntity : BaseNetworkable, IOnParentSpawning, IPrefabPreProcess
{
return;
}
for (int i = 0; i < Components.Count; i++)
for (int j = 0; j < Components.Count; j++)
{
if (!(Components[i] == null))
if (!(Components[j] == null))
{
Components[i].LoadComponent(info);
Components[j].LoadComponent(info);
}
}
}
@ -3396,6 +3423,10 @@ public class BaseEntity : BaseNetworkable, IOnParentSpawning, IPrefabPreProcess
{
base.gameObject.BroadcastOnParentSpawning();
}
for (int i = 0; i < entitySlots.Length; i++)
{
entitySlots[i] = default(EntityRef);
}
}
public void OnParentSpawning()
@ -3409,7 +3440,7 @@ public class BaseEntity : BaseNetworkable, IOnParentSpawning, IPrefabPreProcess
UnityEngine.Object.Destroy(base.gameObject);
return;
}
if (GameManager.server.preProcessed.NeedsProcessing(base.gameObject))
if (GameManager.server.preProcessed.NeedsProcessing(base.gameObject, PreProcessPrefabOptions.Default_NoResetPosition))
{
GameManager.server.preProcessed.ProcessObject(null, base.gameObject, PreProcessPrefabOptions.Default_NoResetPosition);
}
@ -3425,7 +3456,7 @@ public class BaseEntity : BaseNetworkable, IOnParentSpawning, IPrefabPreProcess
{
if (net == null && !base.IsDestroyed && ((base.transform.parent != null) ? base.transform.parent.GetComponentInParent<BaseEntity>() : null) == null)
{
if (GameManager.server.preProcessed.NeedsProcessing(base.gameObject))
if (GameManager.server.preProcessed.NeedsProcessing(base.gameObject, PreProcessPrefabOptions.Default_NoResetPosition))
{
GameManager.server.preProcessed.ProcessObject(null, base.gameObject, PreProcessPrefabOptions.Default_NoResetPosition);
}
@ -4784,6 +4815,19 @@ public class BaseEntity : BaseNetworkable, IOnParentSpawning, IPrefabPreProcess
}
}
public void ClientRPC(RpcTarget target, bool arg1, bool arg2)
{
if (Network.Net.sv.IsConnected() && net != null)
{
GetRpcTargetNetworkGroup(ref target);
NetWrite netWrite = ClientRPCStart(target.Function);
netWrite.Bool(arg1);
netWrite.Bool(arg2);
ClientRPCSend(netWrite, target.Connections);
FreeRPCTarget(target);
}
}
public void ClientRPC(RpcTarget target, ulong arg1, int arg2)
{
if (Network.Net.sv.IsConnected() && net != null)
@ -5129,19 +5173,6 @@ public class BaseEntity : BaseNetworkable, IOnParentSpawning, IPrefabPreProcess
}
}
public void ClientRPC(RpcTarget target, bool arg1, bool arg2)
{
if (Network.Net.sv.IsConnected() && net != null)
{
GetRpcTargetNetworkGroup(ref target);
NetWrite netWrite = ClientRPCStart(target.Function);
netWrite.Bool(arg1);
netWrite.Bool(arg2);
ClientRPCSend(netWrite, target.Connections);
FreeRPCTarget(target);
}
}
public void ClientRPC(RpcTarget target, float arg1, float arg2, byte arg3, float arg4, byte arg5, float arg6)
{
if (Network.Net.sv.IsConnected() && net != null)

View file

@ -27,6 +27,40 @@ public class BaseGameMode : BaseEntity
public PlayerInventoryProperties[] teamloadouts;
}
[Serializable]
public struct ItemRestriction
{
public ItemDefinition Definition;
public EraRestriction Restriction;
}
[Serializable]
public struct LootTypeModifier
{
public ItemDefinition.LootDistributionModifierType LootType;
public int Modifier;
}
[Serializable]
public struct CraftingCostMultiplier
{
public ItemDefinition.LootDistributionModifierType LootType;
[Range(0f, 20f)]
public float Multiplier;
[Tooltip("Will override the Multiplier if set")]
public CraftingCostConVar ConVarToUse;
}
public enum CraftingCostConVar
{
None,
HardcoreFirearmAmmunition
}
private GameMode gameModeScores;
public string[] scoreColumns;
@ -140,12 +174,29 @@ public class BaseGameMode : BaseEntity
public float corpseRemovalTimeOverride;
public bool canRepairIfCraftingBanned;
public bool hasKillFeed;
[Header("Map")]
public bool allowPings = true;
public bool fogOfWar;
public float fogOfWarRevealSize = 256f;
public bool mapMarkers = true;
public bool hidePlayerOnMap;
public bool hideMapPlayerDirectionIndicator;
public bool hideUndergroundOnMap;
public BaseMission[] blockedMissions = new BaseMission[0];
public TechTreeData[] allowedTechTrees = new TechTreeData[0];
public static BaseGameMode svActiveGameMode = null;
public static List<BaseGameMode> svGameModeManifest = new List<BaseGameMode>();
@ -167,6 +218,12 @@ public class BaseGameMode : BaseEntity
public GameModeTeam[] teams;
public ItemRestriction[] Restrictions;
public LootTypeModifier[] LootDistributionModifiers = new LootTypeModifier[0];
public CraftingCostMultiplier[] CraftingCostModifiers = new CraftingCostMultiplier[0];
private static bool isResetting = false;
public static event Action<BaseGameMode> GameModeChanged;
@ -568,31 +625,34 @@ public class BaseGameMode : BaseEntity
Invoke(DeleteEntities, 5f);
return;
}
MonumentInfo[] array = TerrainMeta.Path.Monuments.Where((MonumentInfo x) => x.IsSafeZone).ToArray();
foreach (MonumentInfo monumentInfo in array)
foreach (MonumentInfo monument in TerrainMeta.Path.Monuments)
{
List<BaseEntity> list = new List<BaseEntity>();
Vis.Entities(new OBB(monumentInfo.transform, monumentInfo.Bounds), list);
foreach (BaseEntity item in list)
if (monument.IsSafeZone && !safeZone)
{
if (!safeZone && (item is HumanNPC || item is NPCAutoTurret || item is Marketplace))
List<BaseEntity> list = new List<BaseEntity>();
Vis.Entities(new OBB(monument.transform, monument.Bounds), list);
foreach (BaseEntity item in list)
{
item.Kill();
if (item is HumanNPC || item is NPCAutoTurret || item is Marketplace)
{
item.Kill();
}
else if (!missionSystem && item is NPCSimpleMissionProvider)
{
item.Kill();
}
}
}
if (!safeZone)
{
NPCSpawner[] componentsInChildren = monumentInfo.GetComponentsInChildren<NPCSpawner>();
for (int num2 = 0; num2 < componentsInChildren.Length; num2++)
NPCSpawner[] componentsInChildren = monument.GetComponentsInChildren<NPCSpawner>();
for (int i = 0; i < componentsInChildren.Length; i++)
{
componentsInChildren[num2].isSpawnerActive = false;
componentsInChildren[i].isSpawnerActive = false;
}
}
if (mlrs)
{
continue;
}
IndividualSpawner[] componentsInChildren2 = monumentInfo.GetComponentsInChildren<IndividualSpawner>();
IndividualSpawner[] componentsInChildren2 = monument.GetComponentsInChildren<IndividualSpawner>();
foreach (IndividualSpawner individualSpawner in componentsInChildren2)
{
if (individualSpawner.entityPrefab.isValid && individualSpawner.entityPrefab.GetEntity() is MLRS)
@ -601,15 +661,30 @@ public class BaseGameMode : BaseEntity
}
}
}
foreach (BaseNetworkable serverEntity in BaseNetworkable.serverEntities)
BaseNetworkable[] array = BaseNetworkable.serverEntities.ToArray();
foreach (BaseNetworkable baseNetworkable in array)
{
if (!mlrs && serverEntity is MLRS)
if (!mlrs && baseNetworkable is MLRS)
{
serverEntity.Kill();
baseNetworkable.Kill();
}
if (!missionSystem && serverEntity is NPCMissionProvider)
if (!missionSystem && baseNetworkable is NPCMissionProvider)
{
serverEntity.Kill();
baseNetworkable.Kill();
}
}
if (mlrs)
{
return;
}
for (int j = 0; j < SingletonComponent<SpawnHandler>.Instance.SpawnIndividuals.Count; j++)
{
SpawnIndividual spawnIndividual = SingletonComponent<SpawnHandler>.Instance.SpawnIndividuals[j];
GameObject gameObject = GameManager.server.FindPrefab(spawnIndividual.PrefabID);
if (gameObject != null && gameObject.GetComponent<MLRS>() != null)
{
SingletonComponent<SpawnHandler>.Instance.SpawnIndividuals.RemoveAt(j);
j--;
}
}
}
@ -764,6 +839,15 @@ public class BaseGameMode : BaseEntity
}
}
public static uint GetActiveGameModeId(bool serverside)
{
if (!(svActiveGameMode != null))
{
return 0u;
}
return svActiveGameMode.prefabID;
}
public static BaseGameMode GetActiveGameMode(bool serverside)
{
return svActiveGameMode;
@ -864,7 +948,7 @@ public class BaseGameMode : BaseEntity
{
try
{
ConsoleSystem.Run(ConsoleSystem.Option.Server, convar);
ConsoleSystem.Run(ConsoleSystem.Option.Server, convar.ToLower());
}
catch (Exception exception)
{
@ -982,15 +1066,18 @@ public class BaseGameMode : BaseEntity
Invoke(ResetMatch, timeBetweenMatches);
}
public virtual void OnNewPlayer(BasePlayer player)
public virtual void OnNewPlayer(BasePlayer player, bool shouldSpawnNow)
{
player.Respawn();
if (!AllowsSleeping())
if (shouldSpawnNow)
{
player.EndSleeping();
player.SendNetworkUpdateImmediate();
player.Respawn();
if (!AllowsSleeping())
{
player.EndSleeping();
player.SendNetworkUpdateImmediate();
}
PostPlayerRespawn(player);
}
PostPlayerRespawn(player);
}
public void PostPlayerRespawn(BasePlayer player)
@ -1300,4 +1387,97 @@ public class BaseGameMode : BaseEntity
}
return false;
}
public int GetLootWeightModifier(ItemDefinition forDefinition)
{
if (forDefinition == null)
{
return 0;
}
int num = 0;
LootTypeModifier[] lootDistributionModifiers = LootDistributionModifiers;
for (int i = 0; i < lootDistributionModifiers.Length; i++)
{
LootTypeModifier lootTypeModifier = lootDistributionModifiers[i];
if ((lootTypeModifier.LootType & forDefinition.lootDistributionType) != ItemDefinition.LootDistributionModifierType.None)
{
num += lootTypeModifier.Modifier;
}
}
return num;
}
public float GetCraftingCostModifier(ItemDefinition forDefinition)
{
if (forDefinition == null)
{
return 1f;
}
CraftingCostMultiplier[] craftingCostModifiers = CraftingCostModifiers;
for (int i = 0; i < craftingCostModifiers.Length; i++)
{
CraftingCostMultiplier craftingCostMultiplier = craftingCostModifiers[i];
if ((craftingCostMultiplier.LootType & forDefinition.lootDistributionType) != ItemDefinition.LootDistributionModifierType.None)
{
if (craftingCostMultiplier.ConVarToUse != CraftingCostConVar.None)
{
return GetCraftingCostConVar(craftingCostMultiplier.ConVarToUse);
}
return craftingCostMultiplier.Multiplier;
}
}
return 1f;
}
protected virtual float GetCraftingCostConVar(CraftingCostConVar conVar)
{
return 1f;
}
public bool IsAllowed(ItemDefinition item, EraRestriction restriction)
{
ItemRestriction[] restrictions = Restrictions;
for (int i = 0; i < restrictions.Length; i++)
{
ItemRestriction itemRestriction = restrictions[i];
if (itemRestriction.Definition == item && restriction != EraRestriction.Default && itemRestriction.Restriction != EraRestriction.Default && (itemRestriction.Restriction & restriction) == 0)
{
return false;
}
}
return true;
}
public bool IsAllowed(TechTreeData techTree)
{
if (allowedTechTrees == null || allowedTechTrees.Length == 0)
{
return true;
}
TechTreeData[] array = allowedTechTrees;
for (int i = 0; i < array.Length; i++)
{
if (array[i] == techTree)
{
return true;
}
}
return false;
}
public bool CanShowPlayerMarkerOnMap(BasePlayer bp)
{
if (!hidePlayerOnMap)
{
return true;
}
foreach (Item item in bp.inventory.containerBelt.itemList)
{
if (item.info.HasComponent<ItemModCompass>())
{
return true;
}
}
return false;
}
}

View file

@ -8,7 +8,7 @@ using UnityEngine.Assertions;
public class BaseLock : BaseEntity
{
[ItemSelector(ItemCategory.All)]
[ItemSelector]
public ItemDefinition itemType;
public bool CanRemove = true;

View file

@ -647,6 +647,8 @@ public class BaseMission : BaseScriptableObject
public BasePlayer.TutorialItemAllowance AllowedTutorialItems;
public bool IsTutorialMission;
public BaseMission followupMission;
public int repeatDelaySecondsSuccess = -1;
@ -911,7 +913,7 @@ public class BaseMission : BaseScriptableObject
{
Debug.LogError("BIG REWARD SCREWUP, NULL ITEM DEF");
}
else if (!itemAmount.itemDef.IsAllowedInEra(EraRestriction.Mission))
else if (!itemAmount.itemDef.IsAllowed(EraRestriction.Mission))
{
Debug.LogError($"Blocking mission reward '{itemAmount.itemDef.shortname}' not allowed in era '{ConVar.Server.Era}'");
}
@ -948,6 +950,12 @@ public class BaseMission : BaseScriptableObject
Analytics.Azure.OnMissionComplete(assignee, this, failReason);
instance.status = MissionStatus.Failed;
MissionEnded(instance, assignee);
if (failReason == MissionFailReason.ResetPlayerState)
{
instance.endTime = 0f;
instance.status = MissionStatus.Default;
assignee.MissionDirty();
}
}
public virtual void MissionEnded(MissionInstance instance, BasePlayer assignee)
@ -969,7 +977,6 @@ public class BaseMission : BaseScriptableObject
Facepunch.Pool.FreeUnmanaged(ref obj);
}
RemoveBlockers(instance);
instance.endTime = UnityEngine.Time.time;
assignee.SetActiveMission(-1);
assignee.MissionDirty();
}

View file

@ -17,9 +17,9 @@ public abstract class BaseModifiers<T> : EntityComponent<T> where T : BaseCombat
protected bool dirty = true;
protected float timeSinceLastTick;
protected double timeSinceLastTick;
protected float lastTickTime;
protected double lastTickTime;
public int ActiveModifierCount => All.Count;
@ -79,7 +79,10 @@ public abstract class BaseModifiers<T> : EntityComponent<T> where T : BaseCombat
Remove(shortestLifeModifier);
}
All.Add(modifier);
AdjustSourceCount(modifier.Source, 1);
if (!modifier.IsHiddenModifier())
{
AdjustSourceCount(modifier.Source, 1);
}
ApplyModifierValue(modifier);
SetDirty(flag: true);
}
@ -324,32 +327,32 @@ public abstract class BaseModifiers<T> : EntityComponent<T> where T : BaseCombat
public void ResetTicking()
{
lastTickTime = UnityEngine.Time.realtimeSinceStartup;
timeSinceLastTick = 0f;
lastTickTime = UnityEngine.Time.timeAsDouble;
timeSinceLastTick = 0.0;
}
public virtual void ServerUpdate(BaseCombatEntity ownerEntity)
{
float num = UnityEngine.Time.realtimeSinceStartup - lastTickTime;
lastTickTime = UnityEngine.Time.realtimeSinceStartup;
double num = UnityEngine.Time.timeAsDouble - lastTickTime;
lastTickTime = UnityEngine.Time.timeAsDouble;
timeSinceLastTick += num;
if (!(timeSinceLastTick <= ConVar.Server.modifierTickRate))
if (!(timeSinceLastTick <= (double)ConVar.Server.modifierTickRate))
{
if (owner != null && !owner.IsDead())
{
TickModifiers(ownerEntity, timeSinceLastTick);
}
timeSinceLastTick = 0f;
timeSinceLastTick = 0.0;
}
}
protected virtual void TickModifiers(BaseCombatEntity ownerEntity, float delta)
protected virtual void TickModifiers(BaseCombatEntity ownerEntity, double delta)
{
for (int num = All.Count - 1; num >= 0; num--)
{
Modifier modifier = All[num];
float num2 = (IsModifierCompatibleWithDigestionBoost(modifier.Type) ? GetValue(Modifier.ModifierType.DigestionBoost, 1f) : 1f);
modifier.Tick(ownerEntity, delta * num2);
float num2 = (IsModifierCompatibleWithDigestionBoost(modifier.Type) ? GetValue(Modifier.ModifierType.DigestionBoostTimeMod, 1f) : 1f);
modifier.Tick(ownerEntity, delta * (double)num2);
if (modifier.Expired)
{
Remove(modifier);

View file

@ -1,3 +1,6 @@
using Development.Attributes;
[ResetStaticFields]
public abstract class BaseMonoBehaviour : FacepunchBehaviour
{
public virtual bool IsDebugging()

View file

@ -2,6 +2,7 @@
using System;
using System.Collections.Generic;
using ConVar;
using Development.Attributes;
using Facepunch;
using Facepunch.Rust;
using Network;
@ -10,6 +11,7 @@ using UnityEngine;
using UnityEngine.Assertions;
using UnityEngine.Serialization;
[ResetStaticFields]
public class BaseMountable : BaseCombatEntity
{
public enum ClippingCheckLocation

View file

@ -68,6 +68,7 @@ public class BaseOven : StorageContainer, ISplashable, IIndustrialStorage, IAlwa
private static Dictionary<float, HashSet<ItemDefinition>> _materialOutputCache;
[Header("Base Oven Settings")]
public TemperatureType temperature;
public Menu.Option switchOnMenu;
@ -916,7 +917,7 @@ public class BaseOven : StorageContainer, ISplashable, IIndustrialStorage, IAlwa
{
foreach (CookingItem cookingItem in cookingItems)
{
if (cookingItem.cookingProgress != 1f)
if (base.inventory != null && cookingItem != null && cookingItem.cookingProgress != 1f)
{
Item slot = base.inventory.GetSlot(cookingItem.slotIndex + _inputSlotIndex);
if (slot == null)

File diff suppressed because it is too large Load diff

View file

@ -10,6 +10,8 @@ public class BasePrefab : BaseMonoBehaviour, IPrefabPreProcess
public bool isServer => !isClient;
bool IPrefabPreProcess.CanRunDuringBundling => false;
public virtual void PreProcess(IPrefabProcessor preProcess, GameObject rootObj, string name, bool serverside, bool clientside, bool bundling)
{
prefabID = StringPool.Get(name);

View file

@ -32,7 +32,7 @@ public class BaseProjectile : AttackEntity
public int contents;
[ItemSelector(ItemCategory.All)]
[ItemSelector]
public ItemDefinition ammoType;
public bool allowPlayerReloading = true;
@ -489,20 +489,21 @@ public class BaseProjectile : AttackEntity
protected bool TryReload(IAmmoContainer ammoSource, int desiredAmount, bool canRefundAmmo = true)
{
List<Item> list = ammoSource.FindItemsByItemID(primaryMagazine.ammoType.itemid);
if (list.Count == 0 && !primaryMagazine.allowAmmoSwitching)
using PooledList<Item> pooledList = Facepunch.Pool.Get<PooledList<Item>>();
ammoSource.FindItemsByItemID(pooledList, primaryMagazine.ammoType.itemid);
if (pooledList.Count == 0 && !primaryMagazine.allowAmmoSwitching)
{
return false;
}
if (list.Count == 0)
if (pooledList.Count == 0)
{
Item item = ammoSource.FindAmmo(primaryMagazine.definition.ammoTypes);
if (item == null)
{
return false;
}
list = ammoSource.FindItemsByItemID(item.info.itemid);
if (list == null || list.Count == 0)
ammoSource.FindItemsByItemID(pooledList, item.info.itemid);
if (pooledList.Count == 0)
{
return false;
}
@ -514,14 +515,14 @@ public class BaseProjectile : AttackEntity
}
SetAmmoCount(0);
}
primaryMagazine.ammoType = list[0].info;
primaryMagazine.ammoType = pooledList[0].info;
}
int num = desiredAmount;
if (num == -1)
{
num = primaryMagazine.capacity - primaryMagazine.contents;
}
foreach (Item item2 in list)
foreach (Item item2 in pooledList)
{
_ = item2.amount;
int num2 = Mathf.Min(num, item2.amount);

View file

@ -0,0 +1,34 @@
using System;
using UnityEngine;
public class BaseRaidBenchmarkScene : BenchmarkScene
{
[Serializable]
public struct RunConfig
{
public string Name;
public int PlayerCount;
public int BaseCount;
public TextAsset[] BaseJsons;
public bool SpawnBaseInMiddle;
public TextAsset MiddleBase;
}
[Header("Base Raid Benchmark")]
public GameObject WorldSetupPrefab;
public TerrainConfig TerrainConfig;
public GameObjectRef PlayerPrefab;
public GameObjectRef ClientPrefab;
public GameObjectRef SoundManagerPrefab;
public RunConfig[] Runs;
}

View file

@ -451,6 +451,10 @@ public class BaseSculpture : IOEntity, IServerFileReceiver, IUGCBrowserEntity, I
public bool CanUpdateSculpture(BasePlayer player)
{
if (IsLocked())
{
return false;
}
if (player.IsAdmin || player.IsDeveloper)
{
return true;
@ -459,10 +463,6 @@ public class BaseSculpture : IOEntity, IServerFileReceiver, IUGCBrowserEntity, I
{
return false;
}
if (IsLocked())
{
return (ulong)player.userID == base.OwnerID;
}
return true;
}
@ -604,11 +604,14 @@ public class BaseSculpture : IOEntity, IServerFileReceiver, IUGCBrowserEntity, I
[RPC_Server.MaxDistance(3f)]
public void SV_SetColorIndex(RPCMessage msg)
{
int num = msg.read.Int32();
if (num >= 0 && num < colorSettings.Length)
if (CanUpdateSculpture(msg.player))
{
_currentColorIndex = num;
SendNetworkUpdate();
int num = msg.read.Int32();
if (num >= 0 && num < colorSettings.Length)
{
_currentColorIndex = num;
SendNetworkUpdate();
}
}
}
@ -649,7 +652,7 @@ public class BaseSculpture : IOEntity, IServerFileReceiver, IUGCBrowserEntity, I
[RPC_Server.MaxDistance(3f)]
public void SV_Add(RPCMessage msg)
{
if (!IsLocked())
if (CanUpdateSculpture(msg.player))
{
Vector3 worldSpacePosition = msg.read.Vector3();
if (TryGetHeldCarvingAttributeServer(msg.player, out var attribute) && attribute.AllowCarve)
@ -664,7 +667,7 @@ public class BaseSculpture : IOEntity, IServerFileReceiver, IUGCBrowserEntity, I
[RPC_Server.MaxDistance(3f)]
public void SV_Carve(RPCMessage msg)
{
if (IsLocked())
if (!CanUpdateSculpture(msg.player))
{
return;
}
@ -690,7 +693,7 @@ public class BaseSculpture : IOEntity, IServerFileReceiver, IUGCBrowserEntity, I
[RPC_Server.MaxDistance(3f)]
public void SV_Smooth(RPCMessage msg)
{
if (IsLocked())
if (!CanUpdateSculpture(msg.player))
{
return;
}

View file

@ -1218,7 +1218,13 @@ public class BaseVehicle : BaseMountable, VehicleSpawner.IVehicleSpawnUser
{
creatorEntity = owner;
base.OwnerID = owner.userID;
SetFlag(Flags.Locked, b: true);
bool b = true;
BaseGameMode activeGameMode = BaseGameMode.GetActiveGameMode(base.isServer);
if (activeGameMode != null && !activeGameMode.safeZone)
{
b = false;
}
SetFlag(Flags.Locked, b);
safeAreaRadius = newSafeAreaRadius;
safeAreaOrigin = newSafeAreaOrigin;
spawnTime = UnityEngine.Time.realtimeSinceStartup;

View file

@ -88,6 +88,8 @@ public class BaseVehicleModule : BaseVehicle, IPrefabPreProcess
public virtual bool HasAnEngine => false;
bool IPrefabPreProcess.CanRunDuringBundling => false;
public bool PropagateDamage { get; private set; } = true;
public override bool OnRpcMessage(BasePlayer player, uint rpc, Message msg)

View file

@ -37,6 +37,8 @@ public class BaseViewModel : FacepunchBehaviour, IPrefabPreProcess, IViewmodelWo
[Header("Shield Overrides")]
public AnimationCurve leftArmShieldHideCurve = AnimationCurve.Linear(0f, 0f, 1f, 1f);
bool IPrefabPreProcess.CanRunDuringBundling => false;
public void PreProcess(IPrefabProcessor preProcess, GameObject rootObj, string name, bool serverside, bool clientside, bool bundling)
{
}

View file

@ -244,6 +244,10 @@ public class BatteringRam : BaseSiegeWeapon, IEngineControllerUser, IEntity, Veh
{
using (TimeWarning.New("Conditions"))
{
if (!RPC_Server.CallsPerSecond.Test(3999508679u, "RPC_CloseDoor", this, player, 2uL))
{
return true;
}
if (!RPC_Server.MaxDistance.Test(3999508679u, "RPC_CloseDoor", this, player, 3f))
{
return true;
@ -281,6 +285,10 @@ public class BatteringRam : BaseSiegeWeapon, IEngineControllerUser, IEntity, Veh
{
using (TimeWarning.New("Conditions"))
{
if (!RPC_Server.CallsPerSecond.Test(3314360565u, "RPC_OpenDoor", this, player, 2uL))
{
return true;
}
if (!RPC_Server.MaxDistance.Test(3314360565u, "RPC_OpenDoor", this, player, 3f))
{
return true;
@ -541,6 +549,7 @@ public class BatteringRam : BaseSiegeWeapon, IEngineControllerUser, IEntity, Veh
[RPC_Server]
[RPC_Server.MaxDistance(3f)]
[RPC_Server.CallsPerSecond(2uL)]
protected void RPC_OpenDoor(RPCMessage rpc)
{
if (rpc.player.CanInteract(usableWhileCrawling: true) && CanOpenDoor())
@ -551,6 +560,7 @@ public class BatteringRam : BaseSiegeWeapon, IEngineControllerUser, IEntity, Veh
[RPC_Server]
[RPC_Server.MaxDistance(3f)]
[RPC_Server.CallsPerSecond(2uL)]
protected void RPC_CloseDoor(RPCMessage rpc)
{
if (rpc.player.CanInteract(usableWhileCrawling: true) && CanCloseDoor())

View file

@ -0,0 +1,96 @@
using System;
using System.Collections.Generic;
using ProtoBuf;
using UnityEngine;
namespace Benchmark;
[JsonModel]
public class Building
{
[JsonModel]
public class Entity
{
public ulong NetId;
public string ResPath;
public ulong ParentNetId;
public Vector3 Pos;
public Vector3 RotEuler;
public ulong SkinID;
public virtual void FromProto(ProtoBuf.Entity ent)
{
NetId = ent.baseNetworkable.uid.Value;
ResPath = StringPool.Get(ent.baseNetworkable.prefabID);
ParentNetId = ent.parent?.uid.Value ?? 0;
Pos = ent.baseEntity.pos;
RotEuler = ent.baseEntity.rot;
SkinID = ent.baseEntity.skinid;
}
}
[JsonModel]
public class BuildingEntity : Entity
{
public BuildingGrade.Enum Grade;
public ulong Model;
public override void FromProto(ProtoBuf.Entity ent)
{
base.FromProto(ent);
if (ent.buildingBlock != null)
{
Grade = (BuildingGrade.Enum)ent.buildingBlock.grade;
Model = ent.buildingBlock.model;
}
else
{
Grade = BuildingGrade.Enum.None;
Model = 0uL;
}
}
}
[JsonModel]
public class SpawnMarker
{
[Flags]
public enum SpawnType
{
LocalPlayer = 1,
RemotePlayer = 2
}
public Vector3 Pos;
public Vector3 RotEuler;
public SpawnType Type;
}
public const uint InvalidBuildingId = 0u;
public uint Id;
public List<BuildingEntity> BuildingEntities;
public List<SpawnMarker> SpawnMarkers;
public Building(uint id)
{
Id = id;
BuildingEntities = new List<BuildingEntity>();
SpawnMarkers = new List<SpawnMarker>();
}
public override string ToString()
{
return $"{Id}: {BuildingEntities.Count} entities";
}
}

View file

@ -26,7 +26,32 @@ public class BiomeVisuals : MonoBehaviour
[Horizontal(2, -1)]
public EnvironmentVolumeOverride[] EnvironmentVolumeOverrides;
protected void Start()
private bool _supportsPooling;
private GameObject _defaultSelection;
protected void Awake()
{
_supportsPooling = base.gameObject.SupportsPoolingInParent();
if ((bool)Arid && Arid.activeSelf)
{
_defaultSelection = Arid;
}
else if ((bool)Temperate && Temperate.activeSelf)
{
_defaultSelection = Temperate;
}
else if ((bool)Tundra && Tundra.activeSelf)
{
_defaultSelection = Tundra;
}
else if ((bool)Arctic && Arctic.activeSelf)
{
_defaultSelection = Arctic;
}
}
protected void OnEnable()
{
int num = ((TerrainMeta.BiomeMap != null) ? TerrainMeta.BiomeMap.GetBiomeMaxType(base.transform.position) : 2);
if (OverrideBiome)
@ -60,21 +85,27 @@ public class BiomeVisuals : MonoBehaviour
case 8:
SetChoice(Arctic);
break;
default:
SetChoice(_defaultSelection);
break;
}
}
private void SetChoice(GameObject selection)
{
bool shouldDestroy = !base.gameObject.SupportsPoolingInParent();
ApplyChoice(selection, Arid, shouldDestroy);
ApplyChoice(selection, Temperate, shouldDestroy);
ApplyChoice(selection, Tundra, shouldDestroy);
ApplyChoice(selection, Arctic, shouldDestroy);
bool flag = !_supportsPooling;
ApplyChoice(selection, Arid, flag);
ApplyChoice(selection, Temperate, flag);
ApplyChoice(selection, Tundra, flag);
ApplyChoice(selection, Arctic, flag);
if (selection != null)
{
selection.SetActive(value: true);
}
GameManager.Destroy(this);
if (flag)
{
GameManager.Destroy(this);
}
}
private void ApplyChoice(GameObject selection, GameObject target, bool shouldDestroy)

View file

@ -7,7 +7,9 @@ using System.Linq;
using System.Threading;
using System.Threading.Tasks;
using CompanionServer;
using CompanionServer.Handlers;
using ConVar;
using Development.Attributes;
using Facepunch;
using Facepunch.Network;
using Facepunch.Network.Raknet;
@ -18,25 +20,28 @@ using Network;
using ProtoBuf;
using Rust;
using Rust.Ai;
using TMPro;
using Rust.UI;
using UnityEngine;
using UnityEngine.AI;
[ResetStaticFields]
public class Bootstrap : SingletonComponent<Bootstrap>
{
internal static bool bootstrapInitRun;
public static bool isErrored;
public string messageString = "Loading...";
public Translate.Phrase currentLoadingPhrase;
public CanvasGroup BootstrapUiCanvas;
public GameObject errorPanel;
public TextMeshProUGUI errorText;
public RustText errorText;
public TextMeshProUGUI statusText;
public RustText statusText;
private Translate.Phrase openingBundles = new Translate.Phrase("bootstrap.openingbundles", "Opening Bundles");
private static string lastWrittenValue;
@ -188,7 +193,8 @@ public class Bootstrap : SingletonComponent<Bootstrap>
WriteToLog("Bootstrap Startup");
EarlyInitialize();
BenchmarkTimer.Enabled = Facepunch.Utility.CommandLine.Full.Contains("+autobench");
BenchmarkTimer timer = BenchmarkTimer.New("bootstrap");
Stopwatch timer = BenchmarkTimer.Get("bootstrap");
timer?.Start();
if (!UnityEngine.Application.isEditor)
{
BuildInfo current = BuildInfo.Current;
@ -207,9 +213,9 @@ public class Bootstrap : SingletonComponent<Bootstrap>
if (AssetBundleBackend.Enabled)
{
AssetBundleBackend newBackend = new AssetBundleBackend();
using (BenchmarkTimer.New("bootstrap;bundles"))
using (BenchmarkTimer.Measure("bootstrap;bundles"))
{
yield return StartCoroutine(LoadingUpdate("Opening Bundles"));
yield return StartCoroutine(LoadingUpdate(openingBundles));
newBackend.Load("Bundles/Bundles");
FileSystem.Backend = newBackend;
}
@ -218,10 +224,24 @@ public class Bootstrap : SingletonComponent<Bootstrap>
ThrowError(FileSystem.Backend.loadingError);
yield break;
}
using (BenchmarkTimer.New("bootstrap;bundlesindex"))
using (BenchmarkTimer.Measure("bootstrap;bundlesindex"))
{
newBackend.BuildFileIndex();
}
while (true)
{
if (FileSystem.Backend.isError)
{
ThrowError(FileSystem.Backend.loadingError);
yield break;
}
float assetSceneProgress = newBackend.GetAssetSceneProgress("AssetScene-bootstrap");
if (assetSceneProgress >= 1f)
{
break;
}
yield return StartCoroutine(LoadingUpdate($"Loading Menu Prefabs {assetSceneProgress * 100f:0.0}%"));
}
}
if (FileSystem.Backend.isError)
{
@ -239,13 +259,13 @@ public class Bootstrap : SingletonComponent<Bootstrap>
{
yield break;
}
using (BenchmarkTimer.New("bootstrap;gamemanifest"))
using (BenchmarkTimer.Measure("bootstrap;gamemanifest"))
{
yield return StartCoroutine(LoadingUpdate("Loading Game Manifest"));
GameManifest.Load();
yield return StartCoroutine(LoadingUpdate("DONE!"));
}
using (BenchmarkTimer.New("bootstrap;selfcheck"))
using (BenchmarkTimer.Measure("bootstrap;selfcheck"))
{
yield return StartCoroutine(LoadingUpdate("Running Self Check"));
SelfCheck.Run();
@ -255,39 +275,39 @@ public class Bootstrap : SingletonComponent<Bootstrap>
yield break;
}
yield return StartCoroutine(LoadingUpdate("Bootstrap Tier0"));
using (BenchmarkTimer.New("bootstrap;tier0"))
using (BenchmarkTimer.Measure("bootstrap;tier0"))
{
Init_Tier0();
}
using (BenchmarkTimer.New("bootstrap;commandlinevalues"))
using (BenchmarkTimer.Measure("bootstrap;commandlinevalues"))
{
ConsoleSystem.UpdateValuesFromCommandLine();
}
yield return StartCoroutine(LoadingUpdate("Bootstrap Systems"));
using (BenchmarkTimer.New("bootstrap;init_systems"))
using (BenchmarkTimer.Measure("bootstrap;init_systems"))
{
Init_Systems();
}
yield return StartCoroutine(LoadingUpdate("Bootstrap Config"));
using (BenchmarkTimer.New("bootstrap;init_config"))
using (BenchmarkTimer.Measure("bootstrap;init_config"))
{
Init_Config();
}
using (BenchmarkTimer.New("bootstrap;commandlinevalues2"))
using (BenchmarkTimer.Measure("bootstrap;commandlinevalues2"))
{
ConsoleSystem.UpdateValuesFromCommandLine();
}
if (!isErrored)
{
yield return StartCoroutine(LoadingUpdate("Loading Items"));
using (BenchmarkTimer.New("bootstrap;itemmanager"))
using (BenchmarkTimer.Measure("bootstrap;itemmanager"))
{
ItemManager.Initialize();
}
if (!isErrored)
{
yield return StartCoroutine(DedicatedServerStartup());
timer?.Dispose();
timer?.Stop();
GameManager.Destroy(base.gameObject);
}
}
@ -318,11 +338,10 @@ public class Bootstrap : SingletonComponent<Bootstrap>
World.InitSalt(ConVar.Server.salt);
World.Url = ConVar.Server.levelurl;
World.Transfer = ConVar.Server.leveltransfer;
LevelManager.LoadLevel(ConVar.Server.level);
yield return LevelManager.LoadLevelAsync(ConVar.Server.level);
yield return CoroutineEx.waitForEndOfFrame;
yield return CoroutineEx.waitForEndOfFrame;
string[] assetList = FileSystem_Warmup.GetAssetList();
yield return StartCoroutine(FileSystem_Warmup.Run(assetList, WriteToLog, "Asset Warmup ({0}/{1})"));
yield return StartCoroutine(FileSystem_Warmup.Run(WriteToLog, "Asset Warmup ({0}/{1})"));
yield return StartCoroutine(StartServer(!Facepunch.CommandLine.HasSwitch("-skipload"), "", allowOutOfDateSaves: false));
if (!UnityEngine.Object.FindObjectOfType<Performance>())
{
@ -394,7 +413,7 @@ public class Bootstrap : SingletonComponent<Bootstrap>
}
else
{
UnityEngine.Debug.LogError("Failed to find DungeonGridRoot, NOT generating Dungeon navmesh");
UnityEngine.Debug.LogWarning("Failed to find DungeonGridRoot, NOT generating Dungeon navmesh");
}
if ((bool)TerrainMeta.Path && (bool)TerrainMeta.Path.DungeonBaseRoot)
{
@ -406,7 +425,7 @@ public class Bootstrap : SingletonComponent<Bootstrap>
}
else
{
UnityEngine.Debug.LogError("Failed to find DungeonBaseRoot , NOT generating Dungeon navmesh");
UnityEngine.Debug.LogWarning("Failed to find DungeonBaseRoot , NOT generating Dungeon navmesh");
}
GenerateDungeonBase.SetupAI();
}
@ -458,9 +477,26 @@ public class Bootstrap : SingletonComponent<Bootstrap>
}
NexusServer.ZoneClient.StartListening();
}
if (ConVar.Server.autoUploadMap)
{
Task uploadTask = MapUploader.UploadMap();
while (!uploadTask.IsCompleted)
{
yield return null;
}
if (!uploadTask.IsCompletedSuccessfully)
{
UnityEngine.Debug.LogError("Failed to upload map file:");
UnityEngine.Debug.LogException(uploadTask.Exception);
}
}
serverMgr.OpenConnection();
CompanionServer.Server.Initialize();
using (BenchmarkTimer.New("Boombox.LoadStations"))
if (ConVar.Server.autoUploadMapImages && Map.ImageData != null)
{
MapUploader.UploadMapImage(Map.ImageData);
}
using (BenchmarkTimer.Measure("Boombox.LoadStations"))
{
BoomBox.LoadStations();
}
@ -478,11 +514,27 @@ public class Bootstrap : SingletonComponent<Bootstrap>
ItemManager.Initialize();
}
public bool RetrySteam()
{
if (!Facepunch.CommandLine.HasSwitch("-nosteam"))
{
return !PlatformService.Initialize(RustPlatformHooks.Instance);
}
return true;
}
public void ThrowError(string error)
{
UnityEngine.Debug.Log("ThrowError: " + error);
errorPanel.SetActive(value: true);
errorText.text = error;
isErrored = true;
}
public void ClearError()
{
isErrored = false;
}
public void ThrowSteamError()
{
isErrored = true;
}
@ -492,11 +544,11 @@ public class Bootstrap : SingletonComponent<Bootstrap>
Rust.Application.Quit();
}
public static IEnumerator LoadingUpdate(string str)
public static IEnumerator LoadingUpdate(Translate.Phrase phrase)
{
if ((bool)SingletonComponent<Bootstrap>.Instance)
{
SingletonComponent<Bootstrap>.Instance.messageString = str;
SingletonComponent<Bootstrap>.Instance.currentLoadingPhrase = phrase;
yield return CoroutineEx.waitForEndOfFrame;
yield return CoroutineEx.waitForEndOfFrame;
}

View file

@ -48,7 +48,7 @@ public class BuildingPrivlidge : StorageContainer
new UpkeepBracket(ConVar.Decay.bracket_0_blockcount, ConVar.Decay.bracket_0_costfraction),
new UpkeepBracket(ConVar.Decay.bracket_1_blockcount, ConVar.Decay.bracket_1_costfraction),
new UpkeepBracket(ConVar.Decay.bracket_2_blockcount, ConVar.Decay.bracket_2_costfraction),
new UpkeepBracket(ConVar.Decay.bracket_3_blockcount, ConVar.Decay.bracket_3_costfraction)
new UpkeepBracket(0, ConVar.Decay.bracket_3_costfraction)
};
private static UpkeepBracket[] doorUpkeepBrackets = new UpkeepBracket[4]
@ -56,7 +56,7 @@ public class BuildingPrivlidge : StorageContainer
new UpkeepBracket(ConVar.Decay.bracket_0_doorcount, ConVar.Decay.bracket_0_doorfraction),
new UpkeepBracket(ConVar.Decay.bracket_1_doorcount, ConVar.Decay.bracket_1_doorfraction),
new UpkeepBracket(ConVar.Decay.bracket_2_doorcount, ConVar.Decay.bracket_2_doorfraction),
new UpkeepBracket(ConVar.Decay.bracket_3_doorcount, ConVar.Decay.bracket_3_doorfraction)
new UpkeepBracket(0, ConVar.Decay.bracket_3_doorfraction)
};
private List<ItemAmount> upkeepBuffer = new List<ItemAmount>();
@ -613,9 +613,12 @@ public class BuildingPrivlidge : StorageContainer
float num2 = -1f;
if (base.inventory != null)
{
using PooledList<Item> pooledList = Facepunch.Pool.Get<PooledList<Item>>();
foreach (ItemAmount item in obj)
{
int num3 = base.inventory.FindItemsByItemID(item.itemid).Sum((Item x) => x.amount);
pooledList.Clear();
base.inventory.FindItemsByItemID(pooledList, item.itemid);
int num3 = pooledList.Sum((Item x) => x.amount);
if (num3 > 0 && item.amount > 0f)
{
float num4 = (float)num3 / item.amount * num;
@ -734,35 +737,45 @@ public class BuildingPrivlidge : StorageContainer
nextProtectedCalcTime = UnityEngine.Time.realtimeSinceStartup + delay;
}
private float CalculateTaxRate(UpkeepBracket[] brackets, int entityCount)
private static float CalculateTaxRate(int entityCount, bool blocks)
{
if (entityCount == 0)
{
return brackets[0].fraction;
if (!blocks)
{
return ConVar.Decay.bracket_0_doorfraction;
}
return ConVar.Decay.bracket_0_costfraction;
}
int num = entityCount;
for (int i = 0; i < brackets.Length; i++)
float num2 = 0f;
for (int i = 0; i < 4; i++)
{
UpkeepBracket upkeepBracket = brackets[i];
upkeepBracket.blocksTaxPaid = 0f;
if (num > 0)
{
int num2 = 0;
num2 = ((i != brackets.Length - 1) ? Mathf.Min(num, brackets[i].objectsUpTo) : num);
num -= num2;
upkeepBracket.blocksTaxPaid = (float)num2 * upkeepBracket.fraction;
}
}
float num3 = 0f;
foreach (UpkeepBracket upkeepBracket2 in brackets)
{
if (!(upkeepBracket2.blocksTaxPaid > 0f))
float num3 = (blocks ? ConVar.Decay.bracket_0_costfraction : ConVar.Decay.bracket_0_doorfraction);
int b = (blocks ? ConVar.Decay.bracket_0_blockcount : ConVar.Decay.bracket_0_doorcount);
switch (i)
{
case 1:
num3 = (blocks ? ConVar.Decay.bracket_1_costfraction : ConVar.Decay.bracket_1_doorfraction);
b = (blocks ? ConVar.Decay.bracket_1_blockcount : ConVar.Decay.bracket_1_doorcount);
break;
case 2:
num3 = (blocks ? ConVar.Decay.bracket_2_costfraction : ConVar.Decay.bracket_1_doorfraction);
b = (blocks ? ConVar.Decay.bracket_2_blockcount : ConVar.Decay.bracket_1_doorcount);
break;
case 3:
num3 = (blocks ? ConVar.Decay.bracket_3_costfraction : ConVar.Decay.bracket_1_doorfraction);
b = int.MaxValue;
break;
}
num3 += upkeepBracket2.blocksTaxPaid;
if (num > 0)
{
int num4 = Mathf.Min(num, b);
num -= num4;
num2 += (float)num4 * num3;
}
}
return num3 / (float)entityCount;
return num2 /= (float)entityCount;
}
private float CalculateDoorTaxRate()
@ -780,7 +793,7 @@ public class BuildingPrivlidge : StorageContainer
{
return ConVar.Decay.bracket_0_doorfraction;
}
return CalculateTaxRate(doorUpkeepBrackets, building.doors.Count);
return CalculateTaxRate(building.doors.Count, blocks: false);
}
private float CalculateBuildingTaxRate()
@ -794,7 +807,7 @@ public class BuildingPrivlidge : StorageContainer
{
return ConVar.Decay.bracket_0_costfraction;
}
return CalculateTaxRate(upkeepBrackets, building.buildingBlocks.Count);
return CalculateTaxRate(building.buildingBlocks.Count, blocks: true);
}
private void ApplyUpkeepPayment()

View file

@ -92,6 +92,8 @@ public class Buoyancy : ListComponent<Buoyancy>, IServerComponent, IPrefabPrePro
public bool InWater => submergedFraction > requiredSubmergedFraction;
bool IPrefabPreProcess.CanRunDuringBundling => false;
public Priority BuoyancyPriority { get; set; }
public void PreProcess(IPrefabProcessor preProcess, GameObject rootObj, string name, bool serverside, bool clientside, bool bundling)

View file

@ -0,0 +1,72 @@
using System;
using Facepunch;
using ProtoBuf;
using UnityEngine;
public class BuriedItem : Pool.IPooled
{
public int? ItemId { get; private set; }
public ulong UID { get; private set; }
public ItemOwnershipShare? OwnershipShare { get; private set; }
public ulong? SkinId { get; private set; }
public long ExpiryTime { get; set; }
public Vector2 Location { get; private set; }
public float? Condition { get; private set; }
public static BuriedItem Create(Item item, Vector3 worldPosition, long expiryTime)
{
BuriedItem buriedItem = Pool.Get<BuriedItem>();
buriedItem.ItemId = item.info.itemid;
buriedItem.ExpiryTime = expiryTime;
buriedItem.Location = new Vector2(worldPosition.x, worldPosition.z);
buriedItem.Condition = (item.hasCondition ? new float?(item.condition) : ((float?)null));
buriedItem.UID = item.uid.Value;
if (item.ownershipShares.Count > 0)
{
buriedItem.OwnershipShare = item.ownershipShares[0];
}
if (item.skin != 0L)
{
buriedItem.SkinId = item.skin;
}
return buriedItem;
}
public static BuriedItem Create(ProtoBuf.BuriedItems.StoredBuriedItem storedBuriedItem)
{
BuriedItem buriedItem = Pool.Get<BuriedItem>();
buriedItem.ItemId = storedBuriedItem.itemId;
buriedItem.SkinId = storedBuriedItem.skinId;
buriedItem.Location = storedBuriedItem.location;
buriedItem.ExpiryTime = DateTimeOffset.UtcNow.ToUnixTimeMilliseconds() + storedBuriedItem.expiryTimeDiff;
buriedItem.Condition = ((storedBuriedItem.condition < 0f) ? ((float?)null) : new float?(storedBuriedItem.condition));
buriedItem.UID = storedBuriedItem.uid;
if (storedBuriedItem.ownership != null)
{
buriedItem.OwnershipShare = new ItemOwnershipShare
{
amount = storedBuriedItem.ownership.amount,
reason = storedBuriedItem.ownership.reason,
username = storedBuriedItem.ownership.username
};
}
return buriedItem;
}
public void EnterPool()
{
ItemId = null;
OwnershipShare = null;
SkinId = null;
}
public void LeavePool()
{
}
}

View file

@ -0,0 +1,232 @@
using System;
using System.Collections.Generic;
using Facepunch;
using ProtoBuf;
using Spatial;
using UnityEngine;
public class BuriedItems : PointEntity
{
[ServerVar(Help = "Time in seconds before an item expires.")]
public static float expiryTime = 86400f;
private const int CellSize = 128;
private const float WorldSize = 8096f;
private const float QuerySize = 64f;
[ServerVar]
public static int maxBuriedItems = 32;
[ServerVar(Help = "Metal detector loot weight is 100.")]
public static int buriedItemWeight = 100;
[ServerVar(Help = "[0.0 to 1.0]")]
public static float buryItemChance = 0.85f;
private Grid<BuriedItem> grid = new Grid<BuriedItem>(128, 8096f);
private readonly SortedList<long, BuriedItem> itemExpiryTracking = new SortedList<long, BuriedItem>(128);
private readonly Dictionary<ulong, BuriedItem> uidItemMapping = new Dictionary<ulong, BuriedItem>(128);
private static readonly System.Random Random = new System.Random();
private (long lastExpiryTime, long modifiedExpiryTime)? lastExpiryTime;
public static BuriedItems Instance { get; private set; }
public override void ServerInit()
{
base.ServerInit();
Clear();
Instance = this;
}
public void Register(Item item, Vector3 worldPosition)
{
if (item != null && item.uid.IsValid && item.info.allowBurying && Random.NextDouble() <= (double)buryItemChance && itemExpiryTracking.Count < maxBuriedItems)
{
TimeSpan timeSpan = TimeSpan.FromSeconds(expiryTime);
long num = DateTimeOffset.UtcNow.Add(timeSpan).ToUnixTimeMilliseconds();
BuriedItem buriedItem = BuriedItem.Create(item, worldPosition, num);
Add(buriedItem);
}
}
private void Add(BuriedItem buriedItem)
{
HandleDuplicateExpiryTimes(buriedItem);
grid.Add(buriedItem, buriedItem.Location.x, buriedItem.Location.y);
itemExpiryTracking.Add(buriedItem.ExpiryTime, buriedItem);
uidItemMapping.Add(buriedItem.UID, buriedItem);
}
private void HandleDuplicateExpiryTimes(BuriedItem buriedItem)
{
long num = buriedItem.ExpiryTime;
if (lastExpiryTime.HasValue && lastExpiryTime.Value.lastExpiryTime == num)
{
long num2;
for (num2 = lastExpiryTime.Value.modifiedExpiryTime + 1; itemExpiryTracking.ContainsKey(num2); num2++)
{
}
lastExpiryTime = (num, num2);
buriedItem.ExpiryTime = num2;
}
else
{
lastExpiryTime = (num, num);
}
}
private void PruneExpiredItems()
{
if (itemExpiryTracking.Count == 0)
{
return;
}
long num = DateTimeOffset.UtcNow.ToUnixTimeMilliseconds();
if (itemExpiryTracking.Values[0].ExpiryTime > num)
{
return;
}
using PooledList<BuriedItem> pooledList = Pool.Get<PooledList<BuriedItem>>();
foreach (var (num3, item) in itemExpiryTracking)
{
if (num3 <= num)
{
pooledList.Add(item);
continue;
}
break;
}
if (pooledList.Count <= 0)
{
return;
}
if (pooledList.Count == itemExpiryTracking.Count)
{
itemExpiryTracking.Clear();
}
foreach (BuriedItem item2 in pooledList)
{
UnregisterItem(item2);
}
}
private void UnregisterItem(BuriedItem buriedItem)
{
grid.Remove(buriedItem);
itemExpiryTracking.Remove(buriedItem.ExpiryTime);
uidItemMapping.Remove(buriedItem.UID);
Pool.Free(ref buriedItem);
}
public void UnregisterItem(ulong itemUid)
{
if (itemUid == 0L || !uidItemMapping.TryGetValue(itemUid, out var value))
{
Debug.LogError($"Couldn't find buried item with ID {itemUid}");
}
else
{
UnregisterItem(value);
}
}
public void Clear()
{
uidItemMapping.Clear();
foreach (BuriedItem value in itemExpiryTracking.Values)
{
BuriedItem obj = value;
Pool.Free(ref obj);
}
itemExpiryTracking.Clear();
grid = new Grid<BuriedItem>(128, 8096f);
lastExpiryTime = null;
}
public void DoUpdate()
{
PruneExpiredItems();
}
public void AddItems(List<DiggableEntityLoot.ItemEntry> items, Vector3 digWorldPos)
{
List<BuriedItem> obj = Pool.Get<List<BuriedItem>>();
grid.Query(digWorldPos.x, digWorldPos.z, 64f, obj);
foreach (BuriedItem item in obj)
{
if (item.ItemId.HasValue)
{
items.Add(new DiggableEntityLoot.ItemEntry
{
Item = ItemManager.FindItemDefinition(item.ItemId.Value),
Skin = item.SkinId.GetValueOrDefault(),
Min = 1,
Max = 1,
Weight = buriedItemWeight,
Condition = item.Condition,
UID = item.UID,
Owner = item.OwnershipShare
});
}
}
Pool.Free(ref obj, freeElements: false);
}
public override void Save(SaveInfo info)
{
base.Save(info);
if (!info.forDisk)
{
return;
}
ProtoBuf.BuriedItems buriedItems = Pool.Get<ProtoBuf.BuriedItems>();
buriedItems.buriedItems = Pool.Get<List<ProtoBuf.BuriedItems.StoredBuriedItem>>();
foreach (BuriedItem value in itemExpiryTracking.Values)
{
if (value.ItemId.HasValue)
{
ProtoBuf.BuriedItems.StoredBuriedItem storedBuriedItem = Pool.Get<ProtoBuf.BuriedItems.StoredBuriedItem>();
storedBuriedItem.itemId = value.ItemId.Value;
storedBuriedItem.skinId = value.SkinId.GetValueOrDefault();
storedBuriedItem.expiryTimeDiff = value.ExpiryTime - DateTimeOffset.UtcNow.ToUnixTimeMilliseconds();
storedBuriedItem.location = value.Location;
storedBuriedItem.condition = (value.Condition.HasValue ? value.Condition.Value : (-1f));
storedBuriedItem.uid = value.UID;
if (value.OwnershipShare.HasValue)
{
ItemOwnershipAmount itemOwnershipAmount = Pool.Get<ItemOwnershipAmount>();
itemOwnershipAmount.amount = value.OwnershipShare.Value.amount;
itemOwnershipAmount.username = value.OwnershipShare.Value.username;
itemOwnershipAmount.reason = value.OwnershipShare.Value.reason;
storedBuriedItem.ownership = itemOwnershipAmount;
}
buriedItems.buriedItems.Add(storedBuriedItem);
}
}
info.msg.buriedItemStorage = buriedItems;
}
public override void Load(LoadInfo info)
{
base.Load(info);
if (!info.fromDisk || info.msg.buriedItemStorage == null)
{
return;
}
Clear();
foreach (ProtoBuf.BuriedItems.StoredBuriedItem buriedItem2 in info.msg.buriedItemStorage.buriedItems)
{
if (buriedItem2.uid != 0L)
{
BuriedItem buriedItem = BuriedItem.Create(buriedItem2);
Add(buriedItem);
}
}
}
}

View file

@ -26,6 +26,8 @@ public class BurstClothHitBoxCollision : BurstCloth, IClientComponent, IPrefabPr
[Tooltip("Keywords in bone names which should be ignored for collision")]
public string[] IgnoreKeywords;
bool IPrefabPreProcess.CanRunDuringBundling => false;
private static void BreakCapsuleIntoSpheres(Transform transform, Vector3 pointA, Vector3 pointB, Vector3 up, float halfHeight, float radius, List<SphereParams> sphereColliders)
{
Vector3 vector = pointA - up * radius;

View file

@ -7,6 +7,8 @@ public class BushEntity : BaseEntity, IPrefabPreProcess
public bool globalBillboard = true;
bool IPrefabPreProcess.CanRunDuringBundling => false;
public override void InitShared()
{
base.InitShared();

View file

@ -1,5 +1,7 @@
using Development.Attributes;
using UnityEngine;
[ResetStaticFields]
public class Buttons
{
public class ConButton : ConsoleSystem.IConsoleButton
@ -63,6 +65,13 @@ public class Buttons
}
}
public void Reset()
{
_timePressed = default(TimeSince);
IsDown = false;
frame = 0;
}
public void Call(ConsoleSystem.Arg arg)
{
}

View file

@ -1,5 +1,7 @@
using Development.Attributes;
using UnityEngine;
[ResetStaticFields]
public class CH47FlightTest : MonoBehaviour
{
public struct HelicopterInputState_t

View file

@ -29,4 +29,6 @@ public class CameraEx : MonoBehaviour
internal AmbientMode old_ambientMode;
public float aspect;
private Camera camera;
}

View file

@ -108,6 +108,10 @@ public class Catapult : BaseSiegeWeapon
{
using (TimeWarning.New("Conditions"))
{
if (!RPC_Server.CallsPerSecond.Test(1188838966u, "SERVER_CancelReload", this, player, 3uL))
{
return true;
}
if (!RPC_Server.IsVisible.Test(1188838966u, "SERVER_CancelReload", this, player, 3f))
{
return true;
@ -186,6 +190,10 @@ public class Catapult : BaseSiegeWeapon
{
using (TimeWarning.New("Conditions"))
{
if (!RPC_Server.CallsPerSecond.Test(2817383917u, "SERVER_ReloadStart", this, player, 3uL))
{
return true;
}
if (!RPC_Server.IsVisible.Test(2817383917u, "SERVER_ReloadStart", this, player, 3f))
{
return true;
@ -496,6 +504,7 @@ public class Catapult : BaseSiegeWeapon
[RPC_Server]
[RPC_Server.MaxDistance(3f)]
[RPC_Server.IsVisible(3f)]
[RPC_Server.CallsPerSecond(3uL)]
private void SERVER_ReloadStart(RPCMessage msg)
{
if (msg.player.CanInteract() && CanReload())
@ -510,6 +519,7 @@ public class Catapult : BaseSiegeWeapon
[RPC_Server]
[RPC_Server.MaxDistance(3f)]
[RPC_Server.IsVisible(3f)]
[RPC_Server.CallsPerSecond(3uL)]
public void SERVER_CancelReload(RPCMessage msg)
{
if (msg.player == reloadingPlayer)

View file

@ -2,6 +2,7 @@ using System;
using Facepunch.Flexbox;
using Rust.UI;
using UnityEngine;
using UnityEngine.UI;
public class ChangeSignText : UIDialog
{
@ -43,6 +44,8 @@ public class ChangeSignText : UIDialog
public GameObject chatToggleButton;
public Toggle autoSaveToggle;
[Header("Layout")]
public FlexElement rootElement;

View file

@ -145,7 +145,13 @@ public class ChickenCoop : StorageContainer
{
using (TimeWarning.New("Call"))
{
SubmitEggForHatching();
RPCMessage msg3 = new RPCMessage
{
connection = msg.connection,
player = player,
read = msg.read
};
SubmitEggForHatching(msg3);
}
}
catch (Exception exception2)
@ -181,14 +187,14 @@ public class ChickenCoop : StorageContainer
[RPC_Server]
[RPC_Server.IsVisible(3f)]
private void SubmitEggForHatching()
private void SubmitEggForHatching(RPCMessage msg)
{
if (HasFlag(Flags.Reserved3) || HasFlag(Flags.Reserved1))
{
return;
}
Item slot = base.inventory.GetSlot(0);
if (slot != null && !(slot.info.shortname != "egg"))
if (slot != null && !(slot.info.shortname != "egg") && !(msg.player.inventory.loot.entitySource != this))
{
slot.UseItem();
Animals.Add(new AnimalStatus

View file

@ -25,4 +25,6 @@ public class Client : SingletonComponent<Client>
public static Translate.Phrase loading_queue_status = new Translate.Phrase("loading.queue.status", "{0:N0} PLAYERS AHEAD OF YOU, {1:N0} PLAYERS BEHIND");
public static Translate.Phrase loading_queue_next = new Translate.Phrase("loading.queue.next", "YOU'RE NEXT - {1:N0} PLAYERS BEHIND YOU");
public static Translate.Phrase party_too_large_phrase = new Translate.Phrase("loading.party_too_large", "Party too large to join server: max team size {0}");
}

View file

@ -18,7 +18,21 @@ public class Climate : SingletonComponent<Climate>
public Float4 FogDensity;
[Horizontal(4, -1)]
public Texture2D4 LUT;
public Color4 FogColorGrad;
[Horizontal(4, -1)]
public Float4 FogAmbientIntensity = Float4.One();
[Horizontal(4, -1)]
[Range(0f, 1f)]
public Float4 FogAmbientSaturation = Float4.One();
[Horizontal(4, -1)]
public Float4 FogLightBoost = Float4.One();
public float BiomeWeightExponent = 1f;
public float FogHeightFalloff = 0.02f;
}
[Serializable]
@ -86,6 +100,16 @@ public class Climate : SingletonComponent<Climate>
[Serializable]
public class Float4 : Value4<float>
{
public static Float4 One()
{
return new Float4
{
Dawn = 1f,
Dusk = 1f,
Noon = 1f,
Night = 1f
};
}
}
[Serializable]
@ -106,12 +130,11 @@ public class Climate : SingletonComponent<Climate>
private const int weatherFadeHours = 6;
public float BiomeFogShoreDistanceFalloff = -25f;
[Range(0f, 1f)]
public float BlendingSpeed = 1f;
[Range(1f, 9f)]
public float FogMultiplier = 5f;
public float FogDarknessDistance = 200f;
public bool DebugLUTBlending;
@ -130,6 +153,16 @@ public class Climate : SingletonComponent<Climate>
public ClimateParameters Jungle;
public float UndergroundFogDensity;
public Color UndergroundFogColor = Color.black;
public VolumeCloudsConfig[] DefaultCloudConfigs;
public VolumeCloudsCirrusConfig[] DefaultCirrusConfigs;
public VolumeCloudsConfig[] AllCloudConfigs;
private Dictionary<WeatherPresetType, WeatherPreset[]> presetLookup;
private ClimateParameters[] climateLookup;
@ -196,6 +229,44 @@ public class Climate : SingletonComponent<Climate>
}
}
private void GetPresetVCloudConfigs(WeatherPreset preset, uint seed, out VolumeCloudsConfig cfg, out VolumeCloudsCirrusConfig cfgCirrus, out VolumeCloudsRadialWeatherLayerConfig cfgStorm)
{
if (preset.VolumeCloudsConfigs != null && preset.VolumeCloudsConfigs.Length != 0)
{
cfg = preset.VolumeCloudsConfigs[SeedRandom.Range(seed, 0, preset.VolumeCloudsConfigs.Length)];
}
else if (DefaultCloudConfigs.Length == 0)
{
Debug.LogError("Current weather profile has no cloud config, and default cloud config list is empty! This shouldn't be so");
cfg = null;
}
else
{
cfg = DefaultCloudConfigs[SeedRandom.Range(seed, 0, DefaultCloudConfigs.Length)];
}
if (preset.VolumeCloudsCirrusConfigs != null && preset.VolumeCloudsCirrusConfigs.Length != 0)
{
cfgCirrus = preset.VolumeCloudsCirrusConfigs[SeedRandom.Range(seed, 0, preset.VolumeCloudsCirrusConfigs.Length)];
}
else if (DefaultCirrusConfigs.Length == 0)
{
Debug.LogError("Current weather profile has no cirrus cloud config, and default cirrus cloud config list is empty! This shouldn't be so");
cfgCirrus = null;
}
else
{
cfgCirrus = DefaultCirrusConfigs[SeedRandom.Range(seed, 0, DefaultCirrusConfigs.Length)];
}
if (preset.VolumeCloudsStormLayers != null && preset.VolumeCloudsStormLayers.Length != 0)
{
cfgStorm = preset.VolumeCloudsStormLayers[SeedRandom.Range(seed, 0, preset.VolumeCloudsStormLayers.Length)];
}
else
{
cfgStorm = null;
}
}
protected void Update()
{
if (!Rust.Application.isReceiving && !Rust.Application.isLoading && (bool)TOD_Sky.Instance)

View file

@ -5,8 +5,5 @@ public class ClothingMovementProperties : ScriptableObject
{
public float speedReduction;
[Tooltip("If this piece of clothing is worn movement speed will be reduced by atleast this much")]
public float minSpeedReduction;
public float waterSpeedBonus;
}

View file

@ -11,7 +11,7 @@ using Rust;
using UnityEngine;
using UnityEngine.Assertions;
public class CodeLock : BaseLock
public class CodeLock : BaseLock, ISprayCallback
{
public GameObjectRef keyEnterDialog;
@ -39,9 +39,11 @@ public class CodeLock : BaseLock
private bool hasGuestCode;
private string code = string.Empty;
[NonSerialized]
public string code = string.Empty;
private string guestCode = string.Empty;
[NonSerialized]
public string guestCode = string.Empty;
[NonSerialized]
public List<ulong> whitelistPlayers = new List<ulong>();
@ -415,6 +417,12 @@ public class CodeLock : BaseLock
}
}
void ISprayCallback.OnReskinned(BasePlayer byPlayer)
{
hasCode = code.Length > 0;
hasGuestCode = guestCode.Length > 0;
}
public override void PostServerLoad()
{
base.PostServerLoad();

View file

@ -18,6 +18,8 @@ public class CollectibleEntity : BaseEntity, IPrefabPreProcess
public float xpScale = 1f;
bool IPrefabPreProcess.CanRunDuringBundling => false;
public override bool OnRpcMessage(BasePlayer player, uint rpc, Message msg)
{
using (TimeWarning.New("CollectibleEntity.OnRpcMessage"))

View file

@ -1,5 +1,4 @@
using System;
using System.Buffers;
using System.Collections.Generic;
using System.Runtime.CompilerServices;
using Facepunch;
@ -224,8 +223,8 @@ public class CameraRenderer : Pool.IPooled
state = CameraRendererState.Invalid;
return;
}
int minimumLength = _sampleCount * 4;
byte[] array = System.Buffers.ArrayPool<byte>.Shared.Rent(minimumLength);
int minSize = _sampleCount * 4;
byte[] array = BufferStream.Shared.ArrayPool.Rent(minSize);
List<int> obj = Pool.Get<List<int>>();
List<int> obj2 = Pool.Get<List<int>>();
int count = _task.ExtractRayData(array, obj, obj2);

View file

@ -16,6 +16,8 @@ public class Map : BasePlayerHandler<AppEmpty>
private static string _background;
public static byte[] ImageData => _imageData;
protected override double TokenCost => 5.0;
public override void Execute()

View file

@ -0,0 +1,47 @@
using UnityEngine;
public class Compass : HeldEntity
{
private const string WORLDMODEL_NEEDLE_PATH = "w_compass_rig/weapon_parent/weapon_root/needle";
private const string ADMIRE_ANIMEVENT_TAP1 = "AdmireTap1";
private const string ADMIRE_ANIMEVENT_TAP2 = "AdmireTap2";
[Header("Compass")]
[SerializeField]
[Tooltip("Change this if it does not feel like the needle direction is accurate.")]
private float needleYawAngleOffset;
[SerializeField]
[Min(0f)]
private float needleStiffness = 50f;
[SerializeField]
[Range(0f, 1f)]
private float needleDamping = 0.5f;
[SerializeField]
[Min(0f)]
private float maxAcceleration = 1500f;
[SerializeField]
[Min(0f)]
private float maxSpeed = 360f;
[SerializeField]
[MinMax(0f, 180f)]
[Tooltip("Random variance in how far off the needle will be from target when first deployed.")]
private MinMax startingAngleDelta;
[SerializeField]
private float wiggleAmplitude = 0.5f;
[SerializeField]
private float wiggleFrequency = 1.5f;
[SerializeField]
[Min(0f)]
[Tooltip("Velocity change when the admire animation taps the needle")]
private float admireTapNeedleVelocity = 300f;
}

View file

@ -0,0 +1,7 @@
using UnityEngine;
public class CompassViewmodel : MonoBehaviour, IViewmodelComponent, IAnimationEventReceiver
{
[SerializeField]
private Transform needleBone;
}

View file

@ -0,0 +1,39 @@
using UnityEngine;
namespace ConVar.Misc;
public class NoBuildZoneMaterialController : SingletonComponent<NoBuildZoneMaterialController>
{
[SerializeField]
private Material noBuildZoneMaterial;
private static readonly int DistanceWarningStrength = Shader.PropertyToID("_DistanceWarningStrength");
private static readonly int DistanceWarningStrengthNight = Shader.PropertyToID("_DistanceWarningStrengthNight");
private static readonly int DistanceWarningMinHeight = Shader.PropertyToID("_DistanceWarningMinHeight");
[ClientVar(ClientAdmin = true, Help = "[0.0-1.0]")]
public static void SetStrengthDay(ConsoleSystem.Arg arg)
{
float def = SingletonComponent<NoBuildZoneMaterialController>.Instance.noBuildZoneMaterial.GetFloat(DistanceWarningStrength);
float value = arg.GetFloat(0, def);
SingletonComponent<NoBuildZoneMaterialController>.Instance.noBuildZoneMaterial.SetFloat(DistanceWarningStrength, value);
}
[ClientVar(ClientAdmin = true, Help = "[0.0-1.0]")]
public static void SetStrengthNight(ConsoleSystem.Arg arg)
{
float def = SingletonComponent<NoBuildZoneMaterialController>.Instance.noBuildZoneMaterial.GetFloat(DistanceWarningStrengthNight);
float value = arg.GetFloat(0, def);
SingletonComponent<NoBuildZoneMaterialController>.Instance.noBuildZoneMaterial.SetFloat(DistanceWarningStrengthNight, value);
}
[ClientVar(ClientAdmin = true, Help = "[0.0-10]")]
public static void SetHeight(ConsoleSystem.Arg arg)
{
float def = SingletonComponent<NoBuildZoneMaterialController>.Instance.noBuildZoneMaterial.GetFloat(DistanceWarningMinHeight);
float value = arg.GetFloat(0, def);
SingletonComponent<NoBuildZoneMaterialController>.Instance.noBuildZoneMaterial.SetFloat(DistanceWarningMinHeight, value);
}
}

View file

@ -38,9 +38,11 @@ public class Admin : ConsoleSystem
public string Address;
public ulong EntityId;
public int ConnectedSeconds;
public float VoiationLevel;
public float ViolationLevel;
public float CurrentLevel;
@ -49,6 +51,21 @@ public class Admin : ConsoleSystem
public float Health;
}
[Preserve]
[JsonModel]
public struct PlayerIDInfo
{
public string SteamID;
public string OwnerSteamID;
public string DisplayName;
public string Address;
public ulong EntityId;
}
[Preserve]
[JsonModel]
public struct ServerInfoOutput
@ -165,7 +182,7 @@ public class Admin : ConsoleSystem
if (!flag && text.Length == 0)
{
text2 = text2 + "hostname: " + Server.hostname + "\n";
text2 = text2 + "version : " + 2592 + " secure (secure mode enabled, connected to Steam3)\n";
text2 = text2 + "version : " + 2594 + " secure (secure mode enabled, connected to Steam3)\n";
text2 = text2 + "map : " + Server.level + "\n";
text2 += $"players : {BasePlayer.activePlayerList.Count()} ({Server.maxplayers} max) ({SingletonComponent<ServerMgr>.Instance.connectionQueue.Queued} queued) ({SingletonComponent<ServerMgr>.Instance.connectionQueue.Joining} joining)\n\n";
}
@ -178,6 +195,7 @@ public class Admin : ConsoleSystem
textTable.AddColumn("owner");
textTable.AddColumn("violation");
textTable.AddColumn("kicks");
textTable.AddColumn("entityId");
foreach (BasePlayer activePlayer in BasePlayer.activePlayerList)
{
try
@ -196,16 +214,17 @@ public class Admin : ConsoleSystem
string text4 = activePlayer.displayName.QuoteSafe();
string text5 = Network.Net.sv.GetAveragePing(activePlayer.net.connection).ToString();
string text6 = activePlayer.net.connection.ipaddress;
string text7 = activePlayer.violationLevel.ToString("0.0");
string text8 = activePlayer.GetAntiHackKicks().ToString();
string text7 = activePlayer.net.ID.Value.ToString();
string text8 = activePlayer.violationLevel.ToString("0.0");
string text9 = activePlayer.GetAntiHackKicks().ToString();
if (!arg.IsAdmin && !arg.IsRcon)
{
text6 = "xx.xxx.xx.xxx";
}
string text9 = activePlayer.net.connection.GetSecondsConnected() + "s";
string text10 = activePlayer.net.connection.GetSecondsConnected() + "s";
if (text.Length <= 0 || text4.Contains(text, CompareOptions.IgnoreCase) || userIDString.Contains(text) || text3.Contains(text) || text6.Contains(text))
{
textTable.AddRow(userIDString, text4, text5, text9, text6, (text3 == userIDString) ? string.Empty : text3, text7, text8);
textTable.AddRow(userIDString, text4, text5, text10, text6, (text3 == userIDString) ? string.Empty : text3, text8, text9, text7);
}
}
catch (Exception ex)
@ -1076,6 +1095,7 @@ public class Admin : ConsoleSystem
textTable.AddColumn("ping");
textTable.AddColumn("updt");
textTable.AddColumn("dist");
textTable.AddColumn("enId");
textTable.ResizeRows(BasePlayer.activePlayerList.Count);
foreach (BasePlayer activePlayer in BasePlayer.activePlayerList)
{
@ -1093,6 +1113,8 @@ public class Admin : ConsoleSystem
textTable.AddValue(queuedUpdateCount);
int queuedUpdateCount2 = activePlayer.GetQueuedUpdateCount(BasePlayer.NetworkQueue.UpdateDistance);
textTable.AddValue(queuedUpdateCount2);
ulong value = activePlayer.net.ID.Value;
textTable.AddValue(value);
}
arg.ReplyWith(flag ? textTable.ToJson(stringify: false) : textTable.ToString());
}
@ -1242,6 +1264,17 @@ public class Admin : ConsoleSystem
arg.ReplyWith("Player not found");
return;
}
long timestamp = arg.GetTimestamp(1, 0L);
if (timestamp > 0)
{
playerOrSleeper.State.chatMuteExpiryTimestamp = timestamp;
string text = (timestamp - DateTimeOffset.UtcNow.ToUnixTimeSeconds()).FormatSecondsLong();
playerOrSleeper.ChatMessage("You have been muted for " + text);
}
else
{
playerOrSleeper.ChatMessage("You have been permanently muted");
}
playerOrSleeper.State.chatMuted = true;
playerOrSleeper.SetPlayerFlag(BasePlayer.PlayerFlags.ChatMute, b: true);
}
@ -1256,7 +1289,9 @@ public class Admin : ConsoleSystem
return;
}
playerOrSleeper.State.chatMuted = false;
playerOrSleeper.State.chatMuteExpiryTimestamp = 0.0;
playerOrSleeper.SetPlayerFlag(BasePlayer.PlayerFlags.ChatMute, b: false);
playerOrSleeper.ChatMessage("You have been unmuted");
}
[ServerVar(Help = "Print a list of currently muted players")]
@ -1864,12 +1899,26 @@ public class Admin : ConsoleSystem
DisplayName = x.displayName,
Ping = Network.Net.sv.GetAveragePing(x.net.connection),
Address = x.net.connection.ipaddress,
EntityId = x.net.ID.Value,
ConnectedSeconds = (int)x.net.connection.GetSecondsConnected(),
VoiationLevel = x.violationLevel,
ViolationLevel = x.violationLevel,
Health = x.Health()
}).ToArray();
}
[ServerVar(Help = "Get a list of player's IDs")]
public static PlayerIDInfo[] playerlistids()
{
return BasePlayer.activePlayerList.Select((BasePlayer x) => new PlayerIDInfo
{
SteamID = x.UserIDString,
OwnerSteamID = x.OwnerID.ToString(),
DisplayName = x.displayName,
Address = x.net.connection.ipaddress,
EntityId = x.net.ID.Value
}).ToArray();
}
[ServerVar(Help = "List of banned users")]
public static ServerUsers.User[] Bans()
{
@ -1899,7 +1948,7 @@ public class Admin : ConsoleSystem
NetworkOut = (int)((Network.Net.sv != null) ? Network.Net.sv.GetStat(null, BaseNetwork.StatTypeLong.BytesSent_LastSecond) : 0),
Restarting = SingletonComponent<ServerMgr>.Instance.Restarting,
SaveCreatedTime = SaveRestore.SaveCreatedTime.ToString(),
Version = 2592,
Version = 2594,
Protocol = Protocol.printable
};
}

View file

@ -0,0 +1,23 @@
namespace ConVar;
[Factory("bot")]
public class Bot : ConsoleSystem
{
[ServerVar(ClientAdmin = true, ShowInAdminUI = false)]
public static string crouch_server(Arg args)
{
ulong uLong = args.GetULong(0, 0uL);
if (uLong == 0L)
{
return "No user id";
}
BasePlayer basePlayer = BasePlayer.FindBot(uLong);
if (basePlayer == null)
{
return $"No bot found with id{uLong}";
}
basePlayer.modelState.ducked = args.GetBool(0, def: true);
basePlayer.SendNetworkUpdate();
return "Crouched " + basePlayer.displayName + ".";
}
}

View file

@ -507,6 +507,13 @@ public class CopyPaste : ConsoleSystem
Rust.Application.isLoadingSave = false;
Rust.Application.isLoading = false;
}
foreach (BaseEntity item in list)
{
if (!(item == null) && item is StabilityEntity stabilityEntity)
{
stabilityEntity.UpdateStability();
}
}
playerHistory.AddToHistory(steamId, list);
return list;
}

View file

@ -5,6 +5,7 @@ using System.IO;
using System.Linq;
using System.Text;
using System.Threading;
using Development.Attributes;
using Facepunch;
using Facepunch.Extend;
using Facepunch.Unity;
@ -15,6 +16,7 @@ using UnityEngine;
namespace ConVar;
[Factory("debug")]
[ResetStaticFields]
public class Debugging : ConsoleSystem
{
private const string NO_RECOVER_ARG = "--no-recover";
@ -515,6 +517,22 @@ public class Debugging : ConsoleSystem
}
}
[ServerVar]
public static void setmaxhealth(Arg arg)
{
if (!arg.HasArgs())
{
arg.ReplyWith("Please enter an amount.");
return;
}
int num = arg.GetInt(0);
BasePlayer usePlayer = GetUsePlayer(arg, 1);
if ((bool)usePlayer)
{
usePlayer.SetMaxHealth(num);
}
}
[ServerVar]
public static void setdamage(Arg arg)
{
@ -768,6 +786,35 @@ public class Debugging : ConsoleSystem
arg.ReplyWith($"Destroyed {num} overlapping static spawn points");
}
[ServerVar]
public static void setUnloadableCarFillPercent(Arg arg)
{
BasePlayer basePlayer = arg.Player();
if (basePlayer == null)
{
return;
}
Vector3 position = basePlayer.transform.position;
using PooledList<TrainCarUnloadable> pooledList = Facepunch.Pool.Get<PooledList<TrainCarUnloadable>>();
global::Vis.Entities(position, 3f, pooledList, 8192);
float num = Mathf.Clamp01(arg.GetFloat(0));
foreach (TrainCarUnloadable item in pooledList)
{
if (!item.isServer)
{
continue;
}
foreach (Item item2 in item.GetStorageContainer().inventory.itemList)
{
item2.amount = Mathf.Max(Mathf.RoundToInt(num), 1);
}
item.SetLootPercentage(num);
item.SetVisualOreLevel(num);
item.SendNetworkUpdate();
arg.ReplyWith($"Set ore level to {num} on {item.PrefabName}");
}
}
[ServerVar(Help = "Spawn lots of IO entities to lag the server")]
public static void bench_io(Arg arg)
{
@ -960,7 +1007,7 @@ public class Debugging : ConsoleSystem
arg.ReplyWith(stringBuilder.ToString());
}
[ServerVar(Help = "Make admin invisibile")]
[ServerVar(Help = "Make admin invisible")]
public static void invis(Arg arg)
{
BasePlayer basePlayer = arg.Player();
@ -1000,6 +1047,7 @@ public class Debugging : ConsoleSystem
}
}
arg.ReplyWith("Invis: " + basePlayer.limitNetworking);
basePlayer.Command("debug.setinvis_ui", basePlayer.limitNetworking);
}
private static void TickInvis()
@ -1130,4 +1178,18 @@ public class Debugging : ConsoleSystem
}
arg.ReplyWith(stringBuilder.ToString());
}
[ServerVar]
[ClientVar(ClientAdmin = true)]
public static void printqueues(Arg arg)
{
TextTable textTable = new TextTable();
textTable.AddColumns("Name", "Processed", "Size", "Execution Time");
foreach (ObjectWorkQueue item in ObjectWorkQueue.All.OrderBy((ObjectWorkQueue x) => x.Name))
{
string text = ((item.TotalExecutionTime.TotalMilliseconds < 1000.0) ? $"{Math.Floor(item.TotalExecutionTime.TotalMilliseconds)}ms" : $"{Math.Round(item.TotalExecutionTime.TotalSeconds, 2)}s");
textTable.AddRow(item.Name, item.TotalProcessedCount.ToString(), item.QueueLength.ToString(), text);
}
arg.ReplyWith(arg.HasArg("--json") ? textTable.ToJson() : textTable.ToString());
}
}

View file

@ -93,56 +93,52 @@ public class Decay : ConsoleSystem
[ServerVar(Help = "How long should this building grade take to decay when not protected by upkeep, in hours")]
public static float duration_toptier = 12f;
[ServerVar(Help = "Between 0 and this value are considered bracket 0 and will cost bracket_0_costfraction per upkeep period to maintain")]
public const int UpkeepBracketCount = 4;
[ServerVar(Help = "Number of blocks in the 1st upkeep bracket")]
public static int bracket_0_blockcount = 15;
[ServerVar(Help = "blocks within bracket 0 will cost this fraction per upkeep period to maintain")]
[ServerVar(Help = "Blocks in the 1st upkeep bracket will cost this value per day to maintain")]
public static float bracket_0_costfraction = 0.1f;
[ServerVar(Help = "Between bracket_0_blockcount and this value are considered bracket 1 and will cost bracket_1_costfraction per upkeep period to maintain")]
[ServerVar(Help = "Number of blocks in the 2nd upkeep bracket")]
public static int bracket_1_blockcount = 50;
[ServerVar(Help = "blocks within bracket 1 will cost this fraction per upkeep period to maintain")]
[ServerVar(Help = "Blocks in the 2nd upkeep bracket will cost this value per day to maintain")]
public static float bracket_1_costfraction = 0.15f;
[ServerVar(Help = "Between bracket_1_blockcount and this value are considered bracket 2 and will cost bracket_2_costfraction per upkeep period to maintain")]
[ServerVar(Help = "The number of blocks in the 3rd upkeep bracket")]
public static int bracket_2_blockcount = 125;
[ServerVar(Help = "blocks within bracket 2 will cost this fraction per upkeep period to maintain")]
[ServerVar(Help = "Blocks in the 3rd upkeep bracket will cost this value per day to maintain")]
public static float bracket_2_costfraction = 0.2f;
[ServerVar(Help = "Between bracket_2_blockcount and this value (and beyond) are considered bracket 3 and will cost bracket_3_costfraction per upkeep period to maintain")]
public static int bracket_3_blockcount = 200;
[ServerVar(Help = "blocks within bracket 3 will cost this fraction per upkeep period to maintain")]
[ServerVar(Help = "Blocks in the 4th upkeep bracket will cost this value per day to maintain")]
public static float bracket_3_costfraction = 0.333f;
[ServerVar]
[ServerVar(Help = "Should doors have their own upkeep brackets separate from building blocks")]
public static bool use_door_upkeep_brackets = false;
[ServerVar(Help = "Between 0 and this value are considered bracket 0 and will cost bracket_0_doorfraction per upkeep period to maintain")]
public static int bracket_0_doorcount = 5;
[ServerVar(Help = "Number of doors in the 1st upkeep bracket")]
public static int bracket_0_doorcount = 15;
[ServerVar(Help = "blocks within bracket 0 will cost this fraction per upkeep period to maintain")]
[ServerVar(Help = "Doors in the 1st upkeep bracket will cost this value per day to maintain")]
public static float bracket_0_doorfraction = 0.1f;
[ServerVar(Help = "Between bracket_0_blockcount and this value are considered bracket 1 and will cost bracket_1_doorfraction per upkeep period to maintain")]
public static int bracket_1_doorcount = 10;
[ServerVar(Help = "Number of doors in the 2nd upkeep bracket")]
public static int bracket_1_doorcount = 50;
[ServerVar(Help = "blocks within bracket 1 will cost this fraction per upkeep period to maintain")]
public static float bracket_1_doorfraction = 0.2f;
[ServerVar(Help = "Doors in the 2nd upkeep bracket will cost this value per day to maintain")]
public static float bracket_1_doorfraction = 0.15f;
[ServerVar(Help = "Between bracket_1_blockcount and this value are considered bracket 2 and will cost bracket_2_doorfraction per upkeep period to maintain")]
public static int bracket_2_doorcount = 20;
[ServerVar(Help = "The number of doors in the 3rd upkeep bracket")]
public static int bracket_2_doorcount = 125;
[ServerVar(Help = "blocks within bracket 2 will cost this fraction per upkeep period to maintain")]
public static float bracket_2_doorfraction = 0.5f;
[ServerVar(Help = "Doors in the 3rd upkeep bracket will cost this value per day to maintain")]
public static float bracket_2_doorfraction = 0.2f;
[ServerVar(Help = "Between bracket_2_blockcount and this value (and beyond) are considered bracket 3 and will cost bracket_3_doorfraction per upkeep period to maintain")]
public static int bracket_3_doorcount = 30;
[ServerVar(Help = "blocks within bracket 3 will cost this fraction per upkeep period to maintain")]
public static float bracket_3_doorfraction = 1f;
[ServerVar(Help = "Doors in the 4th upkeep bracket will cost this value per day to maintain")]
public static float bracket_3_doorfraction = 0.333f;
public static float GetCostMultiplier(BuildingGrade.Enum grade)
{

View file

@ -23,39 +23,14 @@ public class Global : ConsoleSystem
{
private static int _developer;
[ServerVar]
[ClientVar(Help = "WARNING: This causes random crashes!")]
public static bool skipAssetWarmup_crashes = false;
[ServerVar]
[ClientVar]
public static int maxthreads = 8;
private const int DefaultWarmupConcurrency = 1;
private const int DefaultPreloadConcurrency = 1;
[ServerVar]
[ClientVar]
public static int warmupConcurrency = 1;
[ServerVar]
[ClientVar]
public static int preloadConcurrency = 1;
[ServerVar]
[ClientVar]
public static bool forceUnloadBundles = true;
private const bool DefaultAsyncWarmupEnabled = false;
[ServerVar]
[ClientVar]
public static bool asyncWarmup = false;
[ClientVar(Saved = true, Help = "Experimental faster loading, requires game restart (0 = off, 1 = partial, 2 = full)")]
public static int asyncLoadingPreset = 0;
[ServerVar]
public static bool updateNetworkPositionWithDebugCameraWhileSpectating = false;
@ -63,8 +38,9 @@ public class Global : ConsoleSystem
[ClientVar(Saved = true)]
public static int perf = 0;
[ClientVar(ClientInfo = true, Saved = true, Help = "If you're an admin this will enable god mode")]
public static bool god = false;
private static bool _god = false;
private static bool _godforceoffoverlay = false;
[ClientVar]
[ServerVar(ClientAdmin = true, ServerAdmin = true, Help = "When enabled a player wearing a gingerbread suit will gib like the gingerbread NPC's")]
@ -131,41 +107,29 @@ public class Global : ConsoleSystem
}
}
public static void ApplyAsyncLoadingPreset()
[ClientVar(ClientInfo = true, Saved = true, Help = "If you're an admin this will enable god mode")]
public static bool god
{
if (asyncLoadingPreset != 0)
get
{
UnityEngine.Debug.Log($"Applying async loading preset number {asyncLoadingPreset}");
return _god;
}
switch (asyncLoadingPreset)
set
{
case 1:
if (warmupConcurrency <= 1)
{
warmupConcurrency = 256;
}
if (preloadConcurrency <= 1)
{
preloadConcurrency = 256;
}
asyncWarmup = false;
break;
case 2:
if (warmupConcurrency <= 1)
{
warmupConcurrency = 256;
}
if (preloadConcurrency <= 1)
{
preloadConcurrency = 256;
}
asyncWarmup = false;
break;
default:
UnityEngine.Debug.LogWarning($"There is no asyncLoading preset number {asyncLoadingPreset}");
break;
case 0:
break;
_god = value;
}
}
[ClientVar(ClientInfo = true, Saved = true, Help = "Media: Forces the global.god overlay to never show if enabled")]
public static bool godforceoffoverlay
{
get
{
return _godforceoffoverlay;
}
set
{
_godforceoffoverlay = value;
}
}
@ -866,6 +830,11 @@ public class Global : ConsoleSystem
public static void teleport2marker(Arg arg)
{
BasePlayer basePlayer = arg.Player();
if (basePlayer == null)
{
arg.ReplyWith("Must be called from a player");
return;
}
if (basePlayer.State.pointsOfInterest == null || basePlayer.State.pointsOfInterest.Count == 0)
{
arg.ReplyWith("You don't have a marker set");
@ -943,9 +912,14 @@ public class Global : ConsoleSystem
public static void teleport2death(Arg arg)
{
BasePlayer basePlayer = arg.Player();
if (basePlayer.ServerCurrentDeathNote == null)
if (basePlayer == null)
{
arg.ReplyWith("You don't have a current death note!");
arg.ReplyWith("Must be called from a player");
return;
}
if (basePlayer.State.deathMarker == null)
{
arg.ReplyWith("No death marker found");
return;
}
Vector3 worldPosition = basePlayer.ServerCurrentDeathNote.worldPosition;

View file

@ -145,11 +145,53 @@ public class Graphics : ConsoleSystem
{
get
{
return Shader.globalMaximumLOD;
int globalMaximumLOD = Shader.globalMaximumLOD;
if (globalMaximumLOD >= 100 && globalMaximumLOD <= 199)
{
return 1;
}
if (globalMaximumLOD >= 200 && globalMaximumLOD <= 299)
{
return 2;
}
if (globalMaximumLOD >= 300 && globalMaximumLOD <= 399)
{
return 3;
}
if (globalMaximumLOD >= 400 && globalMaximumLOD <= 499)
{
return 4;
}
if (globalMaximumLOD >= 500 && globalMaximumLOD <= 599)
{
return 5;
}
_ = 600;
return 6;
}
set
{
Shader.globalMaximumLOD = Mathf.Clamp(value, 100, 600);
switch (Mathf.Clamp(value, 1, 6))
{
case 1:
Shader.globalMaximumLOD = 100;
break;
case 2:
Shader.globalMaximumLOD = 200;
break;
case 3:
Shader.globalMaximumLOD = 300;
break;
case 4:
Shader.globalMaximumLOD = 400;
break;
case 5:
Shader.globalMaximumLOD = 500;
break;
case 6:
Shader.globalMaximumLOD = 600;
break;
}
}
}

View file

@ -36,8 +36,10 @@ public class GraphicsSettings : ConsoleSystem
}
set
{
QualitySettings.globalTextureMipmapLimit = Mathf.Clamp(value, 0, 3);
if (SingletonComponent<FoliageGrid>.Instance != null)
value = Mathf.Clamp(value, 0, 3);
bool num = QualitySettings.globalTextureMipmapLimit != value;
QualitySettings.globalTextureMipmapLimit = value;
if (num && SingletonComponent<FoliageGrid>.Instance != null)
{
SingletonComponent<FoliageGrid>.Instance.OnGlobalTextureMipmapLimitChange();
}

View file

@ -1,5 +1,8 @@
using Development.Attributes;
namespace ConVar;
[ResetStaticFields]
[Factory("grass")]
public class Grass : ConsoleSystem
{

View file

@ -463,10 +463,11 @@ public class Inventory : ConsoleSystem
{
BasePlayer ply = arg.Player();
int itemId = arg.GetInt(0);
List<Item> list = ply.inventory.FindItemsByItemID(itemId);
using PooledList<Item> pooledList = Facepunch.Pool.Get<PooledList<Item>>();
ply.inventory.FindItemsByItemID(pooledList, itemId);
ulong skinId = arg.GetULong(1, 1uL);
bool flag = false;
foreach (Item item in list)
foreach (Item item in pooledList)
{
if (item.skin == skinId)
{

View file

@ -84,22 +84,57 @@ public class Pool : ConsoleSystem
[ClientVar]
public static void print_arraypool(Arg arg)
{
ArrayPool<byte> arrayPool = BaseNetwork.ArrayPool;
ConcurrentQueue<byte[]>[] buffer = arrayPool.GetBuffer();
TextTable textTable = new TextTable();
textTable.AddColumn("index");
textTable.AddColumn("size");
textTable.AddColumn("bytes");
textTable.AddColumn("count");
textTable.AddColumn("memory");
for (int i = 0; i < buffer.Length; i++)
bool flag = arg.HasArg("--json");
string text = (flag ? "[" : string.Empty);
string table = PrintArrayPool<byte>(BaseNetwork.ArrayPool, flag);
text += FormatTable("BaseNetwork.ArrayPool", table, flag);
text += (flag ? "," : "\n");
string table2 = PrintArrayPool<byte>(BufferStream.Shared.ArrayPool, flag);
text += FormatTable("ProtocolParser.ArrayPool", table2, flag);
if (flag)
{
int num = arrayPool.IndexToSize(i);
int count = buffer[i].Count;
int input = num * count;
textTable.AddRow(i.ToString(), num.ToString(), num.FormatBytes(), count.ToString(), input.FormatBytes());
text += "]";
}
arg.ReplyWith(text);
static string FormatTable(string name, string text2, bool toJson)
{
if (!toJson)
{
return name + "\n" + text2;
}
return "{\"name\":\"" + name + "\",\"content\":" + text2 + "}";
}
unsafe static string PrintArrayPool<T>(ArrayPool<T> pool, bool toJson) where T : unmanaged
{
ConcurrentQueue<T[]>[] buffer = pool.GetBuffer();
TextTable textTable = new TextTable(!toJson);
textTable.ResizeColumns(5);
textTable.AddColumn("index");
textTable.AddColumn("size");
textTable.AddColumn("bytes");
textTable.AddColumn("count");
textTable.AddColumn("memory");
textTable.ResizeRows(buffer.Length);
int num = 1;
num = sizeof(T);
for (int i = 0; i < buffer.Length; i++)
{
int num2 = pool.IndexToSize(i);
int num3 = num2 * num;
int count = buffer[i].Count;
int input = num3 * count;
textTable.AddValue(i);
textTable.AddValue(num2);
textTable.AddValue(num2.FormatBytes());
textTable.AddValue(count);
textTable.AddValue(input.FormatBytes());
}
if (!toJson)
{
return textTable.ToString();
}
return textTable.ToJson(stringify: false);
}
arg.ReplyWith(arg.HasArg("--json") ? textTable.ToJson() : textTable.ToString());
}
[ServerVar]

View file

@ -1,9 +1,11 @@
using System;
using System.Collections;
using System.Collections.Generic;
using System.Diagnostics;
using System.IO;
using System.Linq;
using System.Text;
using Development.Attributes;
using Epic.OnlineServices.Logging;
using Epic.OnlineServices.Reports;
using Facepunch;
@ -16,6 +18,7 @@ using UnityEngine;
namespace ConVar;
[Factory("server")]
[ResetStaticFields]
public class Server : ConsoleSystem
{
[ServerVar]
@ -215,6 +218,9 @@ public class Server : ConsoleSystem
[ServerVar(Saved = true)]
public static float pvpBulletDamageMultiplier = 1f;
[ServerVar(Saved = true)]
public static float pveBulletDamageMultiplier = 1f;
[ServerVar]
public static int updatebatch = 512;
@ -404,6 +410,9 @@ public class Server : ConsoleSystem
[ServerVar(Help = "How long per frame to spend on industrial jobs", Saved = true, ShowInAdminUI = true)]
public static float industrialFrameBudgetMs = 0.5f;
[ServerVar(Help = "Should indusrial be paused during autosaves")]
public static bool pauseindustrialduringsave = true;
[ServerVar(Help = "When enabled industrial transfers will abort if they start to take too long. Will lead to inconsistent splitting but should retain performance", Saved = true)]
public static bool industrialTransferStrictTimeLimits = true;
@ -443,6 +452,9 @@ public class Server : ConsoleSystem
[ServerVar(Help = "Automatically upload procedurally generated maps so that players download them (faster) instead of re-generating them", Saved = true, ShowInAdminUI = true)]
public static bool autoUploadMap = true;
[ServerVar(Help = "Automatically upload an image of the map, used to show the map in the server browser", Saved = true, ShowInAdminUI = true)]
public static bool autoUploadMapImages = true;
[ReplicatedVar(Help = "How much of a tax to apply to workbench T2 tech unlocks. 10 = additional 10% scrap cost", Saved = true)]
public static float workbench2TaxRate = 10f;
@ -497,6 +509,18 @@ public class Server : ConsoleSystem
[ServerVar(Saved = true)]
public static bool allowVineSwinging = true;
[ServerVar(Saved = true, ShowInAdminUI = true, Help = "Bags will increase their respawn time by this much")]
public static float respawnTimeAdditionBag = 0f;
[ServerVar(Saved = true, ShowInAdminUI = true, Help = "Beds will increase their respawn time by this much")]
public static float respawnTimeAdditionBed = 0f;
[ServerVar(Saved = true, ShowInAdminUI = true, Help = "All ammo drops from NPC loot will be multiplied by this")]
public static float npcAmmoLootMultiplier = 1f;
[ReplicatedVar(Help = "Multiplies crafting cost of firearm ammunition", Saved = true, ShowInAdminUI = true)]
public static float hardcoreFirearmAmmunitionCraftingMultiplier = 1f;
[ServerVar(Saved = true)]
public static bool showHolsteredItems = true;
@ -536,6 +560,9 @@ public class Server : ConsoleSystem
[ServerVar]
public static bool rpclog_enabled = false;
[ServerVar(Help = "MS per frame to spend warming up entity save caches")]
public static int saveframebudget = 5;
[ServerVar]
public static bool UsePlayerUpdateJobs = false;
@ -1099,10 +1126,10 @@ public class Server : ConsoleSystem
arg.ReplyWith("There is already a server running!");
return;
}
string text = arg.GetString(0, level);
if (!LevelManager.IsValid(text))
string strLevelName = arg.GetString(0, level);
if (!LevelManager.IsValid(strLevelName))
{
arg.ReplyWith("Level '" + text + "' isn't valid!");
arg.ReplyWith("Level '" + strLevelName + "' isn't valid!");
return;
}
if ((bool)UnityEngine.Object.FindObjectOfType<ServerMgr>())
@ -1112,7 +1139,11 @@ public class Server : ConsoleSystem
}
UnityEngine.Object.DontDestroyOnLoad(GameManager.server.CreatePrefab("assets/bundled/prefabs/system/shared.prefab"));
UnityEngine.Object.DontDestroyOnLoad(GameManager.server.CreatePrefab("assets/bundled/prefabs/system/server.prefab"));
LevelManager.LoadLevel(text);
Rust.Global.Runner.StartCoroutine(LoadImpl());
IEnumerator LoadImpl()
{
yield return LevelManager.LoadLevelAsync(strLevelName);
}
}
[ServerVar(Help = "Stops a server")]
@ -1536,7 +1567,7 @@ public class Server : ConsoleSystem
foreach (Item allItem in ItemManager.GetAllItems())
{
num++;
if (!allItem.info.IsAllowedInEra(EraRestriction.Default))
if (!allItem.info.IsAllowed(EraRestriction.Default))
{
if (!dictionary.ContainsKey(allItem.info.shortname))
{
@ -1623,6 +1654,45 @@ public class Server : ConsoleSystem
}
}
public static TextTable GetPlayerReportsListTable(bool forJson)
{
TextTable textTable = new TextTable(!forJson);
textTable.ResizeColumns(4);
textTable.AddColumn("NumReports");
textTable.AddColumn("UserID");
textTable.AddColumn("DisplayName");
textTable.AddColumn("IsConnected");
foreach (BasePlayer item in BasePlayer.allPlayerList.OrderByDescending((BasePlayer x) => x.State.numberOfTimesReported))
{
if (item.State.numberOfTimesReported >= 1)
{
textTable.AddValue(item.State.numberOfTimesReported);
textTable.AddValue(item.userID);
textTable.AddValue(item.displayName);
textTable.AddValue(item.IsConnected);
}
}
return textTable;
}
[ServerVar(Help = "List the amount of reports players on the server have received")]
public static void listplayerreportcounts(Arg arg)
{
bool flag = arg.HasArg("--json");
TextTable playerReportsListTable = GetPlayerReportsListTable(flag);
arg.ReplyWith(flag ? playerReportsListTable.ToJson() : playerReportsListTable.ToString());
}
[ServerVar(Help = "Clear the player reports list")]
public static void clearplayerreportcounts(Arg arg)
{
foreach (BasePlayer allPlayer in BasePlayer.allPlayerList)
{
allPlayer.State.numberOfTimesReported = 0;
}
arg.ReplyWith("Cleared report counts");
}
private static void OnEraChanged()
{
foreach (BaseNetworkable serverEntity in BaseNetworkable.serverEntities)

View file

@ -27,6 +27,12 @@ public class Stability : ConsoleSystem
[ServerVar]
public static bool support_highest_stability = true;
[ServerVar]
public static bool log_stability_death = false;
[ServerVar]
public static bool log_ground_missing_death = false;
[ServerVar]
public static void refresh_stability(Arg args)
{

View file

@ -1,5 +1,6 @@
using System;
using System.Globalization;
using System.Text;
using UnityEngine;
namespace ConVar;
@ -536,6 +537,686 @@ public class Weather : ConsoleSystem
}
}
[ReplicatedVar(Default = "-1")]
public static float ambient_light_multiplier
{
get
{
if (!SingletonComponent<Climate>.Instance)
{
return -1f;
}
return SingletonComponent<Climate>.Instance.WeatherOverrides.AmbientLightMultiplier;
}
set
{
if ((bool)SingletonComponent<Climate>.Instance)
{
SingletonComponent<Climate>.Instance.WeatherOverrides.AmbientLightMultiplier = value;
}
}
}
[ReplicatedVar(Default = "-1")]
public static float directional_light_multiplier
{
get
{
if (!SingletonComponent<Climate>.Instance)
{
return -1f;
}
return SingletonComponent<Climate>.Instance.WeatherOverrides.DirectionalLightMultiplier;
}
set
{
if ((bool)SingletonComponent<Climate>.Instance)
{
SingletonComponent<Climate>.Instance.WeatherOverrides.DirectionalLightMultiplier = value;
}
}
}
[ReplicatedVar(Default = "-1")]
public static float reflection_multiplier
{
get
{
if (!SingletonComponent<Climate>.Instance)
{
return -1f;
}
return SingletonComponent<Climate>.Instance.WeatherOverrides.ReflectionMultiplier;
}
set
{
if ((bool)SingletonComponent<Climate>.Instance)
{
SingletonComponent<Climate>.Instance.WeatherOverrides.ReflectionMultiplier = value;
}
}
}
[ReplicatedVar(Default = "-1")]
public static float sun_mesh_brightness_multiplier
{
get
{
if (!SingletonComponent<Climate>.Instance)
{
return -1f;
}
return SingletonComponent<Climate>.Instance.WeatherOverrides.SunMeshBrightnessMultiplier;
}
set
{
if ((bool)SingletonComponent<Climate>.Instance)
{
SingletonComponent<Climate>.Instance.WeatherOverrides.SunMeshBrightnessMultiplier = value;
}
}
}
[ReplicatedVar(Default = "-1")]
public static float moon_mesh_brightness_multiplier
{
get
{
if (!SingletonComponent<Climate>.Instance)
{
return -1f;
}
return SingletonComponent<Climate>.Instance.WeatherOverrides.MoonMeshBrightnessMultiplier;
}
set
{
if ((bool)SingletonComponent<Climate>.Instance)
{
SingletonComponent<Climate>.Instance.WeatherOverrides.MoonMeshBrightnessMultiplier = value;
}
}
}
[ReplicatedVar(Default = "-1")]
public static float fog_multiplier
{
get
{
if (!SingletonComponent<Climate>.Instance)
{
return -1f;
}
return SingletonComponent<Climate>.Instance.WeatherOverrides.FogMultiplier;
}
set
{
if ((bool)SingletonComponent<Climate>.Instance)
{
SingletonComponent<Climate>.Instance.WeatherOverrides.FogMultiplier = value;
}
}
}
[ReplicatedVar(Default = "-1")]
public static float biome_fog_distance_curve
{
get
{
if (!SingletonComponent<Climate>.Instance)
{
return -1f;
}
return SingletonComponent<Climate>.Instance.WeatherOverrides.BiomeFogDistanceCurve;
}
set
{
if ((bool)SingletonComponent<Climate>.Instance)
{
SingletonComponent<Climate>.Instance.WeatherOverrides.BiomeFogDistanceCurve = value;
}
}
}
[ReplicatedVar(Default = "-1")]
public static float biome_fog_ambient_saturation_mult
{
get
{
if (!SingletonComponent<Climate>.Instance)
{
return -1f;
}
return SingletonComponent<Climate>.Instance.WeatherOverrides.BiomeFogAmbientSaturationMult;
}
set
{
if ((bool)SingletonComponent<Climate>.Instance)
{
SingletonComponent<Climate>.Instance.WeatherOverrides.BiomeFogAmbientSaturationMult = value;
}
}
}
[ReplicatedVar(Default = "-1")]
public static float atmosphere_fog_height_falloff
{
get
{
if (!SingletonComponent<Climate>.Instance)
{
return -1f;
}
return SingletonComponent<Climate>.Instance.WeatherOverrides.AtmosphereFogHeightFalloff;
}
set
{
if ((bool)SingletonComponent<Climate>.Instance)
{
SingletonComponent<Climate>.Instance.WeatherOverrides.AtmosphereFogHeightFalloff = value;
}
}
}
[ReplicatedVar(Default = "-1")]
public static float vclouds_sun_color_scale
{
get
{
if (!SingletonComponent<Climate>.Instance)
{
return -1f;
}
return SingletonComponent<Climate>.Instance.WeatherOverrides.VolumeCloudsSunColorScale;
}
set
{
if ((bool)SingletonComponent<Climate>.Instance)
{
SingletonComponent<Climate>.Instance.WeatherOverrides.VolumeCloudsSunColorScale = value;
}
}
}
[ReplicatedVar(Default = "-1")]
public static float vclouds_moon_color_scale
{
get
{
if (!SingletonComponent<Climate>.Instance)
{
return -1f;
}
return SingletonComponent<Climate>.Instance.WeatherOverrides.VolumeCloudsMoonColorScale;
}
set
{
if ((bool)SingletonComponent<Climate>.Instance)
{
SingletonComponent<Climate>.Instance.WeatherOverrides.VolumeCloudsMoonColorScale = value;
}
}
}
[ReplicatedVar(Default = "-1")]
public static float arid_fog_ambient_intensity_mult
{
get
{
if (!SingletonComponent<Climate>.Instance)
{
return -1f;
}
return SingletonComponent<Climate>.Instance.WeatherOverrides.AridFogMults.AmbientIntensityMult;
}
set
{
if ((bool)SingletonComponent<Climate>.Instance)
{
SingletonComponent<Climate>.Instance.WeatherOverrides.AridFogMults.AmbientIntensityMult = value;
}
}
}
[ReplicatedVar(Default = "-1")]
public static float arid_fog_light_boost_mult
{
get
{
if (!SingletonComponent<Climate>.Instance)
{
return -1f;
}
return SingletonComponent<Climate>.Instance.WeatherOverrides.AridFogMults.LightBoostMult;
}
set
{
if ((bool)SingletonComponent<Climate>.Instance)
{
SingletonComponent<Climate>.Instance.WeatherOverrides.AridFogMults.LightBoostMult = value;
}
}
}
[ReplicatedVar(Default = "-1")]
public static float arid_fog_ramp_start
{
get
{
if (!SingletonComponent<Climate>.Instance)
{
return -1f;
}
return SingletonComponent<Climate>.Instance.WeatherOverrides.AridFogMults.FogRampStartDist;
}
set
{
if ((bool)SingletonComponent<Climate>.Instance)
{
SingletonComponent<Climate>.Instance.WeatherOverrides.AridFogMults.FogRampStartDist = value;
}
}
}
[ReplicatedVar(Default = "-1")]
public static float arid_fog_ramp_end
{
get
{
if (!SingletonComponent<Climate>.Instance)
{
return -1f;
}
return SingletonComponent<Climate>.Instance.WeatherOverrides.AridFogMults.FogRampEndDist;
}
set
{
if ((bool)SingletonComponent<Climate>.Instance)
{
SingletonComponent<Climate>.Instance.WeatherOverrides.AridFogMults.FogRampEndDist = value;
}
}
}
[ReplicatedVar(Default = "-1")]
public static float temperate_fog_ambient_intensity_mult
{
get
{
if (!SingletonComponent<Climate>.Instance)
{
return -1f;
}
return SingletonComponent<Climate>.Instance.WeatherOverrides.TemperateFogMults.AmbientIntensityMult;
}
set
{
if ((bool)SingletonComponent<Climate>.Instance)
{
SingletonComponent<Climate>.Instance.WeatherOverrides.TemperateFogMults.AmbientIntensityMult = value;
}
}
}
[ReplicatedVar(Default = "-1")]
public static float temperate_fog_light_boost_mult
{
get
{
if (!SingletonComponent<Climate>.Instance)
{
return -1f;
}
return SingletonComponent<Climate>.Instance.WeatherOverrides.TemperateFogMults.LightBoostMult;
}
set
{
if ((bool)SingletonComponent<Climate>.Instance)
{
SingletonComponent<Climate>.Instance.WeatherOverrides.TemperateFogMults.LightBoostMult = value;
}
}
}
[ReplicatedVar(Default = "-1")]
public static float temperate_fog_ramp_start
{
get
{
if (!SingletonComponent<Climate>.Instance)
{
return -1f;
}
return SingletonComponent<Climate>.Instance.WeatherOverrides.TemperateFogMults.FogRampStartDist;
}
set
{
if ((bool)SingletonComponent<Climate>.Instance)
{
SingletonComponent<Climate>.Instance.WeatherOverrides.TemperateFogMults.FogRampStartDist = value;
}
}
}
[ReplicatedVar(Default = "-1")]
public static float temperate_fog_ramp_end
{
get
{
if (!SingletonComponent<Climate>.Instance)
{
return -1f;
}
return SingletonComponent<Climate>.Instance.WeatherOverrides.TemperateFogMults.FogRampEndDist;
}
set
{
if ((bool)SingletonComponent<Climate>.Instance)
{
SingletonComponent<Climate>.Instance.WeatherOverrides.TemperateFogMults.FogRampEndDist = value;
}
}
}
[ReplicatedVar(Default = "-1")]
public static float tundra_fog_ambient_intensity_mult
{
get
{
if (!SingletonComponent<Climate>.Instance)
{
return -1f;
}
return SingletonComponent<Climate>.Instance.WeatherOverrides.TundraFogMults.AmbientIntensityMult;
}
set
{
if ((bool)SingletonComponent<Climate>.Instance)
{
SingletonComponent<Climate>.Instance.WeatherOverrides.TundraFogMults.AmbientIntensityMult = value;
}
}
}
[ReplicatedVar(Default = "-1")]
public static float tundra_fog_light_boost_mult
{
get
{
if (!SingletonComponent<Climate>.Instance)
{
return -1f;
}
return SingletonComponent<Climate>.Instance.WeatherOverrides.TundraFogMults.LightBoostMult;
}
set
{
if ((bool)SingletonComponent<Climate>.Instance)
{
SingletonComponent<Climate>.Instance.WeatherOverrides.TundraFogMults.LightBoostMult = value;
}
}
}
[ReplicatedVar(Default = "-1")]
public static float tundra_fog_ramp_start
{
get
{
if (!SingletonComponent<Climate>.Instance)
{
return -1f;
}
return SingletonComponent<Climate>.Instance.WeatherOverrides.TundraFogMults.FogRampStartDist;
}
set
{
if ((bool)SingletonComponent<Climate>.Instance)
{
SingletonComponent<Climate>.Instance.WeatherOverrides.TundraFogMults.FogRampStartDist = value;
}
}
}
[ReplicatedVar(Default = "-1")]
public static float tundra_fog_ramp_end
{
get
{
if (!SingletonComponent<Climate>.Instance)
{
return -1f;
}
return SingletonComponent<Climate>.Instance.WeatherOverrides.TundraFogMults.FogRampEndDist;
}
set
{
if ((bool)SingletonComponent<Climate>.Instance)
{
SingletonComponent<Climate>.Instance.WeatherOverrides.TundraFogMults.FogRampEndDist = value;
}
}
}
[ReplicatedVar(Default = "-1")]
public static float arctic_fog_ambient_intensity_mult
{
get
{
if (!SingletonComponent<Climate>.Instance)
{
return -1f;
}
return SingletonComponent<Climate>.Instance.WeatherOverrides.ArcticFogMults.AmbientIntensityMult;
}
set
{
if ((bool)SingletonComponent<Climate>.Instance)
{
SingletonComponent<Climate>.Instance.WeatherOverrides.ArcticFogMults.AmbientIntensityMult = value;
}
}
}
[ReplicatedVar(Default = "-1")]
public static float arctic_fog_light_boost_mult
{
get
{
if (!SingletonComponent<Climate>.Instance)
{
return -1f;
}
return SingletonComponent<Climate>.Instance.WeatherOverrides.ArcticFogMults.LightBoostMult;
}
set
{
if ((bool)SingletonComponent<Climate>.Instance)
{
SingletonComponent<Climate>.Instance.WeatherOverrides.ArcticFogMults.LightBoostMult = value;
}
}
}
[ReplicatedVar(Default = "-1")]
public static float arctic_fog_ramp_start
{
get
{
if (!SingletonComponent<Climate>.Instance)
{
return -1f;
}
return SingletonComponent<Climate>.Instance.WeatherOverrides.ArcticFogMults.FogRampStartDist;
}
set
{
if ((bool)SingletonComponent<Climate>.Instance)
{
SingletonComponent<Climate>.Instance.WeatherOverrides.ArcticFogMults.FogRampStartDist = value;
}
}
}
[ReplicatedVar(Default = "-1")]
public static float arctic_fog_ramp_end
{
get
{
if (!SingletonComponent<Climate>.Instance)
{
return -1f;
}
return SingletonComponent<Climate>.Instance.WeatherOverrides.ArcticFogMults.FogRampEndDist;
}
set
{
if ((bool)SingletonComponent<Climate>.Instance)
{
SingletonComponent<Climate>.Instance.WeatherOverrides.ArcticFogMults.FogRampEndDist = value;
}
}
}
[ReplicatedVar(Default = "-1")]
public static float jungle_fog_ambient_intensity_mult
{
get
{
if (!SingletonComponent<Climate>.Instance)
{
return -1f;
}
return SingletonComponent<Climate>.Instance.WeatherOverrides.JungleFogMults.AmbientIntensityMult;
}
set
{
if ((bool)SingletonComponent<Climate>.Instance)
{
SingletonComponent<Climate>.Instance.WeatherOverrides.JungleFogMults.AmbientIntensityMult = value;
}
}
}
[ReplicatedVar(Default = "-1")]
public static float jungle_fog_light_boost_mult
{
get
{
if (!SingletonComponent<Climate>.Instance)
{
return -1f;
}
return SingletonComponent<Climate>.Instance.WeatherOverrides.JungleFogMults.LightBoostMult;
}
set
{
if ((bool)SingletonComponent<Climate>.Instance)
{
SingletonComponent<Climate>.Instance.WeatherOverrides.JungleFogMults.LightBoostMult = value;
}
}
}
[ReplicatedVar(Default = "-1")]
public static float jungle_fog_ramp_start
{
get
{
if (!SingletonComponent<Climate>.Instance)
{
return -1f;
}
return SingletonComponent<Climate>.Instance.WeatherOverrides.JungleFogMults.FogRampStartDist;
}
set
{
if ((bool)SingletonComponent<Climate>.Instance)
{
SingletonComponent<Climate>.Instance.WeatherOverrides.JungleFogMults.FogRampStartDist = value;
}
}
}
[ReplicatedVar(Default = "-1")]
public static float jungle_fog_ramp_end
{
get
{
if (!SingletonComponent<Climate>.Instance)
{
return -1f;
}
return SingletonComponent<Climate>.Instance.WeatherOverrides.JungleFogMults.FogRampEndDist;
}
set
{
if ((bool)SingletonComponent<Climate>.Instance)
{
SingletonComponent<Climate>.Instance.WeatherOverrides.JungleFogMults.FogRampEndDist = value;
}
}
}
[ReplicatedVar(Default = "-1")]
public static int cloud_config
{
get
{
if (!SingletonComponent<Climate>.Instance)
{
return -1;
}
return SingletonComponent<Climate>.Instance.WeatherOverrides.OverrideCloudConfig;
}
set
{
if ((bool)SingletonComponent<Climate>.Instance)
{
SingletonComponent<Climate>.Instance.WeatherOverrides.OverrideCloudConfig = value;
}
}
}
[ReplicatedVar(Default = "-1")]
public static float atmosphere_fog_ramp_start_distance
{
get
{
if (!SingletonComponent<Climate>.Instance)
{
return -1f;
}
return SingletonComponent<Climate>.Instance.WeatherOverrides.AtmosphereFogRampStartDistance;
}
set
{
if ((bool)SingletonComponent<Climate>.Instance)
{
SingletonComponent<Climate>.Instance.WeatherOverrides.AtmosphereFogRampStartDistance = value;
}
}
}
[ReplicatedVar(Default = "-1")]
public static float atmosphere_fog_ramp_end_distance
{
get
{
if (!SingletonComponent<Climate>.Instance)
{
return -1f;
}
return SingletonComponent<Climate>.Instance.WeatherOverrides.AtmosphereFogRampEndDistance;
}
set
{
if ((bool)SingletonComponent<Climate>.Instance)
{
SingletonComponent<Climate>.Instance.WeatherOverrides.AtmosphereFogRampEndDistance = value;
}
}
}
[ClientVar]
[ServerVar]
public static void load(Arg args)
@ -557,6 +1238,7 @@ public class Weather : ConsoleSystem
return;
}
SingletonComponent<Climate>.Instance.WeatherOverrides.Set(weatherPreset);
SingletonComponent<Climate>.Instance.WeatherOverrides.SetVolumeCloudsConfigs(weatherPreset);
if (args.IsServerside)
{
ServerMgr.SendReplicatedVars("weather.");
@ -568,6 +1250,73 @@ public class Weather : ConsoleSystem
return Array.Find(SingletonComponent<Climate>.Instance.WeatherPresets, (WeatherPreset x) => x.name.Contains(withName, CompareOptions.IgnoreCase));
}
[ClientVar]
public static void debug_cloud_position(Arg args)
{
}
[ClientVar]
[ServerVar]
public static void load_cloud_config(Arg args)
{
if (!SingletonComponent<Climate>.Instance)
{
return;
}
string name = args.GetString(0);
if (string.IsNullOrEmpty(name))
{
return;
}
VolumeCloudsConfig volumeCloudsConfig = Array.Find(SingletonComponent<Climate>.Instance.AllCloudConfigs, (VolumeCloudsConfig x) => x.name.Contains(name, CompareOptions.IgnoreCase));
if (volumeCloudsConfig == null)
{
args.ReplyWith("Cloud config not found: " + name);
return;
}
WeatherPreset weatherOverrides = SingletonComponent<Climate>.Instance.WeatherOverrides;
weatherOverrides.VolumeCloudsConfigs = new VolumeCloudsConfig[1] { volumeCloudsConfig };
int overrideCloudConfig = Array.IndexOf(SingletonComponent<Climate>.Instance.AllCloudConfigs, volumeCloudsConfig);
weatherOverrides.OverrideCloudConfig = overrideCloudConfig;
if (args.IsServerside)
{
ServerMgr.SendReplicatedVars("weather.");
}
}
[ClientVar]
[ServerVar]
public static void list_cloud_configs(Arg args)
{
if ((bool)SingletonComponent<Climate>.Instance)
{
VolumeCloudsConfig[] allCloudConfigs = SingletonComponent<Climate>.Instance.AllCloudConfigs;
StringBuilder stringBuilder = new StringBuilder();
VolumeCloudsConfig[] array = allCloudConfigs;
foreach (VolumeCloudsConfig volumeCloudsConfig in array)
{
stringBuilder.AppendLine(volumeCloudsConfig.name);
}
args.ReplyWith(stringBuilder.ToString());
}
}
[ClientVar]
[ServerVar]
public static void reset_cloud_config(Arg args)
{
if ((bool)SingletonComponent<Climate>.Instance)
{
WeatherPreset weatherOverrides = SingletonComponent<Climate>.Instance.WeatherOverrides;
weatherOverrides.VolumeCloudsConfigs = null;
weatherOverrides.OverrideCloudConfig = -1;
if (args.IsServerside)
{
ServerMgr.SendReplicatedVars("weather.");
}
}
}
[ClientVar]
[ServerVar]
public static void reset(Arg args)
@ -575,6 +1324,7 @@ public class Weather : ConsoleSystem
if ((bool)SingletonComponent<Climate>.Instance)
{
SingletonComponent<Climate>.Instance.WeatherOverrides.Reset();
SingletonComponent<Climate>.Instance.WeatherOverrides.VolumeCloudsConfigs = null;
if (args.IsServerside)
{
ServerMgr.SendReplicatedVars("weather.");

View file

@ -67,7 +67,7 @@ public class ConnectionAuth : MonoBehaviour
Reject(connection, "Invalid SteamID");
return;
}
if (connection.protocol != 2592)
if (connection.protocol != 2594)
{
if (!DeveloperList.Contains(connection.userid))
{

File diff suppressed because it is too large Load diff

View file

@ -1,5 +1,7 @@
using Development.Attributes;
using UnityEngine;
[ResetStaticFields]
public class CursorManager : SingletonComponent<CursorManager>
{
private static int iHoldOpen;

View file

@ -1,5 +1,7 @@
using Development.Attributes;
using UnityEngine;
[ResetStaticFields]
public class DecorSpawn : MonoBehaviour, IClientComponent
{
public SpawnFilter Filter;

View file

@ -1,6 +1,7 @@
using UnityEngine;
[ExecuteInEditMode]
[RequireComponent(typeof(Camera))]
[RequireComponent(typeof(CommandBufferManager))]
public class DeferredIndirectLightingPass : MonoBehaviour
{

View file

@ -21,7 +21,7 @@ public class DemoShotButton : RustButton, IPointerClickHandler, IEventSystemHand
}
}
public void OnPointerClick(PointerEventData eventData)
public new void OnPointerClick(PointerEventData eventData)
{
if (FireEventOnClicked)
{

View file

@ -74,6 +74,10 @@ public class DeployableBoomBox : ContainerIOEntity, ICassettePlayer, IAudioConne
{
using (TimeWarning.New("Conditions"))
{
if (!RPC_Server.CallsPerSecond.Test(1785864031u, "ServerTogglePlay", this, player, 2uL))
{
return true;
}
if (!RPC_Server.IsVisible.Test(1785864031u, "ServerTogglePlay", this, player, 3f))
{
return true;
@ -182,6 +186,7 @@ public class DeployableBoomBox : ContainerIOEntity, ICassettePlayer, IAudioConne
}
[RPC_Server]
[RPC_Server.CallsPerSecond(2uL)]
[RPC_Server.IsVisible(3f)]
public void ServerTogglePlay(RPCMessage msg)
{

View file

@ -36,6 +36,10 @@ public class DeployedRecorder : StorageContainer, ICassettePlayer
{
using (TimeWarning.New("Conditions"))
{
if (!RPC_Server.CallsPerSecond.Test(1785864031u, "ServerTogglePlay", this, player, 2uL))
{
return true;
}
if (!RPC_Server.IsVisible.Test(1785864031u, "ServerTogglePlay", this, player, 3f))
{
return true;
@ -67,6 +71,7 @@ public class DeployedRecorder : StorageContainer, ICassettePlayer
}
[RPC_Server]
[RPC_Server.CallsPerSecond(2uL)]
[RPC_Server.IsVisible(3f)]
public void ServerTogglePlay(RPCMessage msg)
{

View file

@ -1,3 +1,4 @@
using ConVar;
using UnityEngine;
public class DestroyOnGroundMissing : MonoBehaviour, IServerComponent
@ -8,6 +9,10 @@ public class DestroyOnGroundMissing : MonoBehaviour, IServerComponent
if (baseEntity != null)
{
BaseCombatEntity baseCombatEntity = baseEntity as BaseCombatEntity;
if (Stability.log_ground_missing_death)
{
Debug.Log($"Killing '{baseEntity.ToString()}' at position {base.transform.position} due to ground missing");
}
if (baseCombatEntity != null)
{
baseCombatEntity.Die();

View file

@ -0,0 +1,7 @@
using System;
namespace Development.Attributes;
public class ResetStaticFieldsAttribute : Attribute
{
}

View file

@ -17,6 +17,14 @@ public class DiggableEntityLoot : ScriptableObject
public int Min;
public int Max;
public ulong Skin;
public float? Condition;
public ItemOwnershipShare? Owner;
public ulong? UID;
}
public List<ItemEntry> Items = new List<ItemEntry>();
@ -43,7 +51,7 @@ public class DiggableEntityLoot : ScriptableObject
allowedItems = new List<ItemEntry>();
foreach (ItemEntry item in Items)
{
if (item.Item.IsAllowedInEra(EraRestriction.MetalDetector))
if (item.Item.IsAllowed(EraRestriction.MetalDetector))
{
allowedItems.Add(item);
}

View file

@ -0,0 +1,153 @@
#define UNITY_ASSERTIONS
using System;
using System.Collections.Generic;
using System.Runtime.CompilerServices;
using ConVar;
using Facepunch;
using Network;
using UnityEngine;
using UnityEngine.Assertions;
public class DigitSendCodeLock : CodeLock
{
public ParticleSystem digitsViewParticleSystem;
public List<Transform> digitsParticleAnchorsFront;
public List<Transform> digitsParticleAnchorsBack;
private int __sync_digitsInputted;
[Sync]
private int digitsInputted
{
[CompilerGenerated]
get
{
return __sync_digitsInputted;
}
[CompilerGenerated]
set
{
if (!IsSyncVarEqual(__sync_digitsInputted, value))
{
__sync_digitsInputted = value;
byte nameID = __GetWeaverID("digitsInputted");
QueueSyncVar(nameID);
}
}
}
public override bool OnRpcMessage(BasePlayer player, uint rpc, Message msg)
{
using (TimeWarning.New("DigitSendCodeLock.OnRpcMessage"))
{
if (rpc == 3077276815u && player != null)
{
Assert.IsTrue(player.isServer, "SV_RPC Message is using a clientside player!");
if (Global.developer > 2)
{
Debug.Log("SV_RPCMessage: " + player?.ToString() + " - OnDigitEntered ");
}
using (TimeWarning.New("OnDigitEntered"))
{
using (TimeWarning.New("Conditions"))
{
if (!RPC_Server.CallsPerSecond.Test(3077276815u, "OnDigitEntered", this, player, 4uL))
{
return true;
}
if (!RPC_Server.MaxDistance.Test(3077276815u, "OnDigitEntered", this, player, 3f))
{
return true;
}
}
try
{
using (TimeWarning.New("Call"))
{
RPCMessage rpc2 = new RPCMessage
{
connection = msg.connection,
player = player,
read = msg.read
};
OnDigitEntered(rpc2);
}
}
catch (Exception exception)
{
Debug.LogException(exception);
player.Kick("RPC Error in OnDigitEntered");
}
}
return true;
}
}
return base.OnRpcMessage(player, rpc, msg);
}
[RPC_Server]
[RPC_Server.CallsPerSecond(4uL)]
[RPC_Server.MaxDistance(3f)]
private void OnDigitEntered(RPCMessage rpc)
{
int num = rpc.read.Int16();
digitsInputted = num;
}
protected override bool WriteSyncVar(byte id, NetWrite writer)
{
if (id == 0)
{
if (Global.developer > 2)
{
NetworkableId iD = net.ID;
Debug.Log("SyncVar Writing: digitsInputted for " + iD.ToString());
}
SyncVarNetWrite(writer, __sync_digitsInputted);
return true;
}
return false;
}
protected override bool OnSyncVar(byte id, NetRead reader, bool fromAutoSave = false)
{
return false;
}
private byte __GetWeaverID(string propertyName)
{
_ = propertyName == "digitsInputted";
return 0;
}
protected override bool AutoSaveSyncVars(SaveInfo save)
{
NetWrite obj = Network.Net.sv.StartWrite();
var (src, num) = obj.GetBuffer();
if (_autosaveBuffer == null)
{
_autosaveBuffer = BaseEntity._autosaveBufferPool.Rent(num);
}
if (_autosaveBuffer.Length < num)
{
BaseEntity._autosaveBufferPool.Return(_autosaveBuffer);
_autosaveBuffer = BaseEntity._autosaveBufferPool.Rent(num);
}
Buffer.BlockCopy(src, 0, _autosaveBuffer, 0, num);
save.msg.baseEntity.syncVars = _autosaveBuffer;
Facepunch.Pool.Free(ref obj);
return true;
}
protected override bool AutoLoadSyncVars(LoadInfo load)
{
return true;
}
protected override void ResetSyncVars()
{
__sync_digitsInputted = 0;
}
}

View file

@ -86,6 +86,10 @@ public class Door : AnimatedBuildingBlock, INotifyTrigger, ISimpleUpgradable
private static int reverseOpenHash = Animator.StringToHash("reverseOpen");
private static int reverseCloseAnimHash = Animator.StringToHash("CloseReverse");
private static int reverseOpenAnimHash = Animator.StringToHash("OpenReverse");
public override bool AllowOnCargoShip => allowOnCargoShip;
private bool HasVehiclePushBoxes
@ -817,12 +821,19 @@ public class Door : AnimatedBuildingBlock, INotifyTrigger, ISimpleUpgradable
}
}
private void ReverseDoorAnimation(bool wasOpening)
private void ReverseDoorAnimation(bool wasOpening, bool reverse)
{
if (!(model == null) && !(model.animator == null))
{
AnimatorStateInfo currentAnimatorStateInfo = model.animator.GetCurrentAnimatorStateInfo(0);
model.animator.Play(wasOpening ? closeHash : openHash, 0, 1f - currentAnimatorStateInfo.normalizedTime);
if (reverse)
{
model.animator.Play(wasOpening ? reverseCloseAnimHash : reverseOpenAnimHash, 0, 1f - currentAnimatorStateInfo.normalizedTime);
}
else
{
model.animator.Play(wasOpening ? closeHash : openHash, 0, 1f - currentAnimatorStateInfo.normalizedTime);
}
}
}
@ -886,28 +897,29 @@ public class Door : AnimatedBuildingBlock, INotifyTrigger, ISimpleUpgradable
return;
}
bool flag2 = HasFlag(Flags.Open);
if (checkPhysBoxesOnOpen)
bool flag3 = HasFlag(Flags.Reserved1);
if (checkPhysBoxesOnOpen && !canReverseOpen)
{
bool flag3 = true;
bool flag4 = true;
TriggerNotify[] array = vehiclePhysBoxes;
foreach (TriggerNotify triggerNotify in array)
{
float num = Vector3.Dot(triggerNotify.transform.forward, (baseEntity.transform.position - triggerNotify.transform.position).normalized);
if (InverseDotCheck() ? (num < 0f) : (num > 0f))
{
flag3 = false;
flag4 = false;
break;
}
}
if (flag3 == flag2)
if (flag4 == flag2 || flag4 == flag3)
{
return;
}
}
ReverseDoorAnimation(flag2, flag3);
SetOpen(!flag2, suppressBlockageChecks: true);
ReverseDoorAnimation(flag2);
StopCheckingForBlockages();
ClientRPC(RpcTarget.NetworkGroup("OnDoorInterrupted"), flag2 ? 1 : 0);
ClientRPC(RpcTarget.NetworkGroup("OnDoorInterrupted"), flag2, flag3);
}
public void OnEmpty()

View file

@ -7,7 +7,7 @@ using UnityEngine.Assertions;
public class DoorCloser : BaseEntity
{
[ItemSelector(ItemCategory.All)]
[ItemSelector]
public ItemDefinition itemType;
public float delay = 3f;

Some files were not shown because too many files have changed in this diff Show more