Anchorable component now raises cancellable event on (un)anchor. (#3828)
This commit is contained in:
committed by
GitHub
parent
c17426dfa7
commit
f257846de7
@@ -83,6 +83,13 @@ namespace Content.Server.GameObjects.Components
|
|||||||
if (_physicsComponent == null)
|
if (_physicsComponent == null)
|
||||||
return false;
|
return false;
|
||||||
|
|
||||||
|
var attempt = new AnchorAttemptMessage();
|
||||||
|
|
||||||
|
Owner.EntityManager.EventBus.RaiseLocalEvent(Owner.Uid, attempt, false);
|
||||||
|
|
||||||
|
if (attempt.Cancelled)
|
||||||
|
return false;
|
||||||
|
|
||||||
_physicsComponent.BodyType = BodyType.Static;
|
_physicsComponent.BodyType = BodyType.Static;
|
||||||
|
|
||||||
// Snap rotation to cardinal (multiple of 90)
|
// Snap rotation to cardinal (multiple of 90)
|
||||||
@@ -100,6 +107,8 @@ namespace Content.Server.GameObjects.Components
|
|||||||
if (Snap)
|
if (Snap)
|
||||||
Owner.SnapToGrid(SnapGridOffset.Center, Owner.EntityManager);
|
Owner.SnapToGrid(SnapGridOffset.Center, Owner.EntityManager);
|
||||||
|
|
||||||
|
Owner.EntityManager.EventBus.RaiseLocalEvent(Owner.Uid, new AnchoredMessage(), false);
|
||||||
|
|
||||||
return true;
|
return true;
|
||||||
}
|
}
|
||||||
|
|
||||||
@@ -120,8 +129,17 @@ namespace Content.Server.GameObjects.Components
|
|||||||
if (_physicsComponent == null)
|
if (_physicsComponent == null)
|
||||||
return false;
|
return false;
|
||||||
|
|
||||||
|
var attempt = new UnanchorAttemptMessage();
|
||||||
|
|
||||||
|
Owner.EntityManager.EventBus.RaiseLocalEvent(Owner.Uid, attempt, false);
|
||||||
|
|
||||||
|
if (attempt.Cancelled)
|
||||||
|
return false;
|
||||||
|
|
||||||
_physicsComponent.BodyType = BodyType.Dynamic;
|
_physicsComponent.BodyType = BodyType.Dynamic;
|
||||||
|
|
||||||
|
Owner.EntityManager.EventBus.RaiseLocalEvent(Owner.Uid, new UnanchoredMessage(), false);
|
||||||
|
|
||||||
return true;
|
return true;
|
||||||
}
|
}
|
||||||
|
|
||||||
@@ -147,4 +165,10 @@ namespace Content.Server.GameObjects.Components
|
|||||||
return await TryToggleAnchor(eventArgs.User, eventArgs.Using);
|
return await TryToggleAnchor(eventArgs.User, eventArgs.Using);
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
public class AnchorAttemptMessage : CancellableEntityEventArgs { }
|
||||||
|
public class UnanchorAttemptMessage : CancellableEntityEventArgs { }
|
||||||
|
|
||||||
|
public class AnchoredMessage : EntityEventArgs {}
|
||||||
|
public class UnanchoredMessage : EntityEventArgs {}
|
||||||
}
|
}
|
||||||
|
|||||||
@@ -165,6 +165,9 @@
|
|||||||
<s:Boolean x:Key="/Default/UserDictionary/Words/=tickrate/@EntryIndexedValue">True</s:Boolean>
|
<s:Boolean x:Key="/Default/UserDictionary/Words/=tickrate/@EntryIndexedValue">True</s:Boolean>
|
||||||
<s:Boolean x:Key="/Default/UserDictionary/Words/=Trasen/@EntryIndexedValue">True</s:Boolean>
|
<s:Boolean x:Key="/Default/UserDictionary/Words/=Trasen/@EntryIndexedValue">True</s:Boolean>
|
||||||
<s:Boolean x:Key="/Default/UserDictionary/Words/=unanchor/@EntryIndexedValue">True</s:Boolean>
|
<s:Boolean x:Key="/Default/UserDictionary/Words/=unanchor/@EntryIndexedValue">True</s:Boolean>
|
||||||
|
<s:Boolean x:Key="/Default/UserDictionary/Words/=Unanchored/@EntryIndexedValue">True</s:Boolean>
|
||||||
|
<s:Boolean x:Key="/Default/UserDictionary/Words/=Uncancel/@EntryIndexedValue">True</s:Boolean>
|
||||||
|
<s:Boolean x:Key="/Default/UserDictionary/Words/=Uncancels/@EntryIndexedValue">True</s:Boolean>
|
||||||
<s:Boolean x:Key="/Default/UserDictionary/Words/=Uncuff/@EntryIndexedValue">True</s:Boolean>
|
<s:Boolean x:Key="/Default/UserDictionary/Words/=Uncuff/@EntryIndexedValue">True</s:Boolean>
|
||||||
<s:Boolean x:Key="/Default/UserDictionary/Words/=underplating/@EntryIndexedValue">True</s:Boolean>
|
<s:Boolean x:Key="/Default/UserDictionary/Words/=underplating/@EntryIndexedValue">True</s:Boolean>
|
||||||
<s:Boolean x:Key="/Default/UserDictionary/Words/=unequip/@EntryIndexedValue">True</s:Boolean>
|
<s:Boolean x:Key="/Default/UserDictionary/Words/=unequip/@EntryIndexedValue">True</s:Boolean>
|
||||||
|
|||||||
Reference in New Issue
Block a user