Spectating, fire, damaged limb sprites, water detector, engineer jumpsuit, new signal comp sprites, resharper cleanup (god knows what else, commit more often)

This commit is contained in:
Regalis
2015-11-10 22:22:26 +02:00
parent cd48d12be6
commit 4d949e3be1
89 changed files with 977 additions and 622 deletions
+23
View File
@@ -91,11 +91,13 @@
<Compile Include="Source\GUI\TitleScreen.cs" /> <Compile Include="Source\GUI\TitleScreen.cs" />
<Compile Include="Source\Items\Components\Holdable\MeleeWeapon.cs" /> <Compile Include="Source\Items\Components\Holdable\MeleeWeapon.cs" />
<Compile Include="Source\Items\Components\Label.cs" /> <Compile Include="Source\Items\Components\Label.cs" />
<Compile Include="Source\Items\Components\Signal\WaterDetector.cs" />
<Compile Include="Source\Items\Components\Signal\WifiComponent.cs" /> <Compile Include="Source\Items\Components\Signal\WifiComponent.cs" />
<Compile Include="Source\Items\Components\Signal\SignalCheckComponent.cs" /> <Compile Include="Source\Items\Components\Signal\SignalCheckComponent.cs" />
<Compile Include="Source\Items\Components\ItemLabel.cs" /> <Compile Include="Source\Items\Components\ItemLabel.cs" />
<Compile Include="Source\Items\FixRequirement.cs" /> <Compile Include="Source\Items\FixRequirement.cs" />
<Compile Include="Source\Items\ItemSpawner.cs" /> <Compile Include="Source\Items\ItemSpawner.cs" />
<Compile Include="Source\Map\FireSource.cs" />
<Compile Include="Source\Map\Levels\WrappingWall.cs" /> <Compile Include="Source\Map\Levels\WrappingWall.cs" />
<Compile Include="Source\Map\Lights\LightSource.cs" /> <Compile Include="Source\Map\Lights\LightSource.cs" />
<Compile Include="Source\Map\LocationType.cs" /> <Compile Include="Source\Map\LocationType.cs" />
@@ -288,6 +290,15 @@
<SubType>Designer</SubType> <SubType>Designer</SubType>
<CopyToOutputDirectory>PreserveNewest</CopyToOutputDirectory> <CopyToOutputDirectory>PreserveNewest</CopyToOutputDirectory>
</Content> </Content>
<Content Include="Content\Characters\Human\damagedhead.png">
<CopyToOutputDirectory>PreserveNewest</CopyToOutputDirectory>
</Content>
<Content Include="Content\Characters\Human\damagedlegs.png">
<CopyToOutputDirectory>PreserveNewest</CopyToOutputDirectory>
</Content>
<Content Include="Content\Characters\Human\damagedtorso.png">
<CopyToOutputDirectory>PreserveNewest</CopyToOutputDirectory>
</Content>
<Content Include="Content\Characters\Human\ffirstnames.txt"> <Content Include="Content\Characters\Human\ffirstnames.txt">
<CopyToOutputDirectory>PreserveNewest</CopyToOutputDirectory> <CopyToOutputDirectory>PreserveNewest</CopyToOutputDirectory>
</Content> </Content>
@@ -333,6 +344,9 @@
<Content Include="Content\Characters\Human\torso.png"> <Content Include="Content\Characters\Human\torso.png">
<CopyToOutputDirectory>PreserveNewest</CopyToOutputDirectory> <CopyToOutputDirectory>PreserveNewest</CopyToOutputDirectory>
</Content> </Content>
<Content Include="Content\Characters\TigerThresher\damagedtigerthresher.png">
<CopyToOutputDirectory>PreserveNewest</CopyToOutputDirectory>
</Content>
<Content Include="Content\Items\Artifacts\artifact.png"> <Content Include="Content\Items\Artifacts\artifact.png">
<CopyToOutputDirectory>PreserveNewest</CopyToOutputDirectory> <CopyToOutputDirectory>PreserveNewest</CopyToOutputDirectory>
</Content> </Content>
@@ -348,12 +362,18 @@
<Content Include="Content\Items\Clothes\captainTorso.png"> <Content Include="Content\Items\Clothes\captainTorso.png">
<CopyToOutputDirectory>PreserveNewest</CopyToOutputDirectory> <CopyToOutputDirectory>PreserveNewest</CopyToOutputDirectory>
</Content> </Content>
<Content Include="Content\Items\Clothes\engigear.png">
<CopyToOutputDirectory>PreserveNewest</CopyToOutputDirectory>
</Content>
<Content Include="Content\Items\Clothes\securitygear.png"> <Content Include="Content\Items\Clothes\securitygear.png">
<CopyToOutputDirectory>PreserveNewest</CopyToOutputDirectory> <CopyToOutputDirectory>PreserveNewest</CopyToOutputDirectory>
</Content> </Content>
<Content Include="Content\Items\Electricity\lamp.png"> <Content Include="Content\Items\Electricity\lamp.png">
<CopyToOutputDirectory>PreserveNewest</CopyToOutputDirectory> <CopyToOutputDirectory>PreserveNewest</CopyToOutputDirectory>
</Content> </Content>
<Content Include="Content\Items\Electricity\signalcomp.png">
<CopyToOutputDirectory>PreserveNewest</CopyToOutputDirectory>
</Content>
<Content Include="Content\Items\Electricity\supercapacitor.png"> <Content Include="Content\Items\Electricity\supercapacitor.png">
<CopyToOutputDirectory>PreserveNewest</CopyToOutputDirectory> <CopyToOutputDirectory>PreserveNewest</CopyToOutputDirectory>
</Content> </Content>
@@ -552,6 +572,9 @@
<Content Include="Content\Map\locationTypes.xml"> <Content Include="Content\Map\locationTypes.xml">
<CopyToOutputDirectory>PreserveNewest</CopyToOutputDirectory> <CopyToOutputDirectory>PreserveNewest</CopyToOutputDirectory>
</Content> </Content>
<Content Include="Content\Particles\fire.png">
<CopyToOutputDirectory>PreserveNewest</CopyToOutputDirectory>
</Content>
<Content Include="Content\Particles\flames.png"> <Content Include="Content\Particles\flames.png">
<CopyToOutputDirectory>PreserveNewest</CopyToOutputDirectory> <CopyToOutputDirectory>PreserveNewest</CopyToOutputDirectory>
</Content> </Content>
@@ -1,5 +1,5 @@
<?xml version="1.0" encoding="utf-8" ?> <?xml version="1.0" encoding="utf-8" ?>
<character name ="coelanth" humanoid="false" health="100.0"> <Character name ="coelanth" humanoid="false" health="100.0">
<sound file="Content/Characters/Scorpion/scorpionattack1.ogg" state="Attack" /> <sound file="Content/Characters/Scorpion/scorpionattack1.ogg" state="Attack" />
<sound file="Content/Characters/Scorpion/scorpionidle1.ogg" state="None" /> <sound file="Content/Characters/Scorpion/scorpionidle1.ogg" state="None" />
@@ -55,4 +55,4 @@
</ragdoll> </ragdoll>
<ai attackhumans="100.0" attackrooms="50.0" attackweaker="50" attackstronger="-30" sight="2.0" hearing="10.0"/> <ai attackhumans="100.0" attackrooms="50.0" attackweaker="50" attackstronger="-30" sight="2.0" hearing="10.0"/>
</character> </Character>
@@ -1,5 +1,5 @@
<?xml version="1.0" encoding="utf-8" ?> <?xml version="1.0" encoding="utf-8" ?>
<character name ="crawler" humanoid="false"> <Character name ="crawler" humanoid="false">
<sound file="Content/Characters/Crawler/attack1.ogg" state="Attack" range="500"/> <sound file="Content/Characters/Crawler/attack1.ogg" state="Attack" range="500"/>
<sound file="Content/Characters/Crawler/attack2.ogg" state="Attack" range="500"/> <sound file="Content/Characters/Crawler/attack2.ogg" state="Attack" range="500"/>
@@ -77,5 +77,5 @@
<ai attackhumans="500" attackrooms="50.0" attackweaker="50" attackstronger="-30" <ai attackhumans="500" attackrooms="50.0" attackweaker="50" attackstronger="-30"
sight="0.5" hearing="1.0" sight="0.5" hearing="1.0"
attackcooldown="5.0"/> attackcooldown="5.0"/>
</character> </Character>
Binary file not shown.

After

Width:  |  Height:  |  Size: 1.1 KiB

Binary file not shown.

After

Width:  |  Height:  |  Size: 4.8 KiB

Binary file not shown.

After

Width:  |  Height:  |  Size: 3.6 KiB

+16 -3
View File
@@ -1,5 +1,5 @@
<?xml version="1.0" encoding="utf-8" ?> <?xml version="1.0" encoding="utf-8" ?>
<character name ="human" humanoid="true" needsair="true" genders="true" maleheadid="1,4" femaleheadid="1,4" drowningtime="30"> <Character name ="human" humanoid="true" needsair="true" genders="true" maleheadid="1,4" femaleheadid="1,4" drowningtime="30">
<name firstname="Content/Characters/Human/[GENDER]firstnames.txt" lastname="Content/Characters/Human/lastnames.txt" /> <name firstname="Content/Characters/Human/[GENDER]firstnames.txt" lastname="Content/Characters/Human/lastnames.txt" />
@@ -13,53 +13,66 @@
<!-- head --> <!-- head -->
<limb id = "0" radius="13" mass = "6" type="Head" attackpriority="2" impacttolerance="4.0"> <limb id = "0" radius="13" mass = "6" type="Head" attackpriority="2" impacttolerance="4.0">
<sprite texture="Content/Characters/Human/[GENDER]head[HEADID].png" sourcerect="1,1,37,38" depth="0.04" origin="0.5,0.5"/> <sprite texture="Content/Characters/Human/[GENDER]head[HEADID].png" sourcerect="1,1,37,38" depth="0.04" origin="0.5,0.5"/>
<damagedsprite texture="Content/Characters/Human/damagedhead.png" sourcerect="1,1,37,38" origin="0.5,0.5"/>
</limb> </limb>
<!-- body --> <!-- body -->
<limb id = "1" radius="14" height="21" mass = "20" type="Torso" attackpriority="3" impacttolerance="6.0"> <limb id = "1" radius="14" height="21" mass = "20" type="Torso" attackpriority="3" impacttolerance="6.0">
<sprite texture="Content/Characters/Human/[GENDER]torso.png" sourcerect="0,0,29,58" depth="0.05" origin="0.5,0.6"/> <sprite texture="Content/Characters/Human/[GENDER]torso.png" sourcerect="0,0,29,58" depth="0.05" origin="0.5,0.6"/>
<damagedsprite texture="Content/Characters/Human/damagedtorso.png" sourcerect="0,0,29,58" origin="0.5,0.6"/>
</limb> </limb>
<limb id = "12" radius="13" mass = "20" type="Waist" impacttolerance="6.0"> <limb id = "12" radius="13" mass = "20" type="Waist" impacttolerance="6.0">
<sprite texture="Content/Characters/Human/[GENDER]legs.png" sourcerect="0,0,32,29" depth="0.045" origin="0.5,0.5"/> <sprite texture="Content/Characters/Human/[GENDER]legs.png" sourcerect="0,0,32,29" depth="0.045" origin="0.5,0.5"/>
<damagedsprite texture="Content/Characters/Human/damagedlegs.png" sourcerect="0,0,32,29" origin="0.5,0.5"/>
</limb> </limb>
<!-- left arm --> <!-- left arm -->
<limb id = "2" radius="8" height="20" mass="3" type="LeftArm"> <limb id = "2" radius="8" height="20" mass="3" type="LeftArm">
<sprite texture="Content/Characters/Human/[GENDER]torso.png" sourcerect="30,2,17,39" depth="0.15" origin="0.5,0.5"/> <sprite texture="Content/Characters/Human/[GENDER]torso.png" sourcerect="30,2,17,39" depth="0.15" origin="0.5,0.5"/>
<damagedsprite texture="Content/Characters/Human/damagedtorso.png" sourcerect="30,2,17,39" origin="0.5,0.5"/>
</limb> </limb>
<limb id = "3" radius="6" height="26" mass="3" type="LeftHand" pullpos="0.0,-18.0"> <limb id = "3" radius="6" height="26" mass="3" type="LeftHand" pullpos="0.0,-18.0">
<sprite texture="Content/Characters/Human/[GENDER]torso.png" sourcerect="49,2,13,47" depth="0.16" origin="0.5,0.5"/> <sprite texture="Content/Characters/Human/[GENDER]torso.png" sourcerect="49,2,13,47" depth="0.16" origin="0.5,0.5"/>
<damagedsprite texture="Content/Characters/Human/damagedtorso.png" sourcerect="49,2,13,47" origin="0.5,0.5"/>
</limb> </limb>
<!-- right arm --> <!-- right arm -->
<limb id = "4" radius="8" height="20" mass="3" type="RightArm"> <limb id = "4" radius="8" height="20" mass="3" type="RightArm">
<sprite texture="Content/Characters/Human/[GENDER]torso.png" sourcerect="30,2,17,39" depth="0.01" origin="0.5,0.5"/> <sprite texture="Content/Characters/Human/[GENDER]torso.png" sourcerect="30,2,17,39" depth="0.01" origin="0.5,0.5"/>
<damagedsprite texture="Content/Characters/Human/damagedtorso.png" sourcerect="30,2,17,39" origin="0.5,0.5"/>
</limb> </limb>
<limb id = "5" radius="6" height="26" mass ="3" type="RightHand" pullpos="0.0,-18.0"> <limb id = "5" radius="6" height="26" mass ="3" type="RightHand" pullpos="0.0,-18.0">
<sprite texture="Content/Characters/Human/[GENDER]torso.png" sourcerect="49,2,13,47" origin="0.5,0.5"/> <sprite texture="Content/Characters/Human/[GENDER]torso.png" sourcerect="49,2,13,47" origin="0.5,0.5"/>
<damagedsprite texture="Content/Characters/Human/damagedtorso.png" sourcerect="49,2,13,47" origin="0.5,0.5"/>
</limb> </limb>
<!-- left leg --> <!-- left leg -->
<limb id = "6" radius="10" height="30" mass = "8" type="LeftThigh"> <limb id = "6" radius="10" height="30" mass = "8" type="LeftThigh">
<sprite texture="Content/Characters/Human/[GENDER]legs.png" sourcerect="0,32,26,48" depth="0.15" origin="0.5,0.5"/> <sprite texture="Content/Characters/Human/[GENDER]legs.png" sourcerect="0,32,26,48" depth="0.15" origin="0.5,0.5"/>
<damagedsprite texture="Content/Characters/Human/damagedlegs.png" sourcerect="0,32,26,48" origin="0.5,0.5"/>
</limb> </limb>
<limb id = "7" radius="6" height="39" mass = "5" type="LeftLeg"> <limb id = "7" radius="6" height="39" mass = "5" type="LeftLeg">
<sprite texture="Content/Characters/Human/[GENDER]legs.png" sourcerect="32,0,22,50" depth="0.16" origin="0.5,0.5"/> <sprite texture="Content/Characters/Human/[GENDER]legs.png" sourcerect="32,0,22,50" depth="0.16" origin="0.5,0.5"/>
<damagedsprite texture="Content/Characters/Human/damagedlegs.png" sourcerect="32,0,22,50" origin="0.5,0.5"/>
</limb> </limb>
<limb id = "8" radius="5" height="13" mass = "2" type ="LeftFoot" flip="true" pullpos="-5.0,0.0"> <limb id = "8" radius="5" height="13" mass = "2" type ="LeftFoot" flip="true" pullpos="-5.0,0.0">
<sprite texture="Content/Characters/Human/[GENDER]legs.png" sourcerect="35,53,16,25" depth="0.14" origin="0.5,0.5"/> <sprite texture="Content/Characters/Human/[GENDER]legs.png" sourcerect="35,53,16,25" depth="0.14" origin="0.5,0.5"/>
<damagedsprite texture="Content/Characters/Human/damagedlegs.png" sourcerect="35,53,16,25" origin="0.5,0.5"/>
<sound file ="Content/step.ogg"/> <sound file ="Content/step.ogg"/>
</limb> </limb>
<!-- right leg --> <!-- right leg -->
<limb id = "9" radius="10" height="30" mass = "8" type="RightThigh"> <limb id = "9" radius="10" height="30" mass = "8" type="RightThigh">
<sprite texture="Content/Characters/Human/[GENDER]legs.png" sourcerect="0,32,26,48" depth="0.11" origin="0.5,0.5"/> <sprite texture="Content/Characters/Human/[GENDER]legs.png" sourcerect="0,32,26,48" depth="0.11" origin="0.5,0.5"/>
<damagedsprite texture="Content/Characters/Human/[GENDER]legs.png" sourcerect="0,32,26,48" origin="0.5,0.5"/>
</limb> </limb>
<limb id = "10" radius="6" height="39" mass = "5" type="RightLeg"> <limb id = "10" radius="6" height="39" mass = "5" type="RightLeg">
<sprite texture="Content/Characters/Human/[GENDER]legs.png" sourcerect="32,0,22,50" depth="0.12" origin="0.5,0.5"/> <sprite texture="Content/Characters/Human/[GENDER]legs.png" sourcerect="32,0,22,50" depth="0.12" origin="0.5,0.5"/>
<damagedsprite texture="Content/Characters/Human/[GENDER]legs.png" sourcerect="32,0,22,50" origin="0.5,0.5"/>
</limb> </limb>
<limb id = "11" radius="5" height="13" mass = "2" type ="RightFoot" flip="true" pullpos="-5.0,0.0"> <limb id = "11" radius="5" height="13" mass = "2" type ="RightFoot" flip="true" pullpos="-5.0,0.0">
<sprite texture="Content/Characters/Human/[GENDER]legs.png" sourcerect="35,53,16,25" depth="0.1" origin="0.5,0.5"/> <sprite texture="Content/Characters/Human/[GENDER]legs.png" sourcerect="35,53,16,25" origin="0.5,0.5"/>
<damagedsprite texture="Content/Characters/Human/damagedlegs.png" sourcerect="35,53,16,25" origin="0.5,0.5"/>
<sound file ="Content/step.ogg"/> <sound file ="Content/step.ogg"/>
</limb> </limb>
@@ -88,5 +101,5 @@
<joint limb1="10" limb1anchor="-3,-21" limb2="11" limb2anchor="5,7" lowerlimit="20" upperlimit="90"/> <joint limb1="10" limb1anchor="-3,-21" limb2="11" limb2anchor="5,7" lowerlimit="20" upperlimit="90"/>
</ragdoll> </ragdoll>
</character> </Character>
@@ -1,5 +1,5 @@
<?xml version="1.0" encoding="utf-8" ?> <?xml version="1.0" encoding="utf-8" ?>
<character name ="mantis" humanoid="false"> <Character name ="mantis" humanoid="false">
<sound file="Content/Characters/Crawler/attack1.ogg" state="Attack" range="500"/> <sound file="Content/Characters/Crawler/attack1.ogg" state="Attack" range="500"/>
<sound file="Content/Characters/Crawler/attack2.ogg" state="Attack" range="500"/> <sound file="Content/Characters/Crawler/attack2.ogg" state="Attack" range="500"/>
@@ -88,5 +88,5 @@
<ai attackhumans="500" attackrooms="50.0" attackweaker="50" attackstronger="-30" <ai attackhumans="500" attackrooms="50.0" attackweaker="50" attackstronger="-30"
sight="0.5" hearing="1.0" sight="0.5" hearing="1.0"
attackcooldown="3.0"/> attackcooldown="3.0"/>
</character> </Character>
@@ -1,5 +1,5 @@
<?xml version="1.0" encoding="utf-8" ?> <?xml version="1.0" encoding="utf-8" ?>
<character name ="moloch" humanoid="false" health ="1000"> <Character name ="moloch" humanoid="false" health ="1000">
<sound file="Content/Characters/Moloch/attack1.ogg" state="Attack" range="3000"/> <sound file="Content/Characters/Moloch/attack1.ogg" state="Attack" range="3000"/>
<sound file="Content/Characters/Moloch/attack2.ogg" state="Attack" range="3000"/> <sound file="Content/Characters/Moloch/attack2.ogg" state="Attack" range="3000"/>
@@ -59,4 +59,4 @@
</ragdoll> </ragdoll>
<ai attackhumans="100.0" attackrooms="50.0" attackweaker="50" attackstronger="-30" sight="0.5" hearing="1.0"/> <ai attackhumans="100.0" attackrooms="50.0" attackweaker="50" attackstronger="-30" sight="0.5" hearing="1.0"/>
</character> </Character>
@@ -1,5 +1,5 @@
<?xml version="1.0" encoding="utf-8" ?> <?xml version="1.0" encoding="utf-8" ?>
<character name ="scorpion" humanoid="false"> <Character name ="scorpion" humanoid="false">
<sound file="Content/Characters/Scorpion/scorpionattack1.ogg" state="Attack" /> <sound file="Content/Characters/Scorpion/scorpionattack1.ogg" state="Attack" />
<sound file="Content/Characters/Scorpion/scorpionidle1.ogg" state="None" /> <sound file="Content/Characters/Scorpion/scorpionidle1.ogg" state="None" />
@@ -44,5 +44,5 @@
</ragdoll> </ragdoll>
<ai attackhumans="100" attackrooms="50.0" attackweaker="50" attackstronger="-30" sight="0.5" hearing="1.0"/> <ai attackhumans="100" attackrooms="50.0" attackweaker="50" attackstronger="-30" sight="0.5" hearing="1.0"/>
</character> </Character>
Binary file not shown.

After

Width:  |  Height:  |  Size: 90 KiB

