public IEntityShape AddShape(IEntity entity, PointF position) { if (entity == null) { throw new ArgumentNullException(nameof(entity)); } IEntityShape result = null; if (Instance is IEntityShapesContainer container && Instance is IThreatModelChild child && GetEntityShape(entity.Id) == null) { if (_entities == null) { _entities = new List <IEntityShape>(); } result = new EntityShape(child.Model, entity) { Position = position }; _entities.Add(result); if (Instance is IDirty dirtyObject) { dirtyObject.SetDirty(); } _entityShapeAdded?.Invoke(container, result); } return(result); }
private void EntityShapeAdded(IEntityShapesContainer container, IEntityShape entityShape) { if (entityShape?.Identity is IDataStore dataStore) { HandleEntityShapeEvent(dataStore); } }
private void EntityShapeAdded(IEntityShapesContainer container, IEntityShape entityShape) { if (entityShape?.Identity is IExternalInteractor externalInteractor) { HandleEntityShapeEvent(externalInteractor); } }
public IEntityShape AddShape(IEntity entity, PointF position) { if (!(IsInitialized?.Get() ?? false)) { return(null); } if (entity == null) { throw new ArgumentNullException(nameof(entity)); } IEntityShape result = null; if (GetEntityShape(entity.Id) == null) { if (_entities == null) { _entities = new List <IEntityShape>(); } result = new EntityShape(Model?.Get(), entity) { Position = position }; _entities.Add(result); Dirty.IsDirty = true; _entityShapeAdded?.Invoke(EntityShapesContainer?.Get(), result); } return(result); }
private void EntityShapeAdded(IEntityShapesContainer container, IEntityShape entityShape) { if (entityShape?.Identity is IProcess process) { HandleEntityShapeEvent(process); } }
public void Add([NotNull] IEntityShape entityShape) { if (entityShape.Identity is IThreatModelChild child && child.Model != _model) { throw new ArgumentException(); } _entities.Add(entityShape); }
/// <summary> /// Apparel the specified aryEquip. /// </summary> /// <param name="aryEquip">Ary equip.</param> public virtual void Apparel(List<int> aryEquip, IEntityShape entityShape) { foreach(int equip in aryEquip) { SqlItem sqlItem = GameSqlLite.GetSingleton().Query<SqlItem>(equip); if (!string.IsNullOrEmpty(sqlItem.Url)) { // load the equip mesh object m_ResourceManager.LoadAssetBundleFromStream(sqlItem.Url, delegate(string szMeshName, AssetBundleResource abMeshFile) { // load the equip mesh GameObject mesh = abMeshFile.GetAsset<GameObject>(sqlItem.Url); if (!mesh) throw new System.NullReferenceException(sqlItem.Url); if (sqlItem.Part != (int)PartType.PT_ARM) { // load the equip mesh object m_ResourceManager.LoadAssetBundleFromStream(sqlItem.ExtendUrl, delegate(string szBoneName, AssetBundleResource abBoneFile) { StringHolder holder = abBoneFile.GetAsset<StringHolder>(sqlItem.ExtendUrl); if (holder) entityShape.ChangeEquip((PartType)sqlItem.Part, mesh, holder); return true; }); } else { Transform mount = entityShape.GetMount(MountType.Dummy_R_HandGun); if (mount) { GameObject arm = GameObject.Instantiate(mesh) as GameObject; if (!arm) throw new System.NullReferenceException(); arm.name = mesh.name; arm.transform.parent = mount; arm.layer = entityShape.gameObject.layer; arm.transform.localPosition = Vector3.zero; arm.transform.localRotation = Quaternion.identity; arm.transform.localScale = Vector3.one; } } return true; }); } } }
public void Add(IEntityShape entityShape) { if (entityShape == null) { throw new ArgumentNullException(nameof(entityShape)); } if (_entities == null) { _entities = new List <IEntityShape>(); } _entities.Add(entityShape); }
public IEntityShape AddEntityShape(Guid entityId, PointF position) { IEntityShape result = null; if (Instance is IThreatModelChild child) { var entity = child.Model?.Entities.FirstOrDefault(x => x.Id == entityId); if (entity != null) { result = AddShape(entity, position); } } return(result); }
public void Add(IEntityShape entityShape) { if (!(IsInitialized?.Get() ?? false)) { return; } if (entityShape == null) { throw new ArgumentNullException(nameof(entityShape)); } if (_entities == null) { _entities = new List <IEntityShape>(); } _entities.Add(entityShape); }
public IEntityShape AddEntityShape(Guid entityId, PointF position) { if (!(IsInitialized?.Get() ?? false)) { return(null); } var entity = Model?.Get().Entities.FirstOrDefault(x => x.Id == entityId); IEntityShape result = null; if (entity != null) { result = AddShape(entity, position); } return(result); }
/// <summary> /// Raises the reset shape event. /// </summary> /// <param name="newShape">New shape.</param> IEnumerator OnResetShape(IEntityShape newShape) { // destroy current old entity shape if (Shape != newShape) { if (Shape) GameObject.Destroy(Shape.gameObject); } // bind new entity shape Shape = newShape; // set the shape parent Shape.SetParent( transform ); yield return new WaitForEndOfFrame(); // reset Shape.SetPosition(Vector3.zero); }
public bool RemoveShape(IEntityShape entityShape) { if (entityShape == null) { throw new ArgumentNullException(nameof(entityShape)); } var result = _entities?.Remove(entityShape) ?? false; if (result) { if (Instance is IDirty dirtyObject) { dirtyObject.SetDirty(); } if (entityShape.Identity is IEntity entity && Instance is IEntityShapesContainer container) { _entityShapeRemoved?.Invoke(container, entity); } } return(result); }
public bool RemoveShape(IEntityShape entityShape) { if (!(IsInitialized?.Get() ?? false)) { return(false); } if (entityShape == null) { throw new ArgumentNullException(nameof(entityShape)); } var result = _entities?.Remove(entityShape) ?? false; if (result) { Dirty.IsDirty = true; if (entityShape.Identity is IEntity entity) { _entityShapeRemoved?.Invoke(EntityShapesContainer?.Get(), entity); } } return(result); }
private void OnEntityShapeAdded(IEntityShapesContainer arg1, IEntityShape arg2) { _entityShapeAdded?.Invoke(arg1, arg2); }
/// <summary> /// Sets the shape. /// </summary> /// <param name="shape">Shape.</param> public virtual void SetShape(IEntityShape newShape) { StartCoroutine(OnResetShape(newShape)); }
public bool RemoveShape(IEntityShape entityShape) { return(false); }
public GraphEntity([NotNull] IEntityShape shape, DpiState dpiState) : base() { _shape = shape; _dpiState = dpiState; var identity = shape.Identity; if (identity is IEntity entity) { Initialize(Icons.Resources.ResourceManager, GetIconName(entity), entity.Name); if (_imageSize == ImageSize.Big) { if (entity.BigImage != null && Icon is GoImage icon) { icon.Image = entity.BigImage; } Icon.Size = new SizeF(64.0f, 64.0f); } else { if (entity.Image != null && Icon is GoImage icon) { icon.Image = entity.Image; } Icon.Size = new SizeF(32.0f, 32.0f); } entity.ImageChanged += OnEntityImageChanged; //InPort.ToSpot = GoObject.NoSpot; //InPort.IsValidSelfNode = false; //InPort.IsValidDuplicateLinks = false; //OutPort.FromSpot = GoObject.NoSpot; //OutPort.IsValidSelfNode = false; //OutPort.IsValidDuplicateLinks = false; Port.Size = new SizeF(15f, 15f); Icon.Resizable = false; Reshapable = false; _threatsMarker = new AssociatedThreatsMarker(entity) { Position = new PointF(Icon.Size.Width / 2.0f, Icon.Size.Height / 2.0f), }; _threatsMarker.ThreatEventClicked += OnThreatEventClicked; Add(_threatsMarker); _diagramMarker = new AssociatedDiagramMarker(entity) { Position = new PointF(16.0f * Dpi.Factor.Width, 0), }; _diagramMarker.DiagramClicked += OnDiagramClicked; Add(_diagramMarker); _warningMarker = new WarningMarker() { Position = new PointF(0.0f, 16.0f * Dpi.Factor.Height), }; Add(_warningMarker); switch (_dpiState) { case DpiState.TooSmall: Location = new PointF(_shape.Position.X * 2, _shape.Position.Y * 2); break; case DpiState.TooBig: Location = new PointF(_shape.Position.X / 2, _shape.Position.Y / 2); break; default: Location = _shape.Position; break; } Copyable = false; AddObserver(this); // ReSharper disable once SuspiciousTypeConversion.Global ((INotifyPropertyChanged)identity).PropertyChanged += OnPropertyChanged; } else { throw new ArgumentException(Properties.Resources.ShapeNotEntityError); } }