remove ur from components
This commit is contained in:
parent
1143b9b3dc
commit
7984c90140
|
@ -87,6 +87,7 @@ Object.isAccessor = function(obj, prop)
|
|||
|
||||
Object.mergekey = function(o1,o2,k)
|
||||
{
|
||||
if (!o2) return;
|
||||
if (Object.isAccessor(o2,k))
|
||||
Object.defineProperty(o1, k, Object.getOwnPropertyDescriptor(o2,k));
|
||||
else if (typeof o2[k] === 'object') {
|
||||
|
@ -94,7 +95,10 @@ Object.mergekey = function(o1,o2,k)
|
|||
o1[k] = o2[k].slice();
|
||||
else {
|
||||
if (!o1[k]) o1[k] = {};
|
||||
Object.merge(o1[k], o2[k]);
|
||||
if (typeof o1[k] === 'object')
|
||||
Object.merge(o1[k], o2[k]);
|
||||
else
|
||||
o1[k] = o2[k];
|
||||
}
|
||||
} else
|
||||
o1[k] = o2[k];
|
||||
|
|
|
@ -54,8 +54,6 @@ var component = {
|
|||
},
|
||||
};
|
||||
|
||||
//component.toJSON = ur_json;
|
||||
|
||||
component.sprite = {
|
||||
pos:[0,0],
|
||||
color:[1,1,1],
|
||||
|
@ -353,8 +351,6 @@ collider2d.inputs['M-t'] = function() { this.enabled = !this.enabled; }
|
|||
collider2d.inputs['M-t'].doc = "Toggle if this collider is enabled.";
|
||||
|
||||
component.polygon2d = Object.copy(collider2d, {
|
||||
points: [],
|
||||
|
||||
ur: {
|
||||
flipx: false,
|
||||
flipy: false
|
||||
|
@ -371,11 +367,10 @@ component.polygon2d = Object.copy(collider2d, {
|
|||
make(go) {
|
||||
var poly = Object.create(this);
|
||||
poly.gameobject = go;
|
||||
Object.assign(poly, make_poly2d(go.body, this.points));
|
||||
poly.defn('points', this.points.copy());
|
||||
|
||||
poly.sync();
|
||||
|
||||
poly.points = [];
|
||||
poly.flipx = false;
|
||||
poly.flipy = false;
|
||||
Object.assign(poly, make_poly2d(go.body, poly.points));
|
||||
return poly;
|
||||
},
|
||||
|
||||
|
@ -726,8 +721,7 @@ component.circle2d = Object.copy(collider2d, {
|
|||
make(go) {
|
||||
var circle = Object.create(this);
|
||||
circle.gameobject = go;
|
||||
Object.assign(circle, make_circle2d(go.body, circle.radius, circle.offset));
|
||||
Object.merge(circle, this.ur);
|
||||
Object.assign(circle, make_circle2d(go.body));
|
||||
|
||||
return circle;
|
||||
},
|
||||
|
|
|
@ -770,7 +770,10 @@ editor.inputs.escape.doc = "Quit editor.";
|
|||
|
||||
editor.inputs['C-s'] = function() {
|
||||
if (editor.selectlist.length !== 1 || !editor.selectlist[0].dirty) return;
|
||||
Log.warn(JSON.stringify(editor.selectlist[0],null,1));
|
||||
Log.warn(JSON.stringify(editor.selectlist[0].ur,null,1));
|
||||
Object.merge(editor.selectlist[0].ur, editor.selectlist[0].json_obj());
|
||||
Log.warn(JSON.stringify(editor.selectlist[0].ur,null,1));
|
||||
var path = editor.selectlist[0].toString();
|
||||
path = path.replaceAll('.','/');
|
||||
path = path + "/" + path.name() + ".json";
|
||||
|
|
|
@ -550,11 +550,6 @@ var ur_json = function()
|
|||
if (typeof to === 'object' && !(key in to)) continue;
|
||||
|
||||
if (typeof from[key] === 'object') {
|
||||
if ('ur' in from[key]) {
|
||||
var urdiff = objdiff(from[key],from[key].ur);
|
||||
if (urdiff && !urdiff.empty) ret[key] = urdiff;
|
||||
continue;
|
||||
}
|
||||
var diff = objdiff(from[key], to[key]);
|
||||
if (diff && !diff.empty) ret[key] = diff;
|
||||
continue;
|
||||
|
@ -572,45 +567,8 @@ var ur_json = function()
|
|||
return ur ? ur : {};
|
||||
}
|
||||
|
||||
|
||||
load("scripts/components.js");
|
||||
|
||||
function replacer_empty_nil(key, val) {
|
||||
if (typeof val === 'object' && JSON.stringify(val) === '{}')
|
||||
return undefined;
|
||||
|
||||
// if (typeof val === 'number')
|
||||
// return parseFloat(val.toFixed(4));
|
||||
|
||||
return val;
|
||||
};
|
||||
|
||||
function clean_object(obj) {
|
||||
Object.keys(obj).forEach(function(x) {
|
||||
if (!(x in obj.__proto__)) return;
|
||||
|
||||
switch(typeof obj[x]) {
|
||||
case 'object':
|
||||
if (Array.isArray(obj[x])) {
|
||||
if (obj[x].equal(obj.__proto__[x])) {
|
||||
delete obj[x];
|
||||
}
|
||||
} else
|
||||
clean_object(obj[x]);
|
||||
|
||||
break;
|
||||
|
||||
case 'function':
|
||||
return;
|
||||
|
||||
default:
|
||||
if (obj[x] === obj.__proto__[x])
|
||||
delete obj[x];
|
||||
break;
|
||||
}
|
||||
});
|
||||
};
|
||||
|
||||
function find_com(objects)
|
||||
{
|
||||
if (!objects || objects.length === 0)
|
||||
|
|
|
@ -360,10 +360,11 @@ var gameobject = {
|
|||
obj[prop] = obj.spawn(prototypes.get_ur(p.ur));
|
||||
obj.$[prop] = obj[prop];
|
||||
} else if ('comp' in p) {
|
||||
Log.warn(`spawning a ${p.comp}`);
|
||||
obj[prop] = component[p.comp].make(obj);
|
||||
obj.components[prop] = obj[prop];
|
||||
obj[prop].ur = Object.create(obj[prop].ur);
|
||||
Object.totalmerge(obj[prop].ur, p);
|
||||
// obj[prop].ur = Object.create(obj[prop].ur);
|
||||
// Object.totalmerge(obj[prop].ur, p);
|
||||
}
|
||||
};
|
||||
|
||||
|
|
|
@ -29,7 +29,7 @@ var Log = {
|
|||
var lmatch = nnn.match(/\:\d*\)/);
|
||||
var line = lmatch ? lmatch[0].shift(1).shift(-1) : "0";
|
||||
|
||||
yughlog(lvl, msg, file, line);
|
||||
yughlog(lvl, lg, file, line);
|
||||
},
|
||||
|
||||
info(msg) {
|
||||
|
|
|
@ -203,6 +203,7 @@ struct phys2d_circle *Make2DCircle(int go) {
|
|||
new->shape.moi = phys2d_circle_moi;
|
||||
new->shape.apply = phys2d_applycircle;
|
||||
init_phys2dshape(&new->shape, go, new);
|
||||
phys2d_applycircle(new);
|
||||
|
||||
return new;
|
||||
}
|
||||
|
|
|
@ -51,7 +51,7 @@ static void render_audio(plm_t *mpeg, plm_samples_t *samples, void *user) {
|
|||
}
|
||||
|
||||
void ds_openvideo(struct datastream *ds, const char *video, const char *adriver) {
|
||||
long rawlen;
|
||||
size_t rawlen;
|
||||
void *raw;
|
||||
raw = slurp_file(video, &rawlen);
|
||||
ds->plm = plm_create_with_memory(raw, rawlen, 0);
|
||||
|
|
|
@ -1458,13 +1458,8 @@ JSValue duk_cmd_box2d(JSContext *js, JSValueConst this, int argc, JSValueConst *
|
|||
|
||||
JSValue duk_make_circle2d(JSContext *js, JSValueConst this, int argc, JSValueConst *argv) {
|
||||
int go = js2int(argv[0]);
|
||||
double radius = js2number(argv[1]);
|
||||
|
||||
struct phys2d_circle *circle = Make2DCircle(go);
|
||||
circle->radius = radius;
|
||||
circle->offset = js2vec2(argv[2]);
|
||||
|
||||
phys2d_applycircle(circle);
|
||||
|
||||
JSValue circleval = JS_NewObject(js);
|
||||
JS_SetPropertyStr(js, circleval, "id", ptr2js(circle));
|
||||
|
@ -1657,7 +1652,7 @@ void ffi_load() {
|
|||
|
||||
DUK_FUNC(make_box2d, 3)
|
||||
DUK_FUNC(cmd_box2d, 6)
|
||||
DUK_FUNC(make_circle2d, 3)
|
||||
DUK_FUNC(make_circle2d, 1)
|
||||
DUK_FUNC(cmd_circle2d, 6)
|
||||
DUK_FUNC(make_poly2d, 2)
|
||||
DUK_FUNC(cmd_poly2d, 6)
|
||||
|
|
Loading…
Reference in a new issue