@@ -1,5 +1,5 @@
<?xml version="1.0" encoding="utf-8" ?> <?xml version="1.0" encoding="utf-8" ?>
<character name ="tigerthresher" humanoid="false" health="300.0"> <Character name ="tigerthresher" humanoid="false" health="300.0">
<sound file="Content/Characters/Scorpion/scorpionattack1.ogg" state="Attack" /> <sound file="Content/Characters/Scorpion/scorpionattack1.ogg" state="Attack" />
<sound file="Content/Characters/Scorpion/scorpionidle1.ogg" state="None" /> <sound file="Content/Characters/Scorpion/scorpionidle1.ogg" state="None" />
@@ -10,37 +10,44 @@
<!-- head --> <!-- head -->
<limb id = "0" radius="12" height="100" type="Head" steerforce="1.0" impacttolerance="50.0"> <limb id = "0" radius="12" height="100" type="Head" steerforce="1.0" impacttolerance="50.0">
<sprite texture="Content/Characters/TigerThresher/tigerthresher.png" sourcerect="371,15,66,136" depth="0.02" origin ="0.5,0.5"/> <sprite texture="Content/Characters/TigerThresher/tigerthresher.png" sourcerect="371,15,66,136" depth="0.02" origin ="0.5,0.5"/>
<damagedsprite texture="Content/Characters/TigerThresher/damagedtigerthresher.png" sourcerect="371,15,66,136" origin ="0.5,0.5"/>
</limb> </limb>
<!-- lower yaw --> <!-- lower yaw -->
<limb id = "1" width="16" height="103" impacttolerance="50.0"> <limb id = "1" width="16" height="103" impacttolerance="50.0">
<sprite texture="Content/Characters/TigerThresher/tigerthresher.png" sourcerect="391,169,28,110" depth="0.025" origin="0.5,0.5"/> <sprite texture="Content/Characters/TigerThresher/tigerthresher.png" sourcerect="391,169,28,110" depth="0.025" origin="0.5,0.5"/>
<attack type="PinchCCW" range="200" duration="0.5" damage="150" bleedingdamage="10" structuredamage="200" damagetype="slash"/> <damagedsprite texture="Content/Characters/TigerThresher/damagedtigerthresher.png" sourcerect="391,169,28,110" origin="0.5,0.5"/>
<attack type="PinchCCW" range="200" duration="0.5" damage="150" bleedingdamage="10" structuredamage="200" damagetype="slash"/>
</limb> </limb>
<!-- body --> <!-- body -->
<limb id = "2" radius="50" height="320" type="Torso" steerforce="0.1"> <limb id = "2" radius="50" height="320" type="Torso" steerforce="0.1">
<sprite texture="Content/Characters/TigerThresher/tigerthresher.png" sourcerect="230,0,136,442" depth="0.015" origin="0.6,0.5"/> <sprite texture="Content/Characters/TigerThresher/tigerthresher.png" sourcerect="230,0,136,442" depth="0.015" origin="0.6,0.5"/>
<damagedsprite texture="Content/Characters/TigerThresher/damagedtigerthresher.png" sourcerect="230,0,136,442" origin="0.6,0.5"/>
</limb> </limb>
<!-- tail --> <!-- tail -->
<limb id = "3" radius="10" height="320" type="Tail"> <limb id = "3" radius="10" height="320" type="Tail">
<sprite texture="Content/Characters/TigerThresher/tigerthresher.png" sourcerect="9,0,79,344" depth="0.02" origin="0.35,0.5"/> <sprite texture="Content/Characters/TigerThresher/tigerthresher.png" sourcerect="9,0,79,344" depth="0.02" origin="0.35,0.5"/>
<damagedsprite texture="Content/Characters/TigerThresher/damagedtigerthresher.png" sourcerect="9,0,79,344" origin="0.35,0.5"/>
</limb> </limb>
<!-- front fins --> <!-- front fins -->
<limb id = "4" width="50" height="200"> <limb id = "4" width="50" height="200">
<sprite texture="Content/Characters/TigerThresher/tigerthresher.png" sourcerect="133,5,91,202" depth="0.008" origin="0.7,0.5"/> <sprite texture="Content/Characters/TigerThresher/tigerthresher.png" sourcerect="133,5,91,202" depth="0.008" origin="0.7,0.5"/>
<damagedsprite texture="Content/Characters/TigerThresher/damagedtigerthresher.png" sourcerect="133,5,91,202" origin="0.7,0.5"/>
</limb> </limb>
<!-- back fins --> <!-- back fins -->
<limb id = "5" width="25" height="100"> <limb id = "5" width="25" height="100">
<sprite texture="Content/Characters/TigerThresher/tigerthresher.png" sourcerect="387,304,38,128" depth="0.01" origin="0.7,0.5"/> <sprite texture="Content/Characters/TigerThresher/tigerthresher.png" sourcerect="387,304,38,128" depth="0.01" origin="0.7,0.5"/>
<damagedsprite texture="Content/Characters/TigerThresher/damagedtigerthresher.png" sourcerect="387,304,38,128" origin="0.7,0.5"/>
</limb> </limb>
<!-- long "fins" --> <!-- long "fins" -->
<limb id = "6" width="10" height="270" ignorecollisions="true"> <limb id = "6" width="10" height="270" ignorecollisions="true">
<sprite texture="Content/Characters/TigerThresher/tigerthresher.png" sourcerect="96,2,23,277" depth="0.01" origin="0.5,0.5"/> <sprite texture="Content/Characters/TigerThresher/tigerthresher.png" sourcerect="96,2,23,277" depth="0.01" origin="0.5,0.5"/>
<damagedsprite texture="Content/Characters/TigerThresher/damagedtigerthresher.png" sourcerect="96,2,23,277" origin="0.5,0.5"/>
</limb> </limb>
@@ -64,4 +71,4 @@
</ragdoll> </ragdoll>
<ai attackhumans="100.0" attackrooms="50.0" attackweaker="50" attackstronger="-30" sight="0.5" hearing="1.0"/> <ai attackhumans="100.0" attackrooms="50.0" attackweaker="50" attackstronger="-30" sight="0.5" hearing="1.0"/>
</character> </Character>
+28 -5
View File
@@ -4,7 +4,7 @@
pickdistance="150" pickdistance="150"
tags="smallitem"> tags="smallitem">
<Sprite texture ="captainhat.png" depth="0.4"/> <Sprite texture ="captainhat.png" depth="0.6"/>
<Body radius="8" density="5"/> <Body radius="8" density="5"/>
@@ -18,7 +18,7 @@
pickdistance="150" pickdistance="150"
tags="smallitem"> tags="smallitem">
<Sprite texture ="captainLegs.png" sourcerect="0,49,52,17" depth="0.4"/> <Sprite texture ="captainLegs.png" sourcerect="0,49,52,17" depth="0.6"/>
<Body width="52" height="17"/> <Body width="52" height="17"/>
@@ -38,7 +38,7 @@
pickdistance="150" pickdistance="150"
tags="smallitem"> tags="smallitem">
<Sprite texture ="captainLegs.png" sourcerect="0,67,51,13" depth="0.4"/> <Sprite texture ="captainLegs.png" sourcerect="0,67,51,13" depth="0.6"/>
<Body width="51" height="13"/> <Body width="51" height="13"/>
@@ -57,7 +57,7 @@
pickdistance="150" pickdistance="150"
tags="smallitem"> tags="smallitem">
<Sprite texture ="securitygear.png" sourcerect="68,0,60,31" depth="0.4"/> <Sprite texture ="securitygear.png" sourcerect="68,0,60,31" depth="0.6"/>
<Body width="52" height="17"/> <Body width="52" height="17"/>
@@ -73,7 +73,7 @@
pickdistance="150" pickdistance="150"
tags="smallitem"> tags="smallitem">
<Sprite texture ="securitygear.png" sourcerect="40,32,34,25" depth="0.4"/> <Sprite texture ="securitygear.png" sourcerect="40,32,34,25" depth="0.6"/>
<Body radius="12"/> <Body radius="12"/>
@@ -82,5 +82,28 @@
</Wearable> </Wearable>
</Item> </Item>
<Item
name="Orange Jumpsuit"
pickdistance="150"
tags="smallitem">
<Sprite texture = "engigear.png" sourcerect="0,52,50,26" depth="0.6"/>
<Body width="50" height="17"/>
<Wearable slots="Any,Torso,Legs">
<sprite texture="engigear.png" limb="Torso" sourcerect="0,0,32,51" origin="0.5,0.48" depth="0.01"/>
<sprite texture="engigear.png" limb="Waist" sourcerect="81,0,30,26" origin="0.5,0.45" hidelimb="true"/>
<sprite texture="engigear.png" limb="RightThigh" sourcerect="53,0,27,49" origin="0.5,0.5" depth="0.10" hidelimb="true"/>
<sprite texture="engigear.png" limb="LeftThigh" sourcerect="53,0,27,49" origin="0.5,0.5" depth="0.14" hidelimb="true"/>
<sprite texture="engigear.png" limb="RightLeg" sourcerect="33,0,20,51" origin="0.5,0.5" depth="0.11" hidelimb="true"/>
<sprite texture="engigear.png" limb="LeftLeg" sourcerect="33,0,20,51" origin="0.5,0.5" depth="0.15" hidelimb="true"/>
</Wearable>
<ItemContainer containableitems="smallitem" capacity="5"/>
</Item>
</Items> </Items>
Binary file not shown.

After

Width:  |  Height:  |  Size: 13 KiB

Binary file not shown.

After

Width:  |  Height:  |  Size: 6.7 KiB

@@ -102,7 +102,7 @@
linkable="true" linkable="true"
price="10"> price="10">
<Sprite texture ="or.png" depth="0.8"/> <Sprite texture="signalcomp.png" depth="0.8" sourcerect="16,0,16,16"/>
<OrComponent canbeselected = "true"/> <OrComponent canbeselected = "true"/>
@@ -129,7 +129,7 @@
linkable="true" linkable="true"
price="10"> price="10">
<Sprite texture ="not.png" depth="0.8"/> <Sprite texture="signalcomp.png" depth="0.8" sourcerect="32,0,16,16"/>
<NotComponent canbeselected = "true"/> <NotComponent canbeselected = "true"/>
@@ -155,7 +155,7 @@
linkable="true" linkable="true"
price="10"> price="10">
<Sprite texture ="light.png" depth="0.8"/> <Sprite texture="signalcomp.png" depth="0.8" sourcerect="48,0,16,16"/>
<LightComponent canbeselected = "true" color="1.0,0.0,0.0,1.0"> <LightComponent canbeselected = "true" color="1.0,0.0,0.0,1.0">
<sprite texture="Content/Items/Electricity/lightsprite.png" origin="0.5,0.5"/> <sprite texture="Content/Items/Electricity/lightsprite.png" origin="0.5,0.5"/>
@@ -182,11 +182,11 @@
linkable="true" linkable="true"
price="10"> price="10">
<Sprite texture ="light.png" depth="0.8"/> <Sprite texture="signalcomp.png" depth="0.8" sourcerect="96,0,31,24"/>
<OxygenDetector canbeselected = "true"/> <OxygenDetector canbeselected = "true"/>
<Body width="16" height="16"/> <Body width="31" height="24"/>
<Holdable selectkey="Action" slots="Any,RightHand,LeftHand" msg="Detach [Wrench]" <Holdable selectkey="Action" slots="Any,RightHand,LeftHand" msg="Detach [Wrench]"
aimpos="35,-10" handle1="0,0" attachable="true" aimable="true"> aimpos="35,-10" handle1="0,0" attachable="true" aimable="true">
@@ -199,6 +199,30 @@
</ConnectionPanel> </ConnectionPanel>
</Item> </Item>
<Item
name="Water Detector"
Tags="smallitem"
pickdistance="150"
linkable="true"
price="10">
<Sprite texture="signalcomp.png" depth="0.8" sourcerect="64,0,31,25"/>
<WaterDetector canbeselected = "true"/>
<Body width="31" height="24"/>
<Holdable selectkey="Action" slots="Any,RightHand,LeftHand" msg="Detach [Wrench]"
aimpos="35,-10" handle1="0,0" attachable="true" aimable="true">
<requireditem name="Wrench" type="Equipped"/>
</Holdable>
<ConnectionPanel selectkey="Action" canbeselected = "true" msg="Rewire [Screwdriver]">
<requireditem name="Screwdriver,Wire" type="Equipped"/>
<output name="signal_out"/>
</ConnectionPanel>
</Item>
<Item <Item
name="Signal Check Component" name="Signal Check Component"
Tags="smallitem" Tags="smallitem"
@@ -206,7 +230,7 @@
linkable="true" linkable="true"
price="10"> price="10">
<Sprite texture ="light.png" depth="0.8"/> <Sprite texture="signalcomp.png" depth="0.8" sourcerect="0,16,16,16"/>
<SignalCheckComponent canbeselected = "true"/> <SignalCheckComponent canbeselected = "true"/>
@@ -233,7 +257,7 @@
linkable="true" linkable="true"
price="10"> price="10">
<Sprite texture ="regex.png" depth="0.8"/> <Sprite texture="signalcomp.png" depth="0.8" sourcerect="16,16,16,16"/>
<RegExFindComponent canbeselected = "true"/> <RegExFindComponent canbeselected = "true"/>
@@ -258,7 +282,7 @@
linkable="true" linkable="true"
price="20"> price="20">
<Sprite texture ="wifi.png" depth="0.8"/> <Sprite texture="signalcomp.png" depth="0.8" sourcerect="0,13,16,19"/>
<WifiComponent canbeselected = "true"/> <WifiComponent canbeselected = "true"/>
@@ -86,6 +86,7 @@
growtime ="0.1" growtime ="0.1"
deleteoncollision="true" deleteoncollision="true"
rotatetodirection="true" rotatetodirection="true"
blendstate="additive"
velocitychange="0.0, -5.0"> velocitychange="0.0, -5.0">
<sprite texture="Content/Particles/explosion.png" sourcerect="128,0,128,64"/> <sprite texture="Content/Particles/explosion.png" sourcerect="128,0,128,64"/>
</spark> </spark>
@@ -102,6 +103,35 @@
<sprite texture="Content/Particles/explosion.png" sourcerect="0,128,128,128"/> <sprite texture="Content/Particles/explosion.png" sourcerect="0,128,128,128"/>
</shockwave> </shockwave>
<flame
startsizemin="0.3,0.3" startsizemax="0.5,0.5"
sizechangemin="0.1,0.1" sizechangemax="0.2,0.2"
startrotationmin ="-20.0" startrotationmax="20"
startcolor="1.0, 1.0, 1.0" startalpha="1.0"
colorchange="-0.6, -1.0, -4.2, -0.8"
lifetime="5.0"
growtime ="0.05"
drawtarget="air"
collideswithwalls="true"
blendstate="additive"
velocitychange="0.0, 2.5">
<sprite texture="Content/Particles/fire.png" sourcerect="0,0,96,96"/>
<sprite texture="Content/Particles/fire.png" sourcerect="96,0,96,96"/>
</flame>
<steam
startsizemin="0.4,0.4" startsizemax="0.5,0.5"
sizechangemin="0.25,0.25" sizechangemax="0.3,0.3"
startrotationmin ="0.0" startrotationmax="360"
startcolor="1.0, 1.0, 1.0" startalpha="0.5"
colorchange="0.0, 0.0, 0.0, -0.25"
growtime ="0.2"
lifetime="3"
collideswithwalls="true"
velocitychange="0.0, 2.5">
<sprite texture="Content/Particles/spatter.png"/>
</steam>
<explosionfire <explosionfire
startsizemin="1.0,1.0" startsizemax="1.5,1.5" startsizemin="1.0,1.0" startsizemax="1.5,1.5"
sizechangemin="0.5,0.5" sizechangemax="0.6,0.6" sizechangemin="0.5,0.5" sizechangemax="0.6,0.6"
@@ -112,6 +142,7 @@
growtime ="0.05" growtime ="0.05"
drawtarget="air" drawtarget="air"
collideswithwalls="true" collideswithwalls="true"
blendstate="additive"
velocitychange="0.0, 0.5"> velocitychange="0.0, 0.5">
<sprite texture="Content/Particles/explosion.png" sourcerect="0,0,128,128"/> <sprite texture="Content/Particles/explosion.png" sourcerect="0,0,128,128"/>
</explosionfire> </explosionfire>
@@ -123,6 +154,7 @@
colorchange="0.0, 0.0, 0.0, -4.0" colorchange="0.0, 0.0, 0.0, -4.0"
lifetime="0.25" lifetime="0.25"
drawtarget="both" drawtarget="both"
blendstate="additive"
velocitychange="0.0, 0.0"> velocitychange="0.0, 0.0">
<sprite texture="Content/Particles/flames.png" sourcerect="0,0,128,64" origin="0.15,0.5"/> <sprite texture="Content/Particles/flames.png" sourcerect="0,0,128,64" origin="0.15,0.5"/>
</weld> </weld>
@@ -134,6 +166,7 @@
colorchange="0.0, 0.0, 0.0, -4.0" colorchange="0.0, 0.0, 0.0, -4.0"
lifetime="0.25" lifetime="0.25"
drawtarget="both" drawtarget="both"
blendstate="additive"
velocitychange="0.0, 0.0"> velocitychange="0.0, 0.0">
<sprite texture="Content/Particles/flames.png" sourcerect="0,64,128,64" origin="0.15,0.5"/> <sprite texture="Content/Particles/flames.png" sourcerect="0,64,128,64" origin="0.15,0.5"/>
</plasma> </plasma>
Binary file not shown.

After

Width:  |  Height:  |  Size: 24 KiB

