コード例 #1
0
cpSpaceAddPostStepCallback(cpSpace space, cpPostStepFunc func, object key, object data)
{
	// cpAssertWarn(space.locked,
		"Adding a post-step callback when the space is not locked is unnecessary. "
		"Post-step callbacks will not called until the end of the next call to cpSpaceStep() or the next query.");
	
	if(!cpSpaceGetPostStepCallback(space, key)){
		cpPostStepCallback *callback = (cpPostStepCallback *)cpcalloc(1, sizeof(cpPostStepCallback));
		callback.func = (func ? func : PostStepDoNothing);
		callback.key = key;
		callback.data = data;
		
		cpArrayPush(space.postStepCallbacks, callback);
		return true;
	} else {
		return false;
	}
}
コード例 #2
0
        public bool AddPostStepCallback(cpPostStepFunc func, object key, object data)
        {
            //cpPostStepCallback func
            cp.AssertSoft(this.IsLocked,
                          "Adding a post-step callback when the space is not locked is unnecessary. " +
                          "Post-step callbacks will not called until the end of the next call to cpSpaceStep() or the next query.");


            if (GetPostStepCallback(key) == null)
            {
                cpPostStepCallback callback = new cpPostStepCallback();                // (cpPostStepCallback*)cpcalloc(1, sizeof(cpPostStepCallback));
                callback.func = (func != null ? func : PostStepDoNothing);
                callback.key  = key;
                callback.data = data;
                this.postStepCallbacks.Add(callback);
                return(true);
            }
            else
            {
                return(false);
            }
        }