Compare commits
1 Commits
master
...
ed-06-08-2
| Author | SHA1 | Date | |
|---|---|---|---|
|
|
a02cebd1de |
@@ -1,4 +1,5 @@
|
|||||||
using Content.Shared.Whitelist;
|
using Content.Shared._CP14.ItemPlacerParenting;
|
||||||
|
using Content.Shared.Whitelist;
|
||||||
using Robust.Shared.GameStates;
|
using Robust.Shared.GameStates;
|
||||||
|
|
||||||
namespace Content.Shared.Placeable;
|
namespace Content.Shared.Placeable;
|
||||||
@@ -7,7 +8,7 @@ namespace Content.Shared.Placeable;
|
|||||||
/// Detects items placed on it that match a whitelist.
|
/// Detects items placed on it that match a whitelist.
|
||||||
/// </summary>
|
/// </summary>
|
||||||
[RegisterComponent, NetworkedComponent, AutoGenerateComponentState]
|
[RegisterComponent, NetworkedComponent, AutoGenerateComponentState]
|
||||||
[Access(typeof(ItemPlacerSystem))]
|
[Access(typeof(ItemPlacerSystem), typeof(CP14ItemPlacerAutoParentSystem))]
|
||||||
public sealed partial class ItemPlacerComponent : Component
|
public sealed partial class ItemPlacerComponent : Component
|
||||||
{
|
{
|
||||||
/// <summary>
|
/// <summary>
|
||||||
|
|||||||
@@ -0,0 +1,9 @@
|
|||||||
|
namespace Content.Shared._CP14.ItemPlacerParenting;
|
||||||
|
|
||||||
|
/// <summary>
|
||||||
|
///
|
||||||
|
/// </summary>
|
||||||
|
[RegisterComponent, Access(typeof(CP14ItemPlacerAutoParentSystem))]
|
||||||
|
public sealed partial class CP14ItemPlacerAutoParentComponent : Component
|
||||||
|
{
|
||||||
|
}
|
||||||
@@ -0,0 +1,65 @@
|
|||||||
|
using Content.Shared.Movement.Pulling.Events;
|
||||||
|
using Content.Shared.Placeable;
|
||||||
|
using Content.Shared.Tag;
|
||||||
|
using Content.Shared.Throwing;
|
||||||
|
using Robust.Shared.Physics.Events;
|
||||||
|
|
||||||
|
namespace Content.Shared._CP14.ItemPlacerParenting;
|
||||||
|
|
||||||
|
/// <summary>
|
||||||
|
///
|
||||||
|
/// </summary>
|
||||||
|
public sealed class CP14ItemPlacerAutoParentSystem : EntitySystem
|
||||||
|
{
|
||||||
|
[Dependency] private readonly SharedTransformSystem _transform = default!;
|
||||||
|
public override void Initialize()
|
||||||
|
{
|
||||||
|
base.Initialize();
|
||||||
|
|
||||||
|
SubscribeLocalEvent<CP14ItemPlacerAutoParentComponent, ItemPlacedEvent>(OnItemPlaced);
|
||||||
|
SubscribeLocalEvent<CP14ItemPlacerAutoParentComponent, ThrownEvent>(OnThrown);
|
||||||
|
SubscribeLocalEvent<CP14ItemPlacerAutoParentComponent, EndCollideEvent>(OnEndCollide);
|
||||||
|
}
|
||||||
|
|
||||||
|
private void OnEndCollide(Entity<CP14ItemPlacerAutoParentComponent> ent, ref EndCollideEvent args)
|
||||||
|
{
|
||||||
|
if (!TryComp<ItemPlacerComponent>(ent, out var itemPlacer))
|
||||||
|
return;
|
||||||
|
|
||||||
|
Detach(args.OtherEntity, ent);
|
||||||
|
}
|
||||||
|
|
||||||
|
private void Detach(EntityUid item, EntityUid parent)
|
||||||
|
{
|
||||||
|
if (Transform(item).ParentUid == parent)
|
||||||
|
_transform.SetParent(item, Transform(parent).ParentUid);
|
||||||
|
}
|
||||||
|
|
||||||
|
private void OnThrown(Entity<CP14ItemPlacerAutoParentComponent> ent, ref ThrownEvent args)
|
||||||
|
{
|
||||||
|
if (!TryComp<ItemPlacerComponent>(ent, out var itemPlacer))
|
||||||
|
return;
|
||||||
|
|
||||||
|
foreach (var placed in itemPlacer.PlacedEntities)
|
||||||
|
{
|
||||||
|
Detach(placed, ent);
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
private void OnItemPlaced(Entity<CP14ItemPlacerAutoParentComponent> ent, ref ItemPlacedEvent args)
|
||||||
|
{
|
||||||
|
if (HasComp<CP14ItemPlacerParentedComponent>(ent))
|
||||||
|
return;
|
||||||
|
|
||||||
|
if (!TryComp<ItemPlacerComponent>(ent, out var itemPlacer))
|
||||||
|
return;
|
||||||
|
|
||||||
|
_transform.SetParent(args.OtherEntity, ent);
|
||||||
|
AddComp<CP14ItemPlacerParentedComponent>(ent);
|
||||||
|
}
|
||||||
|
|
||||||
|
private void Detach(EntityUid target)
|
||||||
|
{
|
||||||
|
|
||||||
|
}
|
||||||
|
}
|
||||||
@@ -0,0 +1,9 @@
|
|||||||
|
namespace Content.Shared._CP14.ItemPlacerParenting;
|
||||||
|
|
||||||
|
/// <summary>
|
||||||
|
///
|
||||||
|
/// </summary>
|
||||||
|
[RegisterComponent, Access(typeof(CP14ItemPlacerAutoParentSystem))]
|
||||||
|
public sealed partial class CP14ItemPlacerParentedComponent : Component
|
||||||
|
{
|
||||||
|
}
|
||||||
@@ -10,6 +10,7 @@
|
|||||||
tags:
|
tags:
|
||||||
- Egg
|
- Egg
|
||||||
- Meat
|
- Meat
|
||||||
|
- CP14Platter
|
||||||
- type: Food
|
- type: Food
|
||||||
trash: Eggshells
|
trash: Eggshells
|
||||||
- type: Sprite
|
- type: Sprite
|
||||||
|
|||||||
@@ -0,0 +1,51 @@
|
|||||||
|
- type: entity
|
||||||
|
id: CP14BasePlate
|
||||||
|
abstract: true
|
||||||
|
parent: BaseItem
|
||||||
|
description: A container for storing and utilizing an essential element of life such as food.
|
||||||
|
components:
|
||||||
|
- type: Fixtures
|
||||||
|
fixtures:
|
||||||
|
fix1:
|
||||||
|
shape:
|
||||||
|
!type:PhysShapeAabb
|
||||||
|
bounds: "-0.25,-0.25,0.25,0.25"
|
||||||
|
mask:
|
||||||
|
- ItemMask
|
||||||
|
fix2:
|
||||||
|
hard: false
|
||||||
|
shape:
|
||||||
|
!type:PhysShapeAabb
|
||||||
|
bounds: "-0.25,-0.25,0.25,0.25"
|
||||||
|
layer:
|
||||||
|
- ItemMask
|
||||||
|
- type: DamageOtherOnHit
|
||||||
|
damage:
|
||||||
|
types:
|
||||||
|
Blunt: 5
|
||||||
|
- type: CP14ItemPlacerAutoParent
|
||||||
|
- type: ItemPlacer
|
||||||
|
maxEntities: 4
|
||||||
|
whitelist:
|
||||||
|
tags:
|
||||||
|
- CP14Platter
|
||||||
|
- type: PlaceableSurface
|
||||||
|
- type: CollisionWake
|
||||||
|
enabled: false
|
||||||
|
|
||||||
|
- type: entity
|
||||||
|
id: CP14TestPlate
|
||||||
|
parent: CP14BasePlate
|
||||||
|
name: wooden plate
|
||||||
|
components:
|
||||||
|
- type: Sprite
|
||||||
|
sprite: Objects/Consumable/Food/plates.rsi #TODO resprite
|
||||||
|
state: plate
|
||||||
|
- type: Item
|
||||||
|
shape:
|
||||||
|
- 0,0,1,0
|
||||||
|
storedOffset: 0,-6
|
||||||
|
- type: DamageOnLand
|
||||||
|
damage:
|
||||||
|
types:
|
||||||
|
Blunt: 5
|
||||||
@@ -27,3 +27,6 @@
|
|||||||
|
|
||||||
- type: Tag
|
- type: Tag
|
||||||
id: CP14AmbientWater
|
id: CP14AmbientWater
|
||||||
|
|
||||||
|
- type: Tag
|
||||||
|
id: CP14Platter
|
||||||
Reference in New Issue
Block a user