protected override void OnRemoveIsoObjectFromWorld(IsoObject iso_object) { base.OnRemoveIsoObjectFromWorld(iso_object); _screenSolver.OnRemoveIsoObject(iso_object); _sortingSolver.OnRemoveIsoObject(iso_object); _warningSolver.OnRemoveIsoObject(iso_object); }
protected override void OnAddIsoObjectToWorld(IsoObject iso_object) { base.OnAddIsoObjectToWorld(iso_object); _screenSolver.OnAddIsoObject(iso_object); _sortingSolver.OnAddIsoObject(iso_object); _warningSolver.OnAddIsoObject(iso_object); }
bool IsIsoObjectVisible(IsoObject iso_object) { iso_object.GetComponentsInChildren<Renderer>(_tmpRenderers); for ( var i = 0; i < _tmpRenderers.Count; ++i ) { if ( _tmpRenderers[i].isVisible ) { return true; } } return false; }
void SetupIsoObjectDepends(IsoObject obj_a) { ClearIsoObjectDepends(obj_a); var min = obj_a.Internal.MinSector; var max = obj_a.Internal.MaxSector; for ( var y = min.y; y < max.y; ++y ) { for ( var x = min.x; x < max.x; ++x ) { var v = new Vector2(x, y); LookUpSectorDepends(v, obj_a); LookUpSectorRDepends(v, obj_a); }} }
void ClearIsoObjectDepends(IsoObject iso_object) { var their_depends_iter = iso_object.Internal.TheirDepends.GetEnumerator(); while ( their_depends_iter.MoveNext() ) { var their_iso_object = their_depends_iter.Current; if ( !their_iso_object.Internal.Dirty ) { their_depends_iter.Current.Internal.SelfDepends.Remove(iso_object); } } iso_object.Internal.SelfDepends.Clear(); iso_object.Internal.TheirDepends.Clear(); }
Bounds IsoObject3DBounds(IsoObject iso_object) { var bounds = new Bounds(); iso_object.GetComponentsInChildren<Renderer>(_tmpRenderers); if ( _tmpRenderers.Count > 0 ) { bounds = _tmpRenderers[0].bounds; for ( var i = 1; i < _tmpRenderers.Count; ++i ) { bounds.Encapsulate(_tmpRenderers[i].bounds); } } return bounds; }
void LookUpSectorRDepends(Vector2 num_pos, IsoObject obj_a) { var sec = FindSector(num_pos); if ( sec != null ) { var sec_objects_iter = sec.objects.GetEnumerator(); while ( sec_objects_iter.MoveNext() ) { var obj_b = sec_objects_iter.Current; if ( obj_a != obj_b && !obj_b.Internal.Dirty && IsIsoObjectDepends(obj_b, obj_a) ) { obj_b.Internal.SelfDepends.Add(obj_a); obj_a.Internal.TheirDepends.Add(obj_b); } } } }
bool UpdateIsoObjectBounds3d(IsoObject iso_object) { if ( iso_object.mode == IsoObject.Mode.Mode3d ) { var bounds3d = IsoObject3DBounds(iso_object); var offset3d = iso_object.transform.position.z - bounds3d.center.z; if ( iso_object.Internal.Bounds3d.extents != bounds3d.extents || !Mathf.Approximately(iso_object.Internal.Offset3d, offset3d) ) { iso_object.Internal.Bounds3d = bounds3d; iso_object.Internal.Offset3d = offset3d; return true; } } return false; }
// --------------------------------------------------------------------- // // Internal // // --------------------------------------------------------------------- public void Internal_MarkDirty(IsoObject iso_object) { if (_screenSolver.OnMarkDirtyIsoObject(iso_object)) { Internal_SetDirtyInEditorMode(); } if (_sortingSolver.OnMarkDirtyIsoObject(iso_object)) { Internal_SetDirtyInEditorMode(); } if (_warningSolver.OnMarkDirtyIsoObject(iso_object)) { Internal_SetDirtyInEditorMode(); } }
float RecursivePlaceIsoObject(IsoObject iso_object, float depth) { if ( iso_object.Internal.Visited ) { return depth; } iso_object.Internal.Visited = true; var self_depends_iter = iso_object.Internal.SelfDepends.GetEnumerator(); while ( self_depends_iter.MoveNext() ) { depth = RecursivePlaceIsoObject(self_depends_iter.Current, depth); } if ( iso_object.mode == IsoObject.Mode.Mode3d ) { var zoffset = iso_object.Internal.Offset3d; var extents = iso_object.Internal.Bounds3d.extents.z; PlaceIsoObject(iso_object, depth + extents + zoffset); return depth + extents * 2.0f + stepDepth; } else { PlaceIsoObject(iso_object, depth); return depth + stepDepth; } }
void PlaceIsoObject(IsoObject iso_object, float depth) { var trans = iso_object.transform; trans.position = IsoUtils.Vec3ChangeZ(trans.position, depth); }
bool IsIsoObjectDepends(IsoObject a, IsoObject b) { return a.Internal.ScreenRect.Overlaps(b.Internal.ScreenRect) && IsIsoObjectDepends(a.position, a.size, b.position, b.size); }
public void RemoveIsoObject(IsoObject iso_object) { ClearIsoObjectDepends(iso_object); _objects.Remove(iso_object); _visibles.Remove(iso_object); _oldVisibles.Remove(iso_object); }
public void AddIsoObject(IsoObject iso_object) { _objects.Add(iso_object); }
public void MarkDirty(IsoObject iso_object) { if ( !iso_object.Internal.Dirty && _visibles.Contains(iso_object) ) { iso_object.Internal.Dirty = true; MarkDirty(); } }
public bool Internal_IsVisible(IsoObject iso_object) { return(_screenSolver.curVisibles.Contains(iso_object)); }