Adding checks for if objects get deleted too fast
Fixing post-build event to create combined directory
This commit is contained in:
parent
5bdc5db408
commit
4755ff6b87
@ -227,7 +227,8 @@
|
||||
<Import Project="$(MSBuildBinPath)\Microsoft.CSharp.targets" />
|
||||
<Import Project="$(MSBuildExtensionsPath)\Microsoft\XNA Game Studio\Microsoft.Xna.GameStudio.targets" />
|
||||
<PropertyGroup>
|
||||
<PostBuildEvent>copy "$(TargetPath)" ..\..\Combined</PostBuildEvent>
|
||||
<PostBuildEvent>if not exist "$(TargetPath)" ..\..\Combined mkdir "$(TargetPath)" ..\..\Combined
|
||||
copy "$(TargetPath)" ..\..\Combined</PostBuildEvent>
|
||||
</PropertyGroup>
|
||||
<!--
|
||||
To modify your build process, add your task inside one of the targets below and uncomment it.
|
||||
|
@ -258,7 +258,8 @@
|
||||
<Import Project="$(MSBuildBinPath)\Microsoft.CSharp.targets" />
|
||||
<Import Project="$(MSBuildExtensionsPath)\Microsoft\XNA Game Studio\Microsoft.Xna.GameStudio.targets" />
|
||||
<PropertyGroup>
|
||||
<PostBuildEvent>copy "$(TargetPath)" ..\..\Combined</PostBuildEvent>
|
||||
<PostBuildEvent>if not exist "$(TargetPath)" ..\..\Combined mkdir "$(TargetPath)" ..\..\Combined
|
||||
copy "$(TargetPath)" ..\..\Combined</PostBuildEvent>
|
||||
</PropertyGroup>
|
||||
<!--
|
||||
To modify your build process, add your task inside one of the targets below and uncomment it.
|
||||
|
@ -222,7 +222,8 @@
|
||||
<Import Project="$(MSBuildBinPath)\Microsoft.CSharp.targets" />
|
||||
<Import Project="$(MSBuildExtensionsPath)\Microsoft\XNA Game Studio\Microsoft.Xna.GameStudio.targets" />
|
||||
<PropertyGroup>
|
||||
<PostBuildEvent>copy "$(TargetPath)" ..\..\Combined</PostBuildEvent>
|
||||
<PostBuildEvent>if not exist "$(TargetPath)" ..\..\Combined mkdir "$(TargetPath)" ..\..\Combined
|
||||
copy "$(TargetPath)" ..\..\Combined</PostBuildEvent>
|
||||
</PropertyGroup>
|
||||
<!--
|
||||
To modify your build process, add your task inside one of the targets below and uncomment it.
|
||||
|
@ -27,6 +27,7 @@ namespace Axios.Engine
|
||||
public abstract class AxiosGameScreen : PhysicsGameScreen
|
||||
{
|
||||
private List<AxiosGameObject> _gameObjects;
|
||||
private List<AxiosGameObject> _objectstoremove = new List<AxiosGameObject>();
|
||||
private AxiosGameObject prevobj;
|
||||
private AxiosGameObject prevfocusobj;
|
||||
|
||||
@ -100,10 +101,11 @@ namespace Axios.Engine
|
||||
if (obj is AxiosGameObject || obj is AxiosUIObject || obj is AxiosTimer)
|
||||
{
|
||||
AxiosGameObject tmp = obj as AxiosGameObject;
|
||||
tmp.LoadContent(this);
|
||||
|
||||
if (obj is AxiosGameObject || obj is AxiosUIObject)
|
||||
tmp.RemoveObject += new AxiosEvents.AxiosGameObjectHandler(RemoveGameObject);
|
||||
|
||||
tmp.LoadContent(this);
|
||||
|
||||
if (obj is AxiosGameObject && !(obj is AxiosUIObject))
|
||||
{
|
||||
_gameObjects.Add(tmp);
|
||||
@ -134,15 +136,21 @@ namespace Axios.Engine
|
||||
|
||||
public void RemoveGameObject(AxiosGameObject gameobject)
|
||||
{
|
||||
gameobject.RemoveObject -= new AxiosGameObject.AxiosGameObjectHandler(RemoveGameObject);
|
||||
try
|
||||
if (this._gameObjects.Contains(gameobject))
|
||||
{
|
||||
gameobject.UnloadContent(this);
|
||||
this._gameObjects.Remove(gameobject);
|
||||
try
|
||||
{
|
||||
gameobject.UnloadContent(this);
|
||||
this._gameObjects.Remove(gameobject);
|
||||
}
|
||||
catch (Exception)
|
||||
{
|
||||
}
|
||||
}
|
||||
catch (Exception)
|
||||
else
|
||||
{
|
||||
//Not sure what is going on - but in certain cases an exception will be triggered that the body has already been marked for removal
|
||||
Singleton<AxiosLog>.Instance.AddLine("[Axios Engine] - Adding objects too fast...remove " + gameobject.Name + " later", LoggingFlag.DEBUG);
|
||||
this._objectstoremove.Add(gameobject);
|
||||
}
|
||||
|
||||
}
|
||||
@ -192,13 +200,24 @@ namespace Axios.Engine
|
||||
{
|
||||
base.Update(gameTime, otherScreenHasFocus, coveredByOtherScreen);
|
||||
|
||||
foreach (AxiosGameObject g in _gameObjects)
|
||||
if (this._objectstoremove.Count > 0)
|
||||
{
|
||||
List<AxiosGameObject> list = this._objectstoremove.ToList<AxiosGameObject>();
|
||||
foreach (AxiosGameObject obj in list)
|
||||
{
|
||||
this.RemoveGameObject(obj);
|
||||
this._objectstoremove.Remove(obj);
|
||||
}
|
||||
}
|
||||
|
||||
|
||||
foreach (AxiosGameObject g in _gameObjects.ToList())
|
||||
g.Update(this, gameTime, otherScreenHasFocus, coveredByOtherScreen);
|
||||
|
||||
foreach (AxiosTimer t in _timers)
|
||||
foreach (AxiosTimer t in _timers.ToList())
|
||||
t.Update(this, gameTime, otherScreenHasFocus, coveredByOtherScreen);
|
||||
|
||||
foreach(AxiosUIObject g in _uiobjects)
|
||||
foreach(AxiosUIObject g in _uiobjects.ToList())
|
||||
g.Update(this, gameTime, otherScreenHasFocus, coveredByOtherScreen);
|
||||
|
||||
}
|
||||
@ -208,7 +227,7 @@ namespace Axios.Engine
|
||||
base.HandleCursor(input);
|
||||
HandleMouseEvents(input);
|
||||
|
||||
foreach (AxiosGameObject g in _gameObjects)
|
||||
foreach (AxiosGameObject g in _gameObjects.ToList())
|
||||
g.HandleCursor(this, input);
|
||||
}
|
||||
|
||||
@ -329,10 +348,10 @@ namespace Axios.Engine
|
||||
{
|
||||
base.HandleInput(input, gameTime);
|
||||
|
||||
foreach (AxiosGameObject g in _gameObjects)
|
||||
foreach (AxiosGameObject g in _gameObjects.ToList())
|
||||
g.HandleInput(this, input, gameTime);
|
||||
|
||||
foreach (AxiosUIObject g in _uiobjects)
|
||||
foreach (AxiosUIObject g in _uiobjects.ToList())
|
||||
g.HandleInput(this, input, gameTime);
|
||||
}
|
||||
|
||||
|
@ -7,7 +7,10 @@ using Microsoft.Xna.Framework.Graphics;
|
||||
using FarseerPhysics.Dynamics;
|
||||
using FarseerPhysics.SamplesFramework;
|
||||
using Axios.Engine.Interfaces;
|
||||
|
||||
using FarseerPhysics.Common.Decomposition;
|
||||
using FarseerPhysics.Common;
|
||||
using FarseerPhysics.Factories;
|
||||
using FarseerPhysics.Common.PolygonManipulation;
|
||||
|
||||
namespace Axios.Engine
|
||||
{
|
||||
@ -88,5 +91,36 @@ namespace Axios.Engine
|
||||
this._draworder = value;
|
||||
}
|
||||
}
|
||||
|
||||
public void CreateBodyFromTexture(AxiosGameScreen gameScreen)
|
||||
{
|
||||
if (this.Texture != null)
|
||||
{
|
||||
uint[] data = new uint[this.Texture.Width * this.Texture.Height];
|
||||
this.Texture.GetData<uint>(data);
|
||||
Vertices vertices = PolygonTools.CreatePolygon(data, this.Texture.Width, false);
|
||||
Vector2 vector = -vertices.GetCentroid();
|
||||
vertices.Translate(ref vector);
|
||||
base.Origin = -vector;
|
||||
List<Vertices> list = BayazitDecomposer.ConvexPartition(SimplifyTools.ReduceByDistance(vertices, 4f));
|
||||
base._scale = 1f;
|
||||
Vector2 vector2 = (Vector2)(new Vector2(ConvertUnits.ToSimUnits(1)) * base._scale);
|
||||
foreach (Vertices vertices2 in list)
|
||||
{
|
||||
vertices2.Scale(ref vector2);
|
||||
}
|
||||
base.BodyPart = BodyFactory.CreateCompoundPolygon(gameScreen.World, list, 1f, BodyType.Dynamic);
|
||||
base.BodyPart.BodyType = BodyType.Dynamic;
|
||||
base.BodyPart.Position = base.Position;
|
||||
base.BodyPart.UserData = this;
|
||||
base.BodyPart.CollidesWith = Category.All;
|
||||
base.BodyPart.CollisionCategories = Category.All;
|
||||
}
|
||||
}
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
}
|
||||
}
|
||||
|
Loading…
Reference in New Issue
Block a user