@@ -37,13 +37,13 @@ namespace Barotrauma
//the duration is determined by the attackDuration of the attacking limb //the duration is determined by the attackDuration of the attacking limb
private float attackTimer; private float attackTimer;
//a "cooldown time" after an attack during which the character doesn't try to attack again //a "cooldown time" after an attack during which the Character doesn't try to attack again
private float attackCoolDown; private float attackCoolDown;
private float coolDownTimer; private float coolDownTimer;
//a point in a wall which the character is currently targeting //a point in a wall which the Character is currently targeting
private Vector2 wallAttackPos; private Vector2 wallAttackPos;
//the entity (a wall) which the character is targeting //the entity (a wall) which the Character is targeting
private IDamageable targetEntity; private IDamageable targetEntity;
//the limb selected for the current attack //the limb selected for the current attack
@@ -226,7 +226,7 @@ namespace Barotrauma
private void GetTargetEntity() private void GetTargetEntity()
{ {
targetEntity = null; targetEntity = null;
//check if there's a wall between the target and the character //check if there's a wall between the target and the Character
Vector2 rayStart = Character.AnimController.Limbs[0].SimPosition; Vector2 rayStart = Character.AnimController.Limbs[0].SimPosition;
Vector2 rayEnd = selectedAiTarget.Position; Vector2 rayEnd = selectedAiTarget.Position;
Body closestBody = Submarine.CheckVisibility(rayStart, rayEnd); Body closestBody = Submarine.CheckVisibility(rayStart, rayEnd);
@@ -313,7 +313,7 @@ namespace Barotrauma
} }
else else
{ {
//limb.body.ApplyTorque(limb.Mass * -20.0f * character.animController.Dir * dir); //limb.body.ApplyTorque(limb.Mass * -20.0f * Character.animController.Dir * dir);
} }
Vector2 diff = attackPosition - limb.SimPosition; Vector2 diff = attackPosition - limb.SimPosition;
@@ -341,7 +341,7 @@ namespace Barotrauma
} }
//goes through all the AItargets, evaluates how preferable it is to attack the target, //goes through all the AItargets, evaluates how preferable it is to attack the target,
//whether the character can see/hear the target and chooses the most preferable target within //whether the Character can see/hear the target and chooses the most preferable target within
//sight/hearing range //sight/hearing range
public void UpdateTargets(Character character) public void UpdateTargets(Character character)
{ {
@@ -370,7 +370,7 @@ namespace Barotrauma
Character targetCharacter = target.Entity as Character; Character targetCharacter = target.Entity as Character;
//ignore the aitarget if it is the character itself //ignore the aitarget if it is the Character itself
if (targetCharacter == character) continue; if (targetCharacter == character) continue;
if (targetCharacter!=null) if (targetCharacter!=null)
@@ -381,7 +381,7 @@ namespace Barotrauma
} }
else if (target.Entity!=null && attackRooms!=0.0f) else if (target.Entity!=null && attackRooms!=0.0f)
{ {
//skip the target if it's the room the character is inside of //skip the target if it's the room the Character is inside of
if (character.AnimController.CurrentHull != null && character.AnimController.CurrentHull == target.Entity as Hull) continue; if (character.AnimController.CurrentHull != null && character.AnimController.CurrentHull == target.Entity as Hull) continue;
valueModifier = attackRooms; valueModifier = attackRooms;
@@ -407,7 +407,7 @@ namespace Barotrauma
//if (targetCharacter != null) //if (targetCharacter != null)
//{ //{
// //if target is a character that isn't visible, ignore // //if target is a Character that isn't visible, ignore
// if (closestStructure != null) continue; // if (closestStructure != null) continue;
// //prefer targets with low health // //prefer targets with low health
@@ -542,11 +542,6 @@ namespace Barotrauma
AiState newState = AiState.None; AiState newState = AiState.None;
Vector2 newWallAttackPos = Vector2.Zero; Vector2 newWallAttackPos = Vector2.Zero;
float wanderAngle; float wanderAngle;
float updateTargetsTimer, raycastTimer, coolDownTimer;
Vector2 newVelocity = Vector2.Zero;
Vector2 targetPosition = Vector2.Zero;
ushort targetID; ushort targetID;
@@ -590,10 +585,10 @@ namespace Barotrauma
} }
} }
//the "memory" of the character //the "memory" of the Character
//keeps track of how preferable it is to attack a specific target //keeps track of how preferable it is to attack a specific target
//(if the character can't inflict much damage the target, the priority decreases //(if the Character can't inflict much damage the target, the priority decreases
//and if the target attacks the character, the priority increases) //and if the target attacks the Character, the priority increases)
class AITargetMemory class AITargetMemory
{ {
//private AITarget target; //private AITarget target;
@@ -141,7 +141,7 @@ namespace Barotrauma
if (startNode==null || endNode==null) if (startNode==null || endNode==null)
{ {
DebugConsole.ThrowError("Pathfinding error, couldn't find matching pathnodes to waypoints"); DebugConsole.ThrowError("Pathfinding error, couldn't find matching pathnodes to waypoints");
return new SteeringPath();; return new SteeringPath();
} }
} }
@@ -17,7 +17,7 @@ namespace Barotrauma
protected float walkSpeed, swimSpeed; protected float walkSpeed, swimSpeed;
//how large impacts the character can take before being stunned //how large impacts the Character can take before being stunned
//protected float impactTolerance; //protected float impactTolerance;
protected float stunTimer; protected float stunTimer;
@@ -25,7 +25,7 @@ namespace Barotrauma
prefabs = new List<BackgroundSpritePrefab>(); prefabs = new List<BackgroundSpritePrefab>();
XDocument doc = ToolBox.TryLoadXml(configPath); XDocument doc = ToolBox.TryLoadXml(configPath);
if (doc == null) return; if (doc == null || doc.Root == null) return;
foreach (XElement element in doc.Root.Elements()) foreach (XElement element in doc.Root.Elements())
{ {
@@ -78,7 +78,7 @@ namespace Barotrauma
} }
if (amount > 0) if (amount > 0)
{ {
Swarm swarm = new Swarm(swarmMembers, prefab.SwarmRadius); new Swarm(swarmMembers, prefab.SwarmRadius);
} }
} }
} }
+17 -18
View File
@@ -5,12 +5,10 @@ using FarseerPhysics.Dynamics.Joints;
using Lidgren.Network; using Lidgren.Network;
using Microsoft.Xna.Framework; using Microsoft.Xna.Framework;
using Microsoft.Xna.Framework.Graphics; using Microsoft.Xna.Framework.Graphics;
using Microsoft.Xna.Framework.Input;
using Barotrauma.Networking; using Barotrauma.Networking;
using Barotrauma.Particles; using Barotrauma.Particles;
using System; using System;
using System.Collections.Generic; using System.Collections.Generic;
using System.Diagnostics;
using System.Linq; using System.Linq;
using System.Xml.Linq; using System.Xml.Linq;
@@ -27,7 +25,7 @@ namespace Barotrauma
public static bool DisableControls; public static bool DisableControls;
//the character that the player is currently controlling //the Character that the player is currently controlling
private static Character controlled; private static Character controlled;
public static Character Controlled public static Character Controlled
@@ -43,7 +41,6 @@ namespace Barotrauma
} }
public readonly bool IsNetworkPlayer; public readonly bool IsNetworkPlayer;
private int importantUpdateTimer;
private CharacterInventory inventory; private CharacterInventory inventory;
@@ -116,7 +113,7 @@ namespace Barotrauma
{ {
get get
{ {
return (info != null && !string.IsNullOrWhiteSpace(info.Name)) ? info.Name : SpeciesName; return info != null && !string.IsNullOrWhiteSpace(info.Name) ? info.Name : SpeciesName;
} }
} }
@@ -334,7 +331,7 @@ namespace Barotrauma
Info = characterInfo==null ? new CharacterInfo(file) : characterInfo; Info = characterInfo==null ? new CharacterInfo(file) : characterInfo;
XDocument doc = ToolBox.TryLoadXml(file); XDocument doc = ToolBox.TryLoadXml(file);
if (doc == null) return; if (doc == null || doc.Root == null) return;
SpeciesName = ToolBox.GetAttributeString(doc.Root, "name", "Unknown"); SpeciesName = ToolBox.GetAttributeString(doc.Root, "name", "Unknown");
@@ -516,7 +513,7 @@ namespace Barotrauma
if (IsKeyDown(InputType.Down)) targetMovement.Y -= 1.0f; if (IsKeyDown(InputType.Down)) targetMovement.Y -= 1.0f;
//the vertical component is only used for falling through platforms and climbing ladders when not in water, //the vertical component is only used for falling through platforms and climbing ladders when not in water,
//so the movement can't be normalized or the character would walk slower when pressing down/up //so the movement can't be normalized or the Character would walk slower when pressing down/up
if (AnimController.InWater) if (AnimController.InWater)
{ {
float length = targetMovement.Length(); float length = targetMovement.Length();
@@ -693,7 +690,7 @@ namespace Barotrauma
} }
/// <summary> /// <summary>
/// Control the character according to player input /// Control the Character according to player input
/// </summary> /// </summary>
public void ControlLocalPlayer(float deltaTime, Camera cam, bool moveCam = true) public void ControlLocalPlayer(float deltaTime, Camera cam, bool moveCam = true)
{ {
@@ -753,7 +750,7 @@ namespace Barotrauma
} }
//find the closest item if selectkey has been hit, or if the character is being //find the closest item if selectkey has been hit, or if the Character is being
//controlled by the player (in order to highlight it) //controlled by the player (in order to highlight it)
if (findClosestTimer <= 0.0f || Screen.Selected == GameMain.EditMapScreen) if (findClosestTimer <= 0.0f || Screen.Selected == GameMain.EditMapScreen)
@@ -921,13 +918,13 @@ namespace Barotrauma
aiTarget.SightRange = 0.0f; aiTarget.SightRange = 0.0f;
//distance is approximated based on the mass of the character //distance is approximated based on the mass of the Character
//(which corresponds to size because all the characters have the same limb density) //(which corresponds to size because all the characters have the same limb density)
foreach (Limb limb in AnimController.Limbs) foreach (Limb limb in AnimController.Limbs)
{ {
aiTarget.SightRange += limb.Mass * 1000.0f; aiTarget.SightRange += limb.Mass * 1000.0f;
} }
//the faster the character is moving, the easier it is to see it //the faster the Character is moving, the easier it is to see it
Limb torso = AnimController.GetLimb(LimbType.Torso); Limb torso = AnimController.GetLimb(LimbType.Torso);
if (torso !=null) if (torso !=null)
{ {
@@ -1060,6 +1057,8 @@ namespace Barotrauma
foreach (Limb limb in AnimController.Limbs) foreach (Limb limb in AnimController.Limbs)
{ {
limb.AddDamage(limb.SimPosition, DamageType.Blunt, 500.0f, 0.0f, false);
Vector2 diff = centerOfMass - limb.SimPosition; Vector2 diff = centerOfMass - limb.SimPosition;
if (diff == Vector2.Zero) continue; if (diff == Vector2.Zero) continue;
limb.body.ApplyLinearImpulse(diff * 10.0f); limb.body.ApplyLinearImpulse(diff * 10.0f);
@@ -1138,7 +1137,7 @@ namespace Barotrauma
if (GameMain.NetworkMember != null) if (GameMain.NetworkMember != null)
{ {
//if the character is controlled by this client/server, let others know that the character has died //if the Character is controlled by this client/server, let others know that the Character has died
if (Character.controlled == this) if (Character.controlled == this)
{ {
string chatMessage = "You have " + DeathMsg[(int)causeOfDeath] + "."; string chatMessage = "You have " + DeathMsg[(int)causeOfDeath] + ".";
@@ -1149,12 +1148,12 @@ namespace Barotrauma
new NetworkEvent(NetworkEventType.KillCharacter, ID, true, causeOfDeath); new NetworkEvent(NetworkEventType.KillCharacter, ID, true, causeOfDeath);
} }
//if it's an ai character, only let the server kill it //if it's an ai Character, only let the server kill it
else if (GameMain.Server != null && this is AICharacter) else if (GameMain.Server != null && this is AICharacter)
{ {
new NetworkEvent(NetworkEventType.KillCharacter, ID, true, causeOfDeath); new NetworkEvent(NetworkEventType.KillCharacter, ID, true, causeOfDeath);
} }
//otherwise don't kill the character unless received a message about the character dying //otherwise don't kill the Character unless received a message about the Character dying
else if (!isNetworkMessage) else if (!isNetworkMessage)
{ {
return; return;
@@ -1350,9 +1349,9 @@ namespace Barotrauma
case NetworkEventType.KillCharacter: case NetworkEventType.KillCharacter:
if (GameMain.Server != null) if (GameMain.Server != null)
{ {
Client sender =GameMain.Server.connectedClients.Find(c => c.Connection == message.SenderConnection); Client sender =GameMain.Server.ConnectedClients.Find(c => c.Connection == message.SenderConnection);
if (sender ==null || sender.character != this) if (sender ==null || sender.Character != this)
throw new Exception("Received a KillCharacter message from someone else than the client controlling the character!"); throw new Exception("Received a KillCharacter message from someone else than the client controlling the Character!");
} }
CauseOfDeath causeOfDeath = CauseOfDeath.Damage; CauseOfDeath causeOfDeath = CauseOfDeath.Damage;
@@ -1505,7 +1504,7 @@ namespace Barotrauma
catch catch
{ {
//failed to read position, character may be further than NetConfig.CharacterIgnoreDistance //failed to read position, Character may be further than NetConfig.CharacterIgnoreDistance
pos = SimPosition; pos = SimPosition;
} }
@@ -45,8 +45,6 @@ namespace Barotrauma
if (character.Inventory != null) character.Inventory.DrawOwn(spriteBatch); if (character.Inventory != null) character.Inventory.DrawOwn(spriteBatch);
Color color = Color.Orange;
if (character.SelectedCharacter != null && character.SelectedCharacter.Inventory!=null) if (character.SelectedCharacter != null && character.SelectedCharacter.Inventory!=null)
{ {
character.SelectedCharacter.Inventory.Draw(spriteBatch); character.SelectedCharacter.Inventory.Draw(spriteBatch);
@@ -274,7 +274,7 @@ namespace Barotrauma
public virtual XElement Save(XElement parentElement) public virtual XElement Save(XElement parentElement)
{ {
XElement charElement = new XElement("character"); XElement charElement = new XElement("Character");
charElement.Add( charElement.Add(
new XAttribute("name", Name), new XAttribute("name", Name),
@@ -178,7 +178,7 @@ namespace Barotrauma
//headMovement *= movement.Length(); //headMovement *= movement.Length();
//the movement angle is between direction of the head and the direction //the movement angle is between direction of the head and the direction
//where the character is actually trying to go //where the Character is actually trying to go
//current * (float)alpha + previous * (1.0f - (float)alpha); //current * (float)alpha + previous * (1.0f - (float)alpha);
@@ -685,7 +685,7 @@ namespace Barotrauma
leftLeg.body.ApplyTorque(Dir * -8.0f); leftLeg.body.ApplyTorque(Dir * -8.0f);
rightLeg.body.ApplyTorque(Dir * -8.0f); rightLeg.body.ApplyTorque(Dir * -8.0f);
//apply forces to the head and the torso to move the character up/down //apply forces to the head and the torso to move the Character up/down
float movementFactor = (handPos.Y / stepHeight) * (float)Math.PI; float movementFactor = (handPos.Y / stepHeight) * (float)Math.PI;
movementFactor = 0.8f + (float)Math.Abs(Math.Sin(movementFactor)); movementFactor = 0.8f + (float)Math.Abs(Math.Sin(movementFactor));
@@ -727,7 +727,7 @@ namespace Barotrauma
// Limb rightHand = GetLimb(LimbType.RightHand); // Limb rightHand = GetLimb(LimbType.RightHand);
// Limb head = GetLimb(LimbType.Head); // Limb head = GetLimb(LimbType.Head);
// Vector2 diff = Vector2.Normalize(character.CursorPosition - RefLimb.Position); // Vector2 diff = Vector2.Normalize(Character.CursorPosition - RefLimb.Position);
// rightHand.body.ApplyLinearImpulse(diff * 20.0f); // rightHand.body.ApplyLinearImpulse(diff * 20.0f);
// head.body.ApplyLinearImpulse(diff * 5.0f); // head.body.ApplyLinearImpulse(diff * 5.0f);
@@ -863,8 +863,6 @@ namespace Barotrauma
transformedHoldPos += Vector2.Transform(itemPos, torsoTransform); transformedHoldPos += Vector2.Transform(itemPos, torsoTransform);
} }
Vector2 bodyVelocity = torso.body.LinearVelocity / 60.0f;
item.body.ResetDynamics(); item.body.ResetDynamics();
Vector2 currItemPos = (character.SelectedItems[0]==item) ? Vector2 currItemPos = (character.SelectedItems[0]==item) ?
@@ -29,7 +29,7 @@ namespace Barotrauma
private set; private set;
} }
//names of the items the character spawns with //names of the items the Character spawns with
public List<string> ItemNames; public List<string> ItemNames;
public List<bool> EquipItem; public List<bool> EquipItem;
+37 -5
View File
@@ -34,7 +34,7 @@ namespace Barotrauma
protected readonly Vector2 stepOffset; protected readonly Vector2 stepOffset;
public Sprite sprite; public Sprite sprite, damagedSprite;
public bool inWater; public bool inWater;
@@ -50,6 +50,8 @@ namespace Barotrauma
public readonly float impactTolerance; public readonly float impactTolerance;
private float damage;
private readonly Vector2 armorSector; private readonly Vector2 armorSector;
private readonly float armorValue; private readonly float armorValue;
@@ -142,7 +144,7 @@ namespace Barotrauma
// set // set
// { // {
// damage = Math.Max(value, 0.0f); // damage = Math.Max(value, 0.0f);
// if (damage >=maxHealth) character.Kill(); // if (damage >=maxHealth) Character.Kill();
// } // }
//} //}
@@ -246,7 +248,7 @@ namespace Barotrauma
foreach (XElement subElement in element.Elements()) foreach (XElement subElement in element.Elements())
{ {
switch (subElement.Name.ToString()) switch (subElement.Name.ToString().ToLower())
{ {
case "sprite": case "sprite":
string spritePath = subElement.Attribute("texture").Value; string spritePath = subElement.Attribute("texture").Value;
@@ -260,6 +262,18 @@ namespace Barotrauma
sprite = new Sprite(subElement, "", spritePath); sprite = new Sprite(subElement, "", spritePath);
break; break;
case "damagedsprite":
string damagedSpritePath = subElement.Attribute("texture").Value;
if (character.Info != null)
{
damagedSpritePath = damagedSpritePath.Replace("[GENDER]", (character.Info.Gender == Gender.Female) ? "f" : "");
damagedSpritePath = damagedSpritePath.Replace("[HEADID]", character.Info.HeadSpriteId.ToString());
}
damagedSprite = new Sprite(subElement, "", damagedSpritePath);
break;
case "attack": case "attack":
attack = new Attack(subElement); attack = new Attack(subElement);
break; break;
@@ -313,10 +327,9 @@ namespace Barotrauma
damageSoundType = DamageSoundType.LimbArmor; damageSoundType = DamageSoundType.LimbArmor;
amount = Math.Max(0.0f, amount - totalArmorValue); amount = Math.Max(0.0f, amount - totalArmorValue);
bleedingAmount = Math.Max(0.0f, bleedingAmount - totalArmorValue); ; bleedingAmount = Math.Max(0.0f, bleedingAmount - totalArmorValue);
} }
if (playSound) if (playSound)
{ {
SoundPlayer.PlayDamageSound(damageSoundType, amount, ConvertUnits.ToDisplayUnits(simPosition)); SoundPlayer.PlayDamageSound(damageSoundType, amount, ConvertUnits.ToDisplayUnits(simPosition));
@@ -342,6 +355,9 @@ namespace Barotrauma
GameMain.ParticleManager.CreateParticle("waterblood", Position, Vector2.Zero); GameMain.ParticleManager.CreateParticle("waterblood", Position, Vector2.Zero);
} }
damage += Math.Max(amount,bleedingAmount) / character.MaxHealth * 100.0f;
return new AttackResult(amount, bleedingAmount, hitArmor); return new AttackResult(amount, bleedingAmount, hitArmor);
} }
@@ -362,6 +378,9 @@ namespace Barotrauma
public void Update(float deltaTime) public void Update(float deltaTime)
{ {
if (!character.IsDead) damage = Math.Max(0.0f, damage-deltaTime*0.1f);
if (LinearVelocity.X>100.0f) if (LinearVelocity.X>100.0f)
{ {
//DebugConsole.ThrowError("CHARACTER EXPLODED"); //DebugConsole.ThrowError("CHARACTER EXPLODED");
@@ -454,6 +473,19 @@ namespace Barotrauma
1.0f, spriteEffect, depth); 1.0f, spriteEffect, depth);
} }
if (damage>0.0f && damagedSprite!=null)
{
SpriteEffects spriteEffect = (dir == Direction.Right) ? SpriteEffects.None : SpriteEffects.FlipHorizontally;
float depth = sprite.Depth - 0.0000015f;
damagedSprite.Draw(spriteBatch,
new Vector2(body.DrawPosition.X, -body.DrawPosition.Y),
color*Math.Min(damage/50.0f,1.0f), sprite.origin,
-body.DrawRotation,
1.0f, spriteEffect, depth);
}
if (!GameMain.DebugDraw) return; if (!GameMain.DebugDraw) return;
if (pullJoint!=null) if (pullJoint!=null)
+3 -3
View File
@@ -41,7 +41,7 @@ namespace Barotrauma
private Vector2 targetMovement; private Vector2 targetMovement;
//a movement vector that overrides targetmovement if trying to steer //a movement vector that overrides targetmovement if trying to steer
//a character to the position sent by server in multiplayer mode //a Character to the position sent by server in multiplayer mode
protected Vector2 correctionMovement; protected Vector2 correctionMovement;
protected float floorY; protected float floorY;
@@ -616,7 +616,7 @@ namespace Barotrauma
{ {
//create a splash particle //create a splash particle
Barotrauma.Particles.Particle splash = GameMain.ParticleManager.CreateParticle("watersplash", GameMain.ParticleManager.CreateParticle("watersplash",
new Vector2(limb.Position.X, limbHull.Surface), new Vector2(limb.Position.X, limbHull.Surface),
new Vector2(0.0f, Math.Abs(-limb.LinearVelocity.Y * 10.0f)), new Vector2(0.0f, Math.Abs(-limb.LinearVelocity.Y * 10.0f)),
0.0f); 0.0f);
@@ -633,7 +633,7 @@ namespace Barotrauma
//if the character dropped into water, create a wave //if the Character dropped into water, create a wave
if (limb.LinearVelocity.Y<0.0f) if (limb.LinearVelocity.Y<0.0f)
{ {
//1.0 when the limb is parallel to the surface of the water //1.0 when the limb is parallel to the surface of the water
+4 -4
View File
@@ -162,9 +162,9 @@ namespace Barotrauma
} }
//public virtual void Apply(ActionType type, float deltaTime, Item item, Character character = null) //public virtual void Apply(ActionType type, float deltaTime, Item item, Character Character = null)
//{ //{
// if (this.type == type) Apply(deltaTime, character, item); // if (this.type == type) Apply(deltaTime, Character, item);
//} //}
private bool HasRequiredItems(Entity entity) private bool HasRequiredItems(Entity entity)
@@ -225,7 +225,7 @@ namespace Barotrauma
} }
} }
//protected virtual void Apply(float deltaTime, Character character, Item item) //protected virtual void Apply(float deltaTime, Character Character, Item item)
//{ //{
// if (explosion != null) explosion.Explode(item.SimPosition); // if (explosion != null) explosion.Explode(item.SimPosition);
@@ -235,7 +235,7 @@ namespace Barotrauma
// { // {
// ObjectProperty property; // ObjectProperty property;
// if (character!=null && character.properties.TryGetValue(propertyNames[i], out property)) // if (Character!=null && Character.properties.TryGetValue(propertyNames[i], out property))
// { // {
// ApplyToProperty(property, propertyEffects[i], deltaTime); // ApplyToProperty(property, propertyEffects[i], deltaTime);
// } // }
-2
View File
@@ -130,8 +130,6 @@ namespace Barotrauma
private void CalculateHash() private void CalculateHash()
{ {
StringBuilder sb = new StringBuilder();
List<byte[]> hashes = new List<byte[]>(); List<byte[]> hashes = new List<byte[]>();
//foreach (ContentFile file in files) //foreach (ContentFile file in files)
+8 -6
View File
@@ -167,8 +167,8 @@ namespace Barotrauma
{ {
SinglePlayerMode mode = GameMain.GameSession.gameMode as SinglePlayerMode; SinglePlayerMode mode = GameMain.GameSession.gameMode as SinglePlayerMode;
if (mode == null) break; if (mode == null) break;
mode.CrewManager.AddCharacter(Character.Controlled); GameMain.GameSession.CrewManager.AddCharacter(Character.Controlled);
mode.CrewManager.SelectCharacter(null, Character.Controlled); GameMain.GameSession.CrewManager.SelectCharacter(null, Character.Controlled);
} }
} }
else else
@@ -232,10 +232,12 @@ namespace Barotrauma
break; break;
case "editwater": case "editwater":
case "water": case "water":
if (GameMain.Client== null) if (GameMain.Client == null) Hull.EditWater = !Hull.EditWater;
{
Hull.EditWater = !Hull.EditWater; break;
} case "fire":
if (GameMain.Client == null) Hull.EditFire = !Hull.EditFire;
break; break;
case "generatelevel": case "generatelevel":
GameMain.Level = new Level("asdf", 50.0f, 500,500, 50); GameMain.Level = new Level("asdf", 50.0f, 500,500, 50);
+1 -1
View File
@@ -101,7 +101,7 @@ namespace EventInput
public static class EventInput public static class EventInput
{ {
/// <summary> /// <summary>
/// Event raised when a character has been entered. /// Event raised when a Character has been entered.
/// </summary> /// </summary>
public static event CharEnteredHandler CharEntered; public static event CharEnteredHandler CharEntered;
+2 -2
View File
@@ -41,9 +41,9 @@ namespace Barotrauma
public Task(float priority, string name) public Task(float priority, string name)
{ {
if (GameMain.GameSession==null || GameMain.GameSession.taskManager == null) return; if (GameMain.GameSession==null || GameMain.GameSession.TaskManager == null) return;
taskManager = GameMain.GameSession.taskManager; taskManager = GameMain.GameSession.TaskManager;
musicType = "repair"; musicType = "repair";
this.priority = priority; this.priority = priority;
this.name = name; this.name = name;
+2 -2
View File
@@ -85,9 +85,9 @@ namespace Barotrauma
if (textBlock.Text != "") if (textBlock.Text != "")
{ {
//if you attempt to display a character that is not in your font //if you attempt to display a Character that is not in your font
//you will get an exception, so we filter the characters //you will get an exception, so we filter the characters
//remove the filtering if you're using a default character in your spritefont //remove the filtering if you're using a default Character in your spritefont
String filtered = ""; String filtered = "";
foreach (char c in value) foreach (char c in value)
{ {
@@ -32,7 +32,7 @@ namespace Barotrauma
Hull cargoRoom = Hull.FindHull(wp.Position); Hull cargoRoom = Hull.FindHull(wp.Position);
if (wp == null) if (cargoRoom == null)
{ {
DebugConsole.ThrowError("A waypoint marked as Cargo must be placed inside a room!"); DebugConsole.ThrowError("A waypoint marked as Cargo must be placed inside a room!");
return; return;
@@ -44,7 +44,7 @@ namespace Barotrauma
Rand.Range(cargoRoom.Rect.X + 20, cargoRoom.Rect.Right - 20), Rand.Range(cargoRoom.Rect.X + 20, cargoRoom.Rect.Right - 20),
Rand.Range(cargoRoom.Rect.Y - cargoRoom.Rect.Height + 20.0f, cargoRoom.Rect.Y)); Rand.Range(cargoRoom.Rect.Y - cargoRoom.Rect.Height + 20.0f, cargoRoom.Rect.Y));
new Item(prefab as ItemPrefab, wp.Position); new Item(prefab as ItemPrefab, position);
} }
purchasedItems.Clear(); purchasedItems.Clear();
+77 -1
View File
@@ -20,6 +20,10 @@ namespace Barotrauma
private GUIFrame guiFrame; private GUIFrame guiFrame;
private GUIListBox listBox; private GUIListBox listBox;
private bool crewFrameOpen;
private GUIButton crewButton;
protected GUIFrame crewFrame;
public int Money public int Money
{ {
@@ -34,10 +38,13 @@ namespace Barotrauma
guiFrame = new GUIFrame(new Rectangle(0, 50, 150, 450), Color.Transparent); guiFrame = new GUIFrame(new Rectangle(0, 50, 150, 450), Color.Transparent);
listBox = new GUIListBox(new Rectangle(0, 0, 150, 0), Color.Transparent, null, guiFrame); listBox = new GUIListBox(new Rectangle(0, 30, 150, 0), Color.Transparent, null, guiFrame);
listBox.ScrollBarEnabled = false; listBox.ScrollBarEnabled = false;
listBox.OnSelected = SelectCharacter; listBox.OnSelected = SelectCharacter;
crewButton = new GUIButton(new Rectangle(0, 00, 100, 20), "Crew", GUI.Style, guiFrame);
crewButton.OnClicked = ToggleCrewFrame;
money = 10000; money = 10000;
} }
@@ -100,6 +107,8 @@ namespace Barotrauma
public void Update(float deltaTime) public void Update(float deltaTime)
{ {
guiFrame.Update(deltaTime); guiFrame.Update(deltaTime);
if (crewFrameOpen) crewFrame.Update(deltaTime);
} }
public void KillCharacter(Character killedCharacter) public void KillCharacter(Character killedCharacter)
@@ -113,6 +122,71 @@ namespace Barotrauma
//} //}
} }
public void CreateCrewFrame(List<Character> crew)
{
int width = 600, height = 400;
crewFrame = new GUIFrame(new Rectangle(GameMain.GraphicsWidth / 2 - width / 2, GameMain.GraphicsHeight / 2 - height / 2, width, height), GUI.Style);
crewFrame.Padding = new Vector4(10.0f, 10.0f, 10.0f, 10.0f);
GUIListBox crewList = new GUIListBox(new Rectangle(0, 0, 280, 300), Color.White * 0.7f, GUI.Style, crewFrame);
crewList.Padding = new Vector4(10.0f, 10.0f, 10.0f, 10.0f);
crewList.OnSelected = SelectCrewCharacter;
foreach (Character character in crew)
{
GUIFrame frame = new GUIFrame(new Rectangle(0, 0, 0, 40), Color.Transparent, null, crewList);
frame.UserData = character;
frame.Padding = new Vector4(5.0f, 5.0f, 5.0f, 5.0f);
frame.Color = (GameMain.NetworkMember != null && GameMain.NetworkMember.Character == character) ? Color.Gold * 0.2f : Color.Transparent;
frame.HoverColor = Color.LightGray * 0.5f;
frame.SelectedColor = Color.Gold * 0.5f;
GUITextBlock textBlock = new GUITextBlock(
new Rectangle(40, 0, 0, 25),
character.Info.Name + " (" + character.Info.Job.Name + ")",
Color.Transparent, Color.White,
Alignment.Left, Alignment.Left,
null, frame);
textBlock.Padding = new Vector4(5.0f, 0.0f, 5.0f, 0.0f);
new GUIImage(new Rectangle(-10, 0, 0, 0), character.AnimController.Limbs[0].sprite, Alignment.Left, frame);
}
var closeButton = new GUIButton(new Rectangle(0, 0, 80, 20), "Close", Alignment.BottomCenter, GUI.Style, crewFrame);
closeButton.OnClicked = ToggleCrewFrame;
}
protected virtual bool SelectCrewCharacter(GUIComponent component, object obj)
{
Character character = obj as Character;
if (character == null) return false;
GUIComponent existingFrame = crewFrame.FindChild("selectedcharacter");
if (existingFrame != null) crewFrame.RemoveChild(existingFrame);
var previewPlayer = new GUIFrame(
new Rectangle(0, 0, 230, 300),
new Color(0.0f, 0.0f, 0.0f, 0.8f), Alignment.TopRight, GUI.Style, crewFrame);
previewPlayer.Padding = new Vector4(5.0f, 5.0f, 5.0f, 5.0f);
previewPlayer.UserData = "selectedcharacter";
character.Info.CreateInfoFrame(previewPlayer);
if (GameMain.NetworkMember != null) GameMain.NetworkMember.SelectCrewCharacter(component, obj);
return true;
}
private bool ToggleCrewFrame(GUIButton button, object obj)
{
if (crewFrame == null) CreateCrewFrame(characters);
crewFrameOpen = !crewFrameOpen;
return true;
}
public void StartShift() public void StartShift()
{ {
listBox.ClearChildren(); listBox.ClearChildren();
@@ -161,6 +235,8 @@ namespace Barotrauma
public void Draw(SpriteBatch spriteBatch) public void Draw(SpriteBatch spriteBatch)
{ {
guiFrame.Draw(spriteBatch); guiFrame.Draw(spriteBatch);
if (crewFrameOpen) crewFrame.Draw(spriteBatch);
} }
public void Save(XElement parentElement) public void Save(XElement parentElement)
@@ -47,6 +47,11 @@ namespace Barotrauma
get { return endMessage; } get { return endMessage; }
} }
public GameModePreset Preset
{
get { return preset; }
}
public GameMode(GameModePreset preset) public GameMode(GameModePreset preset)
{ {
this.preset = preset; this.preset = preset;
@@ -12,7 +12,7 @@ namespace Barotrauma
{ {
//private const int StartCharacterAmount = 3; //private const int StartCharacterAmount = 3;
public readonly CrewManager CrewManager; //public readonly CrewManager CrewManager;
//public readonly HireManager hireManager; //public readonly HireManager hireManager;
private GUIButton endShiftButton; private GUIButton endShiftButton;
@@ -36,14 +36,18 @@ namespace Barotrauma
public int Money public int Money
{ {
get { return CrewManager.Money; } get { return GameMain.GameSession.CrewManager.Money; }
set { CrewManager.Money = value; } set { GameMain.GameSession.CrewManager.Money = value; }
}
private CrewManager CrewManager
{
get { return GameMain.GameSession.CrewManager; }
} }
public SinglePlayerMode(GameModePreset preset) public SinglePlayerMode(GameModePreset preset)
: base(preset) : base(preset)
{ {
CrewManager = new CrewManager();
CargoManager = new CargoManager(); CargoManager = new CargoManager();
@@ -86,7 +90,7 @@ namespace Barotrauma
{ {
if (subElement.Name.ToString().ToLower() != "crew") continue; if (subElement.Name.ToString().ToLower() != "crew") continue;
CrewManager = new CrewManager(subElement); GameMain.GameSession.CrewManager = new CrewManager(subElement);
} }
savedOnStart = true; savedOnStart = true;
@@ -23,7 +23,7 @@ namespace Barotrauma
GameMain.GameSession.StartShift("tuto"); GameMain.GameSession.StartShift("tuto");
GameMain.GameSession.taskManager.Tasks.Clear(); GameMain.GameSession.TaskManager.Tasks.Clear();
GameMain.GameScreen.Select(); GameMain.GameScreen.Select();
} }
@@ -255,7 +255,6 @@ namespace Barotrauma
infoBox = CreateInfoFrame("You can see the equipped wire at the middle of the connection panel. Drag it to the power connector."); infoBox = CreateInfoFrame("You can see the equipped wire at the middle of the connection panel. Drag it to the power connector.");
var steeringConnection = steering.Item.Connections.Find(c => c.Name.Contains("power")); var steeringConnection = steering.Item.Connections.Find(c => c.Name.Contains("power"));
var junctionConnection = junctionBox.Item.Connections.Find(c => c.Name.Contains("power"));
while (steeringConnection.Wires.FirstOrDefault(w => w != null) == null) while (steeringConnection.Wires.FirstOrDefault(w => w != null) == null)
{ {
+20 -27
View File
@@ -12,23 +12,17 @@ namespace Barotrauma
{ {
class GameSession class GameSession
{ {
public readonly TaskManager taskManager; public readonly TaskManager TaskManager;
//protected DateTime startTime;
//protected DateTime endTime;
public readonly GameMode gameMode;
public readonly GameMode gameMode;
private GUIFrame guiRoot; private GUIFrame guiRoot;
//private GUIListBox chatBox;
//private GUITextBox textBox;
private string saveFile; private string saveFile;
private Submarine submarine; private Submarine submarine;
public CrewManager CrewManager;
public Quest Quest public Quest Quest
{ {
@@ -65,28 +59,29 @@ namespace Barotrauma
get { return saveFile; } get { return saveFile; }
} }
public GameSession(Submarine submarine, string saveFile, GameModePreset gameModePreset) public GameSession(Submarine submarine, string saveFile, GameModePreset gameModePreset = null)
:this(submarine, saveFile, gameModePreset.Instantiate())
{ {
GameMain.GameSession = this;
} CrewManager = new CrewManager();
public GameSession(Submarine selectedSub, string saveFile, GameMode gameMode = null) TaskManager = new TaskManager(this);
{
taskManager = new TaskManager(this);
this.saveFile = saveFile; this.saveFile = saveFile;
guiRoot = new GUIFrame(new Rectangle(0,0,GameMain.GraphicsWidth,GameMain.GraphicsWidth), Color.Transparent); guiRoot = new GUIFrame(new Rectangle(0,0,GameMain.GraphicsWidth,GameMain.GraphicsWidth), Color.Transparent);
this.gameMode = gameMode; if (gameModePreset!=null) this.gameMode = gameModePreset.Instantiate();
this.submarine = selectedSub; this.submarine = submarine;
} }
public GameSession(Submarine selectedSub, string saveFile, string filePath) public GameSession(Submarine selectedSub, string saveFile, string filePath)
: this(selectedSub, saveFile) : this(selectedSub, saveFile)
{ {
GameMain.GameSession = this;
CrewManager = new CrewManager();
XDocument doc = ToolBox.TryLoadXml(filePath); XDocument doc = ToolBox.TryLoadXml(filePath);
if (doc == null) return; if (doc == null) return;
@@ -131,7 +126,7 @@ namespace Barotrauma
if (gameMode!=null) gameMode.Start(); if (gameMode!=null) gameMode.Start();
taskManager.StartShift(level); TaskManager.StartShift(level);
} }
public void EndShift(string endMessage) public void EndShift(string endMessage)
@@ -149,7 +144,7 @@ namespace Barotrauma
GameMain.LobbyScreen.Select(); GameMain.LobbyScreen.Select();
} }
taskManager.EndShift(); TaskManager.EndShift();
//gameMode.End(); //gameMode.End();
//return true; //return true;
@@ -158,9 +153,7 @@ namespace Barotrauma
public void KillCharacter(Character character) public void KillCharacter(Character character)
{ {
SinglePlayerMode singlePlayerMode = gameMode as SinglePlayerMode; CrewManager.KillCharacter(character);
if (singlePlayerMode == null) return;
singlePlayerMode.CrewManager.KillCharacter(character);
} }
public bool LoadPrevious(GUIButton button, object obj) public bool LoadPrevious(GUIButton button, object obj)
@@ -174,7 +167,7 @@ namespace Barotrauma
public void Update(float deltaTime) public void Update(float deltaTime)
{ {
taskManager.Update(deltaTime); TaskManager.Update(deltaTime);
guiRoot.Update(deltaTime); guiRoot.Update(deltaTime);
+1 -1
View File
@@ -336,7 +336,7 @@ namespace Barotrauma.Items.Components
} }
//opening a partially stuck door makes it less stuck //opening a partially stuck door makes it less stuck
if (isOpen) stuck = MathHelper.Clamp(stuck-30.0f, 0.0f, 100.0f); ; if (isOpen) stuck = MathHelper.Clamp(stuck-30.0f, 0.0f, 100.0f);
} }
} }
} }
@@ -7,7 +7,7 @@ namespace Barotrauma.Items.Components
{ {
class Holdable : Pickable class Holdable : Pickable
{ {
//the position(s) in the item that the character grabs //the position(s) in the item that the Character grabs
protected Vector2[] handlePos; protected Vector2[] handlePos;
private List<RelatedItem> prevRequiredItems; private List<RelatedItem> prevRequiredItems;
@@ -24,7 +24,7 @@ namespace Barotrauma.Items.Components
private bool attachable, attached, attachedByDefault; private bool attachable, attached, attachedByDefault;
private PhysicsBody body; private PhysicsBody body;
//the angle in which the character holds the item //the angle in which the Character holds the item
protected float holdAngle; protected float holdAngle;
[HasDefaultValue(false, true)] [HasDefaultValue(false, true)]
@@ -115,13 +115,11 @@ namespace Barotrauma.Items.Components
AnimController ac = picker.AnimController; AnimController ac = picker.AnimController;
Limb rightHand = ac.GetLimb(LimbType.RightHand);
if (!hitting) if (!hitting)
{ {
if (picker.IsKeyDown(InputType.Aim)) if (picker.IsKeyDown(InputType.Aim))
{ {
hitPos = (float)System.Math.Min(hitPos+deltaTime*5.0f, MathHelper.Pi*0.7f); hitPos = Math.Min(hitPos+deltaTime*5.0f, MathHelper.Pi*0.7f);
ac.HoldItem(deltaTime, item, handlePos, new Vector2(0.6f, -0.1f), new Vector2(-0.3f, 0.2f), false, hitPos); ac.HoldItem(deltaTime, item, handlePos, new Vector2(0.6f, -0.1f), new Vector2(-0.3f, 0.2f), false, hitPos);
} }
@@ -104,7 +104,7 @@ namespace Barotrauma.Items.Components
if (character == null) return false; if (character == null) return false;
if (!character.IsKeyDown(InputType.Aim)) return false; if (!character.IsKeyDown(InputType.Aim)) return false;
//if (DoesUseFail(character)) return false; //if (DoesUseFail(Character)) return false;
IsActive = true; IsActive = true;
@@ -181,7 +181,7 @@ namespace Barotrauma.Items.Components
//ApplyStatusEffects(ActionType.OnUse, 1.0f, null, targ); //ApplyStatusEffects(ActionType.OnUse, 1.0f, null, targ);
} }
//if (character.SecondaryKeyDown.State) //if (Character.SecondaryKeyDown.State)
//{ //{
// IPropertyObject propertyObject = targetBody.UserData as IPropertyObject; // IPropertyObject propertyObject = targetBody.UserData as IPropertyObject;
// if (propertyObject!=null) ApplyStatusEffects(ActionType.OnUse, 1.0f, item.SimPosition, propertyObject); // if (propertyObject!=null) ApplyStatusEffects(ActionType.OnUse, 1.0f, item.SimPosition, propertyObject);
@@ -30,18 +30,18 @@ namespace Barotrauma.Items.Components
if (character == null) return false; if (character == null) return false;
if (!character.IsKeyDown(InputType.Aim) || throwing) return false; if (!character.IsKeyDown(InputType.Aim) || throwing) return false;
//Vector2 diff = Vector2.Normalize(character.CursorPosition - character.AnimController.RefLimb.Position); //Vector2 diff = Vector2.Normalize(Character.CursorPosition - Character.AnimController.RefLimb.Position);
//if (character.SelectedItems[1]==item) //if (Character.SelectedItems[1]==item)
//{ //{
// Limb leftHand = character.AnimController.GetLimb(LimbType.LeftHand); // Limb leftHand = Character.AnimController.GetLimb(LimbType.LeftHand);
// leftHand.body.ApplyLinearImpulse(diff * 20.0f); // leftHand.body.ApplyLinearImpulse(diff * 20.0f);
// leftHand.Disabled = true; // leftHand.Disabled = true;
//} //}
//if (character.SelectedItems[0] == item) //if (Character.SelectedItems[0] == item)
//{ //{
// Limb rightHand = character.AnimController.GetLimb(LimbType.RightHand); // Limb rightHand = Character.AnimController.GetLimb(LimbType.RightHand);
// rightHand.body.ApplyLinearImpulse(diff * 20.0f); // rightHand.body.ApplyLinearImpulse(diff * 20.0f);
// rightHand.Disabled = true; // rightHand.Disabled = true;
//} //}
@@ -373,7 +373,7 @@ namespace Barotrauma.Items.Components
public virtual void Move(Vector2 amount) { } public virtual void Move(Vector2 amount) { }
/// <summary>a character has picked the item</summary> /// <summary>a Character has picked the item</summary>
public virtual bool Pick(Character picker) public virtual bool Pick(Character picker)
{ {
return false; return false;
@@ -384,7 +384,7 @@ namespace Barotrauma.Items.Components
return CanBeSelected; return CanBeSelected;
} }
/// <summary>a character has dropped the item</summary> /// <summary>a Character has dropped the item</summary>
public virtual void Drop(Character dropper) { } public virtual void Drop(Character dropper) { }
public virtual void Draw(SpriteBatch spriteBatch, bool editing = false) { } public virtual void Draw(SpriteBatch spriteBatch, bool editing = false) { }
@@ -475,7 +475,7 @@ namespace Barotrauma.Items.Components
} }
/// <summary> /// <summary>
/// Returns 0.0f-1.0f based on how well the character can use the itemcomponent /// Returns 0.0f-1.0f based on how well the Character can use the itemcomponent
/// </summary> /// </summary>
/// <returns>0.5f if all the skills meet the skill requirements exactly, 1.0f if they're way above and 0.0f if way less</returns> /// <returns>0.5f if all the skills meet the skill requirements exactly, 1.0f if they're way above and 0.0f if way less</returns>
protected float DegreeOfSuccess(Character character) protected float DegreeOfSuccess(Character character)
@@ -496,14 +496,14 @@ namespace Barotrauma.Items.Components
return (average+100.0f)/2.0f; return (average+100.0f)/2.0f;
} }
//public bool CheckFailure(Character character) //public bool CheckFailure(Character Character)
//{ //{
// foreach (Skill skill in requiredSkills) // foreach (Skill skill in requiredSkills)
// { // {
// int characterLevel = character.GetSkillLevel(skill.Name); // int characterLevel = Character.GetSkillLevel(skill.Name);
// if (characterLevel > skill.Level) continue; // if (characterLevel > skill.Level) continue;
// item.ApplyStatusEffects(ActionType.OnFailure, 1.0f, character); // item.ApplyStatusEffects(ActionType.OnFailure, 1.0f, Character);
// //Item.ApplyStatusEffects(); // //Item.ApplyStatusEffects();
// return true; // return true;
+4 -4
View File
@@ -30,7 +30,7 @@
// } // }
// public override bool Select(Character character) // public override bool Select(Character Character)
// { // {
// if (textBox == null) // if (textBox == null)
// { // {
@@ -47,10 +47,10 @@
// textBox.Select(); // textBox.Select();
// return base.Select(character); // return base.Select(Character);
// } // }
// public override void DrawHUD(SpriteBatch spriteBatch, Character character) // public override void DrawHUD(SpriteBatch spriteBatch, Character Character)
// { // {
// //isActive = true; // //isActive = true;
// GuiFrame.Update((float)Physics.step); // GuiFrame.Update((float)Physics.step);
@@ -61,7 +61,7 @@
// //int y = Game1.GraphicsHeight / 2 - height / 2 - 50; // //int y = Game1.GraphicsHeight / 2 - height / 2 - 50;
// //GUI.DrawRectangle(spriteBatch, new Rectangle(x, y, width, height), Color.Black, true); // //GUI.DrawRectangle(spriteBatch, new Rectangle(x, y, width, height), Color.Black, true);
// if (!textBox.Selected) character.SelectedConstruction = null; // if (!textBox.Selected) Character.SelectedConstruction = null;
// } // }
// private bool TextChanged(GUITextBox textBox, string text) // private bool TextChanged(GUITextBox textBox, string text)
@@ -42,8 +42,7 @@ namespace Barotrauma.Items.Components
ventList = new List<Vent>(); ventList = new List<Vent>();
item.linkedTo.CollectionChanged += delegate(object sender, System.Collections.Specialized.NotifyCollectionChangedEventArgs e) item.linkedTo.CollectionChanged += delegate { GetVents(); };
{ GetVents(); };
} }
public override void Update(float deltaTime, Camera cam) public override void Update(float deltaTime, Camera cam)
@@ -78,9 +78,8 @@ namespace Barotrauma.Items.Components
return (pingState > 1.0f); return (pingState > 1.0f);
} }
public override void DrawHUD(Microsoft.Xna.Framework.Graphics.SpriteBatch spriteBatch, Character character) public override void DrawHUD(SpriteBatch spriteBatch, Character character)
{ {
int width = GuiFrame.Rect.Width, height = GuiFrame.Rect.Height;
int x = GuiFrame.Rect.X; int x = GuiFrame.Rect.X;
int y = GuiFrame.Rect.Y; int y = GuiFrame.Rect.Y;
@@ -120,7 +119,6 @@ namespace Barotrauma.Items.Components
if (Level.Loaded != null) if (Level.Loaded != null)
{ {
List<VoronoiCell> cells = Level.Loaded.GetCells(-Level.Loaded.Position, 7); List<VoronoiCell> cells = Level.Loaded.GetCells(-Level.Loaded.Position, 7);
Vector2 offset = Vector2.Zero;
foreach (VoronoiCell cell in cells) foreach (VoronoiCell cell in cells)
{ {
@@ -174,7 +172,6 @@ namespace Barotrauma.Items.Components
end.Y = -end.Y; end.Y = -end.Y;
Vector2 diff = end - start; Vector2 diff = end - start;
Vector2 normalizedDiff = Vector2.Normalize(diff);
for (float x = 0; x < diff.Length(); x+=4.0f ) for (float x = 0; x < diff.Length(); x+=4.0f )
{ {
GUI.DrawLine(spriteBatch, center + start, center + end, Color.Green); GUI.DrawLine(spriteBatch, center + start, center + end, Color.Green);
@@ -141,7 +141,6 @@ namespace Barotrauma.Items.Components
public override void DrawHUD(SpriteBatch spriteBatch, Character character) public override void DrawHUD(SpriteBatch spriteBatch, Character character)
{ {
int width = GuiFrame.Rect.Width, height = GuiFrame.Rect.Height;
int x = GuiFrame.Rect.X; int x = GuiFrame.Rect.X;
int y = GuiFrame.Rect.Y; int y = GuiFrame.Rect.Y;
@@ -79,7 +79,7 @@ namespace Barotrauma.Items.Components
{ {
if (character != null && !characterUsable) return false; if (character != null && !characterUsable) return false;
//ApplyStatusEffects(ActionType.OnUse, 1.0f, character); //ApplyStatusEffects(ActionType.OnUse, 1.0f, Character);
Launch(new Vector2( Launch(new Vector2(
(float)Math.Cos(item.body.Rotation), (float)Math.Cos(item.body.Rotation),
@@ -191,7 +191,7 @@ namespace Barotrauma.Items.Components
bool mouseInRect = panelRect.Contains(PlayerInput.MousePosition); bool mouseInRect = panelRect.Contains(PlayerInput.MousePosition);
Wire equippedWire = null; Wire equippedWire = null;
//if the character using the panel has a wire item equipped //if the Character using the panel has a wire item equipped
//and the wire hasn't been connected yet, draw it on the panel //and the wire hasn't been connected yet, draw it on the panel
for (int i = 0; i < character.SelectedItems.Length; i++) for (int i = 0; i < character.SelectedItems.Length; i++)
{ {
@@ -246,7 +246,7 @@ namespace Barotrauma.Items.Components
} }
} }
//if the character using the panel has a wire item equipped //if the Character using the panel has a wire item equipped
//and the wire hasn't been connected yet, draw it on the panel //and the wire hasn't been connected yet, draw it on the panel
if (equippedWire!=null) if (equippedWire!=null)
{ {
@@ -262,9 +262,9 @@ namespace Barotrauma.Items.Components
} }
} }
//for (int i = 0; i < character.SelectedItems.Length; i++ ) //for (int i = 0; i < Character.SelectedItems.Length; i++ )
//{ //{
// Item selectedItem = character.SelectedItems[i]; // Item selectedItem = Character.SelectedItems[i];
// if (selectedItem == null) continue; // if (selectedItem == null) continue;
@@ -281,7 +281,7 @@ namespace Barotrauma.Items.Components
if (!PlayerInput.LeftButtonDown()) if (!PlayerInput.LeftButtonDown())
{ {
panel.Item.NewComponentEvent(panel, true, true); panel.Item.NewComponentEvent(panel, true, true);
//draggingConnected.Drop(character); //draggingConnected.Drop(Character);
draggingConnected = null; draggingConnected = null;
} }
} }
@@ -0,0 +1,38 @@
using System.Xml.Linq;
namespace Barotrauma.Items.Components
{
class WaterDetector : ItemComponent
{
private Hull hull;
public WaterDetector(Item item, XElement element)
: base (item, element)
{
hull = Hull.FindHull(item.Position);
IsActive = true;
}
public override void OnMapLoaded()
{
hull = Hull.FindHull(item.Position);
}
public override void Move(Microsoft.Xna.Framework.Vector2 amount)
{
hull = Hull.FindHull(item.Position);
}
public override void Update(float deltaTime, Camera cam)
{
if (hull == null) return;
float waterDepth = hull.Volume / hull.Size.X;
bool underWater = (hull.Rect.Y-hull.Rect.Height + waterDepth)>item.Position.Y;
item.SendSignal(underWater ? "1" : "0", "signal_out");
}
}
}
@@ -41,7 +41,7 @@ namespace Barotrauma.Items.Components
public override void Move(Vector2 amount) public override void Move(Vector2 amount)
{ {
amount = FarseerPhysics.ConvertUnits.ToDisplayUnits(amount); //amount = FarseerPhysics.ConvertUnits.ToDisplayUnits(amount);
//for (int i = 0; i<Nodes.Count; i++) //for (int i = 0; i<Nodes.Count; i++)
//{ //{
// Nodes[i] += amount; // Nodes[i] += amount;
+3 -3
View File
@@ -252,17 +252,17 @@ namespace Barotrauma
selectedSlot = containerRect.Contains(PlayerInput.MousePosition) ? slotIndex : -1; selectedSlot = containerRect.Contains(PlayerInput.MousePosition) ? slotIndex : -1;
GUI.DrawRectangle(spriteBatch, containerRect, Color.White, false); GUI.DrawRectangle(spriteBatch, containerRect, Color.White);
Item[] containedItems = null; Item[] containedItems = null;
if (items[slotIndex] != null) containedItems = items[slotIndex].ContainedItems; if (items[slotIndex] != null) containedItems = items[slotIndex].ContainedItems;
if (containedItems == null || containedItems.Count() == 0) return; if (containedItems == null || !containedItems.Any()) return;
for (int i = 0; i < itemCapacity; i++) for (int i = 0; i < itemCapacity; i++)
{ {
rect.Y = rect.Y - rect.Height - 10; rect.Y = rect.Y - rect.Height - 10;
UpdateSlot(spriteBatch, rect, selectedSlot, (i < containedItems.Count()) ? containedItems[i] : null, true); UpdateSlot(spriteBatch, rect, selectedSlot, i < containedItems.Count() ? containedItems[i] : null, true);
} }
} }
} }
+5 -5
View File
@@ -479,8 +479,8 @@ namespace Barotrauma
//ApplyStatusEffect(effect, type, deltaTime, this); //ApplyStatusEffect(effect, type, deltaTime, this);
if (effect.Targets.HasFlag(StatusEffect.TargetType.Character)) targets.Add(character); if (effect.Targets.HasFlag(StatusEffect.TargetType.Character)) targets.Add(character);
//effect.Apply(type, deltaTime, null, character); //effect.Apply(type, deltaTime, null, Character);
//ApplyStatusEffect(effect, type, deltaTime, null, character, limb); //ApplyStatusEffect(effect, type, deltaTime, null, Character, limb);
if (container != null && effect.Targets.HasFlag(StatusEffect.TargetType.Parent)) targets.Add(container); if (container != null && effect.Targets.HasFlag(StatusEffect.TargetType.Parent)) targets.Add(container);
//{ //{
@@ -803,7 +803,7 @@ namespace Barotrauma
} }
} }
/// <param name="position">Position of the character doing the pick, only items that are close enough to this are checked</param> /// <param name="position">Position of the Character doing the pick, only items that are close enough to this are checked</param>
/// <param name="pickPosition">the item closest to pickPosition is returned</param> /// <param name="pickPosition">the item closest to pickPosition is returned</param>
/// <param name="hull">If a hull is specified, only items within that hull are checked</param> /// <param name="hull">If a hull is specified, only items within that hull are checked</param>
public static Item FindPickable(Vector2 position, Vector2 pickPosition, Hull hull = null, Item[] ignoredItems=null) public static Item FindPickable(Vector2 position, Vector2 pickPosition, Hull hull = null, Item[] ignoredItems=null)
@@ -1171,7 +1171,7 @@ namespace Barotrauma
Item item = new Item(rect, ip); Item item = new Item(rect, ip);
item.ID = (ushort)int.Parse(element.Attribute("ID").Value); item.ID = (ushort)int.Parse(element.Attribute("ID").Value);
item.linkedToID = new List<int>(); item.linkedToID = new List<ushort>();
foreach (XAttribute attribute in element.Attributes()) foreach (XAttribute attribute in element.Attributes())
{ {
@@ -1198,7 +1198,7 @@ namespace Barotrauma
string[] linkedToIds = linkedToString.Split(','); string[] linkedToIds = linkedToString.Split(',');
for (int i = 0; i<linkedToIds.Length;i++) for (int i = 0; i<linkedToIds.Length;i++)
{ {
item.linkedToID.Add(int.Parse(linkedToIds[i])); item.linkedToID.Add((ushort)int.Parse(linkedToIds[i]));
} }
} }
+2 -2
View File
@@ -22,13 +22,13 @@ namespace Barotrauma
//default size //default size
protected Vector2 size; protected Vector2 size;
//how close the character has to be to the item to pick it up //how close the Character has to be to the item to pick it up
private float pickDistance; private float pickDistance;
private bool pickThroughWalls; private bool pickThroughWalls;
//an area next to the construction //an area next to the construction
//the construction can be Activated() by a character inside the area //the construction can be Activated() by a Character inside the area
public List<Rectangle> Triggers; public List<Rectangle> Triggers;
public string ConfigFile public string ConfigFile
+186
View File
@@ -0,0 +1,186 @@
using Barotrauma.Lights;
using Microsoft.Xna.Framework;
using System;
using System.Collections.Generic;
using System.Linq;
using System.Text;
namespace Barotrauma
{
class FireSource
{
const float OxygenConsumption = 10.0f;
const float GrowSpeed = 5.0f;
Hull hull;
LightSource lightSource;
Vector2 position;
Vector2 size;
public Vector2 Size
{
get { return size; }
}
public FireSource(Vector2 position)
{
hull = Hull.FindHull(position);
if (hull == null) return;
lightSource = new LightSource(position, 50.0f, new Color(1.0f, 0.9f, 0.6f));
hull.AddFireSource(this);
this.position = position - new Vector2(-5.0f, 5.0f);
this.position.Y = hull.Rect.Y - hull.Rect.Height;
size = new Vector2(10.0f, 10.0f);
}
private void LimitSize()
{
position.X = Math.Max(hull.Rect.X, position.X);
position.Y = Math.Min(hull.Rect.Y, position.Y);
size.X = Math.Min(hull.Rect.Width - (position.X - hull.Rect.X), size.X);
size.Y = Math.Min(hull.Rect.Height - (hull.Rect.Y - position.Y), size.Y);
}
public static void UpdateAll(List<FireSource> fireSources, float deltaTime)
{
for (int i = fireSources.Count - 1; i >= 0; i--)
{
fireSources[i].Update(deltaTime);
}
//combine overlapping fires
for (int i = fireSources.Count - 1; i >= 0; i--)
{
for (int j = i-1; j>=0 ; j--)
{
if (!fireSources[i].CheckOverLap(fireSources[j])) continue;
fireSources[j].position.X = Math.Min(fireSources[i].position.X, fireSources[j].position.X);
fireSources[j].size.X =
Math.Max(fireSources[i].position.X + fireSources[i].size.X, fireSources[j].position.X + fireSources[j].size.X)
- fireSources[j].position.X;
fireSources[i].Remove();
}
}
}
private bool CheckOverLap(FireSource fireSource)
{
return !(position.X > fireSource.position.X + fireSource.size.X &&
position.X + size.X < fireSource.position.X);
}
public void Update(float deltaTime)
{
float count = Rand.Range(0.0f, (float)Math.Sqrt(size.X)/2.0f);
for (int i = 0; i < count; i++ )
{
float normalizedPos = 0.5f-(i / count);
Vector2 spawnPos = new Vector2(position.X + Rand.Range(0.0f, size.X), Rand.Range(position.Y - size.Y, position.Y)+10.0f);
Vector2 speed = new Vector2((spawnPos.X - (position.X + size.X/2.0f)), (float)Math.Sqrt(size.X)*Rand.Range(10.0f,15.0f));
var particle = GameMain.ParticleManager.CreateParticle("flame",
spawnPos, speed, 0.0f, hull);
if (particle == null) continue;
if (Rand.Int(20) == 1) particle.OnChangeHull = OnChangeHull;
particle.Size *= MathHelper.Clamp(size.X/100.0f * (hull.Oxygen/hull.FullVolume), 0.5f, 4.0f);
}
DamageCharacters(deltaTime);
if (hull.Volume > 0.0f) Extinquish(deltaTime);
lightSource.Range = Math.Max(size.X, size.Y)*Rand.Range(8.0f, 10.0f)/2.0f;
lightSource.Color = new Color(1.0f, 0.9f, 0.6f) * Rand.Range(0.8f, 1.0f);
hull.Oxygen -= size.X*deltaTime*OxygenConsumption;
float growModifier = hull.OxygenPercentage < 20.0f ? hull.OxygenPercentage/20.0f : 1.0f;
position.X -= GrowSpeed * growModifier * 0.5f * deltaTime;
//position.Y += GrowSpeed*0.5f * deltaTime;
size.X += GrowSpeed * growModifier * deltaTime;
//size.Y += GrowSpeed * deltaTime;
LimitSize();
}
private void OnChangeHull(Vector2 pos, Hull particleHull)
{
if (particleHull == hull || particleHull==null) return;
if (particleHull.FireSources.Find(fs => pos.X > fs.position.X && pos.X < fs.position.X+fs.size.X)!=null) return;
new FireSource(new Vector2(pos.X, particleHull.Rect.Y-particleHull.Rect.Height + 5.0f));
}
private void DamageCharacters(float deltaTime)
{
foreach (Character c in Character.CharacterList)
{
if (c.AnimController.CurrentHull == null) continue;
float range = (float)Math.Sqrt(size.X) * 10.0f;
if (c.Position.X < position.X - range || c.Position.X > position.X + size.X + range) continue;
if (c.Position.Y < position.Y - size.Y || c.Position.Y > hull.Rect.Y) continue;
c.Health -= (float)Math.Sqrt(size.X) * deltaTime;
}
}
private void Extinquish(float deltaTime)
{
float extinquishAmount = Math.Min(hull.Volume / 100.0f, size.X);
float steamCount = Rand.Range(-5.0f, (float)Math.Sqrt(extinquishAmount));
for (int i = 0; i < steamCount; i++)
{
Vector2 spawnPos = new Vector2(position.X + size.X * (i / steamCount) + Rand.Range(-5.0f, 5.0f), Rand.Range(position.Y - size.Y, position.Y) + 10.0f);
Vector2 speed = new Vector2((spawnPos.X - (position.X + size.X / 2.0f)), (float)Math.Sqrt(size.X) * Rand.Range(20.0f, 25.0f));
var particle = GameMain.ParticleManager.CreateParticle("steam",
spawnPos, speed, 0.0f, hull);
if (particle == null) continue;
particle.Size *= MathHelper.Clamp(size.X / 10.0f, 0.5f, 3.0f);
}
position.X += extinquishAmount * 0.1f / 2.0f;
size.X -= extinquishAmount * 0.1f;
hull.Volume -= extinquishAmount;
if (size.X < 1.0f) Remove();
}
public void Remove()
{
lightSource.Remove();
hull.RemoveFire(this);
}
}
}
+1 -1
View File
@@ -609,7 +609,7 @@ namespace Barotrauma
Gap g = new Gap(rect); Gap g = new Gap(rect);
g.ID = (ushort)int.Parse(element.Attribute("ID").Value); g.ID = (ushort)int.Parse(element.Attribute("ID").Value);
g.linkedToID = new List<int>(); g.linkedToID = new List<ushort>();
//int i = 0; //int i = 0;
//while (element.Attribute("linkedto" + i) != null) //while (element.Attribute("linkedto" + i) != null)
//{ //{
+53 -2
View File
@@ -15,9 +15,11 @@ namespace Barotrauma
{ {
public static List<Hull> hullList = new List<Hull>(); public static List<Hull> hullList = new List<Hull>();
public static bool EditWater; public static bool EditWater, EditFire;
public static WaterRenderer renderer; public static WaterRenderer renderer;
private List<FireSource> fireSources;
public const float OxygenDistributionSpeed = 500.0f; public const float OxygenDistributionSpeed = 500.0f;
public const float OxygenDetoriationSpeed = 0.3f; public const float OxygenDetoriationSpeed = 0.3f;
@@ -126,12 +128,19 @@ namespace Barotrauma
get { return waveVel; } get { return waveVel; }
} }
public List<FireSource> FireSources
{
get { return fireSources; }
}
public Hull(Rectangle rectangle) public Hull(Rectangle rectangle)
{ {
rect = rectangle; rect = rectangle;
OxygenPercentage = Rand.Range(90.0f, 100.0f, false); OxygenPercentage = Rand.Range(90.0f, 100.0f, false);
fireSources = new List<FireSource>();
properties = TypeDescriptor.GetProperties(GetType()) properties = TypeDescriptor.GetProperties(GetType())
.Cast<PropertyDescriptor>() .Cast<PropertyDescriptor>()
.ToDictionary(pr => pr.Name); .ToDictionary(pr => pr.Name);
@@ -197,6 +206,11 @@ namespace Barotrauma
hullList.Remove(this); hullList.Remove(this);
} }
public void AddFireSource(FireSource fireSource)
{
fireSources.Add(fireSource);
}
public override void Update(Camera cam, float deltaTime) public override void Update(Camera cam, float deltaTime)
{ {
Oxygen -= OxygenDetoriationSpeed * deltaTime; Oxygen -= OxygenDetoriationSpeed * deltaTime;
@@ -217,7 +231,20 @@ namespace Barotrauma
} }
} }
} }
else if (EditFire)
{
Vector2 position = cam.ScreenToWorld(PlayerInput.MousePosition);
if (Submarine.RectContains(rect, position))
{
if (PlayerInput.LeftButtonClicked())
{
new FireSource(position);
}
}
}
FireSource.UpdateAll(fireSources, deltaTime);
//update client hulls if the amount of water has changed by >10% //update client hulls if the amount of water has changed by >10%
if (Math.Abs(lastSentVolume - volume) > FullVolume * 0.1f) if (Math.Abs(lastSentVolume - volume) > FullVolume * 0.1f)
{ {
@@ -292,8 +319,11 @@ namespace Barotrauma
LethalPressure += ( Submarine.Loaded!=null && Submarine.Loaded.AtDamageDepth) ? 100.0f*deltaTime : 10.0f * deltaTime; LethalPressure += ( Submarine.Loaded!=null && Submarine.Loaded.AtDamageDepth) ? 100.0f*deltaTime : 10.0f * deltaTime;
} }
}
public void RemoveFire(FireSource fire)
{
fireSources.Remove(fire);
} }
public override void Draw(SpriteBatch spriteBatch, bool editing) public override void Draw(SpriteBatch spriteBatch, bool editing)
@@ -441,6 +471,27 @@ namespace Barotrauma
return null; return null;
} }
public List<Gap> FindGaps()
{
List<Gap> gaps = new List<Gap>();
foreach (Gap gap in Gap.GapList)
{
if (gap.Open < 0.01f) continue;
if (gap.linkedTo.Count == 0) continue;
var gapHull = gap.linkedTo[0] as Hull;
if (gapHull == this) gaps.Add(gap);
if (gap.linkedTo.Count < 2) continue;
gapHull = gap.linkedTo[1] as Hull;
if (gapHull == this) gaps.Add(gap);
}
return gaps;
}
public override XElement Save(XDocument doc) public override XElement Save(XDocument doc)
{ {
XElement element = new XElement("Hull"); XElement element = new XElement("Hull");
-3
View File
@@ -731,10 +731,8 @@ namespace Barotrauma
// cell.body.SetTransform(cell.body.Position + simAmount, cell.body.Rotation); // cell.body.SetTransform(cell.body.Position + simAmount, cell.body.Rotation);
//} //}
int i = 0;
foreach (Body body in bodies) foreach (Body body in bodies)
{ {
i++;
body.SetTransform(body.Position + simAmount, body.Rotation); body.SetTransform(body.Position + simAmount, body.Rotation);
} }
@@ -759,7 +757,6 @@ namespace Barotrauma
Vector2 prevVelocity; Vector2 prevVelocity;
public void Move(Vector2 amount) public void Move(Vector2 amount)
{ {
Vector2 velocity = amount;
Vector2 simVelocity = ConvertUnits.ToSimUnits(amount / (float)Physics.step); Vector2 simVelocity = ConvertUnits.ToSimUnits(amount / (float)Physics.step);
foreach (Body body in bodies) foreach (Body body in bodies)
@@ -62,10 +62,6 @@ namespace Voronoi2
{ {
public double x, y; public double x, y;
public Point ()
{
}
public void setPoint ( double x, double y ) public void setPoint ( double x, double y )
{ {
this.x = x; this.x = x;
+1 -1
View File
@@ -54,7 +54,7 @@ namespace Barotrauma
nameFormats = new List<string>(); nameFormats = new List<string>();
foreach (XAttribute nameFormat in element.Element("nameformats").Attributes()) foreach (XAttribute nameFormat in element.Element("nameformats").Attributes())
{ {
nameFormats.Add(nameFormat.Value.ToString()); nameFormats.Add(nameFormat.Value);
} }
string spritePath = ToolBox.GetAttributeString(element, "symbol", "Content/Map/beaconSymbol.png"); string spritePath = ToolBox.GetAttributeString(element, "symbol", "Content/Map/beaconSymbol.png");
+1 -1
View File
@@ -24,7 +24,7 @@ namespace Barotrauma
protected static Vector2 startMovingPos = Vector2.Zero; protected static Vector2 startMovingPos = Vector2.Zero;
protected List<int> linkedToID; protected List<ushort> linkedToID;
//observable collection because some entities may need to be notified when the collection is modified //observable collection because some entities may need to be notified when the collection is modified
public ObservableCollection<MapEntity> linkedTo; public ObservableCollection<MapEntity> linkedTo;
+1 -1
View File
@@ -35,7 +35,7 @@ namespace Barotrauma
waterEffect.Parameters["xWaveWidth"].SetValue(0.05f); waterEffect.Parameters["xWaveWidth"].SetValue(0.05f);
waterEffect.Parameters["xWaveHeight"].SetValue(0.05f); waterEffect.Parameters["xWaveHeight"].SetValue(0.05f);
#if WINDOWS #if WINDOWS
waterEffect.Parameters["xTexture"].SetValue(waterTexture); //waterEffect.Parameters["xTexture"].SetValue(waterTexture);
#endif #endif
#if LINUX #if LINUX
waterEffect.Parameters["xWaterBumpMap"].SetValue(waterTexture); waterEffect.Parameters["xWaterBumpMap"].SetValue(waterTexture);
+2 -2
View File
@@ -327,11 +327,11 @@ namespace Barotrauma
w.assignedJob = JobPrefab.List.Find(jp => jp.Name.ToLower() == jobName); w.assignedJob = JobPrefab.List.Find(jp => jp.Name.ToLower() == jobName);
} }
w.linkedToID = new List<int>(); w.linkedToID = new List<ushort>();
int i = 0; int i = 0;
while (element.Attribute("linkedto" + i) != null) while (element.Attribute("linkedto" + i) != null)
{ {
w.linkedToID.Add(int.Parse(element.Attribute("linkedto" + i).Value)); w.linkedToID.Add((ushort)int.Parse(element.Attribute("linkedto" + i).Value));
i += 1; i += 1;
} }
} }
+19 -10
View File
@@ -1,5 +1,4 @@
using System; using System;
using System.Diagnostics;
using Lidgren.Network; using Lidgren.Network;
using Microsoft.Xna.Framework; using Microsoft.Xna.Framework;
using System.Collections.Generic; using System.Collections.Generic;
@@ -207,7 +206,7 @@ namespace Barotrauma.Networking
if (packetType == (byte)PacketTypes.LoggedIn) if (packetType == (byte)PacketTypes.LoggedIn)
{ {
myID = inc.ReadInt32(); myID = inc.ReadInt32();
bool gameStarted= inc.ReadBoolean(); gameStarted = inc.ReadBoolean();
if (gameStarted && Screen.Selected != GameMain.GameScreen) if (gameStarted && Screen.Selected != GameMain.GameScreen)
{ {
new GUIMessageBox("Please wait", "A round is already running. You will have to wait for a new round to start."); new GUIMessageBox("Please wait", "A round is already running. You will have to wait for a new round to start.");
@@ -219,7 +218,7 @@ namespace Barotrauma.Networking
{ {
GameMain.NetLobbyScreen.Select(); GameMain.NetLobbyScreen.Select();
new GUIMessageBox("Connection timed out", "You were disconnected for too long and your character was deleted. Please wait for another round to start."); new GUIMessageBox("Connection timed out", "You were disconnected for too long and your Character was deleted. Please wait for another round to start.");
} }
GameMain.NetLobbyScreen.ClearPlayers(); GameMain.NetLobbyScreen.ClearPlayers();
@@ -428,7 +427,7 @@ namespace Barotrauma.Networking
switch (packetType) switch (packetType)
{ {
case (byte)PacketTypes.StartGame: case (byte)PacketTypes.StartGame:
if (gameStarted) continue; if (Screen.Selected == GameMain.GameScreen) continue;
GameMain.ShowLoading(StartGame(inc), false); GameMain.ShowLoading(StartGame(inc), false);
@@ -467,8 +466,8 @@ namespace Barotrauma.Networking
if (!c.IsNetworkPlayer || !c.IsHumanoid || c.Info==null) continue; if (!c.IsNetworkPlayer || !c.IsHumanoid || c.Info==null) continue;
crew.Add(c); crew.Add(c);
} }
CreateCrewFrame(crew); GameMain.GameSession.CrewManager.CreateCrewFrame(crew);
break; break;
@@ -532,7 +531,7 @@ namespace Barotrauma.Networking
if (gameMode == null) if (gameMode == null)
{ {
DebugConsole.ThrowError("Game mode ''"+gameMode+"'' not found!"); DebugConsole.ThrowError("Game mode ''" + modeName + "'' not found!");
yield return CoroutineStatus.Success; yield return CoroutineStatus.Success;
} }
@@ -576,7 +575,7 @@ namespace Barotrauma.Networking
AddChatMessage("Press TAB to chat", ChatMessageType.Server); AddChatMessage("Press TAB to chat", ChatMessageType.Server);
CreateCrewFrame(crew); GameMain.GameSession.CrewManager.CreateCrewFrame(crew);
yield return CoroutineStatus.Success; yield return CoroutineStatus.Success;
} }
@@ -624,7 +623,7 @@ namespace Barotrauma.Networking
myCharacter = null; myCharacter = null;
foreach (Client c in otherClients) foreach (Client c in otherClients)
{ {
c.character = null; c.Character = null;
} }
yield return CoroutineStatus.Success; yield return CoroutineStatus.Success;
@@ -680,6 +679,16 @@ namespace Barotrauma.Networking
} }
} }
public bool SpectateClicked(GUIButton button, object userData)
{
NetOutgoingMessage msg = client.CreateMessage();
msg.Write((byte)PacketTypes.Spectate);
client.SendMessage(msg, NetDeliveryMethod.ReliableUnordered);
return false;
}
public void SendCharacterData() public void SendCharacterData()
{ {
if (characterInfo == null) return; if (characterInfo == null) return;
@@ -800,7 +809,7 @@ namespace Barotrauma.Networking
int bitCount = Rand.Int(100); int bitCount = Rand.Int(100);
for (int i = 0; i<bitCount; i++) for (int i = 0; i<bitCount; i++)
{ {
msg.Write((Rand.Int(2)==0) ? true : false); msg.Write(Rand.Int(2)==0);
} }
+108 -233
View File
@@ -2,6 +2,7 @@
using System; using System;
using System.Collections.Generic; using System.Collections.Generic;
using System.Diagnostics; using System.Diagnostics;
using System.Linq;
using Lidgren.Network; using Lidgren.Network;
using Microsoft.Xna.Framework; using Microsoft.Xna.Framework;
using RestSharp; using RestSharp;
@@ -11,15 +12,17 @@ namespace Barotrauma.Networking
{ {
partial class GameServer : NetworkMember partial class GameServer : NetworkMember
{ {
public List<Client> connectedClients = new List<Client>(); public List<Client> ConnectedClients = new List<Client>();
//for keeping track of disconnected clients in case the reconnect shortly after //for keeping track of disconnected clients in case the reconnect shortly after
private List<Client> disconnectedClients = new List<Client>(); private List<Client> disconnectedClients = new List<Client>();
private NetStats netStats; private NetStats netStats;
private int roundStartSeed;
//is the server running //is the server running
bool started; private bool started;
private NetServer server; private NetServer server;
private NetPeerConfiguration config; private NetPeerConfiguration config;
@@ -131,7 +134,7 @@ namespace Barotrauma.Networking
request.AddParameter("action", "addserver"); request.AddParameter("action", "addserver");
request.AddParameter("servername", name); request.AddParameter("servername", name);
request.AddParameter("serverport", Port); request.AddParameter("serverport", Port);
request.AddParameter("playercount", PlayerCountToByte(connectedClients.Count, config.MaximumConnections)); request.AddParameter("playercount", PlayerCountToByte(ConnectedClients.Count, config.MaximumConnections));
request.AddParameter("password", string.IsNullOrWhiteSpace(password) ? 0 : 1); request.AddParameter("password", string.IsNullOrWhiteSpace(password) ? 0 : 1);
// execute the request // execute the request
@@ -143,7 +146,7 @@ namespace Barotrauma.Networking
return; return;
} }
if (response!=null && !string.IsNullOrWhiteSpace(response.Content)) if (response != null && !string.IsNullOrWhiteSpace(response.Content))
{ {
DebugConsole.ThrowError("Error while connecting to master server (" +response.Content+")"); DebugConsole.ThrowError("Error while connecting to master server (" +response.Content+")");
return; return;
@@ -160,7 +163,7 @@ namespace Barotrauma.Networking
var request = new RestRequest("masterserver.php", Method.GET); var request = new RestRequest("masterserver.php", Method.GET);
request.AddParameter("action", "refreshserver"); request.AddParameter("action", "refreshserver");
request.AddParameter("gamestarted", gameStarted ? 1 : 0); request.AddParameter("gamestarted", gameStarted ? 1 : 0);
request.AddParameter("playercount", PlayerCountToByte(connectedClients.Count, config.MaximumConnections)); request.AddParameter("playercount", PlayerCountToByte(ConnectedClients.Count, config.MaximumConnections));
System.Diagnostics.Debug.WriteLine("refreshing master"); System.Diagnostics.Debug.WriteLine("refreshing master");
@@ -221,7 +224,7 @@ namespace Barotrauma.Networking
//if all characters dead //if all characters dead
if (AutoRestart && if (AutoRestart &&
connectedClients.Find(c => c.character != null && !c.character.IsDead)==null && ConnectedClients.Find(c => c.Character != null && !c.Character.IsDead)==null &&
(myCharacter == null || myCharacter.IsDead)) (myCharacter == null || myCharacter.IsDead))
{ {
EndButtonHit(null, null); EndButtonHit(null, null);
@@ -229,7 +232,7 @@ namespace Barotrauma.Networking
return; return;
} }
} }
else if (autoRestart && Screen.Selected == GameMain.NetLobbyScreen && connectedClients.Count>0) else if (autoRestart && Screen.Selected == GameMain.NetLobbyScreen && ConnectedClients.Count>0)
{ {
AutoRestartTimer -= deltaTime; AutoRestartTimer -= deltaTime;
if (AutoRestartTimer < 0.0f) if (AutoRestartTimer < 0.0f)
@@ -243,16 +246,16 @@ namespace Barotrauma.Networking
disconnectedClients[i].deleteDisconnectedTimer -= deltaTime; disconnectedClients[i].deleteDisconnectedTimer -= deltaTime;
if (disconnectedClients[i].deleteDisconnectedTimer > 0.0f) continue; if (disconnectedClients[i].deleteDisconnectedTimer > 0.0f) continue;
if (gameStarted && disconnectedClients[i].character!=null) if (gameStarted && disconnectedClients[i].Character!=null)
{ {
disconnectedClients[i].character.Remove(); disconnectedClients[i].Character.Remove();
disconnectedClients[i].character = null; disconnectedClients[i].Character = null;
} }
disconnectedClients.RemoveAt(i); disconnectedClients.RemoveAt(i);
} }
foreach (Client c in connectedClients) foreach (Client c in ConnectedClients)
{ {
c.ReliableChannel.Update(deltaTime); c.ReliableChannel.Update(deltaTime);
} }
@@ -283,7 +286,7 @@ namespace Barotrauma.Networking
foreach (Character c in Character.CharacterList) foreach (Character c in Character.CharacterList)
{ {
if (c as AICharacter == null || c.IsDead) continue; if (!(c is AICharacter) || c.IsDead) continue;
if (c.SimPosition.Length() > NetConfig.CharacterIgnoreDistance) continue; if (c.SimPosition.Length() > NetConfig.CharacterIgnoreDistance) continue;
@@ -301,12 +304,10 @@ namespace Barotrauma.Networking
updateTimer = DateTime.Now + updateInterval; updateTimer = DateTime.Now + updateInterval;
} }
if (registeredToMaster && refreshMasterTimer < DateTime.Now) if (!registeredToMaster || refreshMasterTimer >= DateTime.Now) return;
{
CoroutineManager.StartCoroutine(RefreshMaster());
refreshMasterTimer = DateTime.Now + refreshMasterInterval; CoroutineManager.StartCoroutine(RefreshMaster());
} refreshMasterTimer = DateTime.Now + refreshMasterInterval;
} }
private void SparseUpdate() private void SparseUpdate()
@@ -315,7 +316,7 @@ namespace Barotrauma.Networking
foreach (Character c in Character.CharacterList) foreach (Character c in Character.CharacterList)
{ {
if (c as AICharacter != null || c.IsDead) continue; if (c is AICharacter || c.IsDead) continue;
new NetworkEvent(NetworkEventType.ImportantEntityUpdate, c.ID, false); new NetworkEvent(NetworkEventType.ImportantEntityUpdate, c.ID, false);
} }
@@ -325,8 +326,6 @@ namespace Barotrauma.Networking
private void ReadMessage(NetIncomingMessage inc) private void ReadMessage(NetIncomingMessage inc)
{ {
NetOutgoingMessage outmsg;
switch (inc.MessageType) switch (inc.MessageType)
{ {
case NetIncomingMessageType.ConnectionApproval: case NetIncomingMessageType.ConnectionApproval:
@@ -336,7 +335,7 @@ namespace Barotrauma.Networking
Debug.WriteLine(inc.SenderConnection + " status changed. " + (NetConnectionStatus)inc.SenderConnection.Status); Debug.WriteLine(inc.SenderConnection + " status changed. " + (NetConnectionStatus)inc.SenderConnection.Status);
if (inc.SenderConnection.Status == NetConnectionStatus.Connected) if (inc.SenderConnection.Status == NetConnectionStatus.Connected)
{ {
Client sender = connectedClients.Find(x => x.Connection == inc.SenderConnection); Client sender = ConnectedClients.Find(x => x.Connection == inc.SenderConnection);
if (sender == null) break; if (sender == null) break;
@@ -345,7 +344,7 @@ namespace Barotrauma.Networking
DisconnectClient(sender, sender.name+" was unable to connect to the server (nonmatching game version)", DisconnectClient(sender, sender.name+" was unable to connect to the server (nonmatching game version)",
"Version " + GameMain.Version + " required to connect to the server (Your version: " + sender.version + ")"); "Version " + GameMain.Version + " required to connect to the server (Your version: " + sender.version + ")");
} }
else if (connectedClients.Find(x => x.name == sender.name && x != sender)!=null) else if (ConnectedClients.Find(x => x.name == sender.name && x != sender)!=null)
{ {
DisconnectClient(sender, sender.name + " was unable to connect to the server (name already in use)", DisconnectClient(sender, sender.name + " was unable to connect to the server (name already in use)",
"The name ''"+sender.name+"'' is already in use. Please choose another name."); "The name ''"+sender.name+"'' is already in use. Please choose another name.");
@@ -357,19 +356,16 @@ namespace Barotrauma.Networking
GameMain.NetLobbyScreen.AddPlayer(sender.name); GameMain.NetLobbyScreen.AddPlayer(sender.name);
// Notify the client that they have logged in // Notify the client that they have logged in
outmsg = server.CreateMessage(); var outmsg = server.CreateMessage();
outmsg.Write((byte)PacketTypes.LoggedIn); outmsg.Write((byte)PacketTypes.LoggedIn);
outmsg.Write(sender.ID); outmsg.Write(sender.ID);
outmsg.Write(gameStarted); outmsg.Write(gameStarted);
outmsg.Write(gameStarted && sender.Character!=null);
outmsg.Write(gameStarted && sender.character!=null);
//notify the client about other clients already logged in //notify the client about other clients already logged in
outmsg.Write((characterInfo == null) ? connectedClients.Count - 1 : connectedClients.Count); outmsg.Write((characterInfo == null) ? ConnectedClients.Count - 1 : ConnectedClients.Count);
foreach (Client c in connectedClients) foreach (Client c in ConnectedClients)
{ {
if (c.Connection == inc.SenderConnection) continue; if (c.Connection == inc.SenderConnection) continue;
outmsg.Write(c.name); outmsg.Write(c.name);
@@ -401,7 +397,7 @@ namespace Barotrauma.Networking
} }
else if (inc.SenderConnection.Status == NetConnectionStatus.Disconnected) else if (inc.SenderConnection.Status == NetConnectionStatus.Disconnected)
{ {
var connectedClient = connectedClients.Find(c => c.Connection == inc.SenderConnection); var connectedClient = ConnectedClients.Find(c => c.Connection == inc.SenderConnection);
if (connectedClient != null && !disconnectedClients.Contains(connectedClient)) if (connectedClient != null && !disconnectedClients.Contains(connectedClient))
{ {
connectedClient.deleteDisconnectedTimer = NetConfig.DeleteDisconnectedTime; connectedClient.deleteDisconnectedTimer = NetConfig.DeleteDisconnectedTime;
@@ -415,7 +411,7 @@ namespace Barotrauma.Networking
break; break;
case NetIncomingMessageType.Data: case NetIncomingMessageType.Data:
Client dataSender = connectedClients.Find(c => c.Connection == inc.SenderConnection); Client dataSender = ConnectedClients.Find(c => c.Connection == inc.SenderConnection);
if (dataSender == null) return; if (dataSender == null) return;
byte packetType = 0; byte packetType = 0;
@@ -428,13 +424,10 @@ namespace Barotrauma.Networking
return; return;
} }
bool isReliable = false;
if (packetType == (byte)PacketTypes.ReliableMessage) if (packetType == (byte)PacketTypes.ReliableMessage)
{ {
if (!dataSender.ReliableChannel.CheckMessage(inc)) return; if (!dataSender.ReliableChannel.CheckMessage(inc)) return;
packetType = inc.ReadByte(); packetType = inc.ReadByte();
isReliable = true;
} }
switch (packetType) switch (packetType)
@@ -443,33 +436,6 @@ namespace Barotrauma.Networking
if (!gameStarted) break; if (!gameStarted) break;
NetworkEvent.ReadMessage(inc, true); NetworkEvent.ReadMessage(inc, true);
//List<Client> recipients = connectedClients.FindAll(c => c.Connection != inc.SenderConnection && c.inGame);
//if (recipients.Count == 0) break;
//if (isReliable)
//{
// Debug.WriteLine("receiver reliable networkevent");
// foreach (Client c in recipients)
// {
// var reliableMessage = c.ReliableChannel.CreateMessage();
// inc.Position = 8+16;
// byte[] messageBytes = inc.ReadBytes(inc.LengthBytes-3);
// reliableMessage.InnerMessage.Write(messageBytes);
// c.ReliableChannel.SendMessage(reliableMessage, c.Connection);
// }
//}
//else
//{
// outmsg = server.CreateMessage();
// outmsg.Write(inc);
// List<NetConnection> recipientConnections = new List<NetConnection>();
// foreach (Client c in recipients) recipientConnections.Add(c.Connection);
// server.SendMessage(outmsg, recipientConnections, inc.DeliveryMethod, 0);
//}
break; break;
case (byte)PacketTypes.Chatmessage: case (byte)PacketTypes.Chatmessage:
ChatMessageType messageType = (ChatMessageType)inc.ReadByte(); ChatMessageType messageType = (ChatMessageType)inc.ReadByte();
@@ -492,7 +458,14 @@ namespace Barotrauma.Networking
dataSender.ReliableChannel.HandleLatestMessageID(inc); dataSender.ReliableChannel.HandleLatestMessageID(inc);
break; break;
case (byte)PacketTypes.Vote: case (byte)PacketTypes.Vote:
Voting.RegisterVote(inc, connectedClients); Voting.RegisterVote(inc, ConnectedClients);
break;
case (byte)PacketTypes.Spectate:
if (gameStarted)
{
var startMessage = CreateStartMessage(roundStartSeed, Submarine.Loaded, GameMain.GameSession.gameMode.Preset);
server.SendMessage(startMessage, inc.SenderConnection, NetDeliveryMethod.ReliableUnordered);
}
break; break;
} }
break; break;
@@ -515,7 +488,7 @@ namespace Barotrauma.Networking
return; return;
} }
if (connectedClients.Find(c => c.Connection == inc.SenderConnection)!=null) if (ConnectedClients.Find(c => c.Connection == inc.SenderConnection)!=null)
{ {
inc.SenderConnection.Deny("Connection error - already joined"); inc.SenderConnection.Deny("Connection error - already joined");
return; return;
@@ -565,7 +538,7 @@ namespace Barotrauma.Networking
DebugConsole.NewMessage(name + " couldn't join the server (wrong content package hash)", Color.Red); DebugConsole.NewMessage(name + " couldn't join the server (wrong content package hash)", Color.Red);
return; return;
} }
else if (connectedClients.Find(c => c.name.ToLower() == name.ToLower() && c.ID!=userID) != null) else if (ConnectedClients.Find(c => c.name.ToLower() == name.ToLower() && c.ID!=userID) != null)
{ {
inc.SenderConnection.Deny("The name ''" + name + "'' is already in use. Please choose another name."); inc.SenderConnection.Deny("The name ''" + name + "'' is already in use. Please choose another name.");
DebugConsole.NewMessage(name + " couldn't join the server (name already in use)", Color.Red); DebugConsole.NewMessage(name + " couldn't join the server (name already in use)", Color.Red);
@@ -577,14 +550,14 @@ namespace Barotrauma.Networking
//existing user re-joining //existing user re-joining
if (userID > 0) if (userID > 0)
{ {
Client existingClient = connectedClients.Find(c => c.ID == userID); Client existingClient = ConnectedClients.Find(c => c.ID == userID);
if (existingClient == null) if (existingClient == null)
{ {
existingClient = disconnectedClients.Find(c => c.ID == userID); existingClient = disconnectedClients.Find(c => c.ID == userID);
if (existingClient != null) if (existingClient != null)
{ {
disconnectedClients.Remove(existingClient); disconnectedClients.Remove(existingClient);
connectedClients.Add(existingClient); ConnectedClients.Add(existingClient);
UpdateCrewFrame(); UpdateCrewFrame();
} }
@@ -598,7 +571,7 @@ namespace Barotrauma.Networking
} }
userID = Rand.Range(1, 1000000); userID = Rand.Range(1, 1000000);
while (connectedClients.Find(c => c.ID == userID) != null) while (ConnectedClients.Find(c => c.ID == userID) != null)
{ {
userID++; userID++;
} }
@@ -607,7 +580,7 @@ namespace Barotrauma.Networking
newClient.Connection = inc.SenderConnection; newClient.Connection = inc.SenderConnection;
newClient.version = version; newClient.version = version;
connectedClients.Add(newClient); ConnectedClients.Add(newClient);
UpdateCrewFrame(); UpdateCrewFrame();
@@ -615,11 +588,11 @@ namespace Barotrauma.Networking
} }
private void SendMessage(NetOutgoingMessage msg, NetDeliveryMethod deliveryMethod, NetConnection excludedConnection) private void SendMessage(NetOutgoingMessage msg, NetDeliveryMethod deliveryMethod, NetConnection excludedConnection = null)
{ {
List<NetConnection> recipients = new List<NetConnection>(); List<NetConnection> recipients = new List<NetConnection>();
foreach (Client client in connectedClients) foreach (Client client in ConnectedClients)
{ {
if (client.Connection != excludedConnection) recipients.Add(client.Connection); if (client.Connection != excludedConnection) recipients.Add(client.Connection);
} }
@@ -634,78 +607,10 @@ namespace Barotrauma.Networking
{ {
if (NetworkEvent.Events.Count == 0) return; if (NetworkEvent.Events.Count == 0) return;
List<Client> recipients = connectedClients.FindAll(c => c.character != null); List<Client> recipients = ConnectedClients.FindAll(c => c.Character != null);
List<NetConnection> recipientConnections = new List<NetConnection>();
foreach (Client c in recipients)
{
recipientConnections.Add(c.Connection);
}
if (recipients.Count == 0) return; if (recipients.Count == 0) return;
//foreach (Client c in recipients)
//{
// for (int i = 0; i < 2; i++)
// {
// bool important = i == 0;
// var events = NetworkEvent.Events.FindAll(e => e.IsImportant == important && e.SenderConnection != c.Connection);
// if (events.Count == 0) continue;
// List<byte[]> msgBytes = new List<byte[]>();
// int totalLength = 1;
// foreach (NetworkEvent unreliableEvent in events)
// {
// NetBuffer tempMessage = new NetBuffer();// server.CreateMessage();
// if (!unreliableEvent.FillData(tempMessage)) continue;
// tempMessage.WritePadBits();
// tempMessage.Position = 0;
// msgBytes.Add(tempMessage.ReadBytes(tempMessage.LengthBytes));
// //one extra byte for writing the length
// totalLength += 1 + tempMessage.LengthBytes;
// }
// //NetOutgoingMessage combinedMessage = null;
// //reliableMessage = null;
// if (important)
// {
// ReliableMessage reliableMessage = c.ReliableChannel.CreateMessage();
// reliableMessage.InnerMessage.Write((byte)msgBytes.Count);
// foreach (byte[] msgData in msgBytes)
// {
// if (msgData.Length > 255) DebugConsole.ThrowError("too large networkevent (" + msgData.Length + " bytes)");
// reliableMessage.InnerMessage.Write((byte)msgData.Length);
// reliableMessage.InnerMessage.Write(msgData);
// }
// c.ReliableChannel.SendMessage(reliableMessage, c.Connection);
// }
// else
// {
// var combinedMessage = server.CreateMessage(totalLength);
// combinedMessage.Write((byte)msgBytes.Count);
// foreach (byte[] msgData in msgBytes)
// {
// if (msgData.Length > 255) DebugConsole.ThrowError("too large networkevent (" + msgData.Length + " bytes)");
// combinedMessage.Write((byte)msgData.Length);
// combinedMessage.Write(msgData);
// }
// server.SendMessage(combinedMessage, c.Connection, NetDeliveryMethod.Unreliable, 0);
// }
// }
//}
foreach (Client c in recipients) foreach (Client c in recipients)
{ {
var message = ComposeNetworkEventMessage(true, c.Connection); var message = ComposeNetworkEventMessage(true, c.Connection);
@@ -725,39 +630,6 @@ namespace Barotrauma.Networking
} }
} }
//foreach (NetworkEvent networkEvent in NetworkEvent.events)
//{
// if (!networkEvent.IsImportant) co
// //if (!networkEvent.IsClient) continue;
// if (!networkEvent.FillData(message))
// {
// continue;
// }
// //Entity e = Entity.FindEntityByID(networkEvent.ID);
// //if (e == null) continue;
// if (networkEvent.IsImportant)
// {
// foreach (Client c in recipients)
// {
// ReliableMessage reliableMessage = c.ReliableChannel.CreateMessage();
// message.Position = 0;
// reliableMessage.InnerMessage.Write(message.ReadBytes(message.LengthBytes));
// c.ReliableChannel.SendMessage(reliableMessage, c.Connection);
// }
// }
// else
// {
// if (server.ConnectionsCount>0)
// {
// server.SendMessage(message, recipientConnections, NetDeliveryMethod.Unreliable, 0);
// }
// }
//}
NetworkEvent.Events.Clear(); NetworkEvent.Events.Clear();
} }
@@ -768,7 +640,7 @@ namespace Barotrauma.Networking
if (Voting.AllowSubVoting) if (Voting.AllowSubVoting)
{ {
Voting.HighestVoted<Submarine>(VoteType.Sub, connectedClients); selectedSub = Voting.HighestVoted<Submarine>(VoteType.Sub, ConnectedClients);
if (selectedSub == null) selectedSub = GameMain.NetLobbyScreen.SelectedSub; if (selectedSub == null) selectedSub = GameMain.NetLobbyScreen.SelectedSub;
} }
else else
@@ -793,22 +665,23 @@ namespace Barotrauma.Networking
AssignJobs(); AssignJobs();
//selectedMap.Load(); roundStartSeed = DateTime.Now.Millisecond;
Rand.SetSyncedSeed(roundStartSeed);
int seed = DateTime.Now.Millisecond; GameModePreset selectedMode = Voting.HighestVoted<GameModePreset>(VoteType.Mode, ConnectedClients);
Rand.SetSyncedSeed(seed);
GameModePreset selectedMode = Voting.HighestVoted<GameModePreset>(VoteType.Mode, connectedClients);
if (selectedMode==null) selectedMode=GameMain.NetLobbyScreen.SelectedMode; if (selectedMode==null) selectedMode=GameMain.NetLobbyScreen.SelectedMode;
GameMain.GameSession = new GameSession(selectedSub, "", selectedMode); GameMain.GameSession = new GameSession(selectedSub, "", selectedMode);
GameMain.GameSession.StartShift(GameMain.NetLobbyScreen.LevelSeed); GameMain.GameSession.StartShift(GameMain.NetLobbyScreen.LevelSeed);
var startMessage = CreateStartMessage(roundStartSeed, Submarine.Loaded, GameMain.GameSession.gameMode.Preset);
SendMessage(startMessage, NetDeliveryMethod.ReliableUnordered);
yield return CoroutineStatus.Running; yield return CoroutineStatus.Running;
List<CharacterInfo> characterInfos = new List<CharacterInfo>(); List<CharacterInfo> characterInfos = new List<CharacterInfo>();
foreach (Client client in connectedClients) foreach (Client client in ConnectedClients)
{ {
client.inGame = true; client.inGame = true;
@@ -829,11 +702,11 @@ namespace Barotrauma.Networking
WayPoint[] assignedWayPoints = WayPoint.SelectCrewSpawnPoints(characterInfos); WayPoint[] assignedWayPoints = WayPoint.SelectCrewSpawnPoints(characterInfos);
for (int i = 0; i < connectedClients.Count; i++) for (int i = 0; i < ConnectedClients.Count; i++)
{ {
connectedClients[i].character = new Character( ConnectedClients[i].Character = new Character(
connectedClients[i].characterInfo, assignedWayPoints[i], true); ConnectedClients[i].characterInfo, assignedWayPoints[i], true);
connectedClients[i].character.GiveJobItems(assignedWayPoints[i]); ConnectedClients[i].Character.GiveJobItems(assignedWayPoints[i]);
} }
if (characterInfo != null) if (characterInfo != null)
@@ -845,7 +718,23 @@ namespace Barotrauma.Networking
} }
yield return CoroutineStatus.Running; yield return CoroutineStatus.Running;
UpdateCrewFrame();
//give some time for the clients to load the map
yield return new WaitForSeconds(2.0f);
gameStarted = true;
GameMain.GameScreen.Cam.TargetPos = Vector2.Zero;
GameMain.GameScreen.Select();
yield return CoroutineStatus.Success;
}
private NetOutgoingMessage CreateStartMessage(int seed, Submarine selectedSub, GameModePreset selectedMode)
{
NetOutgoingMessage msg = server.CreateMessage(); NetOutgoingMessage msg = server.CreateMessage();
msg.Write((byte)PacketTypes.StartGame); msg.Write((byte)PacketTypes.StartGame);
@@ -860,11 +749,13 @@ namespace Barotrauma.Networking
//msg.Write(GameMain.NetLobbyScreen.GameDuration.TotalMinutes); //msg.Write(GameMain.NetLobbyScreen.GameDuration.TotalMinutes);
msg.Write((myCharacter == null) ? (byte)connectedClients.Count : (byte)(connectedClients.Count + 1)); List<Client> playingClients = ConnectedClients.FindAll(c => c.Character != null);
foreach (Client client in connectedClients)
msg.Write((myCharacter == null) ? (byte)playingClients.Count : (byte)(playingClients.Count + 1));
foreach (Client client in playingClients)
{ {
msg.Write(client.ID); msg.Write(client.ID);
WriteCharacterData(msg, client.character.Name, client.character); WriteCharacterData(msg, client.Character.Name, client.Character);
} }
if (myCharacter != null) if (myCharacter != null)
@@ -873,21 +764,7 @@ namespace Barotrauma.Networking
WriteCharacterData(msg, myCharacter.Info.Name, Character.Controlled); WriteCharacterData(msg, myCharacter.Info.Name, Character.Controlled);
} }
SendMessage(msg, NetDeliveryMethod.ReliableUnordered, null); return msg;
UpdateCrewFrame();
//give some time for the clients to load the map
yield return new WaitForSeconds(2.0f);
gameStarted = true;
GameMain.GameScreen.Cam.TargetPos = Vector2.Zero;
GameMain.GameScreen.Select();
yield return CoroutineStatus.Success;
} }
private bool EndButtonHit(GUIButton button, object obj) private bool EndButtonHit(GUIButton button, object obj)
@@ -909,7 +786,7 @@ namespace Barotrauma.Networking
gameStarted = false; gameStarted = false;
if (connectedClients.Count > 0) if (ConnectedClients.Count > 0)
{ {
NetOutgoingMessage msg = server.CreateMessage(); NetOutgoingMessage msg = server.CreateMessage();
msg.Write((byte)PacketTypes.EndGame); msg.Write((byte)PacketTypes.EndGame);
@@ -920,9 +797,9 @@ namespace Barotrauma.Networking
server.SendMessage(msg, server.Connections, NetDeliveryMethod.ReliableOrdered, 0); server.SendMessage(msg, server.Connections, NetDeliveryMethod.ReliableOrdered, 0);
} }
foreach (Client client in connectedClients) foreach (Client client in ConnectedClients)
{ {
client.character = null; client.Character = null;
client.inGame = false; client.inGame = false;
} }
} }
@@ -961,7 +838,7 @@ namespace Barotrauma.Networking
private void DisconnectClient(NetConnection senderConnection, string msg = "", string targetmsg = "") private void DisconnectClient(NetConnection senderConnection, string msg = "", string targetmsg = "")
{ {
Client client = connectedClients.Find(x => x.Connection == senderConnection); Client client = ConnectedClients.Find(x => x.Connection == senderConnection);
if (client != null) DisconnectClient(client, msg, targetmsg); if (client != null) DisconnectClient(client, msg, targetmsg);
} }
@@ -969,18 +846,18 @@ namespace Barotrauma.Networking
{ {
if (client == null) return; if (client == null) return;
if (gameStarted && client.character != null) if (gameStarted && client.Character != null)
{ {
if (GameMain.GameSession!=null && GameMain.GameSession.gameMode!=null) if (GameMain.GameSession!=null && GameMain.GameSession.gameMode!=null)
{ {
TraitorMode traitorMode = GameMain.GameSession.gameMode as TraitorMode; TraitorMode traitorMode = GameMain.GameSession.gameMode as TraitorMode;
if (traitorMode!=null) if (traitorMode!=null)
{ {
traitorMode.CharacterLeft(client.character); traitorMode.CharacterLeft(client.Character);
} }
} }
client.character.ClearInputs(); client.Character.ClearInputs();
} }
if (string.IsNullOrWhiteSpace(msg)) msg = client.name + " has left the server"; if (string.IsNullOrWhiteSpace(msg)) msg = client.name + " has left the server";
@@ -991,7 +868,7 @@ namespace Barotrauma.Networking
outmsg.Write(targetmsg); outmsg.Write(targetmsg);
server.SendMessage(outmsg, client.Connection, NetDeliveryMethod.ReliableUnordered, 0); server.SendMessage(outmsg, client.Connection, NetDeliveryMethod.ReliableUnordered, 0);
connectedClients.Remove(client); ConnectedClients.Remove(client);
outmsg = server.CreateMessage(); outmsg = server.CreateMessage();
outmsg.Write((byte)PacketTypes.PlayerLeft); outmsg.Write((byte)PacketTypes.PlayerLeft);
@@ -1014,24 +891,24 @@ namespace Barotrauma.Networking
{ {
List<Character> crew = new List<Character>(); List<Character> crew = new List<Character>();
foreach (Client c in connectedClients) foreach (Client c in ConnectedClients)
{ {
if (c.character == null || !c.inGame) continue; if (c.Character == null || !c.inGame) continue;
crew.Add(c.character); crew.Add(c.Character);
} }
if (myCharacter != null) crew.Add(myCharacter); if (myCharacter != null) crew.Add(myCharacter);
CreateCrewFrame(crew); if (GameMain.GameSession!=null) GameMain.GameSession.CrewManager.CreateCrewFrame(crew);
} }
public void KickPlayer(string playerName, bool ban = false) public void KickPlayer(string playerName, bool ban = false)
{ {
playerName = playerName.ToLower(); playerName = playerName.ToLower();
Client client = connectedClients.Find( c => c.name.ToLower() == playerName || Client client = ConnectedClients.Find( c => c.name.ToLower() == playerName ||
(c.character != null && c.character.Name.ToLower() == playerName)); (c.Character != null && c.Character.Name.ToLower() == playerName));
if (client == null) return; if (client == null) return;
@@ -1056,10 +933,10 @@ namespace Barotrauma.Networking
public void NewTraitor(out Character traitor, out Character target) public void NewTraitor(out Character traitor, out Character target)
{ {
List<Character> characters = new List<Character>(); List<Character> characters = new List<Character>();
foreach (Client client in connectedClients) foreach (Client client in ConnectedClients)
{ {
if (!client.inGame || client.character==null) continue; if (!client.inGame || client.Character==null) continue;
characters.Add(client.character); characters.Add(client.Character);
} }
if (myCharacter!= null) characters.Add(myCharacter); if (myCharacter!= null) characters.Add(myCharacter);
@@ -1093,9 +970,9 @@ namespace Barotrauma.Networking
} }
Client traitorClient = null; Client traitorClient = null;
foreach (Client c in connectedClients) foreach (Client c in ConnectedClients)
{ {
if (c.character != traitor) continue; if (c.Character != traitor) continue;
traitorClient = c; traitorClient = c;
break; break;
} }
@@ -1133,7 +1010,7 @@ namespace Barotrauma.Networking
int resentMessages = 0; int resentMessages = 0;
y += 110; y += 110;
foreach (Client c in connectedClients) foreach (Client c in ConnectedClients)
{ {
spriteBatch.DrawString(GUI.SmallFont, c.name + ":", new Vector2(x + 10, y), Color.White); spriteBatch.DrawString(GUI.SmallFont, c.name + ":", new Vector2(x + 10, y), Color.White);
spriteBatch.DrawString(GUI.SmallFont, "- avg roundtrip " + c.Connection.AverageRoundtripTime+" s", new Vector2(x + 20, y + 15), Color.White); spriteBatch.DrawString(GUI.SmallFont, "- avg roundtrip " + c.Connection.AverageRoundtripTime+" s", new Vector2(x + 20, y + 15), Color.White);
@@ -1160,7 +1037,7 @@ namespace Barotrauma.Networking
{ {
NetOutgoingMessage msg = server.CreateMessage(); NetOutgoingMessage msg = server.CreateMessage();
msg.Write((byte)PacketTypes.VoteStatus); msg.Write((byte)PacketTypes.VoteStatus);
Voting.WriteData(msg, connectedClients); Voting.WriteData(msg, ConnectedClients);
server.SendMessage(msg, server.Connections, NetDeliveryMethod.ReliableUnordered, 0); server.SendMessage(msg, server.Connections, NetDeliveryMethod.ReliableUnordered, 0);
} }
@@ -1191,14 +1068,12 @@ namespace Barotrauma.Networking
return true; return true;
} }
protected override bool SelectCrewCharacter(GUIComponent component, object obj) public override bool SelectCrewCharacter(GUIComponent component, object obj)
{ {
base.SelectCrewCharacter(component, obj); var characterFrame = component.Parent.Parent.FindChild("selectedcharacter");
var characterFrame = crewFrame.FindChild("selectedcharacter");
Character character = obj as Character; Character character = obj as Character;
if (obj == null) return false; if (character == null) return false;
if (character != myCharacter) if (character != myCharacter)
{ {
@@ -1225,9 +1100,9 @@ namespace Barotrauma.Networking
List<Client> recipients = new List<Client>(); List<Client> recipients = new List<Client>();
foreach (Client c in connectedClients) foreach (Client c in ConnectedClients)
{ {
if (type!=ChatMessageType.Dead || (c.character != null && c.character.IsDead)) recipients.Add(c); if (type!=ChatMessageType.Dead || (c.Character != null && c.Character.IsDead)) recipients.Add(c);
} }
foreach (Client c in recipients) foreach (Client c in recipients)
@@ -1271,7 +1146,7 @@ namespace Barotrauma.Networking
if (jobPrefab != null) jobPreferences.Add(jobPrefab); if (jobPrefab != null) jobPreferences.Add(jobPrefab);
} }
foreach (Client c in connectedClients) foreach (Client c in ConnectedClients)
{ {
if (c.Connection != message.SenderConnection) continue; if (c.Connection != message.SenderConnection) continue;
@@ -1298,7 +1173,7 @@ namespace Barotrauma.Networking
private void AssignJobs() private void AssignJobs()
{ {
List<Client> unassigned = new List<Client>(connectedClients); List<Client> unassigned = new List<Client>(ConnectedClients);
int[] assignedClientCount = new int[JobPrefab.List.Count]; int[] assignedClientCount = new int[JobPrefab.List.Count];
@@ -1424,7 +1299,7 @@ namespace Barotrauma.Networking
int bitCount = Rand.Int(100); int bitCount = Rand.Int(100);
for (int i = 0; i < bitCount; i++) for (int i = 0; i < bitCount; i++)
{ {
msg.Write((Rand.Int(2) == 0) ? true : false); msg.Write(Rand.Int(2) == 0);
} }
SendMessage(msg, (Rand.Int(2) == 0) ? NetDeliveryMethod.ReliableOrdered : NetDeliveryMethod.Unreliable, null); SendMessage(msg, (Rand.Int(2) == 0) ? NetDeliveryMethod.ReliableOrdered : NetDeliveryMethod.Unreliable, null);
@@ -1442,7 +1317,7 @@ namespace Barotrauma.Networking
public string name; public string name;
public int ID; public int ID;
public Character character; public Character Character;
public CharacterInfo characterInfo; public CharacterInfo characterInfo;
public NetConnection Connection { get; set; } public NetConnection Connection { get; set; }
public string version; public string version;
@@ -36,7 +36,7 @@ namespace Barotrauma.Networking
public bool AutoRestart public bool AutoRestart
{ {
get { return (connectedClients.Count == 0) ? false : autoRestart; } get { return (ConnectedClients.Count == 0) ? false : autoRestart; }
set set
{ {
autoRestart = value; autoRestart = value;
+1 -1
View File
@@ -14,7 +14,7 @@ namespace Barotrauma.Networking
public static string MasterServerUrl = GameMain.Config.MasterServerUrl; public static string MasterServerUrl = GameMain.Config.MasterServerUrl;
//if a character is further than this from the sub, the server will ignore it //if a Character is further than this from the sub, the server will ignore it
//(in sim units) //(in sim units)
public const float CharacterIgnoreDistance = 100.0f; public const float CharacterIgnoreDistance = 100.0f;
+11 -73
View File
@@ -27,7 +27,9 @@ namespace Barotrauma.Networking
Vote, VoteStatus, Vote, VoteStatus,
ResendRequest, ReliableMessage, LatestMessageID ResendRequest, ReliableMessage, LatestMessageID,
Spectate
} }
enum VoteType enum VoteType
@@ -56,10 +58,6 @@ namespace Barotrauma.Networking
public int Port; public int Port;
private bool crewFrameOpen;
private GUIButton crewButton;
protected GUIFrame crewFrame;
protected bool gameStarted; protected bool gameStarted;
protected Character myCharacter; protected Character myCharacter;
@@ -117,8 +115,6 @@ namespace Barotrauma.Networking
chatMsgBox.Font = GUI.SmallFont; chatMsgBox.Font = GUI.SmallFont;
chatMsgBox.OnEnterPressed = EnterChatMessage; chatMsgBox.OnEnterPressed = EnterChatMessage;
crewButton = new GUIButton(new Rectangle(chatBox.Rect.Right-80, chatBox.Rect.Y-30, 80, 20), "Crew", GUI.Style, inGameHUD);
crewButton.OnClicked = ToggleCrewFrame;
Voting = new Voting(); Voting = new Voting();
} }
@@ -159,66 +155,6 @@ namespace Barotrauma.Networking
} }
return message; return message;
}
protected void CreateCrewFrame(List<Character> crew)
{
int width = 600, height = 400;
crewFrame = new GUIFrame(new Rectangle(GameMain.GraphicsWidth / 2 - width / 2, GameMain.GraphicsHeight / 2 - height / 2, width, height), GUI.Style);
crewFrame.Padding = new Vector4(10.0f, 10.0f, 10.0f, 10.0f);
GUIListBox crewList = new GUIListBox(new Rectangle(0, 0, 280, 300), Color.White * 0.7f, GUI.Style, crewFrame);
crewList.Padding = new Vector4(10.0f, 10.0f, 10.0f, 10.0f);
crewList.OnSelected = SelectCrewCharacter;
foreach (Character character in crew)
{
GUIFrame frame = new GUIFrame(new Rectangle(0, 0, 0, 40), Color.Transparent, null, crewList);
frame.UserData = character;
frame.Padding = new Vector4(5.0f, 5.0f, 5.0f, 5.0f);
frame.Color = (myCharacter == character) ? Color.Gold * 0.2f : Color.Transparent;
frame.HoverColor = Color.LightGray * 0.5f;
frame.SelectedColor = Color.Gold * 0.5f;
GUITextBlock textBlock = new GUITextBlock(
new Rectangle(40, 0, 0, 25),
character.Info.Name + " ("+character.Info.Job.Name+")",
Color.Transparent, Color.White,
Alignment.Left, Alignment.Left,
null, frame);
textBlock.Padding = new Vector4(5.0f, 0.0f, 5.0f, 0.0f);
new GUIImage(new Rectangle(-10, 0, 0, 0), character.AnimController.Limbs[0].sprite, Alignment.Left, frame);
}
var closeButton = new GUIButton(new Rectangle(0,0, 80, 20), "Close", Alignment.BottomCenter, GUI.Style, crewFrame);
closeButton.OnClicked = ToggleCrewFrame;
}
protected virtual bool SelectCrewCharacter(GUIComponent component, object obj)
{
Character character = obj as Character;
if (obj == null) return false;
GUIComponent existingFrame = crewFrame.FindChild("selectedcharacter");
if (existingFrame != null) crewFrame.RemoveChild(existingFrame);
var previewPlayer = new GUIFrame(
new Rectangle(0,0, 230, 300),
new Color(0.0f, 0.0f, 0.0f, 0.8f), Alignment.TopRight, GUI.Style, crewFrame);
previewPlayer.Padding = new Vector4(5.0f, 5.0f, 5.0f, 5.0f);
previewPlayer.UserData = "selectedcharacter";
var infoFrame = character.Info.CreateInfoFrame(previewPlayer);
return true;
}
private bool ToggleCrewFrame(GUIButton button, object obj)
{
crewFrameOpen = !crewFrameOpen;
return true;
} }
public bool EnterChatMessage(GUITextBox textBox, string message) public bool EnterChatMessage(GUITextBox textBox, string message)
@@ -251,7 +187,6 @@ namespace Barotrauma.Networking
//float prevScroll = chatBox.BarScroll; //float prevScroll = chatBox.BarScroll;
float prevSize = chatBox.BarSize; float prevSize = chatBox.BarSize;
float oldScroll = chatBox.BarScroll;
msg.Padding = new Vector4(20, 0, 0, 0); msg.Padding = new Vector4(20, 0, 0, 0);
chatBox.AddChild(msg); chatBox.AddChild(msg);
@@ -265,13 +200,13 @@ namespace Barotrauma.Networking
public virtual void Update(float deltaTime) public virtual void Update(float deltaTime)
{ {
if (gameStarted) if (gameStarted && Screen.Selected == GameMain.GameScreen)
{ {
inGameHUD.Update(deltaTime); inGameHUD.Update(deltaTime);
if (crewFrameOpen) crewFrame.Update(deltaTime); //if (crewFrameOpen) crewFrame.Update(deltaTime);
if (Character.Controlled != null && Character.Controlled.IsDead) if (Character.Controlled == null || Character.Controlled.IsDead)
{ {
GameMain.GameScreen.Cam.TargetPos = Vector2.Zero; GameMain.GameScreen.Cam.TargetPos = Vector2.Zero;
GameMain.LightManager.LosEnabled = false; GameMain.LightManager.LosEnabled = false;
@@ -294,11 +229,14 @@ namespace Barotrauma.Networking
public virtual void Draw(Microsoft.Xna.Framework.Graphics.SpriteBatch spriteBatch) public virtual void Draw(Microsoft.Xna.Framework.Graphics.SpriteBatch spriteBatch)
{ {
if (!gameStarted) return; if (!gameStarted && Screen.Selected != GameMain.GameScreen) return;
inGameHUD.Draw(spriteBatch); inGameHUD.Draw(spriteBatch);
}
if (crewFrameOpen) crewFrame.Draw(spriteBatch); public virtual bool SelectCrewCharacter(GUIComponent component, object obj)
{
return false;
} }
public virtual void Disconnect() { } public virtual void Disconnect() { }
+81 -67
View File
@@ -10,6 +10,9 @@ namespace Barotrauma.Particles
{ {
private ParticlePrefab prefab; private ParticlePrefab prefab;
public delegate void OnChangeHullHandler(Vector2 position, Hull currentHull);
public OnChangeHullHandler OnChangeHull;
private Vector2 position; private Vector2 position;
private Vector2 prevPosition; private Vector2 prevPosition;
@@ -26,6 +29,8 @@ namespace Barotrauma.Particles
private Color color; private Color color;
private float alpha; private float alpha;
private int spriteIndex;
private float totalLifeTime; private float totalLifeTime;
private float lifeTime; private float lifeTime;
@@ -37,12 +42,17 @@ namespace Barotrauma.Particles
private Hull currentHull; private Hull currentHull;
private List<Hull> hullLimits; private List<Gap> hullGaps;
public ParticlePrefab.DrawTargetType DrawTarget public ParticlePrefab.DrawTargetType DrawTarget
{ {
get { return prefab.DrawTarget; } get { return prefab.DrawTarget; }
} }
public ParticleBlendState BlendState
{
get { return prefab.BlendState; }
}
public Vector2 Size public Vector2 Size
{ {
@@ -56,10 +66,12 @@ namespace Barotrauma.Particles
set { velocityChange = value; } set { velocityChange = value; }
} }
public void Init(ParticlePrefab prefab, Vector2 position, Vector2 speed, float rotation) public void Init(ParticlePrefab prefab, Vector2 position, Vector2 speed, float rotation, Hull hullGuess = null)
{ {
this.prefab = prefab; this.prefab = prefab;
spriteIndex = Rand.Int(prefab.Sprites.Count);
this.position = position; this.position = position;
prevPosition = position; prevPosition = position;
@@ -84,11 +96,15 @@ namespace Barotrauma.Particles
velocityChange = prefab.VelocityChange; velocityChange = prefab.VelocityChange;
OnChangeHull = null;
if (prefab.DeleteOnCollision || prefab.CollidesWithWalls) if (prefab.DeleteOnCollision || prefab.CollidesWithWalls)
{ {
//currentHull = Hull.FindHull(position); currentHull = Hull.FindHull(position, hullGuess);
hullLimits = new List<Hull>();
hullLimits = FindLimits(position); hullGaps = currentHull==null ? new List<Gap>() : currentHull.FindGaps();
//hullLimits = new List<Hull>();
//hullLimits = FindLimits(position);
} }
if (prefab.RotateToDirection) if (prefab.RotateToDirection)
@@ -99,55 +115,17 @@ namespace Barotrauma.Particles
} }
} }
private List<Hull> FindLimits(Vector2 position) //private List<Hull> FindLimits(Vector2 position)
{ //{
List<Hull> hullList = new List<Hull>(); // List<Hull> hullList = new List<Hull>();
currentHull = Hull.FindHull(position); // currentHull = Hull.FindHull(position);
if (currentHull == null) return hullList; // if (currentHull == null) return hullList;
hullList.Add(currentHull); // hullList.Add(currentHull);
return FindAdjacentHulls(hullList, currentHull, Math.Abs(velocity.X)>Math.Abs(velocity.Y));
}
private List<Hull> FindAdjacentHulls(List<Hull> adjacentHulls, Hull currentHull, bool isHorizontal) // return FindAdjacentHulls(hullList, currentHull, Math.Abs(velocity.X) > Math.Abs(velocity.Y));
{ //}
foreach (Gap gap in Gap.GapList)
{
if (gap.isHorizontal != isHorizontal) continue;
if (gap.Open < 0.01f) continue;
if (gap.linkedTo.Count==0)
{
continue;
}
else if (gap.linkedTo.Count==1)
{
if (!adjacentHulls.Contains(gap.linkedTo[0] as Hull))
{
adjacentHulls.Add(gap.linkedTo[0] as Hull);
}
}
else if (gap.linkedTo[0] == currentHull && gap.linkedTo[1] != null)
{
if (!adjacentHulls.Contains(gap.linkedTo[1] as Hull))
{
adjacentHulls.Add(gap.linkedTo[1] as Hull);
FindAdjacentHulls(adjacentHulls, gap.linkedTo[1] as Hull, isHorizontal);
}
}
else if (gap.linkedTo[1] == currentHull && gap.linkedTo[0] != null)
{
if (!adjacentHulls.Contains(gap.linkedTo[0] as Hull))
{
adjacentHulls.Add(gap.linkedTo[0] as Hull);
FindAdjacentHulls(adjacentHulls, gap.linkedTo[0] as Hull, isHorizontal);
}
}
}
return adjacentHulls;
}
public bool Update(float deltaTime) public bool Update(float deltaTime)
{ {
@@ -182,24 +160,57 @@ namespace Barotrauma.Particles
if ((prefab.DeleteOnCollision || prefab.CollidesWithWalls) && currentHull!=null) if ((prefab.DeleteOnCollision || prefab.CollidesWithWalls) && currentHull!=null)
{ {
bool insideHull = false; Vector2 edgePos = position + prefab.Sprites[spriteIndex].SourceRect.Width * Vector2.Normalize(velocity) * size.X;
foreach (Hull hull in hullLimits) //bool insideHull = false;
{ //foreach (Hull hull in hullLimits)
if (!Submarine.RectContains(hull.Rect, position)) continue; //{
// if (!Submarine.RectContains(hull.Rect, edgePos)) continue;
insideHull = true; // insideHull = true;
break; // break;
} //}
if (!insideHull) if (!Submarine.RectContains(currentHull.Rect, edgePos))
{ {
if (prefab.DeleteOnCollision) return false; if (prefab.DeleteOnCollision) return false;
Hull prevHull = Hull.FindHull(prevPosition, hullLimits, currentHull); bool gapFound = false;
foreach (Gap gap in hullGaps)
{
if (!gap.isHorizontal)
{
if (gap.Rect.X > position.X || gap.Rect.Right < position.X) continue;
if (Math.Sign(velocity.Y) != Math.Sign(gap.Rect.Y - position.Y)) continue;
}
else
{
if (gap.Rect.Y < position.Y || gap.Rect.Y - gap.Rect.Height > position.Y) continue;
if (Math.Sign(velocity.X) != Math.Sign(gap.Rect.X - position.X)) continue;
}
if (prevHull == null) return false; //Rectangle enlargedRect = new Rectangle(gap.Rect.X - 10, gap.Rect.Y + 10, gap.Rect.Width + 20, gap.Rect.Height + 20);
//if (!Submarine.RectContains(enlargedRect, position)) continue;
gapFound = true;
}
if (!gapFound)
{
OnWallCollision(currentHull, edgePos);
}
else
{
currentHull = Hull.FindHull(position);
hullGaps = currentHull == null ? new List<Gap>() : currentHull.FindGaps();
if (OnChangeHull != null) OnChangeHull(edgePos, currentHull);
}
//Hull prevHull = Hull.FindHull(prevPosition, hullLimits, currentHull);
//if (prevHull == null) return false;
OnWallCollision(prevHull);
} }
//if (position.Y < currentHull.Rect.Y-currentHull.Rect.Height) //if (position.Y < currentHull.Rect.Y-currentHull.Rect.Height)
@@ -217,10 +228,10 @@ namespace Barotrauma.Particles
return true; return true;
} }
private void OnWallCollision(Hull prevHull) private void OnWallCollision(Hull prevHull, Vector2 position)
{ {
float restitution = 0.05f; float restitution = 0.5f;
if (position.Y < prevHull.Rect.Y - prevHull.Rect.Height) if (position.Y < prevHull.Rect.Y - prevHull.Rect.Height)
{ {
position.Y = prevHull.Rect.Y - prevHull.Rect.Height + 1.0f; position.Y = prevHull.Rect.Y - prevHull.Rect.Height + 1.0f;
@@ -229,7 +240,8 @@ namespace Barotrauma.Particles
else if (position.Y > prevHull.Rect.Y) else if (position.Y > prevHull.Rect.Y)
{ {
position.Y = prevHull.Rect.Y - 1.0f; position.Y = prevHull.Rect.Y - 1.0f;
velocity.Y = -velocity.Y; velocity.X = Math.Abs(velocity.Y) * Math.Sign(velocity.X);
velocity.Y = -velocity.Y*0.1f;
} }
if (position.X < prevHull.Rect.X) if (position.X < prevHull.Rect.X)
@@ -262,7 +274,9 @@ namespace Barotrauma.Particles
} }
prefab.Sprite.Draw(spriteBatch, drawPosition, color*alpha, prefab.Sprite.origin, drawRotation, drawSize, SpriteEffects.None, prefab.Sprite.Depth); prefab.Sprites[spriteIndex].Draw(spriteBatch, drawPosition, color * alpha,
prefab.Sprites[spriteIndex].origin, drawRotation,
drawSize, SpriteEffects.None, prefab.Sprites[spriteIndex].Depth);
//spriteBatch.Draw( //spriteBatch.Draw(
// prefab.sprite.Texture, // prefab.sprite.Texture,
+14 -6
View File
@@ -7,9 +7,16 @@ using Microsoft.Xna.Framework.Graphics;
namespace Barotrauma.Particles namespace Barotrauma.Particles
{ {
enum ParticleBlendState
{
AlphaBlend, Additive
}
class ParticleManager class ParticleManager
{ {
public static int particleCount; public static int particleCount;
private const int MaxOutOfViewDist = 500;
private const int MaxParticles = 1500; private const int MaxParticles = 1500;
private Particle[] particles; private Particle[] particles;
@@ -45,23 +52,23 @@ namespace Barotrauma.Particles
return CreateParticle(prefabName, position, new Vector2((float)Math.Cos(angle), (float)Math.Sin(angle)) * speed, angle); return CreateParticle(prefabName, position, new Vector2((float)Math.Cos(angle), (float)Math.Sin(angle)) * speed, angle);
} }
public Particle CreateParticle(string prefabName, Vector2 position, Vector2 speed, float rotation=0.0f) public Particle CreateParticle(string prefabName, Vector2 position, Vector2 speed, float rotation=0.0f, Hull hullGuess = null)
{ {
ParticlePrefab prefab = FindPrefab(prefabName); ParticlePrefab prefab = FindPrefab(prefabName);
return CreateParticle(prefab, position, speed, rotation); return CreateParticle(prefab, position, speed, rotation, hullGuess);
} }
public Particle CreateParticle(ParticlePrefab prefab, Vector2 position, Vector2 speed, float rotation=0.0f) public Particle CreateParticle(ParticlePrefab prefab, Vector2 position, Vector2 speed, float rotation = 0.0f, Hull hullGuess = null)
{ {
if (!Submarine.RectContains(cam.WorldView, position)) return null; if (!Submarine.RectContains(MathUtils.ExpandRect(cam.WorldView, MaxOutOfViewDist), position)) return null;
//if (!cam.WorldView.Contains(position)) return null; //if (!cam.WorldView.Contains(position)) return null;
if (particleCount >= MaxParticles) return null; if (particleCount >= MaxParticles) return null;
if (particles[particleCount] == null) particles[particleCount] = new Particle(); if (particles[particleCount] == null) particles[particleCount] = new Particle();
particles[particleCount].Init(prefab, position, speed, rotation); particles[particleCount].Init(prefab, position, speed, rotation, hullGuess);
particleCount++; particleCount++;
@@ -100,12 +107,13 @@ namespace Barotrauma.Particles
} }
} }
public void Draw(SpriteBatch spriteBatch, bool inWater) public void Draw(SpriteBatch spriteBatch, bool inWater, ParticleBlendState blendState)
{ {
ParticlePrefab.DrawTargetType drawTarget = inWater ? ParticlePrefab.DrawTargetType.Water : ParticlePrefab.DrawTargetType.Air; ParticlePrefab.DrawTargetType drawTarget = inWater ? ParticlePrefab.DrawTargetType.Water : ParticlePrefab.DrawTargetType.Air;
for (int i = 0; i < particleCount; i++) for (int i = 0; i < particleCount; i++)
{ {
if (particles[i].BlendState != blendState) continue;
if (!particles[i].DrawTarget.HasFlag(drawTarget)) continue; if (!particles[i].DrawTarget.HasFlag(drawTarget)) continue;
particles[i].Draw(spriteBatch); particles[i].Draw(spriteBatch);
+11 -2
View File
@@ -1,6 +1,7 @@
using System.Xml.Linq; using System.Xml.Linq;
using Microsoft.Xna.Framework; using Microsoft.Xna.Framework;
using FarseerPhysics; using FarseerPhysics;
using System.Collections.Generic;
namespace Barotrauma.Particles namespace Barotrauma.Particles
{ {
@@ -10,7 +11,7 @@ namespace Barotrauma.Particles
public readonly string Name; public readonly string Name;
public readonly Sprite Sprite; public readonly List<Sprite> Sprites;
public readonly float AngularVelocityMin, AngularVelocityMax; public readonly float AngularVelocityMin, AngularVelocityMax;
@@ -35,17 +36,21 @@ namespace Barotrauma.Particles
public readonly DrawTargetType DrawTarget; public readonly DrawTargetType DrawTarget;
public readonly ParticleBlendState BlendState;
public readonly bool RotateToDirection; public readonly bool RotateToDirection;
public ParticlePrefab(XElement element) public ParticlePrefab(XElement element)
{ {
Name = element.Name.ToString(); Name = element.Name.ToString();
Sprites = new List<Sprite>();
foreach (XElement subElement in element.Elements()) foreach (XElement subElement in element.Elements())
{ {
if (subElement.Name.ToString().ToLower() != "sprite") continue; if (subElement.Name.ToString().ToLower() != "sprite") continue;
Sprite = new Sprite(subElement); Sprites.Add(new Sprite(subElement));
} }
if (element.Attribute("angularvelocity") == null) if (element.Attribute("angularvelocity") == null)
@@ -81,6 +86,10 @@ namespace Barotrauma.Particles
SizeChangeMax = SizeChangeMin; SizeChangeMax = SizeChangeMin;
} }
var blendState = ToolBox.GetAttributeString(element, "blendstate", "alphablend");
BlendState = (blendState != "additive") ? ParticleBlendState.AlphaBlend : ParticleBlendState.Additive;
GrowTime = ToolBox.GetAttributeFloat(element, "growtime", 0.0f); GrowTime = ToolBox.GetAttributeFloat(element, "growtime", 0.0f);
if (element.Attribute("startrotation") == null) if (element.Attribute("startrotation") == null)
+1 -1
View File
@@ -41,7 +41,7 @@ namespace Barotrauma
private float density; private float density;
//the direction the item is facing (for example, a gun has to be //the direction the item is facing (for example, a gun has to be
//flipped horizontally if the character holding it turns around) //flipped horizontally if the Character holding it turns around)
float dir; float dir;
public Vector2 TargetPosition public Vector2 TargetPosition
+3 -3
View File
@@ -309,14 +309,14 @@ namespace Barotrauma
{ {
if (!oldKeyboardState.IsKeyUp(key)) continue; if (!oldKeyboardState.IsKeyUp(key)) continue;
char character = (char)key; char Character = (char)key;
if (keyboardState.IsKeyUp(Keys.LeftShift) && keyboardState.IsKeyUp(Keys.RightShift)) if (keyboardState.IsKeyUp(Keys.LeftShift) && keyboardState.IsKeyUp(Keys.RightShift))
{ {
character = char.ToLower(character); Character = char.ToLower(Character);
} }
EventInput.EventInput.OnCharEntered(character); EventInput.EventInput.OnCharEntered(Character);
} }
#endif #endif
+1 -1
View File
@@ -232,7 +232,7 @@ namespace Barotrauma
{ {
ObjectProperty property = null; ObjectProperty property = null;
if (!dictionary.TryGetValue(attribute.Name.ToString().ToLower(), out property)) continue; if (!dictionary.TryGetValue(attribute.Name.ToString().ToLower(), out property)) continue;
if (property.Attributes.OfType<HasDefaultValue>().Count() == 0) continue; if (!property.Attributes.OfType<HasDefaultValue>().Any()) continue;
property.TrySetValue(attribute.Value); property.TrySetValue(attribute.Value);
} }
+1 -1
View File
@@ -14,7 +14,7 @@ namespace Barotrauma
private GUIComponent[] GUItabs; private GUIComponent[] GUItabs;
private int selectedTab; private int selectedTab;
//a character used for picking up and manipulating items //a Character used for picking up and manipulating items
private Character dummyCharacter; private Character dummyCharacter;
private bool characterMode; private bool characterMode;
+10 -3
View File
@@ -254,7 +254,7 @@ namespace Barotrauma
BlendState.AlphaBlend, BlendState.AlphaBlend,
null, DepthStencilState.DepthRead, null, null, null, DepthStencilState.DepthRead, null, null,
cam.Transform); cam.Transform);
GameMain.ParticleManager.Draw(spriteBatch, true); GameMain.ParticleManager.Draw(spriteBatch, true, Particles.ParticleBlendState.AlphaBlend);
spriteBatch.End(); spriteBatch.End();
@@ -271,10 +271,17 @@ namespace Barotrauma
BlendState.AlphaBlend, BlendState.AlphaBlend,
null, DepthStencilState.DepthRead, null, null, null, DepthStencilState.DepthRead, null, null,
cam.Transform); cam.Transform);
GameMain.ParticleManager.Draw(spriteBatch, false, Particles.ParticleBlendState.AlphaBlend);
GameMain.ParticleManager.Draw(spriteBatch, false);
spriteBatch.End(); spriteBatch.End();
spriteBatch.Begin(SpriteSortMode.Immediate,
BlendState.Additive,
null, DepthStencilState.DepthRead, null, null,
cam.Transform);
GameMain.ParticleManager.Draw(spriteBatch, false, Particles.ParticleBlendState.Additive);
spriteBatch.End();
graphics.SetRenderTarget(null); graphics.SetRenderTarget(null);
//---------------------------------------------------------------------------------------- //----------------------------------------------------------------------------------------
+12 -7
View File
@@ -54,6 +54,11 @@ namespace Barotrauma
} }
} }
private CrewManager CrewManager
{
get { return GameMain.GameSession.CrewManager; }
}
public LobbyScreen() public LobbyScreen()
{ {
Rectangle panelRect = new Rectangle( Rectangle panelRect = new Rectangle(
@@ -68,7 +73,7 @@ namespace Barotrauma
// save, Color.Transparent, Color.White, Alignment.Left, GUI.Style, leftPanel); // save, Color.Transparent, Color.White, Alignment.Left, GUI.Style, leftPanel);
GUITextBlock moneyText = new GUITextBlock(new Rectangle(0, 30, 0, 25), "", GUI.Style, GUITextBlock moneyText = new GUITextBlock(new Rectangle(0, 30, 0, 25), "", GUI.Style,
Alignment.TopCenter, Alignment.Top, leftPanel); Alignment.TopLeft, Alignment.TopLeft, leftPanel);
moneyText.TextGetter = GetMoney; moneyText.TextGetter = GetMoney;
GUIButton button = new GUIButton(new Rectangle(0, 70, 100, 30), "Map", null, Alignment.TopCenter, GUI.Style, leftPanel); GUIButton button = new GUIButton(new Rectangle(0, 70, 100, 30), "Map", null, Alignment.TopCenter, GUI.Style, leftPanel);
@@ -234,7 +239,7 @@ namespace Barotrauma
private void UpdateCharacterLists() private void UpdateCharacterLists()
{ {
characterList.ClearChildren(); characterList.ClearChildren();
foreach (CharacterInfo c in gameMode.CrewManager.characterInfos) foreach (CharacterInfo c in CrewManager.characterInfos)
{ {
GUITextBlock textBlock = new GUITextBlock( GUITextBlock textBlock = new GUITextBlock(
new Rectangle(0, 0, 0, 25), new Rectangle(0, 0, 0, 25),
@@ -291,7 +296,7 @@ namespace Barotrauma
CreateItemFrame(prefab, selectedItemList); CreateItemFrame(prefab, selectedItemList);
buyButton.Enabled = gameMode.CrewManager.Money >= selectedItemCost; buyButton.Enabled = CrewManager.Money >= selectedItemCost;
return false; return false;
} }
@@ -310,9 +315,9 @@ namespace Barotrauma
{ {
int cost = selectedItemCost; int cost = selectedItemCost;
if (gameMode.CrewManager.Money < cost) return false; if (CrewManager.Money < cost) return false;
gameMode.CrewManager.Money -= cost; CrewManager.Money -= cost;
for (int i = selectedItemList.children.Count-1; i>=0; i--) for (int i = selectedItemList.children.Count-1; i>=0; i--)
{ {
@@ -345,7 +350,7 @@ namespace Barotrauma
public override void Draw(double deltaTime, GraphicsDevice graphics, SpriteBatch spriteBatch) public override void Draw(double deltaTime, GraphicsDevice graphics, SpriteBatch spriteBatch)
{ {
if (characterList.CountChildren != gameMode.CrewManager.characterInfos.Count) if (characterList.CountChildren != CrewManager.characterInfos.Count)
{ {
UpdateCharacterLists(); UpdateCharacterLists();
} }
@@ -406,7 +411,7 @@ namespace Barotrauma
private string GetMoney() private string GetMoney()
{ {
return "Money: " + ((GameMain.GameSession == null) ? "" : gameMode.CrewManager.Money.ToString()); return "Money: " + ((GameMain.GameSession == null) ? "" : CrewManager.Money.ToString());
} }
private bool SelectCharacter(GUIComponent component, object selection) private bool SelectCharacter(GUIComponent component, object selection)
+11 -7
View File
@@ -129,7 +129,7 @@ namespace Barotrauma
//server info panel ------------------------------------------------------------ //server info panel ------------------------------------------------------------
infoFrame = new GUIFrame(new Rectangle(0, 0, (int)(panelRect.Width * 0.7f), (int)(panelRect.Height * 0.6f)), GUI.Style, menu); infoFrame = new GUIFrame(new Rectangle(0, 0, (int)(panelRect.Width * 0.7f), (int)(panelRect.Height * 0.6f)), GUI.Style, menu);
infoFrame.Padding = new Vector4(20.0f, 20.0f, 20.0f, 20.0f); ; infoFrame.Padding = new Vector4(20.0f, 20.0f, 20.0f, 20.0f);
//chatbox ---------------------------------------------------------------------- //chatbox ----------------------------------------------------------------------
GUIFrame chatFrame = new GUIFrame( GUIFrame chatFrame = new GUIFrame(
@@ -295,8 +295,8 @@ namespace Barotrauma
ServerName = (GameMain.Server==null) ? "Server" : GameMain.Server.Name; ServerName = (GameMain.Server==null) ? "Server" : GameMain.Server.Name;
infoFrame.RemoveChild(infoFrame.children.Find(c => c.UserData as string == "startButton")); infoFrame.RemoveChild(infoFrame.children.Find(c => c.UserData as string == "startButton"));
infoFrame.RemoveChild(infoFrame.children.Find(c => c.UserData as string == "spectateButton"));
playerList.Parent.RemoveChild(playerList.Parent.children.Find(c => c.UserData as string == "banListButton")); playerList.Parent.RemoveChild(playerList.Parent.children.Find(c => c.UserData as string == "banListButton"));
@@ -313,15 +313,13 @@ namespace Barotrauma
GUIButton settingsButton = new GUIButton(new Rectangle(-100, 0, 80, 30), "Settings", Alignment.BottomRight, GUI.Style, infoFrame); GUIButton settingsButton = new GUIButton(new Rectangle(-100, 0, 80, 30), "Settings", Alignment.BottomRight, GUI.Style, infoFrame);
settingsButton.OnClicked = GameMain.Server.ToggleSettingsFrame; settingsButton.OnClicked = GameMain.Server.ToggleSettingsFrame;
settingsButton.CanBeSelected = false;
settingsButton.UserData = "settingsButton"; settingsButton.UserData = "settingsButton";
var banListButton = new GUIButton(new Rectangle(0, 30, 100, 20), "Banned IPs", Alignment.BottomRight, GUI.Style, playerList.Parent); var banListButton = new GUIButton(new Rectangle(0, 30, 100, 20), "Banned IPs", Alignment.BottomRight, GUI.Style, playerList.Parent);
banListButton.OnClicked = GameMain.Server.BanList.ToggleBanFrame; banListButton.OnClicked = GameMain.Server.BanList.ToggleBanFrame;
banListButton.UserData = "banListButton"; banListButton.UserData = "banListButton";
//mapList.OnSelected = new GUIListBox.OnSelectedHandler(Game1.server.UpdateNetLobby);
//modeList.OnSelected += GameMain.Server.UpdateNetLobby;
if (subList.CountChildren > 0 && subList.Selected == null) subList.Select(-1); if (subList.CountChildren > 0 && subList.Selected == null) subList.Select(-1);
if (GameModePreset.list.Count > 0 && modeList.Selected == null) modeList.Select(-1); if (GameModePreset.list.Count > 0 && modeList.Selected == null) modeList.Select(-1);
@@ -337,8 +335,15 @@ namespace Barotrauma
if (GameMain.Server.SubSelectionMode == SelectionMode.Random) subList.Select(Rand.Range(0,subList.CountChildren)); if (GameMain.Server.SubSelectionMode == SelectionMode.Random) subList.Select(Rand.Range(0,subList.CountChildren));
if (GameMain.Server.ModeSelectionMode == SelectionMode.Random) modeList.Select(Rand.Range(0, modeList.CountChildren)); if (GameMain.Server.ModeSelectionMode == SelectionMode.Random) modeList.Select(Rand.Range(0, modeList.CountChildren));
} }
else else if (GameMain.Client != null)
{ {
if (GameMain.Client.GameStarted)
{
GUIButton spectateButton = new GUIButton(new Rectangle(0, 0, 80, 30), "Spectate", Alignment.BottomRight, GUI.Style, infoFrame);
spectateButton.OnClicked = GameMain.Client.SpectateClicked;
spectateButton.UserData = "spectateButton";
}
UpdatePlayerFrame(GameMain.Client.CharacterInfo); UpdatePlayerFrame(GameMain.Client.CharacterInfo);
} }
@@ -654,7 +659,6 @@ namespace Barotrauma
public void NewChatMessage(string message, Color color) public void NewChatMessage(string message, Color color)
{ {
float prevSize = chatBox.BarSize; float prevSize = chatBox.BarSize;
float oldScroll = chatBox.BarScroll;
while (chatBox.CountChildren>20) while (chatBox.CountChildren>20)
{ {
+2 -2
View File
@@ -24,7 +24,7 @@ namespace Barotrauma
if (GameMain.Server != null) if (GameMain.Server != null)
{ {
UpdateVoteTexts(GameMain.Server.connectedClients, VoteType.Sub); UpdateVoteTexts(GameMain.Server.ConnectedClients, VoteType.Sub);
GameMain.Server.UpdateVoteStatus(); GameMain.Server.UpdateVoteStatus();
} }
else else
@@ -44,7 +44,7 @@ namespace Barotrauma
GameMain.NetLobbyScreen.InfoFrame.FindChild("modevotes").Visible = value; GameMain.NetLobbyScreen.InfoFrame.FindChild("modevotes").Visible = value;
if (GameMain.Server != null) if (GameMain.Server != null)
{ {
UpdateVoteTexts(GameMain.Server.connectedClients, VoteType.Mode); UpdateVoteTexts(GameMain.Server.ConnectedClients, VoteType.Mode);
GameMain.Server.UpdateVoteStatus(); GameMain.Server.UpdateVoteStatus();
} }
else else
@@ -143,7 +143,7 @@ namespace Barotrauma
if (string.IsNullOrWhiteSpace(masterServerData)) if (string.IsNullOrWhiteSpace(masterServerData))
{ {
var nameText = new GUITextBlock(new Rectangle(0, 0, 0, 20), "Couldn't find any servers", GUI.Style, serverList); new GUITextBlock(new Rectangle(0, 0, 0, 20), "Couldn't find any servers", GUI.Style, serverList);
return; return;
} }
+1 -1
View File
@@ -217,7 +217,7 @@ namespace Barotrauma
Task criticalTask = null; Task criticalTask = null;
if (GameMain.GameSession!=null) if (GameMain.GameSession!=null)
{ {
foreach (Task task in GameMain.GameSession.taskManager.Tasks) foreach (Task task in GameMain.GameSession.TaskManager.Tasks)
{ {
if (!task.IsStarted) continue; if (!task.IsStarted) continue;
if (criticalTask == null || task.Priority > criticalTask.Priority) if (criticalTask == null || task.Priority > criticalTask.Priority)
+4
View File
@@ -42,6 +42,10 @@ namespace Barotrauma
return (IsValid(vector.X) && IsValid(vector.Y)); return (IsValid(vector.X) && IsValid(vector.Y));
} }
public static Rectangle ExpandRect(Rectangle rect, int amount)
{
return new Rectangle(rect.X - amount, rect.Y + amount, rect.Width + amount * 2, rect.Height + amount * 2);
}
public static int VectorOrientation(Vector2 p1, Vector2 p2, Vector2 p) public static int VectorOrientation(Vector2 p1, Vector2 p2, Vector2 p)
{ {
-1
View File
@@ -179,7 +179,6 @@ namespace Barotrauma
var attribute = element.Attribute(name); var attribute = element.Attribute(name);
if (attribute == null) return defaultValue; if (attribute == null) return defaultValue;
string val = attribute.Value.ToLower().Trim();
return GetAttributeBool(attribute, defaultValue); return GetAttributeBool(attribute, defaultValue);
} }
Binary file not shown.