Unstable 0.16.0.0

This commit is contained in:
Markus Isberg
2022-01-14 01:28:24 +09:00
parent d9baeaa2e1
commit 7d6421a548
237 changed files with 6430 additions and 2205 deletions
@@ -370,18 +370,29 @@ namespace Barotrauma.Items.Components
public Item GetFocusTarget()
{
item.SendSignal(new Signal(MathHelper.ToDegrees(targetRotation).ToString("G", CultureInfo.InvariantCulture), sender: user), "position_out");
for (int i = item.LastSentSignalRecipients.Count - 1; i >= 0; i--)
Item focusTarget = null;
for (int c = 0; c < 2; c++)
{
if (item.LastSentSignalRecipients[i].Item.Condition <= 0.0f || item.LastSentSignalRecipients[i].IsPower) { continue; }
if (item.LastSentSignalRecipients[i].Item.Prefab.FocusOnSelected)
//try finding the item to focus on using trigger_out, and if that fails, using position_out
string connectionName = c == 0 ? "trigger_out" : "position_out";
string signal = c == 0 ? "0" : MathHelper.ToDegrees(targetRotation).ToString("G", CultureInfo.InvariantCulture);
if (!item.SendSignal(new Signal(signal, sender: user), connectionName) || focusTarget != null)
{
return item.LastSentSignalRecipients[i].Item;
continue;
}
for (int i = item.LastSentSignalRecipients.Count - 1; i >= 0; i--)
{
if (item.LastSentSignalRecipients[i].Item.Condition <= 0.0f || item.LastSentSignalRecipients[i].IsPower) { continue; }
if (item.LastSentSignalRecipients[i].Item.Prefab.FocusOnSelected)
{
focusTarget = item.LastSentSignalRecipients[i].Item;
break;
}
}
}
return null;
return focusTarget;
}
public override bool Pick(Character picker)
@@ -170,7 +170,7 @@ namespace Barotrauma.Items.Components
character.CheckTalents(AbilityEffectType.OnItemDeconstructedByAlly, abilityTargetItem);
}
var itemCreationMultiplier = new AbilityValueItem(amountMultiplier, targetItem.Prefab);
var itemCreationMultiplier = new AbilityItemCreationMultiplier(targetItem.Prefab, amountMultiplier);
user.CheckTalents(AbilityEffectType.OnItemDeconstructedMaterial, itemCreationMultiplier);
amountMultiplier = (int)itemCreationMultiplier.Value;
}
@@ -261,8 +261,8 @@ namespace Barotrauma.Items.Components
if (user != null && !user.Removed)
{
// used to spawn items directly into the deconstructor
var itemContainer = new AbilityItemPrefabItem(item, targetItem.Prefab);
user.CheckTalents(AbilityEffectType.OnItemDeconstructedInventory, itemContainer);
var itemDeconstructedInventory = new AbilityItemDeconstructedInventory(targetItem.Prefab, item);
user.CheckTalents(AbilityEffectType.OnItemDeconstructedInventory, itemDeconstructedInventory);
}
int amount = (int)amountMultiplier;
@@ -333,7 +333,7 @@ namespace Barotrauma.Items.Components
for (int i = 0; i < outputContainer.Capacity; i++)
{
var containedItem = outputContainer.Inventory.GetItemAt(i);
if (containedItem?.OwnInventory != null && containedItem.OwnInventory.TryPutItem(item, user: null))
if (containedItem?.OwnInventory != null && containedItem.GetComponent<GeneticMaterial>() == null && containedItem.OwnInventory.TryPutItem(item, user: null))
{
return;
}
@@ -454,4 +454,26 @@ namespace Barotrauma.Items.Components
public Character Character { get; set; }
}
class AbilityItemCreationMultiplier : AbilityObject, IAbilityValue, IAbilityItemPrefab
{
public AbilityItemCreationMultiplier(ItemPrefab itemPrefab, float itemAmountMultiplier)
{
ItemPrefab = itemPrefab;
Value = itemAmountMultiplier;
}
public ItemPrefab ItemPrefab { get; set; }
public float Value { get; set; }
}
class AbilityItemDeconstructedInventory : AbilityObject, IAbilityItem, IAbilityItemPrefab
{
public AbilityItemDeconstructedInventory(ItemPrefab itemPrefab, Item item)
{
ItemPrefab = itemPrefab;
Item = item;
}
public ItemPrefab ItemPrefab { get; set; }
public Item Item { get; set; }
}
}
@@ -179,8 +179,6 @@ namespace Barotrauma.Items.Components
if (selectedItem == null) { return; }
if (!outputContainer.Inventory.CanBePut(selectedItem.TargetItem, selectedItem.OutCondition * selectedItem.TargetItem.Health)) { return; }
RefreshAvailableIngredients();
#if CLIENT
itemList.Enabled = false;
activateButton.Text = TextManager.Get("FabricatorCancel");
@@ -189,7 +187,13 @@ namespace Barotrauma.Items.Components
IsActive = true;
this.user = user;
fabricatedItem = selectedItem;
MoveIngredientsToInputContainer(selectedItem);
RefreshAvailableIngredients();
bool isClient = GameMain.NetworkMember != null && GameMain.NetworkMember.IsClient;
if (!isClient)
{
MoveIngredientsToInputContainer(selectedItem);
}
requiredTime = GetRequiredTime(fabricatedItem, user);
timeUntilReady = requiredTime;
@@ -230,21 +234,19 @@ namespace Barotrauma.Items.Components
}
if (fabricatedItem == null) { return; }
fabricatedItem = null;
#if CLIENT
#if SERVER
if (user != null)
{
GameServer.Log(GameServer.CharacterLogName(user) + " cancelled the fabrication of " + fabricatedItem.DisplayName + " in " + item.Name, ServerLog.MessageType.ItemInteraction);
}
#elif CLIENT
itemList.Enabled = true;
if (activateButton != null)
{
activateButton.Text = TextManager.Get("FabricatorCreate");
}
#endif
#if SERVER
if (user != null)
{
GameServer.Log(GameServer.CharacterLogName(user) + " cancelled the fabrication of " + fabricatedItem.DisplayName + " in " + item.Name, ServerLog.MessageType.ItemInteraction);
}
#endif
fabricatedItem = null;
}
public override void Update(float deltaTime, Camera cam)
@@ -256,15 +258,20 @@ namespace Barotrauma.Items.Components
}
refreshIngredientsTimer -= deltaTime;
if (fabricatedItem == null || !CanBeFabricated(fabricatedItem, availableIngredients, user))
bool isClient = GameMain.NetworkMember?.IsClient ?? false;
if (!isClient)
{
CancelFabricating();
return;
if (fabricatedItem == null || !CanBeFabricated(fabricatedItem, availableIngredients, user))
{
CancelFabricating();
return;
}
}
progressState = fabricatedItem == null ? 0.0f : (requiredTime - timeUntilReady) / requiredTime;
if (GameMain.NetworkMember?.IsClient ?? false)
if (isClient)
{
hasPower = State != FabricatorState.Paused;
if (!hasPower)
@@ -365,28 +372,29 @@ namespace Barotrauma.Items.Components
availableItems.Remove(availableItem);
Entity.Spawner.AddToRemoveQueue(availableItem);
inputContainer.Inventory.RemoveItem(availableItem);
break;
}
}
});
int amountFittingContainer = outputContainer.Inventory.HowManyCanBePut(fabricatedItem.TargetItem, fabricatedItem.OutCondition * fabricatedItem.TargetItem.Health);
var fabricationValueItem = new AbilityValueItem(fabricatedItem.Amount, fabricatedItem.TargetItem);
var fabricationitemAmount = new AbilityFabricationItemAmount(fabricatedItem.TargetItem, fabricatedItem.Amount);
int quality = 0;
if (user?.Info != null)
{
foreach (Character character in Character.GetFriendlyCrew(user))
{
character.CheckTalents(AbilityEffectType.OnAllyItemFabricatedAmount, fabricationValueItem);
character.CheckTalents(AbilityEffectType.OnAllyItemFabricatedAmount, fabricationitemAmount);
}
user.CheckTalents(AbilityEffectType.OnItemFabricatedAmount, fabricationValueItem);
user.CheckTalents(AbilityEffectType.OnItemFabricatedAmount, fabricationitemAmount);
quality = GetFabricatedItemQuality(fabricatedItem, user);
}
var tempUser = user;
for (int i = 0; i < (int)fabricationValueItem.Value; i++)
for (int i = 0; i < (int)fabricationitemAmount.Value; i++)
{
float outCondition = fabricatedItem.OutCondition;
if (i < amountFittingContainer)
@@ -433,7 +441,7 @@ namespace Barotrauma.Items.Components
{
float userSkill = user.GetSkillLevel(skill.Identifier);
float addedSkill = skill.Level * SkillSettings.Current.SkillIncreasePerFabricatorRequiredSkill / Math.Max(userSkill, 1.0f);
var addedSkillValue = new AbilityValueString(addedSkill, skill.Identifier);
var addedSkillValue = new AbilityFabricatorSkillGain(skill.Identifier, addedSkill);
user.CheckTalents(AbilityEffectType.OnItemFabricationSkillGain, addedSkillValue);
user.Info.IncreaseSkillLevel(
@@ -542,6 +550,11 @@ namespace Barotrauma.Items.Components
private void RefreshAvailableIngredients()
{
Character user = this.user;
#if CLIENT
user ??= Character.Controlled;
#endif
List<Item> itemList = new List<Item>();
itemList.AddRange(inputContainer.Inventory.AllItems);
foreach (MapEntity linkedTo in item.linkedTo)
@@ -550,6 +563,10 @@ namespace Barotrauma.Items.Components
{
var itemContainer = linkedItem.GetComponent<ItemContainer>();
if (itemContainer == null) { continue; }
if (user != null)
{
if (!itemContainer.HasRequiredItems(user, addMessage: false)) { continue; }
}
var deconstructor = linkedItem.GetComponent<Deconstructor>();
if (deconstructor != null)
@@ -568,17 +585,10 @@ namespace Barotrauma.Items.Components
itemList.AddRange(container.Inventory.AllItems);
}
}
#if CLIENT
if (Character.Controlled?.Inventory != null)
{
itemList.AddRange(Character.Controlled.Inventory.AllItems);
}
#else
if (user?.Inventory != null)
{
itemList.AddRange(user.Inventory.AllItems);
}
#endif
availableIngredients.Clear();
foreach (Item item in itemList)
{
@@ -600,8 +610,6 @@ namespace Barotrauma.Items.Components
//required ingredients that are already present in the input container
List<Item> usedItems = new List<Item>();
bool isClient = GameMain.NetworkMember != null && GameMain.NetworkMember.IsClient;
targetItem.RequiredItems.ForEach(requiredItem => {
for (int i = 0; i < requiredItem.Amount; i++)
{
@@ -630,10 +638,11 @@ namespace Barotrauma.Items.Components
if (!inputContainer.Inventory.CanBePut(availablePrefab))
{
var unneededItem = inputContainer.Inventory.AllItems.FirstOrDefault(it => !usedItems.Contains(it));
unneededItem?.Drop(null, createNetworkEvent: !isClient);
unneededItem?.Drop(null);
}
inputContainer.Inventory.TryPutItem(availablePrefab, user: null, createNetworkEvent: !isClient);
inputContainer.Inventory.TryPutItem(availablePrefab, user: null);
}
break;
}
}
});
@@ -684,5 +693,26 @@ namespace Barotrauma.Items.Components
}
savedFabricatedItem = null;
}
class AbilityFabricatorSkillGain : AbilityObject, IAbilityValue, IAbilitySkillIdentifier
{
public AbilityFabricatorSkillGain(string skillIdentifier, float skillAmount)
{
SkillIdentifier = skillIdentifier;
Value = skillAmount;
}
public float Value { get; set; }
public string SkillIdentifier { get; set; }
}
class AbilityFabricationItemAmount : AbilityObject, IAbilityValue, IAbilityItemPrefab
{
public AbilityFabricationItemAmount(ItemPrefab itemPrefab, float itemAmount)
{
ItemPrefab = itemPrefab;
Value = itemAmount;
}
public float Value { get; set; }
public ItemPrefab ItemPrefab { get; set; }
}
}
}
@@ -29,6 +29,15 @@ namespace Barotrauma.Items.Components
}
}
public float CurrentBrokenVolume
{
get
{
if (item.ConditionPercentage > 10.0f || !IsActive) { return 0.0f; }
return (1.0f - item.ConditionPercentage / 10.0f) * 100.0f;
}
}
private float pumpSpeedLockTimer, isActiveLockTimer;
[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).")]
@@ -72,6 +81,8 @@ namespace Barotrauma.Items.Components
private const float TinkeringSpeedIncrease = 4.0f;
public override bool UpdateWhenInactive => true;
public Pump(Item item, XElement element)
: base(item, element)
{
@@ -82,11 +93,15 @@ namespace Barotrauma.Items.Components
public override void Update(float deltaTime, Camera cam)
{
pumpSpeedLockTimer -= deltaTime;
isActiveLockTimer -= deltaTime;
if (!IsActive) { return; }
currFlow = 0.0f;
if (TargetLevel != null)
{
pumpSpeedLockTimer -= deltaTime;
float hullPercentage = 0.0f;
if (item.CurrentHull != null) { hullPercentage = (item.CurrentHull.WaterVolume / item.CurrentHull.Volume) * 100.0f; }
FlowPercentage = ((float)TargetLevel - hullPercentage) * 10.0f;
@@ -76,7 +76,7 @@ namespace Barotrauma.Items.Components
{
if (lastUser == value) { return; }
lastUser = value;
degreeOfSuccess = lastUser == null ? 0.0f : DegreeOfSuccess(lastUser);
degreeOfSuccess = lastUser == null ? 0.0f : Math.Min(DegreeOfSuccess(lastUser), 1.0f);
LastUserWasPlayer = lastUser.IsPlayer;
}
}
@@ -601,7 +601,7 @@ namespace Barotrauma.Items.Components
if (!shutDown)
{
float degreeOfSuccess = DegreeOfSuccess(character);
float degreeOfSuccess = Math.Min(DegreeOfSuccess(character), 1.0f);
float refuelLimit = 0.3f;
//characters with insufficient skill levels don't refuel the reactor
if (degreeOfSuccess > refuelLimit)
@@ -106,6 +106,13 @@ namespace Barotrauma.Items.Components
set;
}
[Editable, Serialize(false, false, description: "Should the sonar view be centered on the transducers or the submarine's center of mass. Only has an effect if UseTransducers is enabled.")]
public bool CenterOnTransducers
{
get;
set;
}
[Editable, Serialize(false, false, description: "Does the sonar have mineral scanning mode. " +
"Only available in-game when the Item has no Steering component.")]
public bool HasMineralScanner { get; set; }
@@ -318,7 +325,7 @@ namespace Barotrauma.Items.Components
Vector2 transducerPosSum = Vector2.Zero;
foreach (ConnectedTransducer transducer in connectedTransducers)
{
if (transducer.Transducer.Item.Submarine != null)
if (transducer.Transducer.Item.Submarine != null && CenterOnTransducers)
{
return transducer.Transducer.Item.Submarine.WorldPosition;
}
@@ -311,7 +311,7 @@ namespace Barotrauma.Items.Components
}
// override autopilot pathing while the AI rams, and go full speed ahead
if (AIRamTimer > 0f)
if (AIRamTimer > 0f && controlledSub != null)
{
AIRamTimer -= deltaTime;
TargetVelocity = GetSteeringVelocity(AITacticalTarget, 0f);