@ -30,11 +30,11 @@ public class GameState
// The first sub-model contains all of the static geometry
// The first sub-model contains all of the static geometry
var subModel = worldModel . GetSubModel ( 0 ) ;
var subModel = worldModel . GetSubModel ( 0 ) ;
var subModelGO = CreateWorld GameObject ( subModel ) ;
var subModelGO = CreateBrush GameObject ( subModel ) ;
subModelGO . transform . SetParent ( worldGameObject . transform ) ;
subModelGO . transform . SetParent ( worldGameObject . transform ) ;
}
}
private GameObject CreateWorld GameObject ( BrushModel . SubModel subModel )
private GameObject CreateBrush GameObject ( BrushModel . SubModel subModel )
{
{
var subModelGO = new GameObject ( subModel . Name ) ;
var subModelGO = new GameObject ( subModel . Name ) ;
@ -104,6 +104,26 @@ public class GameState
entity . SetAliasModel ( aliasModel ) ;
entity . SetAliasModel ( aliasModel ) ;
}
}
public void SetEntityBrushModel ( int entityNum , string modelName )
{
var entity = GetOrCreateEntity ( entityNum ) ;
if ( ! uq . GameAssets . TryGetBrushModel ( modelName , out var brushModel ) )
{
Debug . LogWarning ( $"Unknown brush model name: {modelName}" ) ;
return ;
}
var brushModelGO = new GameObject ( brushModel . Name ) ;
for ( int i = 0 ; i < brushModel . SubModelCount ; + + i )
{
var subModelGO = CreateBrushGameObject ( brushModel . GetSubModel ( i ) ) ;
subModelGO . transform . SetParent ( brushModelGO . transform ) ;
}
entity . SetBrushModel ( brushModelGO ) ;
}
public void SetEntityWorldModel ( int entityNum , int subModelNum )
public void SetEntityWorldModel ( int entityNum , int subModelNum )
{
{
var entity = GetOrCreateEntity ( entityNum ) ;
var entity = GetOrCreateEntity ( entityNum ) ;
@ -117,7 +137,7 @@ public class GameState
// TODO: these relatively complex world game objects are going to get destroyed and re-created all the time
// TODO: these relatively complex world game objects are going to get destroyed and re-created all the time
// as the player moves through the map and moves in and out of range of these entities. This can and should
// as the player moves through the map and moves in and out of range of these entities. This can and should
// be done more efficiently by creating the game objects only once and enabling/disabling them on demand.
// be done more efficiently by creating the game objects only once and enabling/disabling them on demand.
var worldModelGO = CreateWorld GameObject ( subModel ) ;
var worldModelGO = CreateBrush GameObject ( subModel ) ;
entity . SetWorldModel ( worldModelGO ) ;
entity . SetWorldModel ( worldModelGO ) ;
}
}