v1.0.20.1 (summer patch)

This commit is contained in:
itchyOwl
2023-06-15 16:46:54 +03:00
parent 6acac1d143
commit 83de72e3d2
209 changed files with 4497 additions and 2488 deletions
@@ -67,13 +67,15 @@ namespace Barotrauma
[AttributeUsage(AttributeTargets.Property)]
class ConditionallyEditable : Editable
{
public ConditionallyEditable(ConditionType conditionType)
public ConditionallyEditable(ConditionType conditionType, bool onlyInEditors = true)
{
this.conditionType = conditionType;
this.onlyInEditors = onlyInEditors;
}
private readonly ConditionType conditionType;
private readonly bool onlyInEditors;
public enum ConditionType
{
//These need to exist at compile time, so it is a little awkward
@@ -81,26 +83,37 @@ namespace Barotrauma
AllowLinkingWifiToChat,
IsSwappableItem,
AllowRotating,
Attachable
Attachable,
HasBody,
Pickable
}
public bool IsEditable(ISerializableEntity entity)
{
if (onlyInEditors && Screen.Selected is { IsEditor: false }) { return false; }
switch (conditionType)
{
case ConditionType.AllowLinkingWifiToChat:
return GameMain.NetworkMember?.ServerSettings?.AllowLinkingWifiToChat ?? true;
case ConditionType.IsSwappableItem:
{
return entity is Item item && item.Prefab.SwappableItem != null && Screen.Selected == GameMain.SubEditorScreen;
return entity is Item item && item.Prefab.SwappableItem != null;
}
case ConditionType.AllowRotating:
{
return entity is Item item && item.body == null && item.Prefab.AllowRotatingInEditor && Screen.Selected == GameMain.SubEditorScreen;
return entity is Item item && item.body == null && item.Prefab.AllowRotatingInEditor;
}
case ConditionType.Attachable:
{
return entity is Holdable holdable && holdable.Attachable && Screen.Selected == GameMain.SubEditorScreen;
return entity is Holdable holdable && holdable.Attachable;
}
case ConditionType.HasBody:
{
return entity is Structure { HasBody: true } || entity is Item { body: not null };
}
case ConditionType.Pickable:
{
return entity is Item item && item.GetComponent<Pickable>() != null;
}
}
return false;