Suggestion General Avoid modifying the given AgentBuildData in Mission.SpawnAgent

Users who are viewing this thread

The AgentBuildData is a great API, we can specify everything we need to create an agent. However when calling Mission.SpawnAgent(AgentBuildData) the final spawned agent can be different from the created AgentBuildData. For example:
  • Mission.SpawnAgent overrides AgentBuildData.Age
  • MissionNetworkComponent.HandleServerEventCreateAgent overrides the AgentBuildData.AgentBodyProperties with VirtualPlayer.BodyProperties
  • MissionNetworkComponent.HandleServerEventCreateAgent overrides the key of AgentBuildData.AgentBanner with MissionPeer.Peer.BannerCode and the colors with CreateAgent.Team.Color
IMO, once given to Mission.SpawnAgent, the AgentBuilData should never get modified, that way modders can spawn an agent with any banner, any color, any body properties.
 
Last edited:
This should already be achievable, NOT by using the Mission.SpawnAgent if you are trying to change something.
Instead, you should be implementing your own method to "spawn" an agent.
 
That is so much code to write just to fix a broken behavior :sad: When I pass an argument to a method I don't expect it to be ignored based on arbitrary decisions.
 
Also there are lots of internal methods that we can't use, for example:
- Mission._activeAgents.Add
- Mission._allAgents.Add
- Mission.DeploymentPlan.HasPlayerSpawnedFrame
- Mission.DeploymentPlan.GetPlayerSpawnFrame
- Agent.BodyPropertiesSeed
- Agent.SetMountAgentBeforeBuild

Also should I manually call the OnAgentBuild on all mission behaviors?

That really sound like a absolutely terrible solution.
 
Back
Top Bottom