You can not select more than 25 topics
Topics must start with a letter or number, can include dashes ('-') and can be up to 35 characters long.
66 lines
1.7 KiB
66 lines
1.7 KiB
using System.Collections;
|
|
using System.Collections.Generic;
|
|
using UnityEngine;
|
|
|
|
public partial class GameModule
|
|
{
|
|
private readonly UniQuake uq;
|
|
|
|
public GameModule(UniQuake uniQuake)
|
|
{
|
|
uq = uniQuake;
|
|
BuildCallbacks();
|
|
}
|
|
|
|
private void SetEntityModel(int entityNum, string modelName)
|
|
{
|
|
if (string.IsNullOrEmpty(modelName))
|
|
{
|
|
uq.GameState.GetEntity(entityNum)?.ClearModel();
|
|
return;
|
|
}
|
|
|
|
if (modelName.StartsWith("*"))
|
|
{
|
|
if (!int.TryParse(modelName.Substring(1), out int subModelNum))
|
|
{
|
|
Debug.LogWarning($"Invalid world sub-model index: {modelName}");
|
|
return;
|
|
}
|
|
|
|
uq.GameState.SetEntityWorldModel(entityNum, subModelNum);
|
|
return;
|
|
}
|
|
|
|
if (modelName.EndsWith(".bsp"))
|
|
{
|
|
// TODO: non-world brush model
|
|
uq.GameState.GetEntity(entityNum)?.ClearModel();
|
|
return;
|
|
}
|
|
|
|
if (modelName.EndsWith(".spr"))
|
|
{
|
|
// TODO: sprite
|
|
uq.GameState.GetEntity(entityNum)?.ClearModel();
|
|
return;
|
|
}
|
|
|
|
uq.GameState.SetEntityAliasModel(entityNum, modelName);
|
|
}
|
|
|
|
private void SetEntityTransform(int entityNum, QVec3 origin, QVec3 angles)
|
|
{
|
|
uq.GameState.GetEntity(entityNum)?.SetTransform(origin.ToUnityPosition(), angles.ToUnityRotation());
|
|
}
|
|
|
|
private void RemoveEntity(int entityNum)
|
|
{
|
|
uq.GameState.RemoveEntity(entityNum);
|
|
}
|
|
|
|
private void UpdateEntityAnimation(int entityNum, float frameNum)
|
|
{
|
|
uq.GameState.GetEntity(entityNum)?.UpdateAnimation(frameNum);
|
|
}
|
|
}
|