Skip to content

Commit

Permalink
Merge pull request #50 from stalengd/cult-buildings-fixes-and-walls
Browse files Browse the repository at this point in the history
Cult buildings fixes and walls
  • Loading branch information
SkaldetSkaeg authored Oct 27, 2024
2 parents c4d099b + d9ea807 commit 7f2f7be
Show file tree
Hide file tree
Showing 7 changed files with 121 additions and 19 deletions.
Original file line number Diff line number Diff line change
Expand Up @@ -57,7 +57,7 @@ public override void StartHijack(PlacementManager manager)
base.StartHijack(manager);
if (_prototype is null)
return;
var entityProto = _prototypeManager.Index(_prototype.ResultEntityId);
var entityProto = _prototypeManager.Index(_prototype.ResultProtoId);
if (!entityProto.TryGetComponent<SpriteComponent>(out var sprite, _componentFactory))
return;
if (sprite?.BaseRSI is null)
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -55,7 +55,7 @@ public void SetOwner(MiGoErectMenu owner)
public void SetItem(CultYoggBuildingPrototype building)
{
Building = building;
ItemView.SetPrototype(building.ResultEntityId.Id);
ItemView.SetPrototype(building.ResultProtoId.Id);
MaterialsContainer.DisposeAllChildren();
if (ItemView.Entity == null)
return;
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -15,16 +15,35 @@ public sealed partial class CultYoggBuildingPrototype : IPrototype
[IdDataField]
public string ID { get; private set; } = default!;

[DataField("frame", required: true)]
public ProtoId<EntityPrototype> FrameEntityId { get; private set; }

/// <summary>
/// Final product of this recipe.
/// </summary>
[DataField("result", required: true)]
public EntProtoId ResultProtoId { get; private set; }

/// <summary>
/// Intermediate form of the building, where cultists should put <see cref="Materials"/> to build
/// <see cref="ResultProtoId"/>. If not present, <see cref="ResultProtoId"/> will be spawned instantly.
/// </summary>
[DataField("frame")]
public EntProtoId? FrameProtoId { get; private set; }

/// <summary>
/// Order to sort these buiildings in the UI.
/// </summary>
[DataField("order")]
public int Order { get; private set; } = 0;

[DataField("result", required: true)]
public ProtoId<EntityPrototype> ResultEntityId { get; private set; }
/// <summary>
/// Optional cooldown to build anything after that, default action cooldown will be used if not present.
/// </summary>
[DataField("cooldown")]
public TimeSpan? CooldownOverride { get; private set; }

[DataField("materials", required: true)]
/// <summary>
/// Set of materials that should be put to the <see cref="FrameProtoId"/> to get <see cref="ResultProtoId"/>.
/// </summary>
[DataField("materials")]
public List<CultYoggBuildingMaterial> Materials { get; private set; } = [];
}

Expand Down
26 changes: 20 additions & 6 deletions Content.Shared/SS220/CultYogg/MiGo/SharedMiGoErectSystem.cs
Original file line number Diff line number Diff line change
Expand Up @@ -127,13 +127,21 @@ private void OnDoAfterErect(Entity<MiGoComponent> entity, ref MiGoErectDoAfterEv
return;

var location = GetCoordinates(args.Location);
PlaceBuildingFrame(buildingPrototype, location, args.Direction);
if (buildingPrototype.FrameProtoId.HasValue)
{
PlaceBuildingFrame(buildingPrototype, location, args.Direction);
}
else
{
PlaceCompleteBuilding(buildingPrototype, location, args.Direction);
}

var erectAction = entity.Comp.MiGoErectActionEntity;
if (erectAction == null || !TryComp<InstantActionComponent>(erectAction, out var actionComponent))
return;

_actionsSystem.SetCooldown(erectAction, actionComponent.UseDelay ?? TimeSpan.FromSeconds(1));
var cooldown = buildingPrototype.CooldownOverride ?? actionComponent.UseDelay ?? TimeSpan.FromSeconds(1);
_actionsSystem.SetCooldown(erectAction, cooldown);
args.Handled = true;
}

Expand Down Expand Up @@ -210,9 +218,9 @@ private void OnBuildingFrameExamined(Entity<CultYoggBuildingFrameComponent> enti

private Entity<CultYoggBuildingFrameComponent> PlaceBuildingFrame(CultYoggBuildingPrototype buildingPrototype, EntityCoordinates location, Direction direction)
{
var frameEntity = SpawnAtPosition(buildingPrototype.FrameEntityId, location);
var frameEntity = SpawnAtPosition(buildingPrototype.FrameProtoId, location);
Transform(frameEntity).LocalRotation = direction.ToAngle();
var resultEntityProto = _prototypeManager.Index(buildingPrototype.ResultEntityId);
var resultEntityProto = _prototypeManager.Index(buildingPrototype.ResultProtoId);
_metaDataSystem.SetEntityName(frameEntity, Loc.GetString("cult-yogg-building-frame-name-template", ("name", resultEntityProto.Name)));
var frame = EnsureComp<CultYoggBuildingFrameComponent>(frameEntity);
frame.BuildingPrototypeId = buildingPrototype.ID;
Expand All @@ -224,6 +232,13 @@ private Entity<CultYoggBuildingFrameComponent> PlaceBuildingFrame(CultYoggBuildi
return (frameEntity, frame);
}

private EntityUid PlaceCompleteBuilding(CultYoggBuildingPrototype buildingPrototype, EntityCoordinates location, Direction direction)
{
var building = SpawnAtPosition(buildingPrototype.ResultProtoId, location);
Transform(building).LocalRotation = direction.ToAngle();
return building;
}

private bool CanInsert(Entity<CultYoggBuildingFrameComponent> entity, EntityUid item)
{
return CanInsert(entity, item, out _);
Expand Down Expand Up @@ -320,8 +335,7 @@ private EntityUid CompleteBuilding(Entity<CultYoggBuildingFrameComponent> entity
if (!_prototypeManager.TryIndex(entity.Comp.BuildingPrototypeId, out var prototype, logError: true))
return default;
var transform = Transform(entity);
var resultEntity = SpawnAtPosition(prototype.ResultEntityId, transform.Coordinates);
Transform(resultEntity).LocalRotation = transform.LocalRotation;
var resultEntity = PlaceCompleteBuilding(prototype, transform.Coordinates, transform.LocalRotation.GetDir());
Del(entity);
return resultEntity;
}
Expand Down
20 changes: 15 additions & 5 deletions Resources/Prototypes/SS220/CultYogg/buildings.yml
Original file line number Diff line number Diff line change
@@ -1,8 +1,18 @@
# © SS220, An EULA/CLA with a hosting restriction, full text: https://raw.githubusercontent.com/SerbiaStrong-220/space-station-14/master/CLA.txt

- type: cultYoggBuilding
id: CultYoggPod
id: CultYoggWall
order: 0
result: WallCultYogg

- type: cultYoggBuilding
id: CultYoggDoor
order: 1
result: CultYoggDoor

- type: cultYoggBuilding
id: CultYoggPod
order: 2
frame: CultYoggBuildingFrame
result: CultYoggPod
materials:
Expand All @@ -15,9 +25,9 @@

- type: cultYoggBuilding
id: FungusHydroponic
order: 1
order: 3
frame: CultYoggBuildingFrame
result: CultYoggFungusHydroponic #ToDo wierd bug with "green" sprite before placement
result: CultYoggFungusHydroponic
materials:
- stack: CableMVlive
count: 5
Expand All @@ -31,7 +41,7 @@

- type: cultYoggBuilding
id: CultYoggAltarBuilding
order: 2
order: 4
frame: CultYoggBuildingFrame
result: CultYoggAltar
materials:
Expand All @@ -47,7 +57,7 @@

- type: cultYoggBuilding
id: CultYoggPondBuilding
order: 3
order: 5
frame: CultYoggBuildingFrame
result: CultYoggPond
materials:
Expand Down
1 change: 1 addition & 0 deletions Resources/Prototypes/SS220/CultYogg/fungus.yml
Original file line number Diff line number Diff line change
Expand Up @@ -22,6 +22,7 @@
- type: Anchorable
- type: Pullable
- type: Sprite
sprite: SS220/Structures/fungusHydroponic.rsi
layers:
- sprite: SS220/Structures/fungusHydroponic.rsi
state: base
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -44,3 +44,61 @@
- !type:DoActsBehavior
acts: ["Destruction"]
- type: Appearance

- type: entity
parent: BaseWall
id: WallCultYogg
name: проклятая стена
components:
- type: Tag
tags:
- Wall
- type: Sprite
sprite: SS220/Structures/Walls/cult_yogg_walls.rsi
state: full
- type: Icon
sprite: SS220/Structures/Walls/cult_yogg_walls.rsi
- type: Destructible
thresholds:
- trigger:
!type:DamageTrigger
damage: 300
behaviors:
- !type:DoActsBehavior
acts: [ "Destruction" ]
- type: IconSmooth
key: cultYoggWall
base: cult

- type: entity
parent: BaseMaterialDoorNavMap
id: CultYoggDoor
name: проклятая дверь
components:
- type: Sprite
sprite: SS220/Structures/Doors/cult_yogg_doors.rsi
layers:
- state: closed
map: ["enum.DoorVisualLayers.Base"]
- type: Door
bumpOpen: false
clickOpen: true
closeTimeOne: 0.2
closeTimeTwo: 0.6
openTimeOne: 0.6
openTimeTwo: 0.2
openSound:
path: /Audio/Effects/door_open.ogg
closeSound:
path: /Audio/Effects/door_close.ogg
- type: Damageable
damageContainer: StructuralInorganic
damageModifierSet: Metallic
- type: Destructible
thresholds:
- trigger:
!type:DamageTrigger
damage: 200
behaviors:
- !type:DoActsBehavior
acts: ["Destruction"]

0 comments on commit 7f2f7be

Please sign in to comment.