Merge branch 'heads/upstream' into OBT/1.2.0(SpringUpdate)
This commit is contained in:
@@ -0,0 +1,15 @@
|
||||
<?xml version="1.0" encoding="utf-8"?>
|
||||
<Configuration>
|
||||
<Settings>
|
||||
<Setting Name="HideUserNamesInLogs" Type="bool" Value="true"/>
|
||||
<Setting Name="CsRunPolicy" Type="listString" Value="Prompt" AllowChangesWhileExecuting="false">
|
||||
<Values>
|
||||
<Value Value="Disabled"/>
|
||||
<Value Value="Prompt"/>
|
||||
<Value Value="Enabled"/>
|
||||
</Values>
|
||||
</Setting>
|
||||
<Setting Name="UseCaching" Type="bool" Value="true" AllowChangesWhileExecuting="false"/>
|
||||
<Setting Name="IsCsEnabledForSession" Type="bool" AllowChangesWhileExecuting="false" ShowInMenus="false" Value="false"/>
|
||||
</Settings>
|
||||
</Configuration>
|
||||
+3
-19
@@ -2,11 +2,11 @@
|
||||
|
||||
local compatibilityLib = {}
|
||||
|
||||
local networking = LuaUserData.RegisterType("Barotrauma.LuaCsNetworking")
|
||||
-- local networking = LuaUserData.RegisterType("Barotrauma.LuaCsNetworking")
|
||||
|
||||
LuaUserData.AddMethod(networking, "RequestGetHTTP", Networking.HttpGet)
|
||||
-- LuaUserData.AddMethod(networking, "RequestGetHTTP", Networking.HttpGet)
|
||||
|
||||
LuaUserData.AddMethod(networking, "RequestPostHTTP", Networking.HttpPost)
|
||||
-- LuaUserData.AddMethod(networking, "RequestPostHTTP", Networking.HttpPost)
|
||||
|
||||
compatibilityLib.CreateVector2 = Vector2.__new
|
||||
compatibilityLib.CreateVector3 = Vector3.__new
|
||||
@@ -78,20 +78,4 @@ end
|
||||
|
||||
compatibilityLib["Player"] = luaPlayer
|
||||
|
||||
Hook.Add("character.created", "compatibility.character.created", function (character)
|
||||
Hook.Call("characterCreated", character)
|
||||
end)
|
||||
|
||||
Hook.Add("character.death", "compatibility.character.death", function (character, causeOfDeathAffliction)
|
||||
Hook.Call("characterDeath", character, causeOfDeathAffliction)
|
||||
end)
|
||||
|
||||
Hook.Add("client.connected", "compatibility.client.connected", function (client)
|
||||
Hook.Call("clientConnected", client)
|
||||
end)
|
||||
|
||||
Hook.Add("client.disconnected", "compatibility.client.disconnected", function (client)
|
||||
Hook.Call("clientDisconnected", client)
|
||||
end)
|
||||
|
||||
return compatibilityLib
|
||||
+7
-8
@@ -1,8 +1,8 @@
|
||||
local defaultLib = {}
|
||||
|
||||
local CreateStatic = LuaSetup.LuaUserData.CreateStatic
|
||||
local CreateEnum = LuaSetup.LuaUserData.CreateEnumTable
|
||||
local AddCallMetaTable = LuaSetup.LuaUserData.AddCallMetaTable
|
||||
local CreateStatic = LuaUserData.CreateStatic
|
||||
local CreateEnum = LuaUserData.CreateEnumTable
|
||||
local AddCallMetaTable = LuaUserData.AddCallMetaTable
|
||||
|
||||
local localizedStrings = {
|
||||
"LocalizedString", "LimitLString", "WrappedLString", "AddedPunctuationLString", "CapitalizeLString", "ConcatLString", "FallbackLString", "FormattedLString", "InputTypeLString", "JoinLString", "LowerLString", "RawLString", "ReplaceLString", "ServerMsgLString", "SplitLString", "TagLString", "TrimLString", "UpperLString", "StripRichTagsLString",
|
||||
@@ -79,13 +79,12 @@ defaultLib["GUI"] = {
|
||||
GUIStyle = CreateStatic("Barotrauma.GUIStyle", true),
|
||||
}
|
||||
|
||||
local guiFallback = defaultLib["GUI"].GUI
|
||||
|
||||
setmetatable(defaultLib["GUI"], {
|
||||
__index = function (table, key)
|
||||
return defaultLib["GUI"].GUI[key]
|
||||
__index = function(_, key)
|
||||
return guiFallback[key]
|
||||
end
|
||||
})
|
||||
|
||||
AddCallMetaTable(defaultLib["GUI"].VideoPlayer.VideoSettings)
|
||||
AddCallMetaTable(defaultLib["GUI"].VideoPlayer.TextSettings)
|
||||
|
||||
return defaultLib
|
||||
+2
-2
@@ -1,7 +1,7 @@
|
||||
local defaultLib = {}
|
||||
|
||||
local CreateStatic = LuaSetup.LuaUserData.CreateStatic
|
||||
local CreateEnum = LuaSetup.LuaUserData.CreateEnumTable
|
||||
local CreateStatic = LuaUserData.CreateStatic
|
||||
local CreateEnum = LuaUserData.CreateEnumTable
|
||||
|
||||
local localizedStrings = {
|
||||
"LocalizedString", "AddedPunctuationLString", "CapitalizeLString", "ConcatLString", "FallbackLString", "FormattedLString", "InputTypeLString", "JoinLString", "LowerLString", "RawLString", "ReplaceLString", "ServerMsgLString", "SplitLString", "TagLString", "TrimLString", "UpperLString", "StripRichTagsLString",
|
||||
+3
-3
@@ -1,8 +1,8 @@
|
||||
local defaultLib = {}
|
||||
|
||||
local AddCallMetaTable = LuaSetup.LuaUserData.AddCallMetaTable
|
||||
local CreateStatic = LuaSetup.LuaUserData.CreateStatic
|
||||
local CreateEnum = LuaSetup.LuaUserData.CreateEnumTable
|
||||
local AddCallMetaTable = LuaUserData.AddCallMetaTable
|
||||
local CreateStatic = LuaUserData.CreateStatic
|
||||
local CreateEnum = LuaUserData.CreateEnumTable
|
||||
|
||||
defaultLib["SByte"] = CreateStatic("Barotrauma.LuaSByte", true)
|
||||
defaultLib["Byte"] = CreateStatic("Barotrauma.LuaByte", true)
|
||||
+2
@@ -1,3 +1,5 @@
|
||||
if true then return end
|
||||
|
||||
local descriptor = LuaUserData.RegisterType("Barotrauma.LuaCsSteam")
|
||||
|
||||
LuaUserData.AddMethod(descriptor, "GetWorkshopCollection", function (id, callback)
|
||||
@@ -0,0 +1,38 @@
|
||||
LuaSetup = {}
|
||||
|
||||
local path = ...
|
||||
|
||||
local function AddTableToGlobal(tbl)
|
||||
for k, v in pairs(tbl) do
|
||||
_G[k] = v
|
||||
end
|
||||
end
|
||||
|
||||
if SERVER then
|
||||
AddTableToGlobal(dofile(path .. "/Lua/DefaultLib/LibServer.lua"))
|
||||
else
|
||||
AddTableToGlobal(dofile(path .. "/Lua/DefaultLib/LibClient.lua"))
|
||||
end
|
||||
|
||||
AddTableToGlobal(dofile(path .. "/Lua/DefaultLib/LibShared.lua"))
|
||||
|
||||
AddTableToGlobal(dofile(path .. "/Lua/CompatibilityLib.lua"))
|
||||
|
||||
dofile(path .. "/Lua/DefaultHook.lua")
|
||||
|
||||
Descriptors = LuaUserData
|
||||
|
||||
dofile(path .. "/Lua/DefaultLib/Utils/Math.lua")
|
||||
dofile(path .. "/Lua/DefaultLib/Utils/String.lua")
|
||||
dofile(path .. "/Lua/DefaultLib/Utils/Util.lua")
|
||||
dofile(path .. "/Lua/DefaultLib/Utils/SteamApi.lua")
|
||||
|
||||
if not CSActive then
|
||||
for k, v in pairs(debug) do
|
||||
if k ~= "getmetatable" and k ~= "setmetatable" and k ~= "traceback" then
|
||||
debug[k] = nil
|
||||
end
|
||||
end
|
||||
end
|
||||
|
||||
LuaSetup = nil
|
||||
Binary file not shown.
|
After Width: | Height: | Size: 6.2 KiB |
@@ -0,0 +1,8 @@
|
||||
<?xml version="1.0" encoding="utf-8"?>
|
||||
<ModConfig>
|
||||
<Lua File="%ModDir%/Lua/LuaSetup.lua" IsAutorun="true" />
|
||||
<Config File="%ModDir%/Config/SettingsShared.xml"/>
|
||||
<Assembly File="%ModDir%/Publicized/BarotraumaCore.dll" IsReferenceModeOnly="true"/>
|
||||
<Assembly File="%ModDir%/Publicized/Barotrauma.dll" Target="Client" IsReferenceModeOnly="true" IsFileRequired="false"/>
|
||||
<Assembly File="%ModDir%/Publicized/DedicatedServer.dll" Target="Server" IsReferenceModeOnly="true"/>
|
||||
</ModConfig>
|
||||
@@ -0,0 +1,6 @@
|
||||
<?xml version="1.0" encoding="utf-8"?>
|
||||
<style>
|
||||
<SettingsMenuTab.LuaCsSettings color="169,212,187,255" hovercolor="220,220,220,255" selectedcolor="255,255,255,255" pressedcolor="100,100,100,255" disabledcolor="125,125,125,125">
|
||||
<Sprite name="LuaCsSettings" texture="%ModDir%/LuaCsSettingsIcon.png" sourcerect="0,0,64,64" tile="false" maintainaspectratio="true" origin="0.5,0.5"/>
|
||||
</SettingsMenuTab.LuaCsSettings>
|
||||
</style>
|
||||
@@ -0,0 +1,23 @@
|
||||
<?xml version="1.0" encoding="utf-8"?>
|
||||
<infotexts language="English" nowhitespace="false" translatedname="English">
|
||||
<LuaCsForBarotrauma.SettingsMenu.ModControlsButton>Mod Controls Settings</LuaCsForBarotrauma.SettingsMenu.ModControlsButton>
|
||||
<LuaCsForBarotrauma.SettingsMenu.ModGameplayButton>Mod Gameplay Settings</LuaCsForBarotrauma.SettingsMenu.ModGameplayButton>
|
||||
<LuaCsForBarotrauma.SettingsMenu.ResetVisibleSettings>Reset Displayed Settings</LuaCsForBarotrauma.SettingsMenu.ResetVisibleSettings>
|
||||
<LuaCsForBarotrauma.SettingsMenu.ResetPrompt.Title>Reset Visible Settings</LuaCsForBarotrauma.SettingsMenu.ResetPrompt.Title>
|
||||
<LuaCsForBarotrauma.SettingsMenu.ResetPrompt.Message>Are you sure you want to reset the values for currently displayed settings?</LuaCsForBarotrauma.SettingsMenu.ResetPrompt.Message>
|
||||
<LuaCsForBarotrauma.SettingsMenu.ResetPrompt.Yes>Yes</LuaCsForBarotrauma.SettingsMenu.ResetPrompt.Yes>
|
||||
<LuaCsForBarotrauma.SettingsMenu.ResetPrompt.No>No</LuaCsForBarotrauma.SettingsMenu.ResetPrompt.No>
|
||||
<!-- Settings -->
|
||||
<!-- Is Cs Enabled-->
|
||||
<LuaCsForBarotrauma.CsRunPolicy.DisplayName>Are C# Mods Allowed</LuaCsForBarotrauma.CsRunPolicy.DisplayName>
|
||||
<LuaCsForBarotrauma.CsRunPolicy.Tooltip>Should unsandboxed scripts and dlls be allowed to run.</LuaCsForBarotrauma.CsRunPolicy.Tooltip>
|
||||
<LuaCsForBarotrauma.CsRunPolicy.DisplayCategory>General</LuaCsForBarotrauma.CsRunPolicy.DisplayCategory>
|
||||
<!-- Use Caching -->
|
||||
<LuaCsForBarotrauma.UseCaching.DisplayName>Use Pre-Caching</LuaCsForBarotrauma.UseCaching.DisplayName>
|
||||
<LuaCsForBarotrauma.UseCaching.Tooltip>Should mod files be preloaded to speed up loading. Should only be turned off if you have mods that have issues with this.</LuaCsForBarotrauma.UseCaching.Tooltip>
|
||||
<LuaCsForBarotrauma.UseCaching.DisplayCategory>General</LuaCsForBarotrauma.UseCaching.DisplayCategory>
|
||||
<!-- Hide Usernames In Logs-->
|
||||
<LuaCsForBarotrauma.HideUserNamesInLogs.DisplayName>Hide Local OS Account Name In Logs</LuaCsForBarotrauma.HideUserNamesInLogs.DisplayName>
|
||||
<LuaCsForBarotrauma.HideUserNamesInLogs.Tooltip>If true, will replace your OS account name with 'USERNAME' in log files' paths.</LuaCsForBarotrauma.HideUserNamesInLogs.Tooltip>
|
||||
<LuaCsForBarotrauma.HideUserNamesInLogs.DisplayCategory>General</LuaCsForBarotrauma.HideUserNamesInLogs.DisplayCategory>
|
||||
</infotexts>
|
||||
@@ -0,0 +1,3 @@
|
||||
<?xml version="1.0" encoding="utf-8"?>
|
||||
<infotexts language="Portuguese" nowhitespace="false" translatedname="Portuguese">
|
||||
</infotexts>
|
||||
@@ -0,0 +1,6 @@
|
||||
<?xml version="1.0" encoding="utf-8"?>
|
||||
<contentpackage name="LuaCsForBarotrauma">
|
||||
<Text file="%ModDir%/Texts/English.xml"/>
|
||||
<UIStyle file="%ModDir%/Style.xml" />
|
||||
<!--<Text file="%ModDir%/Texts/Portuguese.xml"/>-->
|
||||
</contentpackage>
|
||||
+5
@@ -45,6 +45,11 @@
|
||||
<Inventory slots="Any, Any, Any, Any" accessiblewhenalive="False" commonness="50">
|
||||
<Item identifier="alienblood" />
|
||||
</Inventory>
|
||||
|
||||
<StatusEffect type="OnDeconstructed" target="Character">
|
||||
<SpawnItem identifiers="alienblood" spawnposition="ThisInventory" count="3" />
|
||||
</StatusEffect>
|
||||
|
||||
<ai CombatStrength="100" Sight="1" Hearing="1" AggressionHurt="200" AggressionGreed="10" FleeHealthThreshold="10" AttackWhenProvoked="False" AvoidGunfire="True" DamageThreshold="0" AvoidTime="3" MinFleeTime="20" AggressiveBoarding="True" EnforceAggressiveBehaviorForMissions="True" TargetOuterWalls="True" RandomAttack="False" CanOpenDoors="False" KeepDoorsClosed="False" AvoidAbyss="True" StayInAbyss="False" PatrolFlooded="False" PatrolDry="False" StartAggression="0" MaxAggression="100" AggressionCumulation="0" WallTargetingMethod="Target">
|
||||
<target Tag="decoy" State="Attack" Priority="500" ReactDistance="0" AttackDistance="0" Timer="0" IgnoreContained="False" IgnoreInside="False" IgnoreOutside="False" IgnoreIfNotInSameSub="True" IgnoreIncapacitated="False" Threshold="0" ThresholdMin="-1" ThresholdMax="-1" Offset="0,0" AttackPattern="Straight" PrioritizeSubCenter="False" SweepDistance="0" SweepStrength="10" SweepSpeed="1" CircleStartDistance="5000" CircleRotationSpeed="1" CircleStrikeDistanceMultiplier="5" CircleMaxRandomOffset="0" />
|
||||
<target Tag="stronger" State="Avoid" Priority="200" ReactDistance="2000" AttackDistance="0" Timer="0" IgnoreContained="False" IgnoreInside="False" IgnoreOutside="False" IgnoreIfNotInSameSub="False" IgnoreIncapacitated="False" Threshold="0" ThresholdMin="-1" ThresholdMax="-1" Offset="0,0" AttackPattern="Straight" PrioritizeSubCenter="False" SweepDistance="0" SweepStrength="10" SweepSpeed="1" CircleStartDistance="5000" CircleRotationSpeed="1" CircleStrikeDistanceMultiplier="5" CircleMaxRandomOffset="0" />
|
||||
|
||||
BIN
Binary file not shown.
+4
@@ -0,0 +1,4 @@
|
||||
<?xml version="1.0" encoding="utf-8"?>
|
||||
<contentpackage name="Lighting stress (10000 lights)" modversion="1.0.0" corepackage="False" gameversion="1.11.5.0">
|
||||
<Submarine file="%ModDir%/Lighting stress (10000 lights).sub" />
|
||||
</contentpackage>
|
||||
BIN
Binary file not shown.
|
After Width: | Height: | Size: 44 KiB |
+23
@@ -0,0 +1,23 @@
|
||||
<Items>
|
||||
<Item
|
||||
name="Oxygen Dispenser Test"
|
||||
identifier="oxygendispensertest"
|
||||
tags="oxygengenerator,refuelableitem,donttakeitemstorefill"
|
||||
category="Machine"
|
||||
scale="0.5"
|
||||
isshootable="true" GrabWhenSelected="true">
|
||||
|
||||
<Sprite texture="%ModDir%/EthanolPowerGenerator.png" depth="0.55" sourcerect="0,336,112,128"/>
|
||||
|
||||
<Body width="112" height="128" density="25" />
|
||||
<Holdable selectkey="Select" pickkey="Use" slots="RightHand+LeftHand" msg="ItemMsgDetach" MsgWhenDropped="ItemMsgPickupSelect" PickingTime="5.0" holdpos="0,-80" handle1="-30,14" handle2="30,14" attachable="true" aimable="true" AttachesToFloor="true"
|
||||
AttachedByDefault="true" DisallowAttachingOverTags="container,planter,refuelableitem" DisallowAttachingOverSize="115,130">
|
||||
</Holdable>
|
||||
|
||||
<ItemContainer hideitems="false" drawinventory="true" ItemsUseInventoryPlacement="true" capacity="1" maxstacksize="1" canbeselected="true" itempos="32,-83" iteminterval="0,0" itemrotation="0" msg="ItemMsgOxygenRefill" containedspritedepth="0.1">
|
||||
<GuiFrame relativesize="0.2,0.25" anchor="Center" minsize="140,170" maxsize="280,280" style="ItemUI" />
|
||||
<SlotIcon slotindex="0" texture="Content/UI/StatusMonitorUI.png" sourcerect="64,448,64,64" origin="0.5,0.5" />
|
||||
<Containable items="oxygensource" />
|
||||
</ItemContainer>
|
||||
</Item>
|
||||
</Items>
|
||||
BIN
Binary file not shown.
+36
@@ -0,0 +1,36 @@
|
||||
<?xml version="1.0" encoding="utf-8"?>
|
||||
<Items>
|
||||
<Item name="fliptestholdable" identifier="fliptestholdable" Category="Misc" Tags="smallitem" health="35" maxstacksize="1" scale="0.5" isshootable="true" requireaimtouse="true">
|
||||
<sprite texture="Content/Map/Outposts/Art/FactionItems.png" sourcerect="263,193,38,39" depth="0.2" origin="0.5,0.5" />
|
||||
<Body radius="28" density="15" />
|
||||
<LightComponent LightColor="220,150,30,150" range="15" IsOn="true" castshadows="false" lightoffset="40,20" vulnerabletoemp="false" >
|
||||
<IsActiveConditional HasStatusTag="smoking" />
|
||||
<StatusEffect OffsetCopiesEntityTransform="true" offset="40,20" type="OnUse" target="This" statuseffecttags="smoking" duration="0.1" stackable="false">
|
||||
<ParticleEmitter particle="blooddrop" particlespersecond="10" scalemin="3" scalemax="3" velocitymin="0" velocitymax="0" colormultiplier="255,255,255,180" lifetimemultiplier="2"/>
|
||||
<ParticleEmitter particle="smoke" particlespersecond="3" scalemin="0.35" scalemax="0.5" velocitymin="0" velocitymax="10" colormultiplier="255,255,255,200" />
|
||||
</StatusEffect>
|
||||
</LightComponent>
|
||||
<Holdable slots="Any,RightHand,LeftHand" aimable="false" aimpos="32,21" handle1="0,-22" holdangle="0" aimangle="-25" swingamount="0,0" swingspeed="0.5" swingwhenusing="true" msg="ItemMsgPickUpSelect">
|
||||
<StatusEffect type="OnUse" target="This" Condition="-4.0" />
|
||||
<StatusEffect type="OnUse" target="This">
|
||||
<Conditional InWater="false" />
|
||||
<Sound file="Content/Items/Medical/ITEM_cigarette.ogg" range="250" loop="true" selectionmode="Random" />
|
||||
</StatusEffect>
|
||||
<StatusEffect type="OnBroken" target="This">
|
||||
<SpawnItem identifier="bananapeel" spawnposition="SameInventory"/>
|
||||
<Remove />
|
||||
</StatusEffect>
|
||||
</Holdable>
|
||||
</Item>
|
||||
|
||||
<Item name="fliptestlight" identifier="fliptestlighttower" width="176" height="352" texturescale="1.0,1.0" scale="0.5" category="Decorative" subcategory="mining" noninteractable="true">
|
||||
<sprite texture="Content/Map/Outposts/Art/TunnelWalls.png" sourcerect="849,1697,176,352" depth="0.97" premultiplyalpha="false" origin="0.5,0.5" />
|
||||
<LightComponent range="160.0" lightcolor="255,234,181,200" IsOn="true" castshadows="false" LightOffset="200,147" allowingameediting="false">
|
||||
<sprite texture="Content/Map/Outposts/Art/TunnelWalls.png" sourcerect="671,1697,176,62" depth="0.1" origin="0.5,0.5" alpha="1.0" />
|
||||
<StatusEffect OffsetCopiesEntityTransform="true" offset="200,147" type="OnActive" target="This" duration="0.1" stackable="false">
|
||||
<ParticleEmitter particle="blooddrop" particlespersecond="10" scalemin="3" scalemax="3" velocitymin="0" velocitymax="0" colormultiplier="255,255,255,180" lifetimemultiplier="2"/>
|
||||
<ParticleEmitter particle="smoke" particlespersecond="3" scalemin="0.35" scalemax="0.5" velocitymin="0" velocitymax="10" colormultiplier="255,255,255,200" />
|
||||
</StatusEffect>
|
||||
</LightComponent>
|
||||
</Item>
|
||||
</Items>
|
||||
+3
-1
@@ -1,4 +1,6 @@
|
||||
<?xml version="1.0" encoding="utf-8"?>
|
||||
<contentpackage name="[DebugOnlyTest]RotationAndFlippingTests" modversion="1.0.2" corepackage="False" gameversion="1.7.6.0">
|
||||
<contentpackage name="[DebugOnlyTest]RotationAndFlippingTests" modversion="1.0.3" corepackage="False" gameversion="1.11.5.0">
|
||||
<Item file="%ModDir%/OxygenDispenserTest.xml" />
|
||||
<Item file="%ModDir%/StatusEffectAndLightTest.xml" />
|
||||
<Submarine file="%ModDir%/RotationAndFlippingTests.sub" />
|
||||
</contentpackage>
|
||||
@@ -0,0 +1,75 @@
|
||||
print("Hello!")
|
||||
|
||||
Hook.Add("character.created", "test", function(character)
|
||||
print("character.created: ", character)
|
||||
end)
|
||||
|
||||
Hook.Add("character.death", "test", function(character)
|
||||
print("character.death: ", character)
|
||||
end)
|
||||
|
||||
Hook.Add("character.giveJobItems", "test", function(character)
|
||||
print("character.giveJobItems: ", character)
|
||||
end)
|
||||
|
||||
Hook.Add("roundStart", "test", function()
|
||||
print("roundStart")
|
||||
end)
|
||||
|
||||
Hook.Add("roundEnd", "test", function()
|
||||
print("roundEnd")
|
||||
end)
|
||||
|
||||
Hook.Add("missionsEnded", "test", function()
|
||||
print("missionsEnded")
|
||||
end)
|
||||
|
||||
-- cfg tests
|
||||
local str = "CLIENT: "
|
||||
|
||||
if SERVER then
|
||||
str = "SERVER: "
|
||||
end
|
||||
|
||||
function OnChanged(cfg)
|
||||
print(str, "cfg value for ", cfg.InternalName, " changed to ", cfg.Value)
|
||||
end
|
||||
|
||||
local failed, package = trygetpackage("[DebugOnlyTest]TestLuaMod")
|
||||
|
||||
print("packageFailed=", failed)
|
||||
print("package", package.Name)
|
||||
|
||||
local success, config = ConfigService.TryGetConfig(SettingBase.Int32, package, "TestSynchroServer")
|
||||
local success2, config2 = ConfigService.TryGetConfig(SettingBase.Int32, package, "TestSynchroClient")
|
||||
|
||||
if not success or not success2 then
|
||||
print("Failed to get configs.")
|
||||
return
|
||||
end
|
||||
|
||||
config.OnValueChanged.add(OnChanged)
|
||||
config2.OnValueChanged.add(OnChanged)
|
||||
|
||||
print(str, " testsynchroclient=", config2.Value)
|
||||
print(str, " testsynchroserver=", config.Value)
|
||||
|
||||
-- The server should keep updating the value and it should show up on the client.
|
||||
-- The client should try updating and it should fail.
|
||||
|
||||
local lastTime = Timer.Time + 30 -- give time to join
|
||||
|
||||
Hook.Add("think", "printconfig", function()
|
||||
if lastTime > Timer.Time then return end
|
||||
lastTime = Timer.Time + 10
|
||||
|
||||
if SERVER then
|
||||
local succ = config.TrySetValue(config.Value + 1)
|
||||
print("Success of setting value on server for '", config.InternalName,"': ", succ)
|
||||
end
|
||||
if CLIENT then
|
||||
local succ = config.TrySetValue(config.Value + 1)
|
||||
print("Success of setting value on client for '", config.InternalName,"': ", succ, " | This should fail if permissions are not set for client.")
|
||||
end
|
||||
|
||||
end)
|
||||
@@ -0,0 +1,7 @@
|
||||
<?xml version="1.0" encoding="utf-8"?>
|
||||
<ModConfig>
|
||||
<Lua File="%ModDir%/Lua/init.lua" IsAutorun="true" />
|
||||
<Config File="%ModDir%/Settings.xml"/>
|
||||
<Config File="%ModDir%/SettingsClient.xml" Target="Client"/>
|
||||
<Config File="%ModDir%/SettingsServer.xml" Target="Server"/>
|
||||
</ModConfig>
|
||||
@@ -0,0 +1,40 @@
|
||||
<?xml version="1.0" encoding="utf-8"?>
|
||||
<Configuration>
|
||||
<Settings>
|
||||
<Setting Name="TestTickbox" Type="bool" Value="true"/>
|
||||
<Setting Name="TestSynchroClient" Type="int" NetSync="TwoWay" Value="40"/>
|
||||
<Setting Name="TestSynchroServer" Type="int" NetSync="ServerAuthority" Value="25"/>
|
||||
<Setting Name="TestFloat" Type="float" Value="3498"/>
|
||||
<Setting Name="TestHidden" Type="bool" ShowInMenus="false" Value="false"/>
|
||||
<Setting Name="TestRangeFloat" Type="rangeFloat" Min="0" Max="25" Steps="11" Value="4.5"/>
|
||||
<Setting Name="TestRangeInt" Type="rangeInt" Min="0" Max="10" Steps="11" Value="4"/>
|
||||
<Setting Name="TestString" Type="string" Value="ok"/>
|
||||
<Setting Name="TestControl" Type="control" Value="A"/>
|
||||
<Setting Name="TestDropdownList" Type="listString" Value="Hi">
|
||||
<Values>
|
||||
<Value Value="Entry A"/>
|
||||
<Value Value="Entry B"/>
|
||||
<Value Value="Hi"/>
|
||||
<Value Value="YourMom"/>
|
||||
</Values>
|
||||
</Setting>
|
||||
</Settings>
|
||||
<Profiles>
|
||||
<Profile Name="default">
|
||||
<SettingValue Name="TestTickbox" Value="true"/>
|
||||
<SettingValue Name="TestFloat" Value="5"/>
|
||||
<SettingValue Name="TestHidden" Value="true"/>
|
||||
<SettingValue Name="TestRangeFloat" Value="15"/>
|
||||
<SettingValue Name="TestRangeInt" Value="7"/>
|
||||
<SettingValue Name="TestString" Value="Hello!"/>
|
||||
</Profile>
|
||||
<Profile Name="other">
|
||||
<SettingValue Name="TestTickbox" Value="false"/>
|
||||
<SettingValue Name="TestFloat" Value="9"/>
|
||||
<SettingValue Name="TestHidden" Value="false"/>
|
||||
<SettingValue Name="TestRangeFloat" Value="4"/>
|
||||
<SettingValue Name="TestRangeInt" Value="4"/>
|
||||
<SettingValue Name="TestString" Value="Other loaded!"/>
|
||||
</Profile>
|
||||
</Profiles>
|
||||
</Configuration>
|
||||
@@ -0,0 +1,8 @@
|
||||
<?xml version="1.0" encoding="utf-8"?>
|
||||
<Configuration>
|
||||
<!-- Should match 'SettingsServer'. We define these on the client and server separately to give different values. -->
|
||||
<Settings>
|
||||
<Setting Name="TestSynchroClient" Type="int" NetSync="TwoWay" Value="3545" ShowInMenus="false"/>
|
||||
<Setting Name="TestSynchroServer" Type="int" NetSync="ServerAuthority" Value="577" ShowInMenus="false"/>
|
||||
</Settings>
|
||||
</Configuration>
|
||||
@@ -0,0 +1,8 @@
|
||||
<?xml version="1.0" encoding="utf-8"?>
|
||||
<Configuration>
|
||||
<!-- Should match 'SettingsClient'. We define these on the client and server separately to give different values. -->
|
||||
<Settings>
|
||||
<Setting Name="TestSynchroClient" Type="int" NetSync="TwoWay" Value="40" ShowInMenus="false"/>
|
||||
<Setting Name="TestSynchroServer" Type="int" NetSync="ServerAuthority" Value="25" ShowInMenus="false"/>
|
||||
</Settings>
|
||||
</Configuration>
|
||||
@@ -0,0 +1,13 @@
|
||||
<?xml version="1.0" encoding="utf-8"?>
|
||||
<infotexts language="English" nowhitespace="false" translatedname="English">
|
||||
<_x005B_DebugOnlyTest_x005D_TestLuaMod.TestTickbox.DisplayName>Test TickBox</_x005B_DebugOnlyTest_x005D_TestLuaMod.TestTickbox.DisplayName>
|
||||
<_x005B_DebugOnlyTest_x005D_TestLuaMod.TestTickbox.DisplayCategory>Tests</_x005B_DebugOnlyTest_x005D_TestLuaMod.TestTickbox.DisplayCategory>
|
||||
<_x005B_DebugOnlyTest_x005D_TestLuaMod.TestFloat.DisplayName>Test Float</_x005B_DebugOnlyTest_x005D_TestLuaMod.TestFloat.DisplayName>
|
||||
<_x005B_DebugOnlyTest_x005D_TestLuaMod.TestFloat.DisplayCategory>Tests</_x005B_DebugOnlyTest_x005D_TestLuaMod.TestFloat.DisplayCategory>
|
||||
<_x005B_DebugOnlyTest_x005D_TestLuaMod.TestRangeFloat.DisplayName>Test Range Float</_x005B_DebugOnlyTest_x005D_TestLuaMod.TestRangeFloat.DisplayName>
|
||||
<_x005B_DebugOnlyTest_x005D_TestLuaMod.TestRangeFloat.DisplayCategory>Tests</_x005B_DebugOnlyTest_x005D_TestLuaMod.TestRangeFloat.DisplayCategory>
|
||||
<_x005B_DebugOnlyTest_x005D_TestLuaMod.TestRangeInt.DisplayName>Test Range Int</_x005B_DebugOnlyTest_x005D_TestLuaMod.TestRangeInt.DisplayName>
|
||||
<_x005B_DebugOnlyTest_x005D_TestLuaMod.TestRangeInt.DisplayCategory>Tests</_x005B_DebugOnlyTest_x005D_TestLuaMod.TestRangeInt.DisplayCategory>
|
||||
<_x005B_DebugOnlyTest_x005D_TestLuaMod.TestString.DisplayName>Test String</_x005B_DebugOnlyTest_x005D_TestLuaMod.TestString.DisplayName>
|
||||
<_x005B_DebugOnlyTest_x005D_TestLuaMod.TestString.DisplayCategory>Tests</_x005B_DebugOnlyTest_x005D_TestLuaMod.TestString.DisplayCategory>
|
||||
</infotexts>
|
||||
@@ -0,0 +1,4 @@
|
||||
<?xml version="1.0" encoding="utf-8"?>
|
||||
<Items>
|
||||
|
||||
</Items>
|
||||
@@ -0,0 +1,5 @@
|
||||
<?xml version="1.0" encoding="utf-8"?>
|
||||
<contentpackage name="[DebugOnlyTest]TestLuaMod" >
|
||||
<Text file="%ModDir%/Texts/English.xml"/>
|
||||
<Item file="%ModDir%/dummy.xml" />
|
||||
</contentpackage>
|
||||
@@ -0,0 +1,159 @@
|
||||
<?xml version="1.0" encoding="utf-8"?>
|
||||
<RandomEvents>
|
||||
<EventPrefabs>
|
||||
|
||||
<ScriptedEvent identifier="testpathfinding1" tags="testpathfinding_colony">
|
||||
|
||||
<SpawnAction NPCSetIdentifier="customnpcs1" NPCIdentifier="artiedolittle" TargetTag="npc1" SpawnPointTag="spawnpoint1" />
|
||||
<SpawnAction NPCSetIdentifier="customnpcs1" NPCIdentifier="clownmessenger" TargetTag="npc2" SpawnPointTag="spawnpoint2" />
|
||||
<SpawnAction NPCSetIdentifier="customnpcs1" NPCIdentifier="jacovsubra" TargetTag="npc3" SpawnPointTag="spawnpoint3" />
|
||||
<SpawnAction NPCSetIdentifier="customnpcs1" NPCIdentifier="coalitionspy" TargetTag="npc4" SpawnPointTag="spawnpoint4" />
|
||||
<SpawnAction NPCSetIdentifier="customnpcs1" NPCIdentifier="raptorowner" TargetTag="npc5" SpawnPointTag="spawnpoint5" />
|
||||
<SpawnAction NPCSetIdentifier="customnpcs1" NPCIdentifier="hognose" TargetTag="npc6" SpawnPointTag="spawnpoint6" />
|
||||
<SpawnAction NPCSetIdentifier="customnpcs1" NPCIdentifier="drugdealer" TargetTag="npc7" SpawnPointTag="spawnpoint7" />
|
||||
|
||||
<TagAction criteria="hullname:goalroom" tag="goal" />
|
||||
|
||||
<NPCFollowAction NPCTag="npc1" TargetTag="goal" />
|
||||
<NPCFollowAction NPCTag="npc2" TargetTag="goal" />
|
||||
<NPCFollowAction NPCTag="npc3" TargetTag="goal" />
|
||||
<NPCFollowAction NPCTag="npc4" TargetTag="goal" />
|
||||
<NPCFollowAction NPCTag="npc5" TargetTag="goal" forcewalk="true" />
|
||||
<NPCFollowAction NPCTag="npc6" TargetTag="goal" forcewalk="true" />
|
||||
<NPCFollowAction NPCTag="npc7" TargetTag="goal" forcewalk="true" />
|
||||
|
||||
<ConversationAction Text="Spawned 7 test NPCs. They should now navigate to the furthest module at the right side of the outpost. You may fast-forward by 60 seconds to skip to the end of the test." />
|
||||
|
||||
<WaitAction time="60" />
|
||||
|
||||
<CheckVisibilityAction EntityTag="npc1" TargetTag="goal" MaxDistance="500">
|
||||
<Failure>
|
||||
<ConversationAction Text="Test failed. NPC 1 (Artie Dolittle) did not make it to the target module in time." />
|
||||
</Failure>
|
||||
<Success>
|
||||
<CheckVisibilityAction EntityTag="npc2" TargetTag="goal" MaxDistance="500">
|
||||
<Failure>
|
||||
<ConversationAction Text="Test failed. NPC 2 (Clown Messenger) did not make it to the target module in time." />
|
||||
</Failure>
|
||||
<Success>
|
||||
<CheckVisibilityAction EntityTag="npc3" TargetTag="goal" MaxDistance="500">
|
||||
<Failure>
|
||||
<ConversationAction Text="Test failed. NPC 3 (Jacov Subra) did not make it to the target module in time." />
|
||||
</Failure>
|
||||
<Success>
|
||||
<CheckVisibilityAction EntityTag="npc4" TargetTag="goal" MaxDistance="500">
|
||||
<Failure>
|
||||
<ConversationAction Text="Test failed. NPC 4 (Coalition Operative) did not make it to the target module in time." />
|
||||
</Failure>
|
||||
<Success>
|
||||
<CheckVisibilityAction EntityTag="npc5" TargetTag="goal" MaxDistance="500">
|
||||
<Failure>
|
||||
<ConversationAction Text="Test failed. NPC 5 (Severo Ruiz) did not make it to the target module in time." />
|
||||
</Failure>
|
||||
<Success>
|
||||
<CheckVisibilityAction EntityTag="npc6" TargetTag="goal" MaxDistance="500">
|
||||
<Failure>
|
||||
<ConversationAction Text="Test failed. NPC 6 (Captain Hognose) did not make it to the target module in time." />
|
||||
</Failure>
|
||||
<Success>
|
||||
<CheckVisibilityAction EntityTag="npc7" TargetTag="goal" MaxDistance="500">
|
||||
<Failure>
|
||||
<ConversationAction Text="Test failed. NPC 7 (Drug Dealer) did not make it to the target module in time." />
|
||||
</Failure>
|
||||
<Success>
|
||||
<!-- ALL SUCCEEDED ******************************* -->
|
||||
<ConversationAction Text="NPC test successful! All NPCs made it to the target module in time." />
|
||||
</Success>
|
||||
</CheckVisibilityAction>
|
||||
</Success>
|
||||
</CheckVisibilityAction>
|
||||
</Success>
|
||||
</CheckVisibilityAction>
|
||||
</Success>
|
||||
</CheckVisibilityAction>
|
||||
</Success>
|
||||
</CheckVisibilityAction>
|
||||
</Success>
|
||||
</CheckVisibilityAction>
|
||||
</Success>
|
||||
</CheckVisibilityAction>
|
||||
|
||||
<ConversationAction Text="Starting second test: making the NPCs navigate back to the left side of the outpost." />
|
||||
|
||||
<TagAction criteria="hullname:goalroom2" tag="goal2" />
|
||||
|
||||
<NPCFollowAction NPCTag="npc1" TargetTag="goal2" forcewalk="true" />
|
||||
<WaitAction time="2" />
|
||||
|
||||
<NPCFollowAction NPCTag="npc2" TargetTag="goal2" forcewalk="true" />
|
||||
<WaitAction time="2" />
|
||||
<!-- follow another NPC instead of going directly for the goal! -->
|
||||
<NPCFollowAction NPCTag="npc3" TargetTag="npc2" forcewalk="true" />
|
||||
<WaitAction time="2" />
|
||||
<NPCFollowAction NPCTag="npc4" TargetTag="goal2" />
|
||||
<WaitAction time="2" />
|
||||
<NPCFollowAction NPCTag="npc5" TargetTag="goal2" />
|
||||
<WaitAction time="2" />
|
||||
<NPCFollowAction NPCTag="npc6" TargetTag="goal2" />
|
||||
<WaitAction time="2" />
|
||||
<!-- follow another NPC instead of going directly for the goal! -->
|
||||
<NPCFollowAction NPCTag="npc7" TargetTag="npc4" />
|
||||
|
||||
<WaitAction time="100" />
|
||||
|
||||
<CheckVisibilityAction EntityTag="npc1" TargetTag="goal2" MaxDistance="500">
|
||||
<Failure>
|
||||
<ConversationAction Text="Test failed. NPC 1 (Artie Dolittle) did not make it to the target module in time." />
|
||||
</Failure>
|
||||
<Success>
|
||||
<CheckVisibilityAction EntityTag="npc2" TargetTag="goal2" MaxDistance="500">
|
||||
<Failure>
|
||||
<ConversationAction Text="Test failed. NPC 2 (Clown Messenger) did not make it to the target module in time." />
|
||||
</Failure>
|
||||
<Success>
|
||||
<CheckVisibilityAction EntityTag="npc3" TargetTag="goal2" MaxDistance="500">
|
||||
<Failure>
|
||||
<ConversationAction Text="Test failed. NPC 3 (Jacov Subra) did not make it to the target module in time." />
|
||||
</Failure>
|
||||
<Success>
|
||||
<CheckVisibilityAction EntityTag="npc4" TargetTag="goal2" MaxDistance="500">
|
||||
<Failure>
|
||||
<ConversationAction Text="Test failed. NPC 4 (Coalition Operative) did not make it to the target module in time." />
|
||||
</Failure>
|
||||
<Success>
|
||||
<CheckVisibilityAction EntityTag="npc5" TargetTag="goal2" MaxDistance="500">
|
||||
<Failure>
|
||||
<ConversationAction Text="Test failed. NPC 5 (Severo Ruiz) did not make it to the target module in time." />
|
||||
</Failure>
|
||||
<Success>
|
||||
<CheckVisibilityAction EntityTag="npc6" TargetTag="goal2" MaxDistance="500">
|
||||
<Failure>
|
||||
<ConversationAction Text="Test failed. NPC 6 (Captain Hognose) did not make it to the target module in time." />
|
||||
</Failure>
|
||||
<Success>
|
||||
<CheckVisibilityAction EntityTag="npc7" TargetTag="goal2" MaxDistance="500">
|
||||
<Failure>
|
||||
<ConversationAction Text="Test failed. NPC 7 (Drug Dealer) did not make it to the target module in time." />
|
||||
</Failure>
|
||||
<Success>
|
||||
<!-- ALL SUCCEEDED ******************************* -->
|
||||
<ConversationAction Text="NPC test successful! All NPCs made it to the target module in time." />
|
||||
</Success>
|
||||
</CheckVisibilityAction>
|
||||
</Success>
|
||||
</CheckVisibilityAction>
|
||||
</Success>
|
||||
</CheckVisibilityAction>
|
||||
</Success>
|
||||
</CheckVisibilityAction>
|
||||
</Success>
|
||||
</CheckVisibilityAction>
|
||||
</Success>
|
||||
</CheckVisibilityAction>
|
||||
</Success>
|
||||
</CheckVisibilityAction>
|
||||
|
||||
</ScriptedEvent>
|
||||
</EventPrefabs>
|
||||
|
||||
</RandomEvents>
|
||||
BIN
Binary file not shown.
@@ -0,0 +1,8 @@
|
||||
<?xml version="1.0" encoding="utf-8"?>
|
||||
<contentpackage name="[DebugOnlyTest]TestPathFinding" modversion="1.0.0" corepackage="False" gameversion="1.12.4.0">
|
||||
<Outpost file="%ModDir%/[DebugOnlyTest]TestPathFinding.sub" />
|
||||
|
||||
<RandomEvents file="%ModDir%/Events.xml" />
|
||||
|
||||
|
||||
</contentpackage>
|
||||
@@ -1,11 +0,0 @@
|
||||
{
|
||||
"version": "0.2.0",
|
||||
"configurations": [
|
||||
{
|
||||
"name": "MoonSharp Attach",
|
||||
"type": "moonsharp-debug",
|
||||
"debugServer": 41912,
|
||||
"request": "attach"
|
||||
}
|
||||
]
|
||||
}
|
||||
@@ -1,40 +0,0 @@
|
||||
{
|
||||
"Lua.diagnostics.globals": [
|
||||
"Game",
|
||||
"Player",
|
||||
"Random",
|
||||
"Hook",
|
||||
"Timer",
|
||||
"bit32",
|
||||
"TotalTime",
|
||||
"DoFile",
|
||||
"WayPoint",
|
||||
"SpawnType",
|
||||
"Level",
|
||||
"Submarine",
|
||||
"Vector2",
|
||||
"PositionType",
|
||||
"ServerLog_MessageType",
|
||||
"Character",
|
||||
"TraitorMessageType",
|
||||
"ChatMessageType",
|
||||
"CauseOfDeathType",
|
||||
"CreateVector2",
|
||||
"Item",
|
||||
"ChatMessage",
|
||||
"AfflictionPrefab",
|
||||
"Gap",
|
||||
"File",
|
||||
"Networking",
|
||||
"printNoLog",
|
||||
"Client",
|
||||
"SERVER",
|
||||
"setmodulepaths",
|
||||
"Type",
|
||||
"BindingFlags",
|
||||
"UserData",
|
||||
"LuaUserData",
|
||||
"CLIENT",
|
||||
"ContentPackageManager"
|
||||
]
|
||||
}
|
||||
@@ -1,150 +0,0 @@
|
||||
local Register = LuaSetup.LuaUserData.RegisterType
|
||||
local RegisterBarotrauma = LuaSetup.LuaUserData.RegisterTypeBarotrauma
|
||||
|
||||
local localizedStrings = {
|
||||
"LocalizedString", "LimitLString", "WrappedLString", "AddedPunctuationLString", "CapitalizeLString", "ConcatLString", "FallbackLString", "FormattedLString", "InputTypeLString", "JoinLString", "LowerLString", "RawLString", "ReplaceLString", "ServerMsgLString", "SplitLString", "TagLString", "TrimLString", "UpperLString", "StripRichTagsLString",
|
||||
}
|
||||
|
||||
for key, value in pairs(localizedStrings) do
|
||||
RegisterBarotrauma(value)
|
||||
end
|
||||
|
||||
RegisterBarotrauma("EditorScreen")
|
||||
RegisterBarotrauma("SubEditorScreen")
|
||||
RegisterBarotrauma("EventEditorScreen")
|
||||
RegisterBarotrauma("CharacterEditor.CharacterEditorScreen")
|
||||
RegisterBarotrauma("SpriteEditorScreen")
|
||||
RegisterBarotrauma("LevelEditorScreen")
|
||||
|
||||
RegisterBarotrauma("Networking.ClientPeer")
|
||||
RegisterBarotrauma("Networking.GameClient")
|
||||
RegisterBarotrauma("Networking.VoipCapture")
|
||||
|
||||
RegisterBarotrauma("Media.Video")
|
||||
|
||||
RegisterBarotrauma("SoundsFile")
|
||||
RegisterBarotrauma("SoundPrefab")
|
||||
RegisterBarotrauma("PrefabCollection`1")
|
||||
RegisterBarotrauma("PrefabSelector`1")
|
||||
RegisterBarotrauma("BackgroundMusic")
|
||||
RegisterBarotrauma("GUISound")
|
||||
RegisterBarotrauma("DamageSound")
|
||||
|
||||
RegisterBarotrauma("Sounds.SoundManager")
|
||||
RegisterBarotrauma("Sounds.OggSound")
|
||||
RegisterBarotrauma("Sounds.VideoSound")
|
||||
RegisterBarotrauma("Sounds.VoipSound")
|
||||
RegisterBarotrauma("Sounds.SoundChannel")
|
||||
RegisterBarotrauma("Sounds.SoundBuffers")
|
||||
RegisterBarotrauma("RoundSound")
|
||||
RegisterBarotrauma("CharacterSound")
|
||||
RegisterBarotrauma("SoundPlayer")
|
||||
RegisterBarotrauma("Items.Components.ItemSound")
|
||||
|
||||
RegisterBarotrauma("Sounds.LowpassFilter")
|
||||
RegisterBarotrauma("Sounds.HighpassFilter")
|
||||
RegisterBarotrauma("Sounds.BandpassFilter")
|
||||
RegisterBarotrauma("Sounds.NotchFilter")
|
||||
RegisterBarotrauma("Sounds.LowShelfFilter")
|
||||
RegisterBarotrauma("Sounds.HighShelfFilter")
|
||||
RegisterBarotrauma("Sounds.PeakFilter")
|
||||
|
||||
RegisterBarotrauma("Particles.ParticleManager")
|
||||
RegisterBarotrauma("Particles.Particle")
|
||||
RegisterBarotrauma("Particles.ParticleEmitterProperties")
|
||||
RegisterBarotrauma("Particles.ParticleEmitter")
|
||||
RegisterBarotrauma("Particles.ParticlePrefab")
|
||||
|
||||
RegisterBarotrauma("Lights.LightManager")
|
||||
RegisterBarotrauma("Lights.LightSource")
|
||||
RegisterBarotrauma("Lights.LightSourceParams")
|
||||
|
||||
RegisterBarotrauma("LevelWallVertexBuffer")
|
||||
RegisterBarotrauma("LevelRenderer")
|
||||
RegisterBarotrauma("WaterRenderer")
|
||||
RegisterBarotrauma("WaterVertexData")
|
||||
|
||||
RegisterBarotrauma("ChatBox")
|
||||
RegisterBarotrauma("GUICanvas")
|
||||
RegisterBarotrauma("Anchor")
|
||||
RegisterBarotrauma("Alignment")
|
||||
RegisterBarotrauma("Pivot")
|
||||
RegisterBarotrauma("Key")
|
||||
RegisterBarotrauma("PlayerInput")
|
||||
RegisterBarotrauma("ScalableFont")
|
||||
|
||||
Register("Microsoft.Xna.Framework.Graphics.Effect")
|
||||
Register("Microsoft.Xna.Framework.Graphics.EffectParameterCollection")
|
||||
Register("Microsoft.Xna.Framework.Graphics.EffectParameter")
|
||||
|
||||
Register("Microsoft.Xna.Framework.Graphics.SpriteBatch")
|
||||
Register("Microsoft.Xna.Framework.Graphics.Texture2D")
|
||||
Register("EventInput.KeyboardDispatcher")
|
||||
Register("EventInput.KeyEventArgs")
|
||||
Register("Microsoft.Xna.Framework.Input.Keys")
|
||||
Register("Microsoft.Xna.Framework.Input.KeyboardState")
|
||||
|
||||
RegisterBarotrauma("TextureLoader")
|
||||
RegisterBarotrauma("Sprite")
|
||||
RegisterBarotrauma("GUI")
|
||||
RegisterBarotrauma("GUIStyle")
|
||||
RegisterBarotrauma("GUIComponent")
|
||||
RegisterBarotrauma("GUILayoutGroup")
|
||||
RegisterBarotrauma("GUITextBox")
|
||||
RegisterBarotrauma("GUITextBlock")
|
||||
RegisterBarotrauma("GUIButton")
|
||||
RegisterBarotrauma("RectTransform")
|
||||
RegisterBarotrauma("GUIFrame")
|
||||
RegisterBarotrauma("GUITickBox")
|
||||
RegisterBarotrauma("GUIImage")
|
||||
RegisterBarotrauma("GUIListBox")
|
||||
RegisterBarotrauma("GUIScrollBar")
|
||||
RegisterBarotrauma("GUIDropDown")
|
||||
RegisterBarotrauma("GUINumberInput")
|
||||
RegisterBarotrauma("GUIMessage")
|
||||
RegisterBarotrauma("GUIMessageBox")
|
||||
RegisterBarotrauma("GUIColorPicker")
|
||||
RegisterBarotrauma("GUIProgressBar")
|
||||
RegisterBarotrauma("GUICustomComponent")
|
||||
RegisterBarotrauma("GUIScissorComponent")
|
||||
RegisterBarotrauma("GUIComponentStyle")
|
||||
RegisterBarotrauma("GUIFontPrefab")
|
||||
RegisterBarotrauma("GUIFont")
|
||||
RegisterBarotrauma("GUISpritePrefab")
|
||||
RegisterBarotrauma("GUISprite")
|
||||
RegisterBarotrauma("GUISpriteSheetPrefab")
|
||||
RegisterBarotrauma("GUISpriteSheet")
|
||||
RegisterBarotrauma("GUICursorPrefab")
|
||||
RegisterBarotrauma("GUICursor")
|
||||
RegisterBarotrauma("GUIRadioButtonGroup")
|
||||
RegisterBarotrauma("GUIDragHandle")
|
||||
RegisterBarotrauma("GUIContextMenu")
|
||||
RegisterBarotrauma("ContextMenuOption")
|
||||
RegisterBarotrauma("VideoPlayer")
|
||||
RegisterBarotrauma("CreditsPlayer")
|
||||
RegisterBarotrauma("SlideshowPlayer")
|
||||
RegisterBarotrauma("SerializableEntityEditor")
|
||||
RegisterBarotrauma("CircuitBoxWireRenderer")
|
||||
RegisterBarotrauma("CircuitBoxLabel")
|
||||
RegisterBarotrauma("CircuitBoxMouseDragSnapshotHandler")
|
||||
RegisterBarotrauma("CircuitBoxUI")
|
||||
|
||||
RegisterBarotrauma("SettingsMenu")
|
||||
RegisterBarotrauma("TabMenu")
|
||||
RegisterBarotrauma("Widget")
|
||||
RegisterBarotrauma("UpgradeStore")
|
||||
RegisterBarotrauma("VotingInterface")
|
||||
RegisterBarotrauma("MedicalClinicUI")
|
||||
RegisterBarotrauma("LoadingScreen")
|
||||
RegisterBarotrauma("HUD")
|
||||
RegisterBarotrauma("HUDLayoutSettings")
|
||||
RegisterBarotrauma("HUDProgressBar")
|
||||
RegisterBarotrauma("Graph")
|
||||
RegisterBarotrauma("HRManagerUI")
|
||||
RegisterBarotrauma("SubmarineSelection")
|
||||
RegisterBarotrauma("Store")
|
||||
RegisterBarotrauma("UISprite")
|
||||
RegisterBarotrauma("ParamsEditor")
|
||||
|
||||
RegisterBarotrauma("Inventory+SlotReference")
|
||||
RegisterBarotrauma("VisualSlot")
|
||||
@@ -1,20 +0,0 @@
|
||||
local Register = LuaSetup.LuaUserData.RegisterType
|
||||
local RegisterBarotrauma = LuaSetup.LuaUserData.RegisterTypeBarotrauma
|
||||
|
||||
|
||||
local localizedStrings = {
|
||||
"LocalizedString", "AddedPunctuationLString", "CapitalizeLString", "ConcatLString", "FallbackLString", "FormattedLString", "InputTypeLString", "JoinLString", "LowerLString", "RawLString", "ReplaceLString", "ServerMsgLString", "SplitLString", "TagLString", "TrimLString", "UpperLString", "StripRichTagsLString",
|
||||
}
|
||||
|
||||
for key, value in pairs(localizedStrings) do
|
||||
RegisterBarotrauma(value)
|
||||
end
|
||||
|
||||
Register("Steamworks.SteamServer")
|
||||
|
||||
RegisterBarotrauma("Character+TeamChangeEventData")
|
||||
|
||||
RegisterBarotrauma("Networking.GameServer")
|
||||
|
||||
RegisterBarotrauma("Networking.ServerPeer")
|
||||
RegisterBarotrauma("Networking.FileSender")
|
||||
@@ -1,479 +0,0 @@
|
||||
local Register = LuaSetup.LuaUserData.RegisterType
|
||||
local RegisterExtension = LuaSetup.LuaUserData.RegisterExtensionType
|
||||
local RegisterBarotrauma = LuaSetup.LuaUserData.RegisterTypeBarotrauma
|
||||
|
||||
Register("System.TimeSpan")
|
||||
Register("System.Exception")
|
||||
Register("System.Console")
|
||||
Register("System.Exception")
|
||||
|
||||
RegisterBarotrauma("Success`2")
|
||||
RegisterBarotrauma("Failure`2")
|
||||
|
||||
RegisterBarotrauma("LuaSByte")
|
||||
RegisterBarotrauma("LuaByte")
|
||||
RegisterBarotrauma("LuaInt16")
|
||||
RegisterBarotrauma("LuaUInt16")
|
||||
RegisterBarotrauma("LuaInt32")
|
||||
RegisterBarotrauma("LuaUInt32")
|
||||
RegisterBarotrauma("LuaInt64")
|
||||
RegisterBarotrauma("LuaUInt64")
|
||||
RegisterBarotrauma("LuaSingle")
|
||||
RegisterBarotrauma("LuaDouble")
|
||||
|
||||
RegisterBarotrauma("GameMain")
|
||||
RegisterBarotrauma("Networking.BanList")
|
||||
RegisterBarotrauma("Networking.BannedPlayer")
|
||||
|
||||
RegisterBarotrauma("Range`1")
|
||||
|
||||
RegisterBarotrauma("RichString")
|
||||
RegisterBarotrauma("Identifier")
|
||||
RegisterBarotrauma("LanguageIdentifier")
|
||||
|
||||
RegisterBarotrauma("Job")
|
||||
RegisterBarotrauma("JobPrefab")
|
||||
RegisterBarotrauma("JobVariant")
|
||||
|
||||
Register("Voronoi2.DoubleVector2")
|
||||
Register("Voronoi2.Site")
|
||||
Register("Voronoi2.Edge")
|
||||
Register("Voronoi2.Halfedge")
|
||||
Register("Voronoi2.VoronoiCell")
|
||||
Register("Voronoi2.GraphEdge")
|
||||
|
||||
RegisterBarotrauma("WayPoint")
|
||||
RegisterBarotrauma("Level")
|
||||
RegisterBarotrauma("LevelData")
|
||||
RegisterBarotrauma("Level+InterestingPosition")
|
||||
RegisterBarotrauma("LevelGenerationParams")
|
||||
RegisterBarotrauma("LevelObjectManager")
|
||||
RegisterBarotrauma("LevelObject")
|
||||
RegisterBarotrauma("LevelObjectPrefab")
|
||||
RegisterBarotrauma("LevelTrigger")
|
||||
RegisterBarotrauma("CaveGenerationParams")
|
||||
RegisterBarotrauma("CaveGenerator")
|
||||
RegisterBarotrauma("OutpostGenerationParams")
|
||||
RegisterBarotrauma("OutpostGenerator")
|
||||
RegisterBarotrauma("OutpostModuleInfo")
|
||||
RegisterBarotrauma("BeaconStationInfo")
|
||||
RegisterBarotrauma("NPCSet")
|
||||
RegisterBarotrauma("RuinGeneration.Ruin")
|
||||
RegisterBarotrauma("RuinGeneration.RuinGenerationParams")
|
||||
RegisterBarotrauma("LevelWall")
|
||||
RegisterBarotrauma("DestructibleLevelWall")
|
||||
RegisterBarotrauma("Biome")
|
||||
RegisterBarotrauma("Map")
|
||||
RegisterBarotrauma("Networking.RespawnManager")
|
||||
RegisterBarotrauma("Networking.RespawnManager+TeamSpecificState")
|
||||
|
||||
RegisterBarotrauma("Character")
|
||||
RegisterBarotrauma("CharacterPrefab")
|
||||
RegisterBarotrauma("CharacterInfo")
|
||||
RegisterBarotrauma("CharacterInfoPrefab")
|
||||
RegisterBarotrauma("CharacterInfo+HeadPreset")
|
||||
RegisterBarotrauma("CharacterInfo+HeadInfo")
|
||||
RegisterBarotrauma("CharacterHealth")
|
||||
RegisterBarotrauma("CharacterHealth+LimbHealth")
|
||||
RegisterBarotrauma("DamageModifier")
|
||||
RegisterBarotrauma("CharacterInventory")
|
||||
RegisterBarotrauma("CharacterParams")
|
||||
RegisterBarotrauma("CharacterParams+AIParams")
|
||||
RegisterBarotrauma("CharacterParams+TargetParams")
|
||||
RegisterBarotrauma("CharacterParams+InventoryParams")
|
||||
RegisterBarotrauma("CharacterParams+HealthParams")
|
||||
RegisterBarotrauma("CharacterParams+ParticleParams")
|
||||
RegisterBarotrauma("CharacterParams+SoundParams")
|
||||
RegisterBarotrauma("SteeringManager")
|
||||
RegisterBarotrauma("IndoorsSteeringManager")
|
||||
RegisterBarotrauma("SteeringPath")
|
||||
RegisterBarotrauma("CreatureMetrics")
|
||||
|
||||
RegisterBarotrauma("Item")
|
||||
RegisterBarotrauma("DeconstructItem")
|
||||
RegisterBarotrauma("PurchasedItem")
|
||||
RegisterBarotrauma("PurchasedItemSwap")
|
||||
RegisterBarotrauma("PurchasedUpgrade")
|
||||
RegisterBarotrauma("SoldItem")
|
||||
RegisterBarotrauma("StartItem")
|
||||
RegisterBarotrauma("StartItemSet")
|
||||
RegisterBarotrauma("RelatedItem")
|
||||
RegisterBarotrauma("UpgradeManager")
|
||||
RegisterBarotrauma("CargoManager")
|
||||
RegisterBarotrauma("HireManager")
|
||||
RegisterBarotrauma("FabricationRecipe")
|
||||
RegisterBarotrauma("PreferredContainer")
|
||||
RegisterBarotrauma("SwappableItem")
|
||||
RegisterBarotrauma("FabricationRecipe+RequiredItemByIdentifier")
|
||||
RegisterBarotrauma("FabricationRecipe+RequiredItemByTag")
|
||||
RegisterBarotrauma("Submarine")
|
||||
|
||||
RegisterBarotrauma("Networking.AccountInfo")
|
||||
RegisterBarotrauma("Networking.AccountId")
|
||||
RegisterBarotrauma("Networking.SteamId")
|
||||
RegisterBarotrauma("Networking.EpicAccountId")
|
||||
RegisterBarotrauma("Networking.Address")
|
||||
RegisterBarotrauma("Networking.UnknownAddress")
|
||||
RegisterBarotrauma("Networking.P2PAddress")
|
||||
RegisterBarotrauma("Networking.EosP2PAddress")
|
||||
RegisterBarotrauma("Networking.SteamP2PAddress")
|
||||
RegisterBarotrauma("Networking.PipeAddress")
|
||||
RegisterBarotrauma("Networking.LidgrenAddress")
|
||||
RegisterBarotrauma("Networking.Endpoint")
|
||||
RegisterBarotrauma("Networking.SteamP2PEndpoint")
|
||||
RegisterBarotrauma("Networking.PipeEndpoint")
|
||||
RegisterBarotrauma("Networking.LidgrenEndpoint")
|
||||
|
||||
RegisterBarotrauma("INetSerializableStruct")
|
||||
RegisterBarotrauma("Networking.Client")
|
||||
RegisterBarotrauma("Networking.TempClient")
|
||||
RegisterBarotrauma("Networking.NetworkConnection")
|
||||
RegisterBarotrauma("Networking.LidgrenConnection")
|
||||
RegisterBarotrauma("Networking.SteamP2PConnection")
|
||||
RegisterBarotrauma("Networking.VoipQueue")
|
||||
RegisterBarotrauma("Networking.ChatMessage")
|
||||
|
||||
RegisterBarotrauma("AnimController")
|
||||
RegisterBarotrauma("HumanoidAnimController")
|
||||
RegisterBarotrauma("FishAnimController")
|
||||
RegisterBarotrauma("Limb")
|
||||
RegisterBarotrauma("Ragdoll")
|
||||
RegisterBarotrauma("RagdollParams")
|
||||
|
||||
RegisterBarotrauma("AfflictionPrefab")
|
||||
RegisterBarotrauma("Affliction")
|
||||
RegisterBarotrauma("AttackResult")
|
||||
RegisterBarotrauma("Attack")
|
||||
RegisterBarotrauma("Entity")
|
||||
RegisterBarotrauma("EntityGrid")
|
||||
RegisterBarotrauma("EntitySpawner")
|
||||
RegisterBarotrauma("MapEntity")
|
||||
RegisterBarotrauma("MapEntityPrefab")
|
||||
RegisterBarotrauma("CauseOfDeath")
|
||||
RegisterBarotrauma("Hull")
|
||||
RegisterBarotrauma("WallSection")
|
||||
RegisterBarotrauma("Structure")
|
||||
RegisterBarotrauma("Gap")
|
||||
RegisterBarotrauma("PhysicsBody")
|
||||
RegisterBarotrauma("AbilityFlags")
|
||||
RegisterBarotrauma("ItemPrefab")
|
||||
RegisterBarotrauma("ItemAssemblyPrefab")
|
||||
RegisterBarotrauma("InputType")
|
||||
|
||||
RegisterBarotrauma("FireSource")
|
||||
RegisterBarotrauma("SerializableProperty")
|
||||
LuaUserData.MakeFieldAccessible(RegisterBarotrauma("StatusEffect"), "user")
|
||||
RegisterBarotrauma("DurationListElement")
|
||||
RegisterBarotrauma("PropertyConditional")
|
||||
RegisterBarotrauma("DelayedListElement")
|
||||
RegisterBarotrauma("DelayedEffect")
|
||||
|
||||
|
||||
RegisterBarotrauma("ContentPackageManager")
|
||||
RegisterBarotrauma("ContentPackageManager+PackageSource")
|
||||
RegisterBarotrauma("ContentPackageManager+EnabledPackages")
|
||||
RegisterBarotrauma("ContentPackage")
|
||||
RegisterBarotrauma("RegularPackage")
|
||||
RegisterBarotrauma("CorePackage")
|
||||
RegisterBarotrauma("ContentXElement")
|
||||
RegisterBarotrauma("ContentPath")
|
||||
RegisterBarotrauma("ContentPackageId")
|
||||
RegisterBarotrauma("SteamWorkshopId")
|
||||
RegisterBarotrauma("Md5Hash")
|
||||
|
||||
RegisterBarotrauma("AfflictionsFile")
|
||||
RegisterBarotrauma("BackgroundCreaturePrefabsFile")
|
||||
RegisterBarotrauma("BallastFloraFile")
|
||||
RegisterBarotrauma("BeaconStationFile")
|
||||
RegisterBarotrauma("CaveGenerationParametersFile")
|
||||
RegisterBarotrauma("CharacterFile")
|
||||
RegisterBarotrauma("ContentFile")
|
||||
RegisterBarotrauma("CorpsesFile")
|
||||
RegisterBarotrauma("DecalsFile")
|
||||
RegisterBarotrauma("EnemySubmarineFile")
|
||||
RegisterBarotrauma("EventManagerSettingsFile")
|
||||
RegisterBarotrauma("FactionsFile")
|
||||
RegisterBarotrauma("ItemAssemblyFile")
|
||||
RegisterBarotrauma("ItemFile")
|
||||
RegisterBarotrauma("JobsFile")
|
||||
RegisterBarotrauma("LevelGenerationParametersFile")
|
||||
RegisterBarotrauma("LevelObjectPrefabsFile")
|
||||
RegisterBarotrauma("LocationTypesFile")
|
||||
RegisterBarotrauma("MapGenerationParametersFile")
|
||||
RegisterBarotrauma("MissionsFile")
|
||||
RegisterBarotrauma("NPCConversationsFile")
|
||||
RegisterBarotrauma("NPCPersonalityTraitsFile")
|
||||
RegisterBarotrauma("NPCSetsFile")
|
||||
RegisterBarotrauma("OrdersFile")
|
||||
RegisterBarotrauma("OtherFile")
|
||||
RegisterBarotrauma("OutpostConfigFile")
|
||||
RegisterBarotrauma("OutpostFile")
|
||||
RegisterBarotrauma("OutpostModuleFile")
|
||||
RegisterBarotrauma("ParticlesFile")
|
||||
RegisterBarotrauma("RandomEventsFile")
|
||||
RegisterBarotrauma("RuinConfigFile")
|
||||
RegisterBarotrauma("ServerExecutableFile")
|
||||
RegisterBarotrauma("SkillSettingsFile")
|
||||
RegisterBarotrauma("SoundsFile")
|
||||
RegisterBarotrauma("StartItemsFile")
|
||||
RegisterBarotrauma("StructureFile")
|
||||
RegisterBarotrauma("SubmarineFile")
|
||||
RegisterBarotrauma("TalentsFile")
|
||||
RegisterBarotrauma("TalentTreesFile")
|
||||
RegisterBarotrauma("TextFile")
|
||||
RegisterBarotrauma("TutorialsFile")
|
||||
RegisterBarotrauma("UIStyleFile")
|
||||
RegisterBarotrauma("UpgradeModulesFile")
|
||||
RegisterBarotrauma("WreckAIConfigFile")
|
||||
RegisterBarotrauma("WreckFile")
|
||||
|
||||
Register("System.Xml.Linq.XElement")
|
||||
Register("System.Xml.Linq.XName")
|
||||
Register("System.Xml.Linq.XAttribute")
|
||||
Register("System.Xml.Linq.XContainer")
|
||||
Register("System.Xml.Linq.XDocument")
|
||||
Register("System.Xml.Linq.XNode")
|
||||
|
||||
|
||||
RegisterBarotrauma("SubmarineBody")
|
||||
RegisterBarotrauma("Explosion")
|
||||
RegisterBarotrauma("Networking.ServerSettings")
|
||||
RegisterBarotrauma("Networking.ServerSettings+SavedClientPermission")
|
||||
RegisterBarotrauma("Inventory")
|
||||
RegisterBarotrauma("ItemInventory")
|
||||
RegisterBarotrauma("Inventory+ItemSlot")
|
||||
RegisterBarotrauma("FireSource")
|
||||
RegisterBarotrauma("AutoItemPlacer")
|
||||
RegisterBarotrauma("CircuitBoxConnection")
|
||||
RegisterBarotrauma("CircuitBoxComponent")
|
||||
RegisterBarotrauma("CircuitBoxNode")
|
||||
RegisterBarotrauma("CircuitBoxWire")
|
||||
RegisterBarotrauma("CircuitBoxInputOutputNode")
|
||||
RegisterBarotrauma("CircuitBoxSelectable")
|
||||
RegisterBarotrauma("CircuitBoxSizes")
|
||||
|
||||
local componentsToRegister = { "DockingPort", "Door", "GeneticMaterial", "Growable", "Holdable", "LevelResource", "ItemComponent", "ItemLabel", "LightComponent", "Controller", "Deconstructor", "Engine", "Fabricator", "OutpostTerminal", "Pump", "Reactor", "Steering", "PowerContainer", "Projectile", "Repairable", "Rope", "Scanner", "ButtonTerminal", "ConnectionPanel", "CustomInterface", "MemoryComponent", "Terminal", "WifiComponent", "Wire", "TriggerComponent", "ElectricalDischarger", "EntitySpawnerComponent", "ProducedItem", "VineTile", "GrowthSideExtension", "IdCard", "MeleeWeapon", "Pickable", "AbilityItemPickingTime", "Propulsion", "RangedWeapon", "AbilityRangedWeapon", "RepairTool", "Sprayer", "Throwable", "ItemContainer", "AbilityItemContainer", "Ladder", "LimbPos", "AbilityDeconstructedItem", "AbilityItemCreationMultiplier", "AbilityItemDeconstructedInventory", "MiniMap", "OxygenGenerator", "Sonar", "SonarTransducer", "Vent", "NameTag", "Planter", "Powered", "PowerTransfer", "Quality", "RemoteController", "AdderComponent", "AndComponent", "ArithmeticComponent", "ColorComponent", "ConcatComponent", "Connection", "CircuitBox", "DelayComponent", "DivideComponent", "EqualsComponent", "ExponentiationComponent", "FunctionComponent", "GreaterComponent", "ModuloComponent", "MotionSensor", "MultiplyComponent", "NotComponent", "OrComponent", "OscillatorComponent", "OxygenDetector", "RegExFindComponent", "RelayComponent", "SignalCheckComponent", "SmokeDetector", "StringComponent", "SubtractComponent", "TrigonometricFunctionComponent", "WaterDetector", "XorComponent", "StatusHUD", "Turret", "Wearable",
|
||||
"GridInfo", "PowerSourceGroup"
|
||||
}
|
||||
|
||||
for key, value in pairs(componentsToRegister) do
|
||||
RegisterBarotrauma("Items.Components." .. value)
|
||||
end
|
||||
|
||||
LuaUserData.MakeFieldAccessible(RegisterBarotrauma("Items.Components.CustomInterface"), "customInterfaceElementList")
|
||||
RegisterBarotrauma("Items.Components.CustomInterface+CustomInterfaceElement")
|
||||
|
||||
RegisterBarotrauma("WearableSprite")
|
||||
|
||||
RegisterBarotrauma("AIController")
|
||||
RegisterBarotrauma("EnemyAIController")
|
||||
RegisterBarotrauma("HumanAIController")
|
||||
RegisterBarotrauma("AICharacter")
|
||||
RegisterBarotrauma("AITarget")
|
||||
RegisterBarotrauma("AITargetMemory")
|
||||
RegisterBarotrauma("AIChatMessage")
|
||||
RegisterBarotrauma("AIObjectiveManager")
|
||||
RegisterBarotrauma("WreckAI")
|
||||
RegisterBarotrauma("WreckAIConfig")
|
||||
|
||||
RegisterBarotrauma("AIObjectiveChargeBatteries")
|
||||
RegisterBarotrauma("AIObjective")
|
||||
RegisterBarotrauma("AIObjectiveCleanupItem")
|
||||
RegisterBarotrauma("AIObjectiveCleanupItems")
|
||||
RegisterBarotrauma("AIObjectiveCombat")
|
||||
RegisterBarotrauma("AIObjectiveContainItem")
|
||||
RegisterBarotrauma("AIObjectiveDeconstructItem")
|
||||
RegisterBarotrauma("AIObjectiveDeconstructItems")
|
||||
RegisterBarotrauma("AIObjectiveEscapeHandcuffs")
|
||||
RegisterBarotrauma("AIObjectiveExtinguishFire")
|
||||
RegisterBarotrauma("AIObjectiveExtinguishFires")
|
||||
RegisterBarotrauma("AIObjectiveFightIntruders")
|
||||
RegisterBarotrauma("AIObjectiveFindDivingGear")
|
||||
RegisterBarotrauma("AIObjectiveFindSafety")
|
||||
RegisterBarotrauma("AIObjectiveFixLeak")
|
||||
RegisterBarotrauma("AIObjectiveFixLeaks")
|
||||
RegisterBarotrauma("AIObjectiveGetItem")
|
||||
RegisterBarotrauma("AIObjectiveGoTo")
|
||||
RegisterBarotrauma("AIObjectiveIdle")
|
||||
RegisterBarotrauma("AIObjectiveOperateItem")
|
||||
RegisterBarotrauma("AIObjectivePumpWater")
|
||||
RegisterBarotrauma("AIObjectiveRepairItem")
|
||||
RegisterBarotrauma("AIObjectiveRepairItems")
|
||||
RegisterBarotrauma("AIObjectiveRescue")
|
||||
RegisterBarotrauma("AIObjectiveRescueAll")
|
||||
RegisterBarotrauma("AIObjectiveReturn")
|
||||
|
||||
RegisterBarotrauma("Order")
|
||||
RegisterBarotrauma("OrderPrefab")
|
||||
RegisterBarotrauma("OrderTarget")
|
||||
|
||||
RegisterBarotrauma("TalentPrefab")
|
||||
RegisterBarotrauma("TalentOption")
|
||||
RegisterBarotrauma("TalentSubTree")
|
||||
RegisterBarotrauma("TalentTree")
|
||||
RegisterBarotrauma("CharacterTalent")
|
||||
RegisterBarotrauma("Upgrade")
|
||||
RegisterBarotrauma("UpgradeCategory")
|
||||
RegisterBarotrauma("UpgradePrefab")
|
||||
RegisterBarotrauma("UpgradeManager")
|
||||
|
||||
RegisterBarotrauma("Screen")
|
||||
RegisterBarotrauma("GameScreen")
|
||||
RegisterBarotrauma("GameSession")
|
||||
RegisterBarotrauma("GameSettings")
|
||||
RegisterBarotrauma("CrewManager")
|
||||
RegisterBarotrauma("KarmaManager")
|
||||
|
||||
RegisterBarotrauma("GameMode")
|
||||
RegisterBarotrauma("MissionMode")
|
||||
RegisterBarotrauma("PvPMode")
|
||||
RegisterBarotrauma("Mission")
|
||||
RegisterBarotrauma("AbandonedOutpostMission")
|
||||
RegisterBarotrauma("EliminateTargetsMission")
|
||||
RegisterBarotrauma("EndMission")
|
||||
RegisterBarotrauma("BeaconMission")
|
||||
RegisterBarotrauma("CargoMission")
|
||||
RegisterBarotrauma("CombatMission")
|
||||
RegisterBarotrauma("EscortMission")
|
||||
RegisterBarotrauma("GoToMission")
|
||||
RegisterBarotrauma("MineralMission")
|
||||
RegisterBarotrauma("MonsterMission")
|
||||
RegisterBarotrauma("NestMission")
|
||||
RegisterBarotrauma("PirateMission")
|
||||
RegisterBarotrauma("SalvageMission")
|
||||
RegisterBarotrauma("ScanMission")
|
||||
RegisterBarotrauma("MissionPrefab")
|
||||
RegisterBarotrauma("CampaignMode")
|
||||
RegisterBarotrauma("CoOpMode")
|
||||
RegisterBarotrauma("MultiPlayerCampaign")
|
||||
RegisterBarotrauma("Radiation")
|
||||
|
||||
RegisterBarotrauma("CampaignMetadata")
|
||||
RegisterBarotrauma("Wallet")
|
||||
|
||||
RegisterBarotrauma("Faction")
|
||||
RegisterBarotrauma("FactionPrefab")
|
||||
RegisterBarotrauma("Reputation")
|
||||
|
||||
RegisterBarotrauma("Location")
|
||||
RegisterBarotrauma("LocationConnection")
|
||||
RegisterBarotrauma("LocationType")
|
||||
RegisterBarotrauma("LocationTypeChange")
|
||||
|
||||
RegisterBarotrauma("DebugConsole")
|
||||
RegisterBarotrauma("DebugConsole+Command")
|
||||
|
||||
RegisterBarotrauma("TextManager")
|
||||
RegisterBarotrauma("TextPack")
|
||||
|
||||
local descriptor = RegisterBarotrauma("NetLobbyScreen")
|
||||
|
||||
if SERVER then
|
||||
LuaUserData.MakeFieldAccessible(descriptor, "subs")
|
||||
end
|
||||
|
||||
RegisterBarotrauma("EventManager")
|
||||
RegisterBarotrauma("EventManagerSettings")
|
||||
RegisterBarotrauma("Event")
|
||||
RegisterBarotrauma("ArtifactEvent")
|
||||
RegisterBarotrauma("MonsterEvent")
|
||||
RegisterBarotrauma("ScriptedEvent")
|
||||
RegisterBarotrauma("MalfunctionEvent")
|
||||
RegisterBarotrauma("EventSet")
|
||||
RegisterBarotrauma("EventPrefab")
|
||||
|
||||
RegisterBarotrauma("Networking.NetConfig")
|
||||
RegisterBarotrauma("Networking.IWriteMessage")
|
||||
RegisterBarotrauma("Networking.IReadMessage")
|
||||
RegisterBarotrauma("Networking.NetEntityEvent")
|
||||
RegisterBarotrauma("Networking.INetSerializable")
|
||||
Register("Lidgren.Network.NetIncomingMessage")
|
||||
Register("Lidgren.Network.NetConnection")
|
||||
Register("System.Net.IPEndPoint")
|
||||
Register("System.Net.IPAddress")
|
||||
|
||||
RegisterBarotrauma("Skill")
|
||||
RegisterBarotrauma("SkillPrefab")
|
||||
RegisterBarotrauma("SkillSettings")
|
||||
|
||||
RegisterBarotrauma("TraitorManager")
|
||||
RegisterBarotrauma("TraitorEvent")
|
||||
RegisterBarotrauma("TraitorEventPrefab")
|
||||
RegisterBarotrauma("TraitorManager+TraitorResults")
|
||||
|
||||
Register("FarseerPhysics.Dynamics.Body")
|
||||
Register("FarseerPhysics.Dynamics.World")
|
||||
Register("FarseerPhysics.Dynamics.Fixture")
|
||||
Register("FarseerPhysics.ConvertUnits")
|
||||
Register("FarseerPhysics.Collision.AABB")
|
||||
Register("FarseerPhysics.Collision.ContactFeature")
|
||||
Register("FarseerPhysics.Collision.ManifoldPoint")
|
||||
Register("FarseerPhysics.Collision.ContactID")
|
||||
Register("FarseerPhysics.Collision.Manifold")
|
||||
Register("FarseerPhysics.Collision.RayCastInput")
|
||||
Register("FarseerPhysics.Collision.ClipVertex")
|
||||
Register("FarseerPhysics.Collision.RayCastOutput")
|
||||
Register("FarseerPhysics.Collision.EPAxis")
|
||||
Register("FarseerPhysics.Collision.ReferenceFace")
|
||||
Register("FarseerPhysics.Collision.Collision")
|
||||
|
||||
RegisterBarotrauma("Physics")
|
||||
|
||||
local toolBox = RegisterBarotrauma("ToolBox")
|
||||
if CLIENT then
|
||||
LuaUserData.RemoveMember(toolBox, "OpenFileWithShell")
|
||||
end
|
||||
|
||||
RegisterBarotrauma("Camera")
|
||||
RegisterBarotrauma("Key")
|
||||
|
||||
RegisterBarotrauma("PrefabCollection`1")
|
||||
|
||||
RegisterBarotrauma("PrefabSelector`1")
|
||||
|
||||
RegisterBarotrauma("Pair`2")
|
||||
|
||||
RegisterBarotrauma("Items.Components.Signal")
|
||||
RegisterBarotrauma("SubmarineInfo")
|
||||
|
||||
RegisterBarotrauma("MapCreatures.Behavior.BallastFloraBehavior")
|
||||
RegisterBarotrauma("MapCreatures.Behavior.BallastFloraBranch")
|
||||
|
||||
RegisterBarotrauma("PetBehavior")
|
||||
RegisterBarotrauma("SwarmBehavior")
|
||||
RegisterBarotrauma("LatchOntoAI")
|
||||
|
||||
RegisterBarotrauma("Decal")
|
||||
RegisterBarotrauma("DecalPrefab")
|
||||
RegisterBarotrauma("DecalManager")
|
||||
|
||||
RegisterBarotrauma("PriceInfo")
|
||||
|
||||
RegisterBarotrauma("Voting")
|
||||
|
||||
Register("Microsoft.Xna.Framework.Vector2")
|
||||
Register("Microsoft.Xna.Framework.Vector3")
|
||||
Register("Microsoft.Xna.Framework.Vector4")
|
||||
Register("Microsoft.Xna.Framework.Color")
|
||||
Register("Microsoft.Xna.Framework.Point")
|
||||
Register("Microsoft.Xna.Framework.Rectangle")
|
||||
Register("Microsoft.Xna.Framework.Matrix")
|
||||
|
||||
local friend = Register("Steamworks.Friend")
|
||||
|
||||
LuaUserData.RemoveMember(friend, "InviteToGame")
|
||||
LuaUserData.RemoveMember(friend, "SendMessage")
|
||||
|
||||
local workshopItem = Register("Steamworks.Ugc.Item")
|
||||
|
||||
LuaUserData.RemoveMember(workshopItem, "Subscribe")
|
||||
LuaUserData.RemoveMember(workshopItem, "DownloadAsync")
|
||||
LuaUserData.RemoveMember(workshopItem, "Unsubscribe")
|
||||
LuaUserData.RemoveMember(workshopItem, "AddFavorite")
|
||||
LuaUserData.RemoveMember(workshopItem, "RemoveFavorite")
|
||||
LuaUserData.RemoveMember(workshopItem, "Vote")
|
||||
LuaUserData.RemoveMember(workshopItem, "GetUserVote")
|
||||
LuaUserData.RemoveMember(workshopItem, "Edit")
|
||||
|
||||
RegisterExtension("Barotrauma.MathUtils")
|
||||
RegisterExtension("Barotrauma.XMLExtensions")
|
||||
@@ -1,47 +0,0 @@
|
||||
LuaSetup = {}
|
||||
|
||||
local path = table.pack(...)[1]
|
||||
|
||||
package.path = {path .. "/?.lua"}
|
||||
|
||||
setmodulepaths(package.path)
|
||||
|
||||
-- Setup Libraries
|
||||
LuaSetup.LuaUserData = LuaUserData
|
||||
|
||||
require("DefaultRegister/RegisterShared")
|
||||
|
||||
if SERVER then
|
||||
require("DefaultRegister/RegisterServer")
|
||||
else
|
||||
require("DefaultRegister/RegisterClient")
|
||||
end
|
||||
|
||||
local function AddTableToGlobal(tbl)
|
||||
for k, v in pairs(tbl) do
|
||||
_G[k] = v
|
||||
end
|
||||
end
|
||||
|
||||
if SERVER then
|
||||
AddTableToGlobal(require("DefaultLib/LibServer"))
|
||||
else
|
||||
AddTableToGlobal(require("DefaultLib/LibClient"))
|
||||
end
|
||||
|
||||
AddTableToGlobal(require("DefaultLib/LibShared"))
|
||||
|
||||
AddTableToGlobal(require("CompatibilityLib"))
|
||||
|
||||
require("DefaultHook")
|
||||
|
||||
require("DefaultLib/Utils/Math")
|
||||
require("DefaultLib/Utils/String")
|
||||
require("DefaultLib/Utils/Util")
|
||||
require("DefaultLib/Utils/SteamApi")
|
||||
|
||||
require("PostSetup")
|
||||
|
||||
LuaSetup = nil
|
||||
|
||||
require("ModLoader")
|
||||
@@ -1,193 +0,0 @@
|
||||
local LUA_MOD_REQUIRE_PATH = "/Lua/?.lua"
|
||||
local LUA_MOD_AUTORUN_PATH = "/Lua/Autorun"
|
||||
local LUA_MOD_FORCEDAUTORUN_PATH = "/Lua/ForcedAutorun"
|
||||
|
||||
local function EndsWith(str, suffix)
|
||||
return str:sub(-string.len(suffix)) == suffix
|
||||
end
|
||||
|
||||
local function GetFileName(file)
|
||||
return file:match("^.+/(.+)$")
|
||||
end
|
||||
|
||||
local function ExecuteProtected(s, folder)
|
||||
loadfile(s)(folder)
|
||||
end
|
||||
|
||||
local function RunFolder(folder, rootFolder, package)
|
||||
local search = File.DirSearch(folder)
|
||||
for i = 1, #search, 1 do
|
||||
local s = search[i]:gsub("\\", "/")
|
||||
|
||||
if EndsWith(s, ".lua") then
|
||||
local time = os.clock()
|
||||
local ok, result = pcall(ExecuteProtected, s, rootFolder)
|
||||
local diff = os.clock() - time
|
||||
|
||||
print(string.format(" - %s (Took %.5fms)", GetFileName(s), diff))
|
||||
if not ok then
|
||||
printerror(result)
|
||||
end
|
||||
end
|
||||
|
||||
end
|
||||
end
|
||||
|
||||
local function AssertTypes(expectedTypes, ...)
|
||||
local args = table.pack(...)
|
||||
assert(
|
||||
#args == #expectedTypes,
|
||||
string.format(
|
||||
"Assertion failed: incorrect number of args\n\texpected = %s\n\tgot = %s",
|
||||
#expectedTypes, #args
|
||||
)
|
||||
)
|
||||
for i = 1, #args do
|
||||
local arg = args[i]
|
||||
local expectedType = expectedTypes[i]
|
||||
assert(
|
||||
type(arg) == expectedType,
|
||||
string.format(
|
||||
"Assertion failed: incorrect argument type (arg #%d)\n\texpected = %s\n\tgot = %s",
|
||||
i, expectedType, type(arg)
|
||||
)
|
||||
)
|
||||
end
|
||||
end
|
||||
|
||||
local function ExecutionQueue()
|
||||
local executionQueue = {}
|
||||
executionQueue.Queue = {}
|
||||
|
||||
executionQueue.Process = function()
|
||||
while executionQueue.Queue[1] ~= nil do
|
||||
local folder, rootFolder, package = table.unpack(table.remove(executionQueue.Queue, 1))
|
||||
print(string.format("%s %s", package.Name, package.ModVersion))
|
||||
RunFolder(folder, rootFolder, package)
|
||||
end
|
||||
end
|
||||
|
||||
executionQueue.Add = function(...)
|
||||
AssertTypes({ 'string', 'string', 'userdata' }, ...)
|
||||
table.insert(executionQueue.Queue, table.pack(...))
|
||||
end
|
||||
|
||||
return executionQueue
|
||||
end
|
||||
|
||||
local QueueAutorun = ExecutionQueue()
|
||||
local QueueForcedAutorun = ExecutionQueue()
|
||||
|
||||
local function nocase(s)
|
||||
s = string.gsub(s, "%a", function(c)
|
||||
return string.format("[%s%s]", string.lower(c), string.upper(c))
|
||||
end)
|
||||
return s
|
||||
end
|
||||
|
||||
local function ProcessPackages(packages, fn)
|
||||
for pkg in packages do
|
||||
if pkg then
|
||||
local pkgPath = pkg.Path
|
||||
:gsub("\\", "/")
|
||||
:gsub(nocase("/filelist.xml"), "")
|
||||
fn(pkg, pkgPath)
|
||||
end
|
||||
end
|
||||
end
|
||||
|
||||
ProcessPackages(ContentPackageManager.EnabledPackages.All, function(pkg, pkgPath)
|
||||
table.insert(package.path, pkgPath .. LUA_MOD_REQUIRE_PATH)
|
||||
local autorunPath = pkgPath .. LUA_MOD_AUTORUN_PATH
|
||||
if File.DirectoryExists(autorunPath) then
|
||||
QueueAutorun.Add(autorunPath, pkgPath, pkg)
|
||||
end
|
||||
end)
|
||||
|
||||
-- we don't want to execute workshop ForcedAutorun if we have a local Package
|
||||
local executedLocalPackages = {}
|
||||
|
||||
ProcessPackages(ContentPackageManager.EnabledPackages.All, function(pkg, pkgPath)
|
||||
table.insert(package.path, pkgPath .. LUA_MOD_REQUIRE_PATH)
|
||||
local forcedAutorunPath = pkgPath .. LUA_MOD_FORCEDAUTORUN_PATH
|
||||
if File.DirectoryExists(forcedAutorunPath) then
|
||||
QueueForcedAutorun.Add(forcedAutorunPath, pkgPath, pkg)
|
||||
executedLocalPackages[pkg.Name] = true
|
||||
end
|
||||
end)
|
||||
|
||||
if not LuaCsConfig.TreatForcedModsAsNormal then
|
||||
ProcessPackages(ContentPackageManager.LocalPackages, function(pkg, pkgPath)
|
||||
if not executedLocalPackages[pkg.Name] then
|
||||
table.insert(package.path, pkgPath .. LUA_MOD_REQUIRE_PATH)
|
||||
local forcedAutorunPath = pkgPath .. LUA_MOD_FORCEDAUTORUN_PATH
|
||||
if File.DirectoryExists(forcedAutorunPath) then
|
||||
QueueForcedAutorun.Add(forcedAutorunPath, pkgPath, pkg)
|
||||
executedLocalPackages[pkg.Name] = true
|
||||
end
|
||||
end
|
||||
end)
|
||||
|
||||
ProcessPackages(ContentPackageManager.AllPackages, function(pkg, pkgPath)
|
||||
if not executedLocalPackages[pkg.Name] then
|
||||
table.insert(package.path, pkgPath .. LUA_MOD_REQUIRE_PATH)
|
||||
local forcedAutorunPath = pkgPath .. LUA_MOD_FORCEDAUTORUN_PATH
|
||||
if File.DirectoryExists(forcedAutorunPath) then
|
||||
QueueForcedAutorun.Add(forcedAutorunPath, pkgPath, pkg)
|
||||
end
|
||||
end
|
||||
end)
|
||||
end
|
||||
|
||||
setmodulepaths(package.path)
|
||||
setmodulepaths = nil
|
||||
|
||||
local allExecuted = {}
|
||||
for key, value in pairs(QueueAutorun.Queue) do table.insert(allExecuted, value[3]) end
|
||||
for key, value in pairs(QueueForcedAutorun.Queue) do table.insert(allExecuted, value[3]) end
|
||||
|
||||
if SERVER then
|
||||
Networking.Receive("_luastart", function (message, client)
|
||||
local num = message.ReadUInt16()
|
||||
|
||||
local packages = {}
|
||||
|
||||
for i = 1, num, 1 do
|
||||
table.insert(packages, {
|
||||
Name = message.ReadString(),
|
||||
Version = message.ReadString(),
|
||||
Id = message.ReadUInt64(),
|
||||
Hash = message.ReadString()
|
||||
})
|
||||
end
|
||||
|
||||
Hook.Call("client.packages", client, packages)
|
||||
end)
|
||||
elseif Game.IsMultiplayer then
|
||||
local message = Networking.Start("_luastart")
|
||||
|
||||
message.WriteUInt16(#allExecuted)
|
||||
|
||||
for key, package in pairs(allExecuted) do
|
||||
local id = package.UgcId
|
||||
local hash = package.Hash and package.Hash.StringRepresentation or ""
|
||||
|
||||
if id == nil then id = 0 end
|
||||
|
||||
message.WriteString(package.Name)
|
||||
message.WriteString(package.ModVersion)
|
||||
message.WriteUInt64(UInt64(id))
|
||||
message.WriteString(hash)
|
||||
end
|
||||
|
||||
Networking.Send(message)
|
||||
end
|
||||
|
||||
QueueAutorun.Process()
|
||||
QueueForcedAutorun.Process()
|
||||
|
||||
Hook.Add("stop", "luaSetup.stop", function()
|
||||
print("Stopping Lua...")
|
||||
end)
|
||||
|
||||
Hook.Call("loaded")
|
||||
@@ -1,13 +0,0 @@
|
||||
if not CSActive then
|
||||
LuaUserDataIUUD = LuaUserData.RegisterType("Barotrauma.LuaSafeUserData")
|
||||
LuaUserData = LuaUserData.CreateStatic("Barotrauma.LuaSafeUserData");
|
||||
|
||||
for k, v in pairs(debug) do
|
||||
if k ~= "getmetatable" and k ~= "setmetatable" and k ~= "traceback" then
|
||||
debug[k] = nil
|
||||
end
|
||||
end
|
||||
end
|
||||
|
||||
Descriptors = LuaUserData.__new()
|
||||
LuaUserDataIUUD = nil
|
||||
@@ -1,20 +1,23 @@
|
||||
<Project>
|
||||
<ItemGroup>
|
||||
<PackageReference Include="Luatrauma.Internal.AssemblyPublicizer.MSBuild" Version="0.1.4" />
|
||||
<PackageReference Include="Microsoft.CodeAnalysis.CSharp.Scripting" Version="4.1.0" />
|
||||
<PackageReference Include="MonoMod.RuntimeDetour" Version="25.2.3" />
|
||||
<PackageReference Include="HarmonyX" Version="2.14.0" />
|
||||
<PackageReference Include="Sigil" Version="5.0.0" />
|
||||
<ProjectReference Include="$(MSBuildThisFileDirectory)..\..\Libraries\moonsharp\MoonSharp.Interpreter\MoonSharp.Interpreter.csproj" />
|
||||
<ProjectReference Include="$(MSBuildThisFileDirectory)..\..\Libraries\moonsharp\MoonSharp.VsCodeDebugger\MoonSharp.VsCodeDebugger.csproj" />
|
||||
</ItemGroup>
|
||||
|
||||
<!--
|
||||
<ItemGroup>
|
||||
<PackageReference Include="Luatrauma.Internal.AssemblyPublicizer.MSBuild" Version="0.1.4" />
|
||||
<PackageReference Include="Microsoft.CodeAnalysis.CSharp" Version="4.11.0" />
|
||||
<PackageReference Include="HarmonyX" Version="2.16.0" />
|
||||
<PackageReference Include="Sigil" Version="5.0.0" />
|
||||
<PackageReference Include="LightInject" Version="6.6.4" />
|
||||
<PackageReference Include="OneOf" Version="3.0.271" />
|
||||
<PackageReference Include="FluentResults" Version="3.16.0" />
|
||||
<PackageReference Include="Basic.Reference.Assemblies.Net80" Version="1.8.4" />
|
||||
<PackageReference Include="Microsoft.Toolkit.Diagnostics" Version="7.1.2"/>
|
||||
<ProjectReference Include="$(MSBuildThisFileDirectory)..\..\Libraries\moonsharp\MoonSharp.Interpreter\MoonSharp.Interpreter.csproj" />
|
||||
<ProjectReference Include="$(MSBuildThisFileDirectory)..\..\Libraries\moonsharp\MoonSharp.VsCodeDebugger\MoonSharp.VsCodeDebugger.csproj" />
|
||||
</ItemGroup>
|
||||
<!--
|
||||
The `Microsoft.CodeAnalysis.CSharp.Scripting` package includes satellites
|
||||
assemblies, which end up polluting the build folder.
|
||||
This suppresses the extra satellite assemblies.
|
||||
-->
|
||||
<PropertyGroup>
|
||||
<SatelliteResourceLanguages>en</SatelliteResourceLanguages>
|
||||
</PropertyGroup>
|
||||
-->
|
||||
<PropertyGroup>
|
||||
<SatelliteResourceLanguages>en</SatelliteResourceLanguages>
|
||||
</PropertyGroup>
|
||||
</Project>
|
||||
|
||||
@@ -0,0 +1,30 @@
|
||||
<Project>
|
||||
<Target Name="CopyPublicizedFilesOnBuild" AfterTargets="Build">
|
||||
<Copy
|
||||
SourceFiles="$(TargetDir)\Publicized\BarotraumaCore.dll"
|
||||
DestinationFiles="$(TargetDir)\LocalMods\LuaCsForBarotrauma\Publicized\BarotraumaCore.dll"
|
||||
/>
|
||||
<Copy Condition="$(DefineConstants.Contains('CLIENT'))"
|
||||
SourceFiles="$(TargetDir)\Publicized\Barotrauma.dll"
|
||||
DestinationFiles="$(TargetDir)\LocalMods\LuaCsForBarotrauma\Publicized\Barotrauma.dll"
|
||||
/>
|
||||
<Copy Condition="$(DefineConstants.Contains('SERVER'))"
|
||||
SourceFiles="$(TargetDir)\Publicized\DedicatedServer.dll"
|
||||
DestinationFiles="$(TargetDir)\LocalMods\LuaCsForBarotrauma\Publicized\DedicatedServer.dll"
|
||||
/>
|
||||
</Target>
|
||||
<Target Name="CopyPublicizedFilesOnPublish" AfterTargets="Publish">
|
||||
<Copy
|
||||
SourceFiles="$(PublishDir)\Publicized\BarotraumaCore.dll"
|
||||
DestinationFiles="$(PublishDir)\LocalMods\LuaCsForBarotrauma\Publicized\BarotraumaCore.dll"
|
||||
/>
|
||||
<Copy Condition="$(DefineConstants.Contains('CLIENT'))"
|
||||
SourceFiles="$(PublishDir)\Publicized\Barotrauma.dll"
|
||||
DestinationFiles="$(PublishDir)\LocalMods\LuaCsForBarotrauma\Publicized\Barotrauma.dll"
|
||||
/>
|
||||
<Copy Condition="$(DefineConstants.Contains('SERVER'))"
|
||||
SourceFiles="$(PublishDir)\Publicized\DedicatedServer.dll"
|
||||
DestinationFiles="$(PublishDir)\LocalMods\LuaCsForBarotrauma\Publicized\DedicatedServer.dll"
|
||||
/>
|
||||
</Target>
|
||||
</Project>
|
||||
@@ -1,38 +0,0 @@
|
||||
BAROTRAUMA
|
||||
|
||||
http://www.barotraumagame.com
|
||||
|
||||
© 2017-2024 FakeFish Ltd. All rights reserved.
|
||||
© 2019-2024 Daedalic Entertainment GmbH. The Daedalic logo is a trademark of Daedalic Entertainment GmbH, Germany. All rights reserved.
|
||||
Privacy policy: http://privacypolicy.daedalic.com
|
||||
|
||||
See the wiki for more detailed info and instructions:
|
||||
http://barotraumagame.com/wiki
|
||||
|
||||
------------------------------------------------------------------------
|
||||
|
||||
Port forwarding:
|
||||
You may try to forward ports on your router using UPnP (Universal Plug and
|
||||
Play) port forwarding by selecting "Attempt UPnP port forwarding" in the
|
||||
"Host Server" menu.
|
||||
|
||||
However, UPnP isn't supported by all routers, so you may need to setup port
|
||||
forwards manually. The exact steps for forwarding a port depend on your
|
||||
router's model, but you may be able to find a port forwarding guide for
|
||||
your particular router/application on portforward.com or by practicing
|
||||
your google-fu skills.
|
||||
|
||||
These are the values that you should use when forwarding a port to your
|
||||
Barotrauma server:
|
||||
|
||||
Game port (used to communicate with clients)
|
||||
Service/Application: barotrauma
|
||||
External Port: The port you have selected for your server (27015 by default)
|
||||
Internal Port: The port you have selected for your server (27015 by default)
|
||||
Protocol: UDP
|
||||
|
||||
Query port (used to communicate with Steam)
|
||||
Service/Application: barotrauma
|
||||
External Port: The port you have selected for your server (27016 by default)
|
||||
Internal Port: The port you have selected for your server (27016 by default)
|
||||
Protocol: UDP
|
||||
@@ -551,9 +551,14 @@ namespace Barotrauma
|
||||
|
||||
private static void UnlockKillAchievement(Character killer, Character target, Identifier identifier)
|
||||
{
|
||||
if (killer != null &&
|
||||
target.Params.UnlockKillAchievementForWholeCrew &&
|
||||
GameSession.GetSessionCrewCharacters(CharacterType.Player).Contains(killer))
|
||||
bool alwaysUnlockForWholeCrew = false;
|
||||
#if CLIENT
|
||||
alwaysUnlockForWholeCrew = GameMain.GameSession?.Campaign is SinglePlayerCampaign;
|
||||
#endif
|
||||
|
||||
if (killer != null &&
|
||||
(alwaysUnlockForWholeCrew || target.Params.UnlockKillAchievementForWholeCrew) &&
|
||||
GameSession.GetSessionCrewCharacters(CharacterType.Both).Contains(killer))
|
||||
{
|
||||
UnlockAchievement(identifier, unlockClients: true, characterConditions: c => c != null);
|
||||
}
|
||||
|
||||
@@ -49,6 +49,13 @@ namespace Barotrauma
|
||||
}
|
||||
}
|
||||
|
||||
|
||||
/// <summary>
|
||||
/// A multiplier for the sound range for the purposes of displaying the target on sonar.
|
||||
/// E.g. a value of 10 would mean the sonar can detect the target from x10 further than monsters.
|
||||
/// </summary>
|
||||
public float SoundRangeOnSonarMultiplier { get; private set; } = 1.0f;
|
||||
|
||||
public float SightRange
|
||||
{
|
||||
get { return sightRange; }
|
||||
@@ -206,6 +213,7 @@ namespace Barotrauma
|
||||
MinSoundRange = element.GetAttributeFloat("minsoundrange", 0f);
|
||||
MaxSightRange = element.GetAttributeFloat("maxsightrange", SightRange);
|
||||
MaxSoundRange = element.GetAttributeFloat("maxsoundrange", SoundRange);
|
||||
SoundRangeOnSonarMultiplier = element.GetAttributeFloat(nameof(SoundRangeOnSonarMultiplier), 1.0f);
|
||||
FadeOutTime = element.GetAttributeFloat("fadeouttime", FadeOutTime);
|
||||
Static = element.GetAttributeBool("static", Static);
|
||||
StaticSight = element.GetAttributeBool("staticsight", StaticSight);
|
||||
|
||||
@@ -242,16 +242,44 @@ namespace Barotrauma
|
||||
}
|
||||
|
||||
/// <summary>
|
||||
/// The monster won't try to damage these submarines
|
||||
/// The monster won't try to damage these submarines. Applies to hulls, structures and static items (items without a physics body) belonging to these submarines. Does not apply to non-static items, e.g. flares or other provocative items.
|
||||
/// </summary>
|
||||
public HashSet<Submarine> UnattackableSubmarines
|
||||
private readonly HashSet<Submarine> unattackableSubmarines = [];
|
||||
|
||||
/// <summary>
|
||||
/// Set the submarine(s) the monster won't attack. Applies to hulls, structures and static items (items without a physics body) belonging to these submarines. Does not apply to non-static items, e.g. flares or other provocative items.
|
||||
/// </summary>
|
||||
public void SetUnattackableSubmarines(Submarine submarine, bool includeOwnSub = true, bool includeConnectedSubs = true, bool clearExisting = true)
|
||||
{
|
||||
get;
|
||||
private set;
|
||||
} = new HashSet<Submarine>();
|
||||
if (clearExisting)
|
||||
{
|
||||
unattackableSubmarines.Clear();
|
||||
}
|
||||
if (submarine != null)
|
||||
{
|
||||
AddSubs(submarine);
|
||||
}
|
||||
if (includeOwnSub && Character.Submarine is Submarine ownSub && ownSub != submarine)
|
||||
{
|
||||
AddSubs(ownSub);
|
||||
}
|
||||
|
||||
void AddSubs(Submarine sub)
|
||||
{
|
||||
unattackableSubmarines.Add(sub);
|
||||
if (includeConnectedSubs)
|
||||
{
|
||||
foreach (Submarine connectedSub in sub.DockedTo)
|
||||
{
|
||||
unattackableSubmarines.Add(connectedSub);
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
public static bool IsTargetBeingChasedBy(Character target, Character character)
|
||||
=> character?.AIController is EnemyAIController enemyAI && enemyAI.SelectedAiTarget?.Entity == target && enemyAI.State is AIState.Attack or AIState.Aggressive;
|
||||
|
||||
public bool IsBeingChasedBy(Character c) => IsTargetBeingChasedBy(Character, c);
|
||||
private bool IsBeingChased => IsBeingChasedBy(SelectedAiTarget?.Entity as Character);
|
||||
|
||||
@@ -539,26 +567,7 @@ namespace Barotrauma
|
||||
//doesn't do anything usually, but events may sometimes change monsters' (or pets' that use enemy AI) teams
|
||||
Character.UpdateTeam();
|
||||
|
||||
bool ignorePlatforms = Character.AnimController.TargetMovement.Y < -0.5f && (-Character.AnimController.TargetMovement.Y > Math.Abs(Character.AnimController.TargetMovement.X));
|
||||
if (steeringManager == insideSteering)
|
||||
{
|
||||
var currPath = PathSteering.CurrentPath;
|
||||
if (currPath != null && currPath.CurrentNode != null)
|
||||
{
|
||||
if (currPath.CurrentNode.SimPosition.Y < Character.AnimController.GetColliderBottom().Y)
|
||||
{
|
||||
// Don't allow to jump from too high.
|
||||
float allowedJumpHeight = Character.AnimController.ImpactTolerance / 2;
|
||||
float height = Math.Abs(currPath.CurrentNode.SimPosition.Y - Character.SimPosition.Y);
|
||||
ignorePlatforms = height < allowedJumpHeight;
|
||||
}
|
||||
}
|
||||
if (Character.IsClimbing && PathSteering.IsNextLadderSameAsCurrent)
|
||||
{
|
||||
Character.AnimController.TargetMovement = new Vector2(0.0f, Math.Sign(Character.AnimController.TargetMovement.Y));
|
||||
}
|
||||
}
|
||||
Character.AnimController.IgnorePlatforms = ignorePlatforms;
|
||||
HandleLaddersAndPlatforms(deltaTime);
|
||||
|
||||
if (Math.Abs(Character.AnimController.movement.X) > 0.1f && !Character.AnimController.InWater &&
|
||||
(GameMain.NetworkMember == null || GameMain.NetworkMember.IsServer || Character.Controlled == Character))
|
||||
@@ -986,6 +995,69 @@ namespace Barotrauma
|
||||
}
|
||||
}
|
||||
|
||||
//how often the character can try ragdolling to drop down
|
||||
private const float MaxDroppingInterval = 5.0f;
|
||||
|
||||
//last time the character tried ragdolling to drop down
|
||||
private double lastDroppingTime;
|
||||
|
||||
//how long the character can stay ragdolled to drop down
|
||||
private const float MaxDroppingTime = 1.0f;
|
||||
|
||||
//timer for the duration of the ragdolling
|
||||
private float droppingTimer;
|
||||
|
||||
private void HandleLaddersAndPlatforms(float deltaTime)
|
||||
{
|
||||
bool ignorePlatforms = Character.AnimController.TargetMovement.Y < -0.5f && (-Character.AnimController.TargetMovement.Y > Math.Abs(Character.AnimController.TargetMovement.X));
|
||||
if (steeringManager == insideSteering)
|
||||
{
|
||||
var currPath = PathSteering.CurrentPath;
|
||||
if (currPath is { CurrentNode: WayPoint currentNode })
|
||||
{
|
||||
Vector2 colliderBottom = Character.AnimController.GetColliderBottom();
|
||||
if (Character.Submarine != currentNode.Submarine)
|
||||
{
|
||||
colliderBottom = Submarine.GetRelativeSimPosition(colliderBottom, currentNode.Submarine, Character.Submarine);
|
||||
}
|
||||
if (currentNode.SimPosition.Y < colliderBottom.Y)
|
||||
{
|
||||
// Don't allow to jump from too high.
|
||||
float allowedJumpHeight = Character.AnimController.ImpactTolerance / 2;
|
||||
Vector2 diff = currentNode.WorldPosition - Character.WorldPosition;
|
||||
float height = ConvertUnits.ToSimUnits(Math.Abs(diff.Y));
|
||||
ignorePlatforms = height < allowedJumpHeight;
|
||||
|
||||
//trying to head down ladders, but can't climb -> periodically try ragdolling to get down
|
||||
//(may be required by large monsters like mudraptors to fit through hatches)
|
||||
if (ignorePlatforms && !Character.CanClimb && PathSteering.IsCurrentNodeLadder &&
|
||||
ConvertUnits.ToSimUnits(Math.Abs(diff.X)) < Character.AnimController.Collider.GetMaxExtent())
|
||||
{
|
||||
if (lastDroppingTime < Timing.TotalTime - MaxDroppingInterval)
|
||||
{
|
||||
Character.IsRagdolled = true;
|
||||
Character.SetInput(InputType.Ragdoll, hit: false, held: true);
|
||||
droppingTimer += deltaTime;
|
||||
if (droppingTimer > MaxDroppingTime)
|
||||
{
|
||||
lastDroppingTime = Timing.TotalTime;
|
||||
}
|
||||
}
|
||||
else
|
||||
{
|
||||
droppingTimer = 0.0f;
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
if (Character.IsClimbing && PathSteering.IsNextLadderSameAsCurrent)
|
||||
{
|
||||
Character.AnimController.TargetMovement = new Vector2(0.0f, Math.Sign(Character.AnimController.TargetMovement.Y));
|
||||
}
|
||||
}
|
||||
Character.AnimController.IgnorePlatforms = ignorePlatforms;
|
||||
}
|
||||
|
||||
#region Idle
|
||||
|
||||
private void UpdateIdle(float deltaTime, bool followLastTarget = true)
|
||||
@@ -1229,6 +1301,8 @@ namespace Barotrauma
|
||||
return;
|
||||
}
|
||||
|
||||
if (Character.IsAttachedToController()) { return; }
|
||||
|
||||
attackWorldPos = SelectedAiTarget.WorldPosition;
|
||||
attackSimPos = SelectedAiTarget.SimPosition;
|
||||
|
||||
@@ -1751,6 +1825,7 @@ namespace Barotrauma
|
||||
{
|
||||
SelectTarget(door.Item.AiTarget, currentTargetMemory.Priority);
|
||||
State = AIState.Attack;
|
||||
AttackLimb = null;
|
||||
return;
|
||||
}
|
||||
}
|
||||
@@ -1761,12 +1836,20 @@ namespace Barotrauma
|
||||
float margin = AttackLimb != null ? Math.Min(AttackLimb.attack.Range * 0.9f, max) : max;
|
||||
if ((!canAttack || distance > margin) && !IsTryingToSteerThroughGap)
|
||||
{
|
||||
bool useManualSteering = false;
|
||||
// Steer towards the target if in the same room and swimming
|
||||
// Ruins have walls/pillars inside hulls and therefore we should navigate around them using the path steering.
|
||||
if (Character.CurrentHull != null &&
|
||||
Character.Submarine != null && !Character.Submarine.Info.IsRuin &&
|
||||
(Character.AnimController.InWater || pursue || !Character.AnimController.CanWalk) &&
|
||||
targetCharacter != null && VisibleHulls.Contains(targetCharacter.CurrentHull))
|
||||
{
|
||||
if (CanSeeTarget(targetCharacter))
|
||||
{
|
||||
useManualSteering = true;
|
||||
}
|
||||
}
|
||||
if (useManualSteering)
|
||||
{
|
||||
Vector2 myPos = Character.AnimController.SimplePhysicsEnabled ? Character.SimPosition : steeringLimb.SimPosition;
|
||||
SteeringManager.SteeringManual(deltaTime, Vector2.Normalize(attackSimPos - myPos));
|
||||
@@ -2311,18 +2394,49 @@ namespace Barotrauma
|
||||
{
|
||||
float prio = 1 + limb.attack.Priority;
|
||||
if (Character.AnimController.SimplePhysicsEnabled) { return prio; }
|
||||
float dist = Vector2.Distance(limb.WorldPosition, attackPos);
|
||||
float distanceFactor = 1;
|
||||
float distance = Vector2.Distance(limb.WorldPosition, attackPos);
|
||||
float maxDistance = Math.Max(limb.attack.Range * 3, 1000);
|
||||
if (distance > maxDistance)
|
||||
{
|
||||
// Far enough to ignore the attack.
|
||||
return 0;
|
||||
}
|
||||
// Not in range, but relatively close. Let's use the distance factor as a multiplier.
|
||||
float distanceFactor;
|
||||
if (limb.attack.Ranged)
|
||||
{
|
||||
float min = 100;
|
||||
distanceFactor = MathHelper.Lerp(1, 0, MathUtils.InverseLerp(min, Math.Max(limb.attack.Range / 2, min), dist));
|
||||
if (distance < min)
|
||||
{
|
||||
// Too close -> smoothly but steeply reduce the preference (and prefer other attacks, like melee instead)
|
||||
float t = MathUtils.InverseLerp(0, min, distance);
|
||||
distanceFactor = MathHelper.Lerp(0.01f, 1, t * t);
|
||||
}
|
||||
else
|
||||
{
|
||||
distanceFactor = MathHelper.Lerp(1, 0, MathUtils.InverseLerp(min, maxDistance, distance));
|
||||
}
|
||||
}
|
||||
else
|
||||
{
|
||||
// The limb is ignored if the target is not close. Prevents character going in reverse if very far away from it.
|
||||
// We also need a max value that is more than the actual range.
|
||||
distanceFactor = MathHelper.Lerp(1, 0, MathUtils.InverseLerp(0, limb.attack.Range * 3, dist));
|
||||
if (distance <= limb.attack.Range)
|
||||
{
|
||||
// In range.
|
||||
if (!Character.InWater)
|
||||
{
|
||||
// On dry land vertical distance works a bit differently, as we can't necessarily reach the target above/below us.
|
||||
float verticalDistance = Math.Abs(limb.WorldPosition.Y - attackPos.Y);
|
||||
if (verticalDistance > limb.attack.DamageRange)
|
||||
{
|
||||
// Most likely can't reach.
|
||||
return 0;
|
||||
}
|
||||
}
|
||||
// Highly prefer attacks which we can use to hit immediately.
|
||||
return prio * 10;
|
||||
}
|
||||
float min = limb.attack.Range;
|
||||
distanceFactor = MathHelper.Lerp(1, 0, MathUtils.InverseLerp(min, maxDistance, distance));
|
||||
}
|
||||
return prio * distanceFactor;
|
||||
}
|
||||
@@ -2521,6 +2635,7 @@ namespace Barotrauma
|
||||
{
|
||||
SelectTarget(aiTarget, GetTargetMemory(SelectedAiTarget, addIfNotFound: true).Priority);
|
||||
State = AIState.Attack;
|
||||
AttackLimb = null;
|
||||
return true;
|
||||
}
|
||||
}
|
||||
@@ -2555,14 +2670,10 @@ namespace Barotrauma
|
||||
return true;
|
||||
}
|
||||
}
|
||||
if (damageTarget != null)
|
||||
{
|
||||
Character.SetInput(item.IsShootable ? InputType.Shoot : InputType.Use, false, true);
|
||||
item.Use(deltaTime, user: Character);
|
||||
}
|
||||
Character.SetInput(item.IsShootable ? InputType.Shoot : InputType.Use, false, true);
|
||||
item.Use(deltaTime, user: Character);
|
||||
}
|
||||
}
|
||||
if (damageTarget == null) { return true; }
|
||||
//simulate attack input to get the character to attack client-side
|
||||
Character.SetInput(InputType.Attack, true, true);
|
||||
if (!ActiveAttack.IsRunning)
|
||||
@@ -2609,10 +2720,24 @@ namespace Barotrauma
|
||||
}
|
||||
return true;
|
||||
}
|
||||
|
||||
private const float VisibilityCheckStep = 0.2f;
|
||||
private double lastVisibilityCheckTime;
|
||||
private bool canSeeTarget;
|
||||
/// <summary>
|
||||
/// This method uses <see cref="Character.CanSeeTarget"/> and caches the results.
|
||||
/// </summary>
|
||||
private bool CanSeeTarget(ISpatialEntity target)
|
||||
{
|
||||
if (Timing.TotalTime > lastVisibilityCheckTime + VisibilityCheckStep)
|
||||
{
|
||||
canSeeTarget = Character.CanSeeTarget(target);
|
||||
lastVisibilityCheckTime = Timing.TotalTime;
|
||||
}
|
||||
return canSeeTarget;
|
||||
}
|
||||
|
||||
private float aimTimer;
|
||||
private float visibilityCheckTimer;
|
||||
private bool canSeeTarget;
|
||||
private float sinTime;
|
||||
private bool Aim(float deltaTime, ISpatialEntity target, Item weapon)
|
||||
{
|
||||
@@ -2630,13 +2755,7 @@ namespace Barotrauma
|
||||
{
|
||||
Character.CursorPosition -= Character.Submarine.Position;
|
||||
}
|
||||
visibilityCheckTimer -= deltaTime;
|
||||
if (visibilityCheckTimer <= 0.0f)
|
||||
{
|
||||
canSeeTarget = Character.CanSeeTarget(target);
|
||||
visibilityCheckTimer = 0.2f;
|
||||
}
|
||||
if (!canSeeTarget)
|
||||
if (!CanSeeTarget(target))
|
||||
{
|
||||
SetAimTimer();
|
||||
return false;
|
||||
@@ -2817,7 +2936,10 @@ namespace Barotrauma
|
||||
}
|
||||
}
|
||||
steeringManager.SteeringManual(deltaTime, Vector2.Normalize(limbDiff) * 3);
|
||||
Character.AnimController.Collider.ApplyForce(limbDiff * mouthLimb.Mass * 50.0f, mouthPos);
|
||||
if (Character.AnimController.OnGround || Character.InWater)
|
||||
{
|
||||
Character.AnimController.Collider.ApplyForce(limbDiff * mouthLimb.Mass * 50.0f, maxVelocity: 10.0f);
|
||||
}
|
||||
}
|
||||
}
|
||||
else
|
||||
@@ -2956,12 +3078,18 @@ namespace Barotrauma
|
||||
}
|
||||
else
|
||||
{
|
||||
// Ignore all structures, items, and hulls inside these subs.
|
||||
if (aiTarget.Entity.Submarine != null)
|
||||
if (aiTarget.Entity.Submarine != null)
|
||||
{
|
||||
//ignore all items, structures and hulls in wrecks and beacon stations
|
||||
//(we don't want monsters to be distracted by them during missions,
|
||||
//nor have monsters inside them attack "their home" rather than the player)
|
||||
if (aiTarget.Entity.Submarine.Info.IsWreck ||
|
||||
aiTarget.Entity.Submarine.Info.IsBeacon ||
|
||||
UnattackableSubmarines.Contains(aiTarget.Entity.Submarine))
|
||||
aiTarget.Entity.Submarine.Info.IsBeacon)
|
||||
{
|
||||
continue;
|
||||
}
|
||||
if (aiTarget.Entity is Structure or Hull or Item { body: null } &&
|
||||
unattackableSubmarines.Contains(aiTarget.Entity.Submarine))
|
||||
{
|
||||
continue;
|
||||
}
|
||||
@@ -3509,13 +3637,16 @@ namespace Barotrauma
|
||||
{
|
||||
if (targetCharacter.Submarine != null)
|
||||
{
|
||||
// Target is inside -> reduce the priority
|
||||
valueModifier *= 0.5f;
|
||||
if (Character.Submarine != null)
|
||||
if (Character.Submarine != null && !targetCharacter.Submarine.IsConnectedTo(Character.Submarine))
|
||||
{
|
||||
// Both inside different submarines -> can ignore safely
|
||||
// Both inside different, unconnected submarines -> can ignore safely
|
||||
continue;
|
||||
}
|
||||
else
|
||||
{
|
||||
// Target is inside a submarine that we are not -> reduce the priority
|
||||
valueModifier *= 0.5f;
|
||||
}
|
||||
}
|
||||
else if (Character.CurrentHull != null)
|
||||
{
|
||||
@@ -4402,6 +4533,7 @@ namespace Barotrauma
|
||||
{
|
||||
SelectTarget(doorAiTarget, CurrentTargetMemory.Priority);
|
||||
State = AIState.Attack;
|
||||
AttackLimb = null;
|
||||
return false;
|
||||
}
|
||||
}
|
||||
|
||||
@@ -1380,7 +1380,7 @@ namespace Barotrauma
|
||||
}
|
||||
else
|
||||
{
|
||||
isAttackerInfected = attacker.CharacterHealth.GetAfflictionStrengthByType(AfflictionPrefab.AlienInfectedType) > 0;
|
||||
isAttackerInfected = attacker.CharacterHealth.GetAfflictionStrengthByType(AfflictionPrefab.AlienInfectionType) > 0;
|
||||
// Inform other NPCs
|
||||
if (isAttackerInfected || cumulativeDamage > minorDamageThreshold || totalDamage > minorDamageThreshold)
|
||||
{
|
||||
|
||||
@@ -4,6 +4,7 @@ using Microsoft.Xna.Framework;
|
||||
using System;
|
||||
using System.Linq;
|
||||
using FarseerPhysics;
|
||||
using System.Diagnostics;
|
||||
|
||||
namespace Barotrauma
|
||||
{
|
||||
@@ -50,7 +51,7 @@ namespace Barotrauma
|
||||
}
|
||||
|
||||
/// <summary>
|
||||
/// Returns true if any node in the path is in stairs
|
||||
/// Returns true if any node in the path is on stairs
|
||||
/// </summary>
|
||||
public bool PathHasStairs => currentPath != null && currentPath.Nodes.Any(n => n.Stairs != null);
|
||||
|
||||
@@ -285,14 +286,17 @@ namespace Barotrauma
|
||||
}
|
||||
}
|
||||
|
||||
Vector2 diff = DiffToCurrentNode();
|
||||
Vector2 diff = GetDiffAndAdvance();
|
||||
if (diff == Vector2.Zero) { return Vector2.Zero; }
|
||||
return Vector2.Normalize(diff) * weight;
|
||||
}
|
||||
|
||||
protected override Vector2 DoSteeringSeek(Vector2 target, float weight) => CalculateSteeringSeek(target, weight);
|
||||
|
||||
private Vector2 DiffToCurrentNode()
|
||||
|
||||
/// <summary>
|
||||
/// Decides whether and when we should skip to the next node. Returns the difference to the current node (after skipping).
|
||||
/// </summary>
|
||||
private Vector2 GetDiffAndAdvance()
|
||||
{
|
||||
if (currentPath == null || currentPath.Unreachable)
|
||||
{
|
||||
@@ -320,26 +324,37 @@ namespace Barotrauma
|
||||
Reset();
|
||||
return Vector2.Zero;
|
||||
}
|
||||
Vector2 pos = host.WorldPosition;
|
||||
Vector2 diff = currentPath.CurrentNode.WorldPosition - pos;
|
||||
WayPoint currentNode = currentPath.CurrentNode;
|
||||
WayPoint nextNode = currentPath.NextNode;
|
||||
Vector2 diff = currentNode.WorldPosition - host.WorldPosition;
|
||||
float horizontalDistance = Math.Abs(diff.X);
|
||||
float verticalDistance = Math.Abs(diff.Y);
|
||||
bool isDiving = character.AnimController.InWater && character.AnimController.HeadInWater;
|
||||
bool canClimb = character.CanClimb;
|
||||
Ladder currentLadder = GetCurrentLadder();
|
||||
Ladder nextLadder = GetNextLadder();
|
||||
var ladders = currentLadder ?? nextLadder;
|
||||
Ladder ladders = currentLadder ?? nextLadder;
|
||||
bool useLadders = canClimb && ladders != null;
|
||||
var collider = character.AnimController.Collider;
|
||||
Vector2 colliderSize = collider.GetSize();
|
||||
Vector2 colliderSize = ConvertUnits.ToDisplayUnits(collider.GetSize());
|
||||
float colliderHeight = colliderSize.Y;
|
||||
if (character.AnimController.CurrentAnimationParams is FishGroundedParams fishGrounded)
|
||||
{
|
||||
// On monsters, the main collider might be rotated, so we need to take that into account here.
|
||||
float standAngle = fishGrounded.ColliderStandAngleInRadians * character.AnimController.Dir;
|
||||
Vector2 transformedColliderSize = PhysicsBody.RotateVector(colliderSize, standAngle);
|
||||
colliderHeight = Math.Abs(transformedColliderSize.Y);
|
||||
}
|
||||
if (useLadders)
|
||||
{
|
||||
if (character.IsClimbing && Math.Abs(diff.X) - ConvertUnits.ToDisplayUnits(colliderSize.X) > Math.Abs(diff.Y))
|
||||
if (character.IsClimbing && Math.Abs(diff.X) - colliderSize.X > Math.Abs(diff.Y))
|
||||
{
|
||||
// If the current node is horizontally farther from us than vertically, we don't want to keep climbing the ladders.
|
||||
useLadders = false;
|
||||
}
|
||||
else if (!character.IsClimbing && currentPath.NextNode != null && nextLadder == null)
|
||||
else if (!character.IsClimbing && nextNode != null && nextLadder == null)
|
||||
{
|
||||
Vector2 diffToNextNode = currentPath.NextNode.WorldPosition - pos;
|
||||
Vector2 diffToNextNode = nextNode.WorldPosition - host.WorldPosition;
|
||||
if (Math.Abs(diffToNextNode.X) > Math.Abs(diffToNextNode.Y))
|
||||
{
|
||||
// If the next node is horizontally farther from us than vertically, we don't want to start climbing.
|
||||
@@ -356,7 +371,7 @@ namespace Barotrauma
|
||||
{
|
||||
if (currentPath.IsAtEndNode && canClimb && ladders != null)
|
||||
{
|
||||
// Don't release the ladders when ending a path in ladders.
|
||||
// Don't release the ladders when ending a path on ladders.
|
||||
useLadders = true;
|
||||
}
|
||||
else
|
||||
@@ -388,20 +403,18 @@ namespace Barotrauma
|
||||
if (currentLadder == null && nextLadder != null && character.SelectedSecondaryItem == nextLadder.Item)
|
||||
{
|
||||
// Climbing a ladder but the path is still on the node next to the ladder -> Skip the node.
|
||||
NextNode(!doorsChecked);
|
||||
return NextNode(!doorsChecked);
|
||||
}
|
||||
else
|
||||
{
|
||||
bool nextLadderSameAsCurrent = currentLadder == nextLadder;
|
||||
float colliderHeight = collider.Height / 2 + collider.Radius;
|
||||
float heightDiff = currentPath.CurrentNode.SimPosition.Y - collider.SimPosition.Y;
|
||||
float distanceMargin = ConvertUnits.ToDisplayUnits(colliderSize.X);
|
||||
float distanceMargin = colliderSize.X;
|
||||
if (currentLadder != null && nextLadder != null)
|
||||
{
|
||||
//climbing ladders -> don't move horizontally
|
||||
diff.X = 0.0f;
|
||||
}
|
||||
if (Math.Abs(heightDiff) < colliderHeight * 1.25f)
|
||||
if (verticalDistance < colliderHeight / 2 * 1.25f)
|
||||
{
|
||||
if (nextLadder != null && !nextLadderSameAsCurrent)
|
||||
{
|
||||
@@ -410,7 +423,7 @@ namespace Barotrauma
|
||||
{
|
||||
if (nextLadder.Item.TryInteract(character, forceSelectKey: true))
|
||||
{
|
||||
NextNode(!doorsChecked);
|
||||
return NextNode(!doorsChecked);
|
||||
}
|
||||
}
|
||||
}
|
||||
@@ -432,9 +445,9 @@ namespace Barotrauma
|
||||
}
|
||||
if (isAboveFloor)
|
||||
{
|
||||
if (Math.Abs(diff.Y) < distanceMargin)
|
||||
if (verticalDistance < distanceMargin)
|
||||
{
|
||||
NextNode(!doorsChecked);
|
||||
return NextNode(!doorsChecked);
|
||||
}
|
||||
else if (!currentPath.IsAtEndNode && (nextLadder == null || (currentLadder != null && Math.Abs(currentLadder.Item.WorldPosition.X - nextLadder.Item.WorldPosition.X) > distanceMargin)))
|
||||
{
|
||||
@@ -443,14 +456,21 @@ namespace Barotrauma
|
||||
}
|
||||
}
|
||||
}
|
||||
else if (currentLadder != null && currentPath.NextNode != null)
|
||||
else if (currentLadder != null && nextNode != null)
|
||||
{
|
||||
if (Math.Sign(currentPath.CurrentNode.WorldPosition.Y - character.WorldPosition.Y) != Math.Sign(currentPath.NextNode.WorldPosition.Y - character.WorldPosition.Y))
|
||||
if (Math.Sign(currentNode.WorldPosition.Y - character.WorldPosition.Y) != Math.Sign(nextNode.WorldPosition.Y - character.WorldPosition.Y))
|
||||
{
|
||||
//if the current node is below the character and the next one is above (or vice versa)
|
||||
//and both are on ladders, we can skip directly to the next one
|
||||
//e.g. no point in going down to reach the starting point of a path when we could go directly to the one above
|
||||
NextNode(!doorsChecked);
|
||||
return NextNode(!doorsChecked);
|
||||
}
|
||||
//heading towards a ladder waypoint below the character, but the next waypoint is above it on the same ladder
|
||||
// -> allow skipping to that waypoint.
|
||||
// Otherwise the character may get stuck trying to move to a waypoint near the floor at the bottom of the ladder, failing to get close enough because they can't move any lower.
|
||||
else if (nextLadderSameAsCurrent && diff.Y < 0 && nextNode.WorldPosition.Y > currentNode.WorldPosition.Y)
|
||||
{
|
||||
return NextNode(!doorsChecked);
|
||||
}
|
||||
}
|
||||
}
|
||||
@@ -458,21 +478,20 @@ namespace Barotrauma
|
||||
else if (character.AnimController.InWater)
|
||||
{
|
||||
// Swimming
|
||||
var door = currentPath.CurrentNode.ConnectedDoor;
|
||||
var door = currentNode.ConnectedDoor;
|
||||
if (door == null || door.CanBeTraversed)
|
||||
{
|
||||
float margin = MathHelper.Lerp(1, 5, MathHelper.Clamp(collider.LinearVelocity.Length() / 10, 0, 1));
|
||||
float targetDistance = Math.Max(Math.Max(colliderSize.X, colliderSize.Y) / 2 * margin, 0.5f);
|
||||
float horizontalDistance = Math.Abs(character.WorldPosition.X - currentPath.CurrentNode.WorldPosition.X);
|
||||
float verticalDistance = Math.Abs(character.WorldPosition.Y - currentPath.CurrentNode.WorldPosition.Y);
|
||||
if (character.CurrentHull != currentPath.CurrentNode.CurrentHull)
|
||||
float distanceMultiplier = MathHelper.Lerp(1, 5, MathHelper.Clamp(collider.LinearVelocity.Length() / 10, 0, 1));
|
||||
float targetDistance = Math.Max(Math.Max(colliderSize.X, colliderSize.Y) / 2 * distanceMultiplier, 0.5f);
|
||||
float modifiedVerticalDist = verticalDistance;
|
||||
if (character.CurrentHull != currentNode.CurrentHull)
|
||||
{
|
||||
verticalDistance *= 2;
|
||||
modifiedVerticalDist *= 2;
|
||||
}
|
||||
float distance = horizontalDistance + verticalDistance;
|
||||
if (ConvertUnits.ToSimUnits(distance) < targetDistance)
|
||||
float distance = horizontalDistance + modifiedVerticalDist;
|
||||
if (distance < targetDistance)
|
||||
{
|
||||
NextNode(!doorsChecked);
|
||||
return NextNode(!doorsChecked);
|
||||
}
|
||||
}
|
||||
}
|
||||
@@ -480,6 +499,10 @@ namespace Barotrauma
|
||||
{
|
||||
// Walking horizontally
|
||||
Vector2 colliderBottom = character.AnimController.GetColliderBottom();
|
||||
if (character.Submarine != currentNode.Submarine)
|
||||
{
|
||||
colliderBottom = Submarine.GetRelativeSimPosition(colliderBottom, currentNode.Submarine, character.Submarine);
|
||||
}
|
||||
Vector2 velocity = collider.LinearVelocity;
|
||||
// If the character is very short, it would fail to use the waypoint nodes because they are always too high.
|
||||
// If the character is very thin, it would often fail to reach the waypoints, because the horizontal distance is too small.
|
||||
@@ -487,60 +510,113 @@ namespace Barotrauma
|
||||
float minHeight = 1.6125001f;
|
||||
float minWidth = 0.3225f;
|
||||
// Cannot use the head position, because not all characters have head or it can be below the total height of the character
|
||||
float characterHeight = Math.Max(colliderSize.Y + character.AnimController.ColliderHeightFromFloor, minHeight);
|
||||
float horizontalDistance = Math.Abs(collider.SimPosition.X - currentPath.CurrentNode.SimPosition.X);
|
||||
bool isTargetTooHigh = currentPath.CurrentNode.SimPosition.Y > colliderBottom.Y + characterHeight;
|
||||
bool isTargetTooLow = currentPath.CurrentNode.SimPosition.Y < colliderBottom.Y;
|
||||
var door = currentPath.CurrentNode.ConnectedDoor;
|
||||
float margin = MathHelper.Lerp(1, 10, MathHelper.Clamp(Math.Abs(velocity.X) / 5, 0, 1));
|
||||
float colliderHeight = collider.Height / 2 + collider.Radius;
|
||||
if (currentPath.CurrentNode.Stairs == null)
|
||||
float characterHeight = Math.Max(ConvertUnits.ToSimUnits(colliderHeight) + character.AnimController.ColliderHeightFromFloor, minHeight);
|
||||
bool isTargetTooHigh = currentNode.SimPosition.Y > colliderBottom.Y + characterHeight;
|
||||
bool isTargetTooLow = currentNode.SimPosition.Y < colliderBottom.Y;
|
||||
var door = currentNode.ConnectedDoor;
|
||||
float targetDistanceMultiplier = MathHelper.Lerp(1, 10, MathHelper.Clamp(Math.Abs(velocity.X) / 5, 0, 1));
|
||||
if (currentNode.Stairs == null)
|
||||
{
|
||||
float heightDiff = currentPath.CurrentNode.SimPosition.Y - collider.SimPosition.Y;
|
||||
if (heightDiff < colliderHeight)
|
||||
// Only attempt dropping if the node is below the collider bottom.
|
||||
// Using the next node position here, because the current node might be on the top of the ladder, which can be at the same level with the character or even above it.
|
||||
bool isBelowEnough = (nextNode ?? currentNode).WorldPosition.Y < character.WorldPosition.Y - colliderHeight / 2;
|
||||
bool drop = false;
|
||||
if (isBelowEnough)
|
||||
{
|
||||
// Original comment:
|
||||
//the waypoint is between the top and bottom of the collider, no need to move vertically.
|
||||
// Note that the waypoint can be below collider too! This might be incorrect.
|
||||
if (!canClimb)
|
||||
{
|
||||
// Can't climb -> check if we should drop.
|
||||
Door nextDoor = door ?? nextNode?.ConnectedDoor;
|
||||
if (nextDoor is Door { IsHorizontal: true, CanBeTraversed: true } openHatch)
|
||||
{
|
||||
bool isHatchBelowCharacter = openHatch.LinkedGap.WorldPosition.Y < character.WorldPosition.Y;
|
||||
if (isHatchBelowCharacter)
|
||||
{
|
||||
// Trying to go through an open hatch below us -> drop.
|
||||
drop = true;
|
||||
}
|
||||
}
|
||||
else if (currentLadder != null && !isTargetTooLow && nextDoor == null)
|
||||
{
|
||||
// On ladders -> drop.
|
||||
drop = true;
|
||||
}
|
||||
}
|
||||
}
|
||||
if (drop)
|
||||
{
|
||||
return NextNode(!doorsChecked);
|
||||
}
|
||||
else if (verticalDistance < colliderHeight / 2)
|
||||
{
|
||||
// The waypoint is between the top and bottom of the collider, and we don't intend to drop -> no need to move vertically.
|
||||
diff.Y = 0.0f;
|
||||
}
|
||||
}
|
||||
else
|
||||
{
|
||||
// In stairs
|
||||
bool isNextNodeInSameStairs = currentPath.NextNode?.Stairs == currentPath.CurrentNode.Stairs;
|
||||
// On stairs
|
||||
bool isNextNodeInSameStairs = nextNode?.Stairs == currentNode.Stairs;
|
||||
if (!isNextNodeInSameStairs)
|
||||
{
|
||||
margin = 1;
|
||||
if (currentPath.CurrentNode.SimPosition.Y < colliderBottom.Y + character.AnimController.ColliderHeightFromFloor * 0.25f)
|
||||
targetDistanceMultiplier = 1;
|
||||
if (currentNode.SimPosition.Y < colliderBottom.Y + character.AnimController.ColliderHeightFromFloor * 0.25f)
|
||||
{
|
||||
isTargetTooLow = true;
|
||||
}
|
||||
Structure nextStairs = nextNode?.Stairs;
|
||||
if (character.AnimController.Stairs != null && nextStairs != null)
|
||||
{
|
||||
//currently on stairs, and the next node is not in the same stairs
|
||||
// -> we must get off the current stairs first before we can skip to the next node, otherwise the character
|
||||
// would attempt to get "through the stairs" to the next ones
|
||||
if (character.AnimController.Stairs.StairDirection == Direction.Right)
|
||||
{
|
||||
//the direction in which the bot should keep moving depends on the direction of the stairs and whether we're going up or down
|
||||
diff = nextStairs.WorldPosition.Y > character.AnimController.Stairs.WorldPosition.Y ? Vector2.UnitX : -Vector2.UnitX;
|
||||
}
|
||||
else
|
||||
{
|
||||
diff = nextStairs.WorldPosition.Y > character.AnimController.Stairs.WorldPosition.Y ? -Vector2.UnitX : Vector2.UnitX;
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
float targetDistance = Math.Max(colliderSize.X / 2 * margin, minWidth / 2);
|
||||
if (horizontalDistance < targetDistance && !isTargetTooHigh && !isTargetTooLow)
|
||||
// Walking horizontally, check whether we are close enough to the current node.
|
||||
float targetDistance = Math.Max(colliderSize.X / 2 * targetDistanceMultiplier, ConvertUnits.ToDisplayUnits(minWidth / 2));
|
||||
Debug.Assert(targetDistance < 500, "Target distance too large (a character is trying to skip on their path to a waypoint far away), something is probably off here.");
|
||||
if (!isTargetTooHigh && !isTargetTooLow && horizontalDistance < targetDistance)
|
||||
{
|
||||
if (door is not { CanBeTraversed: false } && (currentLadder == null || nextLadder == null))
|
||||
bool isBlockedByDoor = door is { CanBeTraversed: false };
|
||||
// If both the current ladder and the next ladder are not null, we are in the middle of ladders and should let the code above handle advancing the nodes.
|
||||
// However, if either one is null, and we get here, we are probably walking to or from ladders.
|
||||
bool notOnLadders = currentLadder == null || nextLadder == null;
|
||||
if (!isBlockedByDoor && notOnLadders)
|
||||
{
|
||||
NextNode(!doorsChecked);
|
||||
return NextNode(!doorsChecked);
|
||||
}
|
||||
}
|
||||
}
|
||||
if (currentPath.CurrentNode == null)
|
||||
return ReturnDiff();
|
||||
|
||||
Vector2 NextNode(bool checkDoors)
|
||||
{
|
||||
return Vector2.Zero;
|
||||
if (checkDoors)
|
||||
{
|
||||
CheckDoorsInPath();
|
||||
}
|
||||
currentPath.SkipToNextNode();
|
||||
return ReturnDiff();
|
||||
}
|
||||
return ConvertUnits.ToSimUnits(diff);
|
||||
}
|
||||
|
||||
private void NextNode(bool checkDoors)
|
||||
{
|
||||
if (checkDoors)
|
||||
|
||||
Vector2 ReturnDiff()
|
||||
{
|
||||
CheckDoorsInPath();
|
||||
if (currentPath.CurrentNode == null)
|
||||
{
|
||||
return Vector2.Zero;
|
||||
}
|
||||
return ConvertUnits.ToSimUnits(diff);
|
||||
}
|
||||
currentPath.SkipToNextNode();
|
||||
}
|
||||
|
||||
public bool CanAccessDoor(Door door, Func<Controller, bool> buttonFilter = null)
|
||||
@@ -600,8 +676,6 @@ namespace Barotrauma
|
||||
}
|
||||
}
|
||||
|
||||
private Vector2 GetColliderSize() => ConvertUnits.ToDisplayUnits(character.AnimController.Collider.GetSize());
|
||||
|
||||
private float GetColliderLength()
|
||||
{
|
||||
Vector2 colliderSize = character.AnimController.Collider.GetSize();
|
||||
@@ -676,7 +750,7 @@ namespace Barotrauma
|
||||
if (door.LinkedGap.IsHorizontal)
|
||||
{
|
||||
int dir = Math.Sign(nextWaypoint.WorldPosition.X - door.Item.WorldPosition.X);
|
||||
float size = character.AnimController.InWater ? colliderLength : GetColliderSize().X;
|
||||
float size = character.AnimController.InWater ? colliderLength : ConvertUnits.ToDisplayUnits(character.AnimController.Collider.GetSize()).X;
|
||||
shouldBeOpen = (door.Item.WorldPosition.X - character.WorldPosition.X) * dir > -size;
|
||||
}
|
||||
else
|
||||
@@ -794,12 +868,17 @@ namespace Barotrauma
|
||||
if (character == null) { return 0.0f; }
|
||||
float? penalty = GetSingleNodePenalty(nextNode);
|
||||
if (penalty == null) { return null; }
|
||||
Vector2 nextNodePosition = nextNode.Position;
|
||||
if (nextNode.Waypoint.Submarine != node.Waypoint.Submarine)
|
||||
{
|
||||
nextNodePosition = Submarine.GetRelativeSimPosition(nextNodePosition, node.Waypoint.Submarine, nextNode.Waypoint.Submarine);
|
||||
}
|
||||
bool nextNodeAboveWaterLevel = nextNode.Waypoint.CurrentHull != null && nextNode.Waypoint.CurrentHull.Surface < nextNode.Waypoint.Position.Y;
|
||||
if (!character.CanClimb && node.Waypoint.Stairs == null && nextNode.Waypoint.Stairs == null)
|
||||
{
|
||||
if (node.Waypoint.Ladders != null && nextNode.Waypoint.Ladders != null && (!nextNode.Waypoint.Ladders.Item.IsInteractable(character) || character.LockHands) ||
|
||||
(nextNode.Position.Y - node.Position.Y > 1.0f && //more than one sim unit to climb up
|
||||
nextNodeAboveWaterLevel)) //upper node not underwater
|
||||
(nextNodePosition.Y - node.Position.Y > 1.0f && //more than one sim unit to climb up
|
||||
nextNodeAboveWaterLevel)) //upper node not underwater
|
||||
{
|
||||
return null;
|
||||
}
|
||||
@@ -830,7 +909,7 @@ namespace Barotrauma
|
||||
}
|
||||
}
|
||||
|
||||
float yDist = Math.Abs(node.Position.Y - nextNode.Position.Y);
|
||||
float yDist = Math.Abs(node.Position.Y - nextNodePosition.Y);
|
||||
if (nextNodeAboveWaterLevel && node.Waypoint.Ladders == null && nextNode.Waypoint.Ladders == null && node.Waypoint.Stairs == null && nextNode.Waypoint.Stairs == null)
|
||||
{
|
||||
penalty += yDist * 10.0f;
|
||||
@@ -898,18 +977,14 @@ namespace Barotrauma
|
||||
//steer away from edges of the hull
|
||||
bool wander = false;
|
||||
bool inWater = character.AnimController.InWater;
|
||||
Hull currentHull = character.CurrentHull;
|
||||
// TODO: disabled for now, because seems to cause bots to walk towards walls/doors in some places. In some places it's because how the hulls are defined, but there is probably something else too, is it seems to happen also elsewhere.
|
||||
// if (!inWater)
|
||||
// {
|
||||
// Vector2 colliderBottomPos = ConvertUnits.ToDisplayUnits(character.AnimController.GetColliderBottom());
|
||||
// if (Hull.FindHull(colliderBottomPos, guess: currentHull, useWorldCoordinates: false) is Hull lowestHull)
|
||||
// {
|
||||
// // Use the hull found at the collider bottom, if found.
|
||||
// // Makes difference in some rooms that have multiple hulls, of which the lowest hull where the feet are might not be the same as where the center position of the main collider is.
|
||||
// currentHull = lowestHull;
|
||||
// }
|
||||
// }
|
||||
|
||||
//use the hull the legs are in (if one is found), so the character won't walk against the wall when their torso is in a different hull where there'd be room to walk further
|
||||
//(e.g. if the character is in a shallow pool-type room, like in ResearchModule_01_Colony)
|
||||
Hull currentHull =
|
||||
character.AnimController.GetLimb(LimbType.RightLeg)?.Hull ??
|
||||
character.AnimController.GetLimb(LimbType.LeftLeg)?.Hull ??
|
||||
character.CurrentHull;
|
||||
|
||||
if (currentHull != null && !inWater)
|
||||
{
|
||||
float roomWidth = currentHull.Rect.Width;
|
||||
|
||||
@@ -103,9 +103,19 @@ namespace Barotrauma
|
||||
}
|
||||
}
|
||||
|
||||
// For temporarily forcing walking. Will reset after each priority calculation, so it will need to be kept alive by something.
|
||||
// The intention of this boolean to allow walking even when the priority is higher than AIObjectiveManager.RunPriority.
|
||||
public bool ForceWalk { get; set; }
|
||||
/// <summary>
|
||||
/// For temporarily forcing walking. Will reset after each priority calculation, so it will need to be kept alive by something.
|
||||
/// The intention of this boolean to allow walking even when the priority is higher than AIObjectiveManager.RunPriority.
|
||||
/// </summary>
|
||||
public bool ForceWalkTemporarily { get; set; }
|
||||
|
||||
/// <summary>
|
||||
/// Forces the character to walk when executing this objective, even if the priority is above <see cref="AIObjectiveManager.RunPriority"/>.
|
||||
/// Unlike <see cref="ForceWalkTemporarily"/>, this value is not automatically reset.
|
||||
/// </summary>
|
||||
public bool ForceWalkPermanently { get; set; }
|
||||
|
||||
public bool ForceWalk => ForceWalkTemporarily || ForceWalkPermanently;
|
||||
|
||||
public bool IgnoreAtOutpost { get; set; }
|
||||
|
||||
@@ -313,7 +323,7 @@ namespace Barotrauma
|
||||
/// </summary>
|
||||
public float CalculatePriority()
|
||||
{
|
||||
ForceWalk = false;
|
||||
ForceWalkTemporarily = false;
|
||||
Priority = GetPriority();
|
||||
ForceHighestPriority = false;
|
||||
return Priority;
|
||||
|
||||
+1
-1
@@ -40,7 +40,7 @@ namespace Barotrauma
|
||||
if (subObjectives.All(so => so.SubObjectives.None()))
|
||||
{
|
||||
// If none of the subobjectives have subobjectives, no valid container was found. Don't allow running.
|
||||
ForceWalk = true;
|
||||
ForceWalkTemporarily = true;
|
||||
}
|
||||
return prio;
|
||||
}
|
||||
|
||||
+10
-8
@@ -258,13 +258,14 @@ namespace Barotrauma
|
||||
|
||||
protected override bool CheckObjectiveState()
|
||||
{
|
||||
if (character.Submarine is { TeamID: CharacterTeamType.FriendlyNPC } && character.Submarine == Enemy.Submarine)
|
||||
// In a friendly outpost, and the target is still in the outpost
|
||||
if (character.Submarine is { Info.IsOutpost: true } && character.IsOnFriendlyTeam(character.Submarine.TeamID) &&
|
||||
character.Submarine == Enemy.Submarine)
|
||||
{
|
||||
// Target still in the outpost
|
||||
// Outpost guards shouldn't lose the target in friendly outposts,
|
||||
// However, if we are not a guard, let's ensure that we allow the cooldown.
|
||||
if (character.TeamID == CharacterTeamType.FriendlyNPC && !character.IsSecurity)
|
||||
{
|
||||
// Outpost guards shouldn't lose the target in friendly outposts,
|
||||
// However, if we are not a guard, let's ensure that we allow the cooldown.
|
||||
allowCooldown = true;
|
||||
}
|
||||
}
|
||||
@@ -286,7 +287,8 @@ namespace Barotrauma
|
||||
{
|
||||
allowCooldown = true;
|
||||
// Target not in the outpost anymore.
|
||||
if (character.CanSeeTarget(Enemy))
|
||||
if (character.Submarine.IsConnectedTo(Enemy.Submarine) &&
|
||||
character.CanSeeTarget(Enemy))
|
||||
{
|
||||
allowCooldown = false;
|
||||
coolDownTimer = DefaultCoolDown;
|
||||
@@ -389,7 +391,7 @@ namespace Barotrauma
|
||||
HumanAIController.AutoFaceMovement = false;
|
||||
if (!gotoObjective.ShouldRun(true))
|
||||
{
|
||||
ForceWalk = true;
|
||||
ForceWalkTemporarily = true;
|
||||
}
|
||||
}
|
||||
}
|
||||
@@ -468,7 +470,7 @@ namespace Barotrauma
|
||||
isMoving = true;
|
||||
if (!IsEnemyClose(MeleeDistance))
|
||||
{
|
||||
ForceWalk = true;
|
||||
ForceWalkTemporarily = true;
|
||||
}
|
||||
HumanAIController.FaceTarget(Enemy);
|
||||
HumanAIController.AutoFaceMovement = false;
|
||||
@@ -1234,7 +1236,7 @@ namespace Barotrauma
|
||||
}
|
||||
if (isAimBlocked)
|
||||
{
|
||||
ForceWalk = true;
|
||||
ForceWalkTemporarily = true;
|
||||
}
|
||||
if (!followTargetObjective.IsCloseEnough)
|
||||
{
|
||||
|
||||
+5
-1
@@ -95,7 +95,11 @@ namespace Barotrauma
|
||||
if (potentialDeconstructor?.InputContainer == null) { continue; }
|
||||
if (!potentialDeconstructor.InputContainer.Inventory.CanBePut(Item)) { continue; }
|
||||
if (!potentialDeconstructor.Item.HasAccess(character)) { continue; }
|
||||
if (Item.Prefab.DeconstructItems.None(it => it.IsValidDeconstructor(otherItem))) { continue; }
|
||||
if (Item.Prefab.DeconstructItems.Any() &&
|
||||
Item.Prefab.DeconstructItems.None(it => it.IsValidDeconstructor(otherItem)))
|
||||
{
|
||||
continue;
|
||||
}
|
||||
float distFactor = GetDistanceFactor(Item.WorldPosition, potentialDeconstructor.Item.WorldPosition, factorAtMaxDistance: 0.2f);
|
||||
if (distFactor > bestDistFactor)
|
||||
{
|
||||
|
||||
+5
-1
@@ -64,7 +64,11 @@ namespace Barotrauma
|
||||
if (target == null || target.Removed) { return false; }
|
||||
//bots can't handle deconstructing items that require another item to deconstruct, let's not try to do that
|
||||
//in the vanilla game, this means unidentified genetic materials, which we don't want to "deconstruct" anyway
|
||||
if (target.Prefab.DeconstructItems.All(d => d.RequiredOtherItem.Length > 0)) { return false; }
|
||||
if (target.Prefab.DeconstructItems.Any() &&
|
||||
target.Prefab.DeconstructItems.All(d => d.RequiredOtherItem.Length > 0))
|
||||
{
|
||||
return false;
|
||||
}
|
||||
// If the target was selected as a valid target, we'll have to accept it so that the objective can be completed.
|
||||
// The validity changes when a character picks the item up.
|
||||
if (!IsValidTarget(target, character, checkInventory: true))
|
||||
|
||||
+1
-1
@@ -148,7 +148,7 @@ namespace Barotrauma
|
||||
character.Speak(TextManager.GetWithVariable("DialogPutOutFire", "[roomname]", targetHull.DisplayName, FormatCapitals.Yes).Value, null, 0, "putoutfire".ToIdentifier(), 10.0f);
|
||||
}
|
||||
// Prevents running into the flames.
|
||||
objectiveManager.CurrentObjective.ForceWalk = true;
|
||||
objectiveManager.CurrentObjective.ForceWalkTemporarily = true;
|
||||
}
|
||||
if (moveCloser)
|
||||
{
|
||||
|
||||
+2
@@ -11,6 +11,8 @@ namespace Barotrauma
|
||||
public override Identifier Identifier { get; set; } = "extinguish fires".ToIdentifier();
|
||||
public override bool ForceRun => true;
|
||||
protected override bool AllowInAnySub => true;
|
||||
// Periodically clear the ignore list so that fires abandoned when fumbling with finding an extinguisher, navigating etc get reconsidered
|
||||
protected override float IgnoreListClearInterval => 30;
|
||||
|
||||
public AIObjectiveExtinguishFires(Character character, AIObjectiveManager objectiveManager, float priorityModifier = 1) : base(character, objectiveManager, priorityModifier) { }
|
||||
|
||||
|
||||
+22
-7
@@ -49,6 +49,13 @@ namespace Barotrauma
|
||||
public const float DefaultReach = 100;
|
||||
public const float MaxReach = 150;
|
||||
|
||||
/// <summary>
|
||||
/// How long it takes for the objective to be abandoned if no suitable item is found.
|
||||
/// Intended to be an optimization: if the bots are constantly trying to find some item (like a diving suit),
|
||||
/// it can easily lead to performance issues when e.g. AIObjectiveFindDivingGear constantly starts up new GetItem objectives.
|
||||
/// </summary>
|
||||
private float abandonDelayIfItemNotFound = 5.0f;
|
||||
|
||||
/// <summary>
|
||||
/// Is the goal of this objective to get diving gear (i.e. has it been created by <see cref="AIObjectiveFindDivingGear"/>)?
|
||||
/// If so, the objective won't attempt to create another objective if the path requires diving gear
|
||||
@@ -213,7 +220,7 @@ namespace Barotrauma
|
||||
{
|
||||
if (isDoneSeeking)
|
||||
{
|
||||
HandlePotentialItems();
|
||||
HandlePotentialItems(deltaTime);
|
||||
}
|
||||
if (objectiveManager.CurrentOrder is not AIObjectiveGoTo)
|
||||
{
|
||||
@@ -389,6 +396,8 @@ namespace Barotrauma
|
||||
// If the root container changes, the item is no longer where it was (taken by someone -> need to find another item)
|
||||
AbortCondition = obj => targetItem == null || (targetItem.GetRootInventoryOwner() is Entity owner && owner != moveToTarget && owner != character),
|
||||
SpeakIfFails = false,
|
||||
ForceWalkTemporarily = this.ForceWalkTemporarily,
|
||||
ForceWalkPermanently = this.ForceWalkPermanently,
|
||||
endNodeFilter = CreateEndNodeFilter(moveToTarget)
|
||||
};
|
||||
},
|
||||
@@ -598,7 +607,7 @@ namespace Barotrauma
|
||||
}
|
||||
}
|
||||
|
||||
private void HandlePotentialItems()
|
||||
private void HandlePotentialItems(float deltaTime)
|
||||
{
|
||||
Debug.Assert(isDoneSeeking);
|
||||
if (itemCandidates.Any())
|
||||
@@ -652,10 +661,14 @@ namespace Barotrauma
|
||||
}
|
||||
else
|
||||
{
|
||||
#if DEBUG
|
||||
DebugConsole.NewMessage($"{character.Name}: Cannot find an item with the following identifier(s) or tag(s): {string.Join(", ", IdentifiersOrTags)}", Color.Yellow);
|
||||
#endif
|
||||
Abandon = true;
|
||||
abandonDelayIfItemNotFound -= deltaTime;
|
||||
if (abandonDelayIfItemNotFound <= 0.0f)
|
||||
{
|
||||
#if DEBUG
|
||||
DebugConsole.NewMessage($"{character.Name}: Cannot find an item with the following identifier(s) or tag(s): {string.Join(", ", IdentifiersOrTags)}", Color.Yellow);
|
||||
#endif
|
||||
Abandon = true;
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
@@ -718,13 +731,15 @@ namespace Barotrauma
|
||||
|
||||
private bool CheckItem(Item item)
|
||||
{
|
||||
bool matchesIdentifiersOrTags = item.HasIdentifierOrTags(IdentifiersOrTags) || (AllowVariants && !item.Prefab.VariantOf.IsEmpty && IdentifiersOrTags.Contains(item.Prefab.VariantOf));
|
||||
if (!matchesIdentifiersOrTags) { return false; }
|
||||
if (!item.HasAccess(character)) { return false; }
|
||||
if (ignoredItems.Contains(item)) { return false; };
|
||||
if (ignoredIdentifiersOrTags != null && item.HasIdentifierOrTags(ignoredIdentifiersOrTags)) { return false; }
|
||||
if (item.Condition < TargetCondition) { return false; }
|
||||
if (ItemFilter != null && !ItemFilter(item)) { return false; }
|
||||
if (RequireNonEmpty && item.Components.Any(i => i.IsEmpty(character))) { return false; }
|
||||
return item.HasIdentifierOrTags(IdentifiersOrTags) || (AllowVariants && !item.Prefab.VariantOf.IsEmpty && IdentifiersOrTags.Contains(item.Prefab.VariantOf));
|
||||
return true;
|
||||
}
|
||||
|
||||
public override void Reset()
|
||||
|
||||
@@ -958,6 +958,7 @@ namespace Barotrauma
|
||||
|
||||
public bool ShouldRun(bool run)
|
||||
{
|
||||
if (ForceWalk) { return false; }
|
||||
if (run && objectiveManager.ForcedOrder == this && IsWaitOrder && !character.IsOnPlayerTeam)
|
||||
{
|
||||
// NPCs with a wait order don't run.
|
||||
|
||||
+4
-1
@@ -267,7 +267,10 @@ namespace Barotrauma
|
||||
if (node.Waypoint.CurrentHull != character.CurrentHull && HumanAIController.UnsafeHulls.Contains(node.Waypoint.CurrentHull)) { return false; }
|
||||
return true;
|
||||
//don't stop at ladders when idling
|
||||
}, endNodeFilter: node => node.Waypoint.Stairs == null && node.Waypoint.Ladders == null && (!isCurrentHullAllowed || !IsForbidden(node.Waypoint.CurrentHull)));
|
||||
}, endNodeFilter: node =>
|
||||
node.Waypoint.Stairs == null && node.Waypoint.CurrentHull == currentTarget && node.Waypoint.Ladders == null &&
|
||||
(!isCurrentHullAllowed || !IsForbidden(node.Waypoint.CurrentHull)));
|
||||
|
||||
if (path.Unreachable)
|
||||
{
|
||||
//can't go to this room, remove it from the list and try another room
|
||||
|
||||
+4
-3
@@ -78,9 +78,10 @@ namespace Barotrauma
|
||||
if (item.GetRootInventoryOwner() is Character targetCharacter &&
|
||||
AIObjectiveFightIntruders.IsValidTarget(targetCharacter, character, targetCharactersInOtherSubs: false))
|
||||
{
|
||||
float dist = character.CurrentHull.GetApproximateDistance(character.Position, targetCharacter.Position, targetCharacter.CurrentHull, aiTarget.SoundRange, distanceMultiplierPerClosedDoor: 2);
|
||||
if (dist * HumanAIController.Hearing > aiTarget.SoundRange) { continue; }
|
||||
|
||||
float range = aiTarget.SoundRange * HumanAIController.Hearing;
|
||||
float dist = character.CurrentHull.GetApproximateDistance(character.Position, targetCharacter.Position, targetCharacter.CurrentHull, range, distanceMultiplierPerClosedDoor: 2);
|
||||
if (dist > range) { continue; }
|
||||
|
||||
character.Speak(TextManager.Get("dialogheardenemy").Value, identifier: "heardenemy".ToIdentifier(), minDurationBetweenSimilar: 30.0f);
|
||||
if (inspectNoiseObjective != null && subObjectives.Contains(inspectNoiseObjective))
|
||||
{
|
||||
|
||||
+1
-1
@@ -112,7 +112,7 @@ namespace Barotrauma
|
||||
float prio = objectiveManager.GetOrderPriority(this);
|
||||
if (subObjectives.All(so => so.SubObjectives.None() || so.Priority <= 0))
|
||||
{
|
||||
ForceWalk = true;
|
||||
ForceWalkTemporarily = true;
|
||||
}
|
||||
return prio;
|
||||
}
|
||||
|
||||
-4
@@ -103,10 +103,6 @@ namespace Barotrauma
|
||||
|
||||
public void AddObjective<T>(T objective) where T : AIObjective
|
||||
{
|
||||
var result = GameMain.LuaCs.Hook.Call<bool?>("AI.addObjective", this, objective);
|
||||
|
||||
if (result != null && result.Value) return;
|
||||
|
||||
if (objective == null)
|
||||
{
|
||||
#if DEBUG
|
||||
|
||||
+1
@@ -257,6 +257,7 @@ namespace Barotrauma
|
||||
{
|
||||
DialogueIdentifier = AIObjectiveGoTo.DialogCannotReachTarget,
|
||||
TargetName = target.Item.Name,
|
||||
ForceWalkPermanently = ForceWalk,
|
||||
endNodeFilter = EndNodeFilter ?? AIObjectiveGetItem.CreateEndNodeFilter(target.Item)
|
||||
},
|
||||
onAbandon: () => Abandon = true,
|
||||
|
||||
+1
-1
@@ -29,7 +29,7 @@ namespace Barotrauma
|
||||
{
|
||||
if (pump?.Item == null || pump.Item.Removed) { return false; }
|
||||
if (pump.Item.IgnoreByAI(character)) { return false; }
|
||||
if (!pump.Item.IsInteractable(character)) { return false; }
|
||||
if (!pump.Item.IsInteractable(character) || !pump.CanBeSelected) { return false; }
|
||||
if (pump.IsAutoControlled) { return false; }
|
||||
if (pump.Item.ConditionPercentage <= 0) { return false; }
|
||||
if (pump.Item.CurrentHull == null) { return false; }
|
||||
|
||||
+1
-1
@@ -136,7 +136,7 @@ namespace Barotrauma
|
||||
public static bool IsValidTarget(Character target, Character character, out bool ignoredAsMinorWounds)
|
||||
{
|
||||
ignoredAsMinorWounds = false;
|
||||
if (target == null || target.IsDead || target.Removed) { return false; }
|
||||
if (target == null || target.IsDead || target.Removed || target.InvisibleTimer > 0.0f) { return false; }
|
||||
if (target.IsInstigator) { return false; }
|
||||
if (target.IsPet) { return false; }
|
||||
if (!HumanAIController.IsFriendly(character, target, onlySameTeam: true)) { return false; }
|
||||
|
||||
@@ -42,7 +42,9 @@ namespace Barotrauma
|
||||
{
|
||||
enemyAi.PetBehavior?.Update(deltaTime);
|
||||
}
|
||||
if (IsDead || IsUnconscious || Stun > 0.0f || IsIncapacitated)
|
||||
if (IsDead || IsUnconscious || IsIncapacitated ||
|
||||
//only check "real" stuns here, ignoring ragdolling, so the AI can run and decide whether to ragdoll or unragdoll
|
||||
CharacterHealth.Stun > 0.0f)
|
||||
{
|
||||
//don't enable simple physics on dead/incapacitated characters
|
||||
//the ragdoll controls the movement of incapacitated characters instead of the collider,
|
||||
|
||||
@@ -685,7 +685,7 @@ namespace Barotrauma
|
||||
{
|
||||
movement = MathUtils.SmoothStep(movement, TargetMovement, 0.2f);
|
||||
|
||||
if (Collider.BodyType == BodyType.Dynamic)
|
||||
if (Collider.BodyType == BodyType.Dynamic && onGround)
|
||||
{
|
||||
Collider.LinearVelocity = new Vector2(
|
||||
movement.X,
|
||||
|
||||
+3
-2
@@ -1,5 +1,6 @@
|
||||
using Barotrauma.Extensions;
|
||||
using Barotrauma.Items.Components;
|
||||
using Barotrauma.LuaCs.Events;
|
||||
using Barotrauma.Networking;
|
||||
using FarseerPhysics;
|
||||
using Microsoft.Xna.Framework;
|
||||
@@ -1305,11 +1306,11 @@ namespace Barotrauma
|
||||
//increase oxygen and clamp it above zero
|
||||
// -> the character should be revived if there are no major afflictions in addition to lack of oxygen
|
||||
target.Oxygen = Math.Max(target.Oxygen + 10.0f, 10.0f);
|
||||
GameMain.LuaCs.Hook.Call("human.CPRSuccess", this);
|
||||
LuaCsSetup.Instance.EventService.PublishEvent<IEventHumanCPRSuccess>(x => x.OnCharacterCPRSuccess(this));
|
||||
}
|
||||
else
|
||||
{
|
||||
GameMain.LuaCs.Hook.Call("human.CPRFailed", this);
|
||||
LuaCsSetup.Instance.EventService.PublishEvent<IEventHumanCPRFailed>(x => x.OnCharacterCPRFailed(this));
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
@@ -1,17 +1,18 @@
|
||||
using Barotrauma.Networking;
|
||||
using Barotrauma.Extensions;
|
||||
using Barotrauma.LuaCs.Events;
|
||||
using Barotrauma.Networking;
|
||||
using FarseerPhysics;
|
||||
using FarseerPhysics.Dynamics;
|
||||
using FarseerPhysics.Dynamics.Contacts;
|
||||
using FarseerPhysics.Dynamics.Joints;
|
||||
using Microsoft.Xna.Framework;
|
||||
using MoonSharp.Interpreter;
|
||||
using System;
|
||||
using System.Collections.Generic;
|
||||
using System.Linq;
|
||||
using System.Xml.Linq;
|
||||
using Barotrauma.Extensions;
|
||||
using LimbParams = Barotrauma.RagdollParams.LimbParams;
|
||||
using JointParams = Barotrauma.RagdollParams.JointParams;
|
||||
using MoonSharp.Interpreter;
|
||||
using LimbParams = Barotrauma.RagdollParams.LimbParams;
|
||||
|
||||
namespace Barotrauma
|
||||
{
|
||||
@@ -31,6 +32,7 @@ namespace Barotrauma
|
||||
{
|
||||
public Fixture F1, F2;
|
||||
public Vector2 LocalNormal;
|
||||
public Vector2 WorldNormal;
|
||||
public Vector2 Velocity;
|
||||
public Vector2 ImpactPos;
|
||||
|
||||
@@ -40,7 +42,7 @@ namespace Barotrauma
|
||||
F2 = f2;
|
||||
Velocity = velocity;
|
||||
LocalNormal = contact.Manifold.LocalNormal;
|
||||
contact.GetWorldManifold(out _, out FarseerPhysics.Common.FixedArray2<Vector2> points);
|
||||
contact.GetWorldManifold(out WorldNormal, out FarseerPhysics.Common.FixedArray2<Vector2> points);
|
||||
ImpactPos = points[0];
|
||||
}
|
||||
}
|
||||
@@ -827,7 +829,7 @@ namespace Barotrauma
|
||||
return true;
|
||||
}
|
||||
|
||||
private void ApplyImpact(Fixture f1, Fixture f2, Vector2 localNormal, Vector2 impactPos, Vector2 velocity)
|
||||
private void ApplyImpact(Fixture f1, Fixture f2, Vector2 worldNormal, Vector2 impactPos, Vector2 velocity)
|
||||
{
|
||||
if (character.DisableImpactDamageTimer > 0.0f) { return; }
|
||||
|
||||
@@ -839,7 +841,7 @@ namespace Barotrauma
|
||||
return;
|
||||
}
|
||||
|
||||
Vector2 normal = localNormal;
|
||||
Vector2 normal = worldNormal;
|
||||
float impact = Vector2.Dot(velocity, -normal);
|
||||
if (f1.Body == Collider.FarseerBody || !Collider.Enabled)
|
||||
{
|
||||
@@ -857,7 +859,8 @@ namespace Barotrauma
|
||||
|
||||
float impactDamage = GetImpactDamage(impact, impactTolerance);
|
||||
|
||||
var should = GameMain.LuaCs.Hook.Call<float?>("changeFallDamage", impactDamage, character, impactPos, velocity);
|
||||
float? should = null;
|
||||
LuaCsSetup.Instance.EventService.PublishEvent<IEventChangeFallDamage>(x => should = x.OnChangeFallDamage(impactDamage, character, impactPos, velocity) ?? should);
|
||||
|
||||
if (should != null)
|
||||
{
|
||||
@@ -1077,9 +1080,12 @@ namespace Barotrauma
|
||||
}
|
||||
|
||||
Hull newHull = Hull.FindHull(findPos, currentHull);
|
||||
if (setInWater && newHull == null)
|
||||
if (setInWater)
|
||||
{
|
||||
inWater = true;
|
||||
if (newHull == null || findPos.Y < newHull.WorldSurface)
|
||||
{
|
||||
inWater = true;
|
||||
}
|
||||
}
|
||||
|
||||
if (newHull == currentHull) { return; }
|
||||
@@ -1122,7 +1128,10 @@ namespace Barotrauma
|
||||
{
|
||||
//don't teleport out yet if the character is going through a gap
|
||||
if (Gap.FindAdjacent(Gap.GapList.Where(g => g.Submarine == currentHull.Submarine), findPos, 150.0f, allowRoomToRoom: true) != null) { return; }
|
||||
if (Limbs.Any(l => Gap.FindAdjacent(currentHull.ConnectedGaps, l.WorldPosition, ConvertUnits.ToDisplayUnits(l.body.GetSize().Combine()), allowRoomToRoom: true) != null)) { return; }
|
||||
if (Limbs.Any(l => !l.IsSevered && Gap.FindAdjacent(currentHull.ConnectedGaps, l.WorldPosition, ConvertUnits.ToDisplayUnits(l.body.GetSize().Combine()), allowRoomToRoom: true) != null))
|
||||
{
|
||||
return;
|
||||
}
|
||||
character.MemLocalState?.Clear();
|
||||
Teleport(ConvertUnits.ToSimUnits(currentHull.Submarine.Position), currentHull.Submarine.Velocity);
|
||||
}
|
||||
@@ -1259,6 +1268,9 @@ namespace Barotrauma
|
||||
|
||||
private float BodyInRestDelay = 1.0f;
|
||||
|
||||
/// <summary>
|
||||
/// Controls the sleeping state of this character
|
||||
/// </summary>
|
||||
public bool BodyInRest
|
||||
{
|
||||
get { return bodyInRestTimer > BodyInRestDelay; }
|
||||
@@ -1282,7 +1294,7 @@ namespace Barotrauma
|
||||
while (impactQueue.Count > 0)
|
||||
{
|
||||
var impact = impactQueue.Dequeue();
|
||||
ApplyImpact(impact.F1, impact.F2, impact.LocalNormal, impact.ImpactPos, impact.Velocity);
|
||||
ApplyImpact(impact.F1, impact.F2, impact.WorldNormal, impact.ImpactPos, impact.Velocity);
|
||||
}
|
||||
|
||||
CheckValidity();
|
||||
@@ -1325,9 +1337,18 @@ namespace Barotrauma
|
||||
}
|
||||
|
||||
float MaxVel = NetConfig.MaxPhysicsBodyVelocity;
|
||||
Collider.LinearVelocity = new Vector2(
|
||||
NetConfig.Quantize(Collider.LinearVelocity.X, -MaxVel, MaxVel, 12),
|
||||
NetConfig.Quantize(Collider.LinearVelocity.Y, -MaxVel, MaxVel, 12));
|
||||
if (GameMain.NetworkMember != null)
|
||||
{
|
||||
Collider.LinearVelocity = new Vector2(
|
||||
NetConfig.Quantize(Collider.LinearVelocity.X, -MaxVel, MaxVel, 12),
|
||||
NetConfig.Quantize(Collider.LinearVelocity.Y, -MaxVel, MaxVel, 12));
|
||||
}
|
||||
else
|
||||
{
|
||||
Collider.LinearVelocity = new Vector2(
|
||||
MathHelper.Clamp(Collider.LinearVelocity.X, -MaxVel, MaxVel),
|
||||
MathHelper.Clamp(Collider.LinearVelocity.Y, -MaxVel, MaxVel));
|
||||
}
|
||||
|
||||
if (forceStanding)
|
||||
{
|
||||
@@ -1381,9 +1402,19 @@ namespace Barotrauma
|
||||
|
||||
UpdateHullFlowForces(deltaTime);
|
||||
|
||||
if (currentHull == null ||
|
||||
bool applyWaterForces =
|
||||
currentHull == null ||
|
||||
currentHull.WaterVolume > currentHull.Volume * 0.95f ||
|
||||
ConvertUnits.ToSimUnits(currentHull.Surface) > Collider.SimPosition.Y)
|
||||
ConvertUnits.ToSimUnits(currentHull.Surface) > Collider.SimPosition.Y;
|
||||
#if CLIENT
|
||||
if (Screen.Selected is CharacterEditor.CharacterEditorScreen &&
|
||||
this is AnimController animController)
|
||||
{
|
||||
applyWaterForces = animController.CurrentAnimationParams is SwimParams;
|
||||
}
|
||||
#endif
|
||||
|
||||
if (applyWaterForces)
|
||||
{
|
||||
Collider.ApplyWaterForces();
|
||||
}
|
||||
@@ -1473,10 +1504,10 @@ namespace Barotrauma
|
||||
else
|
||||
{
|
||||
// Falling -> ragdoll briefly if we are not moving at all, because we are probably stuck.
|
||||
if (Collider.LinearVelocity == Vector2.Zero && !character.IsRemotePlayer)
|
||||
if (Collider.LinearVelocity == Vector2.Zero && GameMain.NetworkMember is not { IsClient: true })
|
||||
{
|
||||
character.IsRagdolled = true;
|
||||
if (character.IsBot)
|
||||
if (!character.IsPlayer)
|
||||
{
|
||||
// Seems to work without this on player controlled characters -> not sure if we should call it always or just for the bots.
|
||||
character.SetInput(InputType.Ragdoll, hit: false, held: true);
|
||||
@@ -1836,7 +1867,13 @@ namespace Barotrauma
|
||||
{
|
||||
floorFixture = standOnFloorFixture;
|
||||
standOnFloorY = rayStart.Y + (rayEnd.Y - rayStart.Y) * standOnFloorFraction;
|
||||
if (rayStart.Y - standOnFloorY < Collider.Height * 0.5f + Collider.Radius + ColliderHeightFromFloor * 1.2f)
|
||||
|
||||
//allow the floor to be just a bit below the bottom of the collider for the character to be "on ground"
|
||||
//there is some inaccuracy in the physics simulation (and floats), the collider isn't usually precisely ColliderHeightFromFloor above the floor
|
||||
const float Tolerance = 0.1f;
|
||||
float standHeight = Collider.Height * 0.5f + Collider.Radius + ColliderHeightFromFloor;
|
||||
|
||||
if (rayStart.Y - standOnFloorY <= standHeight + Tolerance)
|
||||
{
|
||||
onGround = true;
|
||||
if (standOnFloorFixture.CollisionCategories == Physics.CollisionStairs)
|
||||
|
||||
@@ -190,6 +190,11 @@ namespace Barotrauma
|
||||
set => Params.Health.DoesBleed = value;
|
||||
}
|
||||
|
||||
/// <summary>
|
||||
/// Can this character be contained inside a controller?
|
||||
/// </summary>
|
||||
public bool IsContainable { get; set; }
|
||||
|
||||
public readonly Dictionary<Identifier, SerializableProperty> Properties;
|
||||
public Dictionary<Identifier, SerializableProperty> SerializableProperties
|
||||
{
|
||||
@@ -686,6 +691,11 @@ namespace Barotrauma
|
||||
get { return AnimController.Mass; }
|
||||
}
|
||||
|
||||
/// <summary>
|
||||
/// The position the character was at when we previously set the transforms of the items in the character's inventory.
|
||||
/// </summary>
|
||||
private Vector2 lastInventoryItemSetTransformPosition;
|
||||
|
||||
public CharacterInventory Inventory { get; private set; }
|
||||
|
||||
/// <summary>
|
||||
@@ -791,7 +801,24 @@ namespace Barotrauma
|
||||
set
|
||||
{
|
||||
if (value == selectedCharacter) { return; }
|
||||
if (selectedCharacter != null) { selectedCharacter.selectedBy = null; }
|
||||
//deselect the currently selected character
|
||||
if (selectedCharacter != null)
|
||||
{
|
||||
selectedCharacter.selectedBy = null;
|
||||
//check if some other character has selected the currently selected character too,
|
||||
//and set selectedBy to that other character (otherwise the currently selected character would be unaware they're still being dragged by someone)
|
||||
foreach (var otherCharacter in CharacterList)
|
||||
{
|
||||
if (otherCharacter != this && otherCharacter.selectedCharacter == selectedCharacter)
|
||||
{
|
||||
selectedCharacter.selectedBy = otherCharacter;
|
||||
break;
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
CharacterHUD.RecreateHudTextsIfControlling(this);
|
||||
|
||||
selectedCharacter = value;
|
||||
if (selectedCharacter != null) { selectedCharacter.selectedBy = this; }
|
||||
#if CLIENT
|
||||
@@ -1433,8 +1460,6 @@ namespace Barotrauma
|
||||
}
|
||||
#endif
|
||||
|
||||
GameMain.LuaCs.Hook.Call("character.created", new object[] { newCharacter });
|
||||
|
||||
return newCharacter;
|
||||
}
|
||||
|
||||
@@ -1648,8 +1673,10 @@ namespace Barotrauma
|
||||
AnimController.FindHull(setInWater: true);
|
||||
if (AnimController.CurrentHull != null) { Submarine = AnimController.CurrentHull.Submarine; }
|
||||
|
||||
IsContainable = prefab.ConfigElement.GetAttributeBool(nameof(IsContainable), def: Mass <= 30.0f);
|
||||
|
||||
CharacterList.Add(this);
|
||||
|
||||
|
||||
Enabled = GameMain.NetworkMember == null;
|
||||
|
||||
if (info != null)
|
||||
@@ -1889,7 +1916,6 @@ namespace Barotrauma
|
||||
}
|
||||
}
|
||||
info.Job?.GiveJobItems(this, isPvPMode, spawnPoint);
|
||||
GameMain.LuaCs.Hook.Call("character.giveJobItems", this, spawnPoint, isPvPMode);
|
||||
}
|
||||
|
||||
public void GiveIdCardTags(WayPoint spawnPoint, bool createNetworkEvent = false)
|
||||
@@ -2275,6 +2301,12 @@ namespace Barotrauma
|
||||
}
|
||||
}
|
||||
|
||||
// Try to detach from the controller if we are currently attached to something that is dangerous for our character
|
||||
if (aiControlled && Stun <= 0f && !IsKnockedDownOrRagdolled && !LockHands && ShouldAvoidStayingAttachedToController())
|
||||
{
|
||||
SelectedItem = null;
|
||||
}
|
||||
|
||||
if (GameMain.NetworkMember != null)
|
||||
{
|
||||
if (GameMain.NetworkMember.IsServer)
|
||||
@@ -2323,7 +2355,7 @@ namespace Barotrauma
|
||||
{
|
||||
attackCoolDown -= deltaTime;
|
||||
}
|
||||
else if (IsKeyDown(InputType.Attack))
|
||||
else if (IsKeyDown(InputType.Attack) && !IsAttachedToController())
|
||||
{
|
||||
//normally the attack target, where to aim the attack and such is handled by EnemyAIController,
|
||||
//but in the case of player-controlled monsters, we handle it here
|
||||
@@ -2850,14 +2882,14 @@ namespace Barotrauma
|
||||
#if CLIENT
|
||||
if (Screen.Selected == GameMain.SubEditorScreen) { hidden = false; }
|
||||
#endif
|
||||
if (!CanInteract || hidden || !item.IsInteractable(this)) { return false; }
|
||||
|
||||
Controller controller = item.GetComponent<Controller>();
|
||||
if (controller != null && IsAnySelectedItem(item) && controller.IsAttachedUser(this))
|
||||
{
|
||||
return true;
|
||||
}
|
||||
|
||||
if (!CanInteract || hidden || !item.IsInteractable(this)) { return false; }
|
||||
|
||||
if (item.ParentInventory != null)
|
||||
{
|
||||
return CanAccessInventory(item.ParentInventory);
|
||||
@@ -2979,7 +3011,9 @@ namespace Barotrauma
|
||||
}
|
||||
}
|
||||
|
||||
if (!item.Prefab.InteractThroughWalls && Screen.Selected != GameMain.SubEditorScreen && !insideTrigger)
|
||||
//note that the distance to item should be set to 0 above if the character is within the item's bounding box
|
||||
bool closeEnoughToIgnoreVisibilityCheck = distanceToItem <= 0.1f;
|
||||
if (!item.Prefab.InteractThroughWalls && Screen.Selected != GameMain.SubEditorScreen && !insideTrigger && !closeEnoughToIgnoreVisibilityCheck)
|
||||
{
|
||||
var body = Submarine.CheckVisibility(SimPosition, itemPosition, ignoreLevel: true);
|
||||
bool itemCenterVisible = CheckBody(body, item);
|
||||
@@ -3008,7 +3042,6 @@ namespace Barotrauma
|
||||
{
|
||||
return itemCenterVisible;
|
||||
}
|
||||
|
||||
}
|
||||
|
||||
return true;
|
||||
@@ -3098,7 +3131,11 @@ namespace Barotrauma
|
||||
|
||||
if (!CanInteract)
|
||||
{
|
||||
SelectedItem = SelectedSecondaryItem = null;
|
||||
if (!IsAttachedToController())
|
||||
{
|
||||
SelectedItem = null;
|
||||
}
|
||||
SelectedSecondaryItem = null;
|
||||
focusedItem = null;
|
||||
if (!AllowInput)
|
||||
{
|
||||
@@ -3117,8 +3154,16 @@ namespace Barotrauma
|
||||
{
|
||||
if (!PlayerInput.PrimaryMouseButtonHeld() || Barotrauma.Inventory.DraggingItemToWorld)
|
||||
{
|
||||
FocusedCharacter = CanInteract || CanEat ? FindCharacterAtPosition(mouseSimPos) : null;
|
||||
if (FocusedCharacter != null && !CanSeeTarget(FocusedCharacter)) { FocusedCharacter = null; }
|
||||
//don't allow focusing on anyone when the health window is open (avoids accidentally selecting someone when closing the window)
|
||||
if (CharacterHealth.OpenHealthWindow != null)
|
||||
{
|
||||
FocusedCharacter = null;
|
||||
}
|
||||
else
|
||||
{
|
||||
FocusedCharacter = CanInteract || CanEat ? FindCharacterAtPosition(mouseSimPos) : null;
|
||||
if (FocusedCharacter != null && !CanSeeTarget(FocusedCharacter)) { FocusedCharacter = null; }
|
||||
}
|
||||
float aimAssist = GameSettings.CurrentConfig.AimAssistAmount * (AnimController.InWater ? 1.5f : 1.0f);
|
||||
if (HeldItems.Any(it => it?.GetComponent<Wire>()?.IsActive ?? false))
|
||||
{
|
||||
@@ -3443,7 +3488,7 @@ namespace Barotrauma
|
||||
|
||||
obstructVisionAmount = Math.Max(obstructVisionAmount - deltaTime, 0.0f);
|
||||
|
||||
if (Inventory != null)
|
||||
if (Inventory != null && Vector2.DistanceSquared(lastInventoryItemSetTransformPosition, Position) > 0.1f)
|
||||
{
|
||||
//do not check for duplicates: this is code is called very frequently, and duplicates don't matter here,
|
||||
//so it's better just to avoid the relatively expensive duplicate check
|
||||
@@ -3452,6 +3497,7 @@ namespace Barotrauma
|
||||
if (item.body == null || item.body.Enabled) { continue; }
|
||||
item.SetTransform(SimPosition, 0.0f, forceSubmarine: Submarine);
|
||||
}
|
||||
lastInventoryItemSetTransformPosition = Position;
|
||||
}
|
||||
|
||||
HideFace = false;
|
||||
@@ -3578,7 +3624,7 @@ namespace Barotrauma
|
||||
{
|
||||
wasRagdolled = IsRagdolled;
|
||||
IsRagdolled = IsKeyDown(InputType.Ragdoll);
|
||||
if (IsRagdolled && IsBot && GameMain.NetworkMember is not { IsClient: true })
|
||||
if (IsRagdolled && !IsPlayer && GameMain.NetworkMember is not { IsClient: true })
|
||||
{
|
||||
ClearInput(InputType.Ragdoll);
|
||||
}
|
||||
@@ -3630,7 +3676,19 @@ namespace Barotrauma
|
||||
AnimController.IgnorePlatforms = true;
|
||||
}
|
||||
AnimController.ResetPullJoints();
|
||||
SelectedItem = SelectedSecondaryItem = null;
|
||||
|
||||
// Prevent us from detaching from the controller if we are attached to it OR detach if we
|
||||
// manually ragdoll, in this case it should be similar to us deselecting the controller
|
||||
if (!IsAttachedToController() ||
|
||||
(IsKeyDown(InputType.Ragdoll)
|
||||
// Let only the server do this check since the Ragdoll input for other clients is set to be held
|
||||
// for stunned characters even if a character isn't manually ragdolling
|
||||
&& (GameMain.NetworkMember == null || GameMain.NetworkMember is { IsServer: true } )))
|
||||
{
|
||||
SelectedItem = null;
|
||||
}
|
||||
|
||||
SelectedSecondaryItem = null;
|
||||
SelectedCharacter = null;
|
||||
return;
|
||||
}
|
||||
@@ -3659,6 +3717,13 @@ namespace Barotrauma
|
||||
bool MustDeselect(Item item)
|
||||
{
|
||||
if (item == null) { return false; }
|
||||
|
||||
// Prevent creatures from deselecting the controller if they are attached to it
|
||||
if (IsAIControlled && !CanInteract && IsAttachedToController())
|
||||
{
|
||||
return false;
|
||||
}
|
||||
|
||||
if (!CanInteractWith(item)) { return true; }
|
||||
bool hasSelectableComponent = false;
|
||||
foreach (var component in item.Components)
|
||||
@@ -4384,6 +4449,41 @@ namespace Barotrauma
|
||||
}
|
||||
}
|
||||
|
||||
public void ForceSay(LocalizedString messageToSay, bool sayInRadio, bool removeQuotes = false, float delay = 0.0f)
|
||||
{
|
||||
if (messageToSay.IsNullOrEmpty() || SpeechImpediment >= 100.0f || IsDead)
|
||||
{
|
||||
return;
|
||||
}
|
||||
|
||||
if (removeQuotes)
|
||||
{
|
||||
messageToSay = new TrimLString(messageToSay,
|
||||
TrimLString.Mode.Both, ['"', '”', '“', ' ']);
|
||||
}
|
||||
|
||||
ChatMessageType messageType = ChatMessageType.Default;
|
||||
bool canUseRadio = ChatMessage.CanUseRadio(this, out WifiComponent radio);
|
||||
if (canUseRadio && sayInRadio)
|
||||
{
|
||||
messageType = ChatMessageType.Radio;
|
||||
}
|
||||
|
||||
CoroutineManager.Invoke(() =>
|
||||
{
|
||||
#if SERVER
|
||||
GameMain.Server?.SendChatMessage(messageToSay.Value, messageType, senderClient: null, this);
|
||||
#elif CLIENT
|
||||
// no need to create the message when playing as a client, the server will send it to us
|
||||
if (GameMain.Client == null)
|
||||
{
|
||||
AIChatMessage message = new AIChatMessage(messageToSay.Value, messageType);
|
||||
SendSinglePlayerMessage(message, canUseRadio, radio);
|
||||
}
|
||||
#endif
|
||||
}, delay);
|
||||
}
|
||||
|
||||
public void SetAllDamage(float damageAmount, float bleedingDamageAmount, float burnDamageAmount)
|
||||
{
|
||||
CharacterHealth.SetAllDamage(damageAmount, bleedingDamageAmount, burnDamageAmount);
|
||||
@@ -4596,12 +4696,6 @@ namespace Barotrauma
|
||||
public AttackResult DamageLimb(Vector2 worldPosition, Limb hitLimb, IEnumerable<Affliction> afflictions, float stun, bool playSound, Vector2 attackImpulse, Character attacker = null, float damageMultiplier = 1, bool allowStacking = true, float penetration = 0f, bool shouldImplode = false, bool ignoreDamageOverlay = false, bool recalculateVitality = true)
|
||||
{
|
||||
if (Removed) { return new AttackResult(); }
|
||||
|
||||
AttackResult? retAttackResult = GameMain.LuaCs.Hook.Call<AttackResult?>("character.damageLimb", this, worldPosition, hitLimb, afflictions, stun, playSound, attackImpulse, attacker, damageMultiplier, allowStacking, penetration, shouldImplode);
|
||||
if (retAttackResult != null)
|
||||
{
|
||||
return retAttackResult.Value;
|
||||
}
|
||||
|
||||
SetStun(stun);
|
||||
|
||||
@@ -4774,6 +4868,10 @@ namespace Barotrauma
|
||||
{
|
||||
if (GameMain.NetworkMember != null && GameMain.NetworkMember.IsClient && !isNetworkMessage) { return; }
|
||||
if (Screen.Selected != GameMain.GameScreen) { return; }
|
||||
//don't allow stunning for less than one frame
|
||||
//fixes monsters/enemies that take some minuscule amount of stun from a weapon still being noticeable affected by the stun,
|
||||
//because even a one-frame stun briefly disables the animations and makes the character stop
|
||||
if (newStun < Timing.Step && Stun <= 0.0f) { return; }
|
||||
if (GodMode)
|
||||
{
|
||||
CharacterHealth.Stun = 0;
|
||||
@@ -4801,7 +4899,12 @@ namespace Barotrauma
|
||||
CharacterHealth.Stun = newStun;
|
||||
if (newStun > 0.0f)
|
||||
{
|
||||
SelectedItem = SelectedSecondaryItem = null;
|
||||
if (!IsAttachedToController())
|
||||
{
|
||||
SelectedItem = null;
|
||||
}
|
||||
|
||||
SelectedSecondaryItem = null;
|
||||
if (SelectedCharacter != null) { DeselectCharacter(); }
|
||||
}
|
||||
HealthUpdateInterval = 0.0f;
|
||||
@@ -4990,6 +5093,37 @@ namespace Barotrauma
|
||||
}
|
||||
}
|
||||
|
||||
public bool IsAttachedToController()
|
||||
{
|
||||
if (SelectedItem == null) { return false; }
|
||||
|
||||
var controller = SelectedItem.GetComponent<Controller>();
|
||||
if (controller == null) { return false; }
|
||||
|
||||
return controller.IsAttachedUser(this);
|
||||
}
|
||||
|
||||
public bool ShouldAvoidStayingAttachedToController()
|
||||
{
|
||||
if (!IsAttachedToController()) { return false; }
|
||||
|
||||
var deconstructor = SelectedItem.GetComponent<Deconstructor>();
|
||||
if (deconstructor != null)
|
||||
{
|
||||
return true;
|
||||
}
|
||||
|
||||
// Character is being carried by an enemy!
|
||||
if (IsHuman &&
|
||||
SelectedItem.GetRootInventoryOwner() is Character carryingCharacter &&
|
||||
TeamID != carryingCharacter.TeamID)
|
||||
{
|
||||
return true;
|
||||
}
|
||||
|
||||
return false;
|
||||
}
|
||||
|
||||
public void Kill(CauseOfDeathType causeOfDeath, Affliction causeOfDeathAffliction, bool isNetworkMessage = false, bool log = true)
|
||||
{
|
||||
if (IsDead || CharacterHealth.Unkillable || GodMode || Removed) { return; }
|
||||
@@ -5117,7 +5251,6 @@ namespace Barotrauma
|
||||
AchievementManager.OnCharacterKilled(this, CauseOfDeath);
|
||||
}
|
||||
|
||||
GameMain.LuaCs.Hook.Call("character.death", this, causeOfDeathAffliction);
|
||||
KillProjSpecific(causeOfDeath, causeOfDeathAffliction, log);
|
||||
|
||||
if (info != null)
|
||||
@@ -5128,7 +5261,7 @@ namespace Barotrauma
|
||||
AnimController.movement = Vector2.Zero;
|
||||
AnimController.TargetMovement = Vector2.Zero;
|
||||
|
||||
if (!LockHands)
|
||||
if (!LockHands && causeOfDeath != CauseOfDeathType.Disconnected)
|
||||
{
|
||||
foreach (Item heldItem in HeldItems.ToList())
|
||||
{
|
||||
|
||||
@@ -1,5 +1,6 @@
|
||||
using System;
|
||||
using System.Collections.Generic;
|
||||
using System.Collections.Immutable;
|
||||
using System.Linq;
|
||||
using System.Xml.Linq;
|
||||
using Microsoft.Xna.Framework;
|
||||
|
||||
@@ -482,7 +482,6 @@ namespace Barotrauma
|
||||
{
|
||||
GrainEffectStrength -= amount;
|
||||
}
|
||||
GameMain.LuaCs.Hook.Call("afflictionUpdate", new object[] { this, characterHealth, targetLimb, deltaTime });
|
||||
}
|
||||
|
||||
public void ApplyStatusEffects(ActionType type, float deltaTime, CharacterHealth characterHealth, Limb targetLimb)
|
||||
|
||||
+3
-2
@@ -4,6 +4,7 @@ using System.Xml.Linq;
|
||||
using System;
|
||||
using Barotrauma.Extensions;
|
||||
using Microsoft.Xna.Framework;
|
||||
using Barotrauma.LuaCs.Events;
|
||||
|
||||
namespace Barotrauma
|
||||
{
|
||||
@@ -337,13 +338,13 @@ namespace Barotrauma
|
||||
|
||||
if (Prefab is AfflictionPrefabHusk huskPrefab)
|
||||
{
|
||||
if (huskPrefab.ControlHusk || GameMain.LuaCs.Game.enableControlHusk)
|
||||
if (huskPrefab.ControlHusk || LuaCsSetup.Instance.Game.enableControlHusk)
|
||||
{
|
||||
#if SERVER
|
||||
if (client != null)
|
||||
{
|
||||
GameMain.Server.SetClientCharacter(client, husk);
|
||||
GameMain.LuaCs.Hook.Call("husk.clientControlHusk", new object[] { client, husk });
|
||||
LuaCsSetup.Instance.EventService.PublishEvent<IEventClientControlHusk>(x => x.OnClientControlHusk(client, husk));
|
||||
}
|
||||
#else
|
||||
if (!character.IsRemotelyControlled && character == Character.Controlled)
|
||||
|
||||
+1
-1
@@ -629,7 +629,7 @@ namespace Barotrauma
|
||||
public static readonly Identifier StunType = "stun".ToIdentifier();
|
||||
public static readonly Identifier EMPType = "emp".ToIdentifier();
|
||||
public static readonly Identifier SpaceHerpesType = "spaceherpes".ToIdentifier();
|
||||
public static readonly Identifier AlienInfectedType = "alieninfected".ToIdentifier();
|
||||
public static readonly Identifier AlienInfectionType = "alieninfection".ToIdentifier();
|
||||
public static readonly Identifier InvertControlsType = "invertcontrols".ToIdentifier();
|
||||
public static readonly Identifier DisguisedAsHuskType = "disguiseashusk".ToIdentifier();
|
||||
|
||||
|
||||
@@ -1,17 +1,19 @@
|
||||
using Barotrauma.Abilities;
|
||||
using Barotrauma.Abilities;
|
||||
using Barotrauma.Extensions;
|
||||
using Barotrauma.Extensions;
|
||||
using Barotrauma.LuaCs.Events;
|
||||
using Barotrauma.Networking;
|
||||
using Barotrauma.Networking;
|
||||
using Microsoft.Xna.Framework;
|
||||
using MoonSharp.Interpreter;
|
||||
using System;
|
||||
using System.Collections.Generic;
|
||||
using System.Globalization;
|
||||
using System.Globalization;
|
||||
using System.Linq;
|
||||
using System.Xml.Linq;
|
||||
using Barotrauma.Networking;
|
||||
using Barotrauma.Extensions;
|
||||
using System.Globalization;
|
||||
using MoonSharp.Interpreter;
|
||||
using Barotrauma.Abilities;
|
||||
using static OneOf.Types.TrueFalseOrNull;
|
||||
|
||||
namespace Barotrauma
|
||||
{
|
||||
@@ -657,7 +659,8 @@ namespace Barotrauma
|
||||
return;
|
||||
}
|
||||
|
||||
var should = GameMain.LuaCs.Hook.Call<bool?>("character.applyDamage", this, attackResult, hitLimb, allowStacking);
|
||||
bool? should = null;
|
||||
LuaCsSetup.Instance.EventService.PublishEvent<IEventCharacterApplyDamage>(x => should = x.OnCharacterApplyDamage(this, attackResult, hitLimb, allowStacking) ?? should);
|
||||
if (should != null && should.Value) { return; }
|
||||
|
||||
foreach (Affliction newAffliction in attackResult.Afflictions)
|
||||
@@ -828,10 +831,9 @@ namespace Barotrauma
|
||||
if (newAffliction.Prefab.TargetSpecies.Any() && newAffliction.Prefab.TargetSpecies.None(s => s == Character.SpeciesName)) { return; }
|
||||
if (Character.Params.Health.ImmunityIdentifiers.Contains(newAffliction.Identifier)) { return; }
|
||||
|
||||
var should = GameMain.LuaCs.Hook.Call<bool?>("character.applyAffliction", this, limbHealth, newAffliction, allowStacking);
|
||||
|
||||
if (should != null && should.Value)
|
||||
return;
|
||||
bool? should = null;
|
||||
LuaCsSetup.Instance.EventService.PublishEvent<IEventCharacterApplyAffliction>(x => should = x.OnCharacterApplyAffliction(this, limbHealth, newAffliction, allowStacking) ?? should);
|
||||
if (should != null && should.Value) { return; }
|
||||
|
||||
Affliction existingAffliction = null;
|
||||
foreach ((Affliction affliction, LimbHealth value) in afflictions)
|
||||
@@ -843,9 +845,21 @@ namespace Barotrauma
|
||||
}
|
||||
}
|
||||
|
||||
float modifiedStrength = newAffliction.Strength * (100.0f / MaxVitality) * (1f - GetResistance(newAffliction.Prefab, limbType));
|
||||
if (newAffliction.Prefab.AfflictionType == AfflictionPrefab.StunType)
|
||||
{
|
||||
//don't allow stunning for less than one frame
|
||||
//fixes monsters/enemies that take some minuscule amount of stun from a weapon still being noticeable affected by the stun,
|
||||
//because even a one-frame stun briefly disables the animations and makes the character stop
|
||||
if (modifiedStrength < Timing.Step && Stun <= 0.0f)
|
||||
{
|
||||
return;
|
||||
}
|
||||
}
|
||||
|
||||
if (existingAffliction != null)
|
||||
{
|
||||
float newStrength = newAffliction.Strength * (100.0f / MaxVitality) * (1f - GetResistance(existingAffliction.Prefab, limbType));
|
||||
float newStrength = modifiedStrength;
|
||||
if (allowStacking)
|
||||
{
|
||||
// Add the existing strength
|
||||
@@ -867,7 +881,7 @@ namespace Barotrauma
|
||||
//create a new instance of the affliction to make sure we don't use the same instance for multiple characters
|
||||
//or modify the affliction instance of an Attack or a StatusEffect
|
||||
var copyAffliction = newAffliction.Prefab.Instantiate(
|
||||
Math.Min(newAffliction.Prefab.MaxStrength, newAffliction.Strength * (100.0f / MaxVitality) * (1f - GetResistance(newAffliction.Prefab, limbType))),
|
||||
Math.Min(newAffliction.Prefab.MaxStrength, modifiedStrength),
|
||||
newAffliction.Source);
|
||||
afflictions.Add(copyAffliction, limbHealth);
|
||||
AchievementManager.OnAfflictionReceived(copyAffliction, Character);
|
||||
|
||||
@@ -190,7 +190,7 @@ namespace Barotrauma
|
||||
idleObjective.PreferredOutpostModuleTypes.Add(moduleType);
|
||||
}
|
||||
}
|
||||
humanAI.ReportRange = Hearing;
|
||||
humanAI.Hearing = Hearing;
|
||||
humanAI.ReportRange = ReportRange;
|
||||
humanAI.FindWeaponsRange = FindWeaponsRange;
|
||||
humanAI.AimSpeed = AimSpeed;
|
||||
|
||||
@@ -1293,7 +1293,7 @@ namespace Barotrauma
|
||||
if (!statusEffects.TryGetValue(actionType, out var statusEffectList)) { return; }
|
||||
foreach (StatusEffect statusEffect in statusEffectList)
|
||||
{
|
||||
if (statusEffect.ShouldWaitForInterval(character, deltaTime)) { return; }
|
||||
if (statusEffect.ShouldWaitForInterval(character, deltaTime)) { continue; }
|
||||
|
||||
statusEffect.sourceBody = body;
|
||||
if (statusEffect.type == ActionType.OnDamaged)
|
||||
|
||||
@@ -728,7 +728,9 @@ namespace Barotrauma
|
||||
[Serialize(true, IsPropertySaveable.Yes, description: "Should the character target or ignore walls when it's outside the submarine."), Editable]
|
||||
public bool TargetOuterWalls { get; private set; }
|
||||
|
||||
[Serialize(false, IsPropertySaveable.Yes, description: "If enabled, the character chooses randomly from the available attacks. The priority is used as a weight for weighted random."), Editable]
|
||||
[Serialize(false, IsPropertySaveable.Yes, description: "If disabled (default), the character selects the limb based on a formula where the parameters are a) the priority of the attack b) the distance to the target, and c) the range of the attack" +
|
||||
"If enabled, the character chooses randomly from the available attacks. The priority is used as a weight for weighted random. The distance to the target is in this case ignored."
|
||||
), Editable]
|
||||
public bool RandomAttack { get; private set; }
|
||||
|
||||
[Serialize(false, IsPropertySaveable.Yes, description:"Does the creature know how to open doors (still requires a proper ID card). Humans can always open doors (They don't use this AI definition)."), Editable]
|
||||
|
||||
@@ -77,8 +77,8 @@ namespace Barotrauma
|
||||
}
|
||||
else
|
||||
{
|
||||
conn.SetLabel(conn.Connection.DisplayName, this);
|
||||
conn.Connection.DisplayNameOverride = null;
|
||||
conn.SetLabel(conn.Connection.DisplayName, this);
|
||||
}
|
||||
}
|
||||
#endif
|
||||
|
||||
+3
-2
@@ -106,9 +106,10 @@ namespace Barotrauma
|
||||
void AddTexturePath(string path)
|
||||
{
|
||||
if (string.IsNullOrEmpty(path)) { return; }
|
||||
var contentPath = ContentPath.FromRaw(characterPrefab.ContentPackage, ragdollParams.Texture);
|
||||
//if the path contains a gender variable, we can't load it yet because we don't know which gender we need
|
||||
if (path.Contains("[GENDER]")) { return; }
|
||||
texturePaths.Add(ContentPath.FromRaw(characterPrefab.ContentPackage, ragdollParams.Texture));
|
||||
if (contentPath.FullPath.Contains("[GENDER]")) { return; }
|
||||
texturePaths.Add(contentPath);
|
||||
}
|
||||
}
|
||||
#endif
|
||||
|
||||
+9
-2
@@ -199,9 +199,16 @@ namespace Barotrauma
|
||||
|
||||
try
|
||||
{
|
||||
return success(doc.Root.GetAttributeBool("corepackage", false)
|
||||
ContentPackage contentPackage = doc.Root.GetAttributeBool("corepackage", false)
|
||||
? new CorePackage(doc, path)
|
||||
: new RegularPackage(doc, path));
|
||||
: new RegularPackage(doc, path);
|
||||
|
||||
if (System.IO.Path.GetFileNameWithoutExtension(path)?.Any(char.IsUpper) is true)
|
||||
{
|
||||
DebugConsole.ThrowError($"Invalid filename casing. Please rename \"filelist.xml\" so it is entirely lowercase.", contentPackage: contentPackage);
|
||||
}
|
||||
|
||||
return success(contentPackage);
|
||||
}
|
||||
catch (Exception e)
|
||||
{
|
||||
|
||||
+15
-3
@@ -9,8 +9,10 @@ using System.Diagnostics.CodeAnalysis;
|
||||
using System.Linq;
|
||||
using System.Xml.Linq;
|
||||
using Barotrauma.IO;
|
||||
using Barotrauma.LuaCs.Events;
|
||||
using Barotrauma.Steam;
|
||||
using Microsoft.Xna.Framework;
|
||||
using OneOf.Types;
|
||||
|
||||
namespace Barotrauma
|
||||
{
|
||||
@@ -48,7 +50,10 @@ namespace Barotrauma
|
||||
public static ImmutableArray<RegularPackage>? Regular;
|
||||
}
|
||||
|
||||
public static void SetCore(CorePackage newCore) => SetCoreEnumerable(newCore).Consume();
|
||||
public static void SetCore(CorePackage newCore)
|
||||
{
|
||||
SetCoreEnumerable(newCore).Consume();
|
||||
}
|
||||
|
||||
public static IEnumerable<LoadProgress> SetCoreEnumerable(CorePackage newCore)
|
||||
{
|
||||
@@ -85,7 +90,9 @@ namespace Barotrauma
|
||||
}
|
||||
|
||||
public static void SetRegular(IReadOnlyList<RegularPackage> newRegular)
|
||||
=> SetRegularEnumerable(newRegular).Consume();
|
||||
{
|
||||
SetRegularEnumerable(newRegular).Consume();
|
||||
}
|
||||
|
||||
public static IEnumerable<LoadProgress> SetRegularEnumerable(IReadOnlyList<RegularPackage> inNewRegular)
|
||||
{
|
||||
@@ -583,6 +590,11 @@ namespace Barotrauma
|
||||
package.UgcId.TryUnwrap(out var ugcId) && ugcId is SteamWorkshopId workshopId && workshopId.Value == childUgcItemId.Value));
|
||||
foreach (var missingChild in missingChildren)
|
||||
{
|
||||
if (missingChild.ToString() == "2559634234" ||
|
||||
missingChild.ToString() == "2795927223")
|
||||
{
|
||||
continue;
|
||||
}
|
||||
enabledPackage.AddMissingDependency(missingChild);
|
||||
}
|
||||
});
|
||||
@@ -597,4 +609,4 @@ namespace Barotrauma
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
@@ -99,12 +99,13 @@ namespace Barotrauma
|
||||
public static ContentPath FromRaw(ContentPackage? contentPackage, string? rawValue)
|
||||
{
|
||||
var newRaw = new ContentPath(contentPackage, rawValue);
|
||||
if (prevCreatedRaw is not null && prevCreatedRaw.ContentPackage == contentPackage &&
|
||||
// Removed as this almost never happens but makes the constructor not thread-safe.
|
||||
/*if (prevCreatedRaw is not null && prevCreatedRaw.ContentPackage == contentPackage &&
|
||||
prevCreatedRaw.RawValue == rawValue)
|
||||
{
|
||||
newRaw.cachedValue = prevCreatedRaw.Value;
|
||||
}
|
||||
prevCreatedRaw = newRaw;
|
||||
prevCreatedRaw = newRaw;*/
|
||||
return newRaw;
|
||||
}
|
||||
|
||||
@@ -158,4 +159,4 @@ namespace Barotrauma
|
||||
|
||||
public override string? ToString() => Value;
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
@@ -2311,6 +2311,8 @@ namespace Barotrauma
|
||||
NewMessage($"Start item set changed to \"{AutoItemPlacer.DefaultStartItemSet}\"");
|
||||
}, isCheat: false));
|
||||
|
||||
|
||||
|
||||
//"dummy commands" that only exist so that the server can give clients permissions to use them
|
||||
//TODO: alphabetical order?
|
||||
commands.Add(new Command("control", "control [character name]: Start controlling the specified character (client-only).", null, () =>
|
||||
@@ -3020,7 +3022,10 @@ namespace Barotrauma
|
||||
switch (args[argIndex].ToLowerInvariant())
|
||||
{
|
||||
case "inside":
|
||||
spawnPoint = WayPoint.GetRandom(SpawnType.Human, job, Submarine.MainSub);
|
||||
spawnPoint =
|
||||
WayPoint.GetRandom(SpawnType.Human, job, Submarine.MainSub) ??
|
||||
//try a non-job-specific spawnpoint if a job-specific one can't be found
|
||||
WayPoint.GetRandom(SpawnType.Human, assignedJob: null, Submarine.MainSub);
|
||||
break;
|
||||
case "outside":
|
||||
spawnPoint = WayPoint.GetRandom(SpawnType.Enemy);
|
||||
|
||||
@@ -34,11 +34,12 @@ namespace Barotrauma
|
||||
get { return Prefab.LifeTime; }
|
||||
}
|
||||
|
||||
private float baseAlpha = 1.0f;
|
||||
public float BaseAlpha
|
||||
{
|
||||
get;
|
||||
set;
|
||||
} = 1.0f;
|
||||
get => baseAlpha;
|
||||
set => baseAlpha = MathHelper.Clamp(value, 0f, 1f);
|
||||
}
|
||||
|
||||
public Color Color
|
||||
{
|
||||
|
||||
@@ -131,6 +131,14 @@ namespace Barotrauma
|
||||
/// </summary>
|
||||
OnRemoved = 25,
|
||||
/// <summary>
|
||||
/// Executes continuously while the item/character is being deconstructed.
|
||||
/// </summary>
|
||||
OnDeconstructing = 26,
|
||||
/// <summary>
|
||||
/// Executed once when the item/character is deconstructed.
|
||||
/// </summary>
|
||||
OnDeconstructed = 27,
|
||||
/// <summary>
|
||||
/// Executes when the character dies. Only valid for characters.
|
||||
/// </summary>
|
||||
OnDeath = OnBroken
|
||||
|
||||
@@ -12,7 +12,11 @@ namespace Barotrauma
|
||||
public readonly int RandomSeed;
|
||||
|
||||
protected readonly EventPrefab prefab;
|
||||
|
||||
|
||||
#nullable enable
|
||||
public Mission? TriggeringMission;
|
||||
#nullable restore
|
||||
|
||||
public EventPrefab Prefab => prefab;
|
||||
|
||||
public EventSet ParentSet { get; private set; }
|
||||
|
||||
+5
-3
@@ -29,6 +29,9 @@ namespace Barotrauma
|
||||
[Serialize("", IsPropertySaveable.Yes, description: "Tag to apply to the target (or all targets if there's multiple) when the check succeeds.")]
|
||||
public Identifier ApplyTagToTarget { get; set; }
|
||||
|
||||
[Serialize(true, IsPropertySaveable.Yes, description: "Should the check fail if no targets matching the specified tag are found?")]
|
||||
public bool FailIfTargetNotFound { get; set; }
|
||||
|
||||
public CheckConditionalAction(ScriptedEvent parentEvent, ContentXElement element) : base(parentEvent, element)
|
||||
{
|
||||
if (TargetTag.IsEmpty)
|
||||
@@ -79,11 +82,10 @@ namespace Barotrauma
|
||||
|
||||
if (targets.None())
|
||||
{
|
||||
DebugConsole.LogError($"{nameof(CheckConditionalAction)} error: {GetEventDebugName()} uses a {nameof(CheckConditionalAction)} but no valid target was found for tag \"{TargetTag}\"! This will cause the check to automatically succeed.",
|
||||
contentPackage: ParentEvent.Prefab.ContentPackage);
|
||||
return !FailIfTargetNotFound;
|
||||
}
|
||||
|
||||
if (targets.None() || Conditionals.None())
|
||||
if (Conditionals.None())
|
||||
{
|
||||
foreach (var target in targets)
|
||||
{
|
||||
|
||||
@@ -14,6 +14,33 @@ namespace Barotrauma
|
||||
/// </summary>
|
||||
partial class ConversationAction : EventAction
|
||||
{
|
||||
public class OptionActionGroup : SubactionGroup
|
||||
{
|
||||
[Serialize("", IsPropertySaveable.Yes, description: "The text to display in the option.")]
|
||||
public string Text { get; set; }
|
||||
|
||||
[Serialize(false, IsPropertySaveable.Yes, description: "Should this option end the conversation (closing the conversation prompt?). " +
|
||||
"By default, options that don't have any actions inside them, or that only have a GoTo action, end the conversation. " +
|
||||
"But if there are other actions inside the option, the game assumes there may be some kind of a follow-up coming to the conversation, " +
|
||||
"and by default leaves it open.")]
|
||||
public bool EndConversation { get; set; }
|
||||
|
||||
[Serialize(false, IsPropertySaveable.Yes, description: $"If enabled, the player will send the {nameof(Text)} in chat when selecting the option, or if {nameof(ForceSayText)} is not empty, will send that instead.")]
|
||||
public bool ForceSay { get; set; }
|
||||
|
||||
[Serialize(false, IsPropertySaveable.Yes, description: "If enabled, the message sent in chat will be sent in radio chat instead.")]
|
||||
public bool ForceSayInRadio { get; set; }
|
||||
|
||||
[Serialize("", IsPropertySaveable.Yes, description: $"Message sent in chat, if empty, {nameof(Text)} is used instead.")]
|
||||
public string ForceSayText { get; set; }
|
||||
|
||||
[Serialize(true, IsPropertySaveable.Yes, description: "Should the chat message be stripped of any quotation mark characters?")]
|
||||
public bool ForceSayRemoveQuotes { get; set; }
|
||||
|
||||
public OptionActionGroup(ScriptedEvent scriptedEvent, ContentXElement element) : base(scriptedEvent, element)
|
||||
{
|
||||
}
|
||||
}
|
||||
|
||||
public enum DialogTypes
|
||||
{
|
||||
@@ -33,6 +60,18 @@ namespace Barotrauma
|
||||
[Serialize("", IsPropertySaveable.Yes, description: "The text to display in the prompt. Can be the text as-is, or a tag referring to a line in a text file.")]
|
||||
public string Text { get; set; }
|
||||
|
||||
[Serialize(false, IsPropertySaveable.Yes, description: $"If enabled, the speaker will send the {nameof(Text)} in chat, or if {nameof(ForceSayText)} is not empty, will send that instead. Note: requires a valid SpeakerTag to be defined.")]
|
||||
public bool ForceSay { get; set; }
|
||||
|
||||
[Serialize(false, IsPropertySaveable.Yes, description: "If enabled, the message sent in chat by the speaker will be sent in radio chat instead.")]
|
||||
public bool ForceSayInRadio { get; set; }
|
||||
|
||||
[Serialize("", IsPropertySaveable.Yes, description: $"Message sent in chat by the speaker, if empty, {nameof(Text)} is used instead.")]
|
||||
public string ForceSayText { get; set; }
|
||||
|
||||
[Serialize(true, IsPropertySaveable.Yes, description: "Should the chat message be stripped of any quotation mark characters?")]
|
||||
public bool ForceSayRemoveQuotes { get; set; }
|
||||
|
||||
[Serialize("", IsPropertySaveable.Yes, description: "Tag of the character who's speaking. Makes a speech bubble icon appear above the character to indicate you can speak with them, and stops the character in place when the conversation triggers. Also allows the conversation to be interrupted if the speaker dies or becomes incapacitated mid-conversation.")]
|
||||
public Identifier SpeakerTag { get; set; }
|
||||
|
||||
@@ -75,7 +114,7 @@ namespace Barotrauma
|
||||
private AIObjective prevIdleObjective, prevGotoObjective;
|
||||
private AIObjective npcWaitObjective;
|
||||
|
||||
public List<SubactionGroup> Options { get; private set; }
|
||||
public List<OptionActionGroup> Options { get; private set; }
|
||||
|
||||
public SubactionGroup Interrupted { get; private set; }
|
||||
|
||||
@@ -99,12 +138,12 @@ namespace Barotrauma
|
||||
{
|
||||
actionCount++;
|
||||
Identifier = actionCount;
|
||||
Options = new List<SubactionGroup>();
|
||||
Options = new List<OptionActionGroup>();
|
||||
foreach (var elem in element.Elements())
|
||||
{
|
||||
if (elem.Name.LocalName.Equals("option", StringComparison.OrdinalIgnoreCase))
|
||||
{
|
||||
Options.Add(new SubactionGroup(ParentEvent, elem));
|
||||
Options.Add(new OptionActionGroup(ParentEvent, elem));
|
||||
}
|
||||
else if (elem.Name.LocalName.Equals("interrupt", StringComparison.OrdinalIgnoreCase))
|
||||
{
|
||||
@@ -215,6 +254,10 @@ namespace Barotrauma
|
||||
interrupt = false;
|
||||
dialogOpened = false;
|
||||
Speaker = null;
|
||||
#if CLIENT
|
||||
dialogBox?.Close();
|
||||
dialogBox = null;
|
||||
#endif
|
||||
}
|
||||
|
||||
/// <summary>
|
||||
@@ -292,6 +335,7 @@ namespace Barotrauma
|
||||
if (dialogOpened)
|
||||
{
|
||||
lastActiveTime = Timing.TotalTime;
|
||||
|
||||
#if CLIENT
|
||||
if (GUIMessageBox.MessageBoxes.Any(mb => mb.UserData as string == "ConversationAction"))
|
||||
{
|
||||
@@ -350,7 +394,7 @@ namespace Barotrauma
|
||||
}
|
||||
else
|
||||
{
|
||||
TryStartConversation(null);
|
||||
TryStartConversation(Speaker);
|
||||
}
|
||||
}
|
||||
else
|
||||
@@ -467,11 +511,26 @@ namespace Barotrauma
|
||||
ParentEvent.AddTarget(InvokerTag, targetCharacter);
|
||||
}
|
||||
|
||||
ShowDialog(speaker, targetCharacter);
|
||||
if (ForceSay)
|
||||
{
|
||||
speaker?.ForceSay(
|
||||
ForceSayText.IsNullOrEmpty() ? TextManager.Get(Text).Fallback(Text) : TextManager.Get(ForceSayText).Fallback(ForceSayText),
|
||||
ForceSayInRadio,
|
||||
ForceSayRemoveQuotes,
|
||||
// Small delay so the speaking character doesn't talk at the same time as the player
|
||||
delay: 0.7f);
|
||||
}
|
||||
|
||||
ShowDialog(Speaker, targetCharacter);
|
||||
|
||||
dialogOpened = true;
|
||||
if (speaker != null)
|
||||
if (Speaker != null)
|
||||
{
|
||||
Speaker = speaker;
|
||||
|
||||
// Set the Speaker of the child conversation actions so they know which character is speaking
|
||||
Options.SelectMany(static op => op.Actions).OfType<ConversationAction>().ForEach(action => action.Speaker = speaker);
|
||||
|
||||
speaker.CampaignInteractionType = CampaignMode.InteractionType.None;
|
||||
speaker.SetCustomInteract(null, null);
|
||||
#if SERVER
|
||||
|
||||
@@ -99,6 +99,7 @@ namespace Barotrauma
|
||||
else
|
||||
{
|
||||
int compareToTargetCount = ParentEvent.GetTargets(CompareToTarget).Count();
|
||||
if (compareToTargetCount == 0) { return false; }
|
||||
float percentage = MathUtils.Percentage(targetCount, compareToTargetCount);
|
||||
if (MinPercentageRelativeToTarget > -1 && percentage < MinPercentageRelativeToTarget) { return false; }
|
||||
if (MaxPercentageRelativeToTarget > -1 && percentage > MaxPercentageRelativeToTarget) { return false; }
|
||||
|
||||
@@ -9,14 +9,7 @@ namespace Barotrauma
|
||||
{
|
||||
public class SubactionGroup
|
||||
{
|
||||
public string Text;
|
||||
public List<EventAction> Actions;
|
||||
/// <summary>
|
||||
/// Should this option end the conversation (closing the conversation prompt?). By default, options that don't have any actions inside them, or that only have a GoTo action, end the conversation.
|
||||
/// But if there are other actions inside the option, the game assumes there may be some kind of a follow-up coming to the conversation, and by default leaves it open.
|
||||
/// </summary>
|
||||
public bool EndConversation;
|
||||
|
||||
private int currentSubAction = 0;
|
||||
|
||||
public EventAction CurrentSubAction
|
||||
@@ -31,17 +24,17 @@ namespace Barotrauma
|
||||
}
|
||||
}
|
||||
|
||||
public SubactionGroup(ScriptedEvent scriptedEvent, ContentXElement elem)
|
||||
public SubactionGroup(ScriptedEvent scriptedEvent, ContentXElement element)
|
||||
{
|
||||
Text = elem.GetAttribute("text")?.Value ?? "";
|
||||
SerializableProperty.DeserializeProperties(this, element);
|
||||
|
||||
Actions = new List<EventAction>();
|
||||
EndConversation = elem.GetAttributeBool("endconversation", false);
|
||||
foreach (var e in elem.Elements())
|
||||
foreach (var e in element.Elements())
|
||||
{
|
||||
if (e.Name.ToString().Equals("statuseffect", StringComparison.OrdinalIgnoreCase))
|
||||
{
|
||||
DebugConsole.ThrowError($"Error in event prefab \"{scriptedEvent.Prefab.Identifier}\". Status effect configured as a sub action (text: \"{Text}\"). Please configure status effects as child elements of a StatusEffectAction.",
|
||||
contentPackage: elem.ContentPackage);
|
||||
DebugConsole.ThrowError($"Error in event prefab \"{scriptedEvent.Prefab.Identifier}\". Status effect configured as a sub action. Please configure status effects as child elements of a StatusEffectAction.",
|
||||
contentPackage: element.ContentPackage);
|
||||
continue;
|
||||
}
|
||||
var action = Instantiate(scriptedEvent, e);
|
||||
|
||||
@@ -0,0 +1,62 @@
|
||||
using Barotrauma.Items.Components;
|
||||
using Barotrauma.Networking;
|
||||
using System.Linq;
|
||||
|
||||
namespace Barotrauma
|
||||
{
|
||||
/// <summary>
|
||||
/// Forces a specific character to say a message in chat.
|
||||
/// </summary>
|
||||
class ForceSayAction : EventAction
|
||||
{
|
||||
[Serialize("", IsPropertySaveable.Yes, description: "Tag of the character that should say the message.")]
|
||||
public Identifier TargetTag { get; set; }
|
||||
|
||||
[Serialize("", IsPropertySaveable.Yes, description: "The message that the character should say. Can be the text as-is, or a tag referring to a line in a text file.")]
|
||||
public string Message { get; set; }
|
||||
|
||||
[Serialize(false, IsPropertySaveable.Yes, description: "Should the message that the character says be sent in radio?")]
|
||||
public bool SayInRadio { get; set; }
|
||||
|
||||
[Serialize(true, IsPropertySaveable.Yes, description: "Should the message be stripped of any quotation mark characters?")]
|
||||
public bool RemoveQuotes { get; set; }
|
||||
|
||||
public ForceSayAction(ScriptedEvent parentEvent, ContentXElement element) : base(parentEvent, element) { }
|
||||
|
||||
private bool isFinished = false;
|
||||
|
||||
public override bool IsFinished(ref string goTo)
|
||||
{
|
||||
return isFinished;
|
||||
}
|
||||
|
||||
public override void Reset()
|
||||
{
|
||||
isFinished = false;
|
||||
}
|
||||
|
||||
public override void Update(float deltaTime)
|
||||
{
|
||||
if (isFinished) { return; }
|
||||
|
||||
var targets = ParentEvent.GetTargets(TargetTag);
|
||||
|
||||
LocalizedString messageToSay = TextManager.Get(Message).Fallback(Message);
|
||||
foreach (var target in targets)
|
||||
{
|
||||
if (target != null && target is Character character)
|
||||
{
|
||||
character.ForceSay(messageToSay, SayInRadio, RemoveQuotes);
|
||||
}
|
||||
}
|
||||
|
||||
isFinished = true;
|
||||
}
|
||||
|
||||
public override string ToDebugString()
|
||||
{
|
||||
return $"{ToolBox.GetDebugSymbol(isFinished)} {nameof(ForceSayAction)} -> (TargetTag: {TargetTag.ColorizeObject()}, " +
|
||||
$"Message: {Message})";
|
||||
}
|
||||
}
|
||||
}
|
||||
+58
-65
@@ -1,84 +1,77 @@
|
||||
namespace Barotrauma
|
||||
#nullable enable
|
||||
namespace Barotrauma;
|
||||
|
||||
/// <summary>Changes the state of missions. The way the states are used depends on the type of mission.</summary>
|
||||
internal sealed class MissionStateAction : EventAction
|
||||
{
|
||||
|
||||
/// <summary>
|
||||
/// Changes the state of a specific active mission. The way the states are used depends on the type of mission.
|
||||
/// </summary>
|
||||
class MissionStateAction : EventAction
|
||||
/// <summary>The operation to perform on missions' states.</summary>
|
||||
public enum OperationType
|
||||
{
|
||||
[Serialize("", IsPropertySaveable.Yes, description: "Identifier of the mission whose state to change.")]
|
||||
public Identifier MissionIdentifier { get; set; }
|
||||
/// <summary>Sets the missions' states to <see cref="State"/>.</summary>
|
||||
Set,
|
||||
/// <summary>Adds <see cref="State"/> to the missions' states.</summary>
|
||||
Add
|
||||
}
|
||||
|
||||
public enum OperationType
|
||||
[Serialize("", IsPropertySaveable.Yes, "Identifiers of the missions whose states to change. Leave blank to only set the state of the mission that triggered the parent event.")]
|
||||
public Identifier MissionIdentifier { get; set; }
|
||||
|
||||
[Serialize(OperationType.Set, IsPropertySaveable.Yes, "The operation to perform on missions' states.")]
|
||||
public OperationType Operation { get; set; }
|
||||
|
||||
[Serialize(0, IsPropertySaveable.Yes, "The value to apply to missions' states.")]
|
||||
public int State { get; set; }
|
||||
|
||||
[Serialize(false, IsPropertySaveable.Yes, "If set to true, missions are forced to fail without a chance of retrying them.")]
|
||||
public bool ForceFailure { get; set; }
|
||||
|
||||
public MissionStateAction(ScriptedEvent parentEvent, ContentXElement element) : base(parentEvent, element)
|
||||
{
|
||||
State = element.GetAttributeInt("value", State);
|
||||
if (Operation == OperationType.Add && State == 0 && !ForceFailure)
|
||||
{
|
||||
Set,
|
||||
Add
|
||||
DebugConsole.AddWarning($"Potential error in event \"{parentEvent.Prefab.Identifier}\": {nameof(MissionStateAction)} is set to only add 0 to the mission state, which will do nothing.",
|
||||
contentPackage: element.ContentPackage);
|
||||
}
|
||||
}
|
||||
|
||||
[Serialize(OperationType.Set, IsPropertySaveable.Yes, description: "Should the value be added to the state of the mission, or should the state be set to the specified value.")]
|
||||
public OperationType Operation { get; set; }
|
||||
private bool isFinished;
|
||||
public override bool IsFinished(ref string goTo) => isFinished;
|
||||
public override void Reset() => isFinished = false;
|
||||
|
||||
[Serialize(0, IsPropertySaveable.Yes, description: "The state to set the mission to, or how much to add to the state of the mission.")]
|
||||
public int State { get; set; }
|
||||
public override void Update(float deltaTime)
|
||||
{
|
||||
if (isFinished) { return; }
|
||||
|
||||
[Serialize(false, IsPropertySaveable.Yes, description: "If set to true, the mission is forced to fail without a chance of retrying it.")]
|
||||
public bool ForceFailure { get; set; }
|
||||
|
||||
private bool isFinished;
|
||||
|
||||
public MissionStateAction(ScriptedEvent parentEvent, ContentXElement element) : base(parentEvent, element)
|
||||
if (!MissionIdentifier.IsEmpty)
|
||||
{
|
||||
State = element.GetAttributeInt("value", State);
|
||||
if (MissionIdentifier.IsEmpty)
|
||||
{
|
||||
DebugConsole.ThrowError($"Error in event \"{parentEvent.Prefab.Identifier}\": MissionIdentifier has not been configured.",
|
||||
contentPackage: element.ContentPackage);
|
||||
}
|
||||
if (Operation == OperationType.Add && State == 0 && !ForceFailure)
|
||||
{
|
||||
DebugConsole.AddWarning($"Potential error in event \"{parentEvent.Prefab.Identifier}\": {nameof(MissionStateAction)} is set to add 0 to the mission state, which will do nothing.",
|
||||
contentPackage: element.ContentPackage);
|
||||
}
|
||||
}
|
||||
|
||||
public override bool IsFinished(ref string goTo)
|
||||
{
|
||||
return isFinished;
|
||||
}
|
||||
public override void Reset()
|
||||
{
|
||||
isFinished = false;
|
||||
}
|
||||
|
||||
public override void Update(float deltaTime)
|
||||
{
|
||||
if (isFinished) { return; }
|
||||
|
||||
foreach (Mission mission in GameMain.GameSession.Missions)
|
||||
{
|
||||
if (mission.Prefab.Identifier != MissionIdentifier) { continue; }
|
||||
if (ForceFailure)
|
||||
{
|
||||
mission.ForceFailure = true;
|
||||
}
|
||||
|
||||
switch (Operation)
|
||||
{
|
||||
case OperationType.Set:
|
||||
mission.State = State;
|
||||
break;
|
||||
case OperationType.Add:
|
||||
mission.State += State;
|
||||
break;
|
||||
}
|
||||
SetMissionState(mission);
|
||||
}
|
||||
|
||||
isFinished = true;
|
||||
}
|
||||
else if (ParentEvent.TriggeringMission != null)
|
||||
{
|
||||
SetMissionState(ParentEvent.TriggeringMission);
|
||||
}
|
||||
|
||||
public override string ToDebugString()
|
||||
isFinished = true;
|
||||
}
|
||||
|
||||
private void SetMissionState(Mission mission)
|
||||
{
|
||||
if (ForceFailure) { mission.ForceFailure = true; }
|
||||
switch (Operation)
|
||||
{
|
||||
return $"{ToolBox.GetDebugSymbol(isFinished)} {nameof(MissionStateAction)} -> ({(Operation == OperationType.Set ? State : '+' + State)})";
|
||||
case OperationType.Set:
|
||||
mission.State = State;
|
||||
break;
|
||||
case OperationType.Add:
|
||||
mission.State += State;
|
||||
break;
|
||||
}
|
||||
}
|
||||
|
||||
public override string ToDebugString() => $"{ToolBox.GetDebugSymbol(isFinished)} {nameof(MissionStateAction)} -> ({(Operation == OperationType.Set ? State : '+' + State)})";
|
||||
}
|
||||
@@ -1,4 +1,4 @@
|
||||
using System;
|
||||
using System;
|
||||
using System.Collections.Generic;
|
||||
using System.Linq;
|
||||
|
||||
@@ -18,6 +18,9 @@ namespace Barotrauma
|
||||
[Serialize(true, IsPropertySaveable.Yes, description: "Should the NPC start or stop following the target?")]
|
||||
public bool Follow { get; set; }
|
||||
|
||||
[Serialize(false, IsPropertySaveable.Yes, description: "Should the NPC be forced to walk towards the target?")]
|
||||
public bool ForceWalk { get; set; }
|
||||
|
||||
[Serialize(-1, IsPropertySaveable.Yes, description: "Maximum number of NPCs to target (e.g. you could choose to only make a specific number of security officers follow the player.)")]
|
||||
public int MaxTargets { get; set; }
|
||||
|
||||
@@ -65,7 +68,8 @@ namespace Barotrauma
|
||||
var newObjective = new AIObjectiveGoTo(target, npc, humanAiController.ObjectiveManager, repeat: true)
|
||||
{
|
||||
OverridePriority = Priority,
|
||||
IsFollowOrder = true
|
||||
IsFollowOrder = true,
|
||||
ForceWalkPermanently = ForceWalk
|
||||
};
|
||||
humanAiController.ObjectiveManager.AddObjective(newObjective);
|
||||
humanAiController.ObjectiveManager.WaitTimer = 0.0f;
|
||||
|
||||
@@ -271,6 +271,10 @@ namespace Barotrauma
|
||||
ParentEvent.AddTarget(TargetTag, newCharacter);
|
||||
}
|
||||
spawnedEntity = newCharacter;
|
||||
if (newCharacter is { AIController: EnemyAIController enemyAi, Submarine: Submarine ownSub })
|
||||
{
|
||||
enemyAi.SetUnattackableSubmarines(ownSub);
|
||||
}
|
||||
});
|
||||
}
|
||||
}
|
||||
|
||||
@@ -240,42 +240,45 @@ namespace Barotrauma
|
||||
CreateEvents(eventSet);
|
||||
}
|
||||
|
||||
if (level?.LevelData != null)
|
||||
bool isOutpostLevel = level?.LevelData is { Type: LevelData.LevelType.Outpost } ||
|
||||
(GameMain.GameSession?.GameMode is TestGameMode && Submarine.MainSub?.Info?.Type == SubmarineType.Outpost);
|
||||
if (isOutpostLevel)
|
||||
{
|
||||
if (level.LevelData.Type == LevelData.LevelType.Outpost)
|
||||
//if the outpost is connected to a locked connection, create an event to unlock it
|
||||
if (level?.StartLocation?.Connections.Any(c => c.Locked && level.StartLocation.MapPosition.X < c.OtherLocation(level.StartLocation).MapPosition.X) ?? false)
|
||||
{
|
||||
//if the outpost is connected to a locked connection, create an event to unlock it
|
||||
if (level.StartLocation?.Connections.Any(c => c.Locked && level.StartLocation.MapPosition.X < c.OtherLocation(level.StartLocation).MapPosition.X) ?? false)
|
||||
var unlockPathEventPrefab = EventPrefab.GetUnlockPathEvent(level.LevelData.Biome.Identifier, level.StartLocation.Faction);
|
||||
if (unlockPathEventPrefab != null)
|
||||
{
|
||||
var unlockPathEventPrefab = EventPrefab.GetUnlockPathEvent(level.LevelData.Biome.Identifier, level.StartLocation.Faction);
|
||||
if (unlockPathEventPrefab != null)
|
||||
var newEvent = unlockPathEventPrefab.CreateInstance(RandomSeed);
|
||||
activeEvents.Add(newEvent);
|
||||
}
|
||||
else
|
||||
{
|
||||
//if no event that unlocks the path can be found, unlock it automatically
|
||||
level.StartLocation.Connections.ForEach(c => c.Locked = false);
|
||||
}
|
||||
}
|
||||
Submarine outpost = level?.StartOutpost ?? Submarine.MainSub;
|
||||
if (GameMain.NetworkMember is not { IsClient: true } && outpost != null)
|
||||
{
|
||||
foreach (var eventTag in outpost.Info.TriggerOutpostMissionEvents)
|
||||
{
|
||||
EventPrefab eventPrefab = EventPrefab.FindEventPrefab(identifier: Identifier.Empty, tag: eventTag, outpost.ContentPackage);
|
||||
if (eventPrefab == null)
|
||||
{
|
||||
var newEvent = unlockPathEventPrefab.CreateInstance(RandomSeed);
|
||||
activeEvents.Add(newEvent);
|
||||
DebugConsole.ThrowError($"Outpost {outpost.Info.DisplayName} failed to trigger an event (tag: {eventTag}).", contentPackage: outpost.ContentPackage);
|
||||
}
|
||||
else
|
||||
{
|
||||
//if no event that unlocks the path can be found, unlock it automatically
|
||||
level.StartLocation.Connections.ForEach(c => c.Locked = false);
|
||||
var newEvent = eventPrefab.CreateInstance(RandomSeed);
|
||||
ActivateEvent(newEvent);
|
||||
}
|
||||
}
|
||||
if (GameMain.NetworkMember is not { IsClient: true } && level.StartOutpost != null)
|
||||
{
|
||||
foreach (var eventTag in level.StartOutpost.Info.TriggerOutpostMissionEvents)
|
||||
{
|
||||
EventPrefab eventPrefab = EventPrefab.FindEventPrefab(identifier: Identifier.Empty, tag: eventTag, level.StartOutpost.ContentPackage);
|
||||
if (eventPrefab == null)
|
||||
{
|
||||
DebugConsole.ThrowError($"Outpost {level.StartOutpost.Info.DisplayName} failed to trigger an event (tag: {eventTag}).", contentPackage: level.StartOutpost.ContentPackage);
|
||||
}
|
||||
else
|
||||
{
|
||||
var newEvent = eventPrefab.CreateInstance(RandomSeed);
|
||||
ActivateEvent(newEvent);
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
if (level?.LevelData != null)
|
||||
{
|
||||
RegisterNonRepeatableChildEvents(initialEventSet);
|
||||
void RegisterNonRepeatableChildEvents(EventSet eventSet)
|
||||
{
|
||||
|
||||
@@ -233,7 +233,7 @@ namespace Barotrauma
|
||||
|
||||
}
|
||||
|
||||
protected override bool DetermineCompleted()
|
||||
protected override bool DetermineCompleted(CampaignMode.TransitionType transitionType)
|
||||
{
|
||||
return State > 0 && State != HostagesKilledState;
|
||||
}
|
||||
|
||||
Some files were not shown because too many files have changed in this diff Show More
Reference in New Issue
Block a user