private void UpdatePlacer() { if (!Placer.Visible) { Placer = null; } if (!MyCubeBuilder.Static.DynamicMode && MyCubeBuilder.Static.HitInfo.HasValue) { var hit = MyCubeBuilder.Static.HitInfo.Value as IHitInfo; var grid = hit.HitEntity as MyCubeGrid; GridAi gridAi; if (grid != null && GridToMasterAi.TryGetValue(grid, out gridAi)) { if (MyCubeBuilder.Static.CurrentBlockDefinition != null) { var subtypeIdHash = MyCubeBuilder.Static.CurrentBlockDefinition.Id.SubtypeId; WeaponCount weaponCount; if (gridAi.WeaponCounter.TryGetValue(subtypeIdHash, out weaponCount)) { if (weaponCount.Max > 0 && gridAi.Construct.GetWeaponCount(subtypeIdHash) >= weaponCount.Max) { MyCubeBuilder.Static.NotifyPlacementUnable(); MyCubeBuilder.Static.Deactivate(); return; } } if (WeaponAreaRestrictions.ContainsKey(subtypeIdHash)) { MyOrientedBoundingBoxD restrictedBox; MyOrientedBoundingBoxD buildBox = MyCubeBuilder.Static.GetBuildBoundingBox(); BoundingSphereD restrictedSphere; if (IsWeaponAreaRestricted(subtypeIdHash, buildBox, grid, 0, null, out restrictedBox, out restrictedSphere)) { DsDebugDraw.DrawBox(buildBox, _uninitializedColor); } if (MyAPIGateway.Session.Config.HudState == 1) { if (restrictedBox.HalfExtent.AbsMax() > 0) { DsDebugDraw.DrawBox(restrictedBox, _restrictionAreaColor); } if (restrictedSphere.Radius > 0) { DsDebugDraw.DrawSphere(restrictedSphere, _restrictionAreaColor); } for (int i = 0; i < gridAi.Weapons.Count; i++) { MyOrientedBoundingBoxD b; BoundingSphereD s; CoreComponent Comp = gridAi.Weapons[i]; MyOrientedBoundingBoxD blockBox; SUtils.GetBlockOrientedBoundingBox(Comp.MyCube, out blockBox); CalculateRestrictedShapes(Comp.MyCube.BlockDefinition.Id.SubtypeId, blockBox, out b, out s); if (s.Radius > 0) { DsDebugDraw.DrawSphere(s, _restrictionAreaColor); } if (b.HalfExtent.AbsMax() > 0) { DsDebugDraw.DrawBox(b, _restrictionAreaColor); } } } } } } } }