Fixes edge firelock serialization
This commit is contained in:
@@ -26,7 +26,9 @@ namespace Content.Server.GameObjects.Components.Atmos
|
|||||||
public override string Name => "Airtight";
|
public override string Name => "Airtight";
|
||||||
|
|
||||||
[ViewVariables]
|
[ViewVariables]
|
||||||
private int _airBlockedDirection;
|
private int _initialAirBlockedDirection;
|
||||||
|
[ViewVariables]
|
||||||
|
private int _currentAirBlockedDirection;
|
||||||
private bool _airBlocked = true;
|
private bool _airBlocked = true;
|
||||||
private bool _fixVacuum = false;
|
private bool _fixVacuum = false;
|
||||||
|
|
||||||
@@ -50,10 +52,11 @@ namespace Content.Server.GameObjects.Components.Atmos
|
|||||||
|
|
||||||
public AtmosDirection AirBlockedDirection
|
public AtmosDirection AirBlockedDirection
|
||||||
{
|
{
|
||||||
get => (AtmosDirection)_airBlockedDirection;
|
get => (AtmosDirection)_currentAirBlockedDirection;
|
||||||
set
|
set
|
||||||
{
|
{
|
||||||
_airBlockedDirection = (int) value;
|
_currentAirBlockedDirection = (int) value;
|
||||||
|
_initialAirBlockedDirection = (int)Rotate(AirBlockedDirection, -Owner.Transform.LocalRotation);
|
||||||
|
|
||||||
UpdatePosition();
|
UpdatePosition();
|
||||||
}
|
}
|
||||||
@@ -68,7 +71,7 @@ namespace Content.Server.GameObjects.Components.Atmos
|
|||||||
|
|
||||||
serializer.DataField(ref _airBlocked, "airBlocked", true);
|
serializer.DataField(ref _airBlocked, "airBlocked", true);
|
||||||
serializer.DataField(ref _fixVacuum, "fixVacuum", true);
|
serializer.DataField(ref _fixVacuum, "fixVacuum", true);
|
||||||
serializer.DataField(ref _airBlockedDirection, "airBlockedDirection", (int)AtmosDirection.All, WithFormat.Flags<AtmosDirectionFlags>());
|
serializer.DataField(ref _initialAirBlockedDirection, "airBlockedDirection", (int)AtmosDirection.All, WithFormat.Flags<AtmosDirectionFlags>());
|
||||||
serializer.DataField(ref _rotateAirBlocked, "rotateAirBlocked", true);
|
serializer.DataField(ref _rotateAirBlocked, "rotateAirBlocked", true);
|
||||||
serializer.DataField(ref _fixAirBlockedDirectionInitialize, "fixAirBlockedDirectionInitialize", true);
|
serializer.DataField(ref _fixAirBlockedDirectionInitialize, "fixAirBlockedDirectionInitialize", true);
|
||||||
}
|
}
|
||||||
@@ -88,31 +91,37 @@ namespace Content.Server.GameObjects.Components.Atmos
|
|||||||
Owner.EntityManager.EventBus.SubscribeEvent<RotateEvent>(EventSource.Local, this, RotateEvent);
|
Owner.EntityManager.EventBus.SubscribeEvent<RotateEvent>(EventSource.Local, this, RotateEvent);
|
||||||
|
|
||||||
if(_fixAirBlockedDirectionInitialize)
|
if(_fixAirBlockedDirectionInitialize)
|
||||||
RotateEvent(new RotateEvent(Owner, Angle.South, Owner.Transform.LocalRotation));
|
RotateEvent(new RotateEvent(Owner, Angle.Zero, Owner.Transform.LocalRotation));
|
||||||
|
|
||||||
UpdatePosition();
|
UpdatePosition();
|
||||||
}
|
}
|
||||||
|
|
||||||
private void RotateEvent(RotateEvent ev)
|
private void RotateEvent(RotateEvent ev)
|
||||||
{
|
{
|
||||||
if (!_rotateAirBlocked || ev.Sender != Owner || ev.NewRotation == ev.OldRotation || AirBlockedDirection == AtmosDirection.Invalid)
|
if (!_rotateAirBlocked || ev.Sender != Owner || _initialAirBlockedDirection == (int)AtmosDirection.Invalid)
|
||||||
return;
|
return;
|
||||||
|
|
||||||
var diff = ev.NewRotation - ev.OldRotation;
|
_currentAirBlockedDirection = (int) Rotate((AtmosDirection)_initialAirBlockedDirection, ev.NewRotation);
|
||||||
|
}
|
||||||
|
|
||||||
|
private AtmosDirection Rotate(AtmosDirection myDirection, Angle myAngle)
|
||||||
|
{
|
||||||
var newAirBlockedDirs = AtmosDirection.Invalid;
|
var newAirBlockedDirs = AtmosDirection.Invalid;
|
||||||
|
|
||||||
|
if (myAngle == Angle.Zero)
|
||||||
|
return myDirection;
|
||||||
|
|
||||||
// TODO ATMOS MULTIZ When we make multiZ atmos, special case this.
|
// TODO ATMOS MULTIZ When we make multiZ atmos, special case this.
|
||||||
for (var i = 0; i < Atmospherics.Directions; i++)
|
for (var i = 0; i < Atmospherics.Directions; i++)
|
||||||
{
|
{
|
||||||
var direction = (AtmosDirection) (1 << i);
|
var direction = (AtmosDirection) (1 << i);
|
||||||
if (!AirBlockedDirection.HasFlag(direction)) continue;
|
if (!myDirection.HasFlag(direction)) continue;
|
||||||
var angle = direction.ToAngle();
|
var angle = direction.ToAngle();
|
||||||
angle += diff;
|
angle += myAngle;
|
||||||
newAirBlockedDirs |= angle.ToAtmosDirectionCardinal();
|
newAirBlockedDirs |= angle.ToAtmosDirectionCardinal();
|
||||||
}
|
}
|
||||||
|
|
||||||
AirBlockedDirection = newAirBlockedDirs;
|
return newAirBlockedDirs;
|
||||||
}
|
}
|
||||||
|
|
||||||
public void MapInit()
|
public void MapInit()
|
||||||
|
|||||||
@@ -11,18 +11,18 @@ namespace Content.Shared.Atmos
|
|||||||
[FlagsFor(typeof(AtmosDirectionFlags))]
|
[FlagsFor(typeof(AtmosDirectionFlags))]
|
||||||
public enum AtmosDirection
|
public enum AtmosDirection
|
||||||
{
|
{
|
||||||
Invalid = 0,
|
Invalid = 0, // 0
|
||||||
North = 1 << 0,
|
North = 1 << 0, // 1
|
||||||
South = 1 << 1,
|
South = 1 << 1, // 2
|
||||||
East = 1 << 2,
|
East = 1 << 2, // 4
|
||||||
West = 1 << 3,
|
West = 1 << 3, // 8
|
||||||
|
|
||||||
NorthEast = North | East,
|
NorthEast = North | East, // 5
|
||||||
NorthWest = North | West,
|
SouthEast = South | East, // 6
|
||||||
SouthEast = South | East,
|
NorthWest = North | West, // 9
|
||||||
SouthWest = South | West,
|
SouthWest = South | West, // 10
|
||||||
|
|
||||||
All = North | South | East | West,
|
All = North | South | East | West, // 15
|
||||||
}
|
}
|
||||||
|
|
||||||
public static class AtmosDirectionHelpers
|
public static class AtmosDirectionHelpers
|
||||||
|
|||||||
@@ -76,7 +76,6 @@
|
|||||||
id: FirelockEdge
|
id: FirelockEdge
|
||||||
parent: Firelock
|
parent: Firelock
|
||||||
name: firelock
|
name: firelock
|
||||||
prefix: south
|
|
||||||
components:
|
components:
|
||||||
- type: Firelock
|
- type: Firelock
|
||||||
occludes: false
|
occludes: false
|
||||||
@@ -85,11 +84,10 @@
|
|||||||
enabled: false
|
enabled: false
|
||||||
- type: Sprite
|
- type: Sprite
|
||||||
sprite: Constructible/Structures/Doors/edge_door_hazard.rsi
|
sprite: Constructible/Structures/Doors/edge_door_hazard.rsi
|
||||||
|
|
||||||
- type: Airtight
|
- type: Airtight
|
||||||
fixVacuum: true
|
fixVacuum: true
|
||||||
airBlockedDirection:
|
airBlockedDirection:
|
||||||
- South
|
- East
|
||||||
- type: Collidable
|
- type: Collidable
|
||||||
shapes:
|
shapes:
|
||||||
- !type:PhysShapeAabb
|
- !type:PhysShapeAabb
|
||||||
|
|||||||
Reference in New Issue
Block a user