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

Update Aptitude #58

Draft
wants to merge 10 commits into
base: master
Choose a base branch
from
5 changes: 5 additions & 0 deletions UdpHosts/GameServer/Data/CharacterInventory.cs
Original file line number Diff line number Diff line change
Expand Up @@ -182,6 +182,11 @@ public bool ConsumeResource(uint sdbId, uint cost)
}
}

public uint GetResourceQuantity(uint sdbId)
{
return _resources.TryGetValue(sdbId, out var value) ? value.Quantity : 0;
}

public void AddLoadout(Loadout loadout)
{
_loadouts.Add(loadout.FrameLoadoutId, loadout);
Expand Down
1 change: 1 addition & 0 deletions UdpHosts/GameServer/Data/CharacterLoadout.cs
Original file line number Diff line number Diff line change
Expand Up @@ -155,6 +155,7 @@ public CharacterLoadout(LoadoutReferenceData refData)
public uint GliderID { get; set; }
public uint ChassisID { get; set; }
public uint BackpackID { get; set; }
public uint ChassisChangeTime { get; set; } = 0;
public ChassisWarpaintResult ChassisWarpaint { get; set; }

public VisualsBlock GetChassisVisuals()
Expand Down
6 changes: 5 additions & 1 deletion UdpHosts/GameServer/Entities/BaseAptitudeEntity.cs
Original file line number Diff line number Diff line change
Expand Up @@ -10,6 +10,7 @@
using GameServer;
using GameServer.Aptitude;
using GameServer.Entities;
using GameServer.Entities.Character;

namespace GameServer.Entities;

Expand All @@ -20,11 +21,14 @@ public abstract class BaseAptitudeEntity : BaseEntity, IAptitudeTarget

protected EffectState[] ActiveEffects = new EffectState[MaxEffectCount];

public BaseAptitudeEntity(IShard shard, ulong eid)
public BaseAptitudeEntity(IShard shard, ulong eid, CharacterEntity owner)
: base(shard, eid)
{
Owner = owner;
}

public CharacterEntity Owner { get; }

public List<EffectState> GetActiveEffects() => ActiveEffects.ToList<EffectState>();

public override string ToString()
Expand Down
14 changes: 5 additions & 9 deletions UdpHosts/GameServer/Entities/Carryable/CarryableEntity.cs
Original file line number Diff line number Diff line change
Expand Up @@ -7,14 +7,15 @@
using AeroMessages.GSS.V66.CarryableObject;
using AeroMessages.GSS.V66.CarryableObject.View;
using GameServer.Aptitude;
using GameServer.Entities.Character;
using GameServer.Enums;

namespace GameServer.Entities.Carryable;

public class CarryableEntity : BaseAptitudeEntity, IAptitudeTarget
public sealed class CarryableEntity : BaseAptitudeEntity, IAptitudeTarget
{
public CarryableEntity(IShard shard, ulong eid, uint type)
: base(shard, eid)
: base(shard, eid, owner: null)
{
AeroEntityId = new EntityId() { Backing = EntityId, ControllerId = Controller.Carryable };
Type = type;
Expand Down Expand Up @@ -157,14 +158,9 @@ public override bool CanBeInteractedBy(IEntity other)
public void SetCarrier(BaseEntity entity)
{
Carrier = entity;
if (entity.GetType() == typeof(Entities.Character.CharacterEntity))
if (entity is CharacterEntity { IsPlayerControlled: true } character)
{
var character = entity as Entities.Character.CharacterEntity;

if (character.IsPlayerControlled)
{
Player = character.Player;
}
Player = character.Player;
}

CarryableObject_ObserverView.CarryingCharacterIdProp = Carrier.AeroEntityId;
Expand Down
21 changes: 18 additions & 3 deletions UdpHosts/GameServer/Entities/Character/CharacterEntity.cs
Original file line number Diff line number Diff line change
Expand Up @@ -12,6 +12,7 @@
using GameServer.Data;
using GameServer.Data.SDB;
using GameServer.Data.SDB.Records.customdata;
using GameServer.Entities.Deployable;
using GameServer.Enums;
using GameServer.Systems.Encounters;
using GameServer.Test;
Expand All @@ -28,8 +29,8 @@ public sealed partial class CharacterEntity : BaseAptitudeEntity, IAptitudeTarge
public const byte MaxMapMarkerCount = 64;
private MapMarkerState[] MapMarkers = new MapMarkerState[MaxMapMarkerCount];

public CharacterEntity(IShard shard, ulong eid)
: base(shard, eid)
public CharacterEntity(IShard shard, ulong eid, CharacterEntity owner = null)
: base(shard, eid, owner)
{
AeroEntityId = new EntityId() { Backing = EntityId, ControllerId = Controller.Character };

Expand Down Expand Up @@ -134,6 +135,7 @@ public CharacterEntity(IShard shard, ulong eid)
public AttachedToData? AttachedTo { get; set; } = null;
public IEntity AttachedToEntity { get; set; } = null;
public uint SelectedLoadout { get; set; }
public List<DeployableEntity> OwnedDeployables { get; set; } = new List<DeployableEntity>();

public ushort StatusEffectsChangeTime_0 { get; set; }
public ushort StatusEffectsChangeTime_1 { get; set; }
Expand Down Expand Up @@ -913,6 +915,11 @@ public void SetSpawnTime(uint time)
}
}

public void SetNpcType(ushort npcType)
{
Character_ObserverView.NPCTypeProp = npcType;
}

public void SetWeaponIndex(WeaponIndexData value)
{
WeaponIndex = value;
Expand Down Expand Up @@ -947,6 +954,14 @@ public void SetGliderProfileId(uint profileId)
}
}

public void SetHoverProfileId(uint profileId)
{
if (Character_CombatController != null)
{
Character_CombatController.HoverProfileIdProp = profileId;
}
}

public void SetAuthorizedTerminal(AuthorizedTerminalData value)
{
AuthorizedTerminal = value;
Expand Down Expand Up @@ -1464,7 +1479,7 @@ private void InitViews()
SinFactionsAcquiredByProp = null,
SinTeamsAcquiredByProp = null,
ArmyGUIDProp = 0,
OwnerIdProp = 0,
OwnerIdProp = Owner?.EntityId ?? 0,
NPCTypeProp = 0,
DockedParamsProp = DockedParams,
LookAtTargetProp = null,
Expand Down
11 changes: 7 additions & 4 deletions UdpHosts/GameServer/Entities/Deployable/DeployableEntity.cs
Original file line number Diff line number Diff line change
Expand Up @@ -7,15 +7,16 @@
using AeroMessages.GSS.V66.Deployable;
using AeroMessages.GSS.V66.Deployable.View;
using GameServer.Aptitude;
using GameServer.Entities.Character;
using GameServer.Entities.Turret;

namespace GameServer.Entities.Deployable;

public class DeployableEntity : BaseAptitudeEntity, IAptitudeTarget
public sealed class DeployableEntity : BaseAptitudeEntity, IAptitudeTarget
{
// TODO: Add Deployable Hardpoint support
public DeployableEntity(IShard shard, ulong eid, uint type, uint abilitySrcId)
: base(shard, eid)
public DeployableEntity(IShard shard, ulong eid, uint type, uint abilitySrcId, CharacterEntity owner = null)
: base(shard, eid, owner)
{
AeroEntityId = new EntityId() { Backing = EntityId, ControllerId = Controller.Deployable };
Type = type;
Expand All @@ -28,7 +29,6 @@ public DeployableEntity(IShard shard, ulong eid, uint type, uint abilitySrcId)

public INetworkPlayer Player { get; set; }
public bool IsPlayerOwned => Player != null;
public BaseEntity Owner { get; set; }
public Quaternion Orientation { get; set; }
public Vector3 AimPosition => Position;
public Vector3 AimDirection { get; set; }
Expand All @@ -39,7 +39,10 @@ public DeployableEntity(IShard shard, ulong eid, uint type, uint abilitySrcId)
public uint Type { get; set; }
public uint AbilitySrcId { get; set; }
public uint GibVisualsID { get; set; }
public float Scale { get; set; }
public int MaxHealth { get; set; } = 0;
public uint PoweredOnAbility { get; set; } = 0;
public uint PoweredOffAbility { get; set; } = 0;

public ushort StatusEffectsChangeTime_0 { get; set; }
public ushort StatusEffectsChangeTime_1 { get; set; }
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -6,7 +6,7 @@

namespace GameServer.Entities.MeldingBubble;

public class MeldingBubbleEntity : BaseEntity
public sealed class MeldingBubbleEntity : BaseEntity
{
public MeldingBubbleEntity(IShard shard, ulong eid)
: base(shard, eid)
Expand Down
2 changes: 1 addition & 1 deletion UdpHosts/GameServer/Entities/Melding/MeldingEntity.cs
Original file line number Diff line number Diff line change
Expand Up @@ -6,7 +6,7 @@

namespace GameServer.Entities.Melding;

public class MeldingEntity : BaseEntity
public sealed class MeldingEntity : BaseEntity
{
public MeldingEntity(IShard shard, ulong eid, string perimiterSetName)
: base(shard, eid)
Expand Down
2 changes: 1 addition & 1 deletion UdpHosts/GameServer/Entities/Outpost/OutpostEntity.cs
Original file line number Diff line number Diff line change
Expand Up @@ -8,7 +8,7 @@

namespace GameServer.Entities.Outpost;

public class OutpostEntity : BaseEntity
public sealed class OutpostEntity : BaseEntity
{
private static readonly Random Rng = new();

Expand Down
12 changes: 5 additions & 7 deletions UdpHosts/GameServer/Entities/Thumper/ThumperEntity.cs
Original file line number Diff line number Diff line change
Expand Up @@ -10,23 +10,22 @@

namespace GameServer.Entities.Thumper;

public class ThumperEntity : BaseAptitudeEntity, IAptitudeTarget
public sealed class ThumperEntity : BaseAptitudeEntity, IAptitudeTarget
{
public ThumperEntity(
IShard shard,
ulong eid,
uint nodeType,
Vector3 position,
BaseEntity owner,
CharacterEntity owner,
ResourceNodeBeaconCalldownCommandDef commandDef)
: base(shard, eid)
: base(shard, eid, owner)
{
AeroEntityId = new EntityId() { Backing = EntityId, ControllerId = Controller.ResourceNode };
NodeType = nodeType;
BeaconType = commandDef.ResourceNodeBeaconId;
Scoping = new ScopingComponent() { Global = true };
Position = position;
Owner = owner;
LandedAbility = commandDef.LandedAbility;
CompletedAbility = commandDef.CompletedAbility;
CalldownTimeMs = commandDef.CalldownTimeMs;
Expand All @@ -44,7 +43,6 @@ public ThumperEntity(

public INetworkPlayer Player { get; set; }
public bool IsPlayerOwned => Player != null;
public BaseEntity Owner { get; set; }
public HostilityInfoData HostilityInfo { get; set; }

public uint NodeType { get; set; }
Expand All @@ -57,6 +55,7 @@ public ThumperEntity(
Layer = 0,
Unk2 = 1
};
public float Scale { get; set; }

public uint LandedAbility { get; set; } = 0;
public uint CompletedAbility { get; set; } = 0;
Expand Down Expand Up @@ -185,13 +184,12 @@ public override bool CanBeInteractedBy(IEntity other)

private void InitFields()
{
var charOwner = (CharacterEntity)Owner;
HostilityInfo = new HostilityInfoData { Flags = 0 | HostilityInfoData.HostilityFlags.Faction, FactionId = 1 };
ThumpingCharacterInfo = new ThumpingCharacterInfoStruct
{
OwnerId1 = Owner.AeroEntityId,
OwnerId2 = Owner.AeroEntityId,
Owner = charOwner.ToString(),
Owner = Owner.ToString(),
Unk = 0f,
};
StateInfo = new StateInfoStruct
Expand Down
2 changes: 1 addition & 1 deletion UdpHosts/GameServer/Entities/Turret/TurretEntity.cs
Original file line number Diff line number Diff line change
Expand Up @@ -8,7 +8,7 @@

namespace GameServer.Entities.Turret;

public class TurretEntity : BaseEntity
public sealed class TurretEntity : BaseEntity
{
public TurretEntity(IShard shard, ulong eid, uint type, BaseEntity parent, byte parentChildIndex, byte posture)
: base(shard, eid)
Expand Down
34 changes: 14 additions & 20 deletions UdpHosts/GameServer/Entities/Vehicle/VehicleEntity.cs
Original file line number Diff line number Diff line change
@@ -1,5 +1,6 @@
using System;
using System.Collections.Generic;
using System.Linq;
using System.Numerics;
using AeroMessages.Common;
using AeroMessages.GSS.V66;
Expand Down Expand Up @@ -53,8 +54,8 @@ public class SeatConfig

public sealed class VehicleEntity : BaseAptitudeEntity, IAptitudeTarget
{
public VehicleEntity(IShard shard, ulong eid)
: base(shard, eid)
public VehicleEntity(IShard shard, ulong eid, CharacterEntity owner = null)
: base(shard, eid, owner)
{
AeroEntityId = new EntityId() { Backing = EntityId, ControllerId = Controller.Vehicle };
Interaction = new InteractionComponent()
Expand Down Expand Up @@ -94,7 +95,6 @@ public VehicleEntity(IShard shard, ulong eid)
public byte[] Flags { get; set; } = { 0x00, 0x04, 0x00, 0x00 };
public byte EngineState { get; set; } = 2; // TEMP
public byte PathState { get; set; } = 1;
public BaseEntity Owner { get; set; }
public Dictionary<byte, SeatConfig> Occupants { get; set; } = new Dictionary<byte, SeatConfig>()
{
{
Expand Down Expand Up @@ -361,22 +361,6 @@ public void SetOwningPlayer(INetworkPlayer player)
OwningPlayer = player;
}

public void SetOwner(BaseEntity entity)
{
Owner = entity;

Vehicle_ObserverView.OwnerIdProp = Owner.AeroEntityId;
Vehicle_ObserverView.OwnerNameProp = string.Empty;
Vehicle_ObserverView.OwnerLocalStringProp = 0;

if (Vehicle_BaseController != null)
{
Vehicle_BaseController.OwnerIdProp = Owner.AeroEntityId;
Vehicle_BaseController.OwnerNameProp = string.Empty; // FIXME
Vehicle_BaseController.OwnerLocalStringProp = 0; // FIXME
}
}

public void SetPoseData(MovementInput poseData)
{
Position = poseData.Position;
Expand Down Expand Up @@ -527,7 +511,7 @@ public override bool CanBeInteractedBy(IEntity other)
* If owned by a player and other entity is not that player, require that there is a free seat for the owner. This ensures 1 seat vehicles can't be stolen from a player.
*/
var isInteractable = IsInteractable();
var isCharacter = other.GetType() == typeof(Entities.Character.CharacterEntity);
var isCharacter = other is CharacterEntity;
var numFreeSeats = GetNumberOfFreeSeats();
if (IsPlayerOwned && other != Owner)
{
Expand Down Expand Up @@ -646,6 +630,16 @@ public void ChangeOccupantSeat(CharacterEntity character, byte requestedSeatInde
}
}

public void SlotAbility(uint abilityId)
{
var index = Abilities.FirstOrDefault(a => a.Value == 0).Key;

Abilities[index] = abilityId;

Vehicle_CombatController?.GetType().GetProperty($"SlottedAbility_{index}Prop")
?.SetValue(Vehicle_CombatController, abilityId, null);
}

private void InitFields()
{
HostilityInfo = new HostilityInfoData { Flags = 0 | HostilityInfoData.HostilityFlags.Faction, FactionId = 1 };
Expand Down
1 change: 1 addition & 0 deletions UdpHosts/GameServer/IPlayer.cs
Original file line number Diff line number Diff line change
Expand Up @@ -48,6 +48,7 @@ public enum PlayerStatus

void Login(ulong characterId);
void EnterZoneAck();
void ExitZoneAck();
void Ready();
void Respawn();
void Jump();
Expand Down
3 changes: 3 additions & 0 deletions UdpHosts/GameServer/NetworkClient.cs
Original file line number Diff line number Diff line change
Expand Up @@ -218,6 +218,9 @@ private void Matrix_PacketAvailable(GamePacket packet)
Factory.Get<BaseController>().Init(this, Player, AssignedShard, Logger);
Player.EnterZoneAck();
break;
case MatrixPacketType.ExitZoneAck:
Player.ExitZoneAck();
break;
case MatrixPacketType.KeyframeRequest:
var query = packet.Unpack<KeyframeRequest>();
Logger.Verbose($"KeyframeRequest with {query.EntityRequests?.Length ?? 0} entity requests and {query.RefRequests?.Length ?? 0} ref requests. Total scoped for player: {AssignedShard.EntityMan.GetNumberOfScopedEntities(Player)}");
Expand Down
7 changes: 6 additions & 1 deletion UdpHosts/GameServer/NetworkPlayer.cs
Original file line number Diff line number Diff line change
Expand Up @@ -140,6 +140,11 @@ public void EnterZoneAck()
AssignedShard.EntityMan.Add(CharacterEntity.EntityId, CharacterEntity);
}

public void ExitZoneAck()
{
AssignedShard.EntityMan.Remove(CharacterEntity);
}

public void Respawn()
{
var outpostId = FindClosestAvailableOutpost(CurrentZone, CurrentOutpostId);
Expand Down Expand Up @@ -290,7 +295,7 @@ public void HandleFireWeaponProjectile(uint time, Vector3 aim)
AssignedShard.WeaponSim.OnFireWeaponProjectile(CharacterEntity, time, aim);
}

private void EnterZone(Zone z, uint outpostId = 0)
public void EnterZone(Zone z, uint outpostId = 0)
{
var spawnPoint = outpostId == 0
? new SpawnPoint { Position = z.POIs["spawn"] }
Expand Down
Loading
Loading