Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Xeno improvements #6032

Merged
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
42 changes: 30 additions & 12 deletions Content.Client/MobState/DamageStateVisualizer.cs
Original file line number Diff line number Diff line change
Expand Up @@ -18,34 +18,42 @@ public sealed class DamageStateVisualizer : AppearanceVisualizer, ISerialization
private int? _originalDrawDepth;

[DataField("normal")]
private string? normal;
private string? _normal;

[DataField("crit")]
private string? crit;
private string? _crit;

[DataField("dead")]
private string? dead;
private string? _dead;

/// <summary>
/// Should noRot be turned off when crit / dead.
/// </summary>
[DataField("rotate")]
private bool _rotate;

void ISerializationHooks.BeforeSerialization()
{
_stateMap.TryGetValue(DamageState.Alive, out normal);
_stateMap.TryGetValue(DamageState.Critical, out crit);
_stateMap.TryGetValue(DamageState.Dead, out dead);
_stateMap.TryGetValue(DamageState.Alive, out _normal);
_stateMap.TryGetValue(DamageState.Critical, out _crit);
_stateMap.TryGetValue(DamageState.Dead, out _dead);
}

void ISerializationHooks.AfterDeserialization()
{
if (normal != null)
if (_normal != null)
{
_stateMap.Add(DamageState.Alive, normal);
_stateMap.Add(DamageState.Alive, _normal);
}

if (crit != null)
if (_crit != null)
{
_stateMap.Add(DamageState.Critical, crit);
_stateMap.Add(DamageState.Critical, _crit);
}

if (dead != null)
if (_dead != null)
{
_stateMap.Add(DamageState.Dead, dead);
_stateMap.Add(DamageState.Dead, _dead);
}
}

Expand All @@ -65,6 +73,16 @@ public override void OnChangeData(AppearanceComponent component)

_data = data;

if (_rotate)
{
sprite.NoRotation = data switch
{
DamageState.Critical => false,
DamageState.Dead => false,
_ => true
};
}

if (_stateMap.TryGetValue(_data, out var state))
{
sprite.LayerSetState(DamageStateVisualLayers.Base, state);
Expand Down
4 changes: 2 additions & 2 deletions Content.Server/AI/Utility/AiLogic/UtilityAI.cs
Original file line number Diff line number Diff line change
Expand Up @@ -10,13 +10,13 @@
using Content.Server.AI.WorldState;
using Content.Server.AI.WorldState.States.Utility;
using Content.Server.CPUJob.JobQueues;
using Content.Shared.MobState;
using Content.Shared.Movement.Components;
using Robust.Shared.GameObjects;
using Robust.Shared.IoC;
using Robust.Shared.Log;
using Robust.Shared.Serialization;
using Robust.Shared.Serialization.Manager.Attributes;
using Robust.Shared.Serialization.TypeSerializers.Implementations.Custom.Prototype.Set;

namespace Content.Server.AI.Utility.AiLogic
{
Expand All @@ -36,7 +36,7 @@ public sealed class UtilityAi : AiControllerComponent, ISerializationHooks
/// <summary>
/// The sum of all BehaviorSets gives us what actions the AI can take
/// </summary>
[DataField("behaviorSets")]
[DataField("behaviorSets", customTypeSerializer:typeof(PrototypeIdHashSetSerializer<BehaviorSetPrototype>))]
public HashSet<string> BehaviorSets { get; } = new();

public List<IAiUtility> AvailableActions { get; set; } = new();
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -24,12 +24,12 @@
components:
- type: Sprite
layers:
- state: blue
- texture: Mobs/Aliens/Xenos/xeno.rsi/crit.png
- state: ai
- state: blue
- texture: Mobs/Aliens/Xenos/burrower.rsi/crit.png
- state: ai
- type: TimedSpawner
prototypes:
- MobXeno
- MobXeno
chance: 0.85
intervalSeconds: 30
minimumEntitiesSpawned: 2
Expand Down
9 changes: 5 additions & 4 deletions Resources/Prototypes/Entities/Mobs/NPCs/xeno.yml
Original file line number Diff line number Diff line change
Expand Up @@ -15,18 +15,18 @@
- type: Hands
- type: Sprite
drawdepth: Mobs
sprite: Mobs/Aliens/Xenos/burrower.rsi
layers:
- map: ["enum.DamageStateVisualLayers.Base"]
state: running
sprite: Mobs/Aliens/Xenos/xeno.rsi
- type: Physics
bodyType: Dynamic
- type: Fixtures
fixtures:
- shape:
!type:PhysShapeAabb
bounds: "-0.4,-1,0.4,-0.2"
mass: 85
!type:PhysShapeCircle
radius: 0.35
mass: 120
mask:
- Impassable
- MobImpassable
Expand Down Expand Up @@ -56,6 +56,7 @@
- type: Appearance
visuals:
- type: DamageStateVisualizer
rotate: true
normal: running
crit: crit
dead: dead
Expand Down
Original file line number Diff line number Diff line change
@@ -1,7 +1,7 @@
{
"version": 1,
"license": "CC-BY-SA-3.0",
"copyright": "Taken from Colonial Marines at commit https://gitlab.com/cmdevs/colonial-warfare/-/commit/f6b3c61fcbfe73a3f0f92edd5fc441ef845017e5",
"copyright": "Taken from Colonial Marines at commit https://gitlab.com/cmdevs/colonial-warfare/-/commit/f6b3c61fcbfe73a3f0f92edd5fc441ef845017e5 Sprites centered by metalgearsloth",
"size": {
"x": 64,
"y": 64
Expand Down
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
Binary file not shown.
Binary file not shown.
Binary file not shown.