Item UI replacements, fabricator bugfix, randomly spawning artifacts, AI can fix leaks, LimbAttacks do damage once (not each frame for the duration of the attack)
This commit is contained in:
@@ -98,6 +98,7 @@
|
||||
<Compile Include="Source\Events\Quests\Quest.cs" />
|
||||
<Compile Include="Source\Events\Quests\MonsterQuest.cs" />
|
||||
<Compile Include="Source\Events\Quests\SalvageQuest.cs" />
|
||||
<Compile Include="Source\Events\ArtifactEvent.cs" />
|
||||
<Compile Include="Source\GameSession\CargoManager.cs" />
|
||||
<Compile Include="Source\GameSession\GameModes\GameModePreset.cs" />
|
||||
<Compile Include="Source\GameSession\GameModes\QuestMode.cs" />
|
||||
|
||||
@@ -44,12 +44,12 @@
|
||||
|
||||
<limb id = "8" width="100" height="450" impacttolerance="100.0">
|
||||
<sprite texture="Content/Characters/Endworm/endworm.png" sourcerect="755,552,137,470" depth="0.08" origin="0.5,0.5"/>
|
||||
<attack type="PinchCW" range="500" duration="0.5" damage="30" stun="0.1" bleedingdamage="3" structuredamage="500" damagetype="slash"/>
|
||||
<attack type="PinchCW" range="500" duration="0.5" damage="30" stun="5.0" structuredamage="500" damagetype="slash"/>
|
||||
</limb>
|
||||
|
||||
<limb id = "9" width="100" height="450" impacttolerance="100.0">
|
||||
<sprite texture="Content/Characters/Endworm/endworm.png" sourcerect="892,552,137,470" depth="0.08" origin="0.6,0.5"/>
|
||||
<attack type="PinchCCW" range="500" duration="0.5" damage="300" stun="0.1" bleedingdamage="30" structuredamage="500" damagetype="slash"/>
|
||||
<attack type="PinchCCW" range="500" duration="0.5" damage="30" stun="5.0" structuredamage="500" damagetype="slash"/>
|
||||
</limb>
|
||||
|
||||
|
||||
@@ -71,12 +71,8 @@
|
||||
<joint limb1="0" limb1anchor="-160,50" limb2="8" limb2anchor="0,-200" lowerlimit="-20" upperlimit="50"/>
|
||||
|
||||
<joint limb1="0" limb1anchor="160,50" limb2="9" limb2anchor="0,-200" lowerlimit="-50" upperlimit="20"/>
|
||||
|
||||
|
||||
|
||||
s
|
||||
</ragdoll>
|
||||
|
||||
<ai attackhumans="100" attackrooms="50.0" attackweaker="50" attackstronger="-30" sight="0.5" hearing="1.0"/>
|
||||
<ai attackrooms="100.0" attackweaker="50" attackstronger="-30" sight="0.5" hearing="1.0"/>
|
||||
</Character>
|
||||
|
||||
|
||||
Binary file not shown.
Binary file not shown.
Binary file not shown.
@@ -39,5 +39,23 @@
|
||||
<Fire/>
|
||||
</StatusEffect>
|
||||
</Holdable>
|
||||
</Item>
|
||||
|
||||
<Item
|
||||
name="Faraday Artifact"
|
||||
pickdistance="150">
|
||||
|
||||
<Sprite texture="artifact.png" depth="0.8" sourcerect="40,0,33,61"/>
|
||||
|
||||
<Deconstruct time="30">
|
||||
<Item name="Steel Bar"/>
|
||||
<Item name="Fulgurium Bar"/>
|
||||
<Item name="Fulgurium Bar"/>
|
||||
<Item name="Fulgurium Bar"/>
|
||||
</Deconstruct>
|
||||
|
||||
<Body radius="20" height="20" density="5"/>
|
||||
|
||||
<Holdable slots="RightHand+LeftHand" holdpos="30,-15" handle1="0,10" handle2="0,-10"/>
|
||||
</Item>
|
||||
</Items>
|
||||
@@ -31,6 +31,10 @@
|
||||
<fabricableitem name="RegEx Find Component" requireditems="Steel Bar, FPGA Circuit" requiredtime="10"/>
|
||||
<fabricableitem name="Wifi Component" requireditems="Steel Bar, FPGA Circuit" requiredtime="10"/>
|
||||
|
||||
<fabricableitem name="Fulgurium Battery Cell" requireditems="Steel Bar, Fulgurium Bar, FPGA Circuit" requiredtime="10"/>
|
||||
|
||||
<fabricableitem name="Battery Cell" requireditems="Steel Bar, Copper Bar, FPGA Circuit" requiredtime="10"/>
|
||||
|
||||
<fabricableitem name="Fuel Rod" requireditems="Steel Bar, Uranium Bar"/>
|
||||
|
||||
<fabricableitem name="Incendium Fuel Rod" requireditems="Steel Bar, Incendium Bar"/>
|
||||
|
||||
@@ -23,7 +23,6 @@
|
||||
|
||||
<Reactor canbeselected = "true">
|
||||
<GuiFrame rect="0,0,760,460" alignment="Center" color="0.0,0.0,0.0,0.6"/>
|
||||
<requireditem name="Fuel Rod" type="Contained" msg="Fuel required to run the engine"/>
|
||||
<StatusEffect type="OnActive" target="Contained" targetnames="Fuel Rod, Heat Absorber, Temperature Control Circuit" Condition="-0.1" />
|
||||
<sound file="reactor.ogg" type="OnActive" range="2000.0" volume="FissionRate" volumemultiplier="0.02" loop="true"/>
|
||||
|
||||
@@ -45,6 +44,7 @@
|
||||
</Containable>
|
||||
<Containable name="Incendium Fuel Rod">
|
||||
<StatusEffect type="OnContaining" target="This" AvailableFuel="5000.0" disabledeltatime="true"/>
|
||||
<StatusEffect type="OnContaining" target="Contained" Condition="-0.05"/>
|
||||
</Containable>
|
||||
<Containable name="Heat Absorber"/>
|
||||
<Containable name="Temperature Control Circuit"/>
|
||||
|
||||
@@ -89,11 +89,16 @@
|
||||
<StatusEffect type="OnUse" target="Contained,Character" Condition="-25.0" stun="10.0" disabledeltatime="true" sound="Content/Items/Weapons/stunbaton.ogg">
|
||||
<RequiredItem name="Battery Cell" type="Contained" msg="Loaded Battery Cell required"/>
|
||||
<Explosion range="100.0" force="0.1" shockwave="false" flames="false" camerashake="5.0"/>
|
||||
</StatusEffect>
|
||||
</StatusEffect>
|
||||
<StatusEffect type="OnUse" target="Contained,Character" Condition="-15.0" stun="15.0" disabledeltatime="true" sound="Content/Items/Weapons/stunbaton.ogg">
|
||||
<RequiredItem name="Fulgurium Battery Cell" type="Contained" msg="Loaded Battery Cell required"/>
|
||||
<Explosion range="100.0" force="0.5" shockwave="false" flames="false" camerashake="5.0"/>
|
||||
</StatusEffect>
|
||||
</MeleeWeapon>
|
||||
|
||||
<ItemContainer capacity="1" hideitems="true">
|
||||
<Containable name="Battery Cell"/>
|
||||
<Containable name="Fulgurium Battery Cell"/>
|
||||
</ItemContainer>
|
||||
</Item>
|
||||
|
||||
@@ -111,6 +116,20 @@
|
||||
|
||||
<Pickable slots="Any,RightHand,LeftHand"/>
|
||||
</Item>
|
||||
|
||||
<Item
|
||||
name="Fulgurium Battery Cell"
|
||||
category="Equipment"
|
||||
pickdistance="150"
|
||||
tags="smallitem,loadable"
|
||||
description="A battery cell contructed of the rare and poorly understood compound Fulgurium.">
|
||||
|
||||
<Sprite texture="weapons.png" sourcerect="0,0,20,9" depth="0.8"/>
|
||||
|
||||
<Body width="20" height="9" density="15"/>
|
||||
|
||||
<Pickable slots="Any,RightHand,LeftHand"/>
|
||||
</Item>
|
||||
</Items>
|
||||
|
||||
|
||||
|
||||
@@ -41,5 +41,26 @@
|
||||
difficulty="5"
|
||||
minamount="1" maxamount="1"
|
||||
musictype="deep"/>
|
||||
|
||||
<MonsterEvent name="Under attack" description=""
|
||||
characterfile="Content/Characters/Watcher/watcher.xml"
|
||||
commonness="3"
|
||||
difficulty="5"
|
||||
minamount="1" maxamount="1"/>
|
||||
|
||||
<ArtifactEvent name="Artifact" description=""
|
||||
itemname="Skyholder Artifact"
|
||||
commonness="1"
|
||||
difficulty="0"/>
|
||||
|
||||
<ArtifactEvent name="Artifact" description=""
|
||||
itemname="Thermal Artifact"
|
||||
commonness="1"
|
||||
difficulty="0"/>
|
||||
|
||||
<ArtifactEvent name="Artifact" description=""
|
||||
itemname="Faraday Artifact"
|
||||
commonness="1"
|
||||
difficulty="0"/>
|
||||
|
||||
</Randomevents>
|
||||
@@ -143,7 +143,6 @@ namespace Barotrauma
|
||||
private void UpdateNone(float deltaTime)
|
||||
{
|
||||
//wander around randomly
|
||||
//UpdateSteeringWander(deltaTime, 0.8f);
|
||||
steeringManager.SteeringWander(0.8f);
|
||||
steeringManager.SteeringAvoid(deltaTime, 1.0f);
|
||||
|
||||
@@ -328,9 +327,12 @@ namespace Barotrauma
|
||||
attackTimer += deltaTime;
|
||||
limb.body.ApplyTorque(limb.Mass * 50.0f * Character.AnimController.Dir * dir);
|
||||
|
||||
limb.attack.DoDamage(Character, damageTarget, limb.WorldPosition, deltaTime, (limb.soundTimer <= 0.0f));
|
||||
if (attackTimer >= limb.attack.Duration)
|
||||
{
|
||||
limb.attack.DoDamage(Character, damageTarget, limb.WorldPosition, 1.0f, (limb.soundTimer <= 0.0f));
|
||||
|
||||
limb.soundTimer = Limb.SoundInterval;
|
||||
limb.soundTimer = Limb.SoundInterval;
|
||||
}
|
||||
}
|
||||
|
||||
Vector2 diff = attackPosition - limb.SimPosition;
|
||||
|
||||
@@ -96,6 +96,17 @@ namespace Barotrauma
|
||||
{
|
||||
if (currentPath == null) return Vector2.Zero;
|
||||
|
||||
if (currentPath.CurrentIndex == currentPath.Nodes.Count)
|
||||
{
|
||||
|
||||
Vector2 pos2 = host.SimPosition;
|
||||
if (character != null && character.Submarine == null)
|
||||
{
|
||||
pos2 -= Submarine.Loaded.SimPosition;
|
||||
}
|
||||
return currentTarget-pos2;
|
||||
}
|
||||
|
||||
if (canOpenDoors) CheckDoorsInPath();
|
||||
|
||||
float allowedDistance = character.AnimController.InWater ? 1.0f : 0.6f;
|
||||
|
||||
@@ -149,7 +149,10 @@ namespace Barotrauma
|
||||
if (divingGearObjective != null)
|
||||
{
|
||||
divingGearObjective.TryComplete(deltaTime);
|
||||
return divingGearObjective.IsCompleted();
|
||||
|
||||
bool isCompleted = divingGearObjective.IsCompleted();
|
||||
if (isCompleted) divingGearObjective = null;
|
||||
return isCompleted;
|
||||
}
|
||||
|
||||
return false;
|
||||
@@ -165,6 +168,10 @@ namespace Barotrauma
|
||||
if (character.AnimController.CurrentHull == null) return 0.0f;
|
||||
currenthullSafety = GetHullSafety(character.AnimController.CurrentHull);
|
||||
priority = 100.0f - currenthullSafety;
|
||||
|
||||
|
||||
if (divingGearObjective != null && !divingGearObjective.IsCompleted()) priority += 20.0f;
|
||||
|
||||
return priority;
|
||||
}
|
||||
|
||||
|
||||
@@ -25,10 +25,12 @@ namespace Barotrauma
|
||||
|
||||
public override float GetPriority(Character character)
|
||||
{
|
||||
float leakSize = (leak.isHorizontal ? leak.Rect.Height : leak.Rect.Width) * leak.Open;
|
||||
if (leak.Open == 0.0f) return 0.0f;
|
||||
|
||||
float leakSize = (leak.isHorizontal ? leak.Rect.Height : leak.Rect.Width) * Math.Max(leak.Open, 0.1f);
|
||||
|
||||
float dist = Vector2.DistanceSquared(character.SimPosition, leak.SimPosition);
|
||||
dist = Math.Max(dist/1000.0f, 1.0f);
|
||||
dist = Math.Max(dist/100.0f, 1.0f);
|
||||
return Math.Min(leakSize/dist, 40.0f);
|
||||
}
|
||||
|
||||
@@ -69,7 +71,7 @@ namespace Barotrauma
|
||||
{
|
||||
var repairTool = weldingTool.GetComponent<RepairTool>();
|
||||
if (repairTool == null) return;
|
||||
AddSubObjective(new AIObjectiveOperateItem(repairTool, character, ""));
|
||||
AddSubObjective(new AIObjectiveOperateItem(repairTool, character, "", leak));
|
||||
}
|
||||
}
|
||||
|
||||
|
||||
@@ -46,7 +46,7 @@ namespace Barotrauma
|
||||
this.equip = equip;
|
||||
|
||||
currSearchIndex = 0;
|
||||
|
||||
|
||||
this.itemName = itemName;
|
||||
}
|
||||
|
||||
@@ -136,7 +136,18 @@ namespace Barotrauma
|
||||
|
||||
public override bool IsCompleted()
|
||||
{
|
||||
return character.Inventory.FindItem(itemName) != null;
|
||||
if (itemName!=null)
|
||||
{
|
||||
return character.Inventory.FindItem(itemName) != null;
|
||||
}
|
||||
else if (targetItem!= null)
|
||||
{
|
||||
return character.Inventory.Items.Contains(targetItem);
|
||||
}
|
||||
else
|
||||
{
|
||||
return false;
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
@@ -16,18 +16,18 @@ namespace Barotrauma
|
||||
|
||||
bool repeat;
|
||||
|
||||
//how long until the path to the target is declared unreachable
|
||||
private float waitUntilPathUnreachable;
|
||||
|
||||
public override bool CanBeCompleted
|
||||
{
|
||||
get
|
||||
{
|
||||
if (repeat) return true;
|
||||
if (repeat || waitUntilPathUnreachable > 0.0f) return true;
|
||||
var pathSteering = character.AIController.SteeringManager as IndoorsSteeringManager;
|
||||
|
||||
//path doesn't exist (= hasn't been searched for yet), assume for now that the target is reachable
|
||||
if (pathSteering.CurrentPath == null) return true;
|
||||
//steeringmanager is still targeting some other position, assume for now that the target is reachable
|
||||
if ((target != null && Vector2.Distance(target.Position, targetPos) > 5.0f) ||
|
||||
Vector2.Distance(pathSteering.CurrentTarget, targetPos) > 5.0f) return true;
|
||||
|
||||
return (!pathSteering.CurrentPath.Unreachable);
|
||||
}
|
||||
@@ -43,6 +43,8 @@ namespace Barotrauma
|
||||
{
|
||||
this.target = target;
|
||||
this.repeat = repeat;
|
||||
|
||||
waitUntilPathUnreachable = 5.0f;
|
||||
}
|
||||
|
||||
|
||||
@@ -51,17 +53,20 @@ namespace Barotrauma
|
||||
{
|
||||
this.targetPos = simPos;
|
||||
this.repeat = repeat;
|
||||
|
||||
waitUntilPathUnreachable = 5.0f;
|
||||
}
|
||||
|
||||
protected override void Act(float deltaTime)
|
||||
{
|
||||
{
|
||||
waitUntilPathUnreachable -= deltaTime;
|
||||
|
||||
if (character.SelectedConstruction!=null && character.SelectedConstruction.GetComponent<Ladder>()==null)
|
||||
{
|
||||
character.SelectedConstruction = null;
|
||||
}
|
||||
|
||||
if (target!=null) character.AIController.SelectTarget(target.AiTarget);
|
||||
|
||||
if (target != null) character.AIController.SelectTarget(target.AiTarget);
|
||||
|
||||
Vector2 currTargetPos = Vector2.Zero;
|
||||
|
||||
|
||||
@@ -71,8 +71,15 @@ namespace Barotrauma
|
||||
}
|
||||
}
|
||||
|
||||
if (character.AnimController.InWater)
|
||||
{
|
||||
character.AIController.SteeringManager.SteeringManual(deltaTime, new Vector2(0.0f, 0.5f));
|
||||
}
|
||||
else
|
||||
{
|
||||
character.AIController.SteeringManager.SteeringWander();
|
||||
}
|
||||
|
||||
character.AIController.SteeringManager.SteeringWander(1.0f);
|
||||
return;
|
||||
}
|
||||
|
||||
|
||||
@@ -57,7 +57,7 @@ namespace Barotrauma
|
||||
|
||||
foreach (Gap gap in Gap.GapList)
|
||||
{
|
||||
if (gap.IsRoomToRoom || gap.ConnectedDoor != null || gap.Open<0.1f) continue;
|
||||
if (gap.IsRoomToRoom || gap.ConnectedDoor != null || gap.Open<0.01f) continue;
|
||||
|
||||
AddObjective(new AIObjectiveFixLeak(gap, character));
|
||||
}
|
||||
|
||||
@@ -429,13 +429,13 @@ namespace Barotrauma
|
||||
pos.Y = -pos.Y;
|
||||
GUI.DrawRectangle(spriteBatch, new Rectangle((int)pos.X, (int)pos.Y, 5, 5), Color.Red, true, 0.01f);
|
||||
|
||||
if (limb.AnimTargetPos == Vector2.Zero) continue;
|
||||
//if (limb.AnimTargetPos == Vector2.Zero) continue;
|
||||
|
||||
Vector2 pos2 = ConvertUnits.ToDisplayUnits(limb.AnimTargetPos);
|
||||
pos2.Y = -pos2.Y;
|
||||
GUI.DrawRectangle(spriteBatch, new Rectangle((int)pos2.X, (int)pos2.Y, 5, 5), Color.Blue, true, 0.01f);
|
||||
//Vector2 pos2 = ConvertUnits.ToDisplayUnits(limb.AnimTargetPos);
|
||||
//pos2.Y = -pos2.Y;
|
||||
//GUI.DrawRectangle(spriteBatch, new Rectangle((int)pos2.X, (int)pos2.Y, 5, 5), Color.Blue, true, 0.01f);
|
||||
|
||||
GUI.DrawLine(spriteBatch, pos, pos2, Color.Green);
|
||||
//GUI.DrawLine(spriteBatch, pos, pos2, Color.Green);
|
||||
}
|
||||
}
|
||||
|
||||
@@ -456,7 +456,7 @@ namespace Barotrauma
|
||||
pos.Y = -pos.Y;
|
||||
|
||||
GUI.DrawRectangle(spriteBatch, new Rectangle((int)pos.X - 10, (int)pos.Y - 10, 20, 20), Color.Cyan, false, 0.01f);
|
||||
GUI.DrawLine(spriteBatch, pos, new Vector2(limb.Position.X, -limb.Position.Y), limb==RefLimb ? Color.Orange : Color.Cyan);
|
||||
GUI.DrawLine(spriteBatch, pos, new Vector2(limb.Position.X, -limb.Position.Y), limb == RefLimb ? Color.Orange : Color.Cyan);
|
||||
}
|
||||
}
|
||||
|
||||
|
||||
@@ -1044,7 +1044,7 @@ namespace Barotrauma
|
||||
if (soundStates[i] != state) continue;
|
||||
if (n == selectedSound && sounds[i]!=null)
|
||||
{
|
||||
sounds[i].Play(1.0f, 2000.0f, AnimController.Limbs[0].WorldPosition);
|
||||
sounds[i].Play(1.0f, soundRange[i], AnimController.Limbs[0].WorldPosition);
|
||||
return;
|
||||
}
|
||||
n++;
|
||||
|
||||
66
Subsurface/Source/Events/ArtifactEvent.cs
Normal file
66
Subsurface/Source/Events/ArtifactEvent.cs
Normal file
@@ -0,0 +1,66 @@
|
||||
using FarseerPhysics;
|
||||
using Microsoft.Xna.Framework;
|
||||
using System;
|
||||
using System.Collections.Generic;
|
||||
using System.Linq;
|
||||
using System.Text;
|
||||
using System.Xml.Linq;
|
||||
|
||||
namespace Barotrauma
|
||||
{
|
||||
class ArtifactEvent : ScriptedEvent
|
||||
{
|
||||
private ItemPrefab itemPrefab;
|
||||
|
||||
private Item item;
|
||||
|
||||
private int state;
|
||||
|
||||
public ArtifactEvent(XElement element)
|
||||
: base(element)
|
||||
{
|
||||
string itemName = ToolBox.GetAttributeString(element, "itemname", "");
|
||||
|
||||
itemPrefab = ItemPrefab.list.Find(ip => ip.Name == itemName) as ItemPrefab;
|
||||
|
||||
if (itemPrefab == null)
|
||||
{
|
||||
DebugConsole.ThrowError("Error in SalvageMission: couldn't find an item prefab with the name "+itemName);
|
||||
}
|
||||
}
|
||||
|
||||
protected override void Start()
|
||||
{
|
||||
Vector2 position = Level.Loaded.GetRandomItemPos(30.0f);
|
||||
|
||||
item = new Item(itemPrefab, position, null);
|
||||
item.MoveWithLevel = true;
|
||||
item.body.FarseerBody.IsKinematic = true;
|
||||
}
|
||||
|
||||
public override void Update(float deltaTime)
|
||||
{
|
||||
switch (state)
|
||||
{
|
||||
case 0:
|
||||
Start();
|
||||
state = 1;
|
||||
break;
|
||||
case 1:
|
||||
|
||||
//item.body.LinearVelocity = Vector2.Zero;
|
||||
if (item.Inventory!=null) item.body.FarseerBody.IsKinematic = false;
|
||||
if (item.CurrentHull == null) return;
|
||||
|
||||
state = 2;
|
||||
break;
|
||||
case 2:
|
||||
if (!Submarine.Loaded.AtEndPosition && !Submarine.Loaded.AtStartPosition) return;
|
||||
|
||||
Finished();
|
||||
state = 3;
|
||||
break;
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
@@ -37,10 +37,8 @@ namespace Barotrauma
|
||||
{
|
||||
Vector2 position = (randomWayPoint == null) ? Vector2.Zero : randomWayPoint.Position;
|
||||
|
||||
//!!!!!!!!!!!!!!!!!!
|
||||
if (spawnDeep)
|
||||
{
|
||||
|
||||
position.Y -= Level.Loaded.Size.Y;
|
||||
}
|
||||
|
||||
@@ -70,8 +68,8 @@ namespace Barotrauma
|
||||
monstersDead = false;
|
||||
break;
|
||||
}
|
||||
if (monstersDead) Finished();
|
||||
|
||||
|
||||
if (monstersDead) Finished();
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
@@ -39,36 +39,11 @@ namespace Barotrauma
|
||||
|
||||
public override void Start(Level level)
|
||||
{
|
||||
Vector2 position = Vector2.Zero;
|
||||
|
||||
int tries = 0;
|
||||
do
|
||||
{
|
||||
Vector2 tryPos = level.PositionsOfInterest[Rand.Int(level.PositionsOfInterest.Count, false)];
|
||||
|
||||
if (Submarine.PickBody(
|
||||
ConvertUnits.ToSimUnits(tryPos),
|
||||
ConvertUnits.ToSimUnits(tryPos - Vector2.UnitY*level.Size.Y),
|
||||
null, Physics.CollisionLevel) != null)
|
||||
{
|
||||
position = ConvertUnits.ToDisplayUnits(Submarine.LastPickedPosition);
|
||||
break;
|
||||
}
|
||||
|
||||
tries++;
|
||||
|
||||
if (tries==10)
|
||||
{
|
||||
position = level.EndPosition - Vector2.UnitY*300.0f;
|
||||
}
|
||||
|
||||
} while (tries < 10);
|
||||
|
||||
|
||||
Vector2 position = Level.Loaded.GetRandomItemPos(30.0f);
|
||||
|
||||
item = new Item(itemPrefab, position, null);
|
||||
item.MoveWithLevel = true;
|
||||
item.body.FarseerBody.IsKinematic = true;
|
||||
//item.MoveWithLevel = true;
|
||||
}
|
||||
|
||||
public override void Update(float deltaTime)
|
||||
|
||||
@@ -214,6 +214,8 @@ namespace Barotrauma.Items.Components
|
||||
Gap leak = objective.OperateTarget as Gap;
|
||||
if (leak == null) return true;
|
||||
|
||||
if (Vector2.Distance(leak.WorldPosition, item.WorldPosition) > range) return true;
|
||||
|
||||
character.CursorPosition = leak.Position;
|
||||
character.SetInput(InputType.Aim, false, true);
|
||||
|
||||
|
||||
@@ -249,8 +249,11 @@ namespace Barotrauma.Items.Components
|
||||
|
||||
foreach (Tuple<ItemPrefab,int> ip in fabricatedItem.RequiredItems)
|
||||
{
|
||||
var requiredItem = containers[0].Inventory.Items.FirstOrDefault(it => it != null && it.Prefab == ip.Item1);
|
||||
containers[0].Inventory.RemoveItem(requiredItem);
|
||||
for (int i = 0; i<ip.Item2; i++)
|
||||
{
|
||||
var requiredItem = containers[0].Inventory.Items.FirstOrDefault(it => it != null && it.Prefab == ip.Item1);
|
||||
containers[0].Inventory.RemoveItem(requiredItem);
|
||||
}
|
||||
}
|
||||
|
||||
Item.Spawner.QueueItem(fabricatedItem.TargetItem, containers[1].Inventory);
|
||||
@@ -268,7 +271,7 @@ namespace Barotrauma.Items.Components
|
||||
ItemContainer container = item.GetComponent<ItemContainer>();
|
||||
foreach (Tuple<ItemPrefab,int> ip in targetItem.RequiredItems)
|
||||
{
|
||||
if (Array.FindAll(container.Inventory.Items, it => it != null && it.Prefab == ip.Item1).Count() < ip.Item2) continue;
|
||||
if (Array.FindAll(container.Inventory.Items, it => it != null && it.Prefab == ip.Item1).Count() >= ip.Item2) continue;
|
||||
activateButton.Enabled = false;
|
||||
break;
|
||||
}
|
||||
@@ -276,15 +279,6 @@ namespace Barotrauma.Items.Components
|
||||
|
||||
GuiFrame.Update((float)Physics.step);
|
||||
GuiFrame.Draw(spriteBatch);
|
||||
|
||||
//itemList.Update(0.016f);
|
||||
//itemList.Draw(spriteBatch);
|
||||
|
||||
//if (selectedItemFrame != null)
|
||||
//{
|
||||
// selectedItemFrame.Update(0.016f);
|
||||
// selectedItemFrame.Draw(spriteBatch);
|
||||
//}
|
||||
}
|
||||
|
||||
public override bool FillNetworkData(Networking.NetworkEventType type, Lidgren.Network.NetBuffer message)
|
||||
|
||||
@@ -9,14 +9,16 @@ namespace Barotrauma.Items.Components
|
||||
{
|
||||
class Pump : Powered
|
||||
{
|
||||
float flowPercentage;
|
||||
float maxFlow;
|
||||
private float flowPercentage;
|
||||
private float maxFlow;
|
||||
|
||||
float? targetLevel;
|
||||
private float? targetLevel;
|
||||
|
||||
float lastUpdate;
|
||||
private float lastUpdate;
|
||||
|
||||
Hull hull1;
|
||||
private Hull hull1;
|
||||
|
||||
private GUITickBox isActiveTickBox;
|
||||
|
||||
[HasDefaultValue(0.0f, true)]
|
||||
public float FlowPercentage
|
||||
@@ -47,10 +49,53 @@ namespace Barotrauma.Items.Components
|
||||
}
|
||||
}
|
||||
|
||||
public override bool IsActive
|
||||
{
|
||||
get
|
||||
{
|
||||
return base.IsActive;
|
||||
}
|
||||
set
|
||||
{
|
||||
base.IsActive = value;
|
||||
|
||||
if (isActiveTickBox != null) isActiveTickBox.Selected = value;
|
||||
}
|
||||
}
|
||||
|
||||
public Pump(Item item, XElement element)
|
||||
: base(item, element)
|
||||
{
|
||||
GetHull();
|
||||
|
||||
isActiveTickBox = new GUITickBox(new Rectangle(0, 0, 20, 20), "Running", Alignment.TopLeft, GuiFrame);
|
||||
isActiveTickBox.OnSelected = (GUITickBox box) =>
|
||||
{
|
||||
targetLevel = null;
|
||||
IsActive = !IsActive;
|
||||
if (!IsActive) currPowerConsumption = 0.0f;
|
||||
item.NewComponentEvent(this, true, true);
|
||||
|
||||
return true;
|
||||
};
|
||||
|
||||
var button = new GUIButton(new Rectangle(160, 40, 35, 30), "OUT", GUI.Style, GuiFrame);
|
||||
button.OnClicked = (GUIButton btn, object obj) =>
|
||||
{
|
||||
FlowPercentage -= 10.0f;
|
||||
item.NewComponentEvent(this, true, true);
|
||||
|
||||
return true;
|
||||
};
|
||||
|
||||
button = new GUIButton(new Rectangle(210, 40, 35, 30), "IN", GUI.Style, GuiFrame);
|
||||
button.OnClicked = (GUIButton btn, object obj) =>
|
||||
{
|
||||
FlowPercentage += 10.0f;
|
||||
item.NewComponentEvent(this, true, true);
|
||||
|
||||
return true;
|
||||
};
|
||||
}
|
||||
|
||||
public override void Move(Vector2 amount)
|
||||
@@ -112,28 +157,11 @@ namespace Barotrauma.Items.Components
|
||||
int x = GuiFrame.Rect.X;
|
||||
int y = GuiFrame.Rect.Y;
|
||||
|
||||
GuiFrame.Update(1.0f / 60.0f);
|
||||
GuiFrame.Draw(spriteBatch);
|
||||
|
||||
if (GUI.DrawButton(spriteBatch, new Rectangle(x + 20, y + 20, 100, 40), ((IsActive) ? "TURN OFF" : "TURN ON")))
|
||||
{
|
||||
targetLevel = null;
|
||||
IsActive = !IsActive;
|
||||
if (!IsActive) currPowerConsumption = 0.0f;
|
||||
item.NewComponentEvent(this, true, true);
|
||||
}
|
||||
|
||||
spriteBatch.DrawString(GUI.Font, "Pumping speed: " + (int)flowPercentage + " %", new Vector2(x + 20, y + 80), Color.White);
|
||||
|
||||
if (GUI.DrawButton(spriteBatch, new Rectangle(x + 200, y + 70, 40, 40), "OUT", false))
|
||||
{
|
||||
FlowPercentage -= 10.0f;
|
||||
item.NewComponentEvent(this, true, true);
|
||||
}
|
||||
if (GUI.DrawButton(spriteBatch, new Rectangle(x + 250, y + 70, 40, 40), "IN", false))
|
||||
{
|
||||
FlowPercentage += 10.0f;
|
||||
item.NewComponentEvent(this, true, true);
|
||||
}
|
||||
spriteBatch.DrawString(GUI.Font, "Pumping speed: " + (int)flowPercentage + " %", new Vector2(x + 40, y + 85), Color.White);
|
||||
|
||||
}
|
||||
|
||||
public override void ReceiveSignal(string signal, Connection connection, Item sender, float power=0.0f)
|
||||
|
||||
@@ -52,6 +52,8 @@ namespace Barotrauma.Items.Components
|
||||
|
||||
private PropertyTask powerUpTask;
|
||||
|
||||
private GUITickBox autoTempTickBox;
|
||||
|
||||
private bool unsentChanges;
|
||||
private float sendUpdateTimer;
|
||||
|
||||
@@ -127,7 +129,11 @@ namespace Barotrauma.Items.Components
|
||||
public bool AutoTemp
|
||||
{
|
||||
get { return autoTemp; }
|
||||
set { autoTemp = value; }
|
||||
set
|
||||
{
|
||||
autoTemp = value;
|
||||
if (autoTempTickBox!=null) autoTempTickBox.Selected = value;
|
||||
}
|
||||
}
|
||||
|
||||
public float ExtraCooling { get; set; }
|
||||
@@ -173,8 +179,8 @@ namespace Barotrauma.Items.Components
|
||||
return true;
|
||||
};
|
||||
|
||||
button = new GUIButton(new Rectangle(410, 170, 100, 40), "TURN ON", GUI.Style, GuiFrame);
|
||||
button.OnClicked = ToggleAutoTemp;
|
||||
autoTempTickBox = new GUITickBox(new Rectangle(410, 170, 20, 20), "Automatic temperature control", Alignment.TopLeft, GuiFrame);
|
||||
autoTempTickBox.OnSelected = ToggleAutoTemp;
|
||||
|
||||
button = new GUIButton(new Rectangle(210, 290, 40, 40), "+", GUI.Style, GuiFrame);
|
||||
button.OnPressed = () =>
|
||||
@@ -449,7 +455,7 @@ namespace Barotrauma.Items.Components
|
||||
|
||||
spriteBatch.DrawString(GUI.Font, "Shutdown Temperature: " + shutDownTemp, new Vector2(x + 450, y + 80), Color.White);
|
||||
|
||||
spriteBatch.DrawString(GUI.Font, "Automatic Temperature Control: " + ((autoTemp) ? "ON" : "OFF"), new Vector2(x + 450, y + 180), Color.White);
|
||||
//spriteBatch.DrawString(GUI.Font, "Automatic Temperature Control: " + ((autoTemp) ? "ON" : "OFF"), new Vector2(x + 450, y + 180), Color.White);
|
||||
|
||||
y += 300;
|
||||
|
||||
@@ -466,12 +472,10 @@ namespace Barotrauma.Items.Components
|
||||
//y = y - 260;
|
||||
}
|
||||
|
||||
private bool ToggleAutoTemp(GUIButton button, object userdata)
|
||||
private bool ToggleAutoTemp(GUITickBox tickBox)
|
||||
{
|
||||
unsentChanges = true;
|
||||
autoTemp = !autoTemp;
|
||||
|
||||
button.Text = autoTemp ? "TURN OFF" : "TURN ON";
|
||||
autoTemp = tickBox.Selected;
|
||||
|
||||
return true;
|
||||
}
|
||||
|
||||
@@ -73,6 +73,24 @@ namespace Barotrauma.Items.Components
|
||||
//maxOutput = ToolBox.GetAttributeFloat(element, "maxoutput", 10.0f);
|
||||
|
||||
IsActive = true;
|
||||
|
||||
var button = new GUIButton(new Rectangle(160, 50, 30,30), "-", GUI.Style, GuiFrame);
|
||||
button.OnClicked = (GUIButton btn, object obj) =>
|
||||
{
|
||||
rechargeSpeed = Math.Max(rechargeSpeed - maxRechargeSpeed * 0.1f, 0.0f);
|
||||
item.NewComponentEvent(this, true, false);
|
||||
|
||||
return true;
|
||||
};
|
||||
|
||||
button = new GUIButton(new Rectangle(200, 50, 30, 30), "+", GUI.Style, GuiFrame);
|
||||
button.OnClicked = (GUIButton btn, object obj) =>
|
||||
{
|
||||
rechargeSpeed = Math.Max(rechargeSpeed + maxRechargeSpeed * 0.1f, 0.0f);
|
||||
item.NewComponentEvent(this, true, false);
|
||||
|
||||
return true;
|
||||
};
|
||||
}
|
||||
|
||||
public override bool Pick(Character picker)
|
||||
@@ -189,18 +207,8 @@ namespace Barotrauma.Items.Components
|
||||
"Charge: " + (int)charge + "/" + (int)capacity + " (" + (int)((charge / capacity) * 100.0f) + " %)",
|
||||
new Vector2(x + 30, y + 30), Color.White);
|
||||
|
||||
spriteBatch.DrawString(GUI.Font, "Recharge rate: " + (int)((rechargeSpeed / maxRechargeSpeed)*100.0f)+" %", new Vector2(x + 30, y + 100), Color.White);
|
||||
if (GUI.DrawButton(spriteBatch, new Rectangle(x + 200, y + 90, 40, 40), "+"))
|
||||
{
|
||||
rechargeSpeed = Math.Min(rechargeSpeed + maxRechargeSpeed*0.1f, maxRechargeSpeed);
|
||||
item.NewComponentEvent(this, true, false);
|
||||
}
|
||||
spriteBatch.DrawString(GUI.Font, "Recharge rate: " + (int)((rechargeSpeed / maxRechargeSpeed)*100.0f)+" %", new Vector2(x + 30, y + 95), Color.White);
|
||||
|
||||
if (GUI.DrawButton(spriteBatch, new Rectangle(x + 250, y + 90, 40, 40), "-"))
|
||||
{
|
||||
rechargeSpeed = Math.Max(rechargeSpeed - maxRechargeSpeed * 0.1f, 0.0f);
|
||||
item.NewComponentEvent(this, true, false);
|
||||
}
|
||||
}
|
||||
|
||||
public override bool FillNetworkData(Networking.NetworkEventType type, Lidgren.Network.NetBuffer message)
|
||||
|
||||
@@ -140,6 +140,8 @@ namespace Barotrauma
|
||||
|
||||
public Item FindItem(string itemName)
|
||||
{
|
||||
if (itemName == null) return null;
|
||||
|
||||
return Items.FirstOrDefault(i => i != null && (i.Name == itemName || i.HasTag(itemName)));
|
||||
}
|
||||
|
||||
|
||||
@@ -459,6 +459,8 @@ namespace Barotrauma
|
||||
|
||||
public bool HasTag(string tag)
|
||||
{
|
||||
if (tag == null) return true;
|
||||
|
||||
return (tags.Contains(tag) || tags.Contains(tag.ToLower()));
|
||||
}
|
||||
|
||||
|
||||
@@ -112,7 +112,7 @@ namespace Barotrauma
|
||||
return;
|
||||
}
|
||||
|
||||
sprite.Draw(spriteBatch, new Vector2(position.X + sprite.size.X / 2.0f, -position.Y + sprite.size.Y / 2.0f));
|
||||
sprite.Draw(spriteBatch, new Vector2(position.X + sprite.size.X / 2.0f, -position.Y + sprite.size.Y / 2.0f), SpriteColor);
|
||||
}
|
||||
else
|
||||
{
|
||||
@@ -146,7 +146,7 @@ namespace Barotrauma
|
||||
position = placePosition;
|
||||
}
|
||||
|
||||
if (sprite != null) sprite.DrawTiled(spriteBatch, new Vector2(position.X, -position.Y), placeSize, Color.White);
|
||||
if (sprite != null) sprite.DrawTiled(spriteBatch, new Vector2(position.X, -position.Y), placeSize, SpriteColor);
|
||||
}
|
||||
|
||||
//if (PlayerInput.GetMouseState.RightButton == ButtonState.Pressed) selected = null;
|
||||
|
||||
@@ -854,6 +854,40 @@ namespace Barotrauma
|
||||
return normal;
|
||||
}
|
||||
|
||||
public Vector2 GetRandomItemPos(float offsetFromWall = 10.0f)
|
||||
{
|
||||
Vector2 position = Vector2.Zero;
|
||||
|
||||
offsetFromWall = ConvertUnits.ToSimUnits(offsetFromWall);
|
||||
|
||||
int tries = 0;
|
||||
do
|
||||
{
|
||||
Vector2 startPos = ConvertUnits.ToSimUnits(PositionsOfInterest[Rand.Int(PositionsOfInterest.Count, false)]);
|
||||
|
||||
Vector2 endPos = startPos - ConvertUnits.ToSimUnits(Vector2.UnitY * Size.Y);
|
||||
|
||||
if (Submarine.PickBody(
|
||||
startPos,
|
||||
endPos,
|
||||
null, Physics.CollisionLevel) != null)
|
||||
{
|
||||
position = ConvertUnits.ToDisplayUnits(Submarine.LastPickedPosition - Vector2.Normalize(startPos - endPos)*offsetFromWall);
|
||||
break;
|
||||
}
|
||||
|
||||
tries++;
|
||||
|
||||
if (tries == 10)
|
||||
{
|
||||
position = EndPosition - Vector2.UnitY * 300.0f;
|
||||
}
|
||||
|
||||
} while (tries < 10);
|
||||
|
||||
return position;
|
||||
}
|
||||
|
||||
//public void SetPosition(Vector2 pos)
|
||||
//{
|
||||
// Vector2 amount = pos - Position;
|
||||
|
||||
Binary file not shown.
Reference in New Issue
Block a user