(7ee8dbc11) v0.9.8.0

This commit is contained in:
Joonas Rikkonen
2020-03-31 15:11:41 +03:00
parent 3e99a49383
commit b647059b93
147 changed files with 2299 additions and 1297 deletions
@@ -173,8 +173,8 @@ namespace Barotrauma.Items.Components
if (!item.linkedTo.Contains(target.item)) item.linkedTo.Add(target.item);
if (!target.item.linkedTo.Contains(item)) target.item.linkedTo.Add(item);
if (!target.item.Submarine.DockedTo.Contains(item.Submarine)) target.item.Submarine.DockedTo.Add(item.Submarine);
if (!item.Submarine.DockedTo.Contains(target.item.Submarine)) item.Submarine.DockedTo.Add(target.item.Submarine);
if (!target.item.Submarine.DockedTo.Contains(item.Submarine)) target.item.Submarine.ConnectedDockingPorts.Add(item.Submarine, target);
if (!item.Submarine.DockedTo.Contains(target.item.Submarine)) item.Submarine.ConnectedDockingPorts.Add(target.item.Submarine, this);
DockingTarget = target;
DockingTarget.DockingTarget = this;
@@ -703,8 +703,8 @@ namespace Barotrauma.Items.Components
ApplyStatusEffects(ActionType.OnSecondaryUse, 1.0f);
DockingTarget.item.Submarine.DockedTo.Remove(item.Submarine);
item.Submarine.DockedTo.Remove(DockingTarget.item.Submarine);
DockingTarget.item.Submarine.ConnectedDockingPorts.Remove(item.Submarine);
item.Submarine.ConnectedDockingPorts.Remove(DockingTarget.item.Submarine);
if (door != null && DockingTarget.door != null)
{
@@ -287,24 +287,21 @@ namespace Barotrauma.Items.Components
public override bool Select(Character character)
{
if (!isBroken)
if (isBroken) { return true; }
bool hasRequiredItems = HasRequiredItems(character, false);
if (HasAccess(character))
{
bool hasRequiredItems = HasRequiredItems(character, false);
if (HasAccess(character))
{
float originalPickingTime = PickingTime;
PickingTime = 0;
ToggleState(ActionType.OnUse, character);
PickingTime = originalPickingTime;
}
#if CLIENT
else if (hasRequiredItems && character != null && character == Character.Controlled)
{
GUI.AddMessage(accessDeniedTxt, GUI.Style.Red);
}
#endif
float originalPickingTime = PickingTime;
PickingTime = 0;
ToggleState(ActionType.OnUse, character);
PickingTime = originalPickingTime;
}
#if CLIENT
else if (hasRequiredItems && character != null && character == Character.Controlled)
{
GUI.AddMessage(accessDeniedTxt, GUI.Style.Red);
}
#endif
return false;
}
@@ -578,13 +578,7 @@ namespace Barotrauma.Items.Components
{
character.SetInput(InputType.Aim, false, true);
}
bool isAiming = false;
var holdable = item.GetComponent<Holdable>();
if (holdable != null)
{
isAiming = holdable.ControlPose;
}
sinTime = isAiming ? sinTime + deltaTime * 5 : 0;
sinTime += deltaTime * 5;
}
// Press the trigger only when the tool is approximately facing the target.
Vector2 fromItemToLeak = leak.WorldPosition - item.WorldPosition;
@@ -870,6 +870,7 @@ namespace Barotrauma.Items.Components
switch (subElement.Name.ToString().ToLowerInvariant())
{
case "requireditem":
case "requireditems":
RelatedItem newRequiredItem = RelatedItem.Load(subElement, returnEmptyRequirements, item.Name);
if (newRequiredItem == null) continue;
@@ -22,6 +22,30 @@ namespace Barotrauma.Items.Components
private ItemContainer inputContainer, outputContainer;
private enum FabricatorState
{
Active = 1,
Paused = 2,
Stopped = 0
}
private FabricatorState state;
private FabricatorState State
{
get
{
return state;
}
set
{
if (state == value) { return; }
state = value;
#if SERVER
item.CreateServerEvent(this);
#endif
}
}
public ItemContainer InputContainer
{
get { return inputContainer; }
@@ -61,6 +85,8 @@ namespace Barotrauma.Items.Components
}
}
state = FabricatorState.Stopped;
InitProjSpecific();
}
@@ -147,12 +173,15 @@ namespace Barotrauma.Items.Components
currPowerConsumption = powerConsumption;
currPowerConsumption *= MathHelper.Lerp(1.5f, 1.0f, item.Condition / item.MaxCondition);
if (GameMain.NetworkMember?.IsServer ?? true)
{
State = FabricatorState.Active;
}
#if SERVER
if (user != null)
{
GameServer.Log(user.LogName + " started fabricating " + selectedItem.DisplayName + " in " + item.Name, ServerLog.MessageType.ItemInteraction);
}
item.CreateServerEvent(this);
#endif
}
@@ -180,12 +209,15 @@ namespace Barotrauma.Items.Components
inputContainer.Inventory.Locked = false;
outputContainer.Inventory.Locked = false;
if (GameMain.NetworkMember?.IsServer ?? true)
{
State = FabricatorState.Stopped;
}
#if SERVER
if (user != null)
{
GameServer.Log(user.LogName + " cancelled the fabrication of " + fabricatedItem.DisplayName + " in " + item.Name, ServerLog.MessageType.ItemInteraction);
}
item.CreateServerEvent(this);
#endif
}
@@ -199,8 +231,25 @@ namespace Barotrauma.Items.Components
progressState = fabricatedItem == null ? 0.0f : (requiredTime - timeUntilReady) / requiredTime;
hasPower = Voltage >= MinVoltage;
if (!hasPower) { return; }
if (GameMain.NetworkMember?.IsClient ?? false)
{
hasPower = State != FabricatorState.Paused;
if (!hasPower)
{
return;
}
}
else
{
hasPower = Voltage >= MinVoltage;
if (!hasPower)
{
State = FabricatorState.Paused;
return;
}
State = FabricatorState.Active;
}
var repairable = item.GetComponent<Repairable>();
if (repairable != null)
@@ -37,23 +37,10 @@ namespace Barotrauma.Items.Components
private float currFlow;
public float CurrFlow
{
get
get
{
if (!IsActive) { return 0.0f; }
return Math.Abs(currFlow);
}
}
public override bool IsActive
{
get => base.IsActive;
set
{
base.IsActive = value;
if (!IsActive)
{
powerConsumption = 0;
}
return Math.Abs(currFlow);
}
}
@@ -53,7 +53,9 @@ namespace Barotrauma.Items.Components
private PrismaticJoint stickJoint;
private Body stickTarget;
private Attack attack;
private readonly Attack attack;
private Vector2 launchPos;
public List<Body> IgnoredBodies;
@@ -220,6 +222,8 @@ namespace Barotrauma.Items.Components
item.Drop(null);
launchPos = item.SimPosition;
item.body.Enabled = true;
item.body.ApplyLinearImpulse(impulse, maxVelocity: NetConfig.MaxPhysicsBodyVelocity);
@@ -415,7 +419,9 @@ namespace Barotrauma.Items.Components
item.body.SimPosition - ConvertUnits.ToSimUnits(sub.Position) - dir,
item.body.SimPosition - ConvertUnits.ToSimUnits(sub.Position) + dir,
collisionCategory: Physics.CollisionWall);
if (wallBody?.FixtureList?.First() != null && wallBody.UserData is Structure structure)
if (wallBody?.FixtureList?.First() != null && wallBody.UserData is Structure structure &&
//ignore the hit if it's behind the position the item was launched from, and the projectile is travelling in the opposite direction
Vector2.Dot(item.body.SimPosition - launchPos, dir) > 0)
{
target = wallBody.FixtureList.First();
}
@@ -79,6 +79,12 @@ namespace Barotrauma.Items.Components
Wire wire = wireItem.GetComponent<Wire>();
if (wire != null)
{
if (Item.ItemList.Any(it => it != item && (it.GetComponent<ConnectionPanel>()?.DisconnectedWires.Contains(wire) ?? false)))
{
if (wire.Item.body != null) { wire.Item.body.Enabled = false; }
wire.IsActive = false;
wire.UpdateSections();
}
DisconnectedWires.Add(wire);
base.IsActive = true;
}
@@ -272,13 +272,12 @@ namespace Barotrauma.Items.Components
private void UpdateAITarget(AITarget target)
{
target.Enabled = IsActive;
if (!IsActive) { return; }
if (target.MaxSightRange <= 0)
{
target.MaxSightRange = Range * 5;
}
target.SightRange = target.MaxSightRange * lightBrightness;
target.SightRange = Math.Max(target.SightRange, target.MaxSightRange * lightBrightness);
}
partial void SetLightSourceState(bool enabled, float brightness);
@@ -374,8 +374,9 @@ namespace Barotrauma.Items.Components
reload = reloadTime;
projectile.Drop(null);
projectile.body.Dir = 1.0f;
if (projectile.body == null) { return; }
projectile.body.Dir = 1.0f;
projectile.body.ResetDynamics();
projectile.body.Enabled = true;
projectile.SetTransform(ConvertUnits.ToSimUnits(new Vector2(item.WorldRect.X + transformedBarrelPos.X, item.WorldRect.Y - transformedBarrelPos.Y)), -rotation);
@@ -591,7 +592,7 @@ namespace Barotrauma.Items.Components
foreach (MapEntity e in item.linkedTo)
{
if (e is Item projectileContainer) { CheckProjectileContainer(projectileContainer, projectiles, returnFirst); }
if (returnFirst && projectiles.Any()) return projectiles;
if (returnFirst && projectiles.Any()) { return projectiles; }
}
return projectiles;
@@ -600,15 +601,15 @@ namespace Barotrauma.Items.Components
private void CheckProjectileContainer(Item projectileContainer, List<Projectile> projectiles, bool returnFirst)
{
var containedItems = projectileContainer.ContainedItems;
if (containedItems == null) return;
if (containedItems == null) { return; }
foreach (Item containedItem in containedItems)
{
var projectileComponent = containedItem.GetComponent<Projectile>();
if (projectileComponent != null)
if (projectileComponent != null && projectileComponent.Item.body != null)
{
projectiles.Add(projectileComponent);
if (returnFirst) return;
if (returnFirst) { return; }
}
else
{
@@ -617,10 +618,10 @@ namespace Barotrauma.Items.Components
foreach (Item subContainedItem in containedItem.ContainedItems)
{
projectileComponent = subContainedItem.GetComponent<Projectile>();
if (projectileComponent != null)
if (projectileComponent != null && projectileComponent.Item.body != null)
{
projectiles.Add(projectileComponent);
if (returnFirst) return;
if (returnFirst) { return; }
}
}
}