(e42047dc1) Tester's build, January 30th 2020

This commit is contained in:
Juan Pablo Arce
2020-01-30 15:56:31 -03:00
parent eaa18a20a3
commit 15499cb704
203 changed files with 8274 additions and 4950 deletions
@@ -300,7 +300,7 @@ namespace Barotrauma.Items.Components
#if CLIENT
else if (hasRequiredItems && character != null && character == Character.Controlled)
{
GUI.AddMessage(accessDeniedTxt, Color.Red);
GUI.AddMessage(accessDeniedTxt, GUI.Style.Red);
}
#endif
@@ -139,7 +139,7 @@ namespace Barotrauma.Items.Components
this,
item.WorldPosition,
pickTimer / requiredTime,
Color.Red, Color.Green);
GUI.Style.Red, GUI.Style.Green);
#endif
picker.AnimController.UpdateUseItem(true, item.WorldPosition + new Vector2(0.0f, 100.0f) * ((pickTimer / 10.0f) % 0.1f));
@@ -462,7 +462,7 @@ namespace Barotrauma.Items.Components
this,
targetItem.WorldPosition,
levelResource.DeattachTimer / levelResource.DeattachDuration,
Color.Red, Color.Green);
GUI.Style.Red, GUI.Style.Green);
#endif
}
FixItemProjSpecific(user, deltaTime, targetItem);
@@ -504,11 +504,12 @@ namespace Barotrauma.Items.Components
loopingSoundChannel = null;
}
foreach (SoundChannel channel in playingOneshotSoundChannels)
//no need to Dispose these - SoundManager will do it when it when it needs a free channel and the sound has stopped playing
//disposing immediately on Remove will for example prevent explosives from playing a sound if the explosion removes the item
/*foreach (SoundChannel channel in playingOneshotSoundChannels)
{
channel.Dispose();
loopingSoundChannel = null;
}
}*/
if (GuiFrame != null) { GUI.RemoveFromUpdateList(GuiFrame, true); }
#endif
@@ -85,7 +85,7 @@ namespace Barotrauma.Items.Components
currPowerConsumption = Math.Abs(targetForce) / 100.0f * powerConsumption;
//pumps consume more power when in a bad condition
currPowerConsumption *= MathHelper.Lerp(2.0f, 1.0f, item.Condition / item.MaxCondition);
currPowerConsumption *= MathHelper.Lerp(1.5f, 1.0f, item.Condition / item.MaxCondition);
if (powerConsumption == 0.0f) { Voltage = 1.0f; }
@@ -95,7 +95,8 @@ namespace Barotrauma.Items.Components
Force = MathHelper.Lerp(force, (Voltage < MinVoltage) ? 0.0f : targetForce, 0.1f);
if (Math.Abs(Force) > 1.0f)
{
Vector2 currForce = new Vector2((force / 10.0f) * maxForce * Math.Min(Voltage / MinVoltage, 1.0f), 0.0f);
float voltageFactor = MinVoltage <= 0.0f ? 1.0f : Math.Min(Voltage / MinVoltage, 1.0f);
Vector2 currForce = new Vector2((force / 10.0f) * maxForce * voltageFactor, 0.0f);
//less effective when in a bad condition
currForce *= MathHelper.Lerp(0.5f, 2.0f, item.Condition / item.MaxCondition);
@@ -154,7 +154,7 @@ namespace Barotrauma.Items.Components
outputContainer.Inventory.Locked = true;
currPowerConsumption = powerConsumption;
currPowerConsumption *= MathHelper.Lerp(2.0f, 1.0f, item.Condition / item.MaxCondition);
currPowerConsumption *= MathHelper.Lerp(1.5f, 1.0f, item.Condition / item.MaxCondition);
}
private void CancelFabricating(Character user = null)
@@ -73,7 +73,7 @@ namespace Barotrauma.Items.Components
}
currPowerConsumption = powerConsumption;
currPowerConsumption *= MathHelper.Lerp(2.0f, 1.0f, item.Condition / item.MaxCondition);
currPowerConsumption *= MathHelper.Lerp(1.5f, 1.0f, item.Condition / item.MaxCondition);
hasPower = Voltage > MinVoltage;
if (hasPower)
@@ -42,7 +42,7 @@ namespace Barotrauma.Items.Components
CurrFlow = 0.0f;
currPowerConsumption = powerConsumption;
//consume more power when in a bad condition
currPowerConsumption *= MathHelper.Lerp(2.0f, 1.0f, item.Condition / item.MaxCondition);
currPowerConsumption *= MathHelper.Lerp(1.5f, 1.0f, item.Condition / item.MaxCondition);
if (powerConsumption <= 0.0f)
{
@@ -14,8 +14,6 @@ namespace Barotrauma.Items.Components
private float? targetLevel;
private float pumpSpeedLockTimer, isActiveLockTimer;
private bool hasPower;
[Serialize(0.0f, true, description: "How fast the item is currently pumping water (-100 = full speed out, 100 = full speed in). Intended to be used by StatusEffect conditionals (setting this value in XML has no effect).")]
public float FlowPercentage
@@ -23,7 +21,7 @@ namespace Barotrauma.Items.Components
get { return flowPercentage; }
set
{
if (!MathUtils.IsValid(flowPercentage)) return;
if (!MathUtils.IsValid(flowPercentage)) { return; }
flowPercentage = MathHelper.Clamp(value, -100.0f, 100.0f);
flowPercentage = MathUtils.Round(flowPercentage, 1.0f);
}
@@ -41,11 +39,26 @@ namespace Barotrauma.Items.Components
{
get
{
if (!IsActive) return 0.0f;
if (!IsActive) { return 0.0f; }
return Math.Abs(currFlow);
}
}
public override bool IsActive
{
get => base.IsActive;
set
{
base.IsActive = value;
if (!IsActive)
{
powerConsumption = 0;
}
}
}
public bool HasPower => IsActive && Voltage >= MinVoltage;
public Pump(Item item, XElement element)
: base(item, element)
{
@@ -57,7 +70,6 @@ namespace Barotrauma.Items.Components
public override void Update(float deltaTime, Camera cam)
{
currFlow = 0.0f;
hasPower = false;
if (targetLevel != null)
{
@@ -74,14 +86,12 @@ namespace Barotrauma.Items.Components
currPowerConsumption = powerConsumption * Math.Abs(flowPercentage / 100.0f);
//pumps consume more power when in a bad condition
currPowerConsumption *= MathHelper.Lerp(2.0f, 1.0f, item.Condition / item.MaxCondition);
currPowerConsumption *= MathHelper.Lerp(1.5f, 1.0f, item.Condition / item.MaxCondition);
if (Voltage < MinVoltage) { return; }
if (!HasPower) { return; }
UpdateProjSpecific(deltaTime);
hasPower = true;
ApplyStatusEffects(ActionType.OnActive, deltaTime, null);
if (item.CurrentHull == null) { return; }
@@ -102,8 +112,8 @@ namespace Barotrauma.Items.Components
{
if (connection.Name == "toggle")
{
isActiveLockTimer = 0.1f;
IsActive = !IsActive;
isActiveLockTimer = 0.1f;
}
else if (connection.Name == "set_active")
{
@@ -126,21 +136,23 @@ namespace Barotrauma.Items.Components
pumpSpeedLockTimer = 0.1f;
}
}
if (!IsActive) currPowerConsumption = 0.0f;
}
public override bool AIOperate(float deltaTime, Character character, AIObjectiveOperateItem objective)
{
#if CLIENT
if (GameMain.Client != null) return false;
if (GameMain.Client != null) { return false; }
#endif
if (objective.Option.ToLowerInvariant() == "stoppumping")
{
#if SERVER
if (FlowPercentage > 0.0f) item.CreateServerEvent(this);
if (FlowPercentage > 0.0f)
{
item.CreateServerEvent(this);
}
#endif
IsActive = false;
FlowPercentage = 0.0f;
}
else
@@ -48,7 +48,19 @@ namespace Barotrauma.Items.Components
private Vector2 optimalFissionRate, allowedFissionRate;
private Vector2 optimalTurbineOutput, allowedTurbineOutput;
private bool shutDown;
private bool _powerOn;
public bool PowerOn
{
get { return _powerOn; }
set
{
_powerOn = value;
#if CLIENT
UpdateUIElementStates();
#endif
}
}
private Character lastAIUser;
@@ -152,12 +164,7 @@ namespace Barotrauma.Items.Components
{
autoTemp = value;
#if CLIENT
if (autoTempSlider != null)
{
autoTempSlider.BarScroll = value ?
Math.Min(0.45f, autoTempSlider.BarScroll) :
Math.Max(0.55f, autoTempSlider.BarScroll);
}
UpdateUIElementStates();
#endif
}
}
@@ -257,7 +264,7 @@ namespace Barotrauma.Items.Components
}
currPowerConsumption += autoAdjustAmount;
if (shutDown)
if (!PowerOn)
{
targetFissionRate = 0.0f;
targetTurbineOutput = 0.0f;
@@ -472,8 +479,8 @@ namespace Barotrauma.Items.Components
targetFissionRate = Math.Max(targetFissionRate - deltaTime * 10.0f, 0.0f);
targetTurbineOutput = Math.Max(targetTurbineOutput - deltaTime * 10.0f, 0.0f);
#if CLIENT
fissionRateScrollBar.BarScroll = 1.0f - FissionRate / 100.0f;
turbineOutputScrollBar.BarScroll = 1.0f - TurbineOutput / 100.0f;
FissionRateScrollBar.BarScroll = 1.0f - FissionRate / 100.0f;
TurbineOutputScrollBar.BarScroll = 1.0f - TurbineOutput / 100.0f;
UpdateGraph(deltaTime);
#endif
}
@@ -582,14 +589,14 @@ namespace Barotrauma.Items.Components
LastUser = lastAIUser = character;
bool prevAutoTemp = autoTemp;
bool prevShutDown = shutDown;
bool prevPowerOn = _powerOn;
float prevFissionRate = targetFissionRate;
float prevTurbineOutput = targetTurbineOutput;
switch (objective.Option.ToLowerInvariant())
{
case "powerup":
shutDown = false;
PowerOn = true;
if (objective.Override || !autoTemp)
{
//characters with insufficient skill levels simply set the autotemp on instead of trying to adjust the temperature manually
@@ -604,24 +611,20 @@ namespace Barotrauma.Items.Components
}
}
#if CLIENT
onOffSwitch.BarScroll = 0.0f;
fissionRateScrollBar.BarScroll = FissionRate / 100.0f;
turbineOutputScrollBar.BarScroll = TurbineOutput / 100.0f;
FissionRateScrollBar.BarScroll = FissionRate / 100.0f;
TurbineOutputScrollBar.BarScroll = TurbineOutput / 100.0f;
#endif
break;
case "shutdown":
#if CLIENT
onOffSwitch.BarScroll = 1.0f;
#endif
PowerOn = false;
AutoTemp = false;
shutDown = true;
targetFissionRate = 0.0f;
targetTurbineOutput = 0.0f;
break;
}
if (autoTemp != prevAutoTemp ||
prevShutDown != shutDown ||
prevPowerOn != _powerOn ||
Math.Abs(prevFissionRate - targetFissionRate) > 1.0f ||
Math.Abs(prevTurbineOutput - targetTurbineOutput) > 1.0f)
{
@@ -640,14 +643,11 @@ namespace Barotrauma.Items.Components
case "shutdown":
if (targetFissionRate > 0.0f || targetTurbineOutput > 0.0f)
{
shutDown = true;
PowerOn = false;
AutoTemp = false;
targetFissionRate = 0.0f;
targetTurbineOutput = 0.0f;
unsentChanges = true;
#if CLIENT
onOffSwitch.BarScroll = 1.0f;
#endif
}
break;
}
@@ -116,8 +116,7 @@ namespace Barotrauma.Items.Components
}
}
#if CLIENT
if (activeTickBox != null) activeTickBox.Selected = value == Mode.Active;
if (passiveTickBox != null) passiveTickBox.Selected = value == Mode.Passive;
UpdateGUIElements();
#endif
}
}
@@ -126,10 +125,9 @@ namespace Barotrauma.Items.Components
: base(item, element)
{
connectedTransducers = new List<ConnectedTransducer>();
CurrentMode = Mode.Passive;
IsActive = true;
InitProjSpecific(element);
CurrentMode = Mode.Passive;
}
partial void InitProjSpecific(XElement element);
@@ -344,14 +342,10 @@ namespace Barotrauma.Items.Components
}
}
if (!item.CanClientAccess(c)) return;
if (!item.CanClientAccess(c)) { return; }
CurrentMode = isActive ? Mode.Active : Mode.Passive;
//TODO: cleanup
#if CLIENT
activeTickBox.Selected = currentMode == Mode.Active;
#endif
if (isActive)
{
zoom = MathHelper.Lerp(MinZoom, MaxZoom, zoomT);
@@ -363,8 +357,7 @@ namespace Barotrauma.Items.Components
}
#if CLIENT
zoomSlider.BarScroll = zoomT;
directionalTickBox.Selected = useDirectionalPing;
directionalSlider.BarScroll = pingDirectionT;
directionalModeSwitch.Selected = useDirectionalPing;
#endif
}
#if SERVER
@@ -58,19 +58,24 @@ namespace Barotrauma.Items.Components
get { return autoPilot; }
set
{
if (value == autoPilot) return;
if (value == autoPilot) { return; }
autoPilot = value;
#if CLIENT
autopilotTickBox.Selected = autoPilot;
manualTickBox.Selected = !autoPilot;
maintainPosTickBox.Enabled = autoPilot;
levelEndTickBox.Enabled = autoPilot;
levelStartTickBox.Enabled = autoPilot;
UpdateGUIElements();
#endif
if (autoPilot)
{
if (pathFinder == null) pathFinder = new PathFinder(WayPoint.WayPointList, false);
if (pathFinder == null)
{
pathFinder = new PathFinder(WayPoint.WayPointList, false);
}
MaintainPos = true;
if (posToMaintain == null)
{
posToMaintain = controlledSub != null ?
controlledSub.WorldPosition :
item.Submarine == null ? item.WorldPosition : item.Submarine.WorldPosition;
}
}
else
{
@@ -272,7 +277,7 @@ namespace Barotrauma.Items.Components
ApplyStatusEffects(ActionType.OnActive, deltaTime, null);
if (autoPilot)
if (AutoPilot)
{
UpdateAutoPilot(deltaTime);
float userSkill = 0.0f;
@@ -317,7 +322,7 @@ namespace Barotrauma.Items.Components
private void UpdateAutoPilot(float deltaTime)
{
if (controlledSub == null) return;
if (controlledSub == null) { return; }
if (posToMaintain != null)
{
Vector2 steeringVel = GetSteeringVelocity((Vector2)posToMaintain, 10.0f);
@@ -577,6 +577,8 @@ namespace Barotrauma.Items.Components
railSprite?.Remove(); railSprite = null;
#if CLIENT
crosshairSprite?.Remove(); crosshairSprite = null;
crosshairPointerSprite?.Remove(); crosshairPointerSprite = null;
moveSoundChannel?.Dispose(); moveSoundChannel = null;
#endif